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

4

5 6 7 8
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
9 10
  ALL_TARGET += mlcduce_wrapper
  INSTALL_BINARIES += mlcduce_wrapper$(EXE) cduce_mktop
11 12 13 14
endif


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

19
PACKAGES = ulex camlp4 pcre num netstring cgi
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
  CAMLOPT_P = ocamlopt -p -inline 10000
43 44 45 46 47
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
48
else
49
  CAMLOPT_P = ocamlopt -inline 10000
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
  COMPILE = $(CAMLOPT)
70
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa camlp4.cmxa pr_o.cmx
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 camlp4.cma pr_o.cmo
78
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
79 80
endif

81

82
INSTALL := install -c
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)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
109
	rm -f $(MANDIR)/man1/cduce.1
110
	rm -Rf $(DOCDIR)
111
	ocamlfind remove cduce
112

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

123 124
# Source directories 

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

# Objects to build

130
LIB_OBJECTS = \
131 132
 driver/config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
 misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo \
133
 \
134 135 136 137
 types/compunit.cmo types/sortedList.cmo misc/bool.cmo types/ident.cmo \
 types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \
 types/types.cmo compile/auto_pat.cmo \
 types/sequence.cmo types/builtin_defs.cmo \
138 139 140
 \
 runtime/value.cmo \
 \
141 142 143
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
144
 \
145
 types/patterns.cmo \
146
 \
147 148 149 150 151
 compile/lambda.cmo \
 runtime/run_dispatch.cmo runtime/explain.cmo runtime/eval.cmo \
 \
 parser/location.cmo  parser/url.cmo \
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
152
 \
153
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
154
 compile/compile.cmo \
155
 \
156 157 158 159
 schema/schema_parser.cmo schema/schema_converter.cmo \
 runtime/load_xml.cmo runtime/print_xml.cmo compile/operators.cmo types/builtin.cmo \
 driver/librarian.cmo types/sample.cmo \
 compile/print_auto.cmo \
160
 driver/cduce.cmo \
161 162
 \
 runtime/system.cmo query/query_aggregates.cmo
163

164 165
OBJECTS=$(LIB_OBJECTS)

166 167
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
168 169 170 171
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.mli
	cp $^ $@
172

173
ML_INTERFACE_OBJS = \
174 175
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
176 177 178 179 180 181

ifneq ($(ML_INTERFACE), false)
  OBJECTS += $(ML_INTERFACE_OBJS)
endif

ifneq ($(CURL), false)
182
  LIB_OBJECTS += parser/cduce_curl.cmo
183 184 185
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
186
  LIB_OBJECTS += parser/cduce_netclient.cmo
187 188 189
  PACKAGES += netclient
endif

190 191 192 193 194 195 196
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

197
ifeq ($(PXP),true)
198
  LIB_OBJECTS += runtime/cduce_pxp.cmo
199
  PACKAGES += $(PXP_PACK)
200
endif
201
ifeq ($(EXPAT), true)
202
  LIB_OBJECTS += runtime/cduce_expat.cmo
203 204
  PACKAGES += expat
endif
205

206

207
OBJECTS += driver/run.cmo
208
CDUCE = $(OBJECTS) driver/start.cmo 
209

210 211 212
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
213
 tools/validate.cmo \
214 215
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
216 217
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

218
ALL_INTERFACES = schema/schema_types.mli 
219

220
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
221

222
INCLUDES = $(DIRS:%=-I %) -I +camlp4
223

224
cduce: $(CDUCE:.cmo=.$(EXTENSION))
225 226
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
227

228 229 230 231 232
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
233
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
234

235

236
cduce_lib.$(EXTENSION_LIB): $(LIB_OBJECTS:.cmo=.$(EXTENSION))
237
	@echo "Pack cduce_lib.$(EXTENSION)"
238
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
239
	@echo "Build $@"
240
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
241

242
dtd2cduce: tools/dtd2cduce.ml
243
	@echo "Build $@"
244
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
245

246
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
247
	@echo "Build $@"
248
	$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
249

250
.PHONY: compute_depend
251
compute_depend: $(DEPEND_OCAMLDEP)
252
	@echo "Computing dependencies ..."
253
	ocamlfind ocamldep -package "$(PACKAGES)" \
254
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
255 256
clean:
	for i in $(CLEAN_DIRS); do \
257
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
258
	done
259
	rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
260
	rm -f `find . -name "*~"`
261
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
262
	rm -f cduce$(EXE) ocamlprof.dump
263
	rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) \
264
		mlcduce_wrapper$(EXE) evaluator$(EXE)
265
	rm -Rf prepro package
266
	rm -f web/www/*.html web/*~
267
	rm -f web/*.cdo
268
	rm -f configure.log
269
	rm -rf web/doc
270
	rm -f META
271

272 273 274
distclean: clean
	rm -f Makefile.conf

275
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
276

277
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
278
$(ALL_INTERFACES): misc/q_symbol.cmo
279 280 281

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

282
misc/q_symbol.cmo: misc/q_symbol.ml
283 284
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
285

286
.ml.cmo:
287 288
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
289 290

.ml.cmx:
291 292
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
293 294

.mli.cmi:
295 296
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
297 298 299

include depend

300
# Documentation
301

302
doc: cduce web/site.cdo
303
	mkdir -p web/doc
304
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
305

306
web/site.cdo: cduce web/xhtml.cdo web/site.cd
307
	./cduce -I web/ --compile web/site.cd
308 309

web/xhtml.cdo: cduce web/xhtml.cd
310
	./cduce -I web/ --compile web/xhtml.cd
311

312
install_doc: doc
313
	$(HIDE)mkdir -p $(MANDIR)/man1
314
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
315 316
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
317
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
318
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
319

320 321 322 323 324 325 326 327 328 329 330 331 332

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