Makefile.distrib 7.76 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 52 53 54 55
ifeq ($(ML_INTERFACE), true)
  SYNTAX += -symbol ML_INTERFACE=
  ML_LIB = oCaml_all.cma
endif

56
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
57

58
CAMLC_P = ocamlc -g
59
DEPEND_OCAMLDEP = misc/q_symbol.cmo
60 61
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
62 63 64
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
65
         DEPEND_OCAMLDEP =
66
	endif
67
else
68
	CAMLOPT_P = ocamlopt -inline 25
69 70
endif

71
OPT = -warn-error FPS
72 73 74 75 76 77 78 79
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
80 81 82
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
83 84 85

ifeq ($(NATIVE), true)
	EXTENSION = cmx
86 87
	EXTENSION_LIB = cmxa
	COMPILE = $(CAMLOPT)
88
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
89 90
else
	EXTENSION = cmo
91 92
	EXTENSION_LIB = cma
	COMPILE = $(CAMLC)
93
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
94 95
endif

96 97
INSTALL := $(shell which install)

98

99
all: cduce cDuce_all.cma dtd2cduce validate
100 101 102 103

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
104
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) validate$(EXE) $(PREFIX)/bin/
105
	$(INSTALL) -m644 doc/cduce.1 $(PREFIX)/man/man1/
106 107
	$(INSTALL) -m644 doc/dtd2cduce.1 $(PREFIX)/man/man1/
	$(INSTALL) -m644 doc/validate.1 $(PREFIX)/man/man1/
108 109

uninstall:
110
	rm  $(PREFIX)/bin/cduce$(EXE) \
111
	    $(PREFIX)/bin/dtd2cduce$(EXE) \
112
	    $(PREFIX)/bin/validate$(EXE) \
113 114 115
	    $(PREFIX)/man/man1/cduce.1 \
	    $(PREFIX)/man/man1/dtd2cduce.1 \
	    $(PREFIX)/man/man1/validate.1
116

117 118 119 120
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
121
	@echo "  validate : compiles the schema validation tool"
122 123 124 125 126 127 128 129 130 131 132
	@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]"
133 134 135 136 137 138
	@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]"
139
	@echo ""
140

141 142
# Source directories 

143
DIRS = misc parser schema typing types compile runtime driver query cdo2cmo
144 145 146 147 148
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

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

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
190
CQL_OBJECTS_RUN = query/query_run.cmo
191

192 193
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

194 195
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
196 197
DTD2CDUCE = tools/dtd2cduce.cmo

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

204
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
205

206 207
INCLUDES = $(DIRS:%=-I %)

208
cduce: $(CDUCE:.cmo=.$(EXTENSION))
209
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
210

211 212 213
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
	$(LINK) -a -o $@ cDuce_all.$(EXTENSION)
214

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

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

223
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
224 225
	$(LINK) $(INCLUDES) -o $@ $^

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


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

249
misc/q_symbol.cmo: misc/q_symbol.ml
250
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
251

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

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

268
webpages: cduce web/site.cdo
269
	(cd web; ../cduce --run site.cdo --arg site.xml)
270

271
web/site.cdo: cduce web/xhtml.cdo web/site.cd
272
	./cduce -I web/ --compile web/site.cd
273 274

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

277
website: webpages webiface
278

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