configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Jun 27 11:19:12 2008 +0000 (2008-06-27)
changeset 627 17a57be570a5
parent 614 ede871c1fd91
child 641 c20c96f8e999
permissions -rwxr-xr-x
Update the samples.

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