Makefile.distrib 6.75 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre3
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
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
47

48
CAMLC_P = ocamlc -g
49
DEPEND_OCAMLDEP = misc/q_symbol.cmo
50
51
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
52
53
54
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
55
         DEPEND_OCAMLDEP =
56
	endif
57
else
58
	CAMLOPT_P = ocamlopt -inline 25
59
60
endif

61
OPT = -warn-error FPS
62
63
64
65
66
67
68
69
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
70
71
72
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
73
74
75

ifeq ($(NATIVE), true)
	EXTENSION = cmx
76
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
77
78
else
	EXTENSION = cmo
79
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
80
81
endif

82
83
INSTALL := $(shell which install)

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
help:
	@echo "GOALS"
	@echo "  cduce : compiles the CDuce command line interpreter"
	@echo "  dtd2cduce : compiles the dtd2cduce tools"
	@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]"
	@echo "  NATIVE=false : use the OCaml native code compiler to build CDuce [true]"
	@echo "  PXP_WLEX=true : use wlex for parsing UTF-8 XML files [false]"
	@echo "  EXPAT=true : build expat support [false]"
	@echo "  OCURL=true: build ocurl support [false]"


105
106


107
all: cduce dtd2cduce validate
108
109
110
111

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

uninstall:
116
	rm  $(PREFIX)/bin/cduce$(EXE) $(PREFIX)/bin/dtd2cduce$(EXE) $(PREFIX)/man/man1/cduce.1
117

118
119
# Source directories 

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

# Objects to build

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

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
160
CQL_OBJECTS_RUN = query/query_run.cmo
161

162
163
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

164
165
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
166
167
DTD2CDUCE = tools/dtd2cduce.cmo

168
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
169
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
170
 tools/dtd2cduce.cmo tools/validate.cmo
171
ALL_INTERFACES = schema/schema_types.mli 
172

173
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
174

175
176
INCLUDES = $(DIRS:%=-I %)

177
cduce: $(CDUCE:.cmo=.$(EXTENSION))
178
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
179

180
181
182
bug: $(OBJECTS) bug.cmo
	$(LINK) $(INCLUDES) -o $@ $^

183
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
184
	$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
185
186
# webiface is made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
187
188

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

191
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
192
193
	$(LINK) $(INCLUDES) -o $@ $^

194
.PHONY: compute_depend
195
compute_depend: $(DEPEND_OCAMLDEP)
196
	echo $(DEPEND)
197
	@echo "Computing dependencies ..."
198
199
	ocamlfind ocamldep -package "$(PACKAGES)" \
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) | \
200
	sed -e "s|: |: misc/q_symbol.cmo |" > depend
201
202
203
204
clean:
	for i in $(CLEAN_DIRS); do \
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
205
	(cd expat; $(MAKE) clean)
206
	rm -f `find . -name "*~"`
207
208
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
209
	rm -f dtd2cduce pool webiface validate
210
	rm -Rf prepro package
211
	rm -f web/www/*.html web/*~
212
	rm -f web/*.cdo
213
214
215
216


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

217
misc/q_symbol.cmo: misc/q_symbol.ml
218
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
219

220
.ml.cmo:
221
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
222
223
224
225
226
227
228
229
230
231
232
233

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

236
webpages: cduce web/site.cdo
237
	(cd web; ../cduce --run site.cdo --arg site.xml)
238

239
web/site.cdo: cduce web/xhtml.cdo web/site.cd
240
	./cduce -I web/ --compile web/site.cd
241
242

web/xhtml.cdo: cduce web/xhtml.cd
243
	./cduce -I web/ --compile web/xhtml.cd
244

245
website: webpages webiface
246

247
install_web: website
248
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
249
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
250
	cp webiface $(CGI_DIR)/cduce
251
252
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
253
	fi;  
254
	cp web/img/*.*  $(HTML_DIR)/img