Re: Bug in AX_APPEND_LINK_FLAGS
Mike Frysinger <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.archive-maintainers |
|---|---|
| Organization | wh0rd.org |
| Message-ID | <[email protected]> |
On Wednesday 01 January 2014 18:55:44 Peter Johansson wrote:
> On 01/02/2014 03:59 AM, Mike Frysinger wrote:
> > blah, it's because i misused the AC_REQUIRE helper. it not only makes
> > sure the func is available, but then also calls it. i don't know of a
> > way to get the desired behavior (an m4 error when the macro isn't
> > available) other than AC_REQUIRE.
>
> I think a combination of 'm4_ifndef' and 'm4_fatal' could make it with
> something like:
>
> m4_ifndef([AX_FOO], [m4_fatal])
>
> I haven't tested though.
this seems to work. what do you think of this patch ?
i tried to implement multiple macro support, but i couldn't get m4_foreach to
play nicely with quoting (m4 quoting rules make my head hurt).
it also kind of sucks in that we're adding a dependency on another ax file, but
maybe that's not a big deal ? it'll get found automatically for people who
are running against the whole archive ...
-mike
diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4
index 1f8e708..dc7b866 100644
--- a/m4/ax_append_compile_flags.m4
+++ b/m4/ax_append_compile_flags.m4
@@ -54,11 +54,11 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 3
+#serial 4
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
-[AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
-AC_REQUIRE([AX_APPEND_FLAG])
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
done
diff --git a/m4/ax_append_link_flags.m4 b/m4/ax_append_link_flags.m4
index 48cbd4b..c73ddaf 100644
--- a/m4/ax_append_link_flags.m4
+++ b/m4/ax_append_link_flags.m4
@@ -52,11 +52,11 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 3
+#serial 4
AC_DEFUN([AX_APPEND_LINK_FLAGS],
-[AC_REQUIRE([AX_CHECK_LINK_FLAG])
-AC_REQUIRE([AX_APPEND_FLAG])
+[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3])
done
diff --git a/m4/ax_cflags_force_c89.m4 b/m4/ax_cflags_force_c89.m4
index 19ada7f..1597b25 100644
--- a/m4/ax_cflags_force_c89.m4
+++ b/m4/ax_cflags_force_c89.m4
@@ -55,7 +55,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 8
+#serial 9
AC_DEFUN([AX_CFLAGS_FORCE_C89],[dnl
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
@@ -83,7 +83,7 @@ done
AC_LANG_RESTORE
])
AS_VAR_POPDEF([FLAGS])dnl
-AC_REQUIRE([AX_APPEND_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
diff --git a/m4/ax_cflags_strict_prototypes.m4 b/m4/ax_cflags_strict_prototypes.m4
index 2ac34be..3ad4bf0 100644
--- a/m4/ax_cflags_strict_prototypes.m4
+++ b/m4/ax_cflags_strict_prototypes.m4
@@ -58,7 +58,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 12
+#serial 13
AC_DEFUN([AX_FLAGS_STRICT_PROTOTYPES],[dnl
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
@@ -96,7 +96,7 @@ esac
FLAGS="$ac_save_[]FLAGS"
])
AS_VAR_POPDEF([FLAGS])dnl
-AC_REQUIRE([AX_APPEND_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4
index 0fa3e18..1f07799 100644
--- a/m4/ax_cflags_warn_all.m4
+++ b/m4/ax_cflags_warn_all.m4
@@ -58,7 +58,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 14
+#serial 15
AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
@@ -84,7 +84,7 @@ done
FLAGS="$ac_save_[]FLAGS"
])
AS_VAR_POPDEF([FLAGS])dnl
-AC_REQUIRE([AX_APPEND_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
new file mode 100644
index 0000000..e6a167d
--- /dev/null
+++ b/m4/ax_require_defined.m4
@@ -0,0 +1,35 @@
+#
===========================================================================
+# http://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 <[email protected]>
+#
+# 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 1
+
+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
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJSxbSQAAoJEEFjO5/oN/WBDTQP/j7CZuWBF2QPzC3SbHFNkxc/ AP5a/9e3b5F28MhPB6mhIza5Yxx6fn3cEf+K/6UBv+1Q2ZzzhlGolRE91n0oWCUJ JV9kHAlyB/JFUYfjfZQaSmkMrMe4gdUPqEimcrwxtGtIpAyZv+IcchzlT+uGAIWK mephbN+M4CKIqFd0L7wEpQx5jOUEl4IHRPBn1a1VrJLxZYywaKw41yPiRgnBTqVn p0tF3hgMz2S7KAYwrrPlLAUr3CvAl8ZDzOY9BRjmg2i4XpIqTj3VZd1hUbduk7tf P/eGtXwyIYJmdiFRF/r+qStSBW5PYXlLaEgtl0iEnmuKi0u5G0ytzRYfpie9njrt /Q7eCnTQ8QfrIEaotDHv7jg1mFoaF3NbxeNY6dG5K5w5j53U0wXfSheQl99feuOP zUzwO0zmsA0za3Q2PysPAR1+UQq0lcDOxH+N/oHIcmT9xGBDOOPR2DTitVsmwX2u 8OazdJ+BZ1EkjsP6DtrtSuYqfvqYLi7IKy0e1EMG+8P/ZhLX/mom02QviSLrRdok KNdSaV7OqfXUIUQKaIrFMRB/HUYVIJt/92fdGwRCvxcmCedwsmLdq/4/NdC6CIPt dUixdOo+MUD4VObBW67uUAkPs/mSeuZ3ViWt/wI0h2VDFJQRH3GIu3Pz7i5f1HMv 3OQoRXiDkUzZfGAY39Zp =NCK3 -----END PGP SIGNATURE-----