1.1 --- a/configure Wed Jun 25 08:38:51 2008 +0000
1.2 +++ b/configure Mon Jul 14 15:15:40 2008 +0000
1.3 @@ -11,9 +11,13 @@
1.4 MANDIR_set=
1.5 LOCAL_set=
1.6
1.7 -qo_quit=
1.8 +do_quit=
1.9 CONTRIB_list=
1.10
1.11 +# Given an option string and the following argument,
1.12 +# echoes the value of the option.
1.13 +# If --var=val => echoes val and returns 0, meaning second arg was not consumed
1.14 +# If --var val => echoes val and returns non null, meaning second arg was used
1.15 get_optval(){
1.16 local ret
1.17 case "$1" in
1.18 @@ -29,46 +33,55 @@
1.19 return ${ret}
1.20 }
1.21
1.22 +# The set_xxx functions will set the corresponding configuration variable
1.23 +# They return 0 if second arg was not consumed, and non-zero if it was consumed.
1.24 set_prefix() {
1.25 PREFIX=$(get_optval "$1" "$2")
1.26 return $?
1.27 }
1.28 -
1.29 set_bindir() {
1.30 BINDIR_set=1
1.31 BINDIR=$(get_optval "$1" "$2")
1.32 return $?
1.33 }
1.34 -
1.35 set_libdir() {
1.36 LIBDIR_set=1
1.37 LIBDIR=$(get_optval "$1" "$2")
1.38 return $?
1.39 }
1.40 -
1.41 set_docdir() {
1.42 DOCDIR_set=1
1.43 DOCDIR=$(get_optval "$1" "$2")
1.44 return $?
1.45 }
1.46 -
1.47 set_mandir() {
1.48 MANDIR_set=1
1.49 MANDIR=$(get_optval "$1" "$2")
1.50 return $?
1.51 }
1.52
1.53 +# The set_contrib function is different in that it will work like the others,
1.54 +# except in two cases:
1.55 +# If all => replaces all with the list of all available contribs
1.56 +# If list => just echoes the list of all available contribs, and instructs
1.57 +# caller to quit immediately by setting do_quit to non null.
1.58 +# (can't use the return code, see above).
1.59 set_contrib() {
1.60 opt_val=$(get_optval "$1" "$2")
1.61 local ret=$?
1.62 case "${opt_val}" in
1.63 all)
1.64 - CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma |sed -r -e 's|.*/||; s|\.patch\.lzma||;')
1.65 + CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma \
1.66 + |xargs -I {} basename {} .patch.lzma \
1.67 + |sed -r -e ':a; /$/N; s/\n/,/; ta;'
1.68 + )
1.69 ;;
1.70 list)
1.71 do_quit=1
1.72 echo "Available contributions:"
1.73 - LC_ALL=C ls -1 contrib/*.patch.lzma |sed -r -e 's|.*/||; s|\.patch\.lzma||; s|^| |;'
1.74 + LC_ALL=C ls -1 contrib/*.patch.lzma \
1.75 + |xargs -I {} basename {} .patch.lzma \
1.76 + |sed -r -e 's/^/ /;'
1.77 ;;
1.78 *) CONTRIB_list="${CONTRIB_list},${opt_val}";;
1.79 esac
1.80 @@ -136,7 +149,10 @@
1.81 esac
1.82 done
1.83
1.84 +# Use defaults
1.85 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
1.86 +
1.87 +# Special case when installing locally
1.88 if [ "${LOCAL_set}" = "1" ]; then
1.89 set_prefix "" $(pwd)
1.90 set_bindir "" $(pwd)
1.91 @@ -150,7 +166,7 @@
1.92
1.93 # If this version is a svn snapshot, try to get the revision number
1.94 # If we can't get the revision number, use date
1.95 -echo -n "Computing version string... "
1.96 +printf "Computing version string... "
1.97 case "${VERSION}" in
1.98 *+svn)
1.99 REVISION=$(LC_ALL=C svnversion)
1.100 @@ -163,7 +179,9 @@
1.101 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
1.102 ;;
1.103 esac
1.104 - VERSION="${VERSION/\//_}"
1.105 + # Arrange to have no / in the directory name, no need to create an
1.106 + # arbitrarily deep directory structure
1.107 + VERSION=$(echo "${VERSION}" |sed -r -e 's|/+|_|g;')
1.108 ;;
1.109 esac
1.110 echo "${VERSION}"
1.111 @@ -175,16 +193,18 @@
1.112 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
1.113
1.114 # Check bash is present, and at least version 3.0
1.115 -echo -n "Checking bash is at least bash-3.0... "
1.116 +printf "Checking bash is at least bash-3.0... "
1.117 [ -x /bin/bash ] || do_error "bash 3.0 or above was not found in /bin/bash"
1.118 bash_version=$(/bin/bash -c 'echo ${BASH_VERSION}')
1.119 bash_major=$(/bin/bash -c 'echo ${BASH_VERSINFO[0]}')
1.120 [ ${bash_major} -ge 3 ] || do_error "bash 3.0 or above is needed (/bin/bash is ${bash_version})"
1.121 echo "ok (${bash_version})"
1.122
1.123 -echo -n "Applying contributed code: "
1.124 -for c in ${CONTRIB_list//,/ }; do
1.125 - echo -n "${c}... "
1.126 +printf "Applying contributed code: "
1.127 +# It's safer to change all ',' to spaces rather than setting IFS
1.128 +CONTRIB_list=$(echo "${CONTRIB_list}" |sed -r -e 's/,+/ /g;')
1.129 +for c in ${CONTRIB_list}; do
1.130 + printf "${c}, "
1.131 if [ ! -f "contrib/${c}.patch.lzma" ]; then
1.132 do_error "Contribution '${c}' does not exist"
1.133 fi
1.134 @@ -192,7 +212,7 @@
1.135 done
1.136 echo "done"
1.137
1.138 -echo -n "Building up Makefile... "
1.139 +printf "Building up Makefile... "
1.140 sed -r -e "s,@@BINDIR@@,${BINDIR},g;" \
1.141 -e "s,@@LIBDIR@@,${LIBDIR},g;" \
1.142 -e "s,@@DOCDIR@@,${DOCDIR},g;" \
1.143 @@ -210,6 +230,5 @@
1.144 LIBDIR='${LIBDIR}'
1.145 DOCDIR='${DOCDIR}'
1.146 MANDIR='${MANDIR}'
1.147 - CONTRIB='${CONTRIB_list//
1.148 -/,}'
1.149 + CONTRIB='${CONTRIB_list}'
1.150 __EOF__