Makefile.distrib 8.32 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 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 209 210 211 212 213
    ifeq ($(CGI),true)
      OBJECTS += runtime/cduce_pxp.cmo
      PACKAGES += $(PXP_PACK) cgi
      ALL_TARGET += dtd2cduce
      INSTALL_BINARIES += dtd2cduce
  endif
214
endif
215
ifeq ($(EXPAT), true)
216
  OBJECTS += runtime/cduce_expat.cmo
217 218
  PACKAGES += expat
endif
219

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

224 225
all: $(ALL_TARGET)

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

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

237
ALL_INTERFACES = schema/schema_types.mli 
238

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

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

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

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

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

255

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

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

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

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

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

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

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

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

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

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

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

include depend

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

318
# Documentation
319

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

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

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

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

338 339 340 341 342 343

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


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

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