Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Make the current revision number available
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 4, 2009
1 parent 8854a32 commit bac9b61
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Makefile.in
Expand Up @@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@

DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode

HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h

LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
Expand All @@ -63,7 +63,10 @@ Makefile: $(srcdir)/Makefile.in
$(objects):
$(SHELL) $(auxdir)/mkinstalldirs $@

.PHONY: all 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
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:
@SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \
$(SHELL) $(auxdir)/makedep.sh
Expand All @@ -75,7 +78,7 @@ depend:

include $(depend)

$(objects)/$(TARGET): $(OBJECTS)
$(objects)/$(TARGET): update-revision $(OBJECTS)
$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)

$(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
Expand Down Expand Up @@ -153,6 +156,7 @@ dist $(distfile):
$(SHELL) $(auxdir)/mkinstalldirs $(distdir)
tar cf - $(DIST) | (cd $(distdir); tar xf -)
cp $(distdir)/include/SDL_config.h.default $(distdir)/include/SDL_config.h
$(SHELL) $(distdir)/build-scripts/updaterev.sh
rm -rf `find $(distdir) -name .svn`
find $(distdir) \( \
-name '*~' -o \
Expand Down Expand Up @@ -194,10 +198,4 @@ commit: indent

# Create a SVN snapshot that people can run update on
snapshot:
svn co http://svn.libsdl.org/trunk/SDL SDL-1.3
(cd SDL-1.3 && ./autogen.sh && rm -rf autom4te.cache)
cp SDL-1.3/include/SDL_config.h.default SDL-1.3/include/SDL_config.h
tar zcf $(HOME)/SDL-1.3.tar.gz SDL-1.3
rm -f $(HOME)/SDL-1.3.zip
zip -r $(HOME)/SDL-1.3.zip SDL-1.3
rm -rf SDL-1.3
$(SHELL) $(aux_dir)/snapshot.sh
10 changes: 10 additions & 0 deletions build-scripts/showrev.sh
@@ -0,0 +1,10 @@
#!/bin/sh
#
# Print the current source revision, if available

srcdir=`dirname $0`/..

if [ -d $srcdir/.svn ]; then
cd $srcdir
svnversion -c | sed -e 's,[0-9]*:\([0-9]*\)[A-Z]*,\1,'
fi
24 changes: 24 additions & 0 deletions build-scripts/snapshot.sh
@@ -0,0 +1,24 @@
#!/bin/sh
#
# Generate a current snapshot from source control

svn co http://svn.libsdl.org/trunk/SDL
(cd SDL && ./autogen.sh && rm -rf autom4te.cache)
sh SDL/build-scripts/updaterev.sh
cp SDL/include/SDL_config.h.default SDL/include/SDL_config.h

major=`fgrep "#define SDL_MAJOR_VERSION" SDL/include/SDL_version.h | \
sed 's,[^0-9]*\([0-9]*\),\1,'`
minor=`fgrep "#define SDL_MINOR_VERSION" SDL/include/SDL_version.h | \
sed 's,[^0-9]*\([0-9]*\),\1,'`
patch=`fgrep "#define SDL_PATCHLEVEL" SDL/include/SDL_version.h | \
sed 's,[^0-9]*\([0-9]*\),\1,'`
rev=`fgrep "#define SDL_REVISION" SDL/include/SDL_revision.h | \
sed 's,[^0-9]*\([0-9]*\),\1,'`
path="SDL-$major.$minor.$patch-$rev"

mv SDL $path
tar zcf $path.tar.gz $path
rm -f $path.zip
zip -r $path.zip $path
rm -rf $path
17 changes: 17 additions & 0 deletions build-scripts/updaterev.sh
@@ -0,0 +1,17 @@
#!/bin/sh
#
# Generate a header file with the current source revision

cd `dirname $0`
srcdir=..
header=$srcdir/include/SDL_revision.h

rev=`sh showrev.sh`
if [ "$rev" != "" ]; then
echo "#define SDL_REVISION $rev" >$header.new
if diff $header $header.new >/dev/null 2>&1; then
rm $header.new
else
mv $header.new $header
fi
fi
7 changes: 7 additions & 0 deletions include/SDL_version.h
Expand Up @@ -30,6 +30,7 @@
#define _SDL_version_h

#include "SDL_stdinc.h"
#include "SDL_revision.h"

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Expand Down Expand Up @@ -131,6 +132,12 @@ typedef struct SDL_version
*/
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);

/**
* \fn int SDL_GetRevision()
* \brief Get the code revision of SDL that is linked against your program.
*/
extern DECLSPEC int SDLCALL SDL_GetRevision();

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
Expand Down
7 changes: 7 additions & 0 deletions src/SDL.c
Expand Up @@ -296,6 +296,13 @@ SDL_GetVersion(SDL_version * ver)
SDL_VERSION(ver);
}

/* Get the library source revision */
int
SDL_GetRevision()
{
SDL_REVISION;
}

#if defined(__OS2__)
/* Building for OS/2 */
#ifdef __WATCOMC__
Expand Down

0 comments on commit bac9b61

Please sign in to comment.