Makefile.distrib 8.61 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre5
3

4
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring 
5
ifeq ($(PXP_WLEX), true)
6
  PACKAGES += pxp-wlex-utf8
7
else
8
  PACKAGES += pxp-lex-utf8
9
endif
10

11
12
13
14
# webiface can be made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
# Seems to be some problems with statically linking curl
# EXTRA_OPTS_WEBIFACE = -ccopt -static
15

16
SYNTAX = -I misc/ q_symbol.cmo \
17
  -symbol cduce_version=\"$(VERSION)\" \
18
19
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
20
21
22
23
24
25

ifeq ($(NATIVE), true)
	SYNTAX += -symbol ocaml_compiler=\"native\"
else
	SYNTAX += -symbol ocaml_compiler=\"bytecode\"
endif
26

27
ifeq ($(EXPAT), true)
28
29
  PACKAGES += expat
  SYNTAX += -symbol EXPAT=
30
31
endif

32
33
34
35
36
ifeq ($(CURL), true)
  PACKAGES += curl
  SYNTAX += -symbol CURL=
endif

37
38
39
40
41
ifeq ($(NETCLIENT), true)
  PACKAGES += netclient
  SYNTAX += -symbol NETCLIENT=
endif

42
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
43

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

57
OPT = -warn-error FPS
58
59
60
61
62
63
64
65
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
66
67
68
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
69
70

ifeq ($(NATIVE), true)
71
72
73
74
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
75
else
76
77
78
79
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
80
81
endif

82
ifneq ($(ML_INTERFACE), false)
83
84
  SYNTAX += -symbol ML_INTERFACE=
  ML_LIB = oCaml_all.$(EXTENSION_LIB)
85
  ML_INTERFACE_OBJ = ocamliface/mltypes.cmo ocamliface/mlstub.cmo
86
else
87
  ML_INTERFACE_OBJ = 
88
endif
89

90
INSTALL := $(shell which install)
91

92
all: cduce dtd2cduce validate cdo2ml
93

94
ifneq ($(ML_INTERFACE), false)
95
all: cdml.$(EXTENSION_LIB)
96
97
endif

98
install: all install_cdml
99
100
	mkdir -p $(BINDIR)
	mkdir -p $(MANDIR)/man1
101
102
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
                         validate$(EXE) cdo2ml$(EXE) $(BINDIR)/
103
104
105
	$(INSTALL) -m644 doc/cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/dtd2cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/validate.1 $(MANDIR)/man1/
106
107

install_cdml:
108
ifneq ($(ML_INTERFACE), false)
109
110
111
112
	$(OCAMLFIND) install cduce META \
         cdml.$(EXTENSION_LIB) cdo2cmo/cdml.cmi \
         cDuce_all.cmi oCaml_all.$(EXTENSION_LIB) \
         $(wildcard *.a) oCaml_all.cmi
113
114
endif

115
uninstall:
116
117
118
119
120
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
	  $(BINDIR)/validate$(EXE) $(BINDIR)/cdo2ml$(EXE)
	rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \
	  $(MANDIR)/man1/validate.1
	ocamlfind remove cduce
121

122
123
124
125
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
126
	@echo "  validate : compiles the schema validation tool"
127
128
129
130
131
132
133
134
135
	@echo "  webiface : compiles the CDuce web interface interpreter (CGI script)"
	@echo "  webpages : compiles in web/www/ the files for the CDuce website"
	@echo "             (including the tutorial and manual)"
	@echo "  install_web : compiles webiface and webpages, and install everything"
	@echo "  all : equivalent to (make cduce dtd2cduce validate)"
	@echo "  install : install cduce dtd2cduce, validate et man pages"
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

136
137
# Source directories 

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

# Objects to build

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

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
180
181

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
182
CQL_OBJECTS_RUN = query/query_run.cmo
183

184
185
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

186
187
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
188
189
DTD2CDUCE = tools/dtd2cduce.cmo

190
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
191
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
192
193
 tools/dtd2cduce.cmo tools/validate.cmo \
 $(CQL_OBJECTS_RUN)
194
ALL_INTERFACES = schema/schema_types.mli 
195

196
ifneq ($(ML_INTERFACE), false)
197
  ALL_INTERFACES += ocamliface/mltypes.mli ocamliface/mlstub.mli
198
199
endif

200
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
201

202
203
INCLUDES = $(DIRS:%=-I %)

204
cduce: $(CDUCE:.cmo=.$(EXTENSION))
205
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
206

207
208
209
210
211
212
213
214
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

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


215
216
217
218
219
220
cdml.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	echo 'version="$(VERSION)"' > META
	echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
	echo 'description="Runtime support for CDuce"' >> META
	echo 'archive(byte)="oCaml_all.cma,cdml.cma"' >> META
	echo 'archive(native)="oCaml_all.cmxa,cdml.cmxa"' >> META
221
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
222
	$(COMPILE) -c cdo2cmo/cdml.mli
223
224
225
	$(COMPILE) -c cdo2cmo/cdml.ml
	$(COMPILE) -a -o cdml.$(EXTENSION_LIB) \
		cDuce_all.$(EXTENSION) \
226
		cdo2cmo/cdml.$(EXTENSION)
227

228
229
230
oCaml_all.$(EXTENSION_LIB):
	cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@

231
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
232
	$(LINK) -verbose $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_OPTS_WEBIFACE)
233
234

dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
235
	$(LINK) $(INCLUDES) -o $@ $^
236

237
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
238
239
	$(LINK) $(INCLUDES) -o $@ $^

240
241
242
cdo2ml: ocamliface/cdo2ml.ml
	ocamlc -o $@ -pp camlp4o -I +camlp4 camlp4.cma pr_o.cmo $^

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

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

265
266
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

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

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

272
misc/q_symbol.cmo: misc/q_symbol.ml
273
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
274

275
.ml.cmo:
276
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
277
278
279
280
281
282
283
284
285
286
287
288

.ml.cmx:
	$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<

.mli.cmi:
	$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<

include depend

# CDuce-generated files

driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml
289
	(cd web/examples; ../../cduce build.cd --arg examples.xml)
290

291
webpages: cduce web/site.cdo
292
	(cd web; ../cduce --run site.cdo --arg site.xml)
293

294
web/site.cdo: cduce web/xhtml.cdo web/site.cd
295
	./cduce -I web/ --compile web/site.cd
296
297

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

300
website: webpages webiface
301

302
install_web: website
303
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
304
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
305
	cp webiface $(CGI_DIR)/cduce
306
307
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
308
	fi;  
309
	cp web/img/*.*  $(HTML_DIR)/img
310