Makefile.distrib 8.89 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.3.2
3

4
5
6
7
8
9
10
11
12
13
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
  ALL_TARGET += cdo2ml mlcduce_wrapper
  INSTALL_BINARIES += cdo2ml$(EXE) mlcduce_wrapper$(EXE) cduce_mktop
endif


all: $(ALL_TARGET)
14
15
16
17
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

18
PACKAGES = ulex camlp4 cgi pcre num netstring 
19
20
21
22
23
24
25
26
27
28
29

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

VERBOSE=false

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

30

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

36
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
37

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

51
OPT = -warn-error FPS
52
53
54
55
56
57
58
59
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
60
61
62
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
63
64

ifeq ($(NATIVE), true)
65
66
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
67
  CAML=ocamlopt
68
69
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
70
  SYNTAX += -symbol ocaml_compiler=\"native\"
71
else
72
73
74
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
75
  CAML=ocamlc
76
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
77
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
78
79
endif

80

81
INSTALL := install
82
83

ifeq ($(NATIVE),true)
84
.PHONY: cduce_lib.cma
85
86
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
87
88
endif

89
90
91
install: all install_bin install_lib install_doc

install_bin:
92
	@echo "Install binaries"
93
	$(HIDE)mkdir -p $(BINDIR)
94
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
95
	
96

97
install_lib:
98
	@echo "Build META"
99
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
100
101
102
103
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
         cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \

104

105
uninstall:
106
	rm -f $(BINDIR)/cduce$(EXE) \
107
	  $(BINDIR)/cdo2ml$(EXE) \
108
	  $(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
109
	rm -f $(MANDIR)/man1/cduce.1 \
110
	  $(MANDIR)/man1/cdo2ml.1
111
	rm -Rf $(DOCDIR)
112
	ocamlfind remove cduce
113

114
115
116
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
117
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
118
119
120
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
121
122
123
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

124
125
# Source directories 

126
127
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
128
129
130

# Objects to build

131
SCHEMA_OBJS = \
132
 schema/schema_pcre.cmo \
133
134
135
136
137
138
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
139
 schema/schema_converter.cmo 
140

141
OBJECTS = \
142
 driver/config.cmo \
143
 misc/stats.cmo \
144
 misc/serialize.cmo misc/custom.cmo \
145
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
146
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo misc/imap.cmo \
147
 misc/html.cmo \
148
149
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
150
151
 types/intervals.cmo \
 types/chars.cmo types/atoms.cmo \
152
 types/normal.cmo \
153
 types/types.cmo types/sample.cmo types/sequence.cmo types/patterns.cmo \
154
 types/builtin_defs.cmo \
155
 \
156
 compile/lambda.cmo \
157
158
 runtime/value.cmo \
 \
159
 parser/location.cmo  parser/url.cmo \
160
  \
161
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
162
 \
163
 types/externals.cmo \
164
 typing/typed.cmo typing/typepat.cmo typing/typer.cmo \
165
 \
166
167
 $(SCHEMA_OBJS) \
 \
168
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
169
 runtime/explain.cmo \
170
 runtime/print_xml.cmo runtime/eval.cmo \
171
 compile/compile.cmo \
172
 compile/operators.cmo \
173
 \
174
 types/builtin.cmo \
175
 driver/librarian.cmo \
176
177
 driver/cduce.cmo \
 runtime/system.cmo
178

179
180
181
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

182
ML_INTERFACE_OBJS = \
183
184
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
185
186
187
188
189
190
191
192
193
194
195
196
197
198

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

ifneq ($(CURL), false)
  OBJECTS += parser/cduce_curl.cmo
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
  OBJECTS += parser/cduce_netclient.cmo
  PACKAGES += netclient
endif

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

206
207
ifeq ($(PXP),true)
  OBJECTS += runtime/cduce_pxp.cmo
208
  PACKAGES += $(PXP_PACK)
209
endif
210
211
212
213
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
214

215

216
217
#CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
#CQL_OBJECTS_RUN = query/query_run.cmo
218
CQL_OBJECTS= query/query_aggregates.cmo
219
CQL_OBJECTS_RUN=
220

221
222
OBJECTS += $(CQL_OBJECTS)

223
224
VALIDATE_OBJECTS := $(shell for o in $(OBJECTS); do echo $$o; if [ "$$o" = "schema/schema_parser.cmo" ]; then exit 0; fi; done)	# all objects until schema_parser.cmo

225
226
OBJECTS += $(CQL_OBJECTS_RUN) 
OBJECTS += driver/run.cmo
227
CDUCE = $(OBJECTS) driver/start.cmo 
228

229
230
231
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
232
 tools/validate.cmo \
233
234
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
235
236
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

237
ALL_INTERFACES = schema/schema_types.mli 
238

239
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
240

241
242
INCLUDES = $(DIRS:%=-I %)

243
cduce: $(CDUCE:.cmo=.$(EXTENSION))
244
245
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
246

247
248
249
250
251
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
252
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
253

254

255
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
256
	@echo "Pack cduce_lib.$(EXTENSION)"
257
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
258
	@echo "Build $@"
259
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
260

261
dtd2cduce: tools/dtd2cduce.ml
262
	@echo "Build $@"
263
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
264

265
cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
266
267
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
268

269
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
270
	@echo "Build $@"
271
	$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
272

273
cdo2ml: ocamliface/cdo2ml.ml
274
	@echo "Build $@"
275
	$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^
276

277
.PHONY: compute_depend
278
compute_depend: $(DEPEND_OCAMLDEP)
279
	echo $(DEPEND)
280
	@echo "Computing dependencies ..."
281
	ocamlfind ocamldep -package "$(PACKAGES)" \
282
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
283
284
clean:
	for i in $(CLEAN_DIRS); do \
285
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
286
	done
287
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
288
	rm -f `find . -name "*~"`
289
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
290
	rm -f cduce$(EXE) ocamlprof.dump
291
292
	rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) \
		cdo2ml$(EXE) mlcduce_wrapper$(EXE) evaluator$(EXE)
293
	rm -Rf prepro package
294
	rm -f web/www/*.html web/*~
295
	rm -f web/*.cdo
296
	rm -f configure.log
297
	rm -rf web/doc
298
	rm -f META
299

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

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

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

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

310
misc/q_symbol.cmo: misc/q_symbol.ml
311
312
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
313

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

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

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

include depend

328
# Documentation
329

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

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

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

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

348
349
350
351
352
353
354
355
356
357
358
359
360

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
	$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
	        HIDE=$(HIDE) caml_cduce.cmo

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
	$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
		HIDE=$(HIDE) caml_cduce.cmx