Makefile.distrib 7.84 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre4
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 15 16 17
#
# Check if running Cygwin
#

18
ifneq (,$(findstring Cygwin, $(shell echo "Sys.os_type;;" | ocaml))) 
19 20 21 22 23 24
    EXE=.exe
else
    EXE= 
endif


25
SYNTAX = -I misc/ q_symbol.cmo \
26
  -symbol cduce_version=\"$(VERSION)\" \
27 28
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
29 30 31 32 33 34

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

36
ifeq ($(EXPAT), true)
37
	PACKAGES += expat
38 39 40
	SYNTAX += -symbol EXPAT=
endif

41 42 43 44 45
ifeq ($(CURL), true)
  PACKAGES += curl
  SYNTAX += -symbol CURL=
endif

46 47 48 49 50
ifeq ($(NETCLIENT), true)
  PACKAGES += netclient
  SYNTAX += -symbol NETCLIENT=
endif

51
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
52

53
CAMLC_P = ocamlc -g
54
DEPEND_OCAMLDEP = misc/q_symbol.cmo
55 56
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
57 58 59
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
60
         DEPEND_OCAMLDEP =
61
	endif
62
else
63
	CAMLOPT_P = ocamlopt -inline 25
64 65
endif

66
OPT = -warn-error FPS
67 68 69 70 71 72 73 74
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
75 76 77
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
78 79 80

ifeq ($(NATIVE), true)
	EXTENSION = cmx
81 82
	EXTENSION_LIB = cmxa
	COMPILE = $(CAMLOPT)
83
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
84 85
else
	EXTENSION = cmo
86 87
	EXTENSION_LIB = cma
	COMPILE = $(CAMLC)
88
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
89 90
endif

91 92 93 94 95 96 97 98 99 100 101 102
ifeq ($(ML_INTERFACE), true)
  SYNTAX += -symbol ML_INTERFACE=
  ML_LIB = oCaml_all.$(EXTENSION_LIB)
  ML_INTERFACE_OBJ = \
	cdo2cmo/ml_types.cmo \
	cdo2cmo/ml_cduce.cmo \
	cdo2cmo/ml_ocaml.cmo \
	cdo2cmo/ml_checker.cmo \
	cdo2cmo/ml_generator.cmo
else
  ML_INTERFACE_OBJ= 
endif
103

104
INSTALL := $(shell which install)
105

106
all: cduce cDuce_all.cma dtd2cduce validate
107 108 109 110

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
111
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) validate$(EXE) $(PREFIX)/bin/
112
	$(INSTALL) -m644 doc/cduce.1 $(PREFIX)/man/man1/
113 114
	$(INSTALL) -m644 doc/dtd2cduce.1 $(PREFIX)/man/man1/
	$(INSTALL) -m644 doc/validate.1 $(PREFIX)/man/man1/
115 116

uninstall:
117
	rm  $(PREFIX)/bin/cduce$(EXE) \
118
	    $(PREFIX)/bin/dtd2cduce$(EXE) \
119
	    $(PREFIX)/bin/validate$(EXE) \
120 121 122
	    $(PREFIX)/man/man1/cduce.1 \
	    $(PREFIX)/man/man1/dtd2cduce.1 \
	    $(PREFIX)/man/man1/validate.1
123

124 125 126 127
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
128
	@echo "  validate : compiles the schema validation tool"
129 130 131 132 133 134 135 136 137 138 139
	@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"
	@echo ""
	@echo "OPTIONS (default value in brackets)"
	@echo "  PREFIX=<path> : set the prefix for installation [/usr/local]"
140 141 142 143 144 145
	@echo "  NATIVE=true|false : use the OCaml native code compiler to build CDuce [true]"
	@echo "  PXP_WLEX=true|false : use wlex for parsing UTF-8 XML files [false]"
	@echo "  EXPAT=true|false : build expat support [false]"
	@echo "  CURL=true|false: build curl support [false]"
	@echo "  NETCLIENT=true|false: build netclient support [true]"
	@echo "  ML_INTERFACE=true|false: build support for OCaml [false]"
146
	@echo ""
147

148 149
# Source directories 

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

# 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 167 168
 types/sample.cmo types/builtin_defs.cmo \
 \
 runtime/value.cmo \
 \
169 170 171 172 173
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
174
 \
175
 parser/location.cmo parser/url.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
176 177 178
 \
 typing/typed.cmo typing/typer.cmo \
 \
179
 compile/lambda.cmo \
180
 \
181
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
182
 runtime/explain.cmo \
183
 runtime/print_xml.cmo runtime/eval.cmo \
184
 compile/compile.cmo \
185
 compile/operators.cmo \
186
 \
187
 types/builtin.cmo \
188 189 190
 driver/librarian.cmo

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

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

195 196
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

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

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

207
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
208

209 210
INCLUDES = $(DIRS:%=-I %)

211
cduce: $(CDUCE:.cmo=.$(EXTENSION))
212
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
213

214 215 216
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
	$(LINK) -a -o $@ cDuce_all.$(EXTENSION)
217

218
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
219
	$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
220 221
# webiface is made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
222 223

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

226
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
227 228
	$(LINK) $(INCLUDES) -o $@ $^

229
.PHONY: compute_depend
230
compute_depend: $(DEPEND_OCAMLDEP)
231
	echo $(DEPEND)
232
	@echo "Computing dependencies ..."
233 234
	ocamlfind ocamldep -package "$(PACKAGES)" \
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) | \
235
	sed -e "s|: |: misc/q_symbol.cmo |" > depend
236 237 238 239
clean:
	for i in $(CLEAN_DIRS); do \
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
240
	(cd expat; $(MAKE) clean)
241
	rm -f `find . -name "*~"`
242 243
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
244
	rm -f dtd2cduce pool webiface validate
245
	rm -Rf prepro package
246
	rm -f web/www/*.html web/*~
247
	rm -f web/*.cdo
248 249 250 251


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

252
misc/q_symbol.cmo: misc/q_symbol.ml
253
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
254

255
.ml.cmo:
256
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
257 258 259 260 261 262 263 264 265 266 267 268

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

271
webpages: cduce web/site.cdo
272
	(cd web; ../cduce --run site.cdo --arg site.xml)
273

274
web/site.cdo: cduce web/xhtml.cdo web/site.cd
275
	./cduce -I web/ --compile web/site.cd
276 277

web/xhtml.cdo: cduce web/xhtml.cd
278
	./cduce -I web/ --compile web/xhtml.cd
279

280
website: webpages webiface
281

282
install_web: website
283
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
284
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
285
	cp webiface $(CGI_DIR)/cduce
286 287
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
288
	fi;  
289
	cp web/img/*.*  $(HTML_DIR)/img
290
#*: help