summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-07-07 21:22:25 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-07-07 21:22:25 (GMT)
commit48728211f654cf3f8113097fa00a14f89f197779 (patch)
treed10345e8699c43099d398e15318322ccbb59a467
parent3afa6a22822b85e91f84f2c02283a72b3f2778f3 (diff)
POSIXify ./configure, and comment some parts of it.
Thanks to Martin GUY for pointing out that ./configure was not POSIXly correct. /trunk/configure | 51 35 16 0 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-)
-rwxr-xr-xconfigure51
1 files changed, 35 insertions, 16 deletions
diff --git a/configure b/configure
index ad61765..a1175b5 100755
--- a/configure
+++ b/configure
@@ -11,9 +11,13 @@ DOCDIR_set=
MANDIR_set=
LOCAL_set=
-qo_quit=
+do_quit=
CONTRIB_list=
+# Given an option string and the following argument,
+# echoes the value of the option.
+# If --var=val => echoes val and returns 0, meaning second arg was not consumed
+# If --var val => echoes val and returns non null, meaning second arg was used
get_optval(){
local ret
case "$1" in
@@ -29,46 +33,55 @@ get_optval(){
return ${ret}
}
+# The set_xxx functions will set the corresponding configuration variable
+# They return 0 if second arg was not consumed, and non-zero if it was consumed.
set_prefix() {
PREFIX=$(get_optval "$1" "$2")
return $?
}
-
set_bindir() {
BINDIR_set=1
BINDIR=$(get_optval "$1" "$2")
return $?
}
-
set_libdir() {
LIBDIR_set=1
LIBDIR=$(get_optval "$1" "$2")
return $?
}
-
set_docdir() {
DOCDIR_set=1
DOCDIR=$(get_optval "$1" "$2")
return $?
}
-
set_mandir() {
MANDIR_set=1
MANDIR=$(get_optval "$1" "$2")
return $?
}
+# The set_contrib function is different in that it will work like the others,
+# except in two cases:
+# If all => replaces all with the list of all available contribs
+# If list => just echoes the list of all available contribs, and instructs
+# caller to quit immediately by setting do_quit to non null.
+# (can't use the return code, see above).
set_contrib() {
opt_val=$(get_optval "$1" "$2")
local ret=$?
case "${opt_val}" in
all)
- CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma |sed -r -e 's|.*/||; s|\.patch\.lzma||;')
+ CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma \
+ |xargs -I {} basename {} .patch.lzma \
+ |sed -r -e ':a; /$/N; s/\n/,/; ta;'
+ )
;;
list)
do_quit=1
echo "Available contributions:"
- LC_ALL=C ls -1 contrib/*.patch.lzma |sed -r -e 's|.*/||; s|\.patch\.lzma||; s|^| |;'
+ LC_ALL=C ls -1 contrib/*.patch.lzma \
+ |xargs -I {} basename {} .patch.lzma \
+ |sed -r -e 's/^/ /;'
;;
*) CONTRIB_list="${CONTRIB_list},${opt_val}";;
esac
@@ -136,7 +149,10 @@ while [ $# -ne 0 ]; do
esac
done
+# Use defaults
[ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
+
+# Special case when installing locally
if [ "${LOCAL_set}" = "1" ]; then
set_prefix "" $(pwd)
set_bindir "" $(pwd)
@@ -150,7 +166,7 @@ fi
# If this version is a svn snapshot, try to get the revision number
# If we can't get the revision number, use date
-echo -n "Computing version string... "
+printf "Computing version string... "
case "${VERSION}" in
*+svn)
REVISION=$(LC_ALL=C svnversion)
@@ -163,7 +179,9 @@ case "${VERSION}" in
VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
;;
esac
- VERSION="${VERSION/\//_}"
+ # Arrange to have no / in the directory name, no need to create an
+ # arbitrarily deep directory structure
+ VERSION=$(echo "${VERSION}" |sed -r -e 's|/+|_|g;')
;;
esac
echo "${VERSION}"
@@ -175,16 +193,18 @@ echo "${VERSION}"
[ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
# Check bash is present, and at least version 3.0
-echo -n "Checking bash is at least bash-3.0... "
+printf "Checking bash is at least bash-3.0... "
[ -x /bin/bash ] || do_error "bash 3.0 or above was not found in /bin/bash"
bash_version=$(/bin/bash -c 'echo ${BASH_VERSION}')
bash_major=$(/bin/bash -c 'echo ${BASH_VERSINFO[0]}')
[ ${bash_major} -ge 3 ] || do_error "bash 3.0 or above is needed (/bin/bash is ${bash_version})"
echo "ok (${bash_version})"
-echo -n "Applying contributed code: "
-for c in ${CONTRIB_list//,/ }; do
- echo -n "${c}... "
+printf "Applying contributed code: "
+# It's safer to change all ',' to spaces rather than setting IFS
+CONTRIB_list=$(echo "${CONTRIB_list}" |sed -r -e 's/,+/ /g;')
+for c in ${CONTRIB_list}; do
+ printf "${c}, "
if [ ! -f "contrib/${c}.patch.lzma" ]; then
do_error "Contribution '${c}' does not exist"
fi
@@ -192,7 +212,7 @@ for c in ${CONTRIB_list//,/ }; do
done
echo "done"
-echo -n "Building up Makefile... "
+printf "Building up Makefile... "
sed -r -e "s,@@BINDIR@@,${BINDIR},g;" \
-e "s,@@LIBDIR@@,${LIBDIR},g;" \
-e "s,@@DOCDIR@@,${DOCDIR},g;" \
@@ -210,6 +230,5 @@ crosstool-NG configured as follows:
LIBDIR='${LIBDIR}'
DOCDIR='${DOCDIR}'
MANDIR='${MANDIR}'
- CONTRIB='${CONTRIB_list//
-/,}'
+ CONTRIB='${CONTRIB_list}'
__EOF__