summaryrefslogtreecommitdiffstats
path: root/rules/templates
diff options
context:
space:
mode:
authorJuergen Borleis <jbe@pengutronix.de>2014-06-18 17:25:16 +0200
committerJuergen Borleis <jbe@pengutronix.de>2014-07-11 10:28:35 +0200
commit27e9d1dbe22e9e77660eb47ab36b84ddf17f55d6 (patch)
tree7baeac08b92b653c3874023c158f641dff98e3fd /rules/templates
parenta87cf4a4c595123a621480ab34d37a6f18aabd1e (diff)
downloadptxdist-27e9d1dbe22e9e77660eb47ab36b84ddf17f55d6.tar.gz
ptxdist-27e9d1dbe22e9e77660eb47ab36b84ddf17f55d6.tar.xz
Provide better and generic M4 macros for cross compiling
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Diffstat (limited to 'rules/templates')
-rw-r--r--rules/templates/template-m4-macros/attributes.m4311
-rw-r--r--rules/templates/template-m4-macros/ax_armv4_detection.m498
-rw-r--r--rules/templates/template-m4-macros/ax_armv5_detection.m4100
-rw-r--r--rules/templates/template-m4-macros/ax_armv6_detection.m4101
-rw-r--r--rules/templates/template-m4-macros/ax_armv7_detection.m498
-rw-r--r--rules/templates/template-m4-macros/ax_floating_point.m497
-rw-r--r--rules/templates/template-m4-macros/pkg.m4157
7 files changed, 962 insertions, 0 deletions
diff --git a/rules/templates/template-m4-macros/attributes.m4 b/rules/templates/template-m4-macros/attributes.m4
new file mode 100644
index 000000000..9d561c244
--- /dev/null
+++ b/rules/templates/template-m4-macros/attributes.m4
@@ -0,0 +1,311 @@
+dnl Macros to check the presence of generic (non-typed) symbols.
+dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
+dnl Copyright (c) 2006-2008 xine project
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+dnl
+dnl As a special exception, the copyright owners of the
+dnl macro gives unlimited permission to copy, distribute and modify the
+dnl configure scripts that are the output of Autoconf when processing the
+dnl Macro. You need not follow the terms of the GNU General Public
+dnl License when using or distributing such scripts, even though portions
+dnl of the text of the Macro appear in them. The GNU General Public
+dnl License (GPL) does govern all other use of the material that
+dnl constitutes the Autoconf Macro.
+dnl
+dnl This special exception to the GPL applies to versions of the
+dnl Autoconf Macro released by this project. When you make and
+dnl distribute a modified version of the Autoconf Macro, you may extend
+dnl this special exception to the GPL to apply to your modified version as
+dnl well.
+
+dnl Check if the flag is supported by compiler
+dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
+ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl Check if the flag is supported by compiler (cacheable)
+dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for CFLAG and appends them to CFLAGS if supported
+AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
+ for flag in $1; do
+ CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
+ done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_ldflags_$1]),
+ [ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $1"
+ AC_LINK_IFELSE([int main() { return 1; }],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
+ LDFLAGS="$ac_save_LDFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+ dnl We check $host for which systems to enable this for.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ case $host in
+ dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+ dnl are requested, as different implementations are present; to avoid problems
+ dnl use -Wl,-z,defs only for those platform not behaving this way.
+ *-freebsd* | *-openbsd*) ;;
+ *)
+ dnl First of all check for the --no-undefined variant of GNU ld. This allows
+ dnl for a much more readable commandline, so that people can understand what
+ dnl it does without going to look for what the heck -z defs does.
+ for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+ CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+ break
+ done
+ ;;
+ esac
+
+ AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
+dnl Check for a -Werror flag or equivalent. -Werror is the GCC
+dnl and ICC flag that tells the compiler to treat all the warnings
+dnl as fatal. We usually need this option to make sure that some
+dnl constructs (like attributes) are not simply ignored.
+dnl
+dnl Other compilers don't support -Werror per se, but they support
+dnl an equivalent flag:
+dnl - Sun Studio compiler supports -errwarn=%all
+AC_DEFUN([CC_CHECK_WERROR], [
+ AC_CACHE_CHECK(
+ [for $CC way to treat warnings as errors],
+ [cc_cv_werror],
+ [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
+ [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
+ ])
+])
+
+AC_DEFUN([CC_CHECK_ATTRIBUTE], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
+ AS_TR_SH([cc_cv_attribute_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
+ [AC_DEFINE(
+ AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
+ [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
+ )
+ $4],
+ [$5])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+ CC_CHECK_ATTRIBUTE(
+ [constructor],,
+ [void __attribute__((constructor)) ctor() { int a; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+ CC_CHECK_ATTRIBUTE(
+ [format], [format(printf, n, n)],
+ [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+ CC_CHECK_ATTRIBUTE(
+ [format_arg], [format_arg(printf)],
+ [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+ CC_CHECK_ATTRIBUTE(
+ [visibility_$1], [visibility("$1")],
+ [void __attribute__((visibility("$1"))) $1_function() { }],
+ [$2], [$3])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+ CC_CHECK_ATTRIBUTE(
+ [nonnull], [nonnull()],
+ [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+ CC_CHECK_ATTRIBUTE(
+ [unused], ,
+ [void some_function(void *foo, __attribute__((unused)) void *bar);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+ CC_CHECK_ATTRIBUTE(
+ [sentinel], ,
+ [void some_function(void *foo, ...) __attribute__((sentinel));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
+ CC_CHECK_ATTRIBUTE(
+ [deprecated], ,
+ [void some_function(void *foo, ...) __attribute__((deprecated));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+ CC_CHECK_ATTRIBUTE(
+ [alias], [weak, alias],
+ [void other_function(void *foo) { }
+ void some_function(void *foo) __attribute__((weak, alias("other_function")));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
+ CC_CHECK_ATTRIBUTE(
+ [malloc], ,
+ [void * __attribute__((malloc)) my_alloc(int n);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_PACKED], [
+ CC_CHECK_ATTRIBUTE(
+ [packed], ,
+ [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+ CC_CHECK_ATTRIBUTE(
+ [const], ,
+ [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_FLAG_VISIBILITY], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
+ [cc_cv_flag_visibility],
+ [cc_flag_visibility_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
+ cc_cv_flag_visibility='yes',
+ cc_cv_flag_visibility='no')
+ CFLAGS="$cc_flag_visibility_save_CFLAGS"])
+
+ AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
+ [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
+ [Define this if the compiler supports the -fvisibility flag])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_FUNC_EXPECT], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if compiler has __builtin_expect function],
+ [cc_cv_func_expect],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [int some_function() {
+ int a = 3;
+ return (int)__builtin_expect(a, 3);
+ }])],
+ [cc_cv_func_expect=yes],
+ [cc_cv_func_expect=no])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([test "x$cc_cv_func_expect" = "xyes"],
+ [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
+ [Define this if the compiler supports __builtin_expect() function])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
+ [cc_cv_attribute_aligned],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ for cc_attribute_align_try in 64 32 16 8 4 2; do
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ int main() {
+ static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
+ return c;
+ }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
+ done
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ if test "x$cc_cv_attribute_aligned" != "x"; then
+ AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
+ [Define the highest alignment supported])
+ fi
+])
diff --git a/rules/templates/template-m4-macros/ax_armv4_detection.m4 b/rules/templates/template-m4-macros/ax_armv4_detection.m4
new file mode 100644
index 000000000..05b6ae0de
--- /dev/null
+++ b/rules/templates/template-m4-macros/ax_armv4_detection.m4
@@ -0,0 +1,98 @@
+#
+# SYNOPSIS
+#
+# AX_DETECT_ARMV4([ACTION-IF-ARMv4],[ACTION-IF-NO-ARMv4])
+#
+# DESCRIPTION
+#
+# AX_DETECT_ARMV4 detects from the compiler settings if the target is of
+# type ARMv4. It is intended mostly for cross compiling to be able to collect
+# more information about the target architecture and features. The user can
+# overwrite the detection by using the option --enable-armv4core or
+# --disable-armv4core.
+# It works by detecting the compiler's macros __ARM_ARCH_4__ and
+# __ARM_ARCH_4T__. These are set in gcc compilers when they are configured
+# to create code for ARMv4 cores.
+# This macro cannot detect the correct target's features if the compiler is
+# not correctly configured to reflect the target's features.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Juergen Borleis <jbe@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_DETECT_ARMV4],
+ [AC_REQUIRE([AC_PROG_CC])
+dnl
+dnl Give the user the possibility to overwrite the auto detection
+dnl
+ AC_ARG_ENABLE([armv4core],
+ [AS_HELP_STRING([--enable-armv4core],
+ [Enable optimizations for ARMv4 cores @<:@default=auto@:>@])],
+ [ax_armv4core="${enableval}"],
+ [ax_armv4core=auto])
+
+ AC_CACHE_CHECK([for ARMv4 target core], [ax_cv_armv4core],
+ [ax_cv_armv4core=${ax_armv4core}])
+dnl AC_MSG_RESULT([${ax_cv_armv4core}])
+
+ if test "x${ax_cv_armv4core}" = "xauto"; then
+ if test "x$GCC" != "xyes"; then
+dnl only for GCC we know it works in this way
+ AC_MSG_ERROR([Cannot autodetect the architecture for non GCC compilers])
+ else
+ AC_MSG_CHECKING(if target's core is of type ARMv4)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[
+#undef THIS_IS_V4
+#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
+# define THIS_IS_V4 1
+#endif
+int foo = THIS_IS_V4;
+ ]]) dnl AC_LANG_PROGRAM
+ ],
+ [ax_cv_armv4core=yes],
+ [ax_cv_armv4core=no],
+ [ARMv4 core]); dnl AC_COMPILE_IFELSE
+ AC_MSG_RESULT([${ax_cv_armv4core}]);
+ fi
+ fi
+
+ case "x${ax_cv_armv4core}" in
+ "xyes")
+ $1
+ ;;
+ "xno")
+ $2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown setting for ARMv4 architecture: '${ax_cv_armv4core}'.])
+ ;;
+ esac
+]) dnl AC_DEFUN
diff --git a/rules/templates/template-m4-macros/ax_armv5_detection.m4 b/rules/templates/template-m4-macros/ax_armv5_detection.m4
new file mode 100644
index 000000000..802fe362d
--- /dev/null
+++ b/rules/templates/template-m4-macros/ax_armv5_detection.m4
@@ -0,0 +1,100 @@
+#
+# SYNOPSIS
+#
+# AX_DETECT_ARMV5([ACTION-IF-ARMv5],[ACTION-IF-NO-ARMv5])
+#
+# DESCRIPTION
+#
+# AX_DETECT_ARMV5 detects from the compiler settings if the target is of
+# type ARMv5. It is intended mostly for cross compiling to be able to collect
+# more information about the target architecture and features. The user can
+# overwrite the detection by using the option --enable-armv5core or
+# --disable-armv5core.
+# It works by detecting the compiler's macros __ARM_ARCH_5__, __ARM_ARCH_5E__,
+# __ARM_ARCH_5T__, __ARM_ARCH_5TE__ and __ARM_ARCH_5TEJ__. These are set in
+# gcc compilers when they are configured to create code for ARMv5 cores.
+# This macro cannot detect the correct target's features if the compiler is
+# not correctly configured to reflect the target's features.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Juergen Borleis <jbe@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_DETECT_ARMV5],
+ [AC_REQUIRE([AC_PROG_CC])
+dnl
+dnl Give the user the possibility to overwrite the auto detection
+dnl
+ AC_ARG_ENABLE([armv5core],
+ [AS_HELP_STRING([--enable-armv5core],
+ [Enable optimizations for ARMv5 cores @<:@default=auto@:>@])],
+ [ax_armv5core="${enableval}"],
+ [ax_armv5core=auto])
+
+ AC_CACHE_CHECK([for ARMv5 target core], [ax_cv_armv5core],
+ [ax_cv_armv5core=${ax_armv5core}])
+dnl AC_MSG_RESULT([${ax_cv_armv5core}])
+
+ if test "x${ax_cv_armv5core}" = "xauto"; then
+ if test "x$GCC" != "xyes"; then
+dnl only for GCC we know it works in this way
+ AC_MSG_ERROR([Cannot autodetect the architecture for non GCC compilers])
+ else
+ AC_MSG_CHECKING(if target's core is of type ARMv5)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[
+#undef THIS_IS_V5
+#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5E__) || \
+defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) || \
+defined(__ARM_ARCH_5TEJ__)
+# define THIS_IS_V5 1
+#endif
+int foo = THIS_IS_V5;
+ ]]) dnl AC_LANG_PROGRAM
+ ],
+ [ax_cv_armv5core=yes],
+ [ax_cv_armv5core=no],
+ [ARMv5 core]); dnl AC_COMPILE_IFELSE
+ AC_MSG_RESULT([${ax_cv_armv5core}]);
+ fi
+ fi
+
+ case "x${ax_cv_armv5core}" in
+ "xyes")
+ $1
+ ;;
+ "xno")
+ $2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown setting for ARMv5 architecture: '${ax_cv_armv5core}'.])
+ ;;
+ esac
+]) dnl AC_DEFUN
diff --git a/rules/templates/template-m4-macros/ax_armv6_detection.m4 b/rules/templates/template-m4-macros/ax_armv6_detection.m4
new file mode 100644
index 000000000..4bca085d2
--- /dev/null
+++ b/rules/templates/template-m4-macros/ax_armv6_detection.m4
@@ -0,0 +1,101 @@
+#
+# SYNOPSIS
+#
+# AX_DETECT_ARMV6([ACTION-IF-ARMv6],[ACTION-IF-NO-ARMv6])
+#
+# DESCRIPTION
+#
+# AX_DETECT_ARMV6 detects from the compiler settings if the target is of
+# type ARMv6. It is intended mostly for cross compiling to be able to collect
+# more information about the target architecture and features. The user can
+# overwrite the detection by using the option --enable-armv6core or
+# --disable-armv6core.
+# It works by detecting the compiler's macros __ARM_ARCH_6__, __ARM_ARCH_6J__,
+# __ARM_ARCH_6K__, __ARM_ARCH_6Z__, __ARM_ARCH_6ZK__ and __ARM_ARCH_6T2__.
+# These are set in gcc compilers when they are configured to create code for
+# ARMv6 cores.
+# This macro cannot detect the correct target's features if the compiler is
+# not correctly configured to reflect the target's features.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Juergen Borleis <jbe@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_DETECT_ARMV6],
+ [AC_REQUIRE([AC_PROG_CC])
+dnl
+dnl Give the user the possibility to overwrite the auto detection
+dnl
+ AC_ARG_ENABLE([armv6core],
+ [AS_HELP_STRING([--enable-armv6core],
+ [Enable optimizations for ARMv6 cores @<:@default=auto@:>@])],
+ [ax_armv6core="${enableval}"],
+ [ax_armv6core=auto])
+
+ AC_CACHE_CHECK([for ARMv6 target core], [ax_cv_armv6core],
+ [ax_cv_armv6core=${ax_armv6core}])
+dnl AC_MSG_RESULT([${ax_cv_armv6core}])
+
+ if test "x${ax_cv_armv6core}" = "xauto"; then
+ if test "x$GCC" != "xyes"; then
+dnl only for GCC we know it works in this way
+ AC_MSG_ERROR([Cannot autodetect the architecture for non GCC compilers])
+ else
+ AC_MSG_CHECKING(if target's core is of type ARMv6)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[
+#undef THIS_IS_V6
+#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
+defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
+defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
+# define THIS_IS_V6 1
+#endif
+int foo = THIS_IS_V6;
+ ]]) dnl AC_LANG_PROGRAM
+ ],
+ [ax_cv_armv6core=yes],
+ [ax_cv_armv6core=no],
+ [ARMv6 core]); dnl AC_COMPILE_IFELSE
+ AC_MSG_RESULT([${ax_cv_armv6core}]);
+ fi
+ fi
+
+ case "x${ax_cv_armv6core}" in
+ "xyes")
+ $1
+ ;;
+ "xno")
+ $2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown setting for ARMv6 architecture: '${ax_cv_armv6core}'.])
+ ;;
+ esac
+]) dnl AC_DEFUN
diff --git a/rules/templates/template-m4-macros/ax_armv7_detection.m4 b/rules/templates/template-m4-macros/ax_armv7_detection.m4
new file mode 100644
index 000000000..70050ec2b
--- /dev/null
+++ b/rules/templates/template-m4-macros/ax_armv7_detection.m4
@@ -0,0 +1,98 @@
+#
+# SYNOPSIS
+#
+# AX_DETECT_ARMV7([ACTION-IF-ARMv7],[ACTION-IF-NO-ARMv7])
+#
+# DESCRIPTION
+#
+# AX_DETECT_ARMV7 detects from the compiler settings if the target is of
+# type ARMv7. It is intended mostly for cross compiling to be able to collect
+# more information about the target architecture and features. The user can
+# overwrite the detection by using the option --enable-armv7core or
+# --disable-armv7core.
+# It works by detecting the compiler's macros __ARM_ARCH_7A__, __ARM_ARCH_7M__.
+# These are set in gcc compilers when they are configured to create code for
+# ARMv6 cores.
+# This macro cannot detect the correct target's features if the compiler is
+# not correctly configured to reflect the target's features.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Juergen Borleis <jbe@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_DETECT_ARMV7],
+ [AC_REQUIRE([AC_PROG_CC])
+dnl
+dnl Give the user the possibility to overwrite the auto detection
+dnl
+ AC_ARG_ENABLE([armv7core],
+ [AS_HELP_STRING([--enable-armv7core],
+ [Enable optimizations for ARMv7 cores @<:@default=auto@:>@])],
+ [ax_armv7core="${enableval}"],
+ [ax_armv7core=auto])
+
+ AC_CACHE_CHECK([for ARMv7 target core], [ax_cv_armv7core],
+ [ax_cv_armv7core=${ax_armv6core}])
+dnl AC_MSG_RESULT([${ax_cv_armv7core}])
+
+ if test "x${ax_cv_armv7core}" = "xauto"; then
+ if test "x$GCC" != "xyes"; then
+dnl only for GCC we know it works in this way
+ AC_MSG_ERROR([Cannot autodetect the architecture for non GCC compilers])
+ else
+ AC_MSG_CHECKING(if target's core is of type ARMv7)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[
+#undef THIS_IS_V7
+#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7M__)
+# define THIS_IS_V7 1
+#endif
+int foo = THIS_IS_V7;
+ ]]) dnl AC_LANG_PROGRAM
+ ],
+ [ax_cv_armv7core=yes],
+ [ax_cv_armv7core=no],
+ [ARMv6 core]); dnl AC_COMPILE_IFELSE
+ AC_MSG_RESULT([${ax_cv_armv7core}]);
+ fi
+ fi
+
+ case "x${ax_cv_armv7core}" in
+ "xyes")
+ $1
+ ;;
+ "xno")
+ $2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown setting for ARMv7 architecture: '${ax_cv_armv7core}'.])
+ ;;
+ esac
+]) dnl AC_DEFUN
diff --git a/rules/templates/template-m4-macros/ax_floating_point.m4 b/rules/templates/template-m4-macros/ax_floating_point.m4
new file mode 100644
index 000000000..48970cc53
--- /dev/null
+++ b/rules/templates/template-m4-macros/ax_floating_point.m4
@@ -0,0 +1,97 @@
+#
+# SYNOPSIS
+#
+# AX_HARDWARE_FP([ACTION-IF-HARD-FLOAT],[ACTION-IF-SOFT-FLOAT])
+#
+# DESCRIPTION
+#
+# AX_DETECT_FLOAT detects the compiler settings about floating point usage.
+# It is intended mostly for cross compiling to be able to collect more
+# information about the target architecture and features. The user can
+# overwrite the detection by using the option --enable-hardware-fp or
+# --disable-hardware-fp.
+# It works by detecting the compiler's macro __SOFTFP__. This one is set in
+# gcc compilers when there is no hardware floating point available.
+# This macro cannot detect the correct target's features if the compiler is
+# not correctly configured to reflect the target's features.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Juergen Borleis <jbe@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_HARDWARE_FP],
+ [AC_REQUIRE([AC_PROG_CC])
+dnl
+dnl Give the user the possibility to overwrite the auto detection
+dnl
+ AC_ARG_ENABLE([hardware-fp],
+ [AS_HELP_STRING([--enable-hardware-fp],
+ [Enable hardware floating point @<:@default=auto@:>@])],
+ [ax_hardware_fp="${enableval}"],
+ [ax_hardware_fp=auto])
+
+ AC_CACHE_CHECK([for hardware fp support], [ax_cv_hardware_fp],
+ [ax_cv_hardware_fp=${ax_hardware_fp}])
+dnl AC_MSG_RESULT([${ax_cv_hardware_fp}])
+
+ if test "x${ax_cv_hardware_fp}" = "xauto"; then
+ if test "x$GCC" != "xyes"; then
+dnl only for GCC we know it works in this way
+ AC_MSG_ERROR([Cannot autodetect the hardware floating point feature for non GCC compilers])
+ else
+ AC_MSG_CHECKING(if hardware fp is supported)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[
+#define HARD_FP_SUPPORT 1
+#if defined(__SOFTFP__)
+# undef HARD_FP_SUPPORT
+#endif
+int foo = HARD_FP_SUPPORT;
+ ]]) dnl AC_LANG_PROGRAM
+ ],
+ [ax_cv_hardware_fp=yes],
+ [ax_cv_hardware_fp=no],
+ [hardware FP support]); dnl AC_COMPILE_IFELSE
+ AC_MSG_RESULT([${ax_cv_hardware_fp}]);
+ fi
+ fi
+
+ case "x${ax_cv_hardware_fp}" in
+ "xyes")
+ $1
+ ;;
+ "xno")
+ $2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown setting for hardware floating point usage: '${ax_cv_hardware_fp}'.])
+ ;;
+ esac
+]) dnl AC_DEFUN
diff --git a/rules/templates/template-m4-macros/pkg.m4 b/rules/templates/template-m4-macros/pkg.m4
new file mode 100644
index 000000000..4d42fdd58
--- /dev/null
+++ b/rules/templates/template-m4-macros/pkg.m4
@@ -0,0 +1,157 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+#
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_default([$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ AC_MSG_RESULT([no])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+ ])
+elif test $pkg_failed = untried; then
+ AC_MSG_RESULT([no])
+ m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+ ])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ $3
+fi[]dnl
+])# PKG_CHECK_MODULES