From 08d50c85ec0b946ab73cf6629b4a79915a85eba3 Mon Sep 17 00:00:00 2001
From: Luigi Rizzo <rizzo@icir.org>
Date: Sun, 9 Dec 2007 16:47:25 +0000
Subject: [PATCH] Implement the outcome of a discussion on the -dev list re.
 the use of DESTDIR and INSTALL_PATH - many thanks to Tzafrir Cohen and Simon
 Perreault for extremely useful feedback:

1. comment out the [directories] section the created asterisk.conf ;
   you can set the correct defaults at build time using INSTALL_PATH,
   so the repetition here is redundant and often wrong.
   (The next step now is move asterisk.conf outside the Makefile to
   asterisk.conf.sample, because there is little if anything here
   that needs to be constructed at build/install time).

2. use DESTDIR?=$(INSTALL_PATH) so you only need to specify a path
   once if the two coincide. This should have no ill side effects,
   because if you don't specify DESTDIR, you really need
   INSTALL_PATH="" to set the correct defaults, and if you specify
   DESTDIR the value is not overridden.

The second part required moving the 'export DESTDIR' right after
the assignment to prevent DESTDIR getting set by the export
(this is documented in the Makefile).o hopefully avoid the mistake)$

With this change you can now do something like this from your source tree:

	make INSTALL_PATH=/some/place install samples

and then

	main/asterisk -vdc

which will pick up the correct config files and libraries from
/some/place - i.e. great for developers!



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@92002 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index fa7bd24aae..f012878e80 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,6 @@ export RANLIB
 export HOST_CC
 export STATIC_BUILD
 export INSTALL
-export DESTDIR
 export PROC
 export SOLINK
 export STRIP
@@ -88,12 +87,13 @@ OVERWRITE=y
 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
 DEBUG=-g3
 
-# Staging directory
+# DESTDIR is the staging directory.
 # Files are copied here temporarily during the install process
-# For example, make DESTDIR=/tmp/asterisk woud put things in
-# /tmp/asterisk/etc/asterisk
-# !!! Watch out, put no spaces or comments after the value !!!
-#DESTDIR?=/tmp/asterisk
+# WARNING: do not put spaces or comments after the value.
+# Also, do not export it before this point or the 'export' will
+# assign it to the empty string so ?= fails.
+DESTDIR?=$(INSTALL_PATH)
+export DESTDIR
 
 # Define standard directories for various platforms
 # These apply if they are not redefined in asterisk.conf 
@@ -578,7 +578,7 @@ samples: adsi
 	@if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
 		echo "Creating asterisk.conf"; \
 		( \
-		echo "[directories]" ; \
+		echo "[directories](!) ; remove the (!) to enable this" ; \
 		echo "astetcdir => $(ASTETCDIR)" ; \
 		echo "astmoddir => $(MODULES_DIR)" ; \
 		echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
-- 
GitLab