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 BISECT_REPORT = @BISECT_REPORT@
32 BYTESWAP_H = @BYTESWAP_H@
35 top_srcdir = @top_srcdir@
37 pkg_cil = @OCAML_PKG_cil@
38 pkg_extlib = @OCAML_PKG_extlib@
40 enable_coverage = @enable_coverage@
45 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
46 OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
47 OCAMLOPTLIBS = -linkpkg
49 ifneq ($(enable_coverage),no)
50 OCAMLCFLAGS += -I +bisect -pp 'camlp4o $(OCAMLLIB)/bisect/instrument.cma'
51 OCAMLCLIBS += -I +bisect bisect.cma
52 OCAMLOPTFLAGS += -I +bisect -pp 'camlp4o $(OCAMLLIB)/bisect/instrument.cma'
53 OCAMLOPTLIBS += -I +bisect bisect.cmxa
56 OCAMLDOCFLAGS = -html -sort
59 CFLAGS = @CFLAGS@ -Wall -Werror -fPIC -I$(top_srcdir) -I$(OCAMLLIB)
61 LIBRARY_PATH = @abs_top_builddir@
62 LD_LIBRARY_PATH = @abs_top_builddir@
64 export LD_LIBRARY_PATH
68 ifneq ($(pkg_extlib),no)
73 EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml))
75 TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml))
77 BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml))
80 bitstring.cma bitstring_persistent.cma \
81 bitstring.cmxa bitstring_persistent.cmxa \
84 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
86 bitstring.cma: bitstring_types.cmo bitstring_config.cmo \
87 bitstring_c.o bitstring.cmo bitmatch.cmo
88 $(OCAMLMKLIB) -o bitstring $^
90 bitstring_persistent.cma: bitstring_persistent.cmo
91 $(OCAMLFIND) ocamlc -a $(OCAMLCFLAGS) -o $@ $^
93 bitstring_persistent.cmo: bitstring_persistent.ml
94 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
95 -I +camlp4 -pp camlp4of -c $<
97 bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx \
98 bitstring_c.o bitstring.cmx bitmatch.cmx
99 $(OCAMLMKLIB) -o bitstring $^
101 bitstring_persistent.cmxa: bitstring_persistent.cmx
102 $(OCAMLFIND) ocamlopt -a $(OCAMLOPTFLAGS) -o $@ $^
104 bitstring_persistent.cmx: bitstring_persistent.ml
105 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
106 -I +camlp4 -pp camlp4of -c $<
108 bitstring_persistent.cmi: bitstring_persistent.mli
109 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
110 -I +camlp4 -pp camlp4of -c $<
112 pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
113 $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 dynlink.cma camlp4lib.cma \
114 -pp camlp4of -c $< -o $@
116 bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
117 $(OCAMLFIND) ocamlc -I +camlp4 unix.cma dynlink.cma camlp4lib.cma \
118 $(OCAMLCFLAGS) $(OCAMLCLIBS) \
119 bitstring.cma bitstring_persistent.cma \
122 # Create byteswap.h if the system doesn't have this file.
123 # From gnulib, license is LGPLv2+.
125 byteswap.h: byteswap.in.h
126 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
127 cat $(srcdir)/byteswap.in.h; \
133 ifeq ($(enable_coverage),no)
134 PP = -pp 'camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo'
136 PP = -pp 'camlp4o $(OCAMLLIB)/bisect/bisect.cma bitstring.cma bitstring_persistent.cma pa_bitstring.cmo'
141 test: pa_bitstring.cmo \
142 bitstring.cma bitstring_persistent.cma \
143 bitstring.cmxa bitstring_persistent.cmxa \
145 @for f in $(TESTS); do \
147 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -package unix $(OCAMLOPTLIBS) -I . bitstring.cmxa $$f.ml -o $$f.opt; \
148 if [ $$? -ne 0 ]; then exit 1; fi; \
151 if [ $$? -ne 0 ]; then exit 1; fi; \
153 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
155 tests/test.bmpp: create_test_pattern
159 create_test_pattern: create_test_pattern.cmo
160 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
161 unix.cma -I +camlp4 dynlink.cma camlp4lib.cma \
163 -I . bitstring.cma bitstring_persistent.cma $< -o $@
165 create_test_pattern.cmo: create_test_pattern.ml
166 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
167 unix.cma -I +camlp4 \
172 ifneq ($(BISECT_REPORT),no)
174 rm -f coverage-report/*
177 $(BISECT_REPORT) -html coverage-report bisect*.out
179 @echo Coverage report is in `pwd`/coverage-report/index.html
184 examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
185 @for f in $(EXAMPLES); do \
187 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
188 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
189 if [ $$? -ne 0 ]; then exit 1; fi; \
191 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
193 print-tests: pa_bitstring.cmo bitstring_persistent.cma
194 @for f in $(TESTS); do \
196 cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
197 -printer pr_o.cmo $$f.ml"; \
202 print-examples: pa_bitstring.cmo
203 @for f in $(EXAMPLES); do \
204 echo Example: $$f.ml; \
205 camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
206 -printer pr_o.cmo $$f.ml; \
207 if [ $$? -ne 0 ]; then exit 1; fi; \
214 benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
215 @for f in $(BENCHMARKS); do \
216 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \
217 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \
218 if [ $$? -ne 0 ]; then exit 1; fi; \
219 $(TIME) -f "$$f: %e seconds" $$f.opt; \
220 if [ $$? -ne 0 ]; then exit 1; fi; \
223 @for f in $(BENCHMARKS); do \
224 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \
225 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \
226 if [ $$? -ne 0 ]; then exit 1; fi; \
229 if [ $$? -ne 0 ]; then exit 1; fi; \
230 gprof $$f.opt.p > $$f.profile; \
231 if [ $$? -ne 0 ]; then exit 1; fi; \
232 echo "Wrote profile of $$f"; \
233 echo " to $$f.profile"; \
243 rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.cmp *.a *.o *.so
244 rm -f tests/*~ tests/*.cmi tests/*.cmo tests/*.cmx tests/*.opt
246 rm -f examples/*~ examples/*.cmi examples/*.cmo examples/*.cmx
247 rm -f examples/*.o $(EXAMPLES)
248 rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo
249 rm -f benchmarks/*.cmx benchmarks/*.o
250 rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile
251 rm -f create_test_pattern bitstring-objinfo
252 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
255 rm -rf autom4te.cache
256 rm -f config.log config.status
257 rm -f config.h Makefile META bitstring_config.ml
258 rm -f bitstring-objinfo
259 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
267 $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
268 bitstring.mli bitstring_persistent.mli bitmatch.ml
274 ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a *.so \
276 bitstring_persistent.cmi \
278 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
281 ocamlfind remove bitstring
286 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
288 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
290 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
293 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
295 .depend: bitstring.ml bitstring.mli \
296 bitstring_persistent.ml bitstring_persistent.mli \
297 bitstring_objinfo.ml \
298 create_test_pattern.ml
300 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
301 bitstring.ml bitstring.mli \
302 bitstring_objinfo.ml | \
304 $(SED) 's/ *$$//' | \
305 $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' >> $@-t
306 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
307 bitstring_persistent.ml bitstring_persistent.mli \
308 create_test_pattern.ml | \
310 $(SED) 's/ *$$//' | \
311 $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' >> $@-t
314 ifeq ($(wildcard .depend),.depend)
321 $(MAKE) check-manifest
322 rm -rf $(PACKAGE)-$(VERSION)
323 mkdir $(PACKAGE)-$(VERSION)
324 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
325 $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
326 $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
327 svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
328 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
329 rm -rf $(PACKAGE)-$(VERSION)
330 ls -l $(PACKAGE)-$(VERSION).tar.gz
333 svn -R list | grep -v '/$$' | sort > .check-manifest
334 sort MANIFEST > .orig-manifest; \
335 diff -u .orig-manifest .check-manifest; rv=$$?; \
336 rm -f .orig-manifest .check-manifest; \
339 .PHONY: depend dist check-manifest dpkg doc \
340 print-examples print-tests examples test benchmarks
342 .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll