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