[PATCH modular 15/15] build.sh: refactor installation directories initialization code
Gaetan Nadon
memsize at videotron.ca
Wed Dec 29 17:56:27 PST 2010
The code is best located in setup_buildenv.
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
build.sh | 132 +++++++++++++++++++++++++-------------------------------------
1 files changed, 53 insertions(+), 79 deletions(-)
diff --git a/build.sh b/build.sh
index 49ca386..1058a03 100755
--- a/build.sh
+++ b/build.sh
@@ -59,6 +59,59 @@ EOF
setup_buildenv() {
+ # Set installation directories to default values
+ # if the user has not set them through env var or cmd line
+ if [ X"$PREFIX" != X ]; then
+ PREFIX_SET=yes
+ else
+ PREFIX=/usr/local
+ fi
+
+ if [ X"$EPREFIX" != X ]; then
+ EPREFIX_SET=yes
+ else
+ EPREFIX=$PREFIX
+ fi
+
+ if [ X"$BINDIR" != X ]; then
+ BINDIR_SET=yes
+ else
+ BINDIR=$EPREFIX/bin
+ fi
+
+ if [ X"$DATAROOTDIR" != X ]; then
+ DATAROOTDIR_SET=yes
+ else
+ DATAROOTDIR=$PREFIX/share
+ fi
+
+ if [ X"$DATADIR" != X ]; then
+ DATADIR_SET=yes
+ else
+ DATADIR=$DATAROOTDIR
+ fi
+
+ if [ X"$LIBDIR" != X ]; then
+ LIBDIR_SET=yes
+ # Support previous usage of LIBDIR which was a subdir relative to PREFIX
+ # We use EPREFIX as this is what PREFIX really meant at the time
+ if [ X"`expr substr $LIBDIR 1 1`" != X/ ]; then
+ echo ""
+ echo "Warning: this usage of \$LIBDIR is deprecated. Use a full path name."
+ echo "The supplied value \"$LIBDIR\" has been replaced with $EPREFIX/$LIBDIR."
+ echo ""
+ LIBDIR=$EPREFIX/$LIBDIR
+ fi
+ else
+ LIBDIR=$EPREFIX/lib
+ fi
+
+ if [ X"$LOCALSTATEDIR" != X ]; then
+ LOCALSTATEDIR_SET=yes
+ else
+ LOCALSTATEDIR=$PREFIX/var
+ fi
+
# All directories variables must be full path names
check_full_path $PREFIX PREFIX
check_full_path $EPREFIX EPREFIX
@@ -1072,41 +1125,6 @@ export HOST_OS
HOST_CPU=`uname -m`
export HOST_CPU
-# States if the user has exported PREFIX
-if [ X"$PREFIX" != X ]; then
- PREFIX_SET=yes
-fi
-
-# States if the user has exported EPREFIX
-if [ X"$EPREFIX" != X ]; then
- EPREFIX_SET=yes
-fi
-
-# States if the user has exported BINDIR
-if [ X"$BINDIR" != X ]; then
- BINDIR_SET=yes
-fi
-
-# States if the user has exported DATAROOTDIR
-if [ X"$DATAROOTDIR" != X ]; then
- DATAROOTDIR_SET=yes
-fi
-
-# States if the user has exported DATADIR
-if [ X"$DATADIR" != X ]; then
- DATADIR_SET=yes
-fi
-
-# States if the user has exported LIBDIR
-if [ X"$LIBDIR" != X ]; then
- LIBDIR_SET=yes
-fi
-
-# States if the user has exported LOCALSTATEDIR
-if [ X"$LOCALSTATEDIR" != X ]; then
- LOCALSTATEDIR_SET=yes
-fi
-
# Process command line args
while [ $# != 0 ]
do
@@ -1230,7 +1248,6 @@ do
fi
PREFIX=$1
- PREFIX_SET=yes
too_many=yes
;;
esac
@@ -1238,49 +1255,6 @@ do
shift
done
-# Set the default value for PREFIX
-if [ X"$PREFIX_SET" = X ]; then
- PREFIX=/usr/local
-fi
-
-# Set the default value for EPREFIX
-if [ X"$EPREFIX_SET" = X ]; then
- EPREFIX=$PREFIX
-fi
-
-# Set the default value for BINDIR
-if [ X"$BINDIR_SET" = X ]; then
- BINDIR=$EPREFIX/bin
-fi
-
-# Set the default value for DATAROOTDIR
-if [ X"$DATAROOTDIR_SET" = X ]; then
- DATAROOTDIR=$PREFIX/share
-fi
-
-# Set the default value for DATADIR
-if [ X"$DATADIR_SET" = X ]; then
- DATADIR=$DATAROOTDIR
-fi
-
-# Set the default value for LIBDIR
-if [ X"$LIBDIR_SET" = X ]; then
- LIBDIR=$EPREFIX/lib
-# Support previous usage of LIBDIR which was a subdir relative to PREFIX
-# We use EPREFIX as this is what PREFIX really meant at the time
-elif [ X"`expr substr $LIBDIR 1 1`" != X/ ]; then
- echo ""
- echo "Warning: this usage of \$LIBDIR is deprecated. Use a full path name."
- echo "The supplied value \"$LIBDIR\" has been replaced with $EPREFIX/$LIBDIR."
- echo ""
- LIBDIR=$EPREFIX/$LIBDIR
-fi
-
-# Set the default value for LOCALSTATEDIR
-if [ X"$LOCALSTATEDIR_SET" = X ]; then
- LOCALSTATEDIR=$PREFIX/var
-fi
-
# All user input has been obtained, set-up the user shell variables
if [ X"$LISTONLY" = X ]; then
setup_buildenv
--
1.6.0.4
More information about the xorg-devel
mailing list