Makefile.distrib 9.03 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.3b1
3

4
all: cduce dtd2cduce cdo2ml mlcduce_wrapper cduce_lib.cma
5
6
7
8
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

9
PACKAGES = ulex camlp4 num cgi pcre netstring 
10

11
12
13
14
15
16
17
18
19
20
21

# Call make with VERBOSE=true to get a trace of commands

VERBOSE=false

ifneq ($(VERBOSE), true)
   HIDE=@
else
   HIDE=
endif

22

23
SYNTAX = -I misc/ q_symbol.cmo \
24
  -symbol cduce_version=\"$(VERSION)\" \
25
26
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
27

28
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
29

30
CAMLC_P = ocamlc -g
31
DEPEND_OCAMLDEP = misc/q_symbol.cmo
32
ifeq ($(PROFILE), true)
33
34
35
36
37
38
  CAMLOPT_P = ocamlopt -p
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
39
else
40
  CAMLOPT_P = ocamlopt -inline 25
41
42
endif

43
OPT = -warn-error FPS
44
45
46
47
48
49
50
51
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
52
53
54
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
55
56

ifeq ($(NATIVE), true)
57
58
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
59
  CAML=ocamlopt
60
61
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
62
  SYNTAX += -symbol ocaml_compiler=\"native\"
63
else
64
65
66
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
67
  CAML=ocamlc
68
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
69
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
70
71
endif

72

73
INSTALL := install
74
75

ifeq ($(NATIVE),true)
76
.PHONY: cduce_lib.cma
77
78
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
79
80
endif

81
82
83
install: all install_bin install_lib install_doc

install_bin:
84
	@echo "Install binaries"
85
	$(HIDE)mkdir -p $(BINDIR)
86
	$(HIDE)$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
87
                        cdo2ml$(EXE) \
88
89
			mlcduce_wrapper$(EXE) \
			cduce_mktop $(BINDIR)/
90
	
91

92
install_lib:
93
	@echo "Build META"
94
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
95
96
97
98
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
         cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \

99

100
uninstall:
101
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
102
	  $(BINDIR)/cdo2ml$(EXE) \
103
	  $(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
104
	rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \
105
	  $(MANDIR)/man1/cdo2ml.1
106
	rm -Rf $(DOCDIR)
107
	ocamlfind remove cduce
108

109
110
111
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
112
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
113
114
115
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
116
117
118
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

119
120
# Source directories 

121
122
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
123
124
125

# Objects to build

126
SCHEMA_OBJS = \
127
 schema/schema_pcre.cmo \
128
129
130
131
132
133
134
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \

135
136
137
NEW_SCHEMA_OBJS = \
 schema/schema_components.cmo schema/schema_import.cmo \

138
OBJECTS = \
139
 driver/config.cmo \
140
 misc/stats.cmo \
141
 misc/serialize.cmo misc/custom.cmo \
142
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
143
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo misc/imap.cmo \
144
 misc/html.cmo \
145
146
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
147
148
 types/intervals.cmo \
 types/chars.cmo types/atoms.cmo \
149
 types/normal.cmo \
150
 types/types.cmo types/sample.cmo types/sequence.cmo types/patterns.cmo \
151
 types/builtin_defs.cmo \
152
 \
153
 compile/lambda.cmo \
154
155
 runtime/value.cmo \
 \
156
 parser/location.cmo  parser/url.cmo \
157
 $(SCHEMA_OBJS) \
158
 \
159
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
160
 \
161
 types/externals.cmo \
162
163
 typing/typed.cmo typing/typer.cmo \
 \
164
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
165
 runtime/explain.cmo \
166
 runtime/print_xml.cmo runtime/eval.cmo \
167
 compile/compile.cmo \
168
 compile/operators.cmo \
169
 \
170
 types/builtin.cmo \
171
 driver/librarian.cmo \
172
173
 driver/cduce.cmo \
 runtime/system.cmo
174

175
176
177
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

178
ML_INTERFACE_OBJS = \
179
180
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
181
182
183
184
185
186
187
188
189
190
191
192
193
194

ifneq ($(ML_INTERFACE), false)
  OBJECTS += $(ML_INTERFACE_OBJS)
endif

ifneq ($(CURL), false)
  OBJECTS += parser/cduce_curl.cmo
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
  OBJECTS += parser/cduce_netclient.cmo
  PACKAGES += netclient
endif

195
196
197
198
199
200
201
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

202
203
ifeq ($(PXP),true)
  OBJECTS += runtime/cduce_pxp.cmo
204
  PACKAGES += $(PXP_PACK)
205
endif
206
207
208
209
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
210

211

212
213
#CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
#CQL_OBJECTS_RUN = query/query_run.cmo
214
CQL_OBJECTS= query/query_aggregates.cmo
215
CQL_OBJECTS_RUN=
216

217
218
OBJECTS += $(CQL_OBJECTS)

219
220
VALIDATE_OBJECTS := $(shell for o in $(OBJECTS); do echo $$o; if [ "$$o" = "schema/schema_parser.cmo" ]; then exit 0; fi; done)	# all objects until schema_parser.cmo

221
222
OBJECTS += $(CQL_OBJECTS_RUN) 
OBJECTS += driver/run.cmo
223
CDUCE = $(OBJECTS) driver/start.cmo 
224

225
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
226
 driver/start.cmo driver/examples.cmo driver/webiface.cmo driver/evaluator.cmo \
227
 tools/validate.cmo \
228
229
230
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
 runtime/cduce_expat.cmo \
231
ALL_INTERFACES = schema/schema_types.mli 
232

233
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
234

235
236
INCLUDES = $(DIRS:%=-I %)

237
cduce: $(CDUCE:.cmo=.$(EXTENSION))
238
239
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
240

241
242
243
test_schema: $(OBJECTS:.cmo=.$(EXTENSION)) $(NEW_SCHEMA_OBJS:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
244

245

246
247
248
249
250
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
251
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
252

253

254
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
255
	@echo "Pack cduce_lib.$(EXTENSION)"
256
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
257
	@echo "Build $@"
258
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
259

260
dtd2cduce: tools/dtd2cduce.ml
261
	@echo "Build $@"
262
	-$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
263

264
cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
265
266
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
267

268
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
269
	@echo "Build $@"
270
	$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
271

272
cdo2ml: ocamliface/cdo2ml.ml
273
	@echo "Build $@"
274
	$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^
275

276
.PHONY: compute_depend
277
compute_depend: $(DEPEND_OCAMLDEP)
278
	echo $(DEPEND)
279
	@echo "Computing dependencies ..."
280
	ocamlfind ocamldep -package "$(PACKAGES)" \
281
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
282
283
clean:
	for i in $(CLEAN_DIRS); do \
284
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
285
	done
286
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
287
	rm -f `find . -name "*~"`
288
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
289
	rm -f cduce$(EXE) ocamlprof.dump
290
291
	rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) \
		cdo2ml$(EXE) mlcduce_wrapper$(EXE) evaluator$(EXE)
292
	rm -Rf prepro package
293
	rm -f web/www/*.html web/*~
294
	rm -f web/*.cdo
295
	rm -f configure.log
296
	rm -rf web/doc
297

298
299
300
distclean: clean
	rm -f Makefile.conf

301
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
302

303
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
304
$(ALL_INTERFACES): misc/q_symbol.cmo
305
306
307

.SUFFIXES: .ml .mli .cmo .cmi .cmx

308
misc/q_symbol.cmo: misc/q_symbol.ml
309
310
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
311

312
.ml.cmo:
313
314
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
315
316

.ml.cmx:
317
318
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
319
320

.mli.cmi:
321
322
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
323
324
325

include depend

326
# Documentation
327

328
doc: cduce web/site.cdo
329
	mkdir -p web/doc
330
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
331

332
web/site.cdo: cduce web/xhtml.cdo web/site.cd
333
	./cduce -I web/ --compile web/site.cd
334
335

web/xhtml.cdo: cduce web/xhtml.cd
336
	./cduce -I web/ --compile web/xhtml.cd
337

338
install_doc: doc
339
340
	$(HIDE)mkdir -p $(MANDIR)/man1
	$(HIDE)(cd doc; $(MAKE) install INSTALL=$(INSTALL) MANDIR=$(MANDIR) HIDE=$(HIDE))
341
342
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
343
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
344
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
345

346
347
348
349
350
351
352
353
354
355
356
357
358

### Pack OCaml modules for the CDuce/OCaml interface


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
	$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
	        HIDE=$(HIDE) caml_cduce.cmo

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
	$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
		HIDE=$(HIDE) caml_cduce.cmx