diff configure.in @ 106009:e6af95c4c862

Use gcc-generated dependency files if we can (GNU Make and gcc required). * Makefile.in: If AUTO_DEPEND is defined, make gcc generate dependency files in deps/. Include those files into Makefile. * config.in: Generated (AUTO_DEPEND). * configure.in: --enable-autodepend is new. Check for GNU Make and that gcc supports -MMD -MF. Define AUTO_DEPEND if we can use gcc and GNU make to generate dependencies.
author Jan Djärv <jan.h.d@swipnet.se>
date Sat, 14 Nov 2009 15:17:38 +0000
parents 73190af7ce73
children cd4cbab8bb21
line wrap: on
line diff
--- a/configure.in	Sat Nov 14 15:15:32 2009 +0000
+++ b/configure.in	Sat Nov 14 15:17:38 2009 +0000
@@ -286,6 +286,13 @@
    PROFILING_LDFLAGS=
 fi
 
+AC_ARG_ENABLE(autodepend,
+[AS_HELP_STRING([--enable-autodepend],
+		[automatically generate dependencies to .h-files.
+ 		 Requires GNU Make and Gcc. Enabled if GNU Make and Gcc is
+ 		 found])],
+[ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
+
 #### Make srcdir absolute, if it isn't already.  It's important to
 #### avoid running the path through pwd unnecessarily, since pwd can
 #### give you automounter prefixes, which can go away.  We do all this
@@ -1229,6 +1236,32 @@
 dnl check for Make feature
 AC_PROG_MAKE_SET
 
+dnl check for GNU Make if we have GCC and autodepend is on.
+if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
+   AC_MSG_CHECKING([whether we are using GNU Make])
+   HAVE_GNU_MAKE=no
+   testval=`make --version 2>/dev/null | grep 'GNU Make'`
+   if test "x$testval" != x; then
+      HAVE_GNU_MAKE=yes
+   else
+      ac_enable_autodepend=no
+   fi
+   AC_MSG_RESULT([$HAVE_GNU_MAKE])
+   if test $HAVE_GNU_MAKE = yes; then
+      AC_MSG_CHECKING([whether gcc understands -MMD -MF])
+      SAVE_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -MMD -MF deps.d"
+      AC_TRY_COMPILE([], [], , ac_enable_autodepend=no)
+      CFLAGS="$SAVE_CFLAGS"
+      test -f deps.d || ac_enable_autodepend=no
+      rm -rf deps.d
+      AC_MSG_RESULT([$ac_enable_autodepend])
+   fi
+   if test $ac_enable_autodepend = yes; then
+      AC_DEFINE(AUTO_DEPEND, 1, [Generate dependencies with gcc.])
+   fi
+fi
+
 dnl checks for operating system services
 AC_SYS_LONG_FILE_NAMES