1 # Bitstring syntax extension.
2 # Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
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.
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.
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
20 PACKAGE = @PACKAGE_NAME@
21 VERSION = @PACKAGE_VERSION@
23 OCAMLFIND = @OCAMLFIND@
24 OCAMLMKLIB = @OCAMLMKLIB@
30 BYTESWAP_H = @BYTESWAP_H@
33 top_srcdir = @top_srcdir@
36 pkg_extlib = @pkg_extlib@
43 OCAMLDOCFLAGS = -html -sort
46 CFLAGS = @CFLAGS@ -Wall -Werror -fPIC -I$(top_srcdir) -I$(OCAMLLIB)
48 LIBRARY_PATH = @abs_top_builddir@
49 LD_LIBRARY_PATH = @abs_top_builddir@
51 export LD_LIBRARY_PATH
55 ifneq ($(pkg_extlib),no)
60 EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml))
62 TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml))
64 BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml))
67 bitstring.cma bitstring_persistent.cma \
68 bitstring.cmxa bitstring_persistent.cmxa \
71 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
73 bitstring.cma: bitstring_types.cmo bitstring_config.cmo \
74 bitstring_c.o bitstring.cmo bitmatch.cmo
75 $(OCAMLMKLIB) -o bitstring $^
77 bitstring_persistent.cma: bitstring_persistent.cmo
78 $(OCAMLFIND) ocamlc -a -o $@ $^
80 bitstring_persistent.cmo: bitstring_persistent.ml
81 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
82 -I +camlp4 -pp camlp4of -c $<
84 bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx \
85 bitstring_c.o bitstring.cmx bitmatch.cmx
86 $(OCAMLMKLIB) -o bitstring $^
88 bitstring_persistent.cmxa: bitstring_persistent.cmx
89 $(OCAMLFIND) ocamlopt -a -o $@ $^
91 bitstring_persistent.cmx: bitstring_persistent.ml
92 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
93 -I +camlp4 -pp camlp4of -c $<
95 bitstring_persistent.cmi: bitstring_persistent.mli
96 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
97 -I +camlp4 -pp camlp4of -c $<
99 pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
100 $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 camlp4lib.cma \
101 -pp camlp4of -c $< -o $@
103 bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
104 $(OCAMLFIND) ocamlc -I +camlp4 unix.cma camlp4lib.cma \
105 bitstring.cma bitstring_persistent.cma \
108 # Create byteswap.h if the system doesn't have this file.
109 # From gnulib, license is LGPLv2+.
111 byteswap.h: byteswap.in.h
112 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
113 cat $(srcdir)/byteswap.in.h; \
117 # Tests and examples.
119 PP = -pp "camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
121 test: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma tests/test.bmpp
122 @for f in $(TESTS); do \
124 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
125 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
126 if [ $$? -ne 0 ]; then exit 1; fi; \
129 if [ $$? -ne 0 ]; then exit 1; fi; \
131 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
133 tests/test.bmpp: create_test_pattern
137 create_test_pattern: create_test_pattern.cmo
138 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
139 unix.cma -I +camlp4 camlp4lib.cma \
140 -I . bitstring.cma bitstring_persistent.cma $< -o $@
142 create_test_pattern.cmo: create_test_pattern.ml
143 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
144 unix.cma -I +camlp4 \
147 examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
148 @for f in $(EXAMPLES); do \
150 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
151 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
152 if [ $$? -ne 0 ]; then exit 1; fi; \
154 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
156 print-tests: pa_bitstring.cmo bitstring_persistent.cma
157 @for f in $(TESTS); do \
159 cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
160 -printer pr_o.cmo $$f.ml"; \
165 print-examples: pa_bitstring.cmo
166 @for f in $(EXAMPLES); do \
167 echo Example: $$f.ml; \
168 camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
169 -printer pr_o.cmo $$f.ml; \
170 if [ $$? -ne 0 ]; then exit 1; fi; \
177 benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
178 @for f in $(BENCHMARKS); do \
179 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \
180 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \
181 if [ $$? -ne 0 ]; then exit 1; fi; \
182 $(TIME) -f "$$f: %e seconds" $$f.opt; \
183 if [ $$? -ne 0 ]; then exit 1; fi; \
186 @for f in $(BENCHMARKS); do \
187 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \
188 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \
189 if [ $$? -ne 0 ]; then exit 1; fi; \
192 if [ $$? -ne 0 ]; then exit 1; fi; \
193 gprof $$f.opt.p > $$f.profile; \
194 if [ $$? -ne 0 ]; then exit 1; fi; \
195 echo "Wrote profile of $$f"; \
196 echo " to $$f.profile"; \
206 rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
207 rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
208 rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES)
209 rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo
210 rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile
211 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
214 rm -rf autom4te.cache
215 rm -f config.log config.status
216 rm -f config.h Makefile META bitstring_config.ml
217 rm -f bitstring-objinfo
218 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
226 $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
227 bitstring.mli bitstring_persistent.mli bitmatch.ml
233 ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a *.so \
235 bitstring_persistent.cmi \
237 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
242 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
244 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
246 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
249 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
251 .depend: bitstring.ml bitstring.mli \
252 bitstring_persistent.ml bitstring_persistent.mli \
253 bitstring_objinfo.ml \
254 create_test_pattern.ml
256 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
257 bitstring.ml bitstring.mli \
258 bitstring_objinfo.ml >> $@
259 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
260 bitstring_persistent.ml bitstring_persistent.mli \
261 create_test_pattern.ml >> $@
263 ifeq ($(wildcard .depend),.depend)
270 $(MAKE) check-manifest
271 rm -rf $(PACKAGE)-$(VERSION)
272 mkdir $(PACKAGE)-$(VERSION)
273 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
274 $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
275 $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
276 svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
277 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
278 rm -rf $(PACKAGE)-$(VERSION)
279 ls -l $(PACKAGE)-$(VERSION).tar.gz
282 svn -R list | grep -v '/$$' | sort > .check-manifest
283 sort MANIFEST > .orig-manifest; \
284 diff -u .orig-manifest .check-manifest; rv=$$?; \
285 rm -f .orig-manifest .check-manifest; \
288 .PHONY: depend dist check-manifest dpkg doc \
289 print-examples print-tests examples test benchmarks
291 .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll