cvsimport
[fvwm.git] / utils / make_fvwmdist.sh
blobf053786e3bfc26b28d51612ded8ca4ca889a8707
1 #!/bin/sh
3 # options:
5 # -r Build and commit a release (tags the sources and updates version info).
6 # -w Disable -Werror in compiler flags.
7 # -R Increase release number after building (2.3.29 -> 3.0.0).
8 # -M Increase major number after building (2.3.29 -> 2.4.0).
9 # -N Your name for the ChangeLog.
11 # environment variables:
13 # FVWMRELNAME
14 # The name that will show up in the ChangeLog (only with -r).
15 # If omitted a your gcos name is used. Can also be set with -N.
16 # FVWMRELEMAIL
17 # The email address that will show up in the ChangeLog (only with -r).
18 # FVWMRELPRECVSCOMMAND
19 # A command that will be executed before the first cvs command. Can be used
20 # to bring up the network prior to network access. (only with -r)
21 # FVWMRELPOSTCVSCOMMAND
22 # Same as above, but executed after the last cvs command.
24 CHECK_FILE=AUTHORS
25 CHECK_STRING1=fvwm
26 CHECK_STRING2="Robert Nation"
27 CHECK_VERSION_STRING="AM_INIT_AUTOMAKE"
28 VERSION_PRE="fvwm-"
29 VERSION_POST=".tar.gz"
30 READY_STRING=" is ready for distribution"
31 CFLAGSE="-g -O2 -Wall -Werror"
32 CFLAGSW="-g -O2 -Wall"
33 CFLAGS="$CFLAGSE"
35 export LANG=en_US
36 export LC_ALL=en_US
38 # parse options
39 IS_RELEASE=0
40 IS_MINOR=1
41 IS_MAJOR=0
42 while [ ! x$1 = x ] ; do
43 case "$1" in
44 -r) IS_RELEASE=1 ;;
45 -R) IS_MINOR=0; IS_MAJOR=0 ;;
46 -M) IS_MINOR=0; IS_MAJOR=1 ;;
47 -w) CFLAGS="$CFLAGSW" ;;
48 -N) FVWMRELNAME=$2;shift;;
49 esac
50 shift
51 done
53 if [ $IS_RELEASE = 1 ] ; then
54 echo "Your name and email address will show up in the ChangeLog."
55 if [ -z "$FVWMRELNAME" ] ; then
56 FVWMRELNAME=`perl -e 'print ((split(/,/, ((getpwnam(((getpwuid($<))[0])))[6])))[0]);'`
57 echo "Please enter your name or press return to use \"$FVWMRELNAME\""
58 read ANSWER
59 if [ ! "$ANSWER" = "" ] ; then
60 FVWMRELNAME=$ANSWER
62 else
63 echo "Name: $FVWMRELNAME"
65 if [ -z "$FVWMRELEMAIL" ] ; then
66 echo "Please enter your emailaddress (or set FVWMRELEMAIL variable)"
67 read FVWMRELEMAIL
68 else
69 echo "Email: $FVWMRELEMAIL"
71 echo "Your name will show up in the ChangeLog as $FVWMRELNAME"
72 echo "Your email address will show up in the ChangeLog as $FVWMRELEMAIL"
75 wrong_dir=1
76 if [ -r "$CHECK_FILE" ] ; then
77 if grep "$CHECK_STRING1" "$CHECK_FILE" > /dev/null 2> /dev/null ; then
78 if grep "$CHECK_STRING2" "$CHECK_FILE" > /dev/null 2> /dev/null ; then
79 wrong_dir=0
84 if [ $wrong_dir = 1 ] ; then
85 echo "The fvwm sources are not present in the current directory."
86 echo "Looked for "$CHECK_FILE" containing \""$CHECK_STRING1"\" and \""$CHECK_STRING2"\". exit."
87 exit 11;
90 # get release numbers
91 VERSION=`grep $CHECK_VERSION_STRING configure.in 2>&1 |
92 cut -f 2 -d "," |
93 perl -pe 's/[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+).$/$1/g'`
94 VRELEASE=`echo $VERSION | cut -f 1 -d "."`
95 VMAJOR=`echo $VERSION | cut -f 2 -d "."`
96 VMINOR=`echo $VERSION | cut -f 3 -d "."`
97 if [ -z "$VRELEASE" -o -z "$VMAJOR" ] ; then
98 echo "Failed to fetch version number from configure.in."
99 exit 3;
101 if [ x$VMINOR = x ] ; then
102 VMINOR=0
104 if [ "$IS_MINOR" = 1 ] ; then
105 # minor release
106 VRELEASEP=$VRELEASE
107 VMAJORP=$VMAJOR
108 VMINORP=`echo $VMINOR | perl -pe 's/(.+)/@{[$1+1]}/g'`
109 elif [ "$IS_MAJOR" = 1 ] ; then
110 # major release
111 VRELEASEP=$VRELEASE
112 VMAJORP=`echo $VMAJOR | perl -pe 's/(.+)/@{[$1+1]}/g'`
113 VMINORP=0
114 else
115 VRELEASEP=`echo $VRELEASE | perl -pe 's/(.+)/@{[$1+1]}/g'`
116 VMAJORP=0
117 VMINORP=0
119 VRELNUM=$VRELEASE.$VMAJOR.$VMINOR
120 VRELNUMP=$VRELEASEP.$VMAJORP.$VMINORP
121 VERSION_STRING=$VERSION_PRE$VRELNUM$VERSION_POST
122 echo "***** building $VERSION_STRING *****"
124 # find GNU make
125 MAKE=
126 for i in gnumake gmake make; do
127 VER=`(echo 'all:;@echo $(MAKE_VERSION)' | $i -f -) 2>/dev/null`
128 case $VER in
129 3.*) MAKE=$i; break 2 ;;
130 esac
131 done
132 case $MAKE in
133 ?*) : OK, found one ;;
134 *) echo "Can't find GNU make version 3 on the PATH!"; exit 12 ;;
135 esac
137 # find compiler (prefer gcc)
139 VER=
140 VER=`(gcc --version) 2>/dev/null`
141 if [ x$VER = x ] ; then
142 CC=cc
143 else
144 CC=gcc
147 # clean up
148 echo removing old configure files ...
149 if [ -f configure ] ; then
150 rm configure || exit 21
152 if [ -f config.cache ] ; then
153 rm config.cache || exit 22
155 if [ -f config.log ] ; then
156 rm config.log || exit 23
158 if [ -f config.status ] ; then
159 rm config.status || exit 24
162 # build the distribution
163 echo running automake ...
164 automake --add-missing || exit 31
165 if [ -f config.h.in ]; then
166 echo running autoreconf ...
167 autoreconf || exit 32
168 else
169 echo running autoreconf ...
170 autoreconf || exit 33
171 echo running automake again ...
172 automake --add-missing || exit 34
173 echo running autoconf again ...
174 autoconf || exit 35
176 echo running configure ...
177 ./configure || exit 35
178 echo running make clean ...
179 $MAKE clean || exit 37
180 echo running make ...
181 $MAKE CC="$CC" CFLAGS="$CFLAGS" || exit 38
182 echo running make distcheck2 ...
183 $MAKE CC="$CC" distcheck2 2>&1 | grep "$VERSION_STRING$READY_STRING" || exit 39
184 echo
185 echo "distribution file is ready"
186 echo
188 # update some files and commit changes
189 if [ $IS_RELEASE = 0 ] ; then
190 echo "If this is to be an official release:"
191 echo " . Tag the source tree:"
192 echo " cvs tag version-x_y_z"
193 echo " . Increase the version number in configure.in and commit this change"
194 echo " . Create entries in ChangeLog and NEWS files indicating the release"
195 else
196 echo updating NEWS file
197 NNEWS="new-NEWS"
198 perl -pe '$hr = "-" x 67; s/^(.*) '$VRELNUM' (\(not released yet\))$/$1 '$VRELNUMP' $2\n\n$hr\n\n$1 '$VRELNUM' (@{[substr(`date "+%d-%b-%Y"`,0,11)]})/' \
199 < NEWS > $NNEWS || exit 41
200 mv $NNEWS NEWS || exit 42
201 echo updating FAQ file
202 NFAQ="new-FAQ"
203 if [ $IS_MINOR = 1 ]; then
204 perl -pe 's/(Last updated).*(for unstable release) '$VRELNUM' (and stable)$/$1 @{[substr(`date "+%b %d, %Y"`,0,12)]} $2 '$VRELNUMP' $3/' \
205 < docs/FAQ > docs/$NFAQ || exit 43
206 else
207 perl -pe 's/(Last updated).*(for unstable release .* and stable release) [0-9]*\.[0-9*]\.[0-9*]\.$/$1 @{[substr(`date "+%b %d, %Y"`,0,12)]} $2 '$VRELNUMP'\./' \
208 < docs/FAQ > docs/$NFAQ || exit 44
210 mv docs/$NFAQ docs/FAQ || exit 45
211 echo tagging CVS source
212 if [ ! "$FVWMRELPRECVSCOMMAND" = "" ] ; then
213 $FVWMRELPRECVSCOMMAND
215 cvs tag version-${VRELEASE}_${VMAJOR}_${VMINOR} || exit 46
216 echo increasing version number in configure.in
217 NCFG="new-configure.in"
218 touch $NCFG || exit 47
219 cat configure.in |
220 perl -pe 's/'$VRELNUM'/'$VRELNUMP'/g' \
221 > $NCFG || exit 48
222 mv $NCFG configure.in || exit 49
223 echo generating ChangeLog entry ...
224 NCLOG="new-ChangeLog"
225 touch $NCLOG || exit 50
226 echo `date +%Y-%m-%d`" $FVWMRELNAME <$FVWMRELEMAIL>" > $NCLOG
227 echo >> $NCLOG
228 echo " * NEWS, configure.in:" >> $NCLOG
229 echo " changed version to $VRELNUMP" >> $NCLOG
230 echo >> $NCLOG
231 cat ChangeLog >> $NCLOG
232 mv $NCLOG ChangeLog || exit 51
233 echo committing configure.in and ChangeLog
234 cvs commit -m \
235 "* Set development version to $VRELNUMP." \
236 NEWS configure.in ChangeLog || exit 52
237 if [ ! "$FVWMRELPOSTCVSCOMMAND" = "" ] ; then
238 $FVWMRELPOSTCVSCOMMAND
240 echo
241 echo Then
243 echo " . Upload the distribution to ftp://ftp.fvwm.org/pub/incoming/fvwm"
244 echo " . Notify fvwm-owner@fvwm.org of the upload"
245 echo " . Update the version numbers in fvwm-web/download.html and"
246 echo " fvwm-web/index.html."
247 echo " . If releasing the stable branch, update NEWS in the beta branch to"
248 echo " identify the latest stable release and describe the changes."
249 echo " . Use fvwm-web generated/txt2html.sh to update the NEWS file:"
250 echo " $ cd fvwm-web/generated && ./txt2html.sh ../../fvwm/NEWS"