Merge branch 'master' of git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev
[xfstests-dev.git] / m4 / package_utilies.m4
index efcc0a104dacfbccb5774d19d3d61f746a6acd14..726406c8afad2e44e8a573e2cea0c73e6a9f5d60 100644 (file)
@@ -10,10 +10,28 @@ AC_DEFUN([AC_PACKAGE_NEED_UTILITY],
     fi
   ])
 
+#
+#check compiler can generate dependencies
+#
+AC_DEFUN([AC_PACKAGE_GCC_DEPS],
+  [AC_CACHE_CHECK(whether gcc -MM is supported,
+                  ac_cv_gcc_nodeps,
+                  [cat > conftest.c <<EOF
+                  #include <stdio.h>
+                  int main() { exit(0); }
+EOF
+                  ac_cv_gcc_nodeps=no
+                  if ${CC} -MM conftest.c >/dev/null 2>&1; then
+                     ac_cv_gcc_nodeps=yes
+                  fi
+                  rm -f conftest.c a.out
+                  ])
+  ])
+
 #
 # Generic macro, sets up all of the global build variables.
 # The following environment variables may be set to override defaults:
-#  CC MAKE LIBTOOL TAR ZIP MAKEDEPEND AWK SED ECHO SORT
+#  CC MAKE LIBTOOL TAR ZIP eMAKEDEPEND AWK SED ECHO SORT
 #  MSGFMT MSGMERGE RPM
 #
 AC_DEFUN([AC_PACKAGE_UTILITIES],
@@ -54,10 +72,11 @@ AC_DEFUN([AC_PACKAGE_UTILITIES],
     zip=$ZIP
     AC_SUBST(zip)
 
-    if test -z "$MAKEDEPEND"; then
-        AC_PATH_PROG(MAKEDEPEND, makedepend, /bin/true)
+    AC_PACKAGE_GCC_DEPS()
+    makedepend="$cc -MM"
+    if test $ac_cv_gcc_nodeps = no; then
+       makedepend=/bin/true
     fi
-    makedepend=$MAKEDEPEND
     AC_SUBST(makedepend)
 
     if test -z "$AWK"; then
@@ -111,7 +130,7 @@ AC_DEFUN([AC_PACKAGE_UTILITIES],
 
     dnl .. and what version is rpm
     rpm_version=0
-    test -x "$RPM" && rpm_version=`$RPM --version \
+    test -n "$RPM" && test -x "$RPM" && rpm_version=`$RPM --version \
                         | awk '{print $NF}' | awk -F. '{V=1; print $V}'`
     AC_SUBST(rpm_version)
     dnl At some point in rpm 4.0, rpm can no longer build rpms, and