Makefile.distrib 8.33 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 
20 21 22

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

Pietro Abate's avatar
Pietro Abate committed
23
VERBOSE=false
24 25 26 27 28 29 30

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
Pietro Abate's avatar
Pietro Abate committed
62 63

OCAMLFIND = ocamlfind
64 65
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
66 67

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

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

96
INSTALL := install -c
97 98

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

104 105 106
install: all install_bin install_lib install_doc

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

111

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

119

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

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

136 137
# Source directories 

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

# Objects to build

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

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

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

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

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

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

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

221 222 223
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
224

225 226
all: $(ALL_TARGET)

227
OBJECTS += driver/run.cmo
228
CDUCE = $(OBJECTS) driver/start.cmo 
229

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

238
ALL_INTERFACES = schema/schema_types.mli 
239

240
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
241

242 243
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
244

245
cduce: $(CDUCE:.cmo=.$(EXTENSION))
246 247
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
248

249 250 251 252 253
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
254
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
255

256

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

263
dtd2cduce: tools/dtd2cduce.ml
264
	@echo "Build $@"
265
	$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi1" -linkpkg $^
266 267

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

288 289 290
distclean: clean
	rm -f Makefile.conf

291
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
292

293
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
294
$(ALL_INTERFACES): misc/q_symbol.cmo
295 296 297

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

298
misc/q_symbol.cmo: misc/q_symbol.ml
299
	@echo "Build $@"		  
300
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
301

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

.ml.cmx:
307
	@echo "Build $@"
308
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
309 310

.mli.cmi:
311 312
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
313 314 315

include depend

316 317 318
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

319
# Documentation
320

321
doc: cduce web/site.cdo
322
	mkdir -p web/doc
323
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
324

325
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
326
	./cduce -I web/ --compile web/site.cd
327 328

web/xhtml.cdo: cduce web/xhtml.cd
329
	./cduce -I web/ --compile web/xhtml.cd
330

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

339 340 341 342 343 344

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
345
	$(MAKE) caml_cduce.cmo
346 347 348

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
349
	$(MAKE) caml_cduce.cmx
350