Makefile.distrib 5.71 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
ifeq ($(CURL), true)
  PACKAGES += curl
endif



16

17
18
19
20
#
# Check if running Cygwin
#

21
ifneq (,$(findstring Cygwin, $(shell echo "Sys.os_type;;" | ocaml))) 
22
23
24
25
26
27
    EXE=.exe
else
    EXE= 
endif


28
SYNTAX = -I misc/ q_symbol.cmo \
29
  -symbol cduce_version=\"$(VERSION)\" \
30
31
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
32
33
34
35
36
37

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

39
ifeq ($(EXPAT), true)
40
	PACKAGES += expat
41
42
43
	SYNTAX += -symbol EXPAT=
endif

44
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
45

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

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

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

80
81
82
83
INSTALL := $(shell which install)



84
all: cduce dtd2cduce validate
85
86
87
88

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
89
90
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) $(PREFIX)/bin/
	$(INSTALL) -m644 doc/cduce.1 $(PREFIX)/man/man1/
91
92

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

95
96
# Source directories 

97
DIRS = misc parser schema typing types compile runtime driver query
98
99
100
101
102
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

OBJECTS = \
103
 misc/stats.cmo \
104
 misc/serialize.cmo misc/custom.cmo \
105
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
106
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo \
107
108
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
109
110
 types/intervals.cmo types/chars.cmo types/atoms.cmo \
 types/normal.cmo \
111
 types/types.cmo types/patterns.cmo types/sequence.cmo \
112
113
114
115
 types/sample.cmo types/builtin_defs.cmo \
 \
 runtime/value.cmo \
 \
116
117
118
119
120
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
121
 \
122
 parser/location.cmo parser/url.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
123
124
125
 \
 typing/typed.cmo typing/typer.cmo \
 \
126
 compile/lambda.cmo \
127
 \
128
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
129
 runtime/explain.cmo \
130
 runtime/print_xml.cmo runtime/eval.cmo \
131
 compile/compile.cmo \
132
 compile/operators.cmo \
133
 \
134
135
136
 types/builtin.cmo driver/librarian.cmo driver/cduce.cmo

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
137
CQL_OBJECTS_RUN = query/query_run.cmo
138

139
140
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

141
142
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
143
144
DTD2CDUCE = tools/dtd2cduce.cmo

145
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
146
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
147
 tools/dtd2cduce.cmo tools/validate.cmo
148
ALL_INTERFACES = schema/schema_types.mli 
149

150
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
151

152
153
INCLUDES = $(DIRS:%=-I %)

154
cduce: $(CDUCE:.cmo=.$(EXTENSION))
155
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
156

157
158
159
bug: $(OBJECTS) bug.cmo
	$(LINK) $(INCLUDES) -o $@ $^

160
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
161
	$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
162
163
# webiface is made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
164
165

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

168
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
169
170
	$(LINK) $(INCLUDES) -o $@ $^

171
.PHONY: compute_depend
172
compute_depend: $(DEPEND_OCAMLDEP)
173
	echo $(DEPEND)
174
	@echo "Computing dependencies ..."
175
176
	ocamlfind ocamldep -package "$(PACKAGES)" \
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) | \
177
	sed -e "s|: |: misc/q_symbol.cmo |" > depend
178
179
180
181
clean:
	for i in $(CLEAN_DIRS); do \
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
182
	(cd expat; $(MAKE) clean)
183
	rm -f `find . -name "*~"`
184
185
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
186
	rm -f dtd2cduce pool webiface validate
187
	rm -Rf prepro package
188
	rm -f web/www/*.html web/*~
189
	rm -f web/*.cdo
190
191
192
193


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

194
misc/q_symbol.cmo: misc/q_symbol.ml
195
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
196

197
.ml.cmo:
198
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
199
200
201
202
203
204
205
206
207
208
209
210

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

213
webpages: cduce web/site.cdo
214
	(cd web; ../cduce --run site.cdo --arg site.xml)
215

216
web/site.cdo: cduce web/xhtml.cdo web/site.cd
217
	./cduce -I web/ --compile web/site.cd
218
219

web/xhtml.cdo: cduce web/xhtml.cd
220
	./cduce -I web/ --compile web/xhtml.cd
221

222
website: webpages webiface
223

224
install_web: website
225
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
226
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
227
	cp webiface $(CGI_DIR)/cduce
228
229
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
230
	fi;  
231
	cp web/img/*.*  $(HTML_DIR)/img