From c582699b937d8f15af8620e793bfb13ab5cc39ba Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 18 Feb 2011 11:19:34 -0800 Subject: [PATCH] Added a better way to include build rules in the Makefile Cleaned up dependencies on generating SDL_revision.h Fixed 'make install' if you are not building from a Mercurial repository --- Makefile.in | 18 ++++++++++-------- build-scripts/updaterev.sh | 2 +- configure | 34 +++++++++++++--------------------- configure.in | 21 ++++++++------------- 4 files changed, 32 insertions(+), 43 deletions(-) diff --git a/Makefile.in b/Makefile.in index 12b9097e7..2c48b98b6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,15 +108,12 @@ Makefile.in:; $(objects): $(SHELL) $(auxdir)/mkinstalldirs $@ -# To make sure parallel builds will not fail -include/SDL_revision.h: update-revision - update-revision: $(SHELL) $(auxdir)/updaterev.sh -.PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d) +.PHONY: all install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d) -$(objects)/$(TARGET): update-revision $(OBJECTS) $(VERSION_OBJECTS) +$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS) $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS) @@ -127,13 +124,18 @@ install: all install-bin install-hdrs install-lib install-data install-bin: $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir) $(INSTALL) -m 755 sdl-config $(DESTDIR)$(bindir)/sdl-config -install-hdrs: include/SDL_revision.h +install-hdrs: update-revision $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL for file in $(HDRS); do \ $(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL/$$file; \ done $(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL/SDL_config.h - $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h + if test -f include/SDL_revision.h; then \ + $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h; \ + else \ + $(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h; \ + fi + install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir) $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET) @@ -167,7 +169,7 @@ clean: if test -f test/Makefile; then (cd test; $(MAKE) $@); fi distclean: clean - rm -f Makefile sdl-config + rm -f Makefile Makefile.rules sdl-config rm -f SDL.qpg rm -f config.status config.cache config.log libtool rm -rf $(srcdir)/autom4te* diff --git a/build-scripts/updaterev.sh b/build-scripts/updaterev.sh index f328b3ef0..a01b3343b 100755 --- a/build-scripts/updaterev.sh +++ b/build-scripts/updaterev.sh @@ -7,7 +7,7 @@ cd `dirname $0` srcdir=.. header=$outdir/include/SDL_revision.h -rev=`sh showrev.sh` +rev=`sh showrev.sh 2>/dev/null` if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then echo "#define SDL_REVISION \"$rev\"" >$header.new if diff $header $header.new >/dev/null 2>&1; then diff --git a/configure b/configure index d242062a6..5f6143681 100755 --- a/configure +++ b/configure @@ -28350,7 +28350,6 @@ for EXT in asm cc m c S; do \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\ \\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"` done -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'` VERSION_OBJECTS=`echo $VERSION_SOURCES` VERSION_DEPENDS=`echo $VERSION_SOURCES` @@ -28358,7 +28357,6 @@ VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.rc,$(objects) VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.rc,\\\\ \\$(objects)/\\2.o: \\1/\\2.rc\\\\ \\$(WINDRES) \\$< \\$@,g"` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'` SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES` SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES` @@ -28366,7 +28364,6 @@ SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/ SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.c,\\\\ \\$(objects)/\\2.o: \\1/\\2.c\\\\ \\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"` -SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\\$,\\\\$,g'` # Set runtime shared library paths as needed @@ -28425,9 +28422,19 @@ fi -ac_config_files="$ac_config_files Makefile sdl-config SDL.spec sdl.pc" +cat >Makefile.rules <<__EOF__ -ac_config_commands="$ac_config_commands default" +# Build rules for objects +-include \$(OBJECTS:.lo=.d) + +# Special dependency for SDL.c, since it depends on SDL_revision.h +$srcdir/src/SDL.c: update-revision +$DEPENDS +$VERSION_DEPENDS +$SDLMAIN_DEPENDS +__EOF__ + +ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl-config SDL.spec sdl.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -29334,11 +29341,6 @@ fi -DEPENDS="$DEPENDS" -VERSION_DEPENDS="$VERSION_DEPENDS" -SDLMAIN_DEPENDS="$SDLMAIN_DEPENDS" - - _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -29349,11 +29351,10 @@ do case $ac_config_target in "include/SDL_config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/SDL_config.h" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in:Makefile.rules" ;; "sdl-config") CONFIG_FILES="$CONFIG_FILES sdl-config" ;; "SDL.spec") CONFIG_FILES="$CONFIG_FILES SDL.spec" ;; "sdl.pc") CONFIG_FILES="$CONFIG_FILES sdl.pc" ;; - "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} @@ -30797,15 +30798,6 @@ compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF - ;; - "default":C) cat >>Makefile <<__EOF__ - -# Build rules for objects --include \$(OBJECTS:.lo=.d) -$DEPENDS -$VERSION_DEPENDS -$SDLMAIN_DEPENDS -__EOF__ ;; esac diff --git a/configure.in b/configure.in index 612e93c7c..38bd40a28 100644 --- a/configure.in +++ b/configure.in @@ -2354,7 +2354,6 @@ for EXT in asm cc m c S; do \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\ \\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"` done -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'` VERSION_OBJECTS=`echo $VERSION_SOURCES` VERSION_DEPENDS=`echo $VERSION_SOURCES` @@ -2362,7 +2361,6 @@ VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(obje VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\ \\$(objects)/\\2.o: \\1/\\2.rc\\\\ \\$(WINDRES) \\$< \\$@,g"` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'` SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES` SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES` @@ -2370,7 +2368,6 @@ SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objec SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\ \\$(objects)/\\2.o: \\1/\\2.c\\\\ \\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"` -SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\\$,\\\\$,g'` # Set runtime shared library paths as needed @@ -2431,21 +2428,19 @@ AC_SUBST(BUILD_LDFLAGS) AC_SUBST(EXTRA_LDFLAGS) AC_SUBST(WINDRES) -AC_CONFIG_FILES([ - Makefile sdl-config SDL.spec sdl.pc -]) -AC_CONFIG_COMMANDS([default], - [cat >>Makefile <<__EOF__ +cat >Makefile.rules <<__EOF__ # Build rules for objects -include \$(OBJECTS:.lo=.d) + +# Special dependency for SDL.c, since it depends on SDL_revision.h +$srcdir/src/SDL.c: update-revision $DEPENDS $VERSION_DEPENDS $SDLMAIN_DEPENDS -__EOF__ -], [ -DEPENDS="$DEPENDS" -VERSION_DEPENDS="$VERSION_DEPENDS" -SDLMAIN_DEPENDS="$SDLMAIN_DEPENDS" +__EOF__ + +AC_CONFIG_FILES([ + Makefile:Makefile.in:Makefile.rules sdl-config SDL.spec sdl.pc ]) AC_OUTPUT