Makefile.distrib 5.67 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 curl
5
ifeq ($(PXP_WLEX), true)
6
  PACKAGES += pxp-wlex-utf8
7
else
8
  PACKAGES += pxp-lex-utf8
9
10
endif

11
12
13
14
#
# Check if running Cygwin
#

15
ifneq (,$(findstring Cygwin, $(shell echo "Sys.os_type;;" | ocaml))) 
16
17
18
19
20
21
    EXE=.exe
else
    EXE= 
endif


22
SYNTAX = -I misc/ q_symbol.cmo \
23
  -symbol cduce_version=\"$(VERSION)\" \
24
25
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
26
27
28
29
30
31

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

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

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

40
CAMLC_P = ocamlc -g
41
DEPEND_OCAMLDEP = misc/q_symbol.cmo
42
43
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
44
45
46
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
47
         DEPEND_OCAMLDEP =
48
	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
67

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

74
75
76
77
INSTALL := $(shell which install)



78
all: cduce dtd2cduce validate
79
80
81
82

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
83
84
	$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) $(PREFIX)/bin/
	$(INSTALL) -m644 doc/cduce.1 $(PREFIX)/man/man1/
85
86

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

89
90
# Source directories 

91
DIRS = misc parser schema typing types compile runtime driver query
92
93
94
95
96
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

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

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
131
CQL_OBJECTS_RUN = query/query_run.cmo
132

133
134
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

135
136
CDUCE = $(OBJECTS) $(CQL_OBJECTS) driver/run.cmo $(CQL_OBJECTS_RUN)
WEBIFACE  = $(OBJECTS) $(CQL_OBJECTS) driver/examples.cmo driver/webiface.cmo
137
138
DTD2CDUCE = tools/dtd2cduce.cmo

139
ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
140
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
141
 tools/dtd2cduce.cmo tools/validate.cmo
142
ALL_INTERFACES = schema/schema_types.mli 
143

144
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
145

146
147
INCLUDES = $(DIRS:%=-I %)

148
cduce: $(CDUCE:.cmo=.$(EXTENSION))
149
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
150

151
152
153
bug: $(OBJECTS) bug.cmo
	$(LINK) $(INCLUDES) -o $@ $^

154
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
155
	$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
156
157
# webiface is made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
158
159

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

162
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
163
164
	$(LINK) $(INCLUDES) -o $@ $^

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


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

188
misc/q_symbol.cmo: misc/q_symbol.ml
189
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
190

191
.ml.cmo:
192
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
193
194
195
196
197
198
199
200
201
202
203
204

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

207
webpages: cduce web/site.cdo
208
	(cd web; ../cduce --run site.cdo --arg site.xml)
209

210
web/site.cdo: cduce web/xhtml.cdo web/site.cd
211
	./cduce -I web/ --compile web/site.cd
212
213

web/xhtml.cdo: cduce web/xhtml.cd
214
	./cduce -I web/ --compile web/xhtml.cd
215

216
website: webpages webiface
217

218
install_web: website
219
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
220
	cp CHANGES  INSTALL INSTALL.WIN32 $(HTML_DIR)/
221
	cp webiface $(CGI_DIR)/cduce
222
223
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
224
	fi;  
225
	cp web/img/*.*  $(HTML_DIR)/img