File: compile-resource

package info (click to toggle)
libpano13 2.9.19+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,736 kB
  • ctags: 3,225
  • sloc: ansic: 34,695; sh: 11,214; makefile: 311; perl: 242
file content (46 lines) | stat: -rwxr-xr-x 1,648 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

# Script to compile a resource file for a DLL if there is a .rc file
# for it. The resource source file is supposed to contain a version
# info section, that uses the string BUILDNUMBER as the least
# significant part of the version numbers. This script replaces that
# string with a "build number" before compiling the binary resource
# file. The build number is kept between builds in a "stamp" file, and
# incremented each time. (If there is no stamp file, build number 0 is
# used.) The intention is that only the "official" maintainer of a DLL
# keeps such a stamp file, and thus the DLLs he releases have
# increasing version number resources, which can be used by an
# installer program to decide whether to replace an existing DLL with
# the same name.

# This is just my (tml@iki.fi) idea, if somebody comes up with a
# better way to generate version number resources, don't hesitate to
# suggest.

# The command line arguments are:
# $1: the name of the .rc file to check
# $2: the name of the resource object file to produce, if the rc file exists

# Check if we have a resource file for this DLL.
rcfile=$1
resfile=$2
if [ -f $rcfile ]; then
    # Check if we have a build number stamp file.
    basename=`basename $rcfile .rc`
    if [ -f $basename-build.stamp ]; then
	read number <$basename-build.stamp
	buildnumber=`expr $number + 1`
	echo Build number $buildnumber
	echo $buildnumber >$basename-build.stamp
    else
	echo Using zero as build number
        buildnumber=0
    fi

    m4 -DBUILDNUMBER=$buildnumber <$rcfile >$$.rc &&
	${WINDRES-windres} $$.rc $resfile &&
	rm $$.rc
else
    # Return failure
    exit 1
fi