Release synfig_0_61_03
[synfig.git] / synfig-studio / tags / stable / synfig-studio / bootstrap
1 #! /bin/sh
2 #
3 # Sinfg Studio Bootstrap Script
4 # $Id: bootstrap,v 1.2 2005/01/10 08:13:44 darco Exp $
5
6 # This script creates the configure script and Makefile.in files,
7 # and also fixes a few things in both to ensure a smooth build
8 # on all compilers and platforms.
9 #
10
11 # Grab the current directory and move to our own
12 CURR_DIR=$(pwd)
13 cd $(dirname $0)
14
15 # Environment Variables
16 BOOTSTRAP_NAME=$(basename $0)
17 CONFIG_DIR=$(pwd)/config
18
19 . $CONFIG_DIR/build.cfg
20
21 SED_SCRIPT="
22 s/@PACKAGE@/$PACKAGE/g;
23 s/@PACKAGE_NAME@/$PACKAGE_NAME/g;
24 s/@PACKAGE_BUGREPORT@/$PACKAGE_BUGREPORT/g;
25 s/@PACKAGE_TARNAME@/$PACKAGE_TARNAME/g;
26 s/@PACKAGE_VERSION@/$PACKAGE_VERSION/g;
27 s/@VERSION@/$VERSION/g;
28 s/@VERSION_MAJ@/$VERSION_MAJ/g;
29 s/@VERSION_MIN@/$VERSION_MIN/g;
30 s/@VERSION_REV@/$VERSION_REV/g;
31 s/@VERSION_REL@/$VERSION_REL/g;
32 s/@CFLAGS@//g;
33 "
34
35 # Required automake and autoconf versions
36 #AUTOCONF_VERSION=2.5
37 #AUTOMAKE_VERSION=1.6
38 #LIBTOOL_VERSION=1.4
39 export WANT_AUTOMAKE=1.8
40 export WANT_AUTOCONF_2_5=1
41
42 LIBTOOLIZE=libtoolize
43 INTLTOOLIZE=intltoolize
44 AUTOCONF=autoconf
45 AUTOMAKE=automake
46 ACLOCAL=aclocal
47 AUTOHEADER=autoheader
48
49 # Define the output function
50 output () {
51         echo $BOOTSTRAP_NAME: $*
52 }
53
54 # Define the cleanup function
55 cleanup () {
56         output Cleaning up...
57         rm -fr config.cache autom4te*.cache configure.in $TEMPFILE
58 }
59
60 output Prepairing build environment for $PACKAGE-$VERSION...
61
62 # Look for the CVS directory. If we don't find it, we need to
63 # ask the user if they know what they are doing.
64 ( test -d CVS || test -d .svn ) ||
65 {
66         echo "
67 $BOOTSTRAP_NAME: warning: This shell script is intended for those
68 $BOOTSTRAP_NAME: warning: who either know what they are doing or
69 $BOOTSTRAP_NAME: warning: or downloaded this program from the CVS
70 $BOOTSTRAP_NAME: warning: repository. See README for more details.
71 $BOOTSTRAP_NAME: warning: To avoid seeing this message in the future,
72 $BOOTSTRAP_NAME: warning: create an empty directory called 'CVS'."
73         echo Waiting for 15 seconds...
74         sleep 15
75 }
76
77 # Create the temporary file
78 output Creating temporary file...
79 TEMPFILE=`mktemp /tmp/$BOOTSTRAP_NAME.XXXXXX` ||
80 {
81         output ERROR: Unable to create temporary file!
82         exit 1
83 }
84
85 # Check for autoconf
86 (which autoconf > /dev/null 2>&1 ) ||
87 {
88         output error: 'Could not find GNU autoconf!'
89         output You need to download and install GNU autoconf v2.52 or higher.
90         output '<ftp://ftp.gnu.org/gnu/autoconf>'
91         cleanup;
92         exit 1
93 }
94
95 # Check autoconf version
96 output Using $(autoconf --version | grep utoconf)
97 autoconf --version | grep -q "$AUTOCONF_VERSION" || echo \
98 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Autoconf (expected $AUTOCONF_VERSION)
99 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
100
101 # Check for automake
102 (which automake > /dev/null 2>&1 ) ||
103 {
104         output error: 'Could not find GNU automake!'
105         output You need to download and install GNU automake v1.5 or higher.
106         output '<ftp://ftp.gnu.org/gnu/automake>'
107         cleanup;
108         exit 1
109 }
110
111 # Check automake version
112 output Using $(automake --version | grep utomake)
113 automake --version | grep -q "$AUTOMAKE_VERSION" || echo \
114 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Automake (expected $AUTOMAKE_VERSION)
115 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
116
117 # Check for libtool
118 (which libtool > /dev/null 2>&1 ) ||
119 {
120         output error: 'Could not find GNU libtool!'
121         output You need to download and install GNU libtool v1.4 or higher.
122         output '<ftp://ftp.gnu.org/gnu/libtool>'
123         exit 1
124 }
125
126 # Check libtool version
127 output Using $(libtoolize --version | grep ibtool)
128 libtoolize --version | grep -q "$LIBTOOL_VERSION" || echo \
129 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Libtool (expected $LIBTOOL_VERSION)
130 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
131
132
133 aclocalfix () {
134 sed '
135 s:${srcdir}/intltool:${ac_aux_dir}/intltool:g;
136 s.printf ("\\t%s @ %ld ;\\n", erva+name_rva, 1+ i);.printf ("\\t\\"%s\\" @ %ld ;\\n", erva+name_rva, 1+ i);.;
137 ' < aclocal.m4 > $TEMPFILE &&
138 rm aclocal.m4 &&
139 mv $TEMPFILE aclocal.m4
140 }
141
142 for FILENAME in project.spec ; do {
143 output Creating $FILENAME...
144 sed "$SED_SCRIPT" < $CONFIG_DIR/$FILENAME.in > $FILENAME;
145 } ; done
146
147 output Renaming project.spec to $PACKAGE-$VERSION.spec...
148 mv project.spec "$PACKAGE-$VERSION.spec"
149
150 output Finishing up $PACKAGE-$VERSION.spec...
151 echo %changelog >> "$PACKAGE-$VERSION.spec"
152 cat ChangeLog >> "$PACKAGE-$VERSION.spec"
153
154 output Creating configure.in from configure.ac...
155 sed "$SED_SCRIPT" < $CONFIG_DIR/configure.ac > configure.in;
156
157 output Setting up build environment...
158
159 # Set the shell to output what we are doing
160 set -x
161
162 # Create all of the build environment files
163 (
164 #       $INTLTOOLIZE -c &&
165         $LIBTOOLIZE -c -f &&
166         $ACLOCAL -I $CONFIG_DIR $ACLOCAL_FLAGS &&
167         aclocalfix &&
168         $AUTOHEADER &&
169         $AUTOMAKE --foreign --add-missing --copy --include-deps &&
170         $AUTOCONF -o configure &&
171         true
172 ) ||
173 {
174         # Something went wrong...
175         set +x
176         output Failure.
177         cleanup;
178         exit 1
179 }
180
181 # Turn off echoing of commands
182 set +x
183
184 #output Patching configure script to look for gcc3...
185 #sed "
186 #s/g++ c++/g++3 g++ c++/;
187 #s/gcc cc/gcc3 gcc cc/;
188 #s:"'${prefix}/include'":"'${prefix}/include/sinfg'":;
189 #s:PREFIX/include:PREFIX/include/ETL:;
190 #" < configure > $TEMPFILE
191 #cp $TEMPFILE configure
192
193 # Patch the Makefile.in files
194 for filename in $(find Makefile.in src -name Makefile.in) ; do {
195         echo $BOOTSTRAP_NAME: Patching $filename
196         (
197                 cp $filename $TEMPFILE &&
198                 sed "
199                         s;-I. ;;
200                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
201                         s;configure.in;config/configure.ac;
202                 " < $TEMPFILE > $filename
203         ) ||
204         {
205                 # Patch failure
206                 output Failure. Unable to patch $filename.
207                 cleanup;
208                 exit 1
209         }
210 }; done
211
212 output Creating Makefile...
213 ( echo "
214 all:
215         ./configure --enable-maintainer-mode
216         make all
217         
218 install:
219         ./configure --enable-maintainer-mode
220         make install
221         
222 check:
223         ./configure --enable-maintainer-mode
224         make check
225
226 distcheck:
227         ./configure --enable-maintainer-mode
228         make check
229         
230 dist:
231         ./configure --enable-maintainer-mode
232         make dist
233 " ) > Makefile
234
235 echo $BOOTSTRAP_NAME: Complete.
236
237 cleanup;
238
239 # Move back to the current directory
240 cd $CURR_DIR