Makefile.distrib 7.99 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
endif


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

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

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

VERBOSE=false

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

29

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

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

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

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

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

79

80
INSTALL := install -c
81
82

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

88
89
90
install: all install_bin install_lib install_doc

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

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

103

104
uninstall:
105
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
106
	rm -f $(MANDIR)/man1/cduce.1
107
	rm -Rf $(DOCDIR)
108
	ocamlfind remove cduce
109

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

120
121
# Source directories 

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

# Objects to build

127
OBJECTS = \
128
129
 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 \
130
 \
131
132
133
134
 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 \
135
136
137
 \
 runtime/value.cmo \
 \
138
139
140
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
141
 \
142
 types/patterns.cmo \
143
 \
144
145
146
147
148
 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 \
149
 \
150
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
151
 compile/compile.cmo \
152
 \
153
154
155
156
 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 \
157
 driver/cduce.cmo \
158
159
 \
 runtime/system.cmo query/query_aggregates.cmo
160

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

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

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

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

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

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

203

204
205
all: $(ALL_TARGET)

206
OBJECTS += driver/run.cmo
207
CDUCE = $(OBJECTS) driver/start.cmo 
208

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

217
ALL_INTERFACES = schema/schema_types.mli 
218

219
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
220

221
INCLUDES = $(DIRS:%=-I %) -I +camlp4
222

223
cduce: $(CDUCE:.cmo=.$(EXTENSION))
224
225
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
226

227
228
229
230
231
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
232
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
233

234

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

241
dtd2cduce: tools/dtd2cduce.ml
242
	@echo "Build $@"
243
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) cgi" -linkpkg $^
244
245

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

266
267
268
distclean: clean
	rm -f Makefile.conf

269
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
270

271
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
272
$(ALL_INTERFACES): misc/q_symbol.cmo
273
274
275

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

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

280
.ml.cmo:
281
282
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
283
284

.ml.cmx:
285
	@echo "Build $@"
286
	$(HIDE)$(CAMLOPT) -passopt -for-pack -passopt Cduce_lib -c $(SYNTAX_PARSER) $(INCLUDES) $<
287
288

.mli.cmi:
289
290
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
291
292
293

include depend

294
# Documentation
295

296
doc: cduce web/site.cdo
297
	mkdir -p web/doc
298
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
299

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

web/xhtml.cdo: cduce web/xhtml.cd
304
	./cduce -I web/ --compile web/xhtml.cd
305

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

314
315
316
317
318
319

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
320
	$(MAKE) OCAML_SRC=$(OCAML_SRC) HIDE=$(HIDE) caml_cduce.cmo
321
322
323

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
324
325
	$(MAKE) OCAML_SRC=$(OCAML_SRC) HIDE=$(HIDE) caml_cduce.cmx