configure.ac
changeset 2834 0a0410dd0cb0
child 2835 0a2fa748727e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/configure.ac	Mon Nov 07 22:28:40 2011 +0100
     1.3 @@ -0,0 +1,346 @@
     1.4 +#                                               -*- Autoconf -*-
     1.5 +# Process this file with autoconf to produce a configure script.
     1.6 +
     1.7 +AC_PREREQ([2.67])
     1.8 +#AC_INIT([crosstool-NG], [hg], [crossgcc@sourceware.org])
     1.9 +AC_INIT([crosstool-NG], [m4_esyscmd_s([cat .version])], [crossgcc@sourceware.org])
    1.10 +AC_CONFIG_AUX_DIR([scripts])
    1.11 +
    1.12 +#--------------------------------------------------------------------
    1.13 +# A few helper macros
    1.14 +
    1.15 +# Check for required tool
    1.16 +AC_DEFUN(
    1.17 +    [ACX_CHECK_TOOL_REQ],
    1.18 +    [AC_CHECK_TOOLS([$1], [$2])
    1.19 +     AS_IF(
    1.20 +        [test -z "$$1"],
    1.21 +        [AC_MSG_ERROR([missing required tool: $2])])
    1.22 +    ])
    1.23 +
    1.24 +# Check for required tool, set variable to full pathname
    1.25 +AC_DEFUN(
    1.26 +    [ACX_PATH_TOOL_REQ],
    1.27 +    [ACX_CHECK_TOOL_REQ([$1], [$2])
    1.28 +     AS_CASE(
    1.29 +        [$$1],
    1.30 +        [/*],,
    1.31 +        [?*],[AC_MSG_CHECKING([for absolute path to $$1])
    1.32 +              $1=$(which $$1)
    1.33 +              AC_MSG_RESULT([$$1])])])
    1.34 +
    1.35 +# Check for required program
    1.36 +AC_DEFUN(
    1.37 +    [ACX_CHECK_PROGS_REQ],
    1.38 +    [AC_CHECK_PROGS([$1], [$2])
    1.39 +     AS_IF(
    1.40 +        [test -z "$$1"],
    1.41 +        [AC_MSG_ERROR([missing required tool: $2])])
    1.42 +    ])
    1.43 +
    1.44 +# Check for path to required program
    1.45 +AC_DEFUN(
    1.46 +    [ACX_PATH_PROGS_REQ],
    1.47 +    [AC_PATH_PROGS([$1], [$2])
    1.48 +     AS_IF(
    1.49 +        [test -z "$$1"],
    1.50 +        [AC_MSG_ERROR([missing required tool: $2])])
    1.51 +    ])
    1.52 +
    1.53 +# Set the kconfig option
    1.54 +AC_DEFUN(
    1.55 +    [ACX_SET_KCONFIG_OPTION],
    1.56 +    [AS_IF(
    1.57 +        [test -n "$$1"],
    1.58 +        [kconfig_options="$kconfig_options $1=y"],
    1.59 +        [kconfig_options="$kconfig_options $1"])
    1.60 +    ])
    1.61 +
    1.62 +#--------------------------------------------------------------------
    1.63 +# Allow dummy --{en,dis}able-{static,shared}
    1.64 +AC_ARG_ENABLE(
    1.65 +    [local],
    1.66 +    [AS_HELP_STRING(
    1.67 +        [--enable-local],
    1.68 +        [don't install, and use current directory])])
    1.69 +AC_SUBST([enable_local], [${enable_local:-no}])
    1.70 +AC_ARG_ENABLE(
    1.71 +    [shared],
    1.72 +    [AS_HELP_STRING(
    1.73 +        [--enable-shared],
    1.74 +        [build shared libraries (default=yes) (ignored)])])
    1.75 +AC_ARG_ENABLE(
    1.76 +    [static],
    1.77 +    [AS_HELP_STRING(
    1.78 +        [--enable-static],
    1.79 +        [build static libraries (default=yes) (ignored)])])
    1.80 +
    1.81 +#---------------------------------------------------------------------
    1.82 +# Check for --build and --host...
    1.83 +AC_CANONICAL_BUILD
    1.84 +AC_CANONICAL_HOST
    1.85 +# ... but refuse --target
    1.86 +AS_IF([test -n "$target_alias"],
    1.87 +      AC_MSG_ERROR([--target is not allowed]))
    1.88 +
    1.89 +# Allow program name tranformation (--program-{prefix,suffix,transform-name})
    1.90 +AC_ARG_PROGRAM
    1.91 +
    1.92 +#---------------------------------------------------------------------
    1.93 +# Initial checks that are usually done first (I don't know why, that's
    1.94 +# just what I seem to experience...)
    1.95 +#---------------------------------------------------------------------
    1.96 +AC_PROG_INSTALL
    1.97 +AC_PROG_EGREP
    1.98 +AC_CACHE_VAL([ac_cv_path_SED],
    1.99 +    [AC_ARG_WITH([sed],
   1.100 +        AS_HELP_STRING([--with-sed=PATH],
   1.101 +                       [Specify the full PATH to sed]),
   1.102 +        [ac_cv_path_SED=$withval])])
   1.103 +AC_PROG_SED
   1.104 +AC_MSG_CHECKING([whether sed understands -r -i -e])
   1.105 +touch .ct-ng.sed.test
   1.106 +if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
   1.107 +    rm -f .ct-ng.sed.test
   1.108 +    AC_MSG_RESULT([yes])
   1.109 +else
   1.110 +    rm -f .ct-ng.sed.test
   1.111 +    AC_MSG_RESULT([no])
   1.112 +    AC_MSG_ERROR()
   1.113 +fi
   1.114 +AC_PROG_LN_S
   1.115 +
   1.116 +#--------------------------------------------------------------------
   1.117 +# A bunch of boring tests...
   1.118 +#--------------------------------------------------------------------
   1.119 +AC_PROG_CC
   1.120 +AS_IF([test -z "$CC"],
   1.121 +      [AC_MSG_ERROR([no suitable compiler found])])
   1.122 +AC_PROG_CPP
   1.123 +AC_PROG_RANLIB
   1.124 +ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy])
   1.125 +ACX_PATH_TOOL_REQ([OBJDUMP], [objdump])
   1.126 +ACX_PATH_TOOL_REQ([READELF], [readelf])
   1.127 +
   1.128 +ACX_CHECK_PROGS_REQ([bison], [bison])
   1.129 +ACX_CHECK_PROGS_REQ([flex], [flex])
   1.130 +ACX_CHECK_PROGS_REQ([awk], [gawk mawk nawk awk])
   1.131 +ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
   1.132 +ACX_CHECK_PROGS_REQ([cut], [cut])
   1.133 +ACX_CHECK_PROGS_REQ([stat], [stat])
   1.134 +ACX_CHECK_PROGS_REQ([readlink], [readlink])
   1.135 +ACX_CHECK_PROGS_REQ([curl], [curl])
   1.136 +ACX_CHECK_PROGS_REQ([tar], [tar])
   1.137 +ACX_CHECK_PROGS_REQ([gzip], [gzip])
   1.138 +ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
   1.139 +
   1.140 +#--------------------------------------------------------------------
   1.141 +# Still boring, but remember the path, now...
   1.142 +#--------------------------------------------------------------------
   1.143 +ACX_PATH_PROGS_REQ([PATCH], [patch])
   1.144 +
   1.145 +#--------------------------------------------------------------------
   1.146 +# And a bunch of less boring tests...
   1.147 +#--------------------------------------------------------------------
   1.148 +# We need a bash that is >= 3.1
   1.149 +AC_CACHE_VAL([ac_cv_path__BASH],
   1.150 +    [AC_ARG_WITH([bash],
   1.151 +        AS_HELP_STRING([--with-bash=PATH],
   1.152 +                       [Specify the full PATH to bash >= 3.1]),
   1.153 +        [ac_cv_path__BASH=$withval])])
   1.154 +AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
   1.155 +    [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
   1.156 +        [[_BASH_ver=$($ac_path__BASH --version 2>&1 \
   1.157 +                     |$EGREP '^GNU bash, version (3\.[1-9]|4)')
   1.158 +          test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
   1.159 +        [AC_MSG_RESULT([no])
   1.160 +         AC_MSG_ERROR([could not find bash >= 3.1])])])
   1.161 +AC_SUBST([_BASH], [$ac_cv_path__BASH])
   1.162 +
   1.163 +#----------------------------------------
   1.164 +# Check for GNU make 3.80 or above
   1.165 +AC_CACHE_VAL([ac_cv_path_MAKE],
   1.166 +    [AC_ARG_WITH([make],
   1.167 +        AS_HELP_STRING([--with-make=PATH],
   1.168 +                       [Specify the full PATH to GNU make >= 3.80]),
   1.169 +        [ac_cv_path_MAKE=$withval])])
   1.170 +AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE],
   1.171 +    [AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake],
   1.172 +        [[MAKE_ver=$($ac_path_MAKE --version 2>&1 \
   1.173 +                     |$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])')
   1.174 +          test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]],
   1.175 +        [AC_MSG_RESULT([no])
   1.176 +         AC_MSG_ERROR([could not find GNU make >= 3.80])])])
   1.177 +AC_SUBST([MAKE], [$ac_cv_path_MAKE])
   1.178 +AC_PROG_MAKE_SET
   1.179 +
   1.180 +#----------------------------------------
   1.181 +# Check for libtool >= 1.5.26
   1.182 +AC_CACHE_VAL([ac_cv_path_LIBTOOL],
   1.183 +    [AC_ARG_WITH([libtool],
   1.184 +        AS_HELP_STRING([--with-libtool=PATH],
   1.185 +                       [Specify the full PATH to GNU libtool >= 1.5.26]),
   1.186 +        [ac_cv_path_LIBTOOL=$withval])])
   1.187 +AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL],
   1.188 +    [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool],
   1.189 +        [[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \
   1.190 +                        |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   1.191 +          test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]],
   1.192 +        [AC_MSG_RESULT([no])
   1.193 +         AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])])
   1.194 +AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL])
   1.195 +
   1.196 +#----------------------------------------
   1.197 +# Check for libtoolize >= 1.5.26
   1.198 +AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE],
   1.199 +    [AC_ARG_WITH([libtoolize],
   1.200 +        AS_HELP_STRING([--with-libtoolize=PATH],
   1.201 +                       [Specify the full PATH to GNU libtoolize >= 1.5.26]),
   1.202 +        [ac_cv_path_LIBTOOLIZE=$withval])])
   1.203 +AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE],
   1.204 +    [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtool],
   1.205 +        [[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \
   1.206 +                        |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   1.207 +          test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]],
   1.208 +        [AC_MSG_RESULT([no])
   1.209 +         AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])])
   1.210 +AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE])
   1.211 +
   1.212 +#----------------------------------------
   1.213 +# Check for automake >= 1.10
   1.214 +AC_CACHE_VAL([ac_cv_path_automake],
   1.215 +    [AC_ARG_WITH([automake],
   1.216 +        AS_HELP_STRING([--with-automake=PATH],
   1.217 +                       [Specify the full PATH to GNU automake >= 1.10]),
   1.218 +        [ac_cv_path_automake=$withval])])
   1.219 +AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
   1.220 +    [AC_PATH_PROGS_FEATURE_CHECK([automake], [automake],
   1.221 +        [[automake_ver=$($ac_path_automake --version 2>&1 \
   1.222 +                         |$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)')
   1.223 +          test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]],
   1.224 +        [AC_MSG_RESULT([no])
   1.225 +         AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
   1.226 +AC_SUBST([automake], [$ac_cv_path_automake])
   1.227 +
   1.228 +#--------------------------------------------------------------------
   1.229 +# Boring again... But still a bit of work to do...
   1.230 +#--------------------------------------------------------------------
   1.231 +AC_SUBST([kconfig_options])
   1.232 +
   1.233 +#----------------------------------------
   1.234 +AC_CHECK_PROGS([xz],   [xz])
   1.235 +ACX_SET_KCONFIG_OPTION([xz])
   1.236 +AS_IF(
   1.237 +    [test -z "$xz"],
   1.238 +    [AC_CHECK_PROGS([lzma], [lzma])])
   1.239 +ACX_SET_KCONFIG_OPTION([lzma])
   1.240 +
   1.241 +#----------------------------------------
   1.242 +AC_CHECK_PROGS([cvs], [cvs])
   1.243 +ACX_SET_KCONFIG_OPTION([cvs])
   1.244 +
   1.245 +#----------------------------------------
   1.246 +AC_CHECK_PROGS([svn], [svn])
   1.247 +ACX_SET_KCONFIG_OPTION([svn])
   1.248 +
   1.249 +#--------------------------------------------------------------------
   1.250 +# Now, for some fun...
   1.251 +#--------------------------------------------------------------------
   1.252 +AC_C_INLINE
   1.253 +AC_HEADER_STDC
   1.254 +AC_FUNC_MALLOC
   1.255 +AC_FUNC_REALLOC
   1.256 +AC_FUNC_ALLOCA
   1.257 +AC_CHECK_HEADERS(
   1.258 +    [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
   1.259 +    [ac_ct_curses_hdr_found=yes; break])
   1.260 +AS_IF(
   1.261 +    [test -z "$ac_ct_curses_hdr_found"],
   1.262 +    [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
   1.263 +AC_SEARCH_LIBS(
   1.264 +    [initscr],
   1.265 +    [ncursesw ncurses curses],
   1.266 +    [ac_ct_curses_lib_found=yes; break])
   1.267 +AS_IF(
   1.268 +    [test -z "$ac_ct_curses_lib_found"],
   1.269 +    [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
   1.270 +
   1.271 +#--------------------------------------------------------------------
   1.272 +# Lastly, take care of crosstool-NG internal values
   1.273 +#--------------------------------------------------------------------
   1.274 +# Hey! We need the date! :-)
   1.275 +AC_SUBST(
   1.276 +    [DATE],
   1.277 +    [$(date +%Y%m%d)])
   1.278 +
   1.279 +# Decorate the version string if needed
   1.280 +AS_IF(
   1.281 +    [test -f version.sh -a -x version.sh],
   1.282 +    [V=$(./version.sh "${PACKAGE_VERSION}")])
   1.283 +AS_IF(
   1.284 +    [test -n "${V}"],
   1.285 +    [PACKAGE_VERSION="${V}"],
   1.286 +    [AS_CASE(
   1.287 +        [${PACKAGE_VERSION}],
   1.288 +        [hg|*+hg],
   1.289 +        [rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
   1.290 +                           2>/dev/null                               \
   1.291 +                    || true                                          )"
   1.292 +         PACKAGE_VERSION="${PACKAGE_VERSION}@${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
   1.293 +        ])])
   1.294 +# Arrange to have no / in the directory name, no need to create an
   1.295 +# arbitrarily deep directory structure
   1.296 +[PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
   1.297 +
   1.298 +# Handle the local case
   1.299 +AC_SUBST([sublibdir])
   1.300 +AC_SUBST([subdocdir])
   1.301 +AS_IF(
   1.302 +    [test "x$enable_local" = "xyes"],
   1.303 +    [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
   1.304 +     prefix=$(pwd)
   1.305 +     exec_prefix="$prefix"
   1.306 +     bindir="$prefix"
   1.307 +     libdir="$prefix"
   1.308 +     sublibdir=""
   1.309 +     docdir="$prefix""/docs"
   1.310 +     subdocdir=""
   1.311 +     datarootdir="$prefix"
   1.312 +     mandir="$docdir"],
   1.313 +    [sublibdir="/ct-ng.\${VERSION}"
   1.314 +     subdocdir="/ct-ng.\${VERSION}"])
   1.315 +
   1.316 +#--------------------------------------------------------------------
   1.317 +# Finally, generate the output file(s)
   1.318 +#--------------------------------------------------------------------
   1.319 +AC_CONFIG_FILES([Makefile])
   1.320 +AC_OUTPUT
   1.321 +
   1.322 +
   1.323 +
   1.324 +# AC_CONFIG_SRCDIR([kconfig/menu.c])
   1.325 +# AC_CONFIG_HEADERS([config.h])
   1.326 +# 
   1.327 +# # Checks for programs.
   1.328 +# 
   1.329 +# # Checks for libraries.
   1.330 +# 
   1.331 +# # Checks for header files.
   1.332 +# AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h stddef.h stdlib.h string.h sys/time.h unistd.h])
   1.333 +# 
   1.334 +# # Checks for typedefs, structures, and compiler characteristics.
   1.335 +# AC_HEADER_STDBOOL
   1.336 +# AC_TYPE_INT16_T
   1.337 +# AC_TYPE_INT32_T
   1.338 +# AC_TYPE_INT8_T
   1.339 +# AC_TYPE_SIZE_T
   1.340 +# AC_TYPE_UINT16_T
   1.341 +# AC_TYPE_UINT32_T
   1.342 +# AC_TYPE_UINT8_T
   1.343 +# 
   1.344 +# # Checks for library functions.
   1.345 +# AC_FUNC_MALLOC
   1.346 +# AC_FUNC_REALLOC
   1.347 +# AC_CHECK_FUNCS([bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname])
   1.348 +# 
   1.349 +# AC_OUTPUT