From: Jan Engelhardt <jengelh@medozas.de>
Date: 2011-10-24 17:00:09.801794019 +0200
Upstream: tbd

build: use FHS paths and avoid putting DESTDIR into CFLAGS

DESTDIR just does not belong into CFLAGS. At all.

---
 Makefile.am |   66 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 32 insertions(+), 34 deletions(-)

Index: lcr/Makefile.am
===================================================================
--- lcr.orig/Makefile.am
+++ lcr/Makefile.am
@@ -20,8 +20,6 @@
 ##    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ##    Boston, MA 02110-1301, USA.
 
-INSTALLdir = $(DESTDIR)/usr/local/lcr
-
 pkglogdir=$(localstatedir)/log/@PACKAGE@
 pkgsysconfdir=$(sysconfdir)/@PACKAGE@
 
@@ -30,12 +28,12 @@ pkgsysconfdir=$(sysconfdir)/@PACKAGE@
 #LOGdir=$(DESTDIR)$(pkglogdir)
 #EXTENSIONdir=$(DESTDIR)$(localstatedir)/lib/lcr
 
-CONFIGdir=$(INSTALLdir)
-SHAREdir=$(INSTALLdir)
-LOGdir=$(INSTALLdir)
-EXTENSIONdir=$(INSTALLdir)/extensions
+CONFIGdir=/var/lib/lcr
+SHAREdir=/var/lib/lcr
+LOGdir=/var/lib/lcr
+EXTENSIONdir=/var/lib/lcr/extensions
 
-astmoddir = $(DESTDIR)/usr/lib/asterisk/modules
+astmoddir = $(LIBDIR)/asterisk/modules
 
 INSTALLATION_DEFINES = \
  -DCONFIG_DATA="\"$(CONFIGdir)\"" \
@@ -110,9 +108,9 @@ select.po: select.c select.h
 	$(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c select.c -o select.po
 
 install-exec-hook:
-	mkdir -p $(astmoddir)
-	$(INSTALL) -d $(astmoddir)
-	$(INSTALL) chan_lcr.so $(astmoddir)
+	mkdir -p ${DESTDIR}$(astmoddir)
+	$(INSTALL) -d ${DESTDIR}$(astmoddir)
+	$(INSTALL) chan_lcr.so ${DESTDIR}$(astmoddir)
 endif
 
 INCLUDES = $(all_includes) $(GSM_INCLUDE) $(SS5_INCLUDE) -Wall $(INSTALLATION_DEFINES)
@@ -142,41 +140,41 @@ install-data-hook:
 	@sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
 	@sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
 	@sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
-	mkdir -p $(CONFIGdir)
-	mkdir -p $(SHAREdir)
-	mkdir -p $(LOGdir)
-	mkdir -p $(EXTENSIONdir)
-	@if test -a $(CONFIGdir)/options.conf ; then \
+	mkdir -p ${DESTDIR}$(CONFIGdir)
+	mkdir -p ${DESTDIR}$(SHAREdir)
+	mkdir -p ${DESTDIR}$(LOGdir)
+	mkdir -p ${DESTDIR}$(EXTENSIONdir)
+	@if test -a ${DESTDIR}$(CONFIGdir)/options.conf ; then \
 		echo "NOTE: options.conf already exists, not changed." ; else \
-		cp -v default/options.conf $(CONFIGdir) ; fi
-	@if test -a $(CONFIGdir)/interface.conf ; then \
+		cp -v default/options.conf ${DESTDIR}$(CONFIGdir) ; fi
+	@if test -a ${DESTDIR}$(CONFIGdir)/interface.conf ; then \
 		echo "NOTE: interface.conf already exists, not changed." ; else \
-		cp -v default/interface.conf $(CONFIGdir) ; fi
-	@if test -a $(CONFIGdir)/routing.conf ; then \
+		cp -v default/interface.conf ${DESTDIR}$(CONFIGdir) ; fi
+	@if test -a ${DESTDIR}$(CONFIGdir)/routing.conf ; then \
 		echo "NOTE: routing.conf already exists, not changed." ; else \
-		cp -v default/routing.conf $(CONFIGdir) ; fi
-	@if test -a $(CONFIGdir)/numbering_int.conf ; then \
+		cp -v default/routing.conf ${DESTDIR}$(CONFIGdir) ; fi
+	@if test -a ${DESTDIR}$(CONFIGdir)/numbering_int.conf ; then \
 		echo "NOTE: numbering_int.conf is obsolete, please use routing." ; fi
-	@if test -a $(CONFIGdir)/numbering_ext.conf ; then \
+	@if test -a ${DESTDIR}$(CONFIGdir)/numbering_ext.conf ; then \
 		echo "NOTE: numbering_ext.conf is obsolete, please use routing." ; fi
-	@if test -a $(CONFIGdir)/directory.list ; then \
+	@if test -a ${DESTDIR}$(CONFIGdir)/directory.list ; then \
 		echo "NOTE: directory.list already exists, not changed." ; else \
-		cp -v default/directory.list $(CONFIGdir) ; fi
-	@if test -a $(SHAREdir)/tones_american ; then \
+		cp -v default/directory.list ${DESTDIR}$(CONFIGdir) ; fi
+	@if test -a ${DESTDIR}$(SHAREdir)/tones_american ; then \
 		echo "NOTE: american tones already exists, not overwritten." ; else \
-		cp -a tones_american $(SHAREdir) ; fi
-	@if test -a $(SHAREdir)/tones_german ; then \
+		cp -a tones_american ${DESTDIR}$(SHAREdir) ; fi
+	@if test -a ${DESTDIR}$(SHAREdir)/tones_german ; then \
 		echo "NOTE: german tones already exists, not overwritten." ; else \
-		cp -a tones_german $(SHAREdir) ; fi
-	@if test -a $(SHAREdir)/vbox_german ; then \
+		cp -a tones_german ${DESTDIR}$(SHAREdir) ; fi
+	@if test -a ${DESTDIR}$(SHAREdir)/vbox_german ; then \
 		echo "NOTE: german vbox tones already exists, not overwritten." ; else \
-		cp -a vbox_german $(SHAREdir) ; fi
-	@if test -a $(SHAREdir)/vbox_english ; then \
+		cp -a vbox_german ${DESTDIR}$(SHAREdir) ; fi
+	@if test -a ${DESTDIR}$(SHAREdir)/vbox_english ; then \
 		echo "NOTE: english vbox tones already exists, not overwritten." ; else \
-		cp -a vbox_english $(SHAREdir) ; fi
-	@if test -a $(SHAREdir)/tones_efi ; then \
+		cp -a vbox_english ${DESTDIR}$(SHAREdir) ; fi
+	@if test -a ${DESTDIR}$(SHAREdir)/tones_efi ; then \
 		echo "NOTE: special efi tones already exists, not overwritten." ; else \
-		cp -a tones_efi $(SHAREdir) ; fi
+		cp -a tones_efi ${DESTDIR}$(SHAREdir) ; fi
 
 clean-generic:
 	rm -f *.po
