configure.ac
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Sat Jul 14 18:25:47 2012 +0200 (2012-07-14)
changeset 2999 4ccfca658d9b
parent 2966 dc2943c98775
child 3000 2d362c2a8ed3
permissions -rw-r--r--
configure: check for GNU awk, not any awk

Building glibc requires GNU awk, not any other.

Reported-by: Han Sooloo <hansooloo@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     1 #                                               -*- Autoconf -*-
     2 # Process this file with autoconf to produce a configure script.
     3 
     4 AC_PREREQ([2.67])
     5 #AC_INIT([crosstool-NG], [hg], [crossgcc@sourceware.org])
     6 AC_INIT([crosstool-NG], [m4_esyscmd_s([cat .version])], [crossgcc@sourceware.org])
     7 AC_CONFIG_AUX_DIR([scripts])
     8 
     9 #--------------------------------------------------------------------
    10 # A few helper macros
    11 
    12 # Check for required tool
    13 AC_DEFUN(
    14     [ACX_CHECK_TOOL_REQ],
    15     [AC_CHECK_TOOLS([$1], [$2])
    16      AS_IF(
    17         [test -z "$$1"],
    18         [AC_MSG_ERROR([missing required tool: $2])])
    19     ])
    20 
    21 # Check for required tool, set variable to full pathname
    22 AC_DEFUN(
    23     [ACX_PATH_TOOL_REQ],
    24     [ACX_CHECK_TOOL_REQ([$1], [$2])
    25      AS_CASE(
    26         [$$1],
    27         [/*],,
    28         [?*],[AC_MSG_CHECKING([for absolute path to $$1])
    29               $1=$(which $$1)
    30               AC_MSG_RESULT([$$1])])])
    31 
    32 # Check for required program
    33 AC_DEFUN(
    34     [ACX_CHECK_PROGS_REQ],
    35     [AC_CHECK_PROGS([$1], [$2])
    36      AS_IF(
    37         [test -z "$$1"],
    38         [AC_MSG_ERROR([missing required tool: $2])])
    39     ])
    40 
    41 # Check for path to required program
    42 AC_DEFUN(
    43     [ACX_PATH_PROGS_REQ],
    44     [AC_PATH_PROGS([$1], [$2])
    45      AS_IF(
    46         [test -z "$$1"],
    47         [AC_MSG_ERROR([missing required tool: $2])])
    48     ])
    49 
    50 # Set the kconfig option
    51 AC_DEFUN(
    52     [ACX_SET_KCONFIG_OPTION],
    53     [AS_IF(
    54         [test -n "$$1"],
    55         [kconfig_options="$kconfig_options has_$1=y"],
    56         [kconfig_options="$kconfig_options has_$1"])
    57     ])
    58 
    59 #--------------------------------------------------------------------
    60 # Allow dummy --{en,dis}able-{static,shared}
    61 AC_ARG_ENABLE(
    62     [local],
    63     [AS_HELP_STRING(
    64         [--enable-local],
    65         [don't install, and use current directory])])
    66 AC_SUBST([enable_local], [${enable_local:-no}])
    67 AC_ARG_ENABLE(
    68     [shared],
    69     [AS_HELP_STRING(
    70         [--enable-shared],
    71         [build shared libraries (default=yes) (ignored)])])
    72 AC_ARG_ENABLE(
    73     [static],
    74     [AS_HELP_STRING(
    75         [--enable-static],
    76         [build static libraries (default=yes) (ignored)])])
    77 
    78 #---------------------------------------------------------------------
    79 # Check for --build and --host...
    80 AC_CANONICAL_BUILD
    81 AC_CANONICAL_HOST
    82 # ... but refuse --target
    83 AS_IF([test -n "$target_alias"],
    84       AC_MSG_ERROR([--target is not allowed]))
    85 
    86 # Allow program name tranformation (--program-{prefix,suffix,transform-name})
    87 AC_ARG_PROGRAM
    88 
    89 #---------------------------------------------------------------------
    90 # Initial checks that are usually done first (I don't know why, that's
    91 # just what I seem to experience...)
    92 #---------------------------------------------------------------------
    93 AC_PROG_INSTALL
    94 AC_PROG_GREP
    95 AC_PROG_EGREP
    96 AS_IF(
    97     [test ! "$EGREP" = "$GREP -E"],
    98     [AC_MSG_ERROR([egrep is not $GREP -E])])
    99 AC_CACHE_VAL([ac_cv_path_SED],
   100     [AC_ARG_WITH([sed],
   101         AS_HELP_STRING([--with-sed=PATH],
   102                        [Specify the full PATH to GNU sed]),
   103         [ac_cv_path_SED=$withval])])
   104 AC_PROG_SED
   105 AC_MSG_CHECKING([whether sed understands -r -i -e])
   106 touch .ct-ng.sed.test
   107 if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
   108     rm -f .ct-ng.sed.test
   109     AC_MSG_RESULT([yes])
   110 else
   111     rm -f .ct-ng.sed.test
   112     AC_MSG_RESULT([no])
   113     AC_MSG_ERROR()
   114 fi
   115 AC_PROG_LN_S
   116 
   117 #--------------------------------------------------------------------
   118 # A bunch of boring tests...
   119 #--------------------------------------------------------------------
   120 AC_PROG_CC
   121 AS_IF([test -z "$CC"],
   122       [AC_MSG_ERROR([no suitable compiler found])])
   123 AC_PROG_CPP
   124 AC_PROG_RANLIB
   125 ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy])
   126 ACX_PATH_TOOL_REQ([OBJDUMP], [objdump])
   127 ACX_PATH_TOOL_REQ([READELF], [readelf])
   128 
   129 ACX_CHECK_PROGS_REQ([bison], [bison])
   130 ACX_CHECK_PROGS_REQ([flex], [flex])
   131 ACX_CHECK_PROGS_REQ([gperf], [gperf])
   132 ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
   133 ACX_CHECK_PROGS_REQ([cut], [cut])
   134 ACX_CHECK_PROGS_REQ([stat], [stat])
   135 ACX_CHECK_PROGS_REQ([readlink], [readlink])
   136 ACX_CHECK_PROGS_REQ([wget], [wget])
   137 ACX_CHECK_PROGS_REQ([tar], [tar])
   138 ACX_CHECK_PROGS_REQ([gzip], [gzip])
   139 ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
   140 
   141 #--------------------------------------------------------------------
   142 # Still boring, but remember the path, now...
   143 #--------------------------------------------------------------------
   144 ACX_PATH_PROGS_REQ([PATCH], [patch])
   145 
   146 #--------------------------------------------------------------------
   147 # And a bunch of less boring tests...
   148 #--------------------------------------------------------------------
   149 # We need a bash that is >= 3.1
   150 AC_CACHE_VAL([ac_cv_path__BASH],
   151     [AC_ARG_WITH([bash],
   152         AS_HELP_STRING([--with-bash=PATH],
   153                        [Specify the full PATH to GNU bash >= 3.1]),
   154         [ac_cv_path__BASH=$withval])])
   155 AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
   156     [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
   157         [[_BASH_ver=$($ac_path__BASH --version 2>&1 \
   158                      |$EGREP '^GNU bash, version (3\.[1-9]|4)')
   159           test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
   160         [AC_MSG_RESULT([no])
   161          AC_MSG_ERROR([could not find bash >= 3.1])])])
   162 AC_SUBST([_BASH], [$ac_cv_path__BASH])
   163 
   164 # We need a awk that *is* GNU awk
   165 AC_CACHE_VAL([ac_cv_path__AWK],
   166     [AC_ARG_WITH([awk],
   167         AS_HELP_STRING([--with-awk=PATH],
   168                        [Specify the full PATH to GNU awk]),
   169         [ac_cv_path__AWK=$withval])])
   170 AC_CACHE_CHECK([for GNU awk], [ac_cv_path__AWK],
   171     [AC_PATH_PROGS_FEATURE_CHECK([_AWK], [awk gawk],
   172         [[_AWK_ver=$($ac_path__AWK --version 2>&1 \
   173                      |$EGREP '^GNU Awk ')
   174           test -n "$_AWK_ver" && ac_cv_path__AWK=$ac_path__AWK ac_path__AWK_found=:]],
   175         [AC_MSG_RESULT([no])
   176          AC_MSG_ERROR([could not find GNU awk])])])
   177 AC_SUBST([_AWK], [$ac_cv_path__AWK])
   178 
   179 #----------------------------------------
   180 # Check for GNU make 3.80 or above
   181 AC_CACHE_VAL([ac_cv_path_MAKE],
   182     [AC_ARG_WITH([make],
   183         AS_HELP_STRING([--with-make=PATH],
   184                        [Specify the full PATH to GNU make >= 3.80]),
   185         [ac_cv_path_MAKE=$withval])])
   186 AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE],
   187     [AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake],
   188         [[MAKE_ver=$($ac_path_MAKE --version 2>&1 \
   189                      |$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])')
   190           test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]],
   191         [AC_MSG_RESULT([no])
   192          AC_MSG_ERROR([could not find GNU make >= 3.80])])])
   193 AC_SUBST([MAKE], [$ac_cv_path_MAKE])
   194 AC_PROG_MAKE_SET
   195 
   196 #----------------------------------------
   197 # Check for libtool >= 1.5.26
   198 AC_CACHE_VAL([ac_cv_path_LIBTOOL],
   199     [AC_ARG_WITH([libtool],
   200         AS_HELP_STRING([--with-libtool=PATH],
   201                        [Specify the full PATH to GNU libtool >= 1.5.26]),
   202         [ac_cv_path_LIBTOOL=$withval])])
   203 AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL],
   204     [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool],
   205         [[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \
   206                         |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   207           test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]],
   208         [AC_MSG_RESULT([no])
   209          AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])])
   210 AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL])
   211 
   212 #----------------------------------------
   213 # Check for libtoolize >= 1.5.26
   214 AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE],
   215     [AC_ARG_WITH([libtoolize],
   216         AS_HELP_STRING([--with-libtoolize=PATH],
   217                        [Specify the full PATH to GNU libtoolize >= 1.5.26]),
   218         [ac_cv_path_LIBTOOLIZE=$withval])])
   219 AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE],
   220     [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtoolize],
   221         [[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \
   222                         |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   223           test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]],
   224         [AC_MSG_RESULT([no])
   225          AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])])
   226 AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE])
   227 
   228 #----------------------------------------
   229 # Check for automake >= 1.10
   230 AC_CACHE_VAL([ac_cv_path_automake],
   231     [AC_ARG_WITH([automake],
   232         AS_HELP_STRING([--with-automake=PATH],
   233                        [Specify the full PATH to GNU automake >= 1.10]),
   234         [ac_cv_path_automake=$withval])])
   235 AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
   236     [AC_PATH_PROGS_FEATURE_CHECK([automake], [automake],
   237         [[automake_ver=$($ac_path_automake --version 2>&1 \
   238                          |$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)')
   239           test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]],
   240         [AC_MSG_RESULT([no])
   241          AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
   242 AC_SUBST([automake], [$ac_cv_path_automake])
   243 
   244 #--------------------------------------------------------------------
   245 # Boring again... But still a bit of work to do...
   246 #--------------------------------------------------------------------
   247 AC_SUBST([kconfig_options])
   248 
   249 #----------------------------------------
   250 AC_CHECK_PROGS([xz],   [xz])
   251 ACX_SET_KCONFIG_OPTION([xz])
   252 AS_IF(
   253     [test -z "$xz"],
   254     [AC_CHECK_PROGS([lzma], [lzma])])
   255 ACX_SET_KCONFIG_OPTION([lzma])
   256 
   257 #----------------------------------------
   258 AC_CHECK_PROGS([cvs], [cvs])
   259 ACX_SET_KCONFIG_OPTION([cvs])
   260 
   261 #----------------------------------------
   262 AC_CHECK_PROGS([svn], [svn])
   263 ACX_SET_KCONFIG_OPTION([svn])
   264 
   265 #--------------------------------------------------------------------
   266 # Now, for some fun...
   267 #--------------------------------------------------------------------
   268 AC_C_INLINE
   269 AC_HEADER_STDC
   270 AC_FUNC_MALLOC
   271 AC_FUNC_REALLOC
   272 AC_FUNC_ALLOCA
   273 
   274 #----------------------------------------
   275 # Check for gettext, for the kconfig frontends
   276 AC_SUBST([gettext])
   277 AC_CHECK_HEADERS(
   278     [libintl.h],
   279     [ac_ct_gettext_hdr=$ac_header; break])
   280 AS_IF(
   281     [test -n "$ac_ct_gettext_hdr"],
   282     [AC_CHECK_DECL(
   283         [gettext],
   284         [gettext=y],,
   285         [AC_INCLUDES_DEFAULT()
   286          #include <$ac_ct_gettext_hdr>])])
   287 
   288 #----------------------------------------
   289 # Check for ncurses, for the kconfig frontends
   290 AC_SUBST([ac_ct_curses_hdr])
   291 AC_CHECK_HEADERS(
   292     [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
   293     [ac_ct_curses_hdr=$ac_header; break])
   294 AS_IF(
   295     [test -z "$ac_ct_curses_hdr"],
   296     [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
   297 AC_SEARCH_LIBS(
   298     [initscr],
   299     [ncursesw ncurses curses],
   300     [ac_ct_curses_lib_found=yes; break])
   301 AS_IF(
   302     [test -z "$ac_ct_curses_lib_found"],
   303     [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
   304 
   305 #--------------------------------------------------------------------
   306 # Lastly, take care of crosstool-NG internal values
   307 #--------------------------------------------------------------------
   308 # Hey! We need the date! :-)
   309 AC_SUBST(
   310     [DATE],
   311     [$(date +%Y%m%d)])
   312 
   313 # Decorate the version string if needed
   314 AS_IF(
   315     [test -f version.sh -a -x version.sh],
   316     [V=$(./version.sh "${PACKAGE_VERSION}")])
   317 AS_IF(
   318     [test -n "${V}"],
   319     [PACKAGE_VERSION="${V}"],
   320     [AS_CASE(
   321         [${PACKAGE_VERSION}],
   322         [hg|*+hg],
   323         [rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
   324                            2>/dev/null                               \
   325                     || true                                          )"
   326          PACKAGE_VERSION="${PACKAGE_VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
   327         ])])
   328 # Arrange to have no / in the directory name, no need to create an
   329 # arbitrarily deep directory structure
   330 [PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
   331 
   332 # Handle the local case
   333 AC_SUBST([sublibdir])
   334 AC_SUBST([subdocdir])
   335 AS_IF(
   336     [test "x$enable_local" = "xyes"],
   337     [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
   338      prefix=$(pwd)
   339      exec_prefix="$prefix"
   340      bindir="$prefix"
   341      libdir="$prefix"
   342      sublibdir=""
   343      docdir="$prefix""/docs"
   344      subdocdir=""
   345      datarootdir="$prefix"
   346      mandir="$docdir"],
   347     [sublibdir="/ct-ng.\${VERSION}"
   348      subdocdir="/ct-ng.\${VERSION}"])
   349 
   350 #--------------------------------------------------------------------
   351 # Finally, generate the output file(s)
   352 #--------------------------------------------------------------------
   353 AC_CONFIG_FILES([Makefile])
   354 AC_OUTPUT
   355 
   356 
   357 
   358 # AC_CONFIG_SRCDIR([kconfig/menu.c])
   359 # AC_CONFIG_HEADERS([config.h])
   360 # 
   361 # # Checks for programs.
   362 # 
   363 # # Checks for libraries.
   364 # 
   365 # # Checks for header files.
   366 # 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])
   367 # 
   368 # # Checks for typedefs, structures, and compiler characteristics.
   369 # AC_HEADER_STDBOOL
   370 # AC_TYPE_INT16_T
   371 # AC_TYPE_INT32_T
   372 # AC_TYPE_INT8_T
   373 # AC_TYPE_SIZE_T
   374 # AC_TYPE_UINT16_T
   375 # AC_TYPE_UINT32_T
   376 # AC_TYPE_UINT8_T
   377 # 
   378 # # Checks for library functions.
   379 # AC_FUNC_MALLOC
   380 # AC_FUNC_REALLOC
   381 # AC_CHECK_FUNCS([bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname])
   382 # 
   383 # AC_OUTPUT