Makefile.distrib 9.01 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.3b1
3

4
all: cduce dtd2cduce 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 59 60
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
61
  SYNTAX += -symbol ocaml_compiler=\"native\"
62
else
63 64 65 66
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
67
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
68 69
endif

70

71
INSTALL := install
72 73

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

79 80 81
install: all install_bin install_lib install_doc

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

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

97

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

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

117 118
# Source directories 

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

# Objects to build

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

133 134 135
NEW_SCHEMA_OBJS = \
 schema/schema_components.cmo schema/schema_import.cmo \

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

173 174 175
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@

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

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

193 194 195 196 197 198 199 200 201
ifeq ($(PXP),true)
  OBJECTS += runtime/cduce_pxp.cmo
  PACKAGES += pxp-engine pxp-lex-iso88591 
  ifeq ($(PXP_WLEX), true)
    PACKAGES += pxp-wlex-utf8
  else
    PACKAGES += pxp-lex-utf8
  endif
endif
202 203 204 205
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
206

207

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

213 214
OBJECTS += $(CQL_OBJECTS)

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

217 218
OBJECTS += $(CQL_OBJECTS_RUN) 
OBJECTS += driver/run.cmo
219
CDUCE = $(OBJECTS) driver/start.cmo 
220 221
DTD2CDUCE = tools/dtd2cduce.cmo

222
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
223
 driver/start.cmo driver/examples.cmo driver/webiface.cmo driver/evaluator.cmo \
224
 tools/dtd2cduce.cmo tools/validate.cmo \
225 226 227
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
 runtime/cduce_expat.cmo \
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
test_schema: $(OBJECTS:.cmo=.$(EXTENSION)) $(NEW_SCHEMA_OBJS:.cmo=.$(EXTENSION))
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
241

242

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
dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
258 259
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
260

261
cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
262 263
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
264

265
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
266
	@echo "Build $@"
267
	$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
268

269
cdo2ml: ocamliface/cdo2ml.ml
270
	@echo "Build $@"
271
	$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^
272

273
.PHONY: compute_depend
274
compute_depend: $(DEPEND_OCAMLDEP)
275
	echo $(DEPEND)
276
	@echo "Computing dependencies ..."
277
	ocamlfind ocamldep -package "$(PACKAGES)" \
278
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
279 280
clean:
	for i in $(CLEAN_DIRS); do \
281
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
282
	done
283
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
284
	rm -f `find . -name "*~"`
285
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
286
	rm -f cduce$(EXE) ocamlprof.dump
287 288
	rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) \
		cdo2ml$(EXE) mlcduce_wrapper$(EXE) evaluator$(EXE)
289
	rm -Rf prepro package
290
	rm -f web/www/*.html web/*~
291
	rm -f web/*.cdo
292
	rm -f configure.log
293
	rm -rf web/doc
294

295 296 297
distclean: clean
	rm -f Makefile.conf

298
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
299

300
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
301
$(ALL_INTERFACES): misc/q_symbol.cmo
302 303 304

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

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

309
.ml.cmo:
310 311
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
312 313

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

.mli.cmi:
318 319
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
320 321 322

include depend

323
# Documentation
324

325
doc: cduce web/site.cdo
326
	mkdir -p web/doc
327
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
328

329
web/site.cdo: cduce web/xhtml.cdo web/site.cd
330
	./cduce -I web/ --compile web/site.cd
331 332

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

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

343 344 345 346 347 348 349 350 351 352 353 354 355

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