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