configure.ac
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Tue Jul 17 22:21:28 2012 +0200 (2012-07-17)
changeset 3001 0dfc9c1fcb34
parent 3000 2d362c2a8ed3
child 3067 3bc371c2881f
permissions -rw-r--r--
configure: also check for install

We also need the GNU variant for this one.

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_ARG_WITH([install],
    94     AS_HELP_STRING([--with-install=PATH],
    95                    [Specify the full PATH to a BSD-compatible install]),
    96     [INSTALL=$withval])
    97 AC_PROG_INSTALL
    98 AC_PROG_GREP
    99 AC_PROG_EGREP
   100 AS_IF(
   101     [test ! "$EGREP" = "$GREP -E"],
   102     [AC_MSG_ERROR([egrep is not $GREP -E])])
   103 AC_CACHE_VAL([ac_cv_path_SED],
   104     [AC_ARG_WITH([sed],
   105         AS_HELP_STRING([--with-sed=PATH],
   106                        [Specify the full PATH to GNU sed]),
   107         [ac_cv_path_SED=$withval])])
   108 AC_PROG_SED
   109 AC_MSG_CHECKING([whether sed understands -r -i -e])
   110 touch .ct-ng.sed.test
   111 if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
   112     rm -f .ct-ng.sed.test
   113     AC_MSG_RESULT([yes])
   114 else
   115     rm -f .ct-ng.sed.test
   116     AC_MSG_RESULT([no])
   117     AC_MSG_ERROR()
   118 fi
   119 AC_PROG_LN_S
   120 
   121 #--------------------------------------------------------------------
   122 # A bunch of boring tests...
   123 #--------------------------------------------------------------------
   124 AC_PROG_CC
   125 AS_IF([test -z "$CC"],
   126       [AC_MSG_ERROR([no suitable compiler found])])
   127 AC_PROG_CPP
   128 
   129 # But we still need a way to specify the PATH to GNU versions (Damn MacOS)
   130 AC_ARG_WITH([objcopy],
   131     AS_HELP_STRING([--with-objcopy=PATH],
   132                    [Specify the full PATH to GNU objcopy]),
   133     [OBJCOPY=$withval])
   134 AC_ARG_WITH([objdump],
   135     AS_HELP_STRING([--with-objdump=PATH],
   136                    [Specify the full PATH to GNU objdump]),
   137     [OBJDUMP=$withval])
   138 AC_ARG_WITH([ranlib],
   139     AS_HELP_STRING([--with-ranlib=PATH],
   140                    [Specify the full PATH to GNU ranlib]),
   141     [RANLIB=$withval])
   142 AC_ARG_WITH([readelf],
   143     AS_HELP_STRING([--with-readelf=PATH],
   144                    [Specify the full PATH to GNU readelf]),
   145     [READELF=$withval])
   146 
   147 AC_PROG_RANLIB
   148 ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy])
   149 ACX_PATH_TOOL_REQ([OBJDUMP], [objdump])
   150 ACX_PATH_TOOL_REQ([READELF], [readelf])
   151 
   152 ACX_CHECK_PROGS_REQ([bison], [bison])
   153 ACX_CHECK_PROGS_REQ([flex], [flex])
   154 ACX_CHECK_PROGS_REQ([gperf], [gperf])
   155 ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
   156 ACX_CHECK_PROGS_REQ([cut], [cut])
   157 ACX_CHECK_PROGS_REQ([stat], [stat])
   158 ACX_CHECK_PROGS_REQ([readlink], [readlink])
   159 ACX_CHECK_PROGS_REQ([wget], [wget])
   160 ACX_CHECK_PROGS_REQ([tar], [tar])
   161 ACX_CHECK_PROGS_REQ([gzip], [gzip])
   162 ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
   163 
   164 #--------------------------------------------------------------------
   165 # Still boring, but remember the path, now...
   166 #--------------------------------------------------------------------
   167 ACX_PATH_PROGS_REQ([PATCH], [patch])
   168 
   169 #--------------------------------------------------------------------
   170 # And a bunch of less boring tests...
   171 #--------------------------------------------------------------------
   172 # We need a bash that is >= 3.1
   173 AC_CACHE_VAL([ac_cv_path__BASH],
   174     [AC_ARG_WITH([bash],
   175         AS_HELP_STRING([--with-bash=PATH],
   176                        [Specify the full PATH to GNU bash >= 3.1]),
   177         [ac_cv_path__BASH=$withval])])
   178 AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
   179     [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
   180         [[_BASH_ver=$($ac_path__BASH --version 2>&1 \
   181                      |$EGREP '^GNU bash, version (3\.[1-9]|4)')
   182           test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
   183         [AC_MSG_RESULT([no])
   184          AC_MSG_ERROR([could not find bash >= 3.1])])])
   185 AC_SUBST([_BASH], [$ac_cv_path__BASH])
   186 
   187 # We need a awk that *is* GNU awk
   188 AC_CACHE_VAL([ac_cv_path__AWK],
   189     [AC_ARG_WITH([awk],
   190         AS_HELP_STRING([--with-awk=PATH],
   191                        [Specify the full PATH to GNU awk]),
   192         [ac_cv_path__AWK=$withval])])
   193 AC_CACHE_CHECK([for GNU awk], [ac_cv_path__AWK],
   194     [AC_PATH_PROGS_FEATURE_CHECK([_AWK], [awk gawk],
   195         [[_AWK_ver=$($ac_path__AWK --version 2>&1 \
   196                      |$EGREP '^GNU Awk ')
   197           test -n "$_AWK_ver" && ac_cv_path__AWK=$ac_path__AWK ac_path__AWK_found=:]],
   198         [AC_MSG_RESULT([no])
   199          AC_MSG_ERROR([could not find GNU awk])])])
   200 AC_SUBST([_AWK], [$ac_cv_path__AWK])
   201 
   202 #----------------------------------------
   203 # Check for GNU make 3.80 or above
   204 AC_CACHE_VAL([ac_cv_path_MAKE],
   205     [AC_ARG_WITH([make],
   206         AS_HELP_STRING([--with-make=PATH],
   207                        [Specify the full PATH to GNU make >= 3.80]),
   208         [ac_cv_path_MAKE=$withval])])
   209 AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE],
   210     [AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake],
   211         [[MAKE_ver=$($ac_path_MAKE --version 2>&1 \
   212                      |$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])')
   213           test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]],
   214         [AC_MSG_RESULT([no])
   215          AC_MSG_ERROR([could not find GNU make >= 3.80])])])
   216 AC_SUBST([MAKE], [$ac_cv_path_MAKE])
   217 AC_PROG_MAKE_SET
   218 
   219 #----------------------------------------
   220 # Check for libtool >= 1.5.26
   221 AC_CACHE_VAL([ac_cv_path_LIBTOOL],
   222     [AC_ARG_WITH([libtool],
   223         AS_HELP_STRING([--with-libtool=PATH],
   224                        [Specify the full PATH to GNU libtool >= 1.5.26]),
   225         [ac_cv_path_LIBTOOL=$withval])])
   226 AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL],
   227     [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool],
   228         [[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \
   229                         |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   230           test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]],
   231         [AC_MSG_RESULT([no])
   232          AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])])
   233 AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL])
   234 
   235 #----------------------------------------
   236 # Check for libtoolize >= 1.5.26
   237 AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE],
   238     [AC_ARG_WITH([libtoolize],
   239         AS_HELP_STRING([--with-libtoolize=PATH],
   240                        [Specify the full PATH to GNU libtoolize >= 1.5.26]),
   241         [ac_cv_path_LIBTOOLIZE=$withval])])
   242 AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE],
   243     [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtoolize],
   244         [[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \
   245                         |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
   246           test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]],
   247         [AC_MSG_RESULT([no])
   248          AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])])
   249 AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE])
   250 
   251 #----------------------------------------
   252 # Check for automake >= 1.10
   253 AC_CACHE_VAL([ac_cv_path_automake],
   254     [AC_ARG_WITH([automake],
   255         AS_HELP_STRING([--with-automake=PATH],
   256                        [Specify the full PATH to GNU automake >= 1.10]),
   257         [ac_cv_path_automake=$withval])])
   258 AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
   259     [AC_PATH_PROGS_FEATURE_CHECK([automake], [automake],
   260         [[automake_ver=$($ac_path_automake --version 2>&1 \
   261                          |$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)')
   262           test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]],
   263         [AC_MSG_RESULT([no])
   264          AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
   265 AC_SUBST([automake], [$ac_cv_path_automake])
   266 
   267 #--------------------------------------------------------------------
   268 # Boring again... But still a bit of work to do...
   269 #--------------------------------------------------------------------
   270 AC_SUBST([kconfig_options])
   271 
   272 #----------------------------------------
   273 AC_CHECK_PROGS([xz],   [xz])
   274 ACX_SET_KCONFIG_OPTION([xz])
   275 AS_IF(
   276     [test -z "$xz"],
   277     [AC_CHECK_PROGS([lzma], [lzma])])
   278 ACX_SET_KCONFIG_OPTION([lzma])
   279 
   280 #----------------------------------------
   281 AC_CHECK_PROGS([cvs], [cvs])
   282 ACX_SET_KCONFIG_OPTION([cvs])
   283 
   284 #----------------------------------------
   285 AC_CHECK_PROGS([svn], [svn])
   286 ACX_SET_KCONFIG_OPTION([svn])
   287 
   288 #--------------------------------------------------------------------
   289 # Now, for some fun...
   290 #--------------------------------------------------------------------
   291 AC_C_INLINE
   292 AC_HEADER_STDC
   293 AC_FUNC_MALLOC
   294 AC_FUNC_REALLOC
   295 AC_FUNC_ALLOCA
   296 
   297 #----------------------------------------
   298 # Check for gettext, for the kconfig frontends
   299 AC_SUBST([gettext])
   300 AC_CHECK_HEADERS(
   301     [libintl.h],
   302     [ac_ct_gettext_hdr=$ac_header; break])
   303 AS_IF(
   304     [test -n "$ac_ct_gettext_hdr"],
   305     [AC_CHECK_DECL(
   306         [gettext],
   307         [gettext=y],,
   308         [AC_INCLUDES_DEFAULT()
   309          #include <$ac_ct_gettext_hdr>])])
   310 
   311 #----------------------------------------
   312 # Check for ncurses, for the kconfig frontends
   313 AC_SUBST([ac_ct_curses_hdr])
   314 AC_CHECK_HEADERS(
   315     [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
   316     [ac_ct_curses_hdr=$ac_header; break])
   317 AS_IF(
   318     [test -z "$ac_ct_curses_hdr"],
   319     [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
   320 AC_SEARCH_LIBS(
   321     [initscr],
   322     [ncursesw ncurses curses],
   323     [ac_ct_curses_lib_found=yes; break])
   324 AS_IF(
   325     [test -z "$ac_ct_curses_lib_found"],
   326     [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
   327 
   328 #--------------------------------------------------------------------
   329 # Lastly, take care of crosstool-NG internal values
   330 #--------------------------------------------------------------------
   331 # Hey! We need the date! :-)
   332 AC_SUBST(
   333     [DATE],
   334     [$(date +%Y%m%d)])
   335 
   336 # Decorate the version string if needed
   337 AS_IF(
   338     [test -f version.sh -a -x version.sh],
   339     [V=$(./version.sh "${PACKAGE_VERSION}")])
   340 AS_IF(
   341     [test -n "${V}"],
   342     [PACKAGE_VERSION="${V}"],
   343     [AS_CASE(
   344         [${PACKAGE_VERSION}],
   345         [hg|*+hg],
   346         [rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
   347                            2>/dev/null                               \
   348                     || true                                          )"
   349          PACKAGE_VERSION="${PACKAGE_VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
   350         ])])
   351 # Arrange to have no / in the directory name, no need to create an
   352 # arbitrarily deep directory structure
   353 [PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
   354 
   355 # Handle the local case
   356 AC_SUBST([sublibdir])
   357 AC_SUBST([subdocdir])
   358 AS_IF(
   359     [test "x$enable_local" = "xyes"],
   360     [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
   361      prefix=$(pwd)
   362      exec_prefix="$prefix"
   363      bindir="$prefix"
   364      libdir="$prefix"
   365      sublibdir=""
   366      docdir="$prefix""/docs"
   367      subdocdir=""
   368      datarootdir="$prefix"
   369      mandir="$docdir"],
   370     [sublibdir="/ct-ng.\${VERSION}"
   371      subdocdir="/ct-ng.\${VERSION}"])
   372 
   373 #--------------------------------------------------------------------
   374 # Finally, generate the output file(s)
   375 #--------------------------------------------------------------------
   376 AC_CONFIG_FILES([Makefile])
   377 AC_OUTPUT
   378 
   379 
   380 
   381 # AC_CONFIG_SRCDIR([kconfig/menu.c])
   382 # AC_CONFIG_HEADERS([config.h])
   383 # 
   384 # # Checks for programs.
   385 # 
   386 # # Checks for libraries.
   387 # 
   388 # # Checks for header files.
   389 # 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])
   390 # 
   391 # # Checks for typedefs, structures, and compiler characteristics.
   392 # AC_HEADER_STDBOOL
   393 # AC_TYPE_INT16_T
   394 # AC_TYPE_INT32_T
   395 # AC_TYPE_INT8_T
   396 # AC_TYPE_SIZE_T
   397 # AC_TYPE_UINT16_T
   398 # AC_TYPE_UINT32_T
   399 # AC_TYPE_UINT8_T
   400 # 
   401 # # Checks for library functions.
   402 # AC_FUNC_MALLOC
   403 # AC_FUNC_REALLOC
   404 # AC_CHECK_FUNCS([bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname])
   405 # 
   406 # AC_OUTPUT