| 1 | #!/bin/sh |
| 2 | |
| 3 | # Script to compile a resource file for a DLL if there is a .rc file |
| 4 | # for it. The resource source file is supposed to contain a version |
| 5 | # info section, that uses the string BUILDNUMBER as the least |
| 6 | # significant part of the version numbers. This script replaces that |
| 7 | # string with a "build number" before compiling the binary resource |
| 8 | # file. The build number is kept between builds in a "stamp" file, and |
| 9 | # incremented each time. (If there is no stamp file, build number 0 is |
| 10 | # used.) The intention is that only the "official" maintainer of a DLL |
| 11 | # keeps such a stamp file, and thus the DLLs he releases have |
| 12 | # increasing version number resources, which can be used by an |
| 13 | # installer program to decide whether to replace an existing DLL with |
| 14 | # the same name. |
| 15 | |
| 16 | # This is just my ([email protected]) idea, if somebody comes up with a |
| 17 | # better way to generate version number resources, don't hesitate to |
| 18 | # suggest. |
| 19 | |
| 20 | # The command line arguments are: |
| 21 | # $1: the name of the .rc file to check |
| 22 | # $2: the name of the resource object file to produce, if the rc file exists |
| 23 | |
| 24 | # Check if we have a resource file for this DLL. |
| 25 | rcfile=$1 |
| 26 | resfile=$2 |
| 27 | if [ -f $rcfile ]; then |
| 28 | # Check if we have a build number stamp file. |
| 29 | basename=`basename $rcfile .rc` |
| 30 | if [ -f $basename-build.stamp ]; then |
| 31 | read number <$basename-build.stamp |
| 32 | buildnumber=$[number] |
| 33 | echo Build number $buildnumber |
| 34 | rm -rf $basename-build.stamp |
| 35 | else |
| 36 | echo Using zero as build number |
| 37 | buildnumber=0 |
| 38 | fi |
| 39 | |
| 40 | m4 -DBUILDNUMBER=$buildnumber <$rcfile >$$.rc && |
| 41 | ${WINDRES-windres} $$.rc $resfile && |
| 42 | rm $$.rc |
| 43 | else |
| 44 | # Return failure |
| 45 | exit 1 |
| 46 | fi |