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@
33 pkg_extlib = @pkg_extlib@
40 OCAMLDOCFLAGS = -html -sort
43 CFLAGS = @CFLAGS@ -Wall -Werror -fPIC -I$(OCAMLLIB)
45 LIBRARY_PATH = @abs_top_builddir@
46 LD_LIBRARY_PATH = @abs_top_builddir@
48 export LD_LIBRARY_PATH
52 ifneq ($(pkg_extlib),no)
57 EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml))
59 TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml))
61 BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml))
63 all: bitstring.cma bitstring_persistent.cma \
64 bitstring.cmxa bitstring_persistent.cmxa \
67 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
69 bitstring.cma: bitstring_types.cmo bitstring_config.cmo \
70 bitstring_c.o bitstring.cmo bitmatch.cmo
71 $(OCAMLMKLIB) -o bitstring $^
73 bitstring_persistent.cma: bitstring_persistent.cmo
74 $(OCAMLFIND) ocamlc -a -o $@ $^
76 bitstring_persistent.cmo: bitstring_persistent.ml
77 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
78 -I +camlp4 -pp camlp4of -c $<
80 bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx \
81 bitstring_c.o bitstring.cmx bitmatch.cmx
82 $(OCAMLMKLIB) -o bitstring $^
84 bitstring_persistent.cmxa: bitstring_persistent.cmx
85 $(OCAMLFIND) ocamlopt -a -o $@ $^
87 bitstring_persistent.cmx: bitstring_persistent.ml
88 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
89 -I +camlp4 -pp camlp4of -c $<
91 bitstring_persistent.cmi: bitstring_persistent.mli
92 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
93 -I +camlp4 -pp camlp4of -c $<
95 pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
96 $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 camlp4lib.cma \
97 -pp camlp4of -c $< -o $@
99 bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
100 $(OCAMLFIND) ocamlc -I +camlp4 unix.cma camlp4lib.cma \
101 bitstring.cma bitstring_persistent.cma \
104 # Tests and examples.
106 PP = -pp "camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
108 test: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma tests/test.bmpp
109 @for f in $(TESTS); do \
111 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
112 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
113 if [ $$? -ne 0 ]; then exit 1; fi; \
116 if [ $$? -ne 0 ]; then exit 1; fi; \
118 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
120 tests/test.bmpp: create_test_pattern
124 create_test_pattern: create_test_pattern.cmo
125 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
126 unix.cma -I +camlp4 camlp4lib.cma \
127 -I . bitstring.cma bitstring_persistent.cma $< -o $@
129 create_test_pattern.cmo: create_test_pattern.ml
130 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
131 unix.cma -I +camlp4 \
134 examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
135 @for f in $(EXAMPLES); do \
137 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
138 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
139 if [ $$? -ne 0 ]; then exit 1; fi; \
141 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
143 print-tests: pa_bitstring.cmo bitstring_persistent.cma
144 @for f in $(TESTS); do \
146 cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
147 -printer pr_o.cmo $$f.ml"; \
152 print-examples: pa_bitstring.cmo
153 @for f in $(EXAMPLES); do \
154 echo Example: $$f.ml; \
155 camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
156 -printer pr_o.cmo $$f.ml; \
157 if [ $$? -ne 0 ]; then exit 1; fi; \
164 benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
165 @for f in $(BENCHMARKS); do \
166 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \
167 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \
168 if [ $$? -ne 0 ]; then exit 1; fi; \
169 $(TIME) -f "$$f: %e seconds" $$f.opt; \
170 if [ $$? -ne 0 ]; then exit 1; fi; \
173 @for f in $(BENCHMARKS); do \
174 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \
175 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \
176 if [ $$? -ne 0 ]; then exit 1; fi; \
179 if [ $$? -ne 0 ]; then exit 1; fi; \
180 gprof $$f.opt.p > $$f.profile; \
181 if [ $$? -ne 0 ]; then exit 1; fi; \
182 echo "Wrote profile of $$f"; \
183 echo " to $$f.profile"; \
193 rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
194 rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
195 rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES)
196 rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo
197 rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile
198 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
201 rm -rf autom4te.cache
202 rm -f config.log config.status
203 rm -f config.h Makefile META bitstring_config.ml
204 rm -f bitstring-objinfo
205 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
213 $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
214 bitstring.mli bitstring_persistent.mli bitmatch.ml
220 ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a *.so \
222 bitstring_persistent.cmi \
224 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
229 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
231 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
233 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
236 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
238 .depend: bitstring.ml bitstring.mli \
239 bitstring_persistent.ml bitstring_persistent.mli \
240 bitstring_objinfo.ml \
241 create_test_pattern.ml
243 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
244 bitstring.ml bitstring.mli \
245 bitstring_objinfo.ml >> $@
246 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
247 bitstring_persistent.ml bitstring_persistent.mli \
248 create_test_pattern.ml >> $@
250 ifeq ($(wildcard .depend),.depend)
257 $(MAKE) check-manifest
258 rm -rf $(PACKAGE)-$(VERSION)
259 mkdir $(PACKAGE)-$(VERSION)
260 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
261 $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
262 $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
263 svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
264 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
265 rm -rf $(PACKAGE)-$(VERSION)
266 ls -l $(PACKAGE)-$(VERSION).tar.gz
269 svn -R list | grep -v '/$$' | sort > .check-manifest
270 sort MANIFEST > .orig-manifest; \
271 diff -u .orig-manifest .check-manifest; rv=$$?; \
272 rm -f .orig-manifest .check-manifest; \
275 .PHONY: depend dist check-manifest dpkg doc \
276 print-examples print-tests examples test benchmarks
278 .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll