Makefile.distrib 8.32 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 85 86 87 88 89 90 91
  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
92
  ML_INTERFACE_OBJ = 
93
endif
94

95
INSTALL := $(shell which install)
96

97
all: cduce dtd2cduce validate
98

99
ifneq ($(ML_INTERFACE), false)
100
all: cdml.$(EXTENSION_LIB)
101 102
endif

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

111 112
ifneq ($(ML_INTERFACE), false)
install_cdml:
113 114 115 116
	$(OCAMLFIND) install cduce META \
         cdml.$(EXTENSION_LIB) cdo2cmo/cdml.cmi \
         cDuce_all.cmi oCaml_all.$(EXTENSION_LIB) \
         $(wildcard *.a) oCaml_all.cmi
117 118
endif

119
uninstall:
120 121
	rm $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) $(BINDIR)/validate$(EXE)
	rm $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 $(MANDIR)/man1/validate.1
122

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

137 138
# Source directories 

139
DIRS = misc parser schema typing types compile runtime driver query cdo2cmo
140 141 142 143 144
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

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

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
180 181

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
182
CQL_OBJECTS_RUN = query/query_run.cmo
183

184 185
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

186 187
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
188 189
DTD2CDUCE = tools/dtd2cduce.cmo

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

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

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

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

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


211 212 213 214 215 216
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
217
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
218
	$(COMPILE) -c cdo2cmo/cdml.mli
219 220 221
	$(COMPILE) -c cdo2cmo/cdml.ml
	$(COMPILE) -a -o cdml.$(EXTENSION_LIB) \
		cDuce_all.$(EXTENSION) \
222
		cdo2cmo/cdml.$(EXTENSION)
223

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

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

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

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

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

255 256 257
distclean: clean
	rm -f Makefile.conf

258 259
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

260
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
261
$(ALL_INTERFACES): misc/q_symbol.cmo
262 263 264

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

265
misc/q_symbol.cmo: misc/q_symbol.ml
266
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
267

268
.ml.cmo:
269
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
270 271 272 273 274 275 276 277 278 279 280 281

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

284
webpages: cduce web/site.cdo
285
	(cd web; ../cduce --run site.cdo --arg site.xml)
286

287
web/site.cdo: cduce web/xhtml.cdo web/site.cd
288
	./cduce -I web/ --compile web/site.cd
289 290

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

293
website: webpages webiface
294

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