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