Version 0.9.0
[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         git ls-files | sort > .check-manifest; \
106         sort MANIFEST > .orig-manifest; \
107         diff -u .orig-manifest .check-manifest; rv=$$?; \
108         rm -f .orig-manifest .check-manifest; \
109         exit $$rv
110
111 # Debian packages.
112
113 dpkg:
114         @if [ 0 != `cvs -q update | wc -l` ]; then \
115         echo Please commit all changes to CVS first.; \
116         exit 1; \
117         fi
118         $(MAKE) dist
119         rm -rf /tmp/dbuild
120         mkdir /tmp/dbuild
121         cp $(PACKAGE)-$(VERSION).tar.gz \
122           /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
123         export CVSROOT=`cat CVS/Root`; \
124           cd /tmp/dbuild && \
125           cvs export \
126           -d $(PACKAGE)-$(VERSION) \
127           -D now merjis/freeware/ancient
128         cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
129         rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
130         ls -l /tmp/dbuild
131
132 # Developer documentation (in html/ subdirectory).
133
134 doc:
135         rm -rf html
136         mkdir html
137         -ocamlfind ocamldoc $(OCAMLDOCFLAGS) -d html ancient.ml{i,}
138
139 .PHONY: depend dist check-manifest dpkg doc mmalloc
140
141 .SUFFIXES:      .cmo .cmi .cmx .ml .mli