Makefile.distrib 9.42 KB
Newer Older
1
2
default: cduce

3
include Makefile.conf
4
include VERSION
5

6

7
8
9
10
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
11
  INSTALL_BINARIES += cduce_mktop
12
13
endif

14
OUNIT_TESTS=eval cdnum cdsdl misc
15

16
17
18
19
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

20
PACKAGES = dynlink camlp4 ulex pcre num netstring
21
22
23

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

24
VERBOSE?=false
25
26
27
28
29
30
31

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

32

33
SYNTAX = -I misc/ q_symbol.cmo \
34
  -symbol cduce_version=\"$(VERSION)\" \
35
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
36
37
  -symbol session_dir=\"$(SESSION_DIR)\" \
  -loc "_loc"
38

39
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
40

41
CAMLC_P = ocamlc -g
42
DEPEND_OCAMLDEP = misc/q_symbol.cmo
43
ifeq ($(PROFILE), true)
44
  CAMLOPT_P = ocamlopt -p -inline 10000
45
  ifeq ($(NATIVE), false)
46
    CAMLC_P = ocamlcp -p a
47
    SYNTAX_PARSER =
48
49
    DEPEND_OCAMLDEP =
  endif
50
else
51
  CAMLOPT_P = ocamlopt -inline 10000
52
53
endif

54
OPT = -warn-error FPSXY
55
56
57
58
59
60
61
62
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
Pietro Abate's avatar
Pietro Abate committed
63
64

OCAMLFIND = ocamlfind
65
66
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
67
68

ifeq ($(NATIVE), true)
69
70
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
71
  CAML=ocamlopt
72
  COMPILE = $(CAMLOPT)
73
74
75
76
  LINK = $(CAMLOPT) -linkpkg
  ifeq ($(NATDYNLINK), true)
    LINK += dynlink.cmxa
  endif
77
78
79
  ifeq ($(ADDICON), true)
    LINK += cduceres.o
  endif
80
  LINK += camlp4lib.cmxa
81
  SYNTAX += -symbol ocaml_compiler=\"native\"
82
else
83
84
85
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
86
  CAML=ocamlc
87
  LINK = $(CAMLC) -custom -linkpkg camlp4lib.cma
88
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
89
90
endif

91
92
93
94
95
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
96

97
INSTALL := install -c
98
99

ifeq ($(NATIVE),true)
100
.PHONY: cduce_lib.cma
101
102
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
103
104
endif

105
106
107
install: all install_bin install_lib install_doc

install_bin:
108
	@echo "Install binaries"
109
	$(HIDE)mkdir -p $(BINDIR)
110
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
111

112
install_lib:
113

114
115
install_lib:
	$(HIDE)$(MAKE) NATIVE=true all
116
	@echo "Build META"
117
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
118
119
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
Julien Lopez's avatar
Julien Lopez committed
120
         lib/cduce_lib.cmi lib/cduce_lib.cma lib/cduce_lib.cmxa lib/cduce_lib.a \
121

122

123
uninstall:
124
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
125
	rm -f $(MANDIR)/man1/cduce.1
126
	rm -Rf $(DOCDIR)
127
	ocamlfind remove cduce
128

129
130
131
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
132
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
133
134
135
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
136
137
138
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

139
# Source directories
140

Karoline Malmkjaer's avatar
Karoline Malmkjaer committed
141
DIRS = misc parser schema typing types compile runtime driver query ocamliface win32
142
CLEAN_DIRS = $(DIRS) tools tests
143
144
145

# Objects to build

146
OBJECTS = \
147
 driver/cduce_config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
Pietro Abate's avatar
Pietro Abate committed
148
 misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo misc/utils.cmo \
149
 \
150
151
 types/compunit.cmo types/sortedList.cmo misc/bool.cmo types/ident.cmo \
 types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \
152
 types/var.cmo types/boolVar.cmo types/types.cmo compile/auto_pat.cmo \
153
 types/sequence.cmo types/builtin_defs.cmo \
154
155
156
 \
 runtime/value.cmo \
 \
157
158
159
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
160
 \
161
 types/patterns.cmo \
162
 compile/print_auto.cmo \
163
 \
164
165
166
 compile/lambda.cmo \
 runtime/run_dispatch.cmo runtime/explain.cmo runtime/eval.cmo \
 \
167
 parser/cduce_loc.cmo  parser/url.cmo \
168
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
169
 \
170
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
171
 compile/compile.cmo \
172
 \
173
174
175
 schema/schema_parser.cmo schema/schema_converter.cmo \
 runtime/load_xml.cmo runtime/print_xml.cmo compile/operators.cmo types/builtin.cmo \
 driver/librarian.cmo types/sample.cmo \
176
 driver/cduce.cmo \
177
178
 \
 runtime/system.cmo query/query_aggregates.cmo
179

180
181
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
182
183
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
184

185
ML_INTERFACE_OBJS = \
186
187
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
188
189
190
191
192
193

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

ifneq ($(CURL), false)
194
  OBJECTS += parser/cduce_curl.cmo
195
196
197
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
198
  OBJECTS += parser/cduce_netclient.cmo
199
200
201
  PACKAGES += netclient
endif

202
203
204
205
206
207
208
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

209
ifeq ($(PXP),true)
210
211
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
212
213
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
214
      PACKAGES += netcgi2
215
216
217
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
218
endif
219

220
ifeq ($(EXPAT), true)
221
  OBJECTS += runtime/cduce_expat.cmo
222
223
  PACKAGES += expat
endif
224

225
226
227
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
228

229
230
all: $(ALL_TARGET)

231
OBJECTS += driver/run.cmo
232
CDUCE = $(OBJECTS) driver/start.cmo
233

234
235
236
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
237
 tools/validate.cmo \
238
239
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
240
241
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

242
243
ALL_INTERFACES = schema/schema_types.mli
#types/var.mli types/boolVar.mli
244

245
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
246

247
248
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
249

250
cduce: $(CDUCE:.cmo=.$(EXTENSION))
251
252
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
253

254
255
256
257
258
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
259
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
260

261

262
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
263
	@echo "Pack cduce_lib.$(EXTENSION)"
264
265
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
266
	@echo "Build $@"
267
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
268

269
dtd2cduce: tools/dtd2cduce.ml
270
	@echo "Build $@"
271
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
272
273

.PHONY: compute_depend
274
compute_depend: $(DEPEND_OCAMLDEP)
275
	@echo "Computing dependencies ..."
276
	ocamlfind ocamldep -package "$(PACKAGES)" \
277
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
278
279
clean:
	for i in $(CLEAN_DIRS); do \
280
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
281
	done
282
	rm -f misc/q_symbol.cmo.stamp
283
	(cd ocamliface; $(MAKE) clean)
284
	rm -f `find . -name "*~"`
285
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
286
	rm -f cduce$(EXE) ocamlprof.dump
287
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
288
	rm -Rf prepro package
289
	rm -f web/www/*.html web/*~
290
	rm -f web/*.cdo
291
	rm -f configure.log
292
	rm -rf web/doc
293
	rm -f META
294
295
	rm -rf lib
	$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
296
	$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
297
	$(RM) oUnit-* tests/ocaml/misc/consts.ml tests/ocaml/misc/consts.cdo tests/ocaml/misc/consts.cmi tests/ocaml/misc/consts.cmo tests/ocaml/latypes/latypes2* tests/ocaml/latypes/latypes tests/ocaml/latypes/latypes.c[dm][oxi] tests/ocaml/latypes/latypestest.cm[io]
298
	for i in $(OUNIT_TESTS); do $(RM) `echo tests/ocaml/$$i/$$i tests/ocaml/$$i/$$i.ml tests/ocaml/$$i/$$i.c[dm][oxi] tests/ocaml/$$i/$${i}test.cm[io]`; done
299

300
301
302
distclean: clean
	rm -f Makefile.conf

303
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
304

305
$(ALL_INTERFACES): misc/q_symbol.cmo
306
307
308
309
$(ALL_OBJECTS:.cmo=.cmi): misc/q_symbol.cmo
$(ALL_OBJECTS:.cmo=.cmx) caml_cduce.cmx: misc/q_symbol.cmo
$(ALL_OBJECTS) caml_cduce.cmo: misc/q_symbol.cmo
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
310

311
misc/q_symbol.cmo: misc/q_symbol.ml
312
	@echo "Build $@"
313
314
315
316
317
318
319
	$(HIDE) $(CAMLC) -c -pp camlp4orf $<

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

types/boolVar.cmo: SYNTAX_PARSER=
types/boolVar.cmi: SYNTAX_PARSER=
types/boolVar.cmx: SYNTAX_PARSER=
320

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

325

326
.ml.cmx:
327
	@echo "Build $@"
328
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
329

330
.mli.cmi:
331
332
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
333
334
335

include depend

336
337
338
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

339
# Documentation
340

341
doc: cduce web/site.cdo
342
	mkdir -p web/doc
343
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
344

345
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
346
	./cduce -I web/ --compile web/site.cd
347
348

web/xhtml.cdo: cduce web/xhtml.cd
349
	./cduce -I web/ --compile web/xhtml.cd
350

351
install_doc: doc
352
	$(HIDE)mkdir -p $(MANDIR)/man1
353
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
354
355
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
356
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
357
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
358

359
360
361
362
363
364

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
365
	$(MAKE) caml_cduce.cmo
366
367
368

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
369
	$(MAKE) caml_cduce.cmx