Use gcc's built-in dependency generation, thanks to Adam Strzelecki
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Oct 2009 03:38:01 +0000
changeset 333461ea9005fddf
parent 3333 b334b4f7dfa0
child 3335 b8d313de8a65
Use gcc's built-in dependency generation, thanks to Adam Strzelecki
Makefile.in
build-scripts/makedep.sh
configure.in
     1.1 --- a/Makefile.in	Sat Oct 03 16:23:16 2009 +0000
     1.2 +++ b/Makefile.in	Sun Oct 04 03:38:01 2009 +0000
     1.3 @@ -3,7 +3,6 @@
     1.4  top_builddir = .
     1.5  srcdir  = @srcdir@
     1.6  objects = build
     1.7 -depend	= build-deps
     1.8  prefix = @prefix@
     1.9  exec_prefix = @exec_prefix@
    1.10  bindir	= @bindir@
    1.11 @@ -33,11 +32,10 @@
    1.12  WINDRES	= @WINDRES@
    1.13  
    1.14  TARGET  = libSDL.la
    1.15 -SOURCES = @SOURCES@
    1.16  OBJECTS = @OBJECTS@
    1.17 +VERSION_OBJECTS = @VERSION_OBJECTS@
    1.18  
    1.19  SDLMAIN_TARGET = libSDLmain.a
    1.20 -SDLMAIN_SOURCES = @SDLMAIN_SOURCES@
    1.21  SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
    1.22  
    1.23  # PS3 SPU programs
    1.24 @@ -74,20 +72,15 @@
    1.25  update-revision:
    1.26  	$(SHELL) $(auxdir)/updaterev.sh
    1.27  
    1.28 -.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
    1.29 -depend: update-revision
    1.30 -	@SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
    1.31 -	$(SHELL) $(auxdir)/makedep.sh
    1.32 -	@for src in $(SDLMAIN_SOURCES); do \
    1.33 -	    obj=`echo $$src | sed -e 's|.*/||' -e 's|\.[^\.]*$$|.o|'`; \
    1.34 -	    echo "\$$(objects)/$$obj: $$src" >>$(depend); \
    1.35 -	    echo "	\$$(CC) \$$(CFLAGS) \$$(EXTRA_CFLAGS) -c $$src -o \$$@" >>$(depend); \
    1.36 -	done
    1.37 +.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
    1.38  
    1.39 -include $(depend)
    1.40 +-include $(OBJECTS:.lo=.d)
    1.41 +@DEPENDS@
    1.42 +@VERSION_DEPENDS@
    1.43 +@SDLMAIN_DEPENDS@
    1.44  
    1.45 -$(objects)/$(TARGET): $(OBJECTS)
    1.46 -	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
    1.47 +$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
    1.48 +	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
    1.49  
    1.50  $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
    1.51  	$(AR) cru $@ $(SDLMAIN_OBJECTS)
    1.52 @@ -147,7 +140,7 @@
    1.53  distclean: clean
    1.54  	rm -f Makefile include/SDL_config.h sdl-config
    1.55  	rm -f SDL.qpg
    1.56 -	rm -f config.status config.cache config.log libtool $(depend)
    1.57 +	rm -f config.status config.cache config.log libtool
    1.58  	rm -rf $(srcdir)/autom4te*
    1.59  	find $(srcdir) \( \
    1.60  	    -name '*~' -o \
     2.1 --- a/build-scripts/makedep.sh	Sat Oct 03 16:23:16 2009 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,87 +0,0 @@
     2.4 -#!/bin/sh
     2.5 -#
     2.6 -# Generate dependencies from a list of source files
     2.7 -
     2.8 -# Check to make sure our environment variables are set
     2.9 -if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$output" = x; then
    2.10 -    echo "SOURCES, INCLUDE, and output needs to be set"
    2.11 -    exit 1
    2.12 -fi
    2.13 -cache_prefix=".#$$"
    2.14 -
    2.15 -generate_var()
    2.16 -{
    2.17 -    echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g'
    2.18 -}
    2.19 -
    2.20 -search_deps()
    2.21 -{
    2.22 -    base=`echo $1 | sed 's|/[^/]*$||'`
    2.23 -    grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
    2.24 -    while read file
    2.25 -    do cache=${cache_prefix}_`generate_var $file`
    2.26 -       if test -f $cache; then
    2.27 -          : # We already ahve this cached
    2.28 -       else
    2.29 -           : >$cache
    2.30 -           for path in $base `echo $INCLUDE | sed 's|-I||g'`
    2.31 -           do dep="$path/$file"
    2.32 -              if test -f "$dep"; then
    2.33 -                 echo "	$dep \\" >>$cache
    2.34 -                 search_deps $dep >>$cache
    2.35 -                 break
    2.36 -              fi
    2.37 -           done
    2.38 -       fi
    2.39 -       cat $cache
    2.40 -    done
    2.41 -}
    2.42 -
    2.43 -:>${output}.new
    2.44 -for src in $SOURCES
    2.45 -do  echo "Generating dependencies for $src"
    2.46 -    ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
    2.47 -    if test x"$ext" = x"rc"; then
    2.48 -        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
    2.49 -    else
    2.50 -        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
    2.51 -    fi
    2.52 -    echo "\$(objects)/$obj: $src \\" >>${output}.new
    2.53 -    search_deps $src | sort | uniq >>${output}.new
    2.54 -    case $ext in
    2.55 -        c) cat >>${output}.new <<__EOF__
    2.56 -
    2.57 -	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
    2.58 -
    2.59 -__EOF__
    2.60 -        ;;
    2.61 -        cc) cat >>${output}.new <<__EOF__
    2.62 -
    2.63 -	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
    2.64 -
    2.65 -__EOF__
    2.66 -        ;;
    2.67 -        m) cat >>${output}.new <<__EOF__
    2.68 -
    2.69 -	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
    2.70 -
    2.71 -__EOF__
    2.72 -        ;;
    2.73 -        S) cat >>${output}.new <<__EOF__
    2.74 -
    2.75 -	\$(LIBTOOL)  --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
    2.76 -
    2.77 -__EOF__
    2.78 -        ;;
    2.79 -        rc) cat >>${output}.new <<__EOF__
    2.80 -
    2.81 -	\$(WINDRES) $src \$@
    2.82 -
    2.83 -__EOF__
    2.84 -        ;;
    2.85 -        *)   echo "Unknown file extension: $ext";;
    2.86 -    esac
    2.87 -    echo "" >>${output}.new
    2.88 -done
    2.89 -mv ${output}.new ${output}
    2.90 -rm -f ${cache_prefix}*
     3.1 --- a/configure.in	Sat Oct 03 16:23:16 2009 +0000
     3.2 +++ b/configure.in	Sun Oct 04 03:38:01 2009 +0000
     3.3 @@ -2555,7 +2555,7 @@
     3.4          #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
     3.5          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
     3.6          # The Win32 platform requires special setup
     3.7 -        SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
     3.8 +        VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
     3.9          SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
    3.10          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
    3.11          SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
    3.12 @@ -2769,15 +2769,28 @@
    3.13      SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
    3.14  fi
    3.15  
    3.16 -OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
    3.17 -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
    3.18 -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
    3.19 -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
    3.20 -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
    3.21 -OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
    3.22 +OBJECTS=`echo $SOURCES`
    3.23 +DEPENDS=`echo $SOURCES`
    3.24 +for EXT in asm cc m c S; do
    3.25 +    OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
    3.26 +    DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.'$EXT',\\
    3.27 +$(objects)/\2.lo: \1/\2.'$EXT'\\
    3.28 +	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -MMD -MT \$@ -c \$< -o \$@,g'`
    3.29 +done
    3.30  
    3.31 -SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
    3.32 -SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
    3.33 +VERSION_OBJECTS=`echo $VERSION_SOURCES`
    3.34 +VERSION_DEPENDS=`echo $VERSION_SOURCES`
    3.35 +VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
    3.36 +VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
    3.37 +$(objects)/\2.o: \1/\2.rc\\
    3.38 +	\$(WINDRES) \$< \$@,g'`
    3.39 +
    3.40 +SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
    3.41 +SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
    3.42 +SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
    3.43 +SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
    3.44 +$(objects)/\2.o: \1/\2.c\\
    3.45 +	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -MMD -MT \$@ -c \$< -o \$@,g'`
    3.46  
    3.47  # Set runtime shared library paths as needed
    3.48  
    3.49 @@ -2829,10 +2842,12 @@
    3.50  dnl Expand the sources and objects needed to build the library
    3.51  AC_SUBST(ac_aux_dir)
    3.52  AC_SUBST(INCLUDE)
    3.53 -AC_SUBST(SOURCES)
    3.54  AC_SUBST(OBJECTS)
    3.55 -AC_SUBST(SDLMAIN_SOURCES)
    3.56 +AC_SUBST(DEPENDS)
    3.57 +AC_SUBST(VERSION_OBJECTS)
    3.58 +AC_SUBST(VERSION_DEPENDS)
    3.59  AC_SUBST(SDLMAIN_OBJECTS)
    3.60 +AC_SUBST(SDLMAIN_DEPENDS)
    3.61  AC_SUBST(BUILD_CFLAGS)
    3.62  AC_SUBST(EXTRA_CFLAGS)
    3.63  AC_SUBST(BUILD_LDFLAGS)
    3.64 @@ -2841,7 +2856,4 @@
    3.65  
    3.66  AC_OUTPUT([
    3.67      Makefile sdl-config SDL.spec sdl.pc
    3.68 -], [
    3.69 -    : >build-deps
    3.70 -    if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
    3.71  ])