1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
  
     | 
    
      From: Stefano Zacchiroli <zack@debian.org>
Date: Sat, 3 Jul 2010 18:35:28 +0200
Subject: [PATCH] Makefiles fixes
Patch upstream Makefiles in order to:
 - install stuff properly in debian/ subdirs
 - built native code stuff only if ocamlopt is available
 - install camlidlruntime.h header in /usr/include/ocaml/<version>/
Author: Stefano Zacchiroli <zack@debian.org>
---
 Makefile              |    3 +++
 config/Makefile.unix  |   22 ++++++++++++----------
 lib/Makefile          |   17 +++++++++++++----
 runtime/Makefile.unix |    2 +-
 4 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 45c18d2..b1e6d17 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,9 @@ all:
 	cd lib; $(MAKE) all
 	cd tools; $(MAKE) all
 
+opt:
+	cd lib; $(MAKE) opt
+
 install:
 	cd compiler; $(MAKE) install
 	cd runtime; $(MAKE) install
diff --git a/config/Makefile.unix b/config/Makefile.unix
index cf4549c..8e1eae4 100644
--- a/config/Makefile.unix
+++ b/config/Makefile.unix
@@ -19,7 +19,7 @@ OSTYPE=unix
 
 # How to invoke the C preprocessor
 # Works on most Unix systems:
-CPP=/lib/cpp
+CPP=cpp
 # Alternatives:
 # CPP=cpp
 # CPP=/usr/ccs/lib/cpp
@@ -30,23 +30,25 @@ RANLIB=ranlib
 # If ranlib is not needed:
 #RANLIB=:
 
-# Location of the Objective Caml library in your installation
-OCAMLLIB=/usr/local/lib/ocaml
+# Location of the header files
+DEBIANOCAMLINCDIR=$(shell ocamlc -where)
+OCAMLINCDIR=$(DESTDIR)$(DEBIANOCAMLINCDIR)/caml
 
+# Location of the Objective Caml library in your installation
+OCAMLLIB=$(DESTDIR)$(shell ocamlc -where)
 # Where to install the binaries
-BINDIR=/usr/local/bin
+BINDIR=$(DESTDIR)/usr/bin
 
 # The Objective Caml compilers (the defaults below should be OK)
-OCAMLC=ocamlc -g
+# OCAMLC=ocamlc -g
+OCAMLC=ocamlc
 OCAMLOPT=ocamlopt
 OCAMLYACC=ocamlyacc -v
 OCAMLLEX=ocamllex
 OCAMLDEP=ocamldep
 
 # Extra flags to pass to the C compiler
-CFLAGS=-Wall -g
+CFLAGS=-I$(DEBIANOCAMLINCDIR)
 
-# Suffixes for executables and libraries (do not change)
-EXE=
-LIBEXT=a
-OBJEXT=o
+# Extension for lib files (do not change)
+LIB=.a
diff --git a/lib/Makefile b/lib/Makefile
index 7ce04da..43c77fe 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -19,8 +19,11 @@ BYTELIB=com.cma
 NATIVEOBJS=$(BYTEOBJS:.cmo=.cmx)
 NATIVELIB=$(BYTELIB:.cma=.cmxa)
 INTERFACES=$(BYTEOBJS:.cmo=.cmi)
+LIBEXT=a
 
-all: $(BYTELIB) $(NATIVELIB)
+all: $(BYTELIB)
+
+opt: $(NATIVELIB)
 
 $(BYTELIB): $(BYTEOBJS)
 	$(OCAMLC) -a -o $(BYTELIB) $(BYTEOBJS)
@@ -29,8 +32,14 @@ $(NATIVELIB): $(NATIVEOBJS)
 	$(OCAMLOPT) -a -o $(NATIVELIB) $(NATIVEOBJS)
 
 install:
-	cp $(INTERFACES) $(BYTELIB) $(NATIVELIB) $(NATIVELIB:.cmxa=.$(LIBEXT)) $(OCAMLLIB)
-	cd $(OCAMLLIB); $(RANLIB) $(NATIVELIB:.cmxa=.$(LIBEXT))
+	cp $(INTERFACES) $(BYTELIB) $(OCAMLLIB)
+	if [ -x /usr/bin/ocamlopt ]; then	\
+		cp $(NATIVELIB) $(NATIVELIB:.cmxa=$(LIB)) $(OCAMLLIB);	\
+		cd $(OCAMLLIB);	\
+		$(RANLIB) $(NATIVELIB:.cmxa=$(LIB));	\
+	else	\
+		true;	\
+	fi
 
 .SUFFIXES: .mli .ml .cmi .cmo .cmx
 
@@ -43,7 +52,7 @@ install:
 
 # Clean up
 clean::
-	rm -f *.cm[ioax] $.cmxa *~
+	-$(RM) -f *.cm[ioax] *.cmxa *.a *.o *~
 
 # Dependencies
 depend:
diff --git a/runtime/Makefile.unix b/runtime/Makefile.unix
index 5617349..737b048 100644
--- a/runtime/Makefile.unix
+++ b/runtime/Makefile.unix
@@ -22,7 +22,7 @@ libcamlidl.a: $(OBJS)
 	$(RANLIB) $@
 
 install:
-	cp camlidlruntime.h $(OCAMLLIB)/caml/camlidlruntime.h
+	cp camlidlruntime.h $(OCAMLINCDIR)/camlidlruntime.h
 	cp libcamlidl.a $(OCAMLLIB)/libcamlidl.a
 	cd $(OCAMLLIB); $(RANLIB) libcamlidl.a
 
-- 
 
     |