Makefile.distrib 8.56 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 157
 runtime/value.cmo \
 \
158
 schema/schema_types.cmo \
159 160 161 162 163
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
164
 \
165
 parser/location.cmo parser/url.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
166 167 168
 \
 typing/typed.cmo typing/typer.cmo \
 \
169
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
170
 runtime/explain.cmo \
171
 runtime/print_xml.cmo runtime/eval.cmo \
172
 compile/compile.cmo \
173
 compile/operators.cmo \
174
 \
175
 types/builtin.cmo \
176 177 178
 driver/librarian.cmo

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

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

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

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

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

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

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

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

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

206 207 208 209 210 211 212 213
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)


214 215 216 217 218 219
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
220
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
221
	$(COMPILE) -c cdo2cmo/cdml.mli
222 223 224
	$(COMPILE) -c cdo2cmo/cdml.ml
	$(COMPILE) -a -o cdml.$(EXTENSION_LIB) \
		cDuce_all.$(EXTENSION) \
225
		cdo2cmo/cdml.$(EXTENSION)
226

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

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

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

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

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

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

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

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

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

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

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

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

.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
288
	(cd web/examples; ../../cduce build.cd --arg examples.xml)
289

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

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

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

299
website: webpages webiface
300

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