Makefile.distrib 8 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 13
endif


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

18
PACKAGES = ulex camlp4 pcre num netstring cgi
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
  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 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
  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
INSTALL := install -c
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) $(BINDIR)/cduce_mktop
107
	rm -f $(MANDIR)/man1/cduce.1
108
	rm -Rf $(DOCDIR)
109
	ocamlfind remove cduce
110

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

121 122
# Source directories 

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

# Objects to build

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

162 163
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
164 165 166 167
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.mli
	cp $^ $@
168

169
ML_INTERFACE_OBJS = \
170 171
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
172 173 174 175 176 177

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

ifneq ($(CURL), false)
178
  OBJECTS += parser/cduce_curl.cmo
179 180 181
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
182
  OBJECTS += parser/cduce_netclient.cmo
183 184 185
  PACKAGES += netclient
endif

186 187 188 189 190 191 192
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

193
ifeq ($(PXP),true)
194
  OBJECTS += runtime/cduce_pxp.cmo
195
  PACKAGES += $(PXP_PACK)
196 197
  ALL_TARGET += dtd2cduce
  INSTALL_BINARIES += dtd2cduce
198
endif
199
ifeq ($(EXPAT), true)
200
  OBJECTS += runtime/cduce_expat.cmo
201 202
  PACKAGES += expat
endif
203

204

205
OBJECTS += driver/run.cmo
206
CDUCE = $(OBJECTS) driver/start.cmo 
207

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

216
ALL_INTERFACES = schema/schema_types.mli 
217

218
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
219

220
INCLUDES = $(DIRS:%=-I %) -I +camlp4
221

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

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

cduce_packed: cduce_packed.$(EXTENSION)
231
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
232

233

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

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

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

265 266 267
distclean: clean
	rm -f Makefile.conf

268
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
269

270
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
271
$(ALL_INTERFACES): misc/q_symbol.cmo
272 273 274

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

275
misc/q_symbol.cmo: misc/q_symbol.ml
276 277
	@echo "Build $@"		  
	$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
278

279
.ml.cmo:
280 281
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
282 283

.ml.cmx:
284 285
	@echo "Build $@"
	$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
286 287

.mli.cmi:
288 289
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
290 291 292

include depend

293
# Documentation
294

295
doc: cduce web/site.cdo
296
	mkdir -p web/doc
297
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
298

299
web/site.cdo: cduce web/xhtml.cdo web/site.cd
300
	./cduce -I web/ --compile web/site.cd
301 302

web/xhtml.cdo: cduce web/xhtml.cd
303
	./cduce -I web/ --compile web/xhtml.cd
304

305
install_doc: doc
306
	$(HIDE)mkdir -p $(MANDIR)/man1
307
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
308 309
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
310
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
311
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
312

313 314 315 316 317 318 319 320 321 322 323 324 325

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