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