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

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

9
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring 
10
ifeq ($(PXP_WLEX), true)
11
  PACKAGES += pxp-wlex-utf8
12
else
13
  PACKAGES += pxp-lex-utf8
14
endif
15

16
17
18
19
20
21
22
23
24
25
26

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

VERBOSE=false

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

27

28
SYNTAX = -I misc/ q_symbol.cmo \
29
  -symbol cduce_version=\"$(VERSION)\" \
30
31
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
32

33
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
34

35
CAMLC_P = ocamlc -g
36
DEPEND_OCAMLDEP = misc/q_symbol.cmo
37
ifeq ($(PROFILE), true)
38
39
40
41
42
43
  CAMLOPT_P = ocamlopt -p
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
44
else
45
  CAMLOPT_P = ocamlopt -inline 25
46
47
endif

48
OPT = -warn-error FPS
49
50
51
52
53
54
55
56
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
57
58
59
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
60
61

ifeq ($(NATIVE), true)
62
63
64
65
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
66
  SYNTAX += -symbol ocaml_compiler=\"native\"
67
else
68
69
70
71
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
72
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
73
74
endif

75

76
INSTALL := install
77
78

ifeq ($(NATIVE),true)
79
.PHONY: cduce_lib.cma
80
81
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
82
83
endif

84
85
86
install: all install_bin install_lib install_doc

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

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

102

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

112
113
114
115
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
116
	@echo "  cduce_validate : compiles the schema validation tool"
117
118
119
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
120
121
122
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

123
124
# Source directories 

125
126
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
127
128
129

# Objects to build

130
SCHEMA_OBJS = \
131
 schema/schema_pcre.cmo \
132
133
134
135
136
137
138
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \

139
140
141
NEW_SCHEMA_OBJS = \
 schema/schema_components.cmo schema/schema_import.cmo \

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

179
180
181
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

182
ML_INTERFACE_OBJS = \
183
184
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
185
186
187
188
189
190
191
192
193
194
195
196
197
198

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

199
200
OBJECTS += runtime/cduce_pxp.cmo

201
202
203
204
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
205

206

207
CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
208
CQL_OBJECTS_RUN = query/query_run.cmo
209

210
211
OBJECTS += $(CQL_OBJECTS)

212
213
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

214
215
OBJECTS += $(CQL_OBJECTS_RUN) driver/run.cmo
CDUCE = $(OBJECTS) driver/start.cmo 
216
217
DTD2CDUCE = tools/dtd2cduce.cmo

218
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
219
 driver/run.cmo driver/examples.cmo driver/webiface.cmo driver/evaluator.cmo \
220
 tools/dtd2cduce.cmo tools/validate.cmo \
221
222
223
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
 runtime/cduce_expat.cmo \
224
 $(CQL_OBJECTS_RUN)
225
ALL_INTERFACES = schema/schema_types.mli 
226

227
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
228

229
230
INCLUDES = $(DIRS:%=-I %)

231
cduce: $(CDUCE:.cmo=.$(EXTENSION))
232
233
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
234

235
236
237
test_schema: $(OBJECTS:.cmo=.$(EXTENSION)) $(NEW_SCHEMA_OBJS:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
238

239

240
241
242
243
244
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
245
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
246

247

248
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
249
	@echo "Pack cduce_lib.$(EXTENSION)"
250
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
251
	@echo "Build $@"
252
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
253

254
dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
255
256
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
257

258
cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
259
260
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
261

262
263
264
265
mlcduce_wrapper: $(OBJECTS:.cmo=.$(EXTENSION)) ocamliface/mlcduce_wrapper.ml
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)

266
cdo2ml: ocamliface/cdo2ml.ml
267
	@echo "Build $@"
268
	$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^
269

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

290
291
292
distclean: clean
	rm -f Makefile.conf

293
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
294

295
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
296
$(ALL_INTERFACES): misc/q_symbol.cmo
297
298
299

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

300
misc/q_symbol.cmo: misc/q_symbol.ml
301
302
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
303

304
.ml.cmo:
305
306
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
307
308

.ml.cmx:
309
310
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
311
312

.mli.cmi:
313
314
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
315
316
317

include depend

318
# Documentation
319

320
doc: cduce web/site.cdo
321
	mkdir -p web/doc
322
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
323

324
web/site.cdo: cduce web/xhtml.cdo web/site.cd
325
	./cduce -I web/ --compile web/site.cd
326
327

web/xhtml.cdo: cduce web/xhtml.cd
328
	./cduce -I web/ --compile web/xhtml.cd
329

330
install_doc: doc
331
332
	$(HIDE)mkdir -p $(MANDIR)/man1
	$(HIDE)(cd doc; $(MAKE) install INSTALL=$(INSTALL) MANDIR=$(MANDIR) HIDE=$(HIDE))
333
334
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
335
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
336
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
337

338
339
340
341
342
343
344
345
346
347
348
349
350

### 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