File: fixver.sh

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (138 lines) | stat: -rwxr-xr-x 4,585 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/sh
#
#  Shell script to adjust the version numbers and dates in allegro.h,
#  dllver.rc, readme._tx, allegro._tx, makefile.ver, allegro-config.in,
#  allegro-config.qnx, modules.lst and allegro.spec .
#
#  Note: if you pass "datestamp" as the only argument, then the version
#  digits will remain unchanged and the comment will be set to the date.
#  This is in particular useful for making CVS snapshots.


if [ $# -lt 3 -o $# -gt 4 ]; then
   if [ $# -eq 1 -a $1 == "datestamp" ]; then
      ver=`grep "version=[0-9]" misc/allegro-config.in`
      major_num=`echo $ver | sed -e "s/version=\([0-9]\).*/\1/"`
      sub_num=`echo $ver | sed -e "s/version=[0-9]\.\([0-9]\).*/\1/"`
      wip_num=`echo $ver | sed -e "s/version=[0-9]\.[0-9]\.\([0-9]\+\).*/\1/"`
      $0 $major_num $sub_num $wip_num `date '+%Y%m%d'`
      exit 0
   else
      echo "Usage: fixver major_num sub_num wip_num [comment]" 1>&2
      echo "   or: fixver datestamp" 1>&2
      echo "Example: fixver 3 9 1 WIP" 1>&2
      exit 1
   fi
fi

# get the version and date strings in a nice format
if [ $# -eq 3 ]; then
   verstr="$1.$2.$3"
else
   verstr="$1.$2.$3 ($4)"
fi

year=$(date +%Y)
month=$(date +%m)
day=$(date +%d)
datestr="$(date +%b) $day, $year"

# patch allegro/base.h
echo "s/\#define ALLEGRO_VERSION .*/\#define ALLEGRO_VERSION          $1/" > fixver.sed
echo "s/\#define ALLEGRO_SUB_VERSION .*/\#define ALLEGRO_SUB_VERSION      $2/" >> fixver.sed
echo "s/\#define ALLEGRO_WIP_VERSION .*/\#define ALLEGRO_WIP_VERSION      $3/" >> fixver.sed
echo "s/\#define ALLEGRO_VERSION_STR .*/\#define ALLEGRO_VERSION_STR      \"$verstr\"/" >> fixver.sed
echo "s/\#define ALLEGRO_DATE_STR .*/\#define ALLEGRO_DATE_STR         \"$year\"/" >> fixver.sed
echo "s/\#define ALLEGRO_DATE .*/\#define ALLEGRO_DATE             $year$month$day    \/\* yyyymmdd \*\//" >> fixver.sed

echo "Patching include/allegro/base.h..."
cp include/allegro/base.h fixver.tmp
sed -f fixver.sed fixver.tmp > include/allegro/base.h

echo "Patching src/win/dllver.rc..."
cat > src/win/dllver.rc << END_OF_DLLVER
// Windows resource file for the version info sheet
// generated by misc/fixver.sh

#include <windows.h>


1 VERSIONINFO 
FILEVERSION $1, $2, $3, 0
PRODUCTVERSION $1, $2, $3, 0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
{
   BLOCK "StringFileInfo"
   {
      BLOCK "040904E4"
      {
         VALUE "Comments", "Please see AUTHORS for a list of contributors\000"
         VALUE "CompanyName", "Allegro Developers\000\000"
         VALUE "FileDescription", "Allegro\000"
         VALUE "FileVersion", "$verstr\000"
         VALUE "InternalName", "ALLEG$1$2\000"
         VALUE "LegalCopyright", "Copyright � 1994-$year Allegro Developers\000\000"
         VALUE "OriginalFilename", "ALLEG$1$2.DLL\000"
         VALUE "ProductName", "Allegro\000"
         VALUE "ProductVersion", "$verstr\000"
      }
   }

   BLOCK "VarFileInfo"
   {
      VALUE "Translation", 0x0809, 1252
   }
}

END_OF_DLLVER

# patch readme._tx
echo "s/\\_\/__\/     Version .*/\\_\/__\/     Version $verstr/" > fixver.sed
echo "s/By Shawn Hargreaves, .*\./By Shawn Hargreaves, $datestr\./" >> fixver.sed

echo "Patching readme._tx..."
cp docs/src/readme._tx fixver.tmp
sed -f fixver.sed fixver.tmp > docs/src/readme._tx

# patch allegro._tx
echo "s/@manh=\"version [^\"]*\"/@manh=\"version $verstr\"/" >> fixver.sed

echo "Patching docs/src/allegro._tx..."
cp docs/src/allegro._tx fixver.tmp
sed -f fixver.sed fixver.tmp > docs/src/allegro._tx

# patch the OSX package readme
echo "Patching misc/pkgreadme._tx..."
cp misc/pkgreadme._tx fixver.tmp
sed -f fixver.sed fixver.tmp > misc/pkgreadme._tx

# patch makefile.ver
echo "s/LIBRARY_VERSION = .*/LIBRARY_VERSION = $1$2/" > fixver.sed
echo "s/shared_version = .*/shared_version = $1.$2.$3/" >> fixver.sed
echo "s/shared_major_minor = .*/shared_major_minor = $1.$2/" >> fixver.sed

echo "Patching makefile.ver..."
cp makefile.ver fixver.tmp
sed -f fixver.sed fixver.tmp > makefile.ver

# patch allegro-config.in, allegro-config.qnx
echo "s/version=[0-9].*/version=$1.$2.$3/" >> fixver.sed

echo "Patching misc/allegro-config.in..."
cp misc/allegro-config.in fixver.tmp
sed -f fixver.sed fixver.tmp > misc/allegro-config.in

echo "Patching misc/allegro-config-qnx.sh..."
cp misc/allegro-config-qnx.sh fixver.tmp
sed -f fixver.sed fixver.tmp > misc/allegro-config-qnx.sh

# patch the spec file
echo "Patching misc/allegro.spec..."
cp misc/allegro.spec fixver.tmp
sed -e "s/^Version: .*/Version: $1.$2.$3/" fixver.tmp > misc/allegro.spec

# clean up after ourselves
rm fixver.sed fixver.tmp

echo "Done!"