Makefile.distrib 8.97 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.3.0
3

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

9
PACKAGES = ulex camlp4 num cgi pcre netstring 
10

11 12 13 14 15 16 17 18 19 20 21

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

VERBOSE=false

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

22

23
SYNTAX = -I misc/ q_symbol.cmo \
24
  -symbol cduce_version=\"$(VERSION)\" \
25 26
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
27

28
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
29

30
CAMLC_P = ocamlc -g
31
DEPEND_OCAMLDEP = misc/q_symbol.cmo
32
ifeq ($(PROFILE), true)
33 34 35 36 37 38
  CAMLOPT_P = ocamlopt -p
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
39
else
40
  CAMLOPT_P = ocamlopt -inline 25
41 42
endif

43
OPT = -warn-error FPS
44 45 46 47 48 49 50 51
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
52 53 54
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
55 56

ifeq ($(NATIVE), true)
57 58
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
59
  CAML=ocamlopt
60 61
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
62
  SYNTAX += -symbol ocaml_compiler=\"native\"
63
else
64 65 66
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
67
  CAML=ocamlc
68
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
69
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
70 71
endif

72

73
INSTALL := install
74 75

ifeq ($(NATIVE),true)
76
.PHONY: cduce_lib.cma
77 78
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
79 80
endif

81 82 83
install: all install_bin install_lib install_doc

install_bin:
84
	@echo "Install binaries"
85
	$(HIDE)mkdir -p $(BINDIR)
86
	$(HIDE)$(INSTALL) -m755 cduce$(EXE) \
87
                        cdo2ml$(EXE) \
88 89
			mlcduce_wrapper$(EXE) \
			cduce_mktop $(BINDIR)/
90
	
91

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

99

100
uninstall:
101
	rm -f $(BINDIR)/cduce$(EXE) \
102
	  $(BINDIR)/cdo2ml$(EXE) \
103
	  $(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
104
	rm -f $(MANDIR)/man1/cduce.1 \
105
	  $(MANDIR)/man1/cdo2ml.1
106
	rm -Rf $(DOCDIR)
107
	ocamlfind remove cduce
108

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

119 120
# Source directories 

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

# Objects to build

126
SCHEMA_OBJS = \
127
 schema/schema_pcre.cmo \
128 129 130 131 132 133 134
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \

135 136 137
NEW_SCHEMA_OBJS = \
 schema/schema_components.cmo schema/schema_import.cmo \

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

175 176 177
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

178
ML_INTERFACE_OBJS = \
179 180
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
181 182 183 184 185 186 187 188 189 190 191 192 193 194

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

195 196 197 198 199 200 201
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

202 203
ifeq ($(PXP),true)
  OBJECTS += runtime/cduce_pxp.cmo
204
  PACKAGES += $(PXP_PACK)
205
endif
206 207 208 209
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
210

211

212 213
#CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
#CQL_OBJECTS_RUN = query/query_run.cmo
214
CQL_OBJECTS= query/query_aggregates.cmo
215
CQL_OBJECTS_RUN=
216

217 218
OBJECTS += $(CQL_OBJECTS)

219 220
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

221 222
OBJECTS += $(CQL_OBJECTS_RUN) 
OBJECTS += driver/run.cmo
223
CDUCE = $(OBJECTS) driver/start.cmo 
224

225
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
226
 driver/start.cmo driver/examples.cmo driver/webiface.cmo driver/evaluator.cmo \
227
 tools/validate.cmo \
228 229
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
230 231
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

232
ALL_INTERFACES = schema/schema_types.mli 
233

234
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
235

236 237
INCLUDES = $(DIRS:%=-I %)

238
cduce: $(CDUCE:.cmo=.$(EXTENSION))
239 240
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
241

242 243 244
test_schema: $(OBJECTS:.cmo=.$(EXTENSION)) $(NEW_SCHEMA_OBJS:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
245

246

247 248 249 250 251
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

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

254

255
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
256
	@echo "Pack cduce_lib.$(EXTENSION)"
257
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
258
	@echo "Build $@"
259
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
260

261
dtd2cduce: tools/dtd2cduce.ml
262
	@echo "Build $@"
263
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
264

265
cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
266 267
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
268

269
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
270
	@echo "Build $@"
271
	$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
272

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

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

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

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

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

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

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

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

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

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

include depend

327
# Documentation
328

329
doc: cduce web/site.cdo
330
	mkdir -p web/doc
331
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
332

333
web/site.cdo: cduce web/xhtml.cdo web/site.cd
334
	./cduce -I web/ --compile web/site.cd
335 336

web/xhtml.cdo: cduce web/xhtml.cd
337
	./cduce -I web/ --compile web/xhtml.cd
338

339
install_doc: doc
340 341
	$(HIDE)mkdir -p $(MANDIR)/man1
	$(HIDE)(cd doc; $(MAKE) install INSTALL=$(INSTALL) MANDIR=$(MANDIR) HIDE=$(HIDE))
342 343
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
344
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
345
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
346

347 348 349 350 351 352 353 354 355 356 357 358 359

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