Added a better way to include build rules in the Makefile
authorSam Lantinga <slouken@libsdl.org>
Fri, 18 Feb 2011 11:19:34 -0800
changeset 53450202f62906ca
parent 5344 94189aa89b54
child 5346 437e54382293
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
build-scripts/updaterev.sh
configure
configure.in
     1.1 --- a/Makefile.in	Fri Feb 18 09:30:09 2011 -0800
     1.2 +++ b/Makefile.in	Fri Feb 18 11:19:34 2011 -0800
     1.3 @@ -108,15 +108,12 @@
     1.4  $(objects):
     1.5  	$(SHELL) $(auxdir)/mkinstalldirs $@
     1.6  
     1.7 -# To make sure parallel builds will not fail
     1.8 -include/SDL_revision.h: update-revision
     1.9 -
    1.10  update-revision:
    1.11  	$(SHELL) $(auxdir)/updaterev.sh
    1.12  
    1.13 -.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)
    1.14 +.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)
    1.15  
    1.16 -$(objects)/$(TARGET): update-revision $(OBJECTS) $(VERSION_OBJECTS)
    1.17 +$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
    1.18  	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
    1.19  
    1.20  $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
    1.21 @@ -127,13 +124,18 @@
    1.22  install-bin:
    1.23  	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir)
    1.24  	$(INSTALL) -m 755 sdl-config $(DESTDIR)$(bindir)/sdl-config
    1.25 -install-hdrs: include/SDL_revision.h
    1.26 +install-hdrs: update-revision
    1.27  	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL
    1.28  	for file in $(HDRS); do \
    1.29  	    $(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL/$$file; \
    1.30  	done
    1.31  	$(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL/SDL_config.h
    1.32 -	$(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h
    1.33 +	if test -f include/SDL_revision.h; then \
    1.34 +	    $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h; \
    1.35 +	else \
    1.36 +	    $(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL/SDL_revision.h; \
    1.37 +	fi
    1.38 +
    1.39  install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
    1.40  	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
    1.41  	$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
    1.42 @@ -167,7 +169,7 @@
    1.43  	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
    1.44  
    1.45  distclean: clean
    1.46 -	rm -f Makefile sdl-config
    1.47 +	rm -f Makefile Makefile.rules sdl-config
    1.48  	rm -f SDL.qpg
    1.49  	rm -f config.status config.cache config.log libtool
    1.50  	rm -rf $(srcdir)/autom4te*
     2.1 --- a/build-scripts/updaterev.sh	Fri Feb 18 09:30:09 2011 -0800
     2.2 +++ b/build-scripts/updaterev.sh	Fri Feb 18 11:19:34 2011 -0800
     2.3 @@ -7,7 +7,7 @@
     2.4  srcdir=..
     2.5  header=$outdir/include/SDL_revision.h
     2.6  
     2.7 -rev=`sh showrev.sh`
     2.8 +rev=`sh showrev.sh 2>/dev/null`
     2.9  if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then
    2.10      echo "#define SDL_REVISION \"$rev\"" >$header.new
    2.11      if diff $header $header.new >/dev/null 2>&1; then
     3.1 --- a/configure	Fri Feb 18 09:30:09 2011 -0800
     3.2 +++ b/configure	Fri Feb 18 11:19:34 2011 -0800
     3.3 @@ -28350,7 +28350,6 @@
     3.4  \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
     3.5  	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
     3.6  done
     3.7 -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
     3.8  
     3.9  VERSION_OBJECTS=`echo $VERSION_SOURCES`
    3.10  VERSION_DEPENDS=`echo $VERSION_SOURCES`
    3.11 @@ -28358,7 +28357,6 @@
    3.12  VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.rc,\\\\
    3.13  \\$(objects)/\\2.o: \\1/\\2.rc\\\\
    3.14  	\\$(WINDRES) \\$< \\$@,g"`
    3.15 -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
    3.16  
    3.17  SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
    3.18  SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
    3.19 @@ -28366,7 +28364,6 @@
    3.20  SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.c,\\\\
    3.21  \\$(objects)/\\2.o: \\1/\\2.c\\\\
    3.22  	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
    3.23 -SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\\$,\\\\$,g'`
    3.24  
    3.25  # Set runtime shared library paths as needed
    3.26  
    3.27 @@ -28425,9 +28422,19 @@
    3.28  
    3.29  
    3.30  
    3.31 -ac_config_files="$ac_config_files Makefile sdl-config SDL.spec sdl.pc"
    3.32 -
    3.33 -ac_config_commands="$ac_config_commands default"
    3.34 +cat >Makefile.rules <<__EOF__
    3.35 +
    3.36 +# Build rules for objects
    3.37 +-include \$(OBJECTS:.lo=.d)
    3.38 +
    3.39 +# Special dependency for SDL.c, since it depends on SDL_revision.h
    3.40 +$srcdir/src/SDL.c: update-revision
    3.41 +$DEPENDS
    3.42 +$VERSION_DEPENDS
    3.43 +$SDLMAIN_DEPENDS
    3.44 +__EOF__
    3.45 +
    3.46 +ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl-config SDL.spec sdl.pc"
    3.47  
    3.48  cat >confcache <<\_ACEOF
    3.49  # This file is a shell script that caches the results of configure
    3.50 @@ -29334,11 +29341,6 @@
    3.51  
    3.52  
    3.53  
    3.54 -DEPENDS="$DEPENDS"
    3.55 -VERSION_DEPENDS="$VERSION_DEPENDS"
    3.56 -SDLMAIN_DEPENDS="$SDLMAIN_DEPENDS"
    3.57 -
    3.58 -
    3.59  _ACEOF
    3.60  
    3.61  cat >>$CONFIG_STATUS <<\_ACEOF
    3.62 @@ -29349,11 +29351,10 @@
    3.63    case $ac_config_target in
    3.64      "include/SDL_config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/SDL_config.h" ;;
    3.65      "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
    3.66 -    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
    3.67 +    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in:Makefile.rules" ;;
    3.68      "sdl-config") CONFIG_FILES="$CONFIG_FILES sdl-config" ;;
    3.69      "SDL.spec") CONFIG_FILES="$CONFIG_FILES SDL.spec" ;;
    3.70      "sdl.pc") CONFIG_FILES="$CONFIG_FILES sdl.pc" ;;
    3.71 -    "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
    3.72  
    3.73    *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
    3.74  echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    3.75 @@ -30798,15 +30799,6 @@
    3.76  _LT_EOF
    3.77  
    3.78   ;;
    3.79 -    "default":C) cat >>Makefile <<__EOF__
    3.80 -
    3.81 -# Build rules for objects
    3.82 --include \$(OBJECTS:.lo=.d)
    3.83 -$DEPENDS
    3.84 -$VERSION_DEPENDS
    3.85 -$SDLMAIN_DEPENDS
    3.86 -__EOF__
    3.87 - ;;
    3.88  
    3.89    esac
    3.90  done # for ac_tag
     4.1 --- a/configure.in	Fri Feb 18 09:30:09 2011 -0800
     4.2 +++ b/configure.in	Fri Feb 18 11:19:34 2011 -0800
     4.3 @@ -2354,7 +2354,6 @@
     4.4  \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
     4.5  	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
     4.6  done
     4.7 -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
     4.8  
     4.9  VERSION_OBJECTS=`echo $VERSION_SOURCES`
    4.10  VERSION_DEPENDS=`echo $VERSION_SOURCES`
    4.11 @@ -2362,7 +2361,6 @@
    4.12  VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
    4.13  \\$(objects)/\\2.o: \\1/\\2.rc\\\\
    4.14  	\\$(WINDRES) \\$< \\$@,g"`
    4.15 -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
    4.16  
    4.17  SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
    4.18  SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
    4.19 @@ -2370,7 +2368,6 @@
    4.20  SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
    4.21  \\$(objects)/\\2.o: \\1/\\2.c\\\\
    4.22  	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
    4.23 -SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\\$,\\\\$,g'`
    4.24  
    4.25  # Set runtime shared library paths as needed
    4.26  
    4.27 @@ -2431,21 +2428,19 @@
    4.28  AC_SUBST(EXTRA_LDFLAGS)
    4.29  AC_SUBST(WINDRES)
    4.30  
    4.31 -AC_CONFIG_FILES([
    4.32 -    Makefile sdl-config SDL.spec sdl.pc
    4.33 -])
    4.34 -AC_CONFIG_COMMANDS([default],
    4.35 -                   [cat >>Makefile <<__EOF__
    4.36 +cat >Makefile.rules <<__EOF__
    4.37  
    4.38  # Build rules for objects
    4.39  -include \$(OBJECTS:.lo=.d)
    4.40 +
    4.41 +# Special dependency for SDL.c, since it depends on SDL_revision.h
    4.42 +$srcdir/src/SDL.c: update-revision
    4.43  $DEPENDS
    4.44  $VERSION_DEPENDS
    4.45  $SDLMAIN_DEPENDS
    4.46 -__EOF__ 
    4.47 -], [
    4.48 -DEPENDS="$DEPENDS"
    4.49 -VERSION_DEPENDS="$VERSION_DEPENDS"
    4.50 -SDLMAIN_DEPENDS="$SDLMAIN_DEPENDS"
    4.51 +__EOF__
    4.52 +
    4.53 +AC_CONFIG_FILES([
    4.54 +    Makefile:Makefile.in:Makefile.rules sdl-config SDL.spec sdl.pc
    4.55  ])
    4.56  AC_OUTPUT