Makefile.distrib 8.53 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre5
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
all: cdml.$(EXTENSION_LIB)
96 97
endif

98
install: all
99 100
	mkdir -p $(BINDIR)
	mkdir -p $(MANDIR)/man1
101 102
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
                         validate$(EXE) cdo2ml$(EXE) $(BINDIR)/
103 104 105
	$(INSTALL) -m644 doc/cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/dtd2cduce.1 $(MANDIR)/man1/
	$(INSTALL) -m644 doc/validate.1 $(MANDIR)/man1/
106
ifneq ($(ML_INTERFACE), false)
107 108 109 110
	$(OCAMLFIND) install cduce META \
         cdml.$(EXTENSION_LIB) cdo2cmo/cdml.cmi \
         cDuce_all.cmi oCaml_all.$(EXTENSION_LIB) \
         $(wildcard *.a) oCaml_all.cmi
111 112
endif

113
uninstall:
114 115 116 117 118
	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
119

120 121 122 123
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
124
	@echo "  validate : compiles the schema validation tool"
125 126 127 128 129 130 131 132 133
	@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"

134 135
# Source directories 

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

# Objects to build

OBJECTS = \
142
 misc/stats.cmo \
143
 misc/serialize.cmo misc/custom.cmo \
144
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
145
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo misc/imap.cmo \
146 147
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
148 149
 types/intervals.cmo types/chars.cmo types/atoms.cmo \
 types/normal.cmo \
150
 types/types.cmo types/patterns.cmo types/sequence.cmo \
151 152
 types/sample.cmo types/builtin_defs.cmo \
 \
153
 compile/lambda.cmo \
154 155
 runtime/value.cmo \
 \
156
 schema/schema_types.cmo \
157 158 159 160 161
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
162
 \
163
 parser/location.cmo parser/url.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
164 165 166
 \
 typing/typed.cmo typing/typer.cmo \
 \
167
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
168
 runtime/explain.cmo \
169
 runtime/print_xml.cmo runtime/eval.cmo \
170
 compile/compile.cmo \
171
 compile/operators.cmo \
172
 \
173
 types/builtin.cmo \
174 175 176
 driver/librarian.cmo

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
177 178

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
179
CQL_OBJECTS_RUN = query/query_run.cmo
180

181 182
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

183 184
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
185 186
DTD2CDUCE = tools/dtd2cduce.cmo

187
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
188
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
189 190
 tools/dtd2cduce.cmo tools/validate.cmo \
 $(CQL_OBJECTS_RUN)
191
ALL_INTERFACES = schema/schema_types.mli 
192

193 194 195 196
ifneq ($(ML_INTERFACE), false)
  ALL_INTERFACES += ocamliface/mltypes.mli ocamluface/mlstub.mli
endif

197
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
198

199 200
INCLUDES = $(DIRS:%=-I %)

201
cduce: $(CDUCE:.cmo=.$(EXTENSION))
202
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
203

204 205 206 207 208 209 210 211
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)


212 213 214 215 216 217
cdml.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	echo 'version="$(VERSION)"' > META
	echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
	echo 'description="Runtime support for CDuce"' >> META
	echo 'archive(byte)="oCaml_all.cma,cdml.cma"' >> META
	echo 'archive(native)="oCaml_all.cmxa,cdml.cmxa"' >> META
218
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
219
	$(COMPILE) -c cdo2cmo/cdml.mli
220 221 222
	$(COMPILE) -c cdo2cmo/cdml.ml
	$(COMPILE) -a -o cdml.$(EXTENSION_LIB) \
		cDuce_all.$(EXTENSION) \
223
		cdo2cmo/cdml.$(EXTENSION)
224

225 226 227
oCaml_all.$(EXTENSION_LIB):
	cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@

228
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
229
	$(LINK) -verbose $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_OPTS_WEBIFACE)
230 231

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

234
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
235 236
	$(LINK) $(INCLUDES) -o $@ $^

237 238 239
cdo2ml: ocamliface/cdo2ml.ml
	ocamlc -o $@ -pp camlp4o -I +camlp4 camlp4.cma pr_o.cmo $^

240
.PHONY: compute_depend
241
compute_depend: $(DEPEND_OCAMLDEP)
242
	echo $(DEPEND)
243
	@echo "Computing dependencies ..."
244
	ocamlfind ocamldep -package "$(PACKAGES)" \
245
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
246 247
clean:
	for i in $(CLEAN_DIRS); do \
248
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
249
	done
250
	(cd expat; $(MAKE) clean)
251
	rm -f `find . -name "*~"`
252 253
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
254
	rm -f dtd2cduce pool webiface validate
255
	rm -Rf prepro package
256
	rm -f web/www/*.html web/*~
257
	rm -f web/*.cdo
258

259 260 261
distclean: clean
	rm -f Makefile.conf

262 263
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

264
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
265
$(ALL_INTERFACES): misc/q_symbol.cmo
266 267 268

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

269
misc/q_symbol.cmo: misc/q_symbol.ml
270
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
271

272
.ml.cmo:
273
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
274 275 276 277 278 279 280 281 282 283 284 285

.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
286
	(cd web/examples; ../../cduce build.cd --arg examples.xml)
287

288
webpages: cduce web/site.cdo
289
	(cd web; ../cduce --run site.cdo --arg site.xml)
290

291
web/site.cdo: cduce web/xhtml.cdo web/site.cd
292
	./cduce -I web/ --compile web/site.cd
293 294

web/xhtml.cdo: cduce web/xhtml.cd
295
	./cduce -I web/ --compile web/xhtml.cd
296

297
website: webpages webiface
298

299
install_web: website
300
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
301
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
302
	cp webiface $(CGI_DIR)/cduce
303 304
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
305
	fi;  
306
	cp web/img/*.*  $(HTML_DIR)/img
307