Makefile.distrib 7.99 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
  INSTALL_BINARIES += cduce_mktop
10 11 12
endif


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

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

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

VERBOSE=false

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

29

30
SYNTAX = -I misc/ q_symbol.cmo \
31
  -symbol cduce_version=\"$(VERSION)\" \
32
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
33 34
  -symbol session_dir=\"$(SESSION_DIR)\" \
  -loc "_loc"
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
  CAMLOPT_P = ocamlopt -p -inline 10000
42 43 44 45 46
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
47
else
48
  CAMLOPT_P = ocamlopt -inline 10000
49 50
endif

51
OPT = -warn-error FPSXY
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
  COMPILE = $(CAMLOPT)
69
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa camlp4.cmxa pr_o.cmx
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 camlp4.cma pr_o.cmo
77
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
78 79
endif

80 81 82 83 84
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
85

86
INSTALL := install -c
87 88

ifeq ($(NATIVE),true)
89
.PHONY: cduce_lib.cma
90 91
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
92 93
endif

94 95 96
install: all install_bin install_lib install_doc

install_bin:
97
	@echo "Install binaries"
98
	$(HIDE)mkdir -p $(BINDIR)
99
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
100
	
101

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

109

110
uninstall:
111
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
112
	rm -f $(MANDIR)/man1/cduce.1
113
	rm -Rf $(DOCDIR)
114
	ocamlfind remove cduce
115

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

126 127
# Source directories 

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

# Objects to build

133
OBJECTS = \
134 135
 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 \
136
 \
137 138 139 140
 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 \
141 142 143
 \
 runtime/value.cmo \
 \
144 145 146
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
147
 \
148
 types/patterns.cmo \
149
 \
150 151 152 153 154
 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 \
155
 \
156
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
157
 compile/compile.cmo \
158
 \
159 160 161 162
 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 \
163
 driver/cduce.cmo \
164 165
 \
 runtime/system.cmo query/query_aggregates.cmo
166

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

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

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

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

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

198
ifeq ($(PXP),true)
199
  OBJECTS += runtime/cduce_pxp.cmo
200
  PACKAGES += $(PXP_PACK)
201 202
  ALL_TARGET += dtd2cduce
  INSTALL_BINARIES += dtd2cduce
203
endif
204
ifeq ($(EXPAT), true)
205
  OBJECTS += runtime/cduce_expat.cmo
206 207
  PACKAGES += expat
endif
208

209

210 211
all: $(ALL_TARGET)

212
OBJECTS += driver/run.cmo
213
CDUCE = $(OBJECTS) driver/start.cmo 
214

215 216 217
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
218
 tools/validate.cmo \
219 220
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
221 222
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

223
ALL_INTERFACES = schema/schema_types.mli 
224

225
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
226

227
INCLUDES = $(DIRS:%=-I %) -I +camlp4
228

229
cduce: $(CDUCE:.cmo=.$(EXTENSION))
230 231
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
232

233 234 235 236 237
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
238
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
239

240

241
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
242
	@echo "Pack cduce_lib.$(EXTENSION)"
243
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
244
	@echo "Build $@"
245
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
246

247
dtd2cduce: tools/dtd2cduce.ml
248
	@echo "Build $@"
249
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) cgi" -linkpkg $^
250 251

.PHONY: compute_depend
252
compute_depend: $(DEPEND_OCAMLDEP)
253
	@echo "Computing dependencies ..."
254
	ocamlfind ocamldep -package "$(PACKAGES)" \
255
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
256 257
clean:
	for i in $(CLEAN_DIRS); do \
258
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
259
	done
260
	(cd ocamliface; make clean)
261
	rm -f `find . -name "*~"`
262
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
263
	rm -f cduce$(EXE) ocamlprof.dump
264
	rm -f dtd2cduce$(EXE) webiface$(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
	@echo "Build $@"
292
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -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

### Pack OCaml modules for the CDuce/OCaml interface


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
326
	$(MAKE) caml_cduce.cmo
327 328 329

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
330
	$(MAKE) caml_cduce.cmx
331