configure.ac
author Cody Schafer <dev@codyps.com>
Fri May 09 19:13:49 2014 -0700 (2014-05-09)
changeset 3312 4876ff97e039
parent 3297 021ddc052689
permissions -rw-r--r--
cc/gcc: allow CC_EXTRA_CONFIG_ARRAY on baremetal

The final bare-metal compiler is built using the core backend.
Currently the core uses the CC_CORE_EXTRA_CONFIG_ARRAY variable.

While this works as supposed to, this can leave the user puzzled
in the menuconfig, since all he can see is the core options, not
the final options.

Only show the core options if any of the core passes are needed,
and use the final options in the core-backend if we're issuing
the bare-metal compiler.

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