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