Makefile 4.21 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
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 \
50
 types/types.cmo types/patterns.cmo types/sequence.cmo \
51
 types/sample.cmo \
52
53
54
55
56
57
58
59
 \
 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 \
 \
60
 types/builtin.cmo driver/cduce.cmo
61
62
63

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

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

PREPRO = $(SYNTAX) pr_o.cmo
70

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

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

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

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

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

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

98
99
100
101

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

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

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

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

110
include depend
111

112
# CDuce-generated files
113

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

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

120
# Packaging
121
122
123
124
125
126
127

write_header:
	headache -h header $(DEPEND)

remove_header:
	headache -r $(DEPEND)

128
129
# For development

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

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/
147
	(cd prepro;  make cduce PROFILE=true SYNTAX_PARSER= NATIVE=false)
148

149
# Site-specific installation
150
151

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

158
159
160
161
162
163
164
165
#
# Customize the following variables to match the settings
# of your local web server
#
WEB_PREFIX = /var/www
CGI_DIR = $(WEB_PREFIX)/cgi-bin
CDUCE_HTML_DIR = $(WEB_PREFIX)/html

166
167
168
169
170
171
172
install_web_local:web/files webiface
	cp  web/www/*.php web/cduce.css  $(CDUCE_HTML_DIR)/
	cp webiface $(CGI_DIR)/
	if test ! -d "$(CDUCE_HTML_DIR)/img" ; then \
	  mkdir $(CDUCE_HTML_DIR)/img; \
	fi;  
	cp web/img/*.*  $(CDUCE_HTML_DIR)/img
173

174
website: web/files
175
	scp web/www/*.php web/cduce.css cduce@iris:public_html/
176

177
local_website: cduce
178
	(cd web; ../cduce --quiet site.cd --arg site.xml)
179

180
181
# Distribution

182
183
DISTRIB = $(DIRS) tools web depend INSTALL CHANGES LICENSE README Makefile

184
185
186
187
188
.PHONY: package
package:
	rm -Rf package
	mkdir package
	cp -R $(DISTRIB) package/
189
190
	(cd package; headache -h ../header $(DEPEND))