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

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

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

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

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

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

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

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

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

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

90
INSTALL := $(shell which install)
91

92
all: cduce dtd2cduce validate
93 94

install: all
95 96 97 98 99 100
	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/
101 102

uninstall:
103 104
	rm $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) $(BINDIR)/validate$(EXE)
	rm $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 $(MANDIR)/man1/validate.1
105

106 107 108 109
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
110
	@echo "  validate : compiles the schema validation tool"
111 112 113 114 115 116 117 118 119
	@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"

120 121
# Source directories 

122
DIRS = misc parser schema typing types compile runtime driver query cdo2cmo
123 124 125 126 127
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

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

OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
163 164

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
165
CQL_OBJECTS_RUN = query/query_run.cmo
166

167 168
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

169 170
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
171 172
DTD2CDUCE = tools/dtd2cduce.cmo

173
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
174
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
175 176
 tools/dtd2cduce.cmo tools/validate.cmo \
 $(CQL_OBJECTS_RUN)
177
ALL_INTERFACES = schema/schema_types.mli 
178

179
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
180

181 182
INCLUDES = $(DIRS:%=-I %)

183
cduce: $(CDUCE:.cmo=.$(EXTENSION))
184
	$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
185

186 187 188 189 190 191 192 193
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)


194 195 196
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
	$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
	$(LINK) -a -o $@ cDuce_all.$(EXTENSION)
197 198 199 200 201 202
	$(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)
203

204 205 206
oCaml_all.$(EXTENSION_LIB):
	cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@

207
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
208
	$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
209 210
# webiface is made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
211 212

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

215
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
216 217
	$(LINK) $(INCLUDES) -o $@ $^

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

237 238 239
distclean: clean
	rm -f Makefile.conf

240 241
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)

242 243
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
$(ALL_INTERFACE): misc/q_symbol.cmo
244 245 246

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

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

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

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

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

269
web/site.cdo: cduce web/xhtml.cdo web/site.cd
270
	./cduce -I web/ --compile web/site.cd
271 272

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

275
website: webpages webiface
276

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