configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 13 10:32:38 2008 +0000 (2008-07-13)
changeset 645 8e58024f8e37
parent 615 c9d37346d57f
child 673 a78a4bcc62d6
permissions -rwxr-xr-x
Ioannis E. VENETIS <venetis@mail.capsl.udel.edu> pointed out that GMP and MPFR were not used by gcc.
Turned out that none could use GMP and MPFR as the config option changed its name, but the change was not propagated to all users.

/trunk/scripts/build/binutils.sh | 2 1 1 0 +-
/trunk/scripts/build/debug/300-gdb.sh | 2 1 1 0 +-
/trunk/scripts/build/cc_gcc.sh | 6 3 3 0 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
     1 #!/bin/sh
     2 
     3 VERSION=$(cat .version)
     4 DATE=$(date +%Y%m%d)
     5 
     6 PREFIX_DEFAULT=/usr/local
     7 
     8 BINDIR_set=
     9 LIBDIR_set=
    10 DOCDIR_set=
    11 MANDIR_set=
    12 LOCAL_set=
    13 
    14 do_quit=
    15 CONTRIB_list=
    16 
    17 # Given an option string and the following argument,
    18 # echoes the value of the option.
    19 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
    20 # If --var val => echoes val and returns non null, meaning second arg was used
    21 get_optval(){
    22     local ret
    23     case "$1" in
    24         --*=?*)
    25             echo "${1}" |cut -d '=' -f 2-
    26             ret=0
    27             ;;
    28         *)
    29             echo "${2}"
    30             ret=1
    31             ;;
    32     esac
    33     return ${ret}
    34 }
    35 
    36 # The set_xxx functions will set the corresponding configuration variable
    37 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
    38 set_prefix() {
    39     PREFIX=$(get_optval "$1" "$2")
    40     return $?
    41 }
    42 set_bindir() {
    43     BINDIR_set=1
    44     BINDIR=$(get_optval "$1" "$2")
    45     return $?
    46 }
    47 set_libdir() {
    48     LIBDIR_set=1
    49     LIBDIR=$(get_optval "$1" "$2")
    50     return $?
    51 }
    52 set_docdir() {
    53     DOCDIR_set=1
    54     DOCDIR=$(get_optval "$1" "$2")
    55     return $?
    56 }
    57 set_mandir() {
    58     MANDIR_set=1
    59     MANDIR=$(get_optval "$1" "$2")
    60     return $?
    61 }
    62 
    63 # The set_contrib function is different in that it will work like the others,
    64 # except in two cases:
    65 # If all => replaces all with the list of all available contribs
    66 # If list => just echoes the list of all available contribs, and instructs
    67 # caller to quit immediately by setting do_quit to non null.
    68 # (can't use the return code, see above).
    69 set_contrib() {
    70     opt_val=$(get_optval "$1" "$2")
    71     local ret=$?
    72     case "${opt_val}" in
    73         all)
    74             CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma  \
    75                            |xargs -I {} basename {} .patch.lzma \
    76                            |sed -r -e ':a; /$/N; s/\n/,/; ta;'
    77                           )
    78             ;;
    79         list)
    80             do_quit=1
    81             echo "Available contributions:"
    82             LC_ALL=C ls -1 contrib/*.patch.lzma     \
    83             |xargs -I {} basename {} .patch.lzma    \
    84             |sed -r -e 's/^/  /;'
    85             ;;
    86         *)  CONTRIB_list="${CONTRIB_list},${opt_val}";;
    87     esac
    88     return $ret
    89 }
    90 
    91 do_help() {
    92     cat <<__EOF__
    93 \`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
    94 
    95 USAGE: ./configure [OPTION]...
    96 
    97 Defaults for the options are specified in brackets.
    98 
    99 Configuration:
   100   -h, --help              display this help and exit                                                                                                                  
   101 
   102 Installation directories:
   103   --prefix=PREFIX         install files in PREFIX [${PREFIX_DEFAULT}]
   104   --local                 don't install, and use current directory
   105 
   106 By default, \`make install' will install all the files in
   107 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc.  You can specify
   108 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
   109 for instance \`--prefix=\${HOME}'.
   110 
   111 For better control, use the options below.
   112 
   113 Fine tuning of the installation directories:
   114   --bindir=DIR           user executables [PREFIX/bin]
   115   --libdir=DIR           object code libraries [PREFIX/lib]
   116   --docdir=DIR           info documentation [PREFIX/share/doc]
   117   --mandir=DIR           man documentation [PREFIX/share/man]
   118 
   119 Optional Features:
   120   --with-contrib=XXX     Include externally contributed features found in the
   121                          contrib/ sub-directory. Set to a comma-separated list
   122                          of features. Use 'all' to use all contributions, and
   123                          'list' to see which are available.
   124 __EOF__
   125 }
   126 
   127 do_error() {
   128     echo "[ERROR] ${@}"
   129     exit 1
   130 }
   131 
   132 #---------------------------------------------------------------------
   133 # Set user's options
   134 
   135 while [ $# -ne 0 ]; do
   136     case "$1" in
   137         --prefix*)  set_prefix "$1" "$2" && shift || shift 2;;
   138         --bindir*)  set_bindir "$1" "$2" && shift || shift 2;;
   139         --libdir*)  set_libdir "$1" "$2" && shift || shift 2;;
   140         --docdir*)  set_docdir "$1" "$2" && shift || shift 2;;
   141         --mandir*)  set_mandir "$1" "$2" && shift || shift 2;;
   142         --local)    LOCAL_set=1; shift;;
   143         --with-contrib*)
   144                     set_contrib "$1" "$2" && shift || shift 2
   145                     [ "${do_quit}" = "1" ] && exit 0
   146                     ;;
   147         --help|-h)  do_help; exit 0;;
   148         *)          do_help; exit 1;;
   149     esac
   150 done
   151 
   152 # Use defaults
   153 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
   154 
   155 # Special case when installing locally
   156 if [ "${LOCAL_set}" = "1" ]; then
   157     set_prefix "" $(pwd)
   158     set_bindir "" $(pwd)
   159     set_libdir "" $(pwd)
   160     set_docdir "" $(pwd)/docs
   161     set_mandir "" $(pwd)/docs
   162 fi
   163 
   164 #---------------------------------------------------------------------
   165 # Some sanity checks, now
   166 
   167 # If this version is a svn snapshot, try to get the revision number
   168 # If we can't get the revision number, use date
   169 printf "Computing version string... "
   170 case "${VERSION}" in
   171   *+svn)
   172     REVISION=$(LC_ALL=C svnversion)
   173     case "${REVISION}" in
   174       exported)
   175         VERSION="${VERSION}unknown@$(date +%Y%m%d.%H%M%S)";;
   176       *)
   177         URL=$(LC_ALL=C svn info 2>/dev/null |egrep 'URL: ' |cut -d ' ' -f 2-)
   178         ROOT=$(LC_ALL=C svn info 2>/dev/null |egrep 'Repository Root: ' |cut -d ' ' -f 3-)
   179         VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
   180         ;;
   181     esac
   182     # Arrange to have no / in the directory name, no need to create an
   183     # arbitrarily deep directory structure
   184     VERSION=$(echo "${VERSION}" |sed -r -e 's|/+|_|g;')
   185     ;;
   186 esac
   187 echo "${VERSION}"
   188 
   189 # Now we have the version string, we can build up the paths
   190 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
   191 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
   192 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
   193 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
   194 
   195 # Check bash is present, and at least version 3.0
   196 printf "Checking bash is at least bash-3.0... "
   197 [ -x /bin/bash ] || do_error "bash 3.0 or above was not found in /bin/bash"
   198 bash_version=$(/bin/bash -c 'echo ${BASH_VERSION}')
   199 bash_major=$(/bin/bash -c 'echo ${BASH_VERSINFO[0]}')
   200 [ ${bash_major} -ge 3 ] || do_error "bash 3.0 or above is needed (/bin/bash is ${bash_version})"
   201 echo "ok (${bash_version})"
   202 
   203 printf "Applying contributed code: "
   204 # It's safer to change all ',' to spaces rather than setting IFS
   205 CONTRIB_list=$(echo "${CONTRIB_list}" |sed -r -e 's/,+/ /g;')
   206 for c in ${CONTRIB_list}; do
   207     printf "${c}, "
   208     if [ ! -f "contrib/${c}.patch.lzma" ]; then
   209         do_error "Contribution '${c}' does not exist"
   210     fi
   211     lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
   212 done
   213 echo "done"
   214 
   215 printf "Building up Makefile... "
   216 sed -r -e "s,@@BINDIR@@,${BINDIR},g;"   \
   217        -e "s,@@LIBDIR@@,${LIBDIR},g;"   \
   218        -e "s,@@DOCDIR@@,${DOCDIR},g;"   \
   219        -e "s,@@MANDIR@@,${MANDIR},g;"   \
   220        -e "s,@@VERSION@@,${VERSION},g;" \
   221        -e "s,@@DATE@@,${DATE},g;"       \
   222        -e "s,@@LOCAL@@,${LOCAL_set},g;" \
   223        Makefile.in >Makefile
   224 echo "ok"
   225 
   226 cat <<__EOF__
   227 crosstool-NG configured as follows:
   228   PREFIX='${PREFIX}'
   229   BINDIR='${BINDIR}'
   230   LIBDIR='${LIBDIR}'
   231   DOCDIR='${DOCDIR}'
   232   MANDIR='${MANDIR}'
   233   CONTRIB='${CONTRIB_list}'
   234 __EOF__