Makefile.distrib 8.05 KB
Newer Older
1 2
default: cduce

3
include Makefile.conf
4
include VERSION
5

6

7 8 9 10
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)

ifneq ($(ML_INTERFACE), false)
11
  INSTALL_BINARIES += cduce_mktop
12 13 14
endif


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

19
PACKAGES = camlp4 ulex 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
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
35 36
  -symbol session_dir=\"$(SESSION_DIR)\" \
  -loc "_loc"
37

38
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
39

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

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

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

86 87 88 89 90
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
91

92
INSTALL := install -c
93 94

ifeq ($(NATIVE),true)
95
.PHONY: cduce_lib.cma
96 97
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
98 99
endif

100 101 102
install: all install_bin install_lib install_doc

install_bin:
103
	@echo "Install binaries"
104
	$(HIDE)mkdir -p $(BINDIR)
105
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
106

107

108
install_lib:
109
	@echo "Build META"
110
	$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
111 112 113 114
	$(HIDE)-$(OCAMLFIND) remove cduce
	$(HIDE)-$(OCAMLFIND) install cduce META \
         cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \

115

116
uninstall:
117
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
118
	rm -f $(MANDIR)/man1/cduce.1
119
	rm -Rf $(DOCDIR)
120
	ocamlfind remove cduce
121

122 123 124
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
125
	@echo "  dtd2cduce: compiles the dtd2cduce tools"
126 127 128
	@echo "  doc : build the documentation"
	@echo "  all : build binaries and libraries"
	@echo "  install : install binaries, man pages, documentation"
129 130 131
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

132 133
# Source directories 

134
DIRS = misc parser schema typing types compile runtime driver query ocamliface
135
CLEAN_DIRS = $(DIRS) tools tests
136 137 138

# Objects to build

139
OBJECTS = \
140
 driver/cduce_config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
141
 misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo \
142
 \
143 144 145 146
 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 \
147 148 149
 \
 runtime/value.cmo \
 \
150 151 152
 schema/schema_pcre.cmo schema/schema_types.cmo \
 schema/schema_xml.cmo schema/schema_common.cmo \
 schema/schema_builtin.cmo schema/schema_validator.cmo \
153
 \
154
 types/patterns.cmo \
155
 compile/print_auto.cmo \
156
 \
157 158 159
 compile/lambda.cmo \
 runtime/run_dispatch.cmo runtime/explain.cmo runtime/eval.cmo \
 \
160
 parser/cduce_loc.cmo  parser/url.cmo \
161
 parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
162
 \
163
 typing/typed.cmo typing/typepat.cmo types/externals.cmo typing/typer.cmo \
164
 compile/compile.cmo \
165
 \
166 167 168
 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 \
169
 driver/cduce.cmo \
170 171
 \
 runtime/system.cmo query/query_aggregates.cmo
172

173 174
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
175 176 177 178
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.mli
	cp $^ $@
179

180
ML_INTERFACE_OBJS = \
181 182
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
183 184 185 186 187 188

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

ifneq ($(CURL), false)
189
  OBJECTS += parser/cduce_curl.cmo
190 191 192
  PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
193
  OBJECTS += parser/cduce_netclient.cmo
194 195 196
  PACKAGES += netclient
endif

197 198 199 200 201 202 203
PXP_PACK=pxp-engine pxp-lex-iso88591
ifeq ($(PXP_WLEX), true)
  PXP_PACK += pxp-wlex-utf8
else
  PXP_PACK += pxp-lex-utf8
endif

204
ifeq ($(PXP),true)
205
  OBJECTS += runtime/cduce_pxp.cmo
206
  PACKAGES += $(PXP_PACK)
207 208
  ALL_TARGET += dtd2cduce
  INSTALL_BINARIES += dtd2cduce
209
endif
210
ifeq ($(EXPAT), true)
211
  OBJECTS += runtime/cduce_expat.cmo
212 213
  PACKAGES += expat
endif
214

215

216 217
all: $(ALL_TARGET)

218
OBJECTS += driver/run.cmo
219
CDUCE = $(OBJECTS) driver/start.cmo 
220

221 222 223
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
224
 tools/validate.cmo \
225 226
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
227 228
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

229
ALL_INTERFACES = schema/schema_types.mli 
230

231
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
232

233 234
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
235

236
cduce: $(CDUCE:.cmo=.$(EXTENSION))
237 238
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
239

240 241 242 243 244
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
245
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
246

247

248
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
249
	@echo "Pack cduce_lib.$(EXTENSION)"
250
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
251
	@echo "Build $@"
252
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
253

254
dtd2cduce: tools/dtd2cduce.ml
255
	@echo "Build $@"
256
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) cgi" -linkpkg $^
257 258

.PHONY: compute_depend
259
compute_depend: $(DEPEND_OCAMLDEP)
260
	@echo "Computing dependencies ..."
261
	ocamlfind ocamldep -package "$(PACKAGES)" \
262
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
263 264
clean:
	for i in $(CLEAN_DIRS); do \
265
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
266
	done
267
	(cd ocamliface; $(MAKE) clean)
268
	rm -f `find . -name "*~"`
269
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
270
	rm -f cduce$(EXE) ocamlprof.dump
271
	rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
272
	rm -Rf prepro package
273
	rm -f web/www/*.html web/*~
274
	rm -f web/*.cdo
275
	rm -f configure.log
276
	rm -rf web/doc
277
	rm -f META
278

279 280 281
distclean: clean
	rm -f Makefile.conf

282
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
283

284
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
285
$(ALL_INTERFACES): misc/q_symbol.cmo
286 287 288

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

289
misc/q_symbol.cmo: misc/q_symbol.ml
290
	@echo "Build $@"		  
291
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
292

293
.ml.cmo:
294 295
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
296 297

.ml.cmx:
298
	@echo "Build $@"
299
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
300 301

.mli.cmi:
302 303
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
304 305 306

include depend

307
# Documentation
308

309
doc: cduce web/site.cdo
310
	mkdir -p web/doc
311
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
312

313
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
314
	./cduce -I web/ --compile web/site.cd
315 316

web/xhtml.cdo: cduce web/xhtml.cd
317
	./cduce -I web/ --compile web/xhtml.cd
318

319
install_doc: doc
320
	$(HIDE)mkdir -p $(MANDIR)/man1
321
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
322 323
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
324
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
325
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
326

327 328 329 330 331 332

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
333
	$(MAKE) caml_cduce.cmo
334 335 336

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
337
	$(MAKE) caml_cduce.cmx
338