yann@2834: # -*- Autoconf -*- yann@2834: # Process this file with autoconf to produce a configure script. yann@2834: yann@2834: AC_PREREQ([2.67]) yann@2834: #AC_INIT([crosstool-NG], [hg], [crossgcc@sourceware.org]) yann@2834: AC_INIT([crosstool-NG], [m4_esyscmd_s([cat .version])], [crossgcc@sourceware.org]) yann@2834: AC_CONFIG_AUX_DIR([scripts]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # A few helper macros yann@2834: yann@2834: # Check for required tool yann@2834: AC_DEFUN( yann@2834: [ACX_CHECK_TOOL_REQ], yann@2834: [AC_CHECK_TOOLS([$1], [$2]) yann@2834: AS_IF( yann@2834: [test -z "$$1"], yann@2834: [AC_MSG_ERROR([missing required tool: $2])]) yann@2834: ]) yann@2834: yann@2834: # Check for required tool, set variable to full pathname yann@2834: AC_DEFUN( yann@2834: [ACX_PATH_TOOL_REQ], yann@2834: [ACX_CHECK_TOOL_REQ([$1], [$2]) yann@2834: AS_CASE( yann@2834: [$$1], yann@2834: [/*],, yann@2834: [?*],[AC_MSG_CHECKING([for absolute path to $$1]) yann@2834: $1=$(which $$1) yann@2834: AC_MSG_RESULT([$$1])])]) yann@2834: yann@2834: # Check for required program yann@2834: AC_DEFUN( yann@2834: [ACX_CHECK_PROGS_REQ], yann@2834: [AC_CHECK_PROGS([$1], [$2]) yann@2834: AS_IF( yann@2834: [test -z "$$1"], yann@2834: [AC_MSG_ERROR([missing required tool: $2])]) yann@2834: ]) yann@2834: yann@2834: # Check for path to required program yann@2834: AC_DEFUN( yann@2834: [ACX_PATH_PROGS_REQ], yann@2834: [AC_PATH_PROGS([$1], [$2]) yann@2834: AS_IF( yann@2834: [test -z "$$1"], yann@2834: [AC_MSG_ERROR([missing required tool: $2])]) yann@2834: ]) yann@2834: yann@2834: # Set the kconfig option yann@2834: AC_DEFUN( yann@2834: [ACX_SET_KCONFIG_OPTION], yann@2834: [AS_IF( yann@2834: [test -n "$$1"], yann@2834: [kconfig_options="$kconfig_options $1=y"], yann@2834: [kconfig_options="$kconfig_options $1"]) yann@2834: ]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Allow dummy --{en,dis}able-{static,shared} yann@2834: AC_ARG_ENABLE( yann@2834: [local], yann@2834: [AS_HELP_STRING( yann@2834: [--enable-local], yann@2834: [don't install, and use current directory])]) yann@2834: AC_SUBST([enable_local], [${enable_local:-no}]) yann@2834: AC_ARG_ENABLE( yann@2834: [shared], yann@2834: [AS_HELP_STRING( yann@2834: [--enable-shared], yann@2834: [build shared libraries (default=yes) (ignored)])]) yann@2834: AC_ARG_ENABLE( yann@2834: [static], yann@2834: [AS_HELP_STRING( yann@2834: [--enable-static], yann@2834: [build static libraries (default=yes) (ignored)])]) yann@2834: yann@2834: #--------------------------------------------------------------------- yann@2834: # Check for --build and --host... yann@2834: AC_CANONICAL_BUILD yann@2834: AC_CANONICAL_HOST yann@2834: # ... but refuse --target yann@2834: AS_IF([test -n "$target_alias"], yann@2834: AC_MSG_ERROR([--target is not allowed])) yann@2834: yann@2834: # Allow program name tranformation (--program-{prefix,suffix,transform-name}) yann@2834: AC_ARG_PROGRAM yann@2834: yann@2834: #--------------------------------------------------------------------- yann@2834: # Initial checks that are usually done first (I don't know why, that's yann@2834: # just what I seem to experience...) yann@2834: #--------------------------------------------------------------------- yann@2834: AC_PROG_INSTALL yann@2839: AC_PROG_GREP yann@2834: AC_PROG_EGREP yann@2839: AS_IF( yann@2839: [test ! "$EGREP" = "$GREP -E"], yann@2839: [AC_MSG_ERROR([egrep is not $GREP -E])]) yann@2834: AC_CACHE_VAL([ac_cv_path_SED], yann@2834: [AC_ARG_WITH([sed], yann@2834: AS_HELP_STRING([--with-sed=PATH], yann@2834: [Specify the full PATH to sed]), yann@2834: [ac_cv_path_SED=$withval])]) yann@2834: AC_PROG_SED yann@2834: AC_MSG_CHECKING([whether sed understands -r -i -e]) yann@2834: touch .ct-ng.sed.test yann@2834: if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then yann@2834: rm -f .ct-ng.sed.test yann@2834: AC_MSG_RESULT([yes]) yann@2834: else yann@2834: rm -f .ct-ng.sed.test yann@2834: AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR() yann@2834: fi yann@2834: AC_PROG_LN_S yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # A bunch of boring tests... yann@2834: #-------------------------------------------------------------------- yann@2834: AC_PROG_CC yann@2834: AS_IF([test -z "$CC"], yann@2834: [AC_MSG_ERROR([no suitable compiler found])]) yann@2834: AC_PROG_CPP yann@2834: AC_PROG_RANLIB yann@2834: ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy]) yann@2834: ACX_PATH_TOOL_REQ([OBJDUMP], [objdump]) yann@2834: ACX_PATH_TOOL_REQ([READELF], [readelf]) yann@2834: yann@2834: ACX_CHECK_PROGS_REQ([bison], [bison]) yann@2834: ACX_CHECK_PROGS_REQ([flex], [flex]) yann@2836: ACX_CHECK_PROGS_REQ([gperf], [gperf]) yann@2834: ACX_CHECK_PROGS_REQ([awk], [gawk mawk nawk awk]) yann@2834: ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo]) yann@2834: ACX_CHECK_PROGS_REQ([cut], [cut]) yann@2834: ACX_CHECK_PROGS_REQ([stat], [stat]) yann@2834: ACX_CHECK_PROGS_REQ([readlink], [readlink]) yann@2834: ACX_CHECK_PROGS_REQ([curl], [curl]) yann@2834: ACX_CHECK_PROGS_REQ([tar], [tar]) yann@2834: ACX_CHECK_PROGS_REQ([gzip], [gzip]) yann@2834: ACX_CHECK_PROGS_REQ([bzip2], [bzip2]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Still boring, but remember the path, now... yann@2834: #-------------------------------------------------------------------- yann@2834: ACX_PATH_PROGS_REQ([PATCH], [patch]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # And a bunch of less boring tests... yann@2834: #-------------------------------------------------------------------- yann@2834: # We need a bash that is >= 3.1 yann@2834: AC_CACHE_VAL([ac_cv_path__BASH], yann@2834: [AC_ARG_WITH([bash], yann@2834: AS_HELP_STRING([--with-bash=PATH], yann@2834: [Specify the full PATH to bash >= 3.1]), yann@2834: [ac_cv_path__BASH=$withval])]) yann@2834: AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH], yann@2834: [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash], yann@2834: [[_BASH_ver=$($ac_path__BASH --version 2>&1 \ yann@2834: |$EGREP '^GNU bash, version (3\.[1-9]|4)') yann@2834: test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]], yann@2834: [AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR([could not find bash >= 3.1])])]) yann@2834: AC_SUBST([_BASH], [$ac_cv_path__BASH]) yann@2834: yann@2834: #---------------------------------------- yann@2834: # Check for GNU make 3.80 or above yann@2834: AC_CACHE_VAL([ac_cv_path_MAKE], yann@2834: [AC_ARG_WITH([make], yann@2834: AS_HELP_STRING([--with-make=PATH], yann@2834: [Specify the full PATH to GNU make >= 3.80]), yann@2834: [ac_cv_path_MAKE=$withval])]) yann@2834: AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE], yann@2834: [AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake], yann@2834: [[MAKE_ver=$($ac_path_MAKE --version 2>&1 \ yann@2834: |$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])') yann@2834: test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]], yann@2834: [AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR([could not find GNU make >= 3.80])])]) yann@2834: AC_SUBST([MAKE], [$ac_cv_path_MAKE]) yann@2834: AC_PROG_MAKE_SET yann@2834: yann@2834: #---------------------------------------- yann@2834: # Check for libtool >= 1.5.26 yann@2834: AC_CACHE_VAL([ac_cv_path_LIBTOOL], yann@2834: [AC_ARG_WITH([libtool], yann@2834: AS_HELP_STRING([--with-libtool=PATH], yann@2834: [Specify the full PATH to GNU libtool >= 1.5.26]), yann@2834: [ac_cv_path_LIBTOOL=$withval])]) yann@2834: AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL], yann@2834: [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool], yann@2834: [[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \ yann@2834: |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)') yann@2834: test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]], yann@2834: [AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])]) yann@2834: AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL]) yann@2834: yann@2834: #---------------------------------------- yann@2834: # Check for libtoolize >= 1.5.26 yann@2834: AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE], yann@2834: [AC_ARG_WITH([libtoolize], yann@2834: AS_HELP_STRING([--with-libtoolize=PATH], yann@2834: [Specify the full PATH to GNU libtoolize >= 1.5.26]), yann@2834: [ac_cv_path_LIBTOOLIZE=$withval])]) yann@2834: AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE], yann@2834: [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtool], yann@2834: [[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \ yann@2834: |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)') yann@2834: test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]], yann@2834: [AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])]) yann@2834: AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE]) yann@2834: yann@2834: #---------------------------------------- yann@2834: # Check for automake >= 1.10 yann@2834: AC_CACHE_VAL([ac_cv_path_automake], yann@2834: [AC_ARG_WITH([automake], yann@2834: AS_HELP_STRING([--with-automake=PATH], yann@2834: [Specify the full PATH to GNU automake >= 1.10]), yann@2834: [ac_cv_path_automake=$withval])]) yann@2834: AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake], yann@2834: [AC_PATH_PROGS_FEATURE_CHECK([automake], [automake], yann@2834: [[automake_ver=$($ac_path_automake --version 2>&1 \ yann@2834: |$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)') yann@2834: test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]], yann@2834: [AC_MSG_RESULT([no]) yann@2834: AC_MSG_ERROR([could not find GNU automake >= 1.10])])]) yann@2834: AC_SUBST([automake], [$ac_cv_path_automake]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Boring again... But still a bit of work to do... yann@2834: #-------------------------------------------------------------------- yann@2834: AC_SUBST([kconfig_options]) yann@2834: yann@2834: #---------------------------------------- yann@2834: AC_CHECK_PROGS([xz], [xz]) yann@2834: ACX_SET_KCONFIG_OPTION([xz]) yann@2834: AS_IF( yann@2834: [test -z "$xz"], yann@2834: [AC_CHECK_PROGS([lzma], [lzma])]) yann@2834: ACX_SET_KCONFIG_OPTION([lzma]) yann@2834: yann@2834: #---------------------------------------- yann@2834: AC_CHECK_PROGS([cvs], [cvs]) yann@2834: ACX_SET_KCONFIG_OPTION([cvs]) yann@2834: yann@2834: #---------------------------------------- yann@2834: AC_CHECK_PROGS([svn], [svn]) yann@2834: ACX_SET_KCONFIG_OPTION([svn]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Now, for some fun... yann@2834: #-------------------------------------------------------------------- yann@2834: AC_C_INLINE yann@2834: AC_HEADER_STDC yann@2834: AC_FUNC_MALLOC yann@2834: AC_FUNC_REALLOC yann@2834: AC_FUNC_ALLOCA yann@2835: yann@2835: #---------------------------------------- yann@2835: # Check for gettext, for the kconfig frontends yann@2835: AC_SUBST([gettext]) yann@2835: AC_CHECK_HEADERS( yann@2835: [libintl.h], yann@2835: [ac_ct_gettext_hdr=$ac_header; break]) yann@2835: AS_IF( yann@2835: [test -n "$ac_ct_gettext_hdr"], yann@2835: [AC_CHECK_DECL( yann@2835: [gettext],gettext=y,, yann@2835: [#include <$ac_ct_gettext_hdr>])]) yann@2835: yann@2835: #---------------------------------------- yann@2835: # Check for ncurses, for the kconfig frontends yann@2835: AC_SUBST([ac_ct_curses_hdr]) yann@2834: AC_CHECK_HEADERS( yann@2834: [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h], yann@2835: [ac_ct_curses_hdr=$ac_header; break]) yann@2834: AS_IF( yann@2835: [test -z "$ac_ct_curses_hdr"], yann@2834: [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])]) yann@2834: AC_SEARCH_LIBS( yann@2834: [initscr], yann@2834: [ncursesw ncurses curses], yann@2834: [ac_ct_curses_lib_found=yes; break]) yann@2834: AS_IF( yann@2834: [test -z "$ac_ct_curses_lib_found"], yann@2834: [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Lastly, take care of crosstool-NG internal values yann@2834: #-------------------------------------------------------------------- yann@2834: # Hey! We need the date! :-) yann@2834: AC_SUBST( yann@2834: [DATE], yann@2834: [$(date +%Y%m%d)]) yann@2834: yann@2834: # Decorate the version string if needed yann@2834: AS_IF( yann@2834: [test -f version.sh -a -x version.sh], yann@2834: [V=$(./version.sh "${PACKAGE_VERSION}")]) yann@2834: AS_IF( yann@2834: [test -n "${V}"], yann@2834: [PACKAGE_VERSION="${V}"], yann@2834: [AS_CASE( yann@2834: [${PACKAGE_VERSION}], yann@2834: [hg|*+hg], yann@2834: [rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \ yann@2834: 2>/dev/null \ yann@2834: || true )" yann@2834: PACKAGE_VERSION="${PACKAGE_VERSION}@${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}" yann@2834: ])]) yann@2834: # Arrange to have no / in the directory name, no need to create an yann@2834: # arbitrarily deep directory structure yann@2834: [PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"] yann@2834: yann@2834: # Handle the local case yann@2834: AC_SUBST([sublibdir]) yann@2834: AC_SUBST([subdocdir]) yann@2834: AS_IF( yann@2834: [test "x$enable_local" = "xyes"], yann@2834: [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set]) yann@2834: prefix=$(pwd) yann@2834: exec_prefix="$prefix" yann@2834: bindir="$prefix" yann@2834: libdir="$prefix" yann@2834: sublibdir="" yann@2834: docdir="$prefix""/docs" yann@2834: subdocdir="" yann@2834: datarootdir="$prefix" yann@2834: mandir="$docdir"], yann@2834: [sublibdir="/ct-ng.\${VERSION}" yann@2834: subdocdir="/ct-ng.\${VERSION}"]) yann@2834: yann@2834: #-------------------------------------------------------------------- yann@2834: # Finally, generate the output file(s) yann@2834: #-------------------------------------------------------------------- yann@2834: AC_CONFIG_FILES([Makefile]) yann@2834: AC_OUTPUT yann@2834: yann@2834: yann@2834: yann@2834: # AC_CONFIG_SRCDIR([kconfig/menu.c]) yann@2834: # AC_CONFIG_HEADERS([config.h]) yann@2834: # yann@2834: # # Checks for programs. yann@2834: # yann@2834: # # Checks for libraries. yann@2834: # yann@2834: # # Checks for header files. yann@2834: # 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]) yann@2834: # yann@2834: # # Checks for typedefs, structures, and compiler characteristics. yann@2834: # AC_HEADER_STDBOOL yann@2834: # AC_TYPE_INT16_T yann@2834: # AC_TYPE_INT32_T yann@2834: # AC_TYPE_INT8_T yann@2834: # AC_TYPE_SIZE_T yann@2834: # AC_TYPE_UINT16_T yann@2834: # AC_TYPE_UINT32_T yann@2834: # AC_TYPE_UINT8_T yann@2834: # yann@2834: # # Checks for library functions. yann@2834: # AC_FUNC_MALLOC yann@2834: # AC_FUNC_REALLOC yann@2834: # AC_CHECK_FUNCS([bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname]) yann@2834: # yann@2834: # AC_OUTPUT