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