Makefile.distrib 9.87 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.1+1
3

4 5 6 7 8
all: cduce dtd2cduce validate cdo2ml cduce_lib.cma
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

9
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring 
10
ifeq ($(PXP_WLEX), true)
11
  PACKAGES += pxp-wlex-utf8
12
else
13
  PACKAGES += pxp-lex-utf8
14
endif
15

16 17 18 19 20 21 22 23 24 25 26

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

VERBOSE=false

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

27 28 29 30
# 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
31

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

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

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

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

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

79

80
INSTALL := $(shell which install)
81

82 83

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

89
install: all install_lib
90 91 92 93
	$(HIDE)mkdir -p $(BINDIR)
	$(HIDE)mkdir -p $(MANDIR)/man1
	@echo "Install binaries"
	$(HIDE)$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
94
                         validate$(EXE) cdo2ml$(EXE) $(BINDIR)/
95
	$(HIDE)(cd doc; $(MAKE) install INSTALL=$(INSTALL) MANDIR=$(MANDIR) HIDE=$(HIDE))
96

97
install_lib:
98 99 100 101 102 103
	@echo "Build META"
	$(HIDE)echo 'version="$(VERSION)"' > META
	$(HIDE)echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
	$(HIDE)echo 'description="Runtime support for CDuce"' >> META
	$(HIDE)echo 'archive(byte)="cduce_lib.cma"' >> META
	$(HIDE)echo 'archive(native)="cduce_lib.cmxa"' >> META
104 105 106 107
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
         cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \

108

109
uninstall:
110 111 112
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
	  $(BINDIR)/validate$(EXE) $(BINDIR)/cdo2ml$(EXE)
	rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \
113
	  $(MANDIR)/man1/validate.1 $(MANDIR)/man1/cdo2ml.1
114
	ocamlfind remove cduce
115

116 117 118 119
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
120
	@echo "  validate : compiles the schema validation tool"
121 122 123 124 125 126 127 128 129
	@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"

130 131
# Source directories 

132 133
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
134 135 136

# Objects to build

137 138 139 140 141 142 143 144
SCHEMA_OBJS = \
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \

145 146 147
NEW_SCHEMA_OBJS = \
 schema/schema_components.cmo schema/schema_import.cmo \

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

181 182 183
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

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

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

201 202
OBJECTS += runtime/cduce_pxp.cmo

203 204 205 206
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
207

208

209
CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
210
CQL_OBJECTS_RUN = query/query_run.cmo
211

212 213
OBJECTS += $(CQL_OBJECTS)

214 215
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

216 217
CDUCE = $(OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) driver/examples.cmo driver/webiface.cmo
218
EVALUATOR = $(OBJECTS) driver/examples.cmo driver/evaluator.cmo
219 220
DTD2CDUCE = tools/dtd2cduce.cmo

221
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
222
 driver/run.cmo driver/examples.cmo driver/webiface.cmo driver/evaluator.cmo \
223
 tools/dtd2cduce.cmo tools/validate.cmo \
224 225 226
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
 runtime/cduce_expat.cmo \
227
 $(CQL_OBJECTS_RUN)
228
ALL_INTERFACES = schema/schema_types.mli 
229

230
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
231

232 233
INCLUDES = $(DIRS:%=-I %)

234
cduce: $(CDUCE:.cmo=.$(EXTENSION))
235 236
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
237

238 239 240 241 242
test_schema: $(OBJECTS:.cmo=.$(EXTENSION)) $(NEW_SCHEMA_OBJS:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
	

243 244 245 246 247
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

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

250

251
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
252
	@echo "Pack cduce_lib.$(EXTENSION)"
253
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
254
	@echo "Build $@"
255
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
256

257

258
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
259 260
	@echo "Build $@"
	$(HIDE)$(LINK) -verbose $(INCLUDES) -o $@ $^ $(EXTRA_OPTS_WEBIFACE)
261

262 263 264 265
evaluator: $(EVALUATOR:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) -verbose $(INCLUDES) -o $@ $^ $(EXTRA_OPTS_WEBIFACE)

266
dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
267 268
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
269

270
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
271 272
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
273

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

278
.PHONY: compute_depend
279
compute_depend: $(DEPEND_OCAMLDEP)
280
	echo $(DEPEND)
281
	@echo "Computing dependencies ..."
282
	ocamlfind ocamldep -package "$(PACKAGES)" \
283
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
284 285
clean:
	for i in $(CLEAN_DIRS); do \
286
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
287
	done
288
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
289
	rm -f `find . -name "*~"`
290
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
291
	rm -f cduce$(EXE) ocamlprof.dump
292
	rm -f dtd2cduce$(EXE) webiface$(EXE) validate$(EXE) cdo2ml$(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

298 299 300
distclean: clean
	rm -f Makefile.conf

301
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
302

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

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

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

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

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

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

include depend

# CDuce-generated files

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

331
webpages: cduce web/site.cdo
332
	(cd web; ../cduce --run site.cdo --arg site.xml)
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
website: webpages webiface evaluator
341

342
install_web: website
343
	cp  web/www/*.html web/demo.js web/cduce.css  $(HTML_DIR)/
344
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
345
	cp webiface $(CGI_DIR)/cduce
346
	cp evaluator $(CGI_DIR)/
347 348
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
349
	fi;  
350
	cp web/img/*.*  $(HTML_DIR)/img
351

352 353 354 355 356 357 358 359 360 361 362 363 364

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