Producing first Debian packages.
[perl4caml.git] / Makefile
index 7b1d5e5..e852966 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Interface to Perl from OCaml.
 # Copyright (C) 2003 Merjis Ltd.
-# $Id: Makefile,v 1.12 2003-10-22 10:18:26 rich Exp $
+# $Id: Makefile,v 1.14 2003-11-02 13:28:38 rich Exp $
 
 include Makefile.config
 
@@ -21,9 +21,11 @@ CFLAGS := -Wall -Wno-unused -I$(PERLINCDIR)
 
 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
 
+SED := sed
+
 # XXX Hack required by ocamlopt, and sometimes ocamlc.
 # To work out what this should be, try:
-# `shell perl -MExtUtils::Embed -e ldopts'
+# `perl -MExtUtils::Embed -e ldopts'
 DYNALOADER_HACK := /usr/lib/perl/5.8.1/auto/DynaLoader/DynaLoader.a
 
 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
@@ -43,7 +45,7 @@ WRAPPERS := \
        wrappers/pl_HTTP_Response.cmo \
        wrappers/pl_LWP_UserAgent.cmo
 
-all:   perl4caml.cma perl4caml.cmxa all-examples html
+all:   perl4caml.cma perl4caml.cmxa META all-examples html
 
 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
        $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
@@ -86,12 +88,17 @@ examples/google.opt: examples/google.cmx
 
 .SUFFIXES: .mli .ml .cmi .cmo .cmx
 
+META:  META.in Makefile.config
+       $(SED)  -e 's/@PACKAGE@/$(PACKAGE)/' \
+               -e 's/@VERSION@/$(VERSION)/' \
+               < $< > $@
+
 # Clean.
 
 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
 
 clean:
-       rm -f examples/test examples/loadpage examples/google
+       rm -f META examples/test examples/loadpage examples/google
        for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
 
 # Build dependencies.
@@ -110,13 +117,14 @@ depend:   .depend
 # Install.
 
 install:
-       rm -rf $(OCAMLLIBDIR)/perl
-       install -c -m 0755 -d $(OCAMLLIBDIR)/perl
-       install -c -m 0755 -d $(OCAMLLIBDIR)/stublibs
+       rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
+       install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
+       install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
        install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
-         perl4caml.a libperl4caml.a \
-         $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) $(OCAMLLIBDIR)/perl
-       install -c -m 0644 dllperl4caml.so $(OCAMLLIBDIR)/stublibs
+         perl4caml.a libperl4caml.a META \
+         $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
+         $(DESTDIR)$(OCAMLLIBDIR)/perl
+       install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
 
 # Distribution.