Makefile.distrib 10.6 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

Pietro Abate's avatar
Pietro Abate committed
79
OCAMLFIND = ocamlfind
80 81
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
82 83

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

106 107 108 109 110
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
111

112
INSTALL := install -c
113 114

ifeq ($(NATIVE),true)
115
.PHONY: cduce_lib.cma
116 117
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
118 119
endif

120 121 122
install: all install_bin install_lib install_doc

install_bin:
123
	@echo "Install binaries"
124
	$(HIDE)mkdir -p $(BINDIR)
125
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
126

127
install_lib:
128

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

137

138
uninstall:
139
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
140
	rm -f $(MANDIR)/man1/cduce.1
141
	rm -Rf $(DOCDIR)
142
	ocamlfind remove cduce
143

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

154
# Source directories
155

156
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
157
CLEAN_DIRS := $(DIRS_DEPEND) tools tests
158
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
159 160


161 162 163

# Objects to build

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

198 199
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
200 201
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
202

203
ifneq ($(CURL), false)
204
  OBJECTS += parser/cduce_curl.cmo
205 206
  PACKAGES += curl
endif
207

208
ifneq ($(NETCLIENT), false)
209
  OBJECTS += parser/cduce_netclient.cmo
210
  PACKAGES += netclient
211 212 213
  ifneq (($NETCLIENT4), false)
    SYNTAX += -symbol HAS_NETCLIENT4=true
  endif
214 215
endif

216 217 218 219 220 221 222
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

223
ifeq ($(PXP),true)
224 225
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
226 227
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
228
      PACKAGES += netcgi2
229 230 231
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
232
endif
233

234
ifeq ($(EXPAT), true)
235
  OBJECTS += runtime/cduce_expat.cmo
236 237
  PACKAGES += expat
endif
238

239 240 241
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
242

243 244
all: $(ALL_TARGET)

245
OBJECTS += driver/run.cmo
246 247 248 249 250 251

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

252

253 254 255 256 257 258 259 260
OBJECTS_NO_MLIFACE := $(OBJECTS)

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



261
CDUCE = $(OBJECTS) driver/start.cmo
262

263
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
264 265
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
266
 tools/validate.cmo \
267
 parser/cduce_curl.cmo \
268
 parser/cduce_netclient.cmo \
269 270
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

271
ALL_INTERFACES = schema/schema_types.mli
272

273
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
274

275
INCLUDES = $(DIRS:%=-I %)
276 277
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)

278
# -I +camlp4
279

280
cduce: $(CDUCE:.cmo=.$(EXTENSION))
281 282
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
283

284 285 286 287 288
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
289
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
290

291

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

299
dtd2cduce: tools/dtd2cduce.ml
300
	@echo "Build $@"
301
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
302 303

.PHONY: compute_depend
304

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

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

339 340 341
distclean: clean
	rm -f Makefile.conf

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

344
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
345

346 347 348 349
$(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
350
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
351

352
misc/q_symbol.cmo: misc/q_symbol.ml
353
	@echo "Build $@"
354
	$(HIDE) $(CAMLC) -c -pp camlp4orf $<
355 356


357
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
358

359
.ml.cmo:
360
	@echo "Build $@"
361
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
362

363

364
.ml.cmx:
365
	@echo "Build $@"
366
	$(HIDE) $(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
367

368
.mli.cmi:
369
	@echo "Build $@"
370
	$(HIDE) $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
371 372 373

include depend

374 375 376
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

377
# Documentation
378

379
doc: cduce web/site.cdo
380
	mkdir -p web/doc
381
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
382

383
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
384
	./cduce -I web/ --compile web/site.cd
385 386

web/xhtml.cdo: cduce web/xhtml.cd
387
	./cduce -I web/ --compile web/xhtml.cd
388

389
install_doc: doc
390
	$(HIDE)mkdir -p $(MANDIR)/man1
391
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
392 393
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
394
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
395
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
396

397 398 399 400

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


401
$(OCAMLIFACE)/caml_cduce.cmo:
402
	@echo "Build $@"
403
	@cd $(OCAMLIFACE); \
404
	$(MAKE) -s MODE=byte CAMLC="$(OCAMLFIND) $(CAMLC_P)" caml_cduce.cmo
405

406
$(OCAMLIFACE)/caml_cduce.cmx:
407
	@echo "Build $@"
408
	@cd $(OCAMLIFACE); \
409
	$(MAKE) -s MODE=opt  CAMLOPT="$(OCAMLFIND) $(CAMLOPT_P)" caml_cduce.cmx
410