Use syscmd, ifelse, and sysval. Mainly as an exercise
[gnulib.git] / m4 / regex.m4
index bf4d194..073dac5 100644 (file)
@@ -1,31 +1,23 @@
 #serial 1
 
-dnl From grep.
+dnl Derived from code in GNU grep.
 
 AC_DEFUN(jm_WITH_REGEX,
   [
-    AC_ARG_WITH(included-regex,
-               [  --without-included-regex don't compile regex],
-               USE_REGEX=$withval,
-               USE_REGEX=yes)
+    dnl Even packages that don't use regex.c can use this macro.
+    dnl Of course, for them it doesn't do anything.
 
-    if test "$USE_REGEX" = yes; then
-
-      LIBOBJS="$LIBOBJS regex.o"
-
-    else
-      if test x = y; then
-       # This code is deliberately never run via ./configure.
-       # FIXME: this is a hack to make autoheader put the corresponding
-       # HAVE_* undef for this symbol in config.h.in.  This saves me the
-       # trouble of having to maintain the #undef in acconfig.h manually.
-       AC_CHECK_FUNCS(LIBC_REGEX)
-      fi
-      # Defining it this way (rather than via AC_DEFINE) short-circuits the
-      # autoheader check -- autoheader doesn't know it's already been taken
-      # care of by the hack above.
-      ac_kludge=HAVE_LIBC_REGEX
-      AC_DEFINE_UNQUOTED($ac_kludge)
-    fi
+    syscmd([test -f lib/regex.c])
+    ifelse(sysval, 0,
+      [
+       AC_ARG_WITH(included-regex,
+           [  --without-included-regex don't compile regex (use with caution)],
+                   jm_with_regex=$withval,
+                   jm_with_regex=yes)
+       if test "$jm_with_regex" = yes; then
+         LIBOBJS="$LIBOBJS regex.o"
+       fi
+      ],
+    )
   ]
 )