Renaming bitmatch -> bitstring.
[ocaml-bitstring.git] / Makefile.in
1 # Bitstring 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 pkg_cil         = @pkg_cil@
29 pkg_extlib      = @pkg_extlib@
30
31 OCAMLCFLAGS     = -g
32 OCAMLCPACKAGES  =
33 OCAMLOPTFLAGS   =
34 OCAMLOPTPACKAGES =
35
36 OCAMLDOCFLAGS   = -html -sort
37
38 SUBDIRS         =
39 ifneq ($(pkg_cil),no)
40 ifneq ($(pkg_extlib),no)
41 SUBDIRS         += cil-tools
42 endif
43 endif
44
45 EXAMPLES        = $(patsubst %.ml,%,$(wildcard examples/*.ml))
46
47 TESTS           = $(patsubst %.ml,%,$(wildcard tests/*.ml))
48
49 all:    bitstring.cma bitstring_persistent.cma \
50         bitstring.cmxa bitstring_persistent.cmxa \
51         pa_bitstring.cmo \
52         bitstring-objinfo
53         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
54
55 bitstring.cma: bitstring_types.cmo bitstring_config.cmo bitstring.cmo \
56           bitmatch.cmo
57         $(OCAMLFIND) ocamlc -a -o $@ $^
58
59 bitstring_persistent.cma: bitstring_persistent.cmo
60         $(OCAMLFIND) ocamlc -a -o $@ $^
61
62 bitstring_persistent.cmo: bitstring_persistent.ml
63         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
64           -I +camlp4 -pp camlp4of -c $<
65
66 bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx bitstring.cmx \
67           bitmatch.cmx
68         $(OCAMLFIND) ocamlopt -a -o $@ $^
69
70 bitstring_persistent.cmxa: bitstring_persistent.cmx
71         $(OCAMLFIND) ocamlopt -a -o $@ $^
72
73 bitstring_persistent.cmx: bitstring_persistent.ml
74         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
75           -I +camlp4 -pp camlp4of -c $<
76
77 bitstring_persistent.cmi: bitstring_persistent.mli
78         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
79           -I +camlp4 -pp camlp4of -c $<
80
81 pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
82         $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 camlp4lib.cma \
83           -pp camlp4of -c $< -o $@
84
85 bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
86         $(OCAMLFIND) ocamlc -I +camlp4 unix.cma camlp4lib.cma \
87           bitstring.cma bitstring_persistent.cma \
88           $< -o $@
89
90 # Tests and examples.
91
92 PP      = -pp "camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
93
94 test: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma tests/test.bmpp
95         @for f in $(TESTS); do \
96           echo Building $$f; \
97           $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
98             -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
99           if [ $$? -ne 0 ]; then exit 1; fi; \
100           echo Running $$f; \
101           $$f; \
102           if [ $$? -ne 0 ]; then exit 1; fi; \
103         done
104         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
105
106 tests/test.bmpp: create_test_pattern
107         ./$< $@.new
108         mv $@.new $@
109
110 create_test_pattern: create_test_pattern.cmo
111         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
112           unix.cma -I +camlp4 camlp4lib.cma \
113           -I . bitstring.cma bitstring_persistent.cma $< -o $@
114
115 create_test_pattern.cmo: create_test_pattern.ml
116         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
117           unix.cma -I +camlp4 \
118           -I . -c $< -o $@
119
120 examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
121         @for f in $(EXAMPLES); do \
122           echo Building $$f; \
123           $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
124             -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
125           if [ $$? -ne 0 ]; then exit 1; fi; \
126         done
127         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
128
129 print-tests: pa_bitstring.cmo bitstring_persistent.cma
130         @for f in $(TESTS); do \
131           echo Test: $$f.ml; \
132           cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
133             -printer pr_o.cmo $$f.ml"; \
134           echo $$cmd; \
135           $$cmd; \
136         done
137
138 print-examples: pa_bitstring.cmo
139         @for f in $(EXAMPLES); do \
140           echo Example: $$f.ml; \
141           camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
142             -printer pr_o.cmo $$f.ml; \
143           if [ $$? -ne 0 ]; then exit 1; fi; \
144         done
145
146 # Clean.
147
148 clean:
149         rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
150         rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
151         rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES)
152         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
153
154 distclean: clean
155         rm -rf autom4te.cache
156         rm -f config.log config.status
157         rm -f config.h Makefile META bitstring_config.ml
158         rm -f bitstring-objinfo
159         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
160
161 # Documentation.
162
163 ifneq ($(OCAMLDOC),)
164 doc:
165         rm -rf html
166         mkdir html
167         $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
168           bitstring.mli bitstring_persistent.mli
169 endif
170
171 # Install.
172
173 install:
174         ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a \
175                 bitstring.cmi \
176                 bitstring_persistent.cmi \
177                 pa_bitstring.cmo
178         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
179
180 # Standard rules.
181
182 .mli.cmi:
183         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
184 .ml.cmo:
185         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
186 .ml.cmx:
187         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
188
189 depend: .depend
190         @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
191
192 .depend: bitstring.ml bitstring.mli \
193           bitstring_persistent.ml bitstring_persistent.mli \
194           bitstring_objinfo.ml \
195           create_test_pattern.ml
196         rm -f .depend
197         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
198           bitstring.ml bitstring.mli \
199           bitstring_objinfo.ml >> $@
200         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
201           bitstring_persistent.ml bitstring_persistent.mli \
202           create_test_pattern.ml >> $@
203
204 ifeq ($(wildcard .depend),.depend)
205 include .depend
206 endif
207
208 # Distribution.
209
210 dist:
211         $(MAKE) check-manifest
212         rm -rf $(PACKAGE)-$(VERSION)
213         mkdir $(PACKAGE)-$(VERSION)
214         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
215         $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
216         $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
217         svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
218         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
219         rm -rf $(PACKAGE)-$(VERSION)
220         ls -l $(PACKAGE)-$(VERSION).tar.gz
221
222 check-manifest:
223         svn -R list | grep -v '/$$' | sort > .check-manifest
224         sort MANIFEST > .orig-manifest; \
225         diff -u .orig-manifest .check-manifest; rv=$$?; \
226         rm -f .orig-manifest .check-manifest; \
227         exit $$rv
228
229 .PHONY: depend dist check-manifest dpkg doc \
230         print-examples print-tests examples test
231
232 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll