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