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

4

5 6 7 8 9 10 11 12 13 14
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)
15 16 17 18
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif

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

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

VERBOSE=false

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

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
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
68
  CAML=ocamlopt
69 70
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
71
  SYNTAX += -symbol ocaml_compiler=\"native\"
72
else
73 74 75
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
76
  CAML=ocamlc
77
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
78
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
79 80
endif

81

82
INSTALL := install
83 84

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

90 91 92
install: all install_bin install_lib install_doc

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

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

105

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

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

125 126
# Source directories 

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

# Objects to build

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

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

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

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

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

202 203 204 205 206 207 208
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

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

218

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

224 225
OBJECTS += $(CQL_OBJECTS)

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

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

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

240
ALL_INTERFACES = schema/schema_types.mli 
241

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

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

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

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

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

257

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

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

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

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

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

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

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

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

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

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

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

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

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

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

include depend

331
# Documentation
332

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

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

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

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

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

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