e8fa4038116dcab9e4d0046553de492a35377a95
[ocaml-bitstring.git] / Makefile.in
1 # Bitmatch syntax extension.
2 # Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17 #
18 # $Id$
19
20 PACKAGE         = @PACKAGE_NAME@
21 VERSION         = @PACKAGE_VERSION@
22
23 OCAMLFIND       = @OCAMLFIND@
24 OCAMLMKLIB      = @OCAMLMKLIB@
25 OCAMLDOC        = @OCAMLDOC@
26 INSTALL         = @INSTALL@
27
28 OCAMLCFLAGS     = -g
29 OCAMLCPACKAGES  =
30 OCAMLOPTFLAGS   =
31 OCAMLOPTPACKAGES =
32
33 OCAMLDOCFLAGS   = -html -sort
34
35 SUBDIRS         =
36 ifneq ($(pkg_cil),no)
37 ifneq ($(pkg_extlib),no)
38 SUBDIRS         += cil-tools
39 endif
40 endif
41
42 EXAMPLES        = $(patsubst %.ml,%,$(wildcard examples/*.ml))
43
44 TESTS           = $(patsubst %.ml,%,$(wildcard tests/*.ml))
45
46 all:    bitmatch.cma bitmatch_persistent.cma \
47         bitmatch.cmxa bitmatch_persistent.cmxa \
48         pa_bitmatch.cmo \
49         bitmatch-objinfo
50         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
51
52 bitmatch.cma: bitmatch_types.cmo bitmatch_config.cmo bitmatch.cmo
53         $(OCAMLFIND) ocamlc -a -o $@ $^
54
55 bitmatch_persistent.cma: bitmatch_persistent.cmo
56         $(OCAMLFIND) ocamlc -a -o $@ $^
57
58 bitmatch_persistent.cmo: bitmatch_persistent.ml
59         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
60           -I +camlp4 -pp camlp4of -c $<
61
62 bitmatch.cmxa: bitmatch_types.cmx bitmatch_config.cmx bitmatch.cmx
63         $(OCAMLFIND) ocamlopt -a -o $@ $^
64
65 bitmatch_persistent.cmxa: bitmatch_persistent.cmx
66         $(OCAMLFIND) ocamlopt -a -o $@ $^
67
68 bitmatch_persistent.cmx: bitmatch_persistent.ml
69         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
70           -I +camlp4 -pp camlp4of -c $<
71
72 bitmatch_persistent.cmi: bitmatch_persistent.mli
73         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
74           -I +camlp4 -pp camlp4of -c $<
75
76 pa_bitmatch.cmo: pa_bitmatch.ml bitmatch.cma bitmatch_persistent.cma
77         $(OCAMLFIND) ocamlc bitmatch.cma -I +camlp4 camlp4lib.cma \
78           -pp camlp4of -c $< -o $@
79
80 bitmatch-objinfo: bitmatch_objinfo.cmo bitmatch.cma bitmatch_persistent.cma
81         $(OCAMLFIND) ocamlc -I +camlp4 unix.cma camlp4lib.cma \
82           bitmatch.cma bitmatch_persistent.cma \
83           $< -o $@
84
85 # Tests and examples.
86
87 PP      = -pp "camlp4o bitmatch.cma bitmatch_persistent.cma pa_bitmatch.cmo"
88
89 test: pa_bitmatch.cmo bitmatch.cma bitmatch_persistent.cma tests/test.bmpp
90         @for f in $(TESTS); do \
91           echo Building $$f; \
92           $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
93             -package unix -linkpkg -I . bitmatch.cma $$f.ml -o $$f; \
94           if [ $$? -ne 0 ]; then exit 1; fi; \
95           echo Running $$f; \
96           $$f; \
97           if [ $$? -ne 0 ]; then exit 1; fi; \
98         done
99         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
100
101 tests/test.bmpp: create_test_pattern
102         ./$< $@.new
103         mv $@.new $@
104
105 create_test_pattern: create_test_pattern.cmo
106         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
107           unix.cma -I +camlp4 camlp4lib.cma \
108           -I . bitmatch.cma bitmatch_persistent.cma $< -o $@
109
110 create_test_pattern.cmo: create_test_pattern.ml
111         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
112           unix.cma -I +camlp4 \
113           -I . -c $< -o $@
114
115 examples: pa_bitmatch.cmo bitmatch.cma bitmatch_persistent.cma
116         @for f in $(EXAMPLES); do \
117           echo Building $$f; \
118           $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
119             -package unix -linkpkg -I . bitmatch.cma $$f.ml -o $$f; \
120           if [ $$? -ne 0 ]; then exit 1; fi; \
121         done
122         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
123
124 print-tests: pa_bitmatch.cmo bitmatch_persistent.cma
125         @for f in $(TESTS); do \
126           echo Test: $$f.ml; \
127           cmd="camlp4o bitmatch.cma bitmatch_persistent.cma pa_bitmatch.cmo \
128             -printer pr_o.cmo $$f.ml"; \
129           echo $$cmd; \
130           $$cmd; \
131         done
132
133 print-examples: pa_bitmatch.cmo
134         @for f in $(EXAMPLES); do \
135           echo Example: $$f.ml; \
136           camlp4o bitmatch.cma bitmatch_persistent.cma pa_bitmatch.cmo \
137             -printer pr_o.cmo $$f.ml; \
138           if [ $$? -ne 0 ]; then exit 1; fi; \
139         done
140
141 # Clean.
142
143 clean:
144         rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
145         rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
146         rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES)
147         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
148
149 distclean: clean
150         rm -rf autom4te.cache
151         rm -f config.log config.status
152         rm -f config.h Makefile META bitmatch_config.ml
153         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
154
155 # Documentation.
156
157 ifneq ($(OCAMLDOC),)
158 doc:
159         rm -rf html
160         mkdir html
161         $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
162           bitmatch.mli bitmatch_persistent.mli
163 endif
164
165 # Install.
166
167 install:
168         ocamlfind install bitmatch META *.mli *.cmx *.cma *.cmxa *.a \
169                 bitmatch.cmi \
170                 bitmatch_persistent.cmi \
171                 pa_bitmatch.cmo
172         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
173
174 # Standard rules.
175
176 .mli.cmi:
177         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
178 .ml.cmo:
179         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
180 .ml.cmx:
181         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
182
183 depend: .depend
184         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
185
186 .depend: bitmatch.ml bitmatch.mli \
187           bitmatch_persistent.ml bitmatch_persistent.mli \
188           bitmatch_objinfo.ml \
189           create_test_pattern.ml
190         rm -f .depend
191         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
192           bitmatch.ml bitmatch.mli \
193           bitmatch_objinfo.ml >> $@
194         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
195           bitmatch_persistent.ml bitmatch_persistent.mli \
196           create_test_pattern.ml >> $@
197
198 ifeq ($(wildcard .depend),.depend)
199 include .depend
200 endif
201
202 # Distribution.
203
204 dist:
205         $(MAKE) check-manifest
206         rm -rf $(PACKAGE)-$(VERSION)
207         mkdir $(PACKAGE)-$(VERSION)
208         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
209         $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
210         $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
211         svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
212         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
213         rm -rf $(PACKAGE)-$(VERSION)
214         ls -l $(PACKAGE)-$(VERSION).tar.gz
215
216 check-manifest:
217         svn -R list | grep -v '/$$' | sort > .check-manifest
218         sort MANIFEST > .orig-manifest; \
219         diff -u .orig-manifest .check-manifest; rv=$$?; \
220         rm -f .orig-manifest .check-manifest; \
221         exit $$rv
222
223 .PHONY: depend dist check-manifest dpkg doc \
224         print-examples print-tests examples test
225
226 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll