Makefile.distrib 5.47 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre2
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
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 \
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 \
 \
 query/query_parse.cmo
131

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

215
website: webpages webiface
216

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