Makefile.distrib 8.94 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.3.2+2
3

4 5 6 7 8 9 10 11 12 13
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
  ALL_TARGET += cdo2ml mlcduce_wrapper
  INSTALL_BINARIES += cdo2ml$(EXE) mlcduce_wrapper$(EXE) cduce_mktop
endif


all: $(ALL_TARGET)
14 15 16 17
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

18
PACKAGES = ulex camlp4 cgi pcre num netstring 
19 20 21 22 23 24 25 26 27 28 29

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

VERBOSE=false

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

30

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

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

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

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

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

80

81
INSTALL := install
82 83

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

89 90 91
install: all install_bin install_lib install_doc

install_bin:
92
	@echo "Install binaries"
93
	$(HIDE)mkdir -p $(BINDIR)
94
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
95
	
96

97
install_lib:
98
	@echo "Build META"
99
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
100 101 102 103
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
         cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \

104

105
uninstall:
106
	rm -f $(BINDIR)/cduce$(EXE) \
107
	  $(BINDIR)/cdo2ml$(EXE) \
108
	  $(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
109
	rm -f $(MANDIR)/man1/cduce.1 \
110
	  $(MANDIR)/man1/cdo2ml.1
111
	rm -Rf $(DOCDIR)
112
	ocamlfind remove cduce
113

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

124 125
# Source directories 

126 127
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
128 129 130

# Objects to build

131
SCHEMA_OBJS = \
132
 schema/schema_pcre.cmo \
133 134 135 136 137 138
 schema/schema_types.cmo \
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
139
 schema/schema_converter.cmo 
140

141
OBJECTS = \
142
 driver/config.cmo \
143
 misc/stats.cmo \
144
 misc/serialize.cmo misc/custom.cmo \
145
 misc/state.cmo misc/pool.cmo misc/encodings.cmo \
146
 misc/upool.cmo \
147
  misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo misc/imap.cmo \
148
 misc/html.cmo \
149
 \
150
 types/sortedList.cmo misc/bool.cmo types/boolean.cmo types/ident.cmo \
151 152
 types/intervals.cmo \
 types/chars.cmo types/atoms.cmo \
153
 types/normal.cmo \
154
 types/types.cmo types/sample.cmo types/sequence.cmo types/patterns.cmo \
155
 compile/auto_opt.cmo \
156
 types/builtin_defs.cmo \
157
 \
158
 compile/lambda.cmo \
159 160
 runtime/value.cmo \
 \
161
 parser/location.cmo  parser/url.cmo \
162
  \
163
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
164
 \
165
 types/externals.cmo \
166
 typing/typed.cmo typing/typepat.cmo typing/typer.cmo \
167
 \
168 169
 $(SCHEMA_OBJS) \
 \
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
 driver/librarian.cmo \
178 179
 driver/cduce.cmo \
 runtime/system.cmo
180

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 203 204 205 206 207
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

208 209
ifeq ($(PXP),true)
  OBJECTS += runtime/cduce_pxp.cmo
210
  PACKAGES += $(PXP_PACK)
211
endif
212 213 214 215
ifeq ($(EXPAT), true)
  OBJECTS += runtime/cduce_expat.cmo
  PACKAGES += expat
endif
216

217

218 219
#CQL_OBJECTS= query/query_aggregates.cmo query/query.cmo query/query_parse.cmo 
#CQL_OBJECTS_RUN = query/query_run.cmo
220
CQL_OBJECTS= query/query_aggregates.cmo
221
CQL_OBJECTS_RUN=
222

223 224
OBJECTS += $(CQL_OBJECTS)

225 226
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

227 228
OBJECTS += $(CQL_OBJECTS_RUN) 
OBJECTS += driver/run.cmo
229
CDUCE = $(OBJECTS) driver/start.cmo 
230

231 232 233
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
234
 tools/validate.cmo \
235 236
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
237 238
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

239
ALL_INTERFACES = schema/schema_types.mli 
240

241
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
242

243 244
INCLUDES = $(DIRS:%=-I %)

245
cduce: $(CDUCE:.cmo=.$(EXTENSION))
246 247
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
248

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

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

256

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

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

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

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

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

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

302 303 304
distclean: clean
	rm -f Makefile.conf

305
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
306

307
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
308
$(ALL_INTERFACES): misc/q_symbol.cmo
309 310 311

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

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

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

.ml.cmx:
321 322
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
323 324

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

include depend

330
# Documentation
331

332
doc: cduce web/site.cdo
333
	mkdir -p web/doc
334
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
335

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

web/xhtml.cdo: cduce web/xhtml.cd
340
	./cduce -I web/ --compile web/xhtml.cd
341

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

350 351 352 353 354 355 356 357 358 359 360 361 362

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