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

OCAMLFIND = ocamlfind
71 72
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
73 74

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

97 98 99 100 101
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
102

103
INSTALL := install -c
104 105

ifeq ($(NATIVE),true)
106
.PHONY: cduce_lib.cma
107 108
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
109 110
endif

111 112 113
install: all install_bin install_lib install_doc

install_bin:
114
	@echo "Install binaries"
115
	$(HIDE)mkdir -p $(BINDIR)
116
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
117

118
install_lib:
119

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

128

129
uninstall:
130
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
131
	rm -f $(MANDIR)/man1/cduce.1
132
	rm -Rf $(DOCDIR)
133
	ocamlfind remove cduce
134

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

145
# Source directories
146

147
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
148
CLEAN_DIRS := $(DIRS_DEPEND) tools tests
149
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
150 151


152 153 154

# Objects to build

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

189 190
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
191 192
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
193

194
ifneq ($(CURL), false)
195
  OBJECTS += parser/cduce_curl.cmo
196 197
  PACKAGES += curl
endif
198

199
ifneq ($(NETCLIENT), false)
200
  OBJECTS += parser/cduce_netclient.cmo
201 202 203
  PACKAGES += netclient
endif

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

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

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

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

231 232
all: $(ALL_TARGET)

233
OBJECTS += driver/run.cmo
234 235 236 237 238 239

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

240

241 242 243 244 245 246 247 248
OBJECTS_NO_MLIFACE := $(OBJECTS)

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



249
CDUCE = $(OBJECTS) driver/start.cmo
250

251
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
252 253
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
254
 tools/validate.cmo \
255
 parser/cduce_curl.cmo \
256
 parser/cduce_netclient.cmo \
257 258
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

259
ALL_INTERFACES = schema/schema_types.mli
260

261
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
262

263
INCLUDES = $(DIRS:%=-I %)
264 265
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)

266
# -I +camlp4
267

268
cduce: $(CDUCE:.cmo=.$(EXTENSION))
269 270
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
271

272 273 274 275 276
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
277
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
278

279

280
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
281
	@echo "Pack cduce_lib.$(EXTENSION)"
282 283
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
284
	@echo "Build $@"
285
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
286

287
dtd2cduce: tools/dtd2cduce.ml
288
	@echo "Build $@"
289
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
290 291

.PHONY: compute_depend
292

293
compute_depend: $(DEPEND_OCAMLDEP)
294
	@echo "Computing dependencies ..."
295
	ocamlfind ocamldep -package "$(PACKAGES)" \
296 297
		$(INCLUDES_DEPEND) $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo $(DEPEND) > depend
	for i in $(ALL_ML_IFACE); do \
298
	touch ocamliface/$$i/caml_cduce.ml; \
299 300 301
	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;\
302
        rm -f ocamliface/$$i/caml_cduce.ml; \
303 304
        done

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

327 328 329
distclean: clean
	rm -f Makefile.conf

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

332
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
333

334 335 336 337
$(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
338
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
339

340
misc/q_symbol.cmo: misc/q_symbol.ml
341
	@echo "Build $@"
342
	$(HIDE) $(CAMLC) -c -pp camlp4orf $<
343 344 345 346 347


types/boolVar.cmo: SYNTAX_PARSER=
types/boolVar.cmi: SYNTAX_PARSER=
types/boolVar.cmx: SYNTAX_PARSER=
348
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
349

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

354

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

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

include depend

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

368
# Documentation
369

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

374
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
375
	./cduce -I web/ --compile web/site.cd
376 377

web/xhtml.cdo: cduce web/xhtml.cd
378
	./cduce -I web/ --compile web/xhtml.cd
379

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

388 389 390 391

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


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

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