Makefile.distrib 8.39 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

Jérôme Maloberti's avatar
Jérôme Maloberti committed
19
PACKAGES = dynlink 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
    OBJECTS += runtime/cduce_pxp.cmo
    PACKAGES += $(PXP_PACK)
211 212
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
213
      PACKAGES += netcgi1
214 215 216
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
217
endif
218

219
ifeq ($(EXPAT), true)
220
  OBJECTS += runtime/cduce_expat.cmo
221 222
  PACKAGES += expat
endif
223

224 225 226
ifeq ($(ADDICON), true)
  OBJECTS += cduceres.o
endif
227

228 229
all: $(ALL_TARGET)

230
OBJECTS += driver/run.cmo
231
CDUCE = $(OBJECTS) driver/start.cmo 
232

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

241
ALL_INTERFACES = schema/schema_types.mli 
242

243
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
244

245 246
INCLUDES = $(DIRS:%=-I %)
# -I +camlp4
247

248
cduce: $(CDUCE:.cmo=.$(EXTENSION))
249 250
	@echo "Build $@"
	$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
251

252 253 254 255 256
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

cduce_packed: cduce_packed.$(EXTENSION)
257
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
258

259

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

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

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

291 292 293
distclean: clean
	rm -f Makefile.conf

294
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
295

296
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
297
$(ALL_INTERFACES): misc/q_symbol.cmo
298 299 300

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

301
misc/q_symbol.cmo: misc/q_symbol.ml
302
	@echo "Build $@"		  
303
	$(HIDE)$(CAMLC) -c -pp camlp4orf $<
304

305
.ml.cmo:
306 307
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
308 309

.ml.cmx:
310
	@echo "Build $@"
311
	$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
312 313

.mli.cmi:
314 315
	@echo "Build $@"
	$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
316 317 318

include depend

319 320 321
cduceres.o: win32/cduce.rc win32/cduce_logo-bw.ico
	(cd win32; windres -i cduce.rc -o cduceres.o; mv cduceres.o ..)

322
# Documentation
323

324
doc: cduce web/site.cdo
325
	mkdir -p web/doc
326
	(cd web; ../cduce --run site.cdo --arg doc.xml -o doc)
327

328
web/site.cdo: cduce web/xhtml.cdo web/site.cd web/siteTypes.cd
329
	./cduce -I web/ --compile web/site.cd
330 331

web/xhtml.cdo: cduce web/xhtml.cd
332
	./cduce -I web/ --compile web/xhtml.cd
333

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

342 343 344 345 346 347

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


ocamliface/caml_cduce.cmo:
	@cd ocamliface; \
348
	$(MAKE) caml_cduce.cmo
349 350 351

ocamliface/caml_cduce.cmx:
	@cd ocamliface; \
352
	$(MAKE) caml_cduce.cmx
353