Set a xy_given variable for a --enable/disable-xy option
authorMartin Willi <martin@revosec.ch>
Thu, 11 Mar 2010 07:50:12 +0000 (08:50 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 11 Mar 2010 07:50:12 +0000 (08:50 +0100)
This additional variable allows a check if an option was
explicitly given or implicitly set using the default.

m4/macros/enable-disable.m4

index 6d7959e..3d42365 100644 (file)
@@ -6,12 +6,14 @@ AC_DEFUN([ARG_ENABL_SET],
        [AC_ARG_ENABLE(
                [$1],
                AS_HELP_STRING([--enable-$1], [$2]),
        [AC_ARG_ENABLE(
                [$1],
                AS_HELP_STRING([--enable-$1], [$2]),
-               [if test x$enableval = xyes; then
+               [patsubst([$1], [-], [_])_given=true
+               if test x$enableval = xyes; then
                        patsubst([$1], [-], [_])=true
                 else
                        patsubst([$1], [-], [_])=false
                fi],
                        patsubst([$1], [-], [_])=true
                 else
                        patsubst([$1], [-], [_])=false
                fi],
-               patsubst([$1], [-], [_])=false
+               [patsubst([$1], [-], [_])=false
+               patsubst([$1], [-], [_])_given=false]
        )]
 )
 
        )]
 )
 
@@ -22,11 +24,13 @@ AC_DEFUN([ARG_DISBL_SET],
        [AC_ARG_ENABLE(
                [$1],
                AS_HELP_STRING([--disable-$1], [$2]),
        [AC_ARG_ENABLE(
                [$1],
                AS_HELP_STRING([--disable-$1], [$2]),
-               [if test x$enableval = xyes; then
+               [patsubst([$1], [-], [_])_given=true
+               if test x$enableval = xyes; then
                        patsubst([$1], [-], [_])=true
                 else
                        patsubst([$1], [-], [_])=false
                fi],
                        patsubst([$1], [-], [_])=true
                 else
                        patsubst([$1], [-], [_])=false
                fi],
-               patsubst([$1], [-], [_])=true
+               [patsubst([$1], [-], [_])=true
+               patsubst([$1], [-], [_])_given=false]
        )]
 )
        )]
 )