Makefile.distrib 8.63 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-rc1
3

4
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring 
5
ifeq ($(PXP_WLEX), true)
6
  PACKAGES += pxp-wlex-utf8
7
else
8
  PACKAGES += pxp-lex-utf8
9
endif
10

11 12 13 14
# webiface can be made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
# Seems to be some problems with statically linking curl
# EXTRA_OPTS_WEBIFACE = -ccopt -static
15

16
SYNTAX = -I misc/ q_symbol.cmo \
17
  -symbol cduce_version=\"$(VERSION)\" \
18 19
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
20 21 22 23 24 25

ifeq ($(NATIVE), true)
	SYNTAX += -symbol ocaml_compiler=\"native\"
else
	SYNTAX += -symbol ocaml_compiler=\"bytecode\"
endif
26

27
ifeq ($(EXPAT), true)
28 29
  PACKAGES += expat
  SYNTAX += -symbol EXPAT=
30 31
endif

32 33 34 35 36
ifeq ($(CURL), true)
  PACKAGES += curl
  SYNTAX += -symbol CURL=
endif

37 38 39 40 41
ifeq ($(NETCLIENT), true)
  PACKAGES += netclient
  SYNTAX += -symbol NETCLIENT=
endif

42
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
43

44
CAMLC_P = ocamlc -g
45
DEPEND_OCAMLDEP = misc/q_symbol.cmo
46
ifeq ($(PROFILE), true)
47 48 49 50 51 52
  CAMLOPT_P = ocamlopt -p
  ifeq ($(NATIVE), false) 
    CAMLC_P = ocamlcp -p a
    SYNTAX_PARSER = 
    DEPEND_OCAMLDEP =
  endif
53
else
54
  CAMLOPT_P = ocamlopt -inline 25
55 56
endif

57
OPT = -warn-error FPS
58 59 60 61 62 63 64 65
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
66 67 68
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
69 70

ifeq ($(NATIVE), true)
71 72 73 74
  EXTENSION = cmx
  EXTENSION_LIB = cmxa
  COMPILE = $(CAMLOPT)
  LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
75
else
76 77 78 79
  EXTENSION = cmo
  EXTENSION_LIB = cma
  COMPILE = $(CAMLC)
  LINK = $(CAMLC) -custom -linkpkg gramlib.cma
80 81
endif

82
ifneq ($(ML_INTERFACE), false)
83 84
  SYNTAX += -symbol ML_INTERFACE=
  ML_LIB = oCaml_all.$(EXTENSION_LIB)
85
  ML_INTERFACE_OBJ = ocamliface/mltypes.cmo ocamliface/mlstub.cmo
86
else
87
  ML_INTERFACE_OBJ = 
88
endif
89

90
INSTALL := $(shell which install)
91

92
all: cduce dtd2cduce validate cdo2ml
93

94
ifneq ($(ML_INTERFACE), false)
95 96 97 98 99 100 101
all: cDuce_all.cma
endif

ifeq ($(NATIVE),true)
all: cDuce_all.cmxa
cDuce_all.cma:
	$(MAKE) NATIVE=false $@
102 103
endif

104
install: all install_lib
105 106
	mkdir -p $(BINDIR)
	mkdir -p $(MANDIR)/man1
107 108
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
                         validate$(EXE) cdo2ml$(EXE) $(BINDIR)/
109 110 111
	$(INSTALL) -m644 doc/cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/dtd2cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/validate.1 $(MANDIR)/man1/
112

113
install_lib:
114
ifneq ($(ML_INTERFACE), false)
115 116 117 118 119 120 121 122 123 124
	@echo "--> Build META"
	@echo 'version="$(VERSION)"' > META
	@echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
	@echo 'description="Runtime support for CDuce"' >> META
	@echo 'archive(byte)="oCaml_all.cma,cDuce_all.cma"' >> META
	@echo 'archive(native)="oCaml_all.cmxa,cDuce_all.cmxa"' >> META
	-$(OCAMLFIND) remove cduce
	-$(OCAMLFIND) install cduce META \
         cDuce_all.cmi oCaml_all.cmi \
	 $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a)
125 126
endif

127
uninstall:
128 129 130 131 132
	rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
	  $(BINDIR)/validate$(EXE) $(BINDIR)/cdo2ml$(EXE)
	rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \
	  $(MANDIR)/man1/validate.1
	ocamlfind remove cduce
133

134 135 136 137
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
138
	@echo "  validate : compiles the schema validation tool"
139 140 141 142 143 144 145 146 147
	@echo "  webiface : compiles the CDuce web interface interpreter (CGI script)"
	@echo "  webpages : compiles in web/www/ the files for the CDuce website"
	@echo "             (including the tutorial and manual)"
	@echo "  install_web : compiles webiface and webpages, and install everything"
	@echo "  all : equivalent to (make cduce dtd2cduce validate)"
	@echo "  install : install cduce dtd2cduce, validate et man pages"
	@echo "  clean :  back to the starting point"
	@echo "  uninstall : remove installed files"

148 149
# Source directories 

150 151
DIRS = misc parser schema typing types compile runtime driver query ocamliface
CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
152 153 154 155

# Objects to build

OBJECTS = \
156
 misc/stats.cmo \
157
 misc/serialize.cmo misc/custom.cmo \
158
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
159
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo misc/imap.cmo \
160 161
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
162 163
 types/intervals.cmo types/chars.cmo types/atoms.cmo \
 types/normal.cmo \
164
 types/types.cmo types/patterns.cmo types/sequence.cmo \
165 166
 types/sample.cmo types/builtin_defs.cmo \
 \
167
 compile/lambda.cmo \
168
 runtime/value.cmo \
169
 types/externals.cmo \
170
 \
171
 schema/schema_types.cmo \
172 173 174 175 176
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
177
 \
178
 parser/location.cmo parser/url.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
179 180 181
 \
 typing/typed.cmo typing/typer.cmo \
 \
182
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
183
 runtime/explain.cmo \
184
 runtime/print_xml.cmo runtime/eval.cmo \
185
 compile/compile.cmo \
186
 compile/operators.cmo \
187
 \
188
 types/builtin.cmo \
189 190 191
 driver/librarian.cmo

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
192 193

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
194
CQL_OBJECTS_RUN = query/query_run.cmo
195

196 197
VALIDATE_OBJECTS := $(shell for o in $(OBJECTS); do echo $$o; if [ "$$o" = "schema/schema_parser.cmo" ]; then exit 0; fi; done)	# all objects until schema_parser.cmo

198 199
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
200 201
DTD2CDUCE = tools/dtd2cduce.cmo

202
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
203
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
204 205
 tools/dtd2cduce.cmo tools/validate.cmo \
 $(CQL_OBJECTS_RUN)
206
ALL_INTERFACES = schema/schema_types.mli 
207

208
ifneq ($(ML_INTERFACE), false)
209
  ALL_INTERFACES += ocamliface/mltypes.mli ocamliface/mlstub.mli
210 211
endif

212
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
213

214 215
INCLUDES = $(DIRS:%=-I %)

216
cduce: $(CDUCE:.cmo=.$(EXTENSION))
217
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
218

219 220 221 222 223 224 225 226
cduce_packed.ml: $(CDUCE:.cmo=.ml)
	rm -f cduce_packed.ml
	ocaml tools/pack.ml $^ > cduce_packed.ml

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


227
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
228 229 230 231
	@echo "--> Build $@"
	@$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
	@$(COMPILE) -a -o $@ cDuce_all.$(EXTENSION)

232

233 234 235
oCaml_all.$(EXTENSION_LIB):
	cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@

236
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
237
	$(LINK) -verbose $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_OPTS_WEBIFACE)
238 239

dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
240
	$(LINK) $(INCLUDES) -o $@ $^
241

242
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
243 244
	$(LINK) $(INCLUDES) -o $@ $^

245 246 247
cdo2ml: ocamliface/cdo2ml.ml
	ocamlc -o $@ -pp camlp4o -I +camlp4 camlp4.cma pr_o.cmo $^

248
.PHONY: compute_depend
249
compute_depend: $(DEPEND_OCAMLDEP)
250
	echo $(DEPEND)
251
	@echo "Computing dependencies ..."
252
	ocamlfind ocamldep -package "$(PACKAGES)" \
253
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
254 255
clean:
	for i in $(CLEAN_DIRS); do \
256
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
257
	done
258
	(cd expat; $(MAKE) clean)
259
	rm -f `find . -name "*~"`
260
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
261 262
	rm -f cduce$(EXE) ocamlprof.dump
	rm -f dtd2cduce$(EXE) webiface$(EXE) validate$(EXE) cdo2ml$(EXE)
263
	rm -Rf prepro package
264
	rm -f web/www/*.html web/*~
265
	rm -f web/*.cdo
266

267 268 269
distclean: clean
	rm -f Makefile.conf

270 271
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

272
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
273
$(ALL_INTERFACES): misc/q_symbol.cmo
274 275 276

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

277
misc/q_symbol.cmo: misc/q_symbol.ml
278
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
279

280
.ml.cmo:
281
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
282 283 284 285 286 287 288 289 290 291 292 293

.ml.cmx:
	$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<

.mli.cmi:
	$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<

include depend

# CDuce-generated files

driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml
294
	(cd web/examples; ../../cduce build.cd --arg examples.xml)
295

296
webpages: cduce web/site.cdo
297
	(cd web; ../cduce --run site.cdo --arg site.xml)
298

299
web/site.cdo: cduce web/xhtml.cdo web/site.cd
300
	./cduce -I web/ --compile web/site.cd
301 302

web/xhtml.cdo: cduce web/xhtml.cd
303
	./cduce -I web/ --compile web/xhtml.cd
304

305
website: webpages webiface
306

307
install_web: website
308
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
309
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
310
	cp webiface $(CGI_DIR)/cduce
311 312
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
313
	fi;  
314
	cp web/img/*.*  $(HTML_DIR)/img
315