Makefile.distrib 7.83 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
SYNTAX = -I misc/ q_symbol.cmo \
13
  -symbol cduce_version=\"$(VERSION)\" \
14 15
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
16 17 18 19 20 21

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

23
ifeq ($(EXPAT), true)
24 25
  PACKAGES += expat
  SYNTAX += -symbol EXPAT=
26 27
endif

28 29 30 31 32
ifeq ($(CURL), true)
  PACKAGES += curl
  SYNTAX += -symbol CURL=
endif

33 34 35 36 37
ifeq ($(NETCLIENT), true)
  PACKAGES += netclient
  SYNTAX += -symbol NETCLIENT=
endif

38
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
39

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

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

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

78
ifneq ($(ML_INTERFACE), false)
79 80 81 82 83 84 85 86 87
  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
88
  ML_INTERFACE_OBJ = 
89
endif
90

91
INSTALL := $(shell which install)
92

93
all: cduce dtd2cduce validate
94

95 96 97 98
ifneq ($(ML_INTERFACE), false)
all: cDuce_all.$(EXTENSION_LIB)
endif

99
install: all
100 101 102 103 104 105
	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/
106 107

uninstall:
108 109
	rm $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) $(BINDIR)/validate$(EXE)
	rm $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 $(MANDIR)/man1/validate.1
110

111 112 113 114
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
115
	@echo "  validate : compiles the schema validation tool"
116 117 118 119 120 121 122 123 124
	@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"

125 126
# Source directories 

127
DIRS = misc parser schema typing types compile runtime driver query cdo2cmo
128 129 130 131 132
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

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

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
168 169

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
170
CQL_OBJECTS_RUN = query/query_run.cmo
171

172 173
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

174 175
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
176 177
DTD2CDUCE = tools/dtd2cduce.cmo

178
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
179
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
180 181
 tools/dtd2cduce.cmo tools/validate.cmo \
 $(CQL_OBJECTS_RUN)
182
ALL_INTERFACES = schema/schema_types.mli 
183

184
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
185

186 187
INCLUDES = $(DIRS:%=-I %)

188
cduce: $(CDUCE:.cmo=.$(EXTENSION))
189
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
190

191 192 193 194 195 196 197 198
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)


199 200 201
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
	$(LINK) -a -o $@ cDuce_all.$(EXTENSION)
202 203 204 205 206 207
	$(COMPILE) -c cdo2cmo/cdml.mli
	$(COMPILE) -c -o cdml.$(EXTENSION) cdo2cmo/cdml.ml
	$(LINK) -a -o cdo2cmo/cdml.$(EXTENSION_LIB) \
		oCaml_all.$(EXTENSION_LIB) \
		cDuce_all.$(EXTENSION_LIB) \
		cdo2cmo/cdml.$(EXTENSION)
208

209 210 211
oCaml_all.$(EXTENSION_LIB):
	cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@

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

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

220
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
221 222
	$(LINK) $(INCLUDES) -o $@ $^

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

242 243 244
distclean: clean
	rm -f Makefile.conf

245 246
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

247
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
248
$(ALL_INTERFACES): misc/q_symbol.cmo
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