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