configure.ac
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Jan 30 21:31:20 2012 +0100 (2012-01-30)
changeset 2859 0afb64320510
parent 2840 188d58cfe7cf
child 2860 2275425cbdee
permissions -rw-r--r--
scripts: fix typo in mk-release, remove temporary autom4 files

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