1.1 --- a/configure Mon Dec 22 18:21:51 2008 +0000
1.2 +++ b/configure Sun Jan 04 14:18:20 2009 +0000
1.3 @@ -11,13 +11,13 @@
1.4 # - others obvious... :-/
1.5 #
1.6 # Format of a pattern to check for, one per line:
1.7 -# pattern := tool_test OR pattern|tool_test
1.8 +# pattern := tool_test OR pattern || tool_test
1.9 # tool_test := tool=regexp OR tool
1.10 # tool := basename of the tool OR absolute pathname to the tool
1.11 # regexp := valid grep(1) extended regular expression, $( tool --version)
1.12 # will be matched against this regexp.
1.13 #
1.14 -# In case a pattern list is given (eg foo|bar|buz), then tests are performed
1.15 +# In case a pattern list is given (eg foo || bar || buz), then tests are performed
1.16 # from left to right, stopping at the first matching test (like the shell
1.17 # would parse 'foo || bar || buz' ).
1.18 #
1.19 @@ -25,7 +25,7 @@
1.20 # /bin/bash=^GNU bash, version 3\.
1.21 # will ensure that /bin/bash exists, and that $( /bin/bash --version )
1.22 # matches the regexp '^GNU bash, version 3\.'
1.23 -# autoconf=(GNU Autoconf)|autoconf2.50
1.24 +# autoconf=(GNU Autoconf) || autoconf2.50
1.25 # will ensure that:
1.26 # - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
1.27 # matches the regexp '(GNU Autoconf)' (which btw is the signature of
1.28 @@ -35,16 +35,17 @@
1.29 #
1.30 TOOLS_TO_CHECK='
1.31 /bin/bash=^GNU bash, version 3\.
1.32 +cut
1.33 +xargs
1.34 make=^GNU Make
1.35 gcc
1.36 gawk=^GNU Awk
1.37 -sed
1.38 bison
1.39 flex
1.40 makeinfo
1.41 -automake=\(GNU automake\) [[:digit:]]+\.[[:digit:]]{2,}|automake=\(GNU automake\) [2-9][[:digit:]]*\.
1.42 -libtool
1.43 -curl|wget
1.44 +automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
1.45 +libtool=\(GNU libtool\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
1.46 +curl || wget
1.47 patch
1.48 tar
1.49 gzip
1.50 @@ -75,8 +76,10 @@
1.51 # complete pattern format)
1.52 has_or_abort() {
1.53 save_IFS="${IFS}"
1.54 - IFS="|"
1.55 - for item in ${1}; do
1.56 + tool_pattern="$( echo "${1}" |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
1.57 + IFS='
1.58 +'
1.59 + for item in ${tool_pattern}; do
1.60 case "${item}" in
1.61 *=*)
1.62 tool="${item%%=*}"
1.63 @@ -92,22 +95,36 @@
1.64 echo "not found"
1.65 where=
1.66 continue
1.67 - else
1.68 - if [ -n "${regexp}" ]; then
1.69 - tool_version=$( ${tool} --version 2>&1 )
1.70 - str=$( echo "${tool_version}" |grep -E "${regexp}" |head -n 1 )
1.71 - if [ -z "${str}" ]; then
1.72 - echo "${where}: wrong version string: expecting regexp '${regexp}'"
1.73 - where=""
1.74 - continue
1.75 - fi
1.76 + elif [ -n "${regexp}" ]; then
1.77 + tool_version=$( ${tool} --version 2>&1 )
1.78 + str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
1.79 + if [ -z "${str}" ]; then
1.80 + echo "not found"
1.81 + where=""
1.82 + continue
1.83 fi
1.84 - echo "${where}"
1.85 - break
1.86 fi
1.87 + echo "${where}"
1.88 + break
1.89 done;
1.90 + if [ -z "${where}" ]; then
1.91 + for item in ${tool_pattern}; do
1.92 + case "${item}" in
1.93 + *=*)
1.94 + tool="${item%%=*}"
1.95 + regexp="${item#*=}"
1.96 + ;;
1.97 + *) tool="${item}"
1.98 + regexp=
1.99 + ;;
1.100 + esac
1.101 + echo " could not find '${tool}' matching regexp '${regexp}'"
1.102 + done
1.103 + echo "Either you are missing entirely the needed tool,"
1.104 + echo "or the version you have is tool old."
1.105 + [ ${FORCE} -eq 0 ] && do_error "Bailing out..."
1.106 + fi
1.107 IFS="${save_IFS}"
1.108 - [ -z "${where}" -a ${FORCE} -eq 0 ] && do_error "Bailing out..."
1.109 return 0
1.110 }
1.111
1.112 @@ -161,9 +178,9 @@
1.113 ret=$?
1.114 case "${opt_val}" in
1.115 all)
1.116 - CONTRIB_list="$( LC_ALL=C ls -1 contrib/*.patch.lzma \
1.117 - |xargs -I {} basename {} .patch.lzma \
1.118 - |sed -r -e ':a; /$/N; s/\n/,/; ta;' \
1.119 + CONTRIB_list="$( LC_ALL=C ls -1 contrib/*.patch.lzma \
1.120 + |xargs -I {} basename {} .patch.lzma \
1.121 + |"${sed}" -r -e ':a; /$/N; s/\n/,/; ta;' \
1.122 )"
1.123 ;;
1.124 list)
1.125 @@ -171,7 +188,7 @@
1.126 echo "Available contributions:"
1.127 LC_ALL=C ls -1 contrib/*.patch.lzma \
1.128 |xargs -I {} basename {} .patch.lzma \
1.129 - |sed -r -e 's/^/ /;'
1.130 + |"${sed}" -r -e 's/^/ /;'
1.131 ;;
1.132 *) CONTRIB_list="${CONTRIB_list},${opt_val}";;
1.133 esac
1.134 @@ -218,6 +235,34 @@
1.135 }
1.136
1.137 #---------------------------------------------------------------------
1.138 +# Some sanity checks, now
1.139 +
1.140 +# We check for grep and sed manually, because it is used in has_or_abort
1.141 +printf "Checking for 'grep'... "
1.142 +grep="$( which grep 2>/dev/null )"
1.143 +[ -z "${grep}" ] && do_error "not found"
1.144 +echo "${grep}"
1.145 +printf "Checking whether '${grep}' supports -E... "
1.146 +if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
1.147 + echo "yes"
1.148 +else
1.149 + do_error "no"
1.150 +fi
1.151 +printf "Checking for 'sed'... "
1.152 +sed="$( which sed 2>/dev/null )"
1.153 +[ -z "${sed}" ] && do_error "not found"
1.154 +echo "${sed}"
1.155 +
1.156 +# Check the existence of absolutely required tools
1.157 +save_IFS="${IFS}"
1.158 +IFS='
1.159 +'
1.160 +for tool in ${TOOLS_TO_CHECK}; do
1.161 + has_or_abort "${tool}"
1.162 +done
1.163 +IFS="${save_IFS}"
1.164 +
1.165 +#---------------------------------------------------------------------
1.166 # Set user's options
1.167
1.168 while [ $# -ne 0 ]; do
1.169 @@ -251,7 +296,27 @@
1.170 fi
1.171
1.172 #---------------------------------------------------------------------
1.173 -# Some sanity checks, now
1.174 +# Apply contributed code
1.175 +
1.176 +# It's safer to change all ',' to spaces rather than setting IFS
1.177 +CONTRIB_list="$( echo "${CONTRIB_list}" \
1.178 + |"${sed}" -r -e 's/,+/ /g; s/ +/ /g; s/^ //g; s/ $//g;' \
1.179 + )"
1.180 +if [ -n "${CONTRIB_list}" ]; then
1.181 + has_or_abort 'lzcat'
1.182 + printf "Applying contributed code: "
1.183 + for c in ${CONTRIB_list}; do
1.184 + printf "${c}, "
1.185 + if [ ! -f "contrib/${c}.patch.lzma" ]; then
1.186 + do_error "Contribution '${c}' does not exist"
1.187 + fi
1.188 + lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
1.189 + done
1.190 + echo "done"
1.191 +fi
1.192 +
1.193 +#---------------------------------------------------------------------
1.194 +# Compute the version string
1.195
1.196 # If this version is a svn snapshot, try to get the revision number
1.197 # If we can't get the revision number, use date
1.198 @@ -267,20 +332,23 @@
1.199 |egrep 'URL: ' \
1.200 |cut -d ' ' -f 2- \
1.201 )"
1.202 - ROOT="$( LC_ALL=C svn info 2>/dev/null \
1.203 - |egrep 'Repository Root: ' \
1.204 - |cut -d ' ' -f 3- \
1.205 + ROOT="$( LC_ALL=C svn info 2>/dev/null \
1.206 + |"${grep}" '^Repository Root: ' \
1.207 + |cut -d ' ' -f 3- \
1.208 )"
1.209 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
1.210 ;;
1.211 esac
1.212 # Arrange to have no / in the directory name, no need to create an
1.213 # arbitrarily deep directory structure
1.214 - VERSION="$( echo "${VERSION}" |sed -r -e 's|/+|_|g;' )"
1.215 + VERSION="$( echo "${VERSION}" |"${sed}" -r -e 's|/+|_|g;' )"
1.216 ;;
1.217 esac
1.218 echo "${VERSION}"
1.219
1.220 +#---------------------------------------------------------------------
1.221 +# Compute and check install paths
1.222 +
1.223 # Now we have the version string, we can build up the paths
1.224 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
1.225 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
1.226 @@ -297,40 +365,17 @@
1.227 esac
1.228 done
1.229
1.230 -# Check the existence of absolutely required tools
1.231 -save_IFS="${IFS}"
1.232 -IFS='
1.233 -'
1.234 -for tool in ${TOOLS_TO_CHECK}; do
1.235 - has_or_abort "${tool}"
1.236 -done
1.237 -IFS="${save_IFS}"
1.238 -
1.239 -# It's safer to change all ',' to spaces rather than setting IFS
1.240 -CONTRIB_list="$( echo "${CONTRIB_list}" \
1.241 - |sed -r -e 's/,+/ /g; s/ +/ /g; s/^ //g; s/ $//g;' \
1.242 - )"
1.243 -if [ -n "${CONTRIB_list}" ]; then
1.244 - has_or_abort 'lzcat'
1.245 - printf "Applying contributed code: "
1.246 - for c in ${CONTRIB_list}; do
1.247 - printf "${c}, "
1.248 - if [ ! -f "contrib/${c}.patch.lzma" ]; then
1.249 - do_error "Contribution '${c}' does not exist"
1.250 - fi
1.251 - lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
1.252 - done
1.253 - echo "done"
1.254 -fi
1.255 +#---------------------------------------------------------------------
1.256 +# That's all, folks!
1.257
1.258 printf "Building up Makefile... "
1.259 -sed -r -e "s,@@BINDIR@@,${BINDIR},g
1.260 - s,@@LIBDIR@@,${LIBDIR},g
1.261 - s,@@DOCDIR@@,${DOCDIR},g
1.262 - s,@@MANDIR@@,${MANDIR},g
1.263 - s,@@VERSION@@,${VERSION},g
1.264 - s,@@DATE@@,${DATE},g
1.265 - s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
1.266 +"${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g
1.267 + s,@@LIBDIR@@,${LIBDIR},g
1.268 + s,@@DOCDIR@@,${DOCDIR},g
1.269 + s,@@MANDIR@@,${MANDIR},g
1.270 + s,@@VERSION@@,${VERSION},g
1.271 + s,@@DATE@@,${DATE},g
1.272 + s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
1.273 echo "done"
1.274
1.275 cat <<__EOF__
1.276 @@ -342,4 +387,8 @@
1.277 DOCDIR='${DOCDIR}'
1.278 MANDIR='${MANDIR}'
1.279 CONTRIB='${CONTRIB_list}'
1.280 +
1.281 +Now run:
1.282 + make
1.283 + make install
1.284 __EOF__