Bumped release number to 0.8.0 to reflect the relative stability and maturity of...
[ocaml-ancient.git] / Makefile
1 # Mark objects as 'ancient' so they are taken out of the OCaml heap.
2 # $Id: Makefile,v 1.8 2006-10-06 15:03:47 rich Exp $
3
4 include Makefile.config
5
6 CC      := gcc
7 CFLAGS  := -g -fPIC -Wall -Werror
8
9 OCAMLCFLAGS     := -g
10 OCAMLCPACKAGES  := -package unix
11 OCAMLCLIBS      := -linkpkg
12
13 OCAMLOPTFLAGS   :=
14 OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
15 OCAMLOPTLIBS    := -linkpkg
16
17 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCPACKAGES)
18
19 TARGETS         := mmalloc ancient.cma ancient.cmxa META \
20                    test_ancient_dict_write.opt \
21                    test_ancient_dict_verify.opt \
22                    test_ancient_dict_read.opt
23
24 all:    $(TARGETS)
25
26 ancient.cma: ancient.cmo ancient_c.o
27         ocamlmklib -o ancient -Lmmalloc -lmmalloc $^
28
29 ancient.cmxa: ancient.cmx ancient_c.o
30         ocamlmklib -o ancient -Lmmalloc -lmmalloc $^
31
32 test_ancient_dict_write.opt: ancient.cmxa test_ancient_dict_write.cmx
33         LIBRARY_PATH=.:$$LIBRARY_PATH \
34         ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
35
36 test_ancient_dict_verify.opt: ancient.cmxa test_ancient_dict_verify.cmx
37         LIBRARY_PATH=.:$$LIBRARY_PATH \
38         ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
39
40 test_ancient_dict_read.opt: ancient.cmxa test_ancient_dict_read.cmx
41         LIBRARY_PATH=.:$$LIBRARY_PATH \
42         ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
43
44 # Build the mmalloc library.
45
46 mmalloc:
47         $(MAKE) -C mmalloc
48
49 # Common rules for building OCaml objects.
50
51 .mli.cmi:
52         ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
53 .ml.cmo:
54         ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
55 .ml.cmx:
56         ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTINCS) $(OCAMLOPTPACKAGES) -c $<
57
58 # Findlib META file.
59
60 META:   META.in Makefile.config
61         sed  -e 's/@PACKAGE@/$(PACKAGE)/' \
62              -e 's/@VERSION@/$(VERSION)/' \
63              < $< > $@
64
65 # Clean.
66
67 clean:
68         rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *~ core META *.opt
69         $(MAKE) -C mmalloc clean
70
71 # Dependencies.
72
73 depend: .depend
74
75 .depend: $(wildcard *.mli) $(wildcard *.ml)
76         rm -f .depend
77         ocamldep $^ > $@
78
79 ifeq ($(wildcard .depend),.depend)
80 include .depend
81 endif
82
83 # Install.
84
85 install:
86         rm -rf $(DESTDIR)$(OCAMLLIBDIR)/ancient
87         install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/ancient
88         install -c -m 0644 *.cmi *.mli *.cma *.cmxa *.a META \
89           $(DESTDIR)$(OCAMLLIBDIR)/ancient
90
91 # Distribution.
92
93 dist:
94         $(MAKE) check-manifest
95         rm -rf $(PACKAGE)-$(VERSION)
96         mkdir $(PACKAGE)-$(VERSION)
97         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
98         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
99         rm -rf $(PACKAGE)-$(VERSION)
100         ls -l $(PACKAGE)-$(VERSION).tar.gz
101
102 check-manifest:
103         @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
104         do \
105         b=`dirname $$d`/; \
106         awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
107         sed -e "s|^|$$b|" -e "s|^\./||"; \
108         done | sort > .check-manifest; \
109         sort MANIFEST > .orig-manifest; \
110         diff -u .orig-manifest .check-manifest; rv=$$?; \
111         rm -f .orig-manifest .check-manifest; \
112         exit $$rv
113
114 # Debian packages.
115
116 dpkg:
117         @if [ 0 != `cvs -q update | wc -l` ]; then \
118         echo Please commit all changes to CVS first.; \
119         exit 1; \
120         fi
121         $(MAKE) dist
122         rm -rf /tmp/dbuild
123         mkdir /tmp/dbuild
124         cp $(PACKAGE)-$(VERSION).tar.gz \
125           /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
126         export CVSROOT=`cat CVS/Root`; \
127           cd /tmp/dbuild && \
128           cvs export \
129           -d $(PACKAGE)-$(VERSION) \
130           -D now merjis/freeware/ancient
131         cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
132         rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
133         ls -l /tmp/dbuild
134
135 # Developer documentation (in html/ subdirectory).
136
137 doc:
138         rm -rf html
139         mkdir html
140         -ocamlfind ocamldoc $(OCAMLDOCFLAGS) -d html ancient.ml{i,}
141
142 .PHONY: depend dist check-manifest dpkg doc mmalloc
143
144 .SUFFIXES:      .cmo .cmi .cmx .ml .mli