File: compile-resource

package info (click to toggle)
abiword 3.0.2-9
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,284 kB
  • sloc: cpp: 476,293; ansic: 15,499; makefile: 5,794; sh: 4,359; xml: 3,332; yacc: 1,818; lex: 1,104; perl: 40; python: 6
file content (47 lines) | stat: -rwxr-xr-x 1,696 bytes parent folder | download | duplicates (6)
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
47
#!/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=$[number]
	echo Build number $buildnumber
	rm -rf $basename-build.stamp
    else
	echo Using zero as build number
        buildnumber=0
    fi

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