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

3
include Makefile.conf
4
include VERSION
5

6
OCAMLIFACE=ocamliface/$(ML_INTERFACE_VERSION)
7

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

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

15
OUNIT_TESTS=eval cdnum cdsdl misc
16

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

21
PACKAGES = dynlink camlp4 ulex pcre num netstring
22
ALL_ML_IFACE = 3.x 4.01 4.02
23 24 25

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

26
VERBOSE?=false
27 28 29 30 31 32 33

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

34

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

41
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
42

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

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

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

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

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

99
INSTALL := install -c
100 101

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

107 108 109
install: all install_bin install_lib install_doc

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

114
install_lib:
115

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

124

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

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

141
# Source directories
142

143 144
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
145
CLEAN_DIRS = $(DIRS) tools tests
146 147 148

# Objects to build

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

183 184
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
185 186
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
187

188
ifneq ($(CURL), false)
189
  OBJECTS += parser/cduce_curl.cmo
190 191 192
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
193
  OBJECTS += parser/cduce_netclient.cmo
194 195 196
  PACKAGES += netclient
endif

197 198 199 200 201 202 203
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

204
ifeq ($(PXP),true)
205 206
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
207 208
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
209
      PACKAGES += netcgi2
210 211 212
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
213
endif
214

215
ifeq ($(EXPAT), true)
216
  OBJECTS += runtime/cduce_expat.cmo
217 218
  PACKAGES += expat
endif
219

220 221 222
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
223

224 225
all: $(ALL_TARGET)

226
OBJECTS += driver/run.cmo
227 228 229 230 231 232 233 234 235 236 237 238 239 240

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

OBJECTS_NO_MLIFACE := $(OBJECTS)

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



241
CDUCE = $(OBJECTS) driver/start.cmo
242

243
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
244 245
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
246
 tools/validate.cmo \
247
 parser/cduce_curl.cmo \
248
 parser/cduce_netclient.cmo \
249 250
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

251
ALL_INTERFACES = schema/schema_types.mli
252

253
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
254

255
INCLUDES = $(DIRS:%=-I %)
256 257
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)

258
# -I +camlp4
259

260
cduce: $(CDUCE:.cmo=.$(EXTENSION))
261 262
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
263

264 265 266 267 268
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
269
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
270

271

272
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
273
	@echo "Pack cduce_lib.$(EXTENSION)"
274 275
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
276
	@echo "Build $@"
277
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
278

279
dtd2cduce: tools/dtd2cduce.ml
280
	@echo "Build $@"
281
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
282 283

.PHONY: compute_depend
284

285
compute_depend: $(DEPEND_OCAMLDEP)
286
	@echo "Computing dependencies ..."
287
	ocamlfind ocamldep -package "$(PACKAGES)" \
288 289 290 291 292 293 294
		$(INCLUDES_DEPEND) $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo $(DEPEND) > depend
	for i in $(ALL_ML_IFACE); do \
	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;\
        done

295 296
clean:
	for i in $(CLEAN_DIRS); do \
297
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
298
	done
299
	(cd $(OCAMLIFACE); $(MAKE) clean)
300
	rm -f `find . -name "*~"`
301
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
302
	rm -f cduce$(EXE) ocamlprof.dump
303
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
304
	rm -Rf prepro package
305
	rm -f web/www/*.html web/*~
306
	rm -f web/*.cdo
307
	rm -f configure.log
308
	rm -rf web/doc
309
	rm -f META
310 311
	rm -rf lib
	$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
312
	$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
313
	$(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]
314
	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
315

316 317 318
distclean: clean
	rm -f Makefile.conf

319
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
320

321
$(ALL_INTERFACES): misc/q_symbol.cmo
322 323 324 325
$(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
326

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

329
misc/q_symbol.cmo: misc/q_symbol.ml
330
	@echo "Build $@"
331
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
332

333 334
parser/parser.cmo: PACKAGES += camlp4.extend
parser/parser.cmx: PACKAGES += camlp4.extend
335 336 337 338

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

340
.ml.cmo:
341 342
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
343

344

345
.ml.cmx:
346
	@echo "Build $@"
347
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
348

349
.mli.cmi:
350 351
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
352 353 354

include depend

355 356 357
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

358
# Documentation
359

360
doc: cduce web/site.cdo
361
	mkdir -p web/doc
362
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
363

364
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
365
	./cduce -I web/ --compile web/site.cd
366 367

web/xhtml.cdo: cduce web/xhtml.cd
368
	./cduce -I web/ --compile web/xhtml.cd
369

370
install_doc: doc
371
	$(HIDE)mkdir -p $(MANDIR)/man1
372
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
373 374
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
375
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
376
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
377

378 379 380 381

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


382 383
$(OCAMLIFACE)/caml_cduce.cmo:
	@cd $(OCAMLIFACE); \
384
	$(MAKE) CAMLC="$(CAMLC_P)" CAMLOPT="$(CAMLOPT_P)" caml_cduce.cmo
385

386 387
$(OCAMLIFACE)/caml_cduce.cmx:
	@cd $(OCAMLIFACE); \
388
	$(MAKE) CAMLC="$(CAMLC_P)" CAMLOPT="$(CAMLOPT_P)" caml_cduce.cmx
389

390 391
$(OCAMLIFACE)/mlstub.cmo: SYNTAX += q_MLast.cmo
$(OCAMLIFACE)/mlstub.cmx: SYNTAX += q_MLast.cmo