Makefile 3.95 KB
Newer Older
1
2
3
NATIVE = true
PROFILE = false
PXP_WLEX = false
4

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

12
SYNTAX = camlp4o pa_extend.cmo
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
ifeq ($(PROFILE), true)
	CAMLC_P = ocamlcp -p a
	CAMLOPT_P = ocamlopt -p
	SYNTAX_PARSER = 
else
	CAMLC_P = ocamlc
	CAMLOPT_P = ocamlopt
	SYNTAX_PARSER = -pp '$(SYNTAX)'
endif

CAMLC = ocamlfind $(CAMLC_P) $(PACKAGES)
CAMLOPT = ocamlfind $(CAMLOPT_P) $(PACKAGES)

ifeq ($(NATIVE), true)
	EXTENSION = cmx
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
else
	EXTENSION = cmo
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
endif

all: cduce dtd2cduce local_website
36

37
# Source directories 
38

39
40
DIRS = misc parser typing types runtime driver
CLEAN_DIRS = $(DIRS) tools tests
41

42
# Objects to build
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
OBJECTS = \
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
 misc/pretty.cmo \
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
 types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \
 types/types.cmo types/patterns.cmo types/sequence.cmo types/builtin.cmo \
 \
 parser/location.cmo parser/wlexer.cmo parser/ast.cmo parser/parser.cmo \
 \
 typing/typed.cmo typing/typer.cmo \
 \
 runtime/value.cmo runtime/load_xml.cmo runtime/run_dispatch.cmo \
 runtime/print_xml.cmo runtime/eval.cmo \
 \
 driver/cduce.cmo

CDUCE = $(OBJECTS) driver/run.cmo
WEBIFACE  = $(OBJECTS) driver/examples.cmo driver/webiface.cmo
63
DTD2CDUCE = tools/dtd2cduce.cmo
64

65
66
67
68
DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli)
INCLUDES = $(DIRS:%=-I %)

PREPRO = $(SYNTAX) pr_o.cmo
69

70
71
cduce: $(CDUCE:.cmo=.$(EXTENSION))
	$(LINK) -o $@ $^
72

73
74
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
	$(LINK) -o $@ $^
75

76
77
dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
	$(LINK) -o $@ $^
78

79
.PHONY: compute_depend
80
81
compute_depend:
	@echo "Computing dependencies ..."
82
	ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
83

84
85
86
parser/wlexer.ml: parser/wlexer.mll
	wlex parser/wlexer.mll

87
clean:
88
	for i in $(CLEAN_DIRS); do \
89
90
91
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
92
	rm -f cduce ocamlprof.dump
93
	rm -f dtd2cduce pool webiface
94
	rm -Rf prepro package
95
	rm -f web/www/*.php web/www/*.html web/*~
96

97
98
99
100

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

.ml.cmo:
101
	$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
102

103
.ml.cmx:
104
	$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
105
106

.mli.cmi:
107
	$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
108

109
include depend
110

111
# CDuce-generated files
112

113
114
driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml
	(cd web/examples; ../../cduce -quiet build.cd)
115

116
117
web/files: cduce web/site.cd
	(cd web; ../cduce -quiet site.cd -- -php site.xml)
118

119
# Packaging
120
121
122
123
124
125
126

write_header:
	headache -h header $(DEPEND)

remove_header:
	headache -r $(DEPEND)

127
128
# For development

129
130
pull: tools/pull.$(EXTENSION)
	$(LINK) -o $@ $^
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

profile:
	rm -Rf prepro
	mkdir prepro
	for i in $(DIRS); do \
	mkdir prepro/$$i; \
	for j in $$i/*.ml $$i/*.mli; do \
	if [ -f "$$j" ]; then \
	 echo $$j; \
	 $(PREPRO) $$j -o prepro/$$j; \
	fi; \
	done; \
	done
	cp parser/wlexer.mll prepro/parser/
	cp Makefile depend prepro/
146
	(cd prepro;  make cduce PROFILE=true SYNTAX_PARSER= NATIVE=false)
147

148
# Site-specific installation
149
150

cedre_build:
151
	rsh cedre ". .env; cd IMPLEM/CDUCE; make webiface; make web/files"
152
install_web:
153
	scp web/www/*.php web/cduce.css cduce@iris:public_html/
154
	scp webiface cduce@iris:cgi-bin/cduce
155
156
	ssh cduce@iris "chmod +s cgi-bin/cduce"

157
install_web_local:
158
	ssh root@localhost "cp -f ~beppe/IMPLEM/CDUCE/webiface /var/www/cgi-bin/cduce; cp -f ~beppe/IMPLEM/CDUCE/web/www/*.php /var/www/html/; chmod +s /var/www/cgi-bin/cduce;"
159

160
website: web/files
161
	scp web/www/*.php web/cduce.css cduce@iris:public_html/
162

163
164
local_website: cduce
	(cd web; ../cduce -quiet site.cd -- site.xml)
165

166
167
# Distribution

168
169
DISTRIB = $(DIRS) tools web depend INSTALL CHANGES LICENSE README Makefile

170
171
172
173
174
.PHONY: package
package:
	rm -Rf package
	mkdir package
	cp -R $(DISTRIB) package/
175
176
	(cd package; headache -h ../header $(DEPEND))