Makefile.distrib 5.24 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0-pre1
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
SYNTAX = -I misc/ q_symbol.cmo \
12
  -symbol cduce_version=\"$(VERSION)\" \
13 14
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
15 16 17 18 19 20

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

22
ifeq ($(EXPAT), true)
23
	PACKAGES += expat
24 25 26
	SYNTAX += -symbol EXPAT=
endif

27
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
28

29
CAMLC_P = ocamlc -g
30
DEPEND_OCAMLDEP = misc/q_symbol.cmo
31 32
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
33 34 35
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
36
         DEPEND_OCAMLDEP =
37
	endif
38
else
39
	CAMLOPT_P = ocamlopt -inline 25
40 41
endif

42
OPT = -warn-error FPS
43 44 45 46 47 48 49 50
ANNOT =
INTERFACE =
ifeq ($(ANNOT), true)
	OPT += -passopt -dtypes
endif
ifeq ($(INTERFACE), true)
	OPT += -passopt -i
endif
51 52 53
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
54 55 56

ifeq ($(NATIVE), true)
	EXTENSION = cmx
57
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
58 59
else
	EXTENSION = cmo
60
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
61 62
endif

63
all: cduce dtd2cduce validate
64 65 66 67

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
68
	install -m755 cduce dtd2cduce $(PREFIX)/bin/
69 70 71
	install -m644 doc/cduce.1 $(PREFIX)/man/man1/

uninstall:
72
	rm  $(PREFIX)/bin/cduce $(PREFIX)/bin/dtd2cduce $(PREFIX)/man/man1/cduce.1
73

74 75
# Source directories 

76
DIRS = misc parser schema typing types compile runtime driver
77 78 79 80 81
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

OBJECTS = \
82
 misc/stats.cmo \
83
 misc/serialize.cmo misc/custom.cmo \
84
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
85
 misc/pretty.cmo misc/ns.cmo misc/inttbl.cmo \
86 87
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
88 89
 types/intervals.cmo types/chars.cmo types/atoms.cmo \
 types/normal.cmo \
90
 types/types.cmo types/patterns.cmo types/sequence.cmo \
91 92 93 94
 types/sample.cmo types/builtin_defs.cmo \
 \
 runtime/value.cmo \
 \
95 96 97 98 99
 schema/schema_xml.cmo \
 schema/schema_common.cmo \
 schema/schema_builtin.cmo \
 schema/schema_validator.cmo \
 schema/schema_parser.cmo \
100
 \
101
 parser/location.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
102 103 104
 \
 typing/typed.cmo typing/typer.cmo \
 \
105
 compile/lambda.cmo \
106
 \
107
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
108
 runtime/explain.cmo \
109
 runtime/print_xml.cmo runtime/eval.cmo \
110
 compile/compile.cmo \
111
 compile/operators.cmo \
112
 \
113
 types/builtin.cmo driver/librarian.cmo driver/cduce.cmo
114

115 116
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

117 118 119 120
CDUCE = $(OBJECTS) driver/run.cmo
WEBIFACE  = $(OBJECTS) driver/examples.cmo driver/webiface.cmo
DTD2CDUCE = tools/dtd2cduce.cmo

121 122
ALL_OBJECTS = $(OBJECTS) \
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
123 124
 tools/dtd2cduce.cmo tools/validate.cmo
ALL_INTERFACES = schema/schema_types.mli
125

126
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
127

128 129
INCLUDES = $(DIRS:%=-I %)

130
cduce: $(CDUCE:.cmo=.$(EXTENSION))
131
	$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
132

133 134 135
bug: $(OBJECTS) bug.cmo
	$(LINK) $(INCLUDES) -o $@ $^

136
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
137 138 139
	$(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)
140 141

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

144
validate: $(VALIDATE_OBJECTS) tools/validate.cmo
145 146
	$(LINK) $(INCLUDES) -o $@ $^

147
.PHONY: compute_depend
148
compute_depend: $(DEPEND_OCAMLDEP)
149
	echo $(DEPEND)
150
	@echo "Computing dependencies ..."
151 152 153
	ocamlfind ocamldep -package "$(PACKAGES)" \
		$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) | \
        	sed -e "s|: |: misc/q_symbol.cmo |" > depend
154 155 156 157
clean:
	for i in $(CLEAN_DIRS); do \
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
158
	(cd expat; $(MAKE) clean)
159
	rm -f `find . -name "*~"`
160 161
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
162
	rm -f dtd2cduce pool webiface validate
163
	rm -Rf prepro package
164
	rm -f web/www/*.html web/*~
165
	rm -f web/*.cdo
166 167 168 169


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

170
misc/q_symbol.cmo: misc/q_symbol.ml
171
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
172

173
.ml.cmo:
174
	$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
175 176 177 178 179 180 181 182 183 184 185 186

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

189
webpages: cduce web/site.cdo
190
	(cd web; ../cduce --run site.cdo --arg site.xml)
191

192
web/site.cdo: cduce web/xhtml.cdo web/site.cd
193
	./cduce -I web/ --compile web/site.cd
194 195

web/xhtml.cdo: cduce web/xhtml.cd
196
	./cduce -I web/ --compile web/xhtml.cd
197

198
website: webpages webiface
199

200
install_web: website
201
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
202
	cp CHANGES $(HTML_DIR)/
203
	cp webiface $(CGI_DIR)/cduce
204 205
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
206
	fi;  
207
	cp web/img/*.*  $(HTML_DIR)/img