Makefile.distrib 5.46 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre1
3
NAME = cduce
4

5
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring
6
ifeq ($(PXP_WLEX), true)
7
  PACKAGES += pxp-wlex-utf8
8
else
9
  PACKAGES += pxp-lex-utf8
10
11
endif

12
13
14
15
16
17
18
19
20
21
22
#
# Check if running Cygwin
#

ifneq (,$(findstring Cygwin, $(shell echo "let _ = Sys.os_type" | ocaml))) 
    EXE=.exe
else
    EXE= 
endif


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

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

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

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

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

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

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

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



79
all: cduce dtd2cduce validate
80
81
82
83

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

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

90
91
# Source directories 

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

# Objects to build

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

214
website: webpages webiface
215

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