Makefile.distrib 10.9 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 40 41 42
GIT_COMMIT=$(shell test -x "$$(which git)" && git rev-parse --short HEAD)

GIT_VERSION=$(subst -devel,-devel-$(GIT_COMMIT),$(VERSION))

43
SYNTAX = -I misc/ q_symbol.cmo \
44
  -symbol cduce_version=\"$(GIT_VERSION)\" \
45
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
46 47
  -symbol session_dir=\"$(SESSION_DIR)\" \
  -loc "_loc"
48

49
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
50

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

64
OPT = -warn-error FPSXY
65 66 67 68 69 70 71 72
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
Pietro Abate's avatar
Pietro Abate committed
73

74
ifneq ($(strip $(DEBUG)),)
75
     OPT += -g
76
     SYNTAX += -symbol cduce_debug=\"$(DEBUG)\"
77 78
endif

Kim Nguyễn's avatar
Kim Nguyễn committed
79 80 81 82
ifeq ($(BIN_ANNOT), true)
     OPT += -passopt -bin-annot
endif

Pietro Abate's avatar
Pietro Abate committed
83
OCAMLFIND = ocamlfind
84 85
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
86 87

ifeq ($(NATIVE), true)
88 89
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
90
  CAML=ocamlopt
91
  COMPILE = $(CAMLOPT)
92 93 94 95
  LINK = $(CAMLOPT) -linkpkg
  ifeq ($(NATDYNLINK), true)
    LINK += dynlink.cmxa
  endif
96 97 98
  ifeq ($(ADDICON), true)
    LINK += cduceres.o
  endif
99
  LINK += camlp4lib.cmxa
100
  SYNTAX += -symbol ocaml_compiler=\"native\"
101
else
102 103 104
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
105
  CAML=ocamlc
106
  LINK = $(CAMLC) -custom -linkpkg camlp4lib.cma
107
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
108 109
endif

110 111 112 113 114
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
115

116
INSTALL := install -c
117 118

ifeq ($(NATIVE),true)
119
.PHONY: cduce_lib.cma
120 121
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
122 123
endif

124 125 126
install: all install_bin install_lib install_doc

install_bin:
127
	@echo "Install binaries"
128
	$(HIDE)mkdir -p $(BINDIR)
129
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
130

131
install_lib:
132

133 134
install_lib:
	$(HIDE)$(MAKE) NATIVE=true all
135
	@echo "Build META"
136
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
137 138
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
Julien Lopez's avatar
Julien Lopez committed
139
         lib/cduce_lib.cmi lib/cduce_lib.cma lib/cduce_lib.cmxa lib/cduce_lib.a \
140

141

142
uninstall:
143
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
144
	rm -f $(MANDIR)/man1/cduce.1
145
	rm -Rf $(DOCDIR)
146
	ocamlfind remove cduce
147

148 149 150
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
151
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
152 153 154
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
155 156 157
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

158
# Source directories
159

160
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
161
CLEAN_DIRS := $(DIRS_DEPEND) tools tests
162
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
163 164


165 166 167

# Objects to build

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

202 203
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
204 205
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
206

207
ifneq ($(CURL), false)
208
  OBJECTS += parser/cduce_curl.cmo
209 210
  PACKAGES += curl
endif
211

212
ifneq ($(NETCLIENT), false)
213
  OBJECTS += parser/cduce_netclient.cmo
214
  PACKAGES += netclient
215 216 217
  ifneq (($NETCLIENT4), false)
    SYNTAX += -symbol HAS_NETCLIENT4=true
  endif
218 219
endif

220 221 222 223 224 225 226
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

227
ifeq ($(PXP),true)
228 229
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
230 231
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
232
      PACKAGES += netcgi2
233 234 235
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
236
endif
237

238
ifeq ($(EXPAT), true)
239
  OBJECTS += runtime/cduce_expat.cmo
240 241
  PACKAGES += expat
endif
242

243 244 245
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
246

247 248
all: $(ALL_TARGET)

249
OBJECTS += driver/run.cmo
250 251 252 253 254 255

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)/%)

256

257 258 259 260 261 262 263 264
OBJECTS_NO_MLIFACE := $(OBJECTS)

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



265
CDUCE = $(OBJECTS) driver/start.cmo
266

267
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
268 269
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
270
 tools/validate.cmo \
271
 parser/cduce_curl.cmo \
272
 parser/cduce_netclient.cmo \
273 274
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

275
ALL_INTERFACES = schema/schema_types.mli
276

277
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
278

279
INCLUDES = $(DIRS:%=-I %)
280 281
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)

282
# -I +camlp4
283

284
cduce: $(CDUCE:.cmo=.$(EXTENSION))
285 286
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
287

288 289 290 291 292
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
293
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
294

295

296
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
297
	@echo "Pack cduce_lib.$(EXTENSION)"
298 299
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
300
	@echo "Build $@"
301
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
302

303
dtd2cduce: tools/dtd2cduce.ml
304
	@echo "Build $@"
305
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
306 307

.PHONY: compute_depend
308

309
compute_depend: $(DEPEND_OCAMLDEP)
310
	@echo "Computing dependencies ..."
311
	ocamlfind ocamldep -package "$(PACKAGES)" \
312 313
		$(INCLUDES_DEPEND) $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo $(DEPEND) > depend
	for i in $(ALL_ML_IFACE); do \
314
	touch ocamliface/$$i/caml_cduce.ml; \
315 316 317
	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;\
318
        rm -f ocamliface/$$i/caml_cduce.ml; \
319 320
        done

321 322
clean:
	for i in $(CLEAN_DIRS); do \
Kim Nguyễn's avatar
Kim Nguyễn committed
323
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *.cmt *.cmti *~); \
324
	done
325 326
	rm -f misc/q_symbol.cmo.stamp
	test -n "$(OCAMLIFACE)" && (cd $(OCAMLIFACE); $(MAKE) clean) || true
327
	rm -f `find . -name "*~"`
Kim Nguyễn's avatar
Kim Nguyễn committed
328
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.cmt *.cmti *.o *~ META
329
	rm -f cduce$(EXE) ocamlprof.dump
330
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
331
	rm -Rf prepro package
332
	rm -f web/www/*.html web/*~
333
	rm -f web/*.cdo
334
	rm -f configure.log
335
	rm -rf web/doc
336
	rm -f META
337 338
	rm -rf lib
	$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
339
	$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
340
	$(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]
341
	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
342

343 344 345
distclean: clean
	rm -f Makefile.conf

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

348
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
349

350 351 352 353
$(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
354
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
355

356
misc/q_symbol.cmo: misc/q_symbol.ml
357
	@echo "Build $@"
358
	$(HIDE) $(CAMLC) -c -pp camlp4orf $<
359 360


361
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
362

363
.ml.cmo:
364
	@echo "Build $@"
365
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
366

367

368
.ml.cmx:
369
	@echo "Build $@"
370
	$(HIDE) $(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
371

372
.mli.cmi:
373
	@echo "Build $@"
374
	$(HIDE) $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
375 376 377

include depend

378 379 380
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

Kim Nguyễn's avatar
Kim Nguyễn committed
381 382 383 384 385 386 387 388 389 390 391 392

.merlin:
	rm -f .merlin
	for m in S B; do \
		for i in $(DIRS); do \
			  echo "$$m $$i" >> .merlin; \
		done; \
	done; \
	for p in $(PACKAGES); do \
		echo "PKG $$p" >> .merlin; \
	done

393
# Documentation
394

395
doc: cduce web/site.cdo
396
	mkdir -p web/doc
397
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
398

399
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
400
	./cduce -I web/ --compile web/site.cd
401 402

web/xhtml.cdo: cduce web/xhtml.cd
403
	./cduce -I web/ --compile web/xhtml.cd
404

405
install_doc: doc
406
	$(HIDE)mkdir -p $(MANDIR)/man1
407
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
408 409
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
410
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
411
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
412

413 414 415 416

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


417
$(OCAMLIFACE)/caml_cduce.cmo:
418
	@echo "Build $@"
419
	@cd $(OCAMLIFACE); \
420
	$(MAKE) -s MODE=byte CAMLC="$(OCAMLFIND) $(CAMLC_P)" caml_cduce.cmo
421

422
$(OCAMLIFACE)/caml_cduce.cmx:
423
	@echo "Build $@"
424
	@cd $(OCAMLIFACE); \
425
	$(MAKE) -s MODE=opt  CAMLOPT="$(OCAMLFIND) $(CAMLOPT_P)" caml_cduce.cmx
426