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

3
include Makefile.conf
4
include VERSION
5

6

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

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

14
OUNIT_TESTS=eval cdnum cdsdl misc
15

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

Jérôme Maloberti's avatar
Jérôme Maloberti committed
20
PACKAGES = dynlink camlp4 ulex pcre num netstring 
21 22 23

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

24
VERBOSE?=false
25 26 27 28 29 30 31

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

32

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

39
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
40

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

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

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

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

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

97
INSTALL := install -c
98 99

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

105 106 107
install: all install_bin install_lib install_doc

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

112
install_lib:
113

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

122

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

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

139 140
# Source directories 

141
DIRS = misc parser schema typing types compile runtime driver query ocamliface win32
142
CLEAN_DIRS = $(DIRS) tools tests
143 144 145

# Objects to build

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

180 181
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
182 183
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
184

185
ML_INTERFACE_OBJS = \
186 187
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
188 189 190 191 192 193

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

ifneq ($(CURL), false)
194
  OBJECTS += parser/cduce_curl.cmo
195 196 197
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
198
  OBJECTS += parser/cduce_netclient.cmo
199 200 201
  PACKAGES += netclient
endif

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

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

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

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

229 230
all: $(ALL_TARGET)

231
OBJECTS += driver/run.cmo
232
CDUCE = $(OBJECTS) driver/start.cmo 
233

234 235 236
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
237
 tools/validate.cmo \
238 239
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
240 241
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

242 243
ALL_INTERFACES = schema/schema_types.mli
#types/var.mli types/boolVar.mli
244

245
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
246

247 248
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
249

250
cduce: $(CDUCE:.cmo=.$(EXTENSION))
251 252
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
253

254 255 256 257 258
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
259
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
260

261

262
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
263
	@echo "Pack cduce_lib.$(EXTENSION)"
264 265
	@test -e lib || mkdir lib
	$(HIDE)$(COMPILE) -o lib/cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
266
	@echo "Build $@"
267
	$(HIDE)$(COMPILE) -a -o lib/$@ lib/cduce_lib.$(EXTENSION)
268

269
dtd2cduce: tools/dtd2cduce.ml
270
	@echo "Build $@"
271
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
272 273

.PHONY: compute_depend
274
compute_depend: $(DEPEND_OCAMLDEP)
275
	@echo "Computing dependencies ..."
276
	ocamlfind ocamldep -package "$(PACKAGES)" \
277
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
278 279
clean:
	for i in $(CLEAN_DIRS); do \
280
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
281
	done
282
	(cd ocamliface; $(MAKE) clean)
283
	rm -f `find . -name "*~"`
284
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
285
	rm -f cduce$(EXE) ocamlprof.dump
286
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
287
	rm -Rf prepro package
288
	rm -f web/www/*.html web/*~
289
	rm -f web/*.cdo
290
	rm -f configure.log
291
	rm -rf web/doc
292
	rm -f META
293 294
	rm -rf lib
	$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
295
	$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
296
	$(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]
297
	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
298

299 300 301
distclean: clean
	rm -f Makefile.conf

302
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
303

304
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
305
$(ALL_INTERFACES): misc/q_symbol.cmo
306 307 308

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

309
misc/q_symbol.cmo: misc/q_symbol.ml
310
	@echo "Build $@"		  
311
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
312

313 314 315 316
types/%.cmo: types/%.ml
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $<

317
.ml.cmo:
318 319
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
320

321 322 323 324
types/%.cmx: types/%.ml
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(INCLUDES) $<

325
.ml.cmx:
326
	@echo "Build $@"
327
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
328 329 330 331

types/%.cmi: types/%.mli
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $<
332 333

.mli.cmi:
334 335
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
336 337 338

include depend

339 340 341
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

342
# Documentation
343

344
doc: cduce web/site.cdo
345
	mkdir -p web/doc
346
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
347

348
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
349
	./cduce -I web/ --compile web/site.cd
350 351

web/xhtml.cdo: cduce web/xhtml.cd
352
	./cduce -I web/ --compile web/xhtml.cd
353

354
install_doc: doc
355
	$(HIDE)mkdir -p $(MANDIR)/man1
356
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
357 358
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
359
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
360
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
361

362 363 364 365 366 367

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
368
	$(MAKE) caml_cduce.cmo
369 370 371

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
372
	$(MAKE) caml_cduce.cmx
373