Makefile 4.07 KB
Newer Older
1
2
3
DEBUG = -g
OCAMLCP = ocamlc
OCAMLC = ocamlfind $(OCAMLCP) -package $(PACKAGES)
4
OCAMLOPT = ocamlfind ocamlopt -package $(PACKAGES)
5
6
# extra options:  
#    -p (profiling)
7
#    -inline 25
8

9
PACKAGES = "pxp-engine pxp-lex-iso88591 pxp-wlex-utf8 wlexing camlp4 num,cgi"
10

11
DISTRIB = $(DIRS) tools web depend INSTALL LICENSE README Makefile
12

13
all: cduce.opt dtd2cduce local_website
14

15
# Source directories 
16

17
18
DIRS = misc parser typing types runtime driver
CLEAN_DIRS = $(DIRS) tools tests
19

20
# Objects to build
21

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
41
42

XCDUCE = $(CDUCE:.cmo=.cmx)
43
XWEBIFACE =  $(WEBIFACE:.cmo=.cmx)
44

45
46
47
48
49
50
DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli)
INCLUDES = $(DIRS:%=-I %)

SYNTAX = camlp4o pa_extend.cmo
SYNTAX_PARSER = -pp '$(SYNTAX)'
PREPRO = $(SYNTAX) pr_o.cmo
51

52
cduce: $(CDUCE)
53
	$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $^
54

55
webiface: $(WEBIFACE)
56
	$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $^
57

58
dtd2cduce: tools/dtd2cduce.cmo
59
	$(OCAMLC) $(DEBUG) -linkpkg -o $@ $^
60

61
cduce.opt: $(XCDUCE)
62
	$(OCAMLOPT) -linkpkg -o $@ gramlib.cmxa $^
63

64
webiface.opt: $(XWEBIFACE)
65
	$(OCAMLOPT) -linkpkg -o $@ gramlib.cmxa $^
66

67
68
compute_depend:
	@echo "Computing dependencies ..."
69
	ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
70

71
72
73
parser/wlexer.ml: parser/wlexer.mll
	wlex parser/wlexer.mll

74
clean:
75
	for i in $(CLEAN_DIRS); do \
76
77
78
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
79
	rm -f cduce cduce.opt webiface.opt ocamlprof.dump
80
	rm -f dtd2cduce pool webiface
81
	rm -Rf prepro package
82
	rm -f web/*.php web/*.html web/*~
83

84
85
86
87

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

.ml.cmo:
88
89
	$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $<

90
.ml.cmx:
91
	$(OCAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
92
93

.mli.cmi:
94
	$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $<
95

96
include depend
97

98
# CDuce-generated files
99

100
101
driver/examples.ml: cduce.opt web/examples/build.cd web/examples/examples.xml
	(cd web/examples; ../../cduce.opt -quiet build.cd)
102

103
web/files: cduce.opt web/site.cd
104
	(cd web; ../cduce.opt -quiet site.cd -- -php site.xml)
105

106
# Packaging
107
108
109
110
111
112
113

write_header:
	headache -h header $(DEPEND)

remove_header:
	headache -r $(DEPEND)

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# For development

pull: tools/pull.cmo
	$(OCAMLC) $(DEBUG) -linkpkg -o $@ $^

all.cma: $(OBJECTS)
	$(OCAMLC) $(DEBUG) -o $@ -linkpkg gramlib.cma -a $(OBJECTS)

test: all.cma
	fort all.cma -I +fort $(INCLUDES) tests/test_fort.ml

run_top: all.cma
	ledit ocaml $(INCLUDES) `ocamlfind use pxp` all.cma

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/
	(cd prepro;  make cduce OCAMLCP="ocamlcp -p a" SYNTAX_PARSER=)

144
# Site-specific installation
145
146
147

cedre_build:
	rsh cedre ". .env; cd IMPLEM/CDUCE; make webiface.opt; make web/files"
148
install_web:
149
150
151
152
	scp web/*.php web/cduce.css cduce@iris:public_html/
	scp webiface.opt cduce@iris:cgi-bin/cduce
	ssh cduce@iris "chmod +s cgi-bin/cduce"

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

156
website: web/files
157
	scp web/*.php web/cduce.css cduce@iris:public_html/
158

159
160
161
local_website: cduce.opt webiface.opt
	(cd web; ../cduce.opt -quiet site.cd -- site.xml)

162
163
164
165
166
167
168
# Distribution

.PHONY: package
package:
	rm -Rf package
	mkdir package
	cp -R $(DISTRIB) package/
169
170
	(cd package; headache -h ../header $(DEPEND))