configure.ac
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Tue Jul 17 21:42:32 2012 +0200 (2012-07-17)
branch1.15
changeset 3007 34fea104c84c
parent 2999 4ccfca658d9b
child 3001 0dfc9c1fcb34
permissions -rw-r--r--
configure: add checks for objcopy and objdump

These two went MIA after the migration to an autoconf-based ./configure.

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