Makefile.distrib 8.89 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=a eval cdnum cdsdl
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

113
install_lib:
114
	@echo "Build META"
115
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
116 117
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
118
         cduce_lib.cmi cduce_lib.cma cduce_lib.cmxa cduce_lib.a \
119

120

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

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

137 138
# Source directories 

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

# Objects to build

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

178 179
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
180 181 182 183
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.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 += netcgi1
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
ALL_INTERFACES = schema/schema_types.mli 
243

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

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

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

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

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

260

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

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

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

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

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

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

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

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

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

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

.mli.cmi:
321 322
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
323 324 325

include depend

326 327 328
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

329
# Documentation
330

331
doc: cduce web/site.cdo
332
	mkdir -p web/doc
333
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
334

335
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
336
	./cduce -I web/ --compile web/site.cd
337 338

web/xhtml.cdo: cduce web/xhtml.cd
339
	./cduce -I web/ --compile web/xhtml.cd
340

341
install_doc: doc
342
	$(HIDE)mkdir -p $(MANDIR)/man1
343
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
344 345
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
346
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
347
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
348

349 350 351 352 353 354

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
355
	$(MAKE) caml_cduce.cmo
356 357 358

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
359
	$(MAKE) caml_cduce.cmx
360