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@
31 pkg_extlib = @pkg_extlib@
38 OCAMLDOCFLAGS = -html -sort
42 ifneq ($(pkg_extlib),no)
47 EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml))
49 TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml))
51 BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml))
53 all: bitstring.cma bitstring_persistent.cma \
54 bitstring.cmxa bitstring_persistent.cmxa \
57 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
59 bitstring.cma: bitstring_types.cmo bitstring_config.cmo bitstring.cmo \
61 $(OCAMLFIND) ocamlc -a -o $@ $^
63 bitstring_persistent.cma: bitstring_persistent.cmo
64 $(OCAMLFIND) ocamlc -a -o $@ $^
66 bitstring_persistent.cmo: bitstring_persistent.ml
67 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
68 -I +camlp4 -pp camlp4of -c $<
70 bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx bitstring.cmx \
72 $(OCAMLFIND) ocamlopt -a -o $@ $^
74 bitstring_persistent.cmxa: bitstring_persistent.cmx
75 $(OCAMLFIND) ocamlopt -a -o $@ $^
77 bitstring_persistent.cmx: bitstring_persistent.ml
78 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
79 -I +camlp4 -pp camlp4of -c $<
81 bitstring_persistent.cmi: bitstring_persistent.mli
82 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
83 -I +camlp4 -pp camlp4of -c $<
85 pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
86 $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 camlp4lib.cma \
87 -pp camlp4of -c $< -o $@
89 bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
90 $(OCAMLFIND) ocamlc -I +camlp4 unix.cma camlp4lib.cma \
91 bitstring.cma bitstring_persistent.cma \
96 PP = -pp "camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
98 test: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma tests/test.bmpp
99 @for f in $(TESTS); do \
101 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
102 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
103 if [ $$? -ne 0 ]; then exit 1; fi; \
106 if [ $$? -ne 0 ]; then exit 1; fi; \
108 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
110 tests/test.bmpp: create_test_pattern
114 create_test_pattern: create_test_pattern.cmo
115 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
116 unix.cma -I +camlp4 camlp4lib.cma \
117 -I . bitstring.cma bitstring_persistent.cma $< -o $@
119 create_test_pattern.cmo: create_test_pattern.ml
120 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
121 unix.cma -I +camlp4 \
124 examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
125 @for f in $(EXAMPLES); do \
127 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
128 -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
129 if [ $$? -ne 0 ]; then exit 1; fi; \
131 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
133 print-tests: pa_bitstring.cmo bitstring_persistent.cma
134 @for f in $(TESTS); do \
136 cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
137 -printer pr_o.cmo $$f.ml"; \
142 print-examples: pa_bitstring.cmo
143 @for f in $(EXAMPLES); do \
144 echo Example: $$f.ml; \
145 camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
146 -printer pr_o.cmo $$f.ml; \
147 if [ $$? -ne 0 ]; then exit 1; fi; \
154 benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
155 @for f in $(BENCHMARKS); do \
156 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \
157 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \
158 if [ $$? -ne 0 ]; then exit 1; fi; \
159 $(TIME) -f "$$f: %e seconds" $$f.opt; \
160 if [ $$? -ne 0 ]; then exit 1; fi; \
163 @for f in $(BENCHMARKS); do \
164 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \
165 -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \
166 if [ $$? -ne 0 ]; then exit 1; fi; \
169 if [ $$? -ne 0 ]; then exit 1; fi; \
170 gprof $$f.opt.p > $$f.profile; \
171 if [ $$? -ne 0 ]; then exit 1; fi; \
172 echo "Wrote profile of $$f"; \
173 echo " to $$f.profile"; \
183 rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
184 rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
185 rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES)
186 rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo
187 rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile
188 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
191 rm -rf autom4te.cache
192 rm -f config.log config.status
193 rm -f config.h Makefile META bitstring_config.ml
194 rm -f bitstring-objinfo
195 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
203 $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
204 bitstring.mli bitstring_persistent.mli bitmatch.ml
210 ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a \
212 bitstring_persistent.cmi \
214 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
219 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
221 $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
223 $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
226 @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
228 .depend: bitstring.ml bitstring.mli \
229 bitstring_persistent.ml bitstring_persistent.mli \
230 bitstring_objinfo.ml \
231 create_test_pattern.ml
233 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
234 bitstring.ml bitstring.mli \
235 bitstring_objinfo.ml >> $@
236 $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
237 bitstring_persistent.ml bitstring_persistent.mli \
238 create_test_pattern.ml >> $@
240 ifeq ($(wildcard .depend),.depend)
247 $(MAKE) check-manifest
248 rm -rf $(PACKAGE)-$(VERSION)
249 mkdir $(PACKAGE)-$(VERSION)
250 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
251 $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
252 $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
253 svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
254 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
255 rm -rf $(PACKAGE)-$(VERSION)
256 ls -l $(PACKAGE)-$(VERSION).tar.gz
259 svn -R list | grep -v '/$$' | sort > .check-manifest
260 sort MANIFEST > .orig-manifest; \
261 diff -u .orig-manifest .check-manifest; rv=$$?; \
262 rm -f .orig-manifest .check-manifest; \
265 .PHONY: depend dist check-manifest dpkg doc \
266 print-examples print-tests examples test benchmarks
268 .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll