2007-07-01 19:04:20 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-08-15 15:39:44 +00:00
|
|
|
VERSION=$(cat .version)
|
2007-07-01 19:04:20 +00:00
|
|
|
DATE=$(date +%Y%m%d)
|
|
|
|
|
2008-07-16 21:59:49 +00:00
|
|
|
# All absolutely required tools, one per line to ease diff.
|
|
|
|
# See function 'has_or_abort, below, for syntax
|
|
|
|
# - Hopefully, if gcc is present, then all associated tools will be
|
|
|
|
# - awk must be GNU awk
|
|
|
|
# - makeinfo for building docs, even if discarded later on
|
|
|
|
# - others obvious... :-/
|
|
|
|
TOOLS_TO_CHECK='
|
|
|
|
make/^GNU
|
|
|
|
gcc
|
|
|
|
awk/^GNU
|
|
|
|
sed
|
|
|
|
bison
|
|
|
|
flex
|
|
|
|
makeinfo
|
2008-07-20 09:43:07 +00:00
|
|
|
automake
|
|
|
|
libtool
|
2008-07-16 21:59:49 +00:00
|
|
|
patch
|
|
|
|
tar
|
|
|
|
gzip
|
|
|
|
bzip2
|
|
|
|
'
|
|
|
|
|
2007-07-01 20:52:34 +00:00
|
|
|
PREFIX_DEFAULT=/usr/local
|
2007-07-01 19:04:20 +00:00
|
|
|
|
|
|
|
BINDIR_set=
|
|
|
|
LIBDIR_set=
|
|
|
|
DOCDIR_set=
|
|
|
|
MANDIR_set=
|
2007-07-22 17:44:27 +00:00
|
|
|
LOCAL_set=
|
2007-07-01 19:04:20 +00:00
|
|
|
|
2008-07-18 13:26:27 +00:00
|
|
|
FORCE=0
|
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
do_quit=
|
2008-06-25 08:34:47 +00:00
|
|
|
CONTRIB_list=
|
|
|
|
|
2008-07-16 21:59:49 +00:00
|
|
|
# Simply print the error message, and exit. Obvious, he?
|
|
|
|
do_error() {
|
|
|
|
echo "${@}"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# A small function to test for existence of various tools
|
|
|
|
# Usage: has_or_abort foobar
|
|
|
|
# -> foobar must exist in PATH
|
|
|
|
# Usage: has_or_abort foobar/string
|
|
|
|
# -> foobar must exist in PATH, and $(foobar --version) must contain 'string'
|
|
|
|
has_or_abort() {
|
|
|
|
tool=$(echo "${1}/" |cut -d / -f 1)
|
|
|
|
regexp=$(echo "${1}/" |cut -d / -f 2)
|
|
|
|
printf "Checking for '${tool}'... "
|
|
|
|
where=$(which "${tool}" 2>/dev/null || true)
|
|
|
|
if [ -z "${where}" ]; then
|
2008-07-18 13:26:27 +00:00
|
|
|
printf "not found!"
|
2008-07-22 09:17:40 +00:00
|
|
|
[ ${FORCE} -eq 0 ] && do_error " Bailing out..."
|
2008-07-18 13:26:27 +00:00
|
|
|
echo
|
2008-07-16 21:59:49 +00:00
|
|
|
else
|
|
|
|
printf "${where}"
|
|
|
|
if [ -n "${regexp}" ]; then
|
|
|
|
str=$(${tool} --version 2>&1 |egrep "${regexp}" |head -n 1)
|
|
|
|
if [ -z "${str}" ]; then
|
2008-07-22 09:17:40 +00:00
|
|
|
printf " failed: '${tool} --version' does not match regexp '${regexp}'."
|
|
|
|
[ ${FORCE} -eq 0 ] && do_error " Bailing out..."
|
2008-07-16 21:59:49 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
# 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
|
2007-07-01 19:04:20 +00:00
|
|
|
get_optval(){
|
|
|
|
local ret
|
|
|
|
case "$1" in
|
|
|
|
--*=?*)
|
2007-07-02 17:47:55 +00:00
|
|
|
echo "${1}" |cut -d '=' -f 2-
|
2007-07-01 19:04:20 +00:00
|
|
|
ret=0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "${2}"
|
|
|
|
ret=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return ${ret}
|
|
|
|
}
|
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
# 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.
|
2007-07-01 19:04:20 +00:00
|
|
|
set_prefix() {
|
|
|
|
PREFIX=$(get_optval "$1" "$2")
|
2007-09-12 20:44:15 +00:00
|
|
|
return $?
|
2007-07-01 19:04:20 +00:00
|
|
|
}
|
|
|
|
set_bindir() {
|
|
|
|
BINDIR_set=1
|
2007-09-12 20:44:15 +00:00
|
|
|
BINDIR=$(get_optval "$1" "$2")
|
|
|
|
return $?
|
2007-07-01 19:04:20 +00:00
|
|
|
}
|
|
|
|
set_libdir() {
|
|
|
|
LIBDIR_set=1
|
2007-09-12 20:44:15 +00:00
|
|
|
LIBDIR=$(get_optval "$1" "$2")
|
|
|
|
return $?
|
2007-07-01 19:04:20 +00:00
|
|
|
}
|
|
|
|
set_docdir() {
|
|
|
|
DOCDIR_set=1
|
2007-09-12 20:44:15 +00:00
|
|
|
DOCDIR=$(get_optval "$1" "$2")
|
|
|
|
return $?
|
2007-07-01 19:04:20 +00:00
|
|
|
}
|
|
|
|
set_mandir() {
|
|
|
|
MANDIR_set=1
|
2007-09-12 20:44:15 +00:00
|
|
|
MANDIR=$(get_optval "$1" "$2")
|
|
|
|
return $?
|
2007-07-01 19:04:20 +00:00
|
|
|
}
|
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
# 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).
|
2008-06-25 08:34:47 +00:00
|
|
|
set_contrib() {
|
|
|
|
opt_val=$(get_optval "$1" "$2")
|
|
|
|
local ret=$?
|
|
|
|
case "${opt_val}" in
|
|
|
|
all)
|
2008-07-07 21:22:25 +00:00
|
|
|
CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma \
|
|
|
|
|xargs -I {} basename {} .patch.lzma \
|
|
|
|
|sed -r -e ':a; /$/N; s/\n/,/; ta;'
|
|
|
|
)
|
2008-06-25 08:34:47 +00:00
|
|
|
;;
|
|
|
|
list)
|
|
|
|
do_quit=1
|
|
|
|
echo "Available contributions:"
|
2008-07-07 21:22:25 +00:00
|
|
|
LC_ALL=C ls -1 contrib/*.patch.lzma \
|
|
|
|
|xargs -I {} basename {} .patch.lzma \
|
|
|
|
|sed -r -e 's/^/ /;'
|
2008-06-25 08:34:47 +00:00
|
|
|
;;
|
|
|
|
*) CONTRIB_list="${CONTRIB_list},${opt_val}";;
|
|
|
|
esac
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2007-07-01 20:52:34 +00:00
|
|
|
do_help() {
|
|
|
|
cat <<__EOF__
|
2007-07-02 19:40:54 +00:00
|
|
|
\`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
|
2007-07-01 20:52:34 +00:00
|
|
|
|
|
|
|
USAGE: ./configure [OPTION]...
|
|
|
|
|
|
|
|
Defaults for the options are specified in brackets.
|
|
|
|
|
|
|
|
Configuration:
|
|
|
|
-h, --help display this help and exit
|
2008-07-18 21:03:04 +00:00
|
|
|
--force force ./configure to complete, even if one or more
|
|
|
|
tools were not found. Use at your own risk, only if
|
|
|
|
you know what you are doing!
|
2008-06-25 08:38:51 +00:00
|
|
|
|
|
|
|
Installation directories:
|
2007-07-01 21:21:11 +00:00
|
|
|
--prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
|
2007-07-22 17:44:27 +00:00
|
|
|
--local don't install, and use current directory
|
2007-07-01 20:52:34 +00:00
|
|
|
|
|
|
|
By default, \`make install' will install all the files in
|
|
|
|
\`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
|
|
|
|
an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
|
|
|
|
for instance \`--prefix=\${HOME}'.
|
|
|
|
|
|
|
|
For better control, use the options below.
|
|
|
|
|
|
|
|
Fine tuning of the installation directories:
|
2008-07-18 21:03:04 +00:00
|
|
|
--bindir=DIR user executables [PREFIX/bin]
|
|
|
|
--libdir=DIR object code libraries [PREFIX/lib]
|
|
|
|
--docdir=DIR info documentation [PREFIX/share/doc]
|
|
|
|
--mandir=DIR man documentation [PREFIX/share/man]
|
2008-06-25 08:34:47 +00:00
|
|
|
|
|
|
|
Optional Features:
|
2008-07-18 21:03:04 +00:00
|
|
|
--with-contrib=XXX Include externally contributed features found in the
|
|
|
|
contrib/ sub-directory. Set to a comma-separated list
|
|
|
|
of features. Use 'all' to use all contributions, and
|
|
|
|
'list' to see which are available.
|
2007-07-01 20:52:34 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2007-09-12 20:44:15 +00:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# Set user's options
|
|
|
|
|
2007-07-01 19:04:20 +00:00
|
|
|
while [ $# -ne 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--prefix*) set_prefix "$1" "$2" && shift || shift 2;;
|
|
|
|
--bindir*) set_bindir "$1" "$2" && shift || shift 2;;
|
|
|
|
--libdir*) set_libdir "$1" "$2" && shift || shift 2;;
|
|
|
|
--docdir*) set_docdir "$1" "$2" && shift || shift 2;;
|
|
|
|
--mandir*) set_mandir "$1" "$2" && shift || shift 2;;
|
2007-07-22 17:44:27 +00:00
|
|
|
--local) LOCAL_set=1; shift;;
|
2008-07-18 13:26:27 +00:00
|
|
|
--force) FORCE=1; shift;;
|
2008-06-25 08:34:47 +00:00
|
|
|
--with-contrib*)
|
|
|
|
set_contrib "$1" "$2" && shift || shift 2
|
|
|
|
[ "${do_quit}" = "1" ] && exit 0
|
|
|
|
;;
|
2007-07-01 20:52:34 +00:00
|
|
|
--help|-h) do_help; exit 0;;
|
|
|
|
*) do_help; exit 1;;
|
2007-07-01 19:04:20 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
# Use defaults
|
2007-07-01 21:21:11 +00:00
|
|
|
[ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
|
2008-07-07 21:22:25 +00:00
|
|
|
|
|
|
|
# Special case when installing locally
|
2007-07-22 17:44:27 +00:00
|
|
|
if [ "${LOCAL_set}" = "1" ]; then
|
|
|
|
set_prefix "" $(pwd)
|
|
|
|
set_bindir "" $(pwd)
|
|
|
|
set_libdir "" $(pwd)
|
|
|
|
set_docdir "" $(pwd)/docs
|
|
|
|
set_mandir "" $(pwd)/docs
|
|
|
|
fi
|
2007-07-01 20:52:34 +00:00
|
|
|
|
2007-09-12 20:44:15 +00:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# Some sanity checks, now
|
|
|
|
|
2008-02-17 22:58:57 +00:00
|
|
|
# If this version is a svn snapshot, try to get the revision number
|
|
|
|
# If we can't get the revision number, use date
|
2008-07-07 21:22:25 +00:00
|
|
|
printf "Computing version string... "
|
2008-02-17 22:58:57 +00:00
|
|
|
case "${VERSION}" in
|
|
|
|
*+svn)
|
2008-06-01 20:33:41 +00:00
|
|
|
REVISION=$(LC_ALL=C svnversion)
|
2008-04-17 19:21:32 +00:00
|
|
|
case "${REVISION}" in
|
|
|
|
exported)
|
2008-06-11 21:45:57 +00:00
|
|
|
VERSION="${VERSION}unknown@$(date +%Y%m%d.%H%M%S)";;
|
2008-04-17 19:21:32 +00:00
|
|
|
*)
|
2008-06-01 20:33:41 +00:00
|
|
|
URL=$(LC_ALL=C svn info 2>/dev/null |egrep 'URL: ' |cut -d ' ' -f 2-)
|
|
|
|
ROOT=$(LC_ALL=C svn info 2>/dev/null |egrep 'Repository Root: ' |cut -d ' ' -f 3-)
|
2008-06-11 21:45:57 +00:00
|
|
|
VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
|
2008-04-17 19:21:32 +00:00
|
|
|
;;
|
|
|
|
esac
|
2008-07-07 21:22:25 +00:00
|
|
|
# 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;')
|
2008-02-17 22:58:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
2008-06-11 20:40:38 +00:00
|
|
|
echo "${VERSION}"
|
2008-02-17 22:58:57 +00:00
|
|
|
|
2008-06-25 08:34:47 +00:00
|
|
|
# Now we have the version string, we can build up the paths
|
2008-06-11 21:45:57 +00:00
|
|
|
[ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
|
|
|
|
[ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
|
|
|
|
[ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
|
|
|
|
[ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
|
|
|
|
|
2007-09-12 20:44:15 +00:00
|
|
|
# Check bash is present, and at least version 3.0
|
2008-07-16 21:59:49 +00:00
|
|
|
printf "Checking '/bin/bash' is at least bash-3.0... "
|
|
|
|
[ -x /bin/bash ] || do_error "bash 3.0 or above was not found in '/bin/bash'"
|
2007-09-16 17:50:27 +00:00
|
|
|
bash_version=$(/bin/bash -c 'echo ${BASH_VERSION}')
|
|
|
|
bash_major=$(/bin/bash -c 'echo ${BASH_VERSINFO[0]}')
|
2008-07-16 21:59:49 +00:00
|
|
|
[ ${bash_major} -ge 3 ] || do_error "bash 3.0 or above is needed ('/bin/bash' is '${bash_version}')"
|
|
|
|
echo "${bash_version}"
|
|
|
|
|
|
|
|
# Check the existence of absolutely required tools
|
|
|
|
for tool in ${TOOLS_TO_CHECK}; do
|
|
|
|
has_or_abort "${tool}"
|
|
|
|
done
|
2007-09-12 20:44:15 +00:00
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
# It's safer to change all ',' to spaces rather than setting IFS
|
|
|
|
CONTRIB_list=$(echo "${CONTRIB_list}" |sed -r -e 's/,+/ /g;')
|
2008-07-16 21:59:49 +00:00
|
|
|
if [ -n "${CONTRIB_list}" ]; then
|
|
|
|
has_or_abort lzcat
|
|
|
|
printf "Applying contributed code: "
|
|
|
|
for c in ${CONTRIB_list}; do
|
|
|
|
printf "${c}, "
|
|
|
|
if [ ! -f "contrib/${c}.patch.lzma" ]; then
|
|
|
|
do_error "Contribution '${c}' does not exist"
|
|
|
|
fi
|
|
|
|
lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
|
|
|
|
done
|
|
|
|
echo "done"
|
|
|
|
fi
|
2008-06-25 08:34:47 +00:00
|
|
|
|
2008-07-07 21:22:25 +00:00
|
|
|
printf "Building up Makefile... "
|
2007-07-01 19:04:20 +00:00
|
|
|
sed -r -e "s,@@BINDIR@@,${BINDIR},g;" \
|
|
|
|
-e "s,@@LIBDIR@@,${LIBDIR},g;" \
|
|
|
|
-e "s,@@DOCDIR@@,${DOCDIR},g;" \
|
|
|
|
-e "s,@@MANDIR@@,${MANDIR},g;" \
|
|
|
|
-e "s,@@VERSION@@,${VERSION},g;" \
|
|
|
|
-e "s,@@DATE@@,${DATE},g;" \
|
2007-07-22 17:44:27 +00:00
|
|
|
-e "s,@@LOCAL@@,${LOCAL_set},g;" \
|
2007-07-01 21:21:11 +00:00
|
|
|
Makefile.in >Makefile
|
2008-07-16 21:59:49 +00:00
|
|
|
echo "done"
|
2007-07-01 21:21:11 +00:00
|
|
|
|
|
|
|
cat <<__EOF__
|
2008-07-16 21:59:49 +00:00
|
|
|
|
2007-07-02 19:40:54 +00:00
|
|
|
crosstool-NG configured as follows:
|
2008-06-11 21:45:57 +00:00
|
|
|
PREFIX='${PREFIX}'
|
|
|
|
BINDIR='${BINDIR}'
|
|
|
|
LIBDIR='${LIBDIR}'
|
|
|
|
DOCDIR='${DOCDIR}'
|
|
|
|
MANDIR='${MANDIR}'
|
2008-07-07 21:22:25 +00:00
|
|
|
CONTRIB='${CONTRIB_list}'
|
2007-07-01 21:21:11 +00:00
|
|
|
__EOF__
|