9115302fde777c835825ff67793a5a00bee47dd7
[ocaml-ancient.git] / Makefile
1 # Mark objects as 'ancient' so they are taken out of the OCaml heap.
2 # $Id: Makefile,v 1.4 2006-09-27 14:05:07 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         := 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 $^
37
38 ancient.cmxa: ancient.cmx ancient_c.o
39         ocamlmklib -o ancient $^
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 # 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
72 # Dependencies.
73
74 depend: .depend
75
76 .depend: $(wildcard *.mli) $(wildcard *.ml)
77         rm -f .depend
78         ocamldep $^ > $@
79
80 ifeq ($(wildcard .depend),.depend)
81 include .depend
82 endif
83
84 # Install.
85
86 install:
87         rm -rf $(DESTDIR)$(OCAMLLIBDIR)/ancient
88         install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/weblogs
89         install -c -m 0644 *.cmi *.mli *.cma *.cmxa *.a META \
90           $(DESTDIR)$(OCAMLLIBDIR)/ancient
91
92 # Distribution.
93
94 dist:
95         $(MAKE) check-manifest
96         rm -rf $(PACKAGE)-$(VERSION)
97         mkdir $(PACKAGE)-$(VERSION)
98         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
99         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
100         rm -rf $(PACKAGE)-$(VERSION)
101         ls -l $(PACKAGE)-$(VERSION).tar.gz
102
103 check-manifest:
104         @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
105         do \
106         b=`dirname $$d`/; \
107         awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
108         sed -e "s|^|$$b|" -e "s|^\./||"; \
109         done | sort > .check-manifest; \
110         sort MANIFEST > .orig-manifest; \
111         diff -u .orig-manifest .check-manifest; rv=$$?; \
112         rm -f .orig-manifest .check-manifest; \
113         exit $$rv
114
115 # Debian packages.
116
117 dpkg:
118         @if [ 0 != `cvs -q update | wc -l` ]; then \
119         echo Please commit all changes to CVS first.; \
120         exit 1; \
121         fi
122         $(MAKE) dist
123         rm -rf /tmp/dbuild
124         mkdir /tmp/dbuild
125         cp $(PACKAGE)-$(VERSION).tar.gz \
126           /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
127         export CVSROOT=`cat CVS/Root`; \
128           cd /tmp/dbuild && \
129           cvs export \
130           -d $(PACKAGE)-$(VERSION) \
131           -D now merjis/freeware/ancient
132         cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
133         rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
134         ls -l /tmp/dbuild
135
136 # Developer documentation (in html/ subdirectory).
137
138 doc:
139         rm -rf html
140         mkdir html
141         -ocamlfind ocamldoc $(OCAMLDOCFLAGS) -d html ancient.ml{i,}
142
143 .PHONY: depend dist check-manifest dpkg doc
144
145 .SUFFIXES:      .cmo .cmi .cmx .ml .mli