Makefile.distrib 5.74 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 16 17
#
# Check if running Cygwin
#

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


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

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

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

41 42 43 44 45
ifeq ($(CURL), true)
  PACKAGES += curl
  SYNTAX += -symbol CURL=
endif

46
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
47

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

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

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

82 83 84 85
INSTALL := $(shell which install)



86
all: cduce dtd2cduce validate
87 88 89 90

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

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

97 98
# Source directories 

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

# Objects to build

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

CQL_OBJECTS= query/query.cmo query/query_parse.cmo 
139
CQL_OBJECTS_RUN = query/query_run.cmo
140

141 142
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

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

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

152
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
153

154 155
INCLUDES = $(DIRS:%=-I %)

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

159 160 161
bug: $(OBJECTS) bug.cmo
	$(LINK) $(INCLUDES) -o $@ $^

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

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

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

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


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

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

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

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

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

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

web/xhtml.cdo: cduce web/xhtml.cd
222
	./cduce -I web/ --compile web/xhtml.cd
223

224
website: webpages webiface
225

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