Makefile.distrib 4.49 KB
Newer Older
1
include Makefile.conf
2
VERSION = 0.2.0
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
ULEX_PATH = `ocamlfind query ulex`
12 13
SYNTAX = camlp4o -I misc/ pa_extend.cmo \
  q_symbol.cmo \
14
  $(shell ocamlfind query ulex)/pa_ulex.cma \
15
  -symbol cduce_version=\"$(VERSION)\" \
16 17
  -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
  -symbol session_dir=\"$(SESSION_DIR)\"
18 19 20 21 22 23

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

25
ifeq ($(EXPAT), true)
26
	PACKAGES += expat
27 28 29
	SYNTAX += -symbol EXPAT=
endif

30 31 32
SYNTAX_PARSER = -pp '$(SYNTAX)'

CAMLC_P = ocamlc
33 34
ifeq ($(PROFILE), true)
	CAMLOPT_P = ocamlopt -p
35 36 37
	ifeq ($(NATIVE), false) 
         CAMLC_P = ocamlcp -p a
         SYNTAX_PARSER = 
38
	endif
39
else
40
	CAMLOPT_P = ocamlopt -inline 25
41 42
endif

43
OPT = -warn-error FPS
44 45 46
OCAMLFIND = ocamlfind
CAMLC = $(OCAMLFIND) $(CAMLC_P) $(OPT) -package "$(PACKAGES)"
CAMLOPT = $(OCAMLFIND) $(CAMLOPT_P) $(OPT) -package "$(PACKAGES)"
47 48 49

ifeq ($(NATIVE), true)
	EXTENSION = cmx
50
	LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
51 52
else
	EXTENSION = cmo
53
	LINK = $(CAMLC) -custom -linkpkg gramlib.cma
54 55
endif

56
all: cduce dtd2cduce 
57

58 59 60 61

install: all
	mkdir -p $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man/man1/
62
	install -m755 cduce dtd2cduce $(PREFIX)/bin/
63 64 65
	install -m644 doc/cduce.1 $(PREFIX)/man/man1/

uninstall:
66
	rm  $(PREFIX)/bin/cduce $(PREFIX)/bin/dtd2cduce $(PREFIX)/man/man1/cduce.1
67

68 69
# Source directories 

70
DIRS = misc parser schema typing types runtime driver
71 72 73 74 75
CLEAN_DIRS = $(DIRS) tools tests

# Objects to build

OBJECTS = \
76
 misc/serialize.cmo misc/custom.cmo \
77
 misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
78
 misc/pretty.cmo misc/ns.cmo \
79 80
 \
 types/sortedList.cmo types/boolean.cmo types/ident.cmo \
81 82
 types/intervals.cmo types/chars.cmo types/atoms.cmo \
 types/normal.cmo \
83
 types/types.cmo types/patterns.cmo types/sequence.cmo \
84 85 86 87 88 89
 types/sample.cmo types/builtin_defs.cmo \
 \
 runtime/value.cmo \
 \
 schema/schema_types.cmo schema/schema_xml.cmo schema/schema_builtin.cmo \
 schema/schema_validator.cmo schema/schema_parser.cmo \
90
 \
91
 parser/location.cmo parser/ulexer.cmo parser/ast.cmo parser/parser.cmo \
92 93 94
 \
 typing/typed.cmo typing/typer.cmo \
 \
95
 runtime/load_xml.cmo runtime/run_dispatch.cmo \
96 97 98 99 100 101 102 103
 runtime/print_xml.cmo runtime/eval.cmo \
 \
 types/builtin.cmo driver/cduce.cmo

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

104 105 106 107 108 109
ALL_OBJECTS = $(OBJECTS) \
 driver/run.cmo driver/examples.cmo driver/webiface.cmo \
 tools/dtd2cduce.cmo

DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli)

110 111
INCLUDES = $(DIRS:%=-I %)

112 113 114 115
cduce: $(CDUCE:.cmo=.$(EXTENSION))
	$(LINK) $(INCLUDES) -o $@ $^

webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
116 117 118
	$(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)
119 120

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

123 124 125
validate: $(OBJECTS:.cmo=.$(EXTENSION)) tools/validate.ml
	$(LINK) $(INCLUDES) -o $@ $^

126
.PHONY: compute_depend
127
compute_depend: misc/q_symbol.cmo
128
	@echo "Computing dependencies ..."
129 130
	ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) | \
        sed -e "s|: |: misc/q_symbol.cmo |" > depend
131

132 133
#parser/wlexer.ml: parser/wlexer.mll
#	wlex parser/wlexer.mll
134 135 136 137 138

clean:
	for i in $(CLEAN_DIRS); do \
	(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
	done
139
	(cd expat; $(MAKE) clean)
140
	rm -f `find . -name "*~"`
141 142
	rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
	rm -f cduce ocamlprof.dump
143
	rm -f dtd2cduce pool webiface validate
144
	rm -Rf prepro package
145
	rm -f web/www/*.html web/*~
146 147 148 149


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

150
misc/q_symbol.cmo: misc/q_symbol.ml
151
	$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
152

153 154 155 156 157 158 159 160 161 162 163 164 165 166
.ml.cmo:
	$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<

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

169
webpages: cduce web/site.cd
170
	(cd web; ../cduce --quiet site.cd --arg site.xml)
171

172
website: webpages webiface
173

174
install_web: website
175
	cp  web/www/*.html web/cduce.css  $(HTML_DIR)/
176
	cp CHANGES $(HTML_DIR)/
177
	cp webiface $(CGI_DIR)/cduce
178 179
	if test ! -d "$(HTML_DIR)/img" ; then \
	  mkdir $(HTML_DIR)/img; \
180
	fi;  
181
	cp web/img/*.*  $(HTML_DIR)/img