changeset 3334:61ea9005fddf

Use gcc's built-in dependency generation, thanks to Adam Strzelecki
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Oct 2009 03:38:01 +0000
parents b334b4f7dfa0
children b8d313de8a65
files Makefile.in build-scripts/makedep.sh configure.in
diffstat 3 files changed, 35 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Sat Oct 03 16:23:16 2009 +0000
+++ b/Makefile.in	Sun Oct 04 03:38:01 2009 +0000
@@ -3,7 +3,6 @@
 top_builddir = .
 srcdir  = @srcdir@
 objects = build
-depend	= build-deps
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 bindir	= @bindir@
@@ -33,11 +32,10 @@
 WINDRES	= @WINDRES@
 
 TARGET  = libSDL.la
-SOURCES = @SOURCES@
 OBJECTS = @OBJECTS@
+VERSION_OBJECTS = @VERSION_OBJECTS@
 
 SDLMAIN_TARGET = libSDLmain.a
-SDLMAIN_SOURCES = @SDLMAIN_SOURCES@
 SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
 
 # PS3 SPU programs
@@ -74,20 +72,15 @@
 update-revision:
 	$(SHELL) $(auxdir)/updaterev.sh
 
-.PHONY: all update-revision depend install install-bin install-hdrs install-lib install-data install-man uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data uninstall-man clean distclean dist
-depend: update-revision
-	@SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
-	$(SHELL) $(auxdir)/makedep.sh
-	@for src in $(SDLMAIN_SOURCES); do \
-	    obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.o|'`; \
-	    echo "\$$(objects)/$$obj: $$src" >>$(depend); \
-	    echo "	\$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \
-	done
+.PHONY: all update-revision install install-bin install-hdrs install-lib install-data install-man uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data uninstall-man clean distclean dist
 
-include $(depend)
+-include $(OBJECTS:.lo=.d)
+@DEPENDS@
+@VERSION_DEPENDS@
+@SDLMAIN_DEPENDS@
 
-$(objects)/$(TARGET): $(OBJECTS)
-	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
+$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
+	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
 
 $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
 	$(AR) cru $@ $(SDLMAIN_OBJECTS)
@@ -147,7 +140,7 @@
 distclean: clean
 	rm -f Makefile include/SDL_config.h sdl-config
 	rm -f SDL.qpg
-	rm -f config.status config.cache config.log libtool $(depend)
+	rm -f config.status config.cache config.log libtool
 	rm -rf $(srcdir)/autom4te*
 	find $(srcdir) \( \
 	    -name '*~' -o \
--- a/build-scripts/makedep.sh	Sat Oct 03 16:23:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#!/bin/sh
-#
-# Generate dependencies from a list of source files
-
-# Check to make sure our environment variables are set
-if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$output" = x; then
-    echo "SOURCES, INCLUDE, and output needs to be set"
-    exit 1
-fi
-cache_prefix=".#$$"
-
-generate_var()
-{
-    echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g'
-}
-
-search_deps()
-{
-    base=`echo $1 | sed 's|/[^/]*$||'`
-    grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
-    while read file
-    do cache=${cache_prefix}_`generate_var $file`
-       if test -f $cache; then
-          : # We already ahve this cached
-       else
-           : >$cache
-           for path in $base `echo $INCLUDE | sed 's|-I||g'`
-           do dep="$path/$file"
-              if test -f "$dep"; then
-                 echo "	$dep \\" >>$cache
-                 search_deps $dep >>$cache
-                 break
-              fi
-           done
-       fi
-       cat $cache
-    done
-}
-
-:>${output}.new
-for src in $SOURCES
-do  echo "Generating dependencies for $src"
-    ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
-    if test x"$ext" = x"rc"; then
-        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
-    else
-        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
-    fi
-    echo "\$(objects)/$obj: $src \\" >>${output}.new
-    search_deps $src | sort | uniq >>${output}.new
-    case $ext in
-        c) cat >>${output}.new <<__EOF__
-
-	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
-
-__EOF__
-        ;;
-        cc) cat >>${output}.new <<__EOF__
-
-	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
-
-__EOF__
-        ;;
-        m) cat >>${output}.new <<__EOF__
-
-	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
-
-__EOF__
-        ;;
-        S) cat >>${output}.new <<__EOF__
-
-	\$(LIBTOOL)  --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
-
-__EOF__
-        ;;
-        rc) cat >>${output}.new <<__EOF__
-
-	\$(WINDRES) $src \$@
-
-__EOF__
-        ;;
-        *)   echo "Unknown file extension: $ext";;
-    esac
-    echo "" >>${output}.new
-done
-mv ${output}.new ${output}
-rm -f ${cache_prefix}*
--- a/configure.in	Sat Oct 03 16:23:16 2009 +0000
+++ b/configure.in	Sun Oct 04 03:38:01 2009 +0000
@@ -2555,7 +2555,7 @@
         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
         # The Win32 platform requires special setup
-        SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
+        VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
@@ -2769,15 +2769,28 @@
     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
 fi
 
-OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
-OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
-OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
-OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
-OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
-OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
+OBJECTS=`echo $SOURCES`
+DEPENDS=`echo $SOURCES`
+for EXT in asm cc m c S; do
+    OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
+    DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.'$EXT',\\
+$(objects)/\2.lo: \1/\2.'$EXT'\\
+	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -MMD -MT \$@ -c \$< -o \$@,g'`
+done
 
-SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
-SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
+VERSION_OBJECTS=`echo $VERSION_SOURCES`
+VERSION_DEPENDS=`echo $VERSION_SOURCES`
+VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
+VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
+$(objects)/\2.o: \1/\2.rc\\
+	\$(WINDRES) \$< \$@,g'`
+
+SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
+SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
+SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
+SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
+$(objects)/\2.o: \1/\2.c\\
+	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -MMD -MT \$@ -c \$< -o \$@,g'`
 
 # Set runtime shared library paths as needed
 
@@ -2829,10 +2842,12 @@
 dnl Expand the sources and objects needed to build the library
 AC_SUBST(ac_aux_dir)
 AC_SUBST(INCLUDE)
-AC_SUBST(SOURCES)
 AC_SUBST(OBJECTS)
-AC_SUBST(SDLMAIN_SOURCES)
+AC_SUBST(DEPENDS)
+AC_SUBST(VERSION_OBJECTS)
+AC_SUBST(VERSION_DEPENDS)
 AC_SUBST(SDLMAIN_OBJECTS)
+AC_SUBST(SDLMAIN_DEPENDS)
 AC_SUBST(BUILD_CFLAGS)
 AC_SUBST(EXTRA_CFLAGS)
 AC_SUBST(BUILD_LDFLAGS)
@@ -2841,7 +2856,4 @@
 
 AC_OUTPUT([
     Makefile sdl-config SDL.spec sdl.pc
-], [
-    : >build-deps
-    if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
 ])