Fix error path if realloc call fails.
[ocaml-ancient.git] / Makefile
index 491bb0e..16fd75a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,52 @@
 # Mark objects as 'ancient' so they are taken out of the OCaml heap.
-# $Id: Makefile,v 1.3 2006-09-27 12:10:18 rich Exp $
 
 include Makefile.config
 
 CC     := gcc
-CFLAGS := -g -fPIC -Wall -Werror
+CFLAGS := -g -fPIC -Wall -Werror \
+       -DOCAML_VERSION_MAJOR=$(OCAML_VERSION_MAJOR) \
+       -DOCAML_VERSION_MINOR=$(OCAML_VERSION_MINOR) \
+       -I$(shell ocamlc -where)
 
 OCAMLCFLAGS    := -g
-OCAMLCPACKAGES := 
-OCAMLCLIBS     := 
+OCAMLCPACKAGES := -package unix
+OCAMLCLIBS     := -linkpkg
 
 OCAMLOPTFLAGS  :=
 OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
-OCAMLOPTLIBS   := 
+OCAMLOPTLIBS   := -linkpkg
 
 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCPACKAGES)
 
-all:   ancient.cma ancient.cmxa test_ancient.opt META
+TARGETS                := mmalloc ancient.cma ancient.cmxa META \
+                  test_ancient_dict_write.opt \
+                  test_ancient_dict_verify.opt \
+                  test_ancient_dict_read.opt
+
+all:   $(TARGETS)
 
 ancient.cma: ancient.cmo ancient_c.o
-       ocamlmklib -o ancient $^
+       ocamlmklib -o ancient -Lmmalloc -lmmalloc $^
 
 ancient.cmxa: ancient.cmx ancient_c.o
-       ocamlmklib -o ancient $^
+       ocamlmklib -o ancient -Lmmalloc -lmmalloc $^
+
+test_ancient_dict_write.opt: ancient.cmxa test_ancient_dict_write.cmx
+       LIBRARY_PATH=.:$$LIBRARY_PATH \
+       ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
 
-test_ancient.opt: ancient.cmxa test_ancient.cmx
+test_ancient_dict_verify.opt: ancient.cmxa test_ancient_dict_verify.cmx
        LIBRARY_PATH=.:$$LIBRARY_PATH \
-       ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) -o $@ $^
+       ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
+
+test_ancient_dict_read.opt: ancient.cmxa test_ancient_dict_read.cmx
+       LIBRARY_PATH=.:$$LIBRARY_PATH \
+       ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $^
+
+# Build the mmalloc library.
+
+mmalloc:
+       $(MAKE) -C mmalloc
 
 # Common rules for building OCaml objects.
 
@@ -48,6 +68,7 @@ META: META.in Makefile.config
 
 clean:
        rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *~ core META *.opt
+       $(MAKE) -C mmalloc clean
 
 # Dependencies.
 
@@ -65,7 +86,7 @@ endif
 
 install:
        rm -rf $(DESTDIR)$(OCAMLLIBDIR)/ancient
-       install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/weblogs
+       install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/ancient
        install -c -m 0644 *.cmi *.mli *.cma *.cmxa *.a META \
          $(DESTDIR)$(OCAMLLIBDIR)/ancient
 
@@ -81,12 +102,7 @@ dist:
        ls -l $(PACKAGE)-$(VERSION).tar.gz
 
 check-manifest:
-       @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
-       do \
-       b=`dirname $$d`/; \
-       awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
-       sed -e "s|^|$$b|" -e "s|^\./||"; \
-       done | sort > .check-manifest; \
+       git ls-files | sort > .check-manifest; \
        sort MANIFEST > .orig-manifest; \
        diff -u .orig-manifest .check-manifest; rv=$$?; \
        rm -f .orig-manifest .check-manifest; \
@@ -120,6 +136,6 @@ doc:
        mkdir html
        -ocamlfind ocamldoc $(OCAMLDOCFLAGS) -d html ancient.ml{i,}
 
-.PHONY:        depend dist check-manifest dpkg doc
+.PHONY:        depend dist check-manifest dpkg doc mmalloc
 
 .SUFFIXES:     .cmo .cmi .cmx .ml .mli