a36a4d623af5f4d68e8fa62ab3b26d977b50f5e6
[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: Makefile.in,v 1.5 2008-05-07 14:41:03 rjones Exp $
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 EXAMPLES        = $(wildcard examples/*.ml)
36
37 TESTS           = $(patsubst %.ml,%,$(wildcard tests/*.ml))
38
39 all:    pa_bitmatch.cmo bitmatch.cma bitmatch.cmxa
40
41 pa_bitmatch.cmo: pa_bitmatch.ml
42         $(OCAMLFIND) ocamlc -I +camlp4 camlp4lib.cma \
43           -pp camlp4of.opt -c $< -o $@
44
45 bitmatch.cma: bitmatch.cmo
46         $(OCAMLFIND) ocamlc -a -o $@ $^
47
48 bitmatch.cmxa: bitmatch.cmx
49         $(OCAMLFIND) ocamlopt -a -o $@ $^
50
51 # Tests and examples.
52
53 test: pa_bitmatch.cmo bitmatch.cma
54         @for f in $(TESTS); do \
55           echo Test: $$f; \
56           $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp "camlp4o pa_bitmatch.cmo" \
57             -package unix -linkpkg -I . bitmatch.cma $$f.ml -o $$f; \
58           if [ $$? -ne 0 ]; then exit 1; fi; \
59           $$f; \
60           if [ $$? -ne 0 ]; then exit 1; fi; \
61         done
62
63 print-tests: pa_bitmatch.cmo
64         @for f in $(TESTS); do \
65           echo Test: $$f.ml; \
66           cmd="camlp4o pa_bitmatch.cmo -printer pr_o.cmo $$f.ml"; \
67           echo $$cmd; \
68           $$cmd; \
69         done
70
71 print-examples: pa_bitmatch.cmo
72         @for f in $(EXAMPLES); do \
73           echo Example: $$f; \
74           camlp4o pa_bitmatch.cmo -printer pr_o.cmo $$f; \
75           if [ $$? -ne 0 ]; then exit 1; fi; \
76         done
77
78 # Clean.
79
80 clean:
81         rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
82         rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS)
83         rm -f examples/*~
84
85 # Documentation.
86
87 ifneq ($(OCAMLDOC),)
88 doc:
89         rm -rf html
90         mkdir html
91         $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html bitmatch.mli bitmatch.ml
92 endif
93
94 # Install.
95
96 install:
97         ocamlfind install bitmatch META *.mli *.cmx *.cma *.cmxa *.a \
98                 bitmatch.cmi \
99                 pa_bitmatch.cmo
100
101 # Standard rules.
102
103 .mli.cmi:
104         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
105 .ml.cmo:
106         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
107 .ml.cmx:
108         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
109
110 depend: .depend
111
112 .depend: bitmatch.ml bitmatch.mli
113         rm -f .depend
114         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) $^ > $@
115
116 ifeq ($(wildcard .depend),.depend)
117 include .depend
118 endif
119
120 # Distribution.
121
122 dist:
123         $(MAKE) check-manifest
124         rm -rf $(PACKAGE)-$(VERSION)
125         mkdir $(PACKAGE)-$(VERSION)
126         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
127         $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
128         $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
129         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
130         rm -rf $(PACKAGE)-$(VERSION)
131         ls -l $(PACKAGE)-$(VERSION).tar.gz
132
133 check-manifest:
134         @for d in `find -type d -name CVS`; do \
135         b=`dirname $$d`/; \
136         awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
137         sed -e "s|^|$$b|" -e "s|^\./||"; \
138         done | sort > .check-manifest; \
139         sort MANIFEST > .orig-manifest; \
140         diff -u .orig-manifest .check-manifest; rv=$$?; \
141         rm -f .orig-manifest .check-manifest; \
142         exit $$rv
143
144 .PHONY: depend dist check-manifest dpkg doc print-examples print-tests test
145
146 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll