autoconf-archive-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in AX_APPEND_LINK_FLAGS


From: Mike Frysinger
Subject: Re: Bug in AX_APPEND_LINK_FLAGS
Date: Thu, 2 Jan 2014 13:48:45 -0500
User-agent: KMail/1.13.7 (Linux/3.12.1; KDE/4.6.5; x86_64; ; )

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 <address@hidden>
+#
+#   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

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]