Makefile.distrib 7.96 KB
Newer Older
1
include Makefile.conf
2
include VERSION
3

4

5
6
7
8
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

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


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

18
PACKAGES = ulex camlp4 pcre num netstring cgi
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
  CAMLOPT_P = ocamlopt -p -inline 10000
42
43
44
45
46
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
47
else
48
  CAMLOPT_P = ocamlopt -inline 10000
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
  COMPILE = $(CAMLOPT)
69
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa camlp4.cmxa pr_o.cmx
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 camlp4.cma pr_o.cmo
77
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
78
79
endif

80

81
INSTALL := install -c
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) $(BINDIR)/cduce_mktop
107
	rm -f $(MANDIR)/man1/cduce.1
108
	rm -Rf $(DOCDIR)
109
	ocamlfind remove cduce
110

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

121
122
# Source directories 

123
124
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
125
126
127

# Objects to build

128
OBJECTS = \
129
130
 driver/config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
 misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo \
131
 \
132
133
134
135
 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 \
136
137
138
 \
 runtime/value.cmo \
 \
139
140
141
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
142
 \
143
 types/patterns.cmo \
144
 \
145
146
147
148
149
 compile/lambda.cmo \
 runtime/run_dispatch.cmo runtime/explain.cmo runtime/eval.cmo \
 \
 parser/location.cmo  parser/url.cmo \
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
150
 \
151
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
152
 compile/compile.cmo \
153
 \
154
155
156
157
 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 \
 compile/print_auto.cmo \
158
 driver/cduce.cmo \
159
160
 \
 runtime/system.cmo query/query_aggregates.cmo
161

162
163
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
164
165
166
167
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.mli
	cp $^ $@
168

169
ML_INTERFACE_OBJS = \
170
171
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
172
173
174
175
176
177

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

ifneq ($(CURL), false)
178
  OBJECTS += parser/cduce_curl.cmo
179
180
181
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
182
  OBJECTS += parser/cduce_netclient.cmo
183
184
185
  PACKAGES += netclient
endif

186
187
188
189
190
191
192
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

193
ifeq ($(PXP),true)
194
  OBJECTS += runtime/cduce_pxp.cmo
195
  PACKAGES += $(PXP_PACK)
196
endif
197
ifeq ($(EXPAT), true)
198
  OBJECTS += runtime/cduce_expat.cmo
199
200
  PACKAGES += expat
endif
201

202

203
OBJECTS += driver/run.cmo
204
CDUCE = $(OBJECTS) driver/start.cmo 
205

206
207
208
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
209
 tools/validate.cmo \
210
211
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
212
213
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

214
ALL_INTERFACES = schema/schema_types.mli 
215

216
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
217

218
INCLUDES = $(DIRS:%=-I %) -I +camlp4
219

220
cduce: $(CDUCE:.cmo=.$(EXTENSION))
221
222
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
223

224
225
226
227
228
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
229
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
230

231

232
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
233
	@echo "Pack cduce_lib.$(EXTENSION)"
234
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
235
	@echo "Build $@"
236
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
237

238
dtd2cduce: tools/dtd2cduce.ml
239
	@echo "Build $@"
240
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
241
242

.PHONY: compute_depend
243
compute_depend: $(DEPEND_OCAMLDEP)
244
	@echo "Computing dependencies ..."
245
	ocamlfind ocamldep -package "$(PACKAGES)" \
246
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
247
248
clean:
	for i in $(CLEAN_DIRS); do \
249
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
250
	done
251
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
252
	rm -f `find . -name "*~"`
253
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
254
	rm -f cduce$(EXE) ocamlprof.dump
255
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
256
	rm -Rf prepro package
257
	rm -f web/www/*.html web/*~
258
	rm -f web/*.cdo
259
	rm -f configure.log
260
	rm -rf web/doc
261
	rm -f META
262

263
264
265
distclean: clean
	rm -f Makefile.conf

266
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
267

268
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
269
$(ALL_INTERFACES): misc/q_symbol.cmo
270
271
272

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

273
misc/q_symbol.cmo: misc/q_symbol.ml
274
275
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
276

277
.ml.cmo:
278
279
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
280
281

.ml.cmx:
282
283
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
284
285

.mli.cmi:
286
287
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
288
289
290

include depend

291
# Documentation
292

293
doc: cduce web/site.cdo
294
	mkdir -p web/doc
295
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
296

297
web/site.cdo: cduce web/xhtml.cdo web/site.cd
298
	./cduce -I web/ --compile web/site.cd
299
300

web/xhtml.cdo: cduce web/xhtml.cd
301
	./cduce -I web/ --compile web/xhtml.cd
302

303
install_doc: doc
304
	$(HIDE)mkdir -p $(MANDIR)/man1
305
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
306
307
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
308
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
309
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
310

311
312
313
314
315
316
317
318
319
320
321
322
323

### 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