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

3
include Makefile.conf
4
include VERSION
5

6 7 8 9 10
ifneq ($(ML_INTERFACE), false)
	OCAMLIFACE=ocamliface/$(ML_INTERFACE_VERSION)
else
	OCAMLIFACE=
endif
11

12 13 14 15
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
16
  INSTALL_BINARIES += cduce_mktop
17 18
endif

19
OUNIT_TESTS=eval cdnum cdsdl misc
20

21
ifeq ($(NATIVE),true)
22
ALL_TARGET += cduce_lib.cmxa
23 24
endif

25
PACKAGES = dynlink camlp4 ulex pcre num netstring
26
ALL_ML_IFACE = 3.x 4.01 4.02
27 28 29

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

30
VERBOSE?=false
31 32 33 34 35 36 37

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

38

39
SYNTAX = -I misc/ q_symbol.cmo \
40
  -symbol cduce_version=\"$(VERSION)\" \
41
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
42 43
  -symbol session_dir=\"$(SESSION_DIR)\" \
  -loc "_loc"
44

45
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
46

47
CAMLC_P = ocamlc -g
48
DEPEND_OCAMLDEP = misc/q_symbol.cmo
49
ifeq ($(PROFILE), true)
50
  CAMLOPT_P = ocamlopt -p -inline 100
51
  ifeq ($(NATIVE), false)
52
    CAMLC_P = ocamlcp -p a
53
    SYNTAX_PARSER =
54 55
    DEPEND_OCAMLDEP =
  endif
56
else
57
  CAMLOPT_P = ocamlopt -inline 100
58 59
endif

60
OPT = -warn-error FPSXY
61 62 63 64 65 66 67 68
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
Pietro Abate's avatar
Pietro Abate committed
69

70
ifneq ($(strip $(DEBUG)),)
71
     OPT += -g
72
     SYNTAX += -symbol cduce_debug=\"$(DEBUG)\"
73 74
endif

Pietro Abate's avatar
Pietro Abate committed
75
OCAMLFIND = ocamlfind
76 77
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
78 79

ifeq ($(NATIVE), true)
80 81
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
82
  CAML=ocamlopt
83
  COMPILE = $(CAMLOPT)
84 85 86 87
  LINK = $(CAMLOPT) -linkpkg
  ifeq ($(NATDYNLINK), true)
    LINK += dynlink.cmxa
  endif
88 89 90
  ifeq ($(ADDICON), true)
    LINK += cduceres.o
  endif
91
  LINK += camlp4lib.cmxa
92
  SYNTAX += -symbol ocaml_compiler=\"native\"
93
else
94 95 96
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
97
  CAML=ocamlc
98
  LINK = $(CAMLC) -custom -linkpkg camlp4lib.cma
99
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
100 101
endif

102 103 104 105 106
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
107

108
INSTALL := install -c
109 110

ifeq ($(NATIVE),true)
111
.PHONY: cduce_lib.cma
112 113
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
114 115
endif

116 117 118
install: all install_bin install_lib install_doc

install_bin:
119
	@echo "Install binaries"
120
	$(HIDE)mkdir -p $(BINDIR)
121
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
122

123
install_lib:
124

125 126
install_lib:
	$(HIDE)$(MAKE) NATIVE=true all
127
	@echo "Build META"
128
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
129 130
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
Julien Lopez's avatar
Julien Lopez committed
131
         lib/cduce_lib.cmi lib/cduce_lib.cma lib/cduce_lib.cmxa lib/cduce_lib.a \
132

133

134
uninstall:
135
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
136
	rm -f $(MANDIR)/man1/cduce.1
137
	rm -Rf $(DOCDIR)
138
	ocamlfind remove cduce
139

140 141 142
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
143
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
144 145 146
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
147 148 149
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

150
# Source directories
151

152
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
153
CLEAN_DIRS := $(DIRS_DEPEND) tools tests
154
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
155 156


157 158 159

# Objects to build

160
OBJECTS = \
161
 driver/cduce_config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
162
 misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo misc/utils.cmo \
163
 \
164
 types/compunit.cmo types/sortedList.cmo types/ident.cmo types/var.cmo misc/bool.cmo  \
165
 types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \
166
 types/types.cmo compile/auto_pat.cmo \
167
 types/sequence.cmo types/builtin_defs.cmo \
168 169 170
 \
 runtime/value.cmo \
 \
171 172 173
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
174
 \
175
 types/patterns.cmo \
176
 compile/print_auto.cmo \
177
 \
178 179 180
 compile/lambda.cmo \
 runtime/run_dispatch.cmo runtime/explain.cmo runtime/eval.cmo \
 \
181
 parser/cduce_loc.cmo  parser/url.cmo \
182
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
183
 \
184
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
185
 compile/compile.cmo \
186
 \
187 188 189
 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 \
190
 driver/cduce.cmo \
191 192
 \
 runtime/system.cmo query/query_aggregates.cmo
193

194 195
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
196 197
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
198

199
ifneq ($(CURL), false)
200
  OBJECTS += parser/cduce_curl.cmo
201 202
  PACKAGES += curl
endif
203

204
ifneq ($(NETCLIENT), false)
205
  OBJECTS += parser/cduce_netclient.cmo
206 207 208
  PACKAGES += netclient
endif

209 210 211 212 213 214 215
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

216
ifeq ($(PXP),true)
217 218
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
219 220
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
221
      PACKAGES += netcgi2
222 223 224
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
225
endif
226

227
ifeq ($(EXPAT), true)
228
  OBJECTS += runtime/cduce_expat.cmo
229 230
  PACKAGES += expat
endif
231

232 233 234
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
235

236 237
all: $(ALL_TARGET)

238
OBJECTS += driver/run.cmo
239 240 241 242 243 244

ML_INTERFACE_BASE_OBJS = caml_cduce.cmo mltypes.cmo mlstub.cmo
ML_INTERFACE_BASE_SRC = $(ML_INTERFACE_BASE_OBJS:.cmo=.ml) $(ML_INTERFACE_BASE_OBJS:.cmo=.mli)
ML_INTERFACE_OBJS = \
   $(ML_INTERFACE_BASE_OBJS:%=$(OCAMLIFACE)/%)

245

246 247 248 249 250 251 252 253
OBJECTS_NO_MLIFACE := $(OBJECTS)

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



254
CDUCE = $(OBJECTS) driver/start.cmo
255

256
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
257 258
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
259
 tools/validate.cmo \
260
 parser/cduce_curl.cmo \
261
 parser/cduce_netclient.cmo \
262 263
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

264
ALL_INTERFACES = schema/schema_types.mli
265

266
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
267

268
INCLUDES = $(DIRS:%=-I %)
269 270
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)

271
# -I +camlp4
272

273
cduce: $(CDUCE:.cmo=.$(EXTENSION))
274 275
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
276

277 278 279 280 281
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
282
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
283

284

285
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
286
	@echo "Pack cduce_lib.$(EXTENSION)"
287 288
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
289
	@echo "Build $@"
290
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
291

292
dtd2cduce: tools/dtd2cduce.ml
293
	@echo "Build $@"
294
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
295 296

.PHONY: compute_depend
297

298
compute_depend: $(DEPEND_OCAMLDEP)
299
	@echo "Computing dependencies ..."
300
	ocamlfind ocamldep -package "$(PACKAGES)" \
301 302
		$(INCLUDES_DEPEND) $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo $(DEPEND) > depend
	for i in $(ALL_ML_IFACE); do \
303
	touch ocamliface/$$i/caml_cduce.ml; \
304 305 306
	ocamlfind ocamldep -package "$(PACKAGES)" \
	     $(INCLUDES_DEPEND) -I ocamliface/$$i $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo \
	     $(ML_INTERFACE_BASE_SRC:%=ocamliface/$$i/%) >> depend;\
307
        rm -f ocamliface/$$i/caml_cduce.ml; \
308 309
        done

310 311
clean:
	for i in $(CLEAN_DIRS); do \
312
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
313
	done
314 315
	rm -f misc/q_symbol.cmo.stamp
	test -n "$(OCAMLIFACE)" && (cd $(OCAMLIFACE); $(MAKE) clean) || true
316
	rm -f `find . -name "*~"`
317
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
318
	rm -f cduce$(EXE) ocamlprof.dump
319
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
320
	rm -Rf prepro package
321
	rm -f web/www/*.html web/*~
322
	rm -f web/*.cdo
323
	rm -f configure.log
324
	rm -rf web/doc
325
	rm -f META
326 327
	rm -rf lib
	$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
328
	$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
329
	$(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]
330
	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
331

332 333 334
distclean: clean
	rm -f Makefile.conf

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

337
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
338

339 340 341 342
$(ALL_INTERFACES): misc/q_symbol.cmo
$(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
343
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
344

345
misc/q_symbol.cmo: misc/q_symbol.ml
346
	@echo "Build $@"
347
	$(HIDE) $(CAMLC) -c -pp camlp4orf $<
348 349


350
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
351

352
.ml.cmo:
353
	@echo "Build $@"
354
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
355

356

357
.ml.cmx:
358
	@echo "Build $@"
359
	$(HIDE) $(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
360

361
.mli.cmi:
362
	@echo "Build $@"
363
	$(HIDE) $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
364 365 366

include depend

367 368 369
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

370
# Documentation
371

372
doc: cduce web/site.cdo
373
	mkdir -p web/doc
374
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
375

376
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
377
	./cduce -I web/ --compile web/site.cd
378 379

web/xhtml.cdo: cduce web/xhtml.cd
380
	./cduce -I web/ --compile web/xhtml.cd
381

382
install_doc: doc
383
	$(HIDE)mkdir -p $(MANDIR)/man1
384
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
385 386
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
387
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
388
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
389

390 391 392 393

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


394
$(OCAMLIFACE)/caml_cduce.cmo:
395
	@echo "Build $@"
396
	@cd $(OCAMLIFACE); \
397
	$(MAKE) -s MODE=byte CAMLC="$(OCAMLFIND) $(CAMLC_P)" caml_cduce.cmo
398

399
$(OCAMLIFACE)/caml_cduce.cmx:
400
	@echo "Build $@"
401
	@cd $(OCAMLIFACE); \
402
	$(MAKE) -s MODE=opt  CAMLOPT="$(OCAMLFIND) $(CAMLOPT_P)" caml_cduce.cmx
403