Makefile.distrib 8.28 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
  LINK = $(CAMLOPT) -linkpkg
  ifeq ($(NATDYNLINK), true)
    LINK += dynlink.cmxa
  endif
75 76 77
  ifeq ($(ADDICON), true)
    LINK += cduceres.o
  endif
78
  LINK += camlp4lib.cmxa
79
  SYNTAX += -symbol ocaml_compiler=\"native\"
80
else
81 82 83
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
84
  CAML=ocamlc
85
  LINK = $(CAMLC) -custom -linkpkg camlp4lib.cma
86
  SYNTAX += -symbol ocaml_compiler=\"bytecode\"
87 88
endif

89 90 91 92 93
ifeq ($(FORPACK),true)
  FORPACKOPT=-passopt -for-pack -passopt Cduce_lib
else
  FORPACKOPT=
endif
94

95
INSTALL := install -c
96 97

ifeq ($(NATIVE),true)
98
.PHONY: cduce_lib.cma
99 100
cduce_lib.cma:
	$(HIDE)$(MAKE) NATIVE=false $@
101 102
endif

103 104 105
install: all install_bin install_lib install_doc

install_bin:
106
	@echo "Install binaries"
107
	$(HIDE)mkdir -p $(BINDIR)
108
	$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
109

110

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

118

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

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

135 136
# Source directories 

137
DIRS = misc parser schema typing types compile runtime driver query ocamliface win32
138
CLEAN_DIRS = $(DIRS) tools tests
139 140 141

# Objects to build

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

176 177
schema/schema_types.ml: schema/schema_types.mli
	cp $^ $@
178 179 180 181
compile/auto_pat.ml: compile/auto_pat.mli
	cp $^ $@
compile/lambda.ml: compile/lambda.mli
	cp $^ $@
182

183
ML_INTERFACE_OBJS = \
184 185
  ocamliface/caml_cduce.cmo \
  ocamliface/mltypes.cmo ocamliface/mlstub.cmo
186 187 188 189 190 191

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

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

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

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

218 219 220
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
221

222 223
all: $(ALL_TARGET)

224
OBJECTS += driver/run.cmo
225
CDUCE = $(OBJECTS) driver/start.cmo 
226

227 228 229
ALL_OBJECTS = $(OBJECTS) \
 driver/start.cmo driver/examples.cmo \
 driver/webiface.cmo driver/evaluator.cmo \
230
 tools/validate.cmo \
231 232
 $(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
 parser/cduce_netclient.cmo \
233 234
 runtime/cduce_expat.cmo runtime/cduce_pxp.cmo

235
ALL_INTERFACES = schema/schema_types.mli 
236

237
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
238

239 240
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
241

242
cduce: $(CDUCE:.cmo=.$(EXTENSION))
243 244
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
245

246 247 248 249 250
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
251
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
252

253

254
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
255
	@echo "Pack cduce_lib.$(EXTENSION)"
256
	$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) $(INCLUDES) -pack $^
257
	@echo "Build $@"
258
	$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
259

260
dtd2cduce: tools/dtd2cduce.ml
261
	@echo "Build $@"
262
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) cgi" -linkpkg $^
263 264

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

285 286 287
distclean: clean
	rm -f Makefile.conf

288
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
289

290
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
291
$(ALL_INTERFACES): misc/q_symbol.cmo
292 293 294

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

295
misc/q_symbol.cmo: misc/q_symbol.ml
296
	@echo "Build $@"		  
297
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
298

299
.ml.cmo:
300 301
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
302 303

.ml.cmx:
304
	@echo "Build $@"
305
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
306 307

.mli.cmi:
308 309
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
310 311 312

include depend

313 314 315
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

316
# Documentation
317

318
doc: cduce web/site.cdo
319
	mkdir -p web/doc
320
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
321

322
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
323
	./cduce -I web/ --compile web/site.cd
324 325

web/xhtml.cdo: cduce web/xhtml.cd
326
	./cduce -I web/ --compile web/xhtml.cd
327

328
install_doc: doc
329
	$(HIDE)mkdir -p $(MANDIR)/man1
330
	$(HIDE)(cd doc; $(MAKE) install INSTALL="$(INSTALL)" MANDIR=$(MANDIR) HIDE=$(HIDE))
331 332
	mkdir -p $(DOCDIR)/img
	cp web/doc/*.html $(DOCDIR)/
333
	cp CHANGES INSTALL INSTALL.WIN32 README AUTHORS LICENSE $(DOCDIR)/
334
	cp web/img/left.gif web/img/right.gif $(DOCDIR)/img
335

336 337 338 339 340 341

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
342
	$(MAKE) caml_cduce.cmo
343 344 345

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
346
	$(MAKE) caml_cduce.cmx
347