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