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