summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xbootstrap4
-rw-r--r--configure.ac299
-rw-r--r--m4/README7
-rw-r--r--m4/ax_require_defined.m437
-rw-r--r--m4/ctng_cpu_count.m410
-rw-r--r--m4/ctng_gperf.m423
-rw-r--r--m4/ctng_prog.m436
-rw-r--r--m4/ctng_prog_stat.m418
-rw-r--r--m4/ctng_set_kconfig_option.m47
-rw-r--r--m4/ctng_version_check.m447
-rw-r--r--m4/ctng_with_deprecated.m410
12 files changed, 265 insertions, 234 deletions
diff --git a/.gitignore b/.gitignore
index 225009c..d456d1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Generated files
configure
autom4te.cache
+aclocal.m4
config.log
config.status
/Makefile
diff --git a/bootstrap b/bootstrap
index a71a2b0..25453de 100755
--- a/bootstrap
+++ b/bootstrap
@@ -738,7 +738,7 @@ gen_selection menu debug "Debug facilities"
gen_selection menu comp_tools "Companion tools"
gen_selection menu comp_libs "Companion libraries"
-msg "*** Running autoconf"
-autoconf -Wall --force
+msg "*** Running autoreconf"
+autoreconf -Wall --force
msg "*** Done!"
diff --git a/configure.ac b/configure.ac
index 8ae98bf..97d7607 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,122 +2,17 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.67])
+
+# FIXME Temporary hack until the next release (we'll switch to plain numeric tags then)
+# TBD need to quote sed expression
AC_INIT(
[crosstool-NG],
[m4_esyscmd_s([git describe --always --dirty])],
- [crossgcc@sourceware.org])
+ [crossgcc@sourceware.org],
+ [crosstool-ng],
+ [http://crosstool-ng.org])
AC_CONFIG_AUX_DIR([scripts])
-
-#--------------------------------------------------------------------
-# A few helper macros
-
-# ACX_WITH_DEPRECATED(PROG, VAR)
-# Declare a deprecated --with option: instead of --with-PROG=xxx, must use VAR=xxx
-AC_DEFUN(
- [ACX_WITH_DEPRECATED],
- [AC_ARG_WITH([$1],
- [AS_HELP_STRING([--with-$1=PATH],
- [Deprecated; use $2=PATH instead])],
- [AC_MSG_ERROR([--with-$1=$withval deprecated; use $2=$withval instead])])
- ])
-
-# Check for required tool
-AC_DEFUN(
- [ACX_CHECK_TOOL_REQ],
- [AC_CHECK_TOOLS([$1], [$2])
- AS_IF(
- [test -z "$$1"],
- [AC_MSG_ERROR([missing required tool: $2])])
- ])
-
-# Check for required tool, set variable to full pathname
-AC_DEFUN(
- [ACX_PATH_TOOL_REQ],
- [ACX_WITH_DEPRECATED([$3], [$1])
- AC_ARG_VAR([$1], [Specify the full path to GNU $3])
- ACX_CHECK_TOOL_REQ([$1], [$2])
- AS_CASE(
- [$$1],
- [/*],,
- [?*],[AC_MSG_CHECKING([for absolute path to $$1])
- $1=$(which $$1)
- AC_MSG_RESULT([$$1])])])
-
-# Check for required program
-AC_DEFUN(
- [ACX_CHECK_PROGS_REQ],
- [AC_CHECK_PROGS([$1], [$2])
- AS_IF(
- [test -z "$$1"],
- [AC_MSG_ERROR([missing required tool: $2])])
- ])
-
-# Check for path to required program
-AC_DEFUN(
- [ACX_PATH_PROGS_REQ],
- [AC_PATH_PROGS([$1], [$2])
- AS_IF(
- [test -z "$$1"],
- [AC_MSG_ERROR([missing required tool: $2])])
- ])
-
-# Set the kconfig option
-AC_DEFUN(
- [ACX_SET_KCONFIG_OPTION],
- [AS_IF(
- [test -n "$$1"],
- [AC_SUBST([KCONFIG_$1], ["def_bool y"])],
- [AC_SUBST([KCONFIG_$1], ["bool"])])])
-
-# Check if a given program is available with a particular version.
-# ACX_PROG_VERSION(VAR, HELP, PROG, SRCH, VERSION_CHECK[, CONFIG_OPT])
-# Search for PROG under possible names of SRCH. Allow user overrides in variable
-# VAR; display HELP message. Try to find a version that satisfies VERSION_CHECK
-# regexp; if that is achieved, set CONFIG_OPT in the kconfig. Otherwise, settle
-# for any version found.
-# Sets acx_version_VAR_ok to ':' if the version met the criterion, or false otherwise.
-AC_DEFUN(
- [ACX_PROG_VERSION],
- [AS_IF([test -z "$EGREP"],
- [AC_MSG_ERROR([This macro can only be used after checking for EGREP])])
- ACX_WITH_DEPRECATED([$3], [$1])
- AC_ARG_VAR([$1], [Specify the full path to $2])
- acx_version_$1_ok=false
- AC_CACHE_CHECK([for $3], [ac_cv_path_$1],
- [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4],
- [[ver=`$ac_path_$1 --version 2>/dev/null| $EGREP $5`
- test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1
- test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: acx_version_$1_ok=:]])])
- AS_IF([test -n "$1"],
- [[ver=`$ac_path_$1 --version 2>/dev/null| $EGREP $5`
- test -n "$ver" && acx_version_$1_ok=:]])
- AC_MSG_CHECKING([for $2])
- AS_IF([$acx_version_$1_ok],
- [AC_MSG_RESULT([yes])],
- [AC_MSG_RESULT([no])])
- AC_SUBST([$1], [$ac_cv_path_$1])
- AS_IF([test -n "$6"],
- [AS_IF([$acx_version_$1_ok], [$6=y], [$6=])
- ACX_SET_KCONFIG_OPTION([$6])])
- ])
-
-# Same as above, but make it a fatal error if the tool is not found at all
-# (i.e. "require any version, prefer version X or newer")
-AC_DEFUN(
- [ACX_PROG_VERSION_REQ_ANY],
- [ACX_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6])
- AS_IF([test -z "$$1"],
- [AC_MSG_ERROR([Required tool not found: $3])])
- ])
-
-# Same, but also require the version check to pass
-# (i.e. "require version X or newer")
-AC_DEFUN(
- [ACX_PROG_VERSION_REQ_STRICT],
- [ACX_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6])
- AS_IF([test -z "$$1" || ! $acx_version_$1_ok],
- [AC_MSG_ERROR([Required tool not found: $2])])
- ])
+AC_CONFIG_MACRO_DIR([m4])
# Check if install(1) supports --strip-program=...
AC_DEFUN(
@@ -144,8 +39,7 @@ AC_ARG_ENABLE(
[do not install, and use current directory])])
AC_SUBST([enable_local], [${enable_local:-no}])
-# FIXME: I don't know why we have this. Will remove after the next
-# release.
+# FIXME: I don't know why we have this. Will remove after the 1.24 release.
AC_ARG_ENABLE(
[shared],
[AS_HELP_STRING(
@@ -157,7 +51,6 @@ AC_ARG_ENABLE(
[--enable-static],
[build static libraries (deprecated, ignored)])])
-#---------------------------------------------------------------------
# Check for --build and --host...
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
@@ -168,27 +61,27 @@ AS_IF([test -n "$target_alias"],
# Allow program name tranformation (--program-{prefix,suffix,transform-name})
AC_ARG_PROGRAM
-#---------------------------------------------------------------------
-# Initial checks that are usually done first (I don't know why, that's
-# just what I seem to experience...)
-#---------------------------------------------------------------------
-ACX_WITH_DEPRECATED([install], [INSTALL])
+AC_PROG_MKDIR_P
+
+CTNG_WITH_DEPRECATED([install], [INSTALL])
AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install])
AC_PROG_INSTALL
ACX_INSTALL_STRIP_PROGRAM
-ACX_WITH_DEPRECATED([grep], [GREP])
+CTNG_WITH_DEPRECATED([grep], [GREP])
AC_ARG_VAR([GREP], [Specify the full path to GNU grep])
# This is not a typo! Prefer GNU grep on macOS if it is installed.
-ACX_PATH_TOOL_REQ([GREP], [ggrep grep], [grep])
-ACX_PATH_TOOL_REQ([EGREP], [gegrep egrep], [egrep])
+CTNG_PATH_TOOL_REQ([GREP], [ggrep grep], [grep])
+CTNG_PATH_TOOL_REQ([EGREP], [gegrep egrep], [egrep])
AC_PROG_GREP
AC_PROG_EGREP
+
+# FIXME: ct-ng assumes this in many places...
AS_IF([test "$EGREP" != "$GREP -E"],
[AC_MSG_ERROR([egrep is not $GREP -E])])
-ACX_PROG_VERSION_REQ_STRICT([SED],
+CTNG_PROG_VERSION_REQ_STRICT([SED],
[GNU sed >= 4.0],
[sed],
[gsed sed],
@@ -203,9 +96,11 @@ AC_PROG_LN_S
# Modern GCC/GDB releases require C++ support in the compiler
AC_PROG_CC
AC_PROG_CXX
+AC_PROG_CPP
+AC_PROG_LEX
+AC_PROG_YACC
AS_IF([test -z "$CC" -o -z "$CXX"],
[AC_MSG_ERROR([no suitable compiler found])])
-AC_PROG_CPP
#---------------------------------------------------------------------
# Check to see if the compiler can link statically
@@ -218,82 +113,58 @@ AS_IF([test $static_test -eq 0],
[test $static_test -ne 0],
[static_link=
AC_MSG_RESULT([no])])
-ACX_SET_KCONFIG_OPTION([static_link])
+CTNG_SET_KCONFIG_OPTION([static_link])
AC_PROG_RANLIB
-ACX_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy])
-ACX_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump])
-ACX_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf])
-ACX_PATH_TOOL_REQ([GPERF], [gperf], [gperf])
-
-ACX_CHECK_PROGS_REQ([bison], [bison])
-ACX_CHECK_PROGS_REQ([flex], [flex])
-ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
-ACX_CHECK_PROGS_REQ([cut], [cut])
-ACX_CHECK_PROGS_REQ([readlink], [readlink])
-ACX_CHECK_PROGS_REQ([tar], [tar])
-ACX_CHECK_PROGS_REQ([gzip], [gzip])
-ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
-ACX_CHECK_PROGS_REQ([xz], [xz])
-ACX_CHECK_PROGS_REQ([help2man], [help2man])
+CTNG_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy])
+CTNG_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump])
+CTNG_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf])
+CTNG_PATH_TOOL_REQ([GPERF], [gperf], [gperf])
+
+CTNG_CHECK_PROGS_REQ([bison], [bison])
+CTNG_CHECK_PROGS_REQ([flex], [flex])
+CTNG_CHECK_PROGS_REQ([makeinfo], [makeinfo])
+CTNG_CHECK_PROGS_REQ([cut], [cut])
+CTNG_CHECK_PROGS_REQ([readlink], [readlink])
+CTNG_CHECK_PROGS_REQ([tar], [tar])
+CTNG_CHECK_PROGS_REQ([gzip], [gzip])
+CTNG_CHECK_PROGS_REQ([bzip2], [bzip2])
+CTNG_CHECK_PROGS_REQ([xz], [xz])
+CTNG_CHECK_PROGS_REQ([help2man], [help2man])
# Not a fatal failure even if we have neither - the tarballs may
# be provided in a local directory.
AC_CHECK_PROGS([wget], [wget])
-ACX_SET_KCONFIG_OPTION([wget])
+CTNG_SET_KCONFIG_OPTION([wget])
AC_SUBST([wget])
AC_CHECK_PROGS([curl], [curl])
-ACX_SET_KCONFIG_OPTION([curl])
+CTNG_SET_KCONFIG_OPTION([curl])
AC_SUBST([curl])
-ACX_CHECK_PROGS_REQ([stat], [stat])
-AC_CACHE_CHECK([whether stat takes GNU or BSD format],
- [acx_cv_stat_flavor],
- [touch conftest
- chmod 642 conftest
- attr_bsd=`stat -f '%Lp' conftest 2>/dev/null`
- attr_gnu=`stat -c '%a' conftest 2>/dev/null`
- rm -f conftest
- AS_IF([test "$attr_bsd" = "642"],
- [acx_cv_stat_flavor=BSD],
- [test "$attr_gnu" = "642"],
- [acx_cv_stat_flavor=GNU],
- [AC_MSG_ERROR([cannot determine stat(1) format option])])])
-
+# TBD move the checks/setting kconfig into [IF-BSD] and [IF-GNU] arguments to CTNG_PROG_STAT
+# TBD modify CTNG_SET_KCONFIG_OPTION to take an optional argument to which it should be set
+CTNG_PROG_STAT
# FIXME: support SET_KCONFIG_OPTION with string values? But then
# again, these checks may be moved into ct-ng script.
test "$acx_cv_stat_flavor" = "BSD" && stat_flavor_BSD=y
-ACX_SET_KCONFIG_OPTION([stat_flavor_BSD])
+CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD])
test "$acx_cv_stat_flavor" = "GNU" && stat_flavor_GNU=y
-ACX_SET_KCONFIG_OPTION([stat_flavor_GNU])
+CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU])
-#Find out how to count CPUs
-AC_CACHE_CHECK([whether to use getconf or sysctl to count CPUs],
- [acx_cv_cpu_count],
- [getconf _NPROCESSORS_ONLN >/dev/null 2>&1 && \
- acx_cv_cpu_count="getconf _NPROCESSORS_ONLN"
- sysctl -n hw.ncpu >/dev/null 2>&1 && \
- acx_cv_cpu_count="sysctl -n hw.ncpu"])
-AC_SUBST(CPU_COUNT, "$acx_cv_cpu_count")
+CTNG_CPU_COUNT
-#--------------------------------------------------------------------
-# Still boring, but remember the path, now...
-#--------------------------------------------------------------------
-ACX_PATH_TOOL_REQ([PATCH], [gpatch patch], [patch])
+CTNG_PATH_TOOL_REQ([PATCH], [gpatch patch], [patch])
-#--------------------------------------------------------------------
-# And a bunch of less boring tests...
-#--------------------------------------------------------------------
# We need a bash that is >= 3.1
-ACX_PROG_VERSION_REQ_STRICT([BASH_SHELL],
+CTNG_PROG_VERSION_REQ_STRICT([BASH_SHELL],
[GNU bash >= 3.1],
[bash],
[bash],
['^GNU bash, version (3\.[1-9]|4)'])
# We need a awk that *is* GNU awk
-ACX_PROG_VERSION_REQ_STRICT([AWK],
+CTNG_PROG_VERSION_REQ_STRICT([AWK],
[GNU awk],
[awk],
[gawk awk],
@@ -306,7 +177,7 @@ ACX_PROG_VERSION_REQ_STRICT([AWK],
# build/install crosstool-ng itself.
#----------------------------------------
# Check for GNU make (want 3.81 or above, but will accept as long as any make is found)
-ACX_PROG_VERSION_REQ_ANY([MAKE],
+CTNG_PROG_VERSION_REQ_ANY([MAKE],
[GNU make >= 3.81],
[make],
[gmake make],
@@ -314,85 +185,64 @@ ACX_PROG_VERSION_REQ_ANY([MAKE],
[make_3_81_or_newer])
# Check other companion tools that we may or may not build
-ACX_PROG_VERSION([LIBTOOL],
+CTNG_PROG_VERSION([LIBTOOL],
[GNU libtool >= 2.4],
[libtool],
[glibtool libtool],
['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'],
[libtool_2_4_or_newer])
-ACX_PROG_VERSION([LIBTOOLIZE],
+CTNG_PROG_VERSION([LIBTOOLIZE],
[GNU libtoolize >= 2.4],
[libtoolize],
[glibtoolize libtoolize],
['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'],
[libtoolize_2_4_or_newer])
-ACX_PROG_VERSION([AUTOCONF],
+CTNG_PROG_VERSION([AUTOCONF],
[GNU autoconf >= 2.65],
[autoconf],
[autoconf],
['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[5-9])'],
[autoconf_2_63_or_newer])
-ACX_PROG_VERSION([AUTORECONF],
+CTNG_PROG_VERSION([AUTORECONF],
[GNU autoreconf >= 2.63],
[autoreconf],
[autoreconf],
['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[3-9])'],
[autoreconf_2_63_or_newer])
-ACX_PROG_VERSION([AUTOMAKE],
+CTNG_PROG_VERSION([AUTOMAKE],
[GNU automake >= 1.15],
[automake],
[automake],
['\(GNU automake\) ([2-9]\.|1\.[2-9][0-9]|1\.1[5-9])'],
[automake_1_15_or_newer])
-ACX_PROG_VERSION([M4],
+CTNG_PROG_VERSION([M4],
[GNU m4 >= 1.4.12],
[m4],
[gm4 m4],
['\(GNU M4\) ([2-9]\.|1\.[5-9]|1\.[1-4][0-9]|1\.4\.[2-9][0-9]|1\.4\.1[2-9])'],
[gnu_m4_1_4_12_or_newer])
-#----------------------------------------
-# Gperf 3.1 started generating functions with size_t rather than unsigned int
-AC_MSG_CHECKING([for the type used in gperf declarations])
-echo "#include <string.h>" > conftest.gperf.c
-echo "const char * in_word_set(const char *, GPERF_LEN_TYPE);" >> conftest.gperf.c
-echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c
-AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1],
- [AC_MSG_RESULT([size_t])
- GPERF_LEN_TYPE='size_t'],
- [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1],
- [AC_MSG_RESULT([unsigned int])
- GPERF_LEN_TYPE='unsigned int'],
- [AC_MSG_ERROR([unable to determine gperf len type])])
-rm -f conftest.gperf.c
-AC_SUBST([GPERF_LEN_TYPE])
+CTNG_PROG_GPERF
-#--------------------------------------------------------------------
-# Boring again... But still a bit of work to do...
-#--------------------------------------------------------------------
AC_SUBST([kconfig_options])
-#----------------------------------------
AC_CHECK_PROGS([cvs], [cvs])
-ACX_SET_KCONFIG_OPTION([cvs])
+CTNG_SET_KCONFIG_OPTION([cvs])
-#----------------------------------------
AC_CHECK_PROGS([svn], [svn])
-ACX_SET_KCONFIG_OPTION([svn])
+CTNG_SET_KCONFIG_OPTION([svn])
AC_CHECK_PROGS([git], [git])
-ACX_SET_KCONFIG_OPTION([git])
+CTNG_SET_KCONFIG_OPTION([git])
AC_CHECK_PROGS([DPKG_BUILDFLAGS], [dpkg-buildflags])
-#--------------------------------------------------------------------
-# Now, for some fun...
-#--------------------------------------------------------------------
+# FIXME why checking if not using the result? We don't provide replacemant malloc/alloca/...
AC_C_INLINE
AC_HEADER_STDC
AC_FUNC_MALLOC
@@ -417,7 +267,6 @@ AC_SEARCH_LIBS(bindtextdomain, intl, [test "$ac_res" = "none required" || INTL_L
LIBS=$SAVE_LIBS
AC_SUBST([INTL_LIBS])
-#----------------------------------------
# Check for ncurses, for the kconfig frontends
AC_SUBST([ac_ct_curses_hdr])
AC_CHECK_HEADERS(
@@ -437,9 +286,6 @@ AC_SEARCH_LIBS(
[tgetent],
[termcap tinfo ncursesw ncurses curses])
-#--------------------------------------------------------------------
-# Lastly, take care of crosstool-NG internal values
-#--------------------------------------------------------------------
# Hey! We need the date! :-)
DATE_FMT="%Y%m%d"
if test "x$SOURCE_DATE_EPOCH" = "x"; then
@@ -449,23 +295,10 @@ else
fi
AC_SUBST([DATE])
-# Decorate the version string if needed
+# Decorate the version string per user-supplied version.sh, if any
AS_IF(
[test -f version.sh -a -x version.sh],
- [V=$(./version.sh "${PACKAGE_VERSION}")])
-AS_IF(
- [test -n "${V}"],
- [PACKAGE_VERSION="${V}"],
- [AS_CASE(
- [${PACKAGE_VERSION}],
- [git|*+git],
- [rev_id="$( git rev-parse --short HEAD )"
- git diff-index --quiet HEAD || rev_id="${rev_id}-dirty"
- PACKAGE_VERSION="${PACKAGE_VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
- ])])
-# Arrange to have no / in the directory name, no need to create an
-# arbitrarily deep directory structure
-[PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
+ [PACKAGE_VERSION=$(./version.sh "${PACKAGE_VERSION}")])
# Handle the local case
AC_SUBST([sublibdir])
@@ -485,8 +318,10 @@ AS_IF(
[sublibdir="/\${VERSION}"
subdocdir="/\${VERSION}"])
-#--------------------------------------------------------------------
-# Finally, generate the output file(s)
-#--------------------------------------------------------------------
-AC_CONFIG_FILES([Makefile kconfig/Makefile config/configure.in])
+AC_CONFIG_FILES([
+ Makefile
+ kconfig/Makefile
+ config/configure.in
+])
+
AC_OUTPUT
diff --git a/m4/README b/m4/README
new file mode 100644
index 0000000..a572d61
--- /dev/null
+++ b/m4/README
@@ -0,0 +1,7 @@
+These autoconf helper macros come from various sources:
+
+- ax_*.m4: autoconf-archive, version 2017.09.28 (copied)
+- pkg.m4: pkg-config, version 0.29.2 (run configure, then copy)
+- gettext.m4, iconv.m4, intlmacosx.m4, nls.m4: gettext 0.19.8
+- ctng_*.m4: obviously, implemented anew
+- po.m4: a local dummy stub for gettext's version
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
new file mode 100644
index 0000000..17c3eab
--- /dev/null
+++ b/m4/ax_require_defined.m4
@@ -0,0 +1,37 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+# been defined and thus are available for use. This avoids random issues
+# where a macro isn't expanded. Instead the configure script emits a
+# non-fatal:
+#
+# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+# It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+# Here's an example:
+#
+# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+ m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
diff --git a/m4/ctng_cpu_count.m4 b/m4/ctng_cpu_count.m4
new file mode 100644
index 0000000..4ea50d8
--- /dev/null
+++ b/m4/ctng_cpu_count.m4
@@ -0,0 +1,10 @@
+# Find out how to count CPUs
+AC_DEFUN([CTNG_CPU_COUNT],
+ [AC_CACHE_CHECK([whether to use getconf or sysctl to count CPUs],
+ [acx_cv_cpu_count],
+ [getconf _NPROCESSORS_ONLN >/dev/null 2>&1 && \
+ acx_cv_cpu_count="getconf _NPROCESSORS_ONLN"
+ sysctl -n hw.ncpu >/dev/null 2>&1 && \
+ acx_cv_cpu_count="sysctl -n hw.ncpu"])
+ AC_SUBST(CPU_COUNT, "$acx_cv_cpu_count")
+ ])
diff --git a/m4/ctng_gperf.m4 b/m4/ctng_gperf.m4
new file mode 100644
index 0000000..0ec1a0e
--- /dev/null
+++ b/m4/ctng_gperf.m4
@@ -0,0 +1,23 @@
+# Check for GNU perf location and the type it uses in the prototypes
+# FIXME: remove AC_SUBST after switching to using autoheader
+AC_DEFUN([CTNG_PROG_GPERF],
+ [AX_REQUIRE_DEFINED([CTNG_CHECK_TOOL_REQ])
+ CTNG_CHECK_TOOL_REQ([GPERF], [gperf], [gperf])
+ # Gperf 3.1 started generating functions with size_t rather than unsigned int
+ AC_MSG_CHECKING([for the type used in gperf declarations])
+ cat > conftest.gperf.c <<_ASEOF
+#include <string.h>"
+const char * in_word_set(const char *, GPERF_LEN_TYPE);
+_ASEOF
+ echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c
+ AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1],
+ [AC_MSG_RESULT([size_t])
+ GPERF_LEN_TYPE='size_t'],
+ [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1],
+ [AC_MSG_RESULT([unsigned int])
+ GPERF_LEN_TYPE='unsigned int'],
+ [AC_MSG_ERROR([unable to determine gperf len type])])
+ rm -f conftest.gperf.c
+ AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], $GPERF_LEN_TYPE, [String length type used by gperf])
+ AC_SUBST([GPERF_LEN_TYPE])
+])
diff --git a/m4/ctng_prog.m4 b/m4/ctng_prog.m4
new file mode 100644
index 0000000..ebbe333
--- /dev/null
+++ b/m4/ctng_prog.m4
@@ -0,0 +1,36 @@
+# Several convenience wrappers for checking the programs
+
+# Check for required tool
+AC_DEFUN([CTNG_CHECK_TOOL_REQ],
+ [AC_CHECK_TOOLS([$1], [$2])
+ AS_IF(
+ [test -z "$$1"],
+ [AC_MSG_ERROR([missing required tool: $2])])
+ ])
+
+# Check for required tool, set variable to full pathname
+AC_DEFUN([CTNG_PATH_TOOL_REQ],
+ [AC_ARG_VAR([$1], [Specify the full path to GNU $3])
+ CTNG_CHECK_TOOL_REQ([$1], [$2])
+ AS_CASE(
+ [$$1],
+ [/*],,
+ [?*],[AC_MSG_CHECKING([for absolute path to $$1])
+ $1=$(which $$1)
+ AC_MSG_RESULT([$$1])])])
+
+# Check for required program
+AC_DEFUN([CTNG_CHECK_PROGS_REQ],
+ [AC_CHECK_PROGS([$1], [$2])
+ AS_IF(
+ [test -z "$$1"],
+ [AC_MSG_ERROR([missing required tool: $2])])
+ ])
+
+# Check for path to required program
+AC_DEFUN([CTNG_PATH_PROGS_REQ],
+ [AC_PATH_PROGS([$1], [$2])
+ AS_IF(
+ [test -z "$$1"],
+ [AC_MSG_ERROR([missing required tool: $2])])
+ ])
diff --git a/m4/ctng_prog_stat.m4 b/m4/ctng_prog_stat.m4
new file mode 100644
index 0000000..f7de93e
--- /dev/null
+++ b/m4/ctng_prog_stat.m4
@@ -0,0 +1,18 @@
+# Check that stat(1) is present and determine the syntax for the format
+# string (BSD or GNU).
+AC_DEFUN([CTNG_PROG_STAT],
+ [AX_REQUIRE_DEFINED([CTNG_CHECK_PROGS_REQ])
+ CTNG_CHECK_PROGS_REQ([stat], [stat])
+ AC_CACHE_CHECK([whether stat takes GNU or BSD format],
+ [acx_cv_stat_flavor],
+ [touch conftest
+ chmod 642 conftest
+ attr_bsd=$(stat -f '%Lp' conftest 2>/dev/null)
+ attr_gnu=$(stat -c '%a' conftest 2>/dev/null)
+ rm -f conftest
+ AS_IF([test "$attr_bsd" = "642"],
+ [acx_cv_stat_flavor=BSD],
+ [test "$attr_gnu" = "642"],
+ [acx_cv_stat_flavor=GNU],
+ [AC_MSG_ERROR([cannot determine stat(1) format option])])])
+ ])
diff --git a/m4/ctng_set_kconfig_option.m4 b/m4/ctng_set_kconfig_option.m4
new file mode 100644
index 0000000..9fae320
--- /dev/null
+++ b/m4/ctng_set_kconfig_option.m4
@@ -0,0 +1,7 @@
+# Set the kconfig option.
+AC_DEFUN([CTNG_SET_KCONFIG_OPTION],
+ [AS_IF(
+ [test -n "$$1"],
+ [AC_SUBST([KCONFIG_$1], ["def_bool y"])],
+ [AC_SUBST([KCONFIG_$1], ["bool"])])
+ ])
diff --git a/m4/ctng_version_check.m4 b/m4/ctng_version_check.m4
new file mode 100644
index 0000000..472194b
--- /dev/null
+++ b/m4/ctng_version_check.m4
@@ -0,0 +1,47 @@
+# Check if a given program is available with a particular version.
+# CTNG_PROG_VERSION(VAR, HELP, PROG, SRCH, VERSION_CHECK[, CONFIG_OPT])
+# Search for PROG under possible names of SRCH. Allow user overrides in variable
+# VAR; display HELP message. Try to find a version that satisfies VERSION_CHECK
+# regexp; if that is achieved, set CONFIG_OPT in the kconfig. Otherwise, settle
+# for any version found.
+# Sets acx_version_VAR_ok to ':' if the version met the criterion, or false otherwise.
+AC_DEFUN([CTNG_PROG_VERSION],
+ [AS_IF([test -z "$EGREP"],
+ [AC_MSG_ERROR([This macro can only be used after checking for EGREP])])
+ CTNG_WITH_DEPRECATED([$3], [$1])
+ AC_ARG_VAR([$1], [Specify the full path to $2])
+ acx_version_$1_ok=false
+ AC_CACHE_CHECK([for $3], [ac_cv_path_$1],
+ [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4],
+ [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5)
+ test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1
+ test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: acx_version_$1_ok=:]])])
+ AS_IF([test -n "$1"],
+ [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5)
+ test -n "$ver" && acx_version_$1_ok=:]])
+ AC_MSG_CHECKING([for $2])
+ AS_IF([$acx_version_$1_ok],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])])
+ AC_SUBST([$1], [$ac_cv_path_$1])
+ AS_IF([test -n "$6"],
+ [AS_IF([$acx_version_$1_ok], [$6=y], [$6=])
+ CTNG_SET_KCONFIG_OPTION([$6])])
+ ])
+
+# Same as above, but make it a fatal error if the tool is not found at all
+# (i.e. "require any version, prefer version X or newer")
+AC_DEFUN([CTNG_PROG_VERSION_REQ_ANY],
+ [CTNG_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6])
+ AS_IF([test -z "$$1"],
+ [AC_MSG_ERROR([Required tool not found: $3])])
+ ])
+
+# Same, but also require the version check to pass
+# (i.e. "require version X or newer")
+AC_DEFUN([CTNG_PROG_VERSION_REQ_STRICT],
+ [CTNG_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6])
+ AS_IF([test -z "$$1" || ! $acx_version_$1_ok],
+ [AC_MSG_ERROR([Required tool not found: $2])])
+ ])
+
diff --git a/m4/ctng_with_deprecated.m4 b/m4/ctng_with_deprecated.m4
new file mode 100644
index 0000000..976bc3f
--- /dev/null
+++ b/m4/ctng_with_deprecated.m4
@@ -0,0 +1,10 @@
+# FIXME retire after 1.24
+#
+# CTNG_WITH_DEPRECATED(PROG, VAR)
+# Declare a deprecated --with option: instead of --with-PROG=xxx, must use VAR=xxx
+AC_DEFUN([CTNG_WITH_DEPRECATED],
+ [AC_ARG_WITH([$1],
+ [AS_HELP_STRING([--with-$1=PATH],
+ [Deprecated; use $2=PATH instead])],
+ [AC_MSG_ERROR([--with-$1=$withval deprecated; use $2=$withval instead])])
+ ])