build-scripts/updaterev.sh
author Sam Lantinga <slouken@libsdl.org>
Wed, 16 Feb 2011 02:37:09 -0800
changeset 5310 a9945ce48999
parent 4936 e99358ca7a8d
child 5345 0202f62906ca
permissions -rwxr-xr-x
Made it possible to build SDL from a fresh checkout without any additional steps. The trick is that if you're using configure and you don't want to have SDL_config.h and SDL_revision.h to show up as modified, you need to configure and build from a separate directory. You also need to include SDL_revision.h directly if you want to use the SDL_REVISION constant, as a side effect of these changes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
#!/bin/sh
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
#
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
# Generate a header file with the current source revision
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5310
a9945ce48999 Made it possible to build SDL from a fresh checkout without any additional steps.
Sam Lantinga <slouken@libsdl.org>
parents: 4936
diff changeset
     5
outdir=`pwd`
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
cd `dirname $0`
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
srcdir=..
5310
a9945ce48999 Made it possible to build SDL from a fresh checkout without any additional steps.
Sam Lantinga <slouken@libsdl.org>
parents: 4936
diff changeset
     8
header=$outdir/include/SDL_revision.h
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
rev=`sh showrev.sh`
4936
e99358ca7a8d Don't overwrite SDL_revision.h with a bad revision if Mercurial isn't installed
Sam Lantinga <slouken@libsdl.org>
parents: 4419
diff changeset
    11
if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then
4419
5e7e1f1a4056 Changed revision details to be a string (an hg changeset) instead of an int.
Ryan C. Gordon <icculus@icculus.org>
parents: 2982
diff changeset
    12
    echo "#define SDL_REVISION \"$rev\"" >$header.new
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    if diff $header $header.new >/dev/null 2>&1; then
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
        rm $header.new
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    else
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
        mv $header.new $header
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    fi
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
fi