Fixed a typo.
[synfig.git] / synfig-studio / trunk / 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 Setting up build environment...
160
161 # Set the shell to output what we are doing
162 set -x
163
164 # Create all of the build environment files
165 (
166 #       $INTLTOOLIZE -c &&
167         $LIBTOOLIZE -c -f &&
168         $ACLOCAL -I "$CONFIG_DIR" $ACLOCAL_FLAGS &&
169         aclocalfix &&
170         $AUTOHEADER &&
171         $AUTOMAKE --foreign --add-missing --copy --include-deps &&
172         $AUTOCONF -o configure &&
173         true
174 ) ||
175 {
176         # Something went wrong...
177         set +x
178         output Failure.
179         cleanup;
180         exit 1
181 }
182
183 # Turn off echoing of commands
184 set +x
185
186 #output Patching configure script to look for gcc3...
187 #sed "
188 #s/g++ c++/g++3 g++ c++/;
189 #s/gcc cc/gcc3 gcc cc/;
190 #s:"'${prefix}/include'":"'${prefix}/include/synfig'":;
191 #s:PREFIX/include:PREFIX/include/ETL:;
192 #" < configure > $TEMPFILE
193 #cp $TEMPFILE configure
194
195 # Patch the Makefile.in files
196 for filename in $(find Makefile.in src -name Makefile.in) ; do {
197         echo $BOOTSTRAP_NAME: Patching $filename
198         (
199                 cp $filename $TEMPFILE &&
200                 sed "
201                         s;-I. ;;
202                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
203                         s;configure.in;config/configure.ac;
204                 " < $TEMPFILE > $filename
205         ) ||
206         {
207                 # Patch failure
208                 output Failure. Unable to patch $filename.
209                 cleanup;
210                 exit 1
211         }
212 }; done
213
214 output Creating Makefile...
215 ( echo "
216 all:
217         ./configure --enable-maintainer-mode
218         make all
219         
220 install:
221         ./configure --enable-maintainer-mode
222         make install
223         
224 check:
225         ./configure --enable-maintainer-mode
226         make check
227
228 distcheck:
229         ./configure --enable-maintainer-mode
230         make check
231         
232 dist:
233         ./configure --enable-maintainer-mode
234         make dist
235
236 TAG=${PACKAGE_TARNAME}_${VERSION_MAJ}_${VERSION_MIN}_${VERSION_REV}
237
238 tagstable:
239         -svn delete $SVN_REPOSITORY/tags/stable -m \"Stabe Tag: Removing old tag\"
240         svn mkdir $SVN_REPOSITORY/tags/stable -m \"Stable Tag: Creating new directory\"
241         svn copy . $SVN_REPOSITORY/tags/stable -m \"Stable Tag: Copying everyhting over\"
242
243 tagrelease:
244         svn mkdir $SVN_REPOSITORY/tags/\$(TAG) -m \"Release Tag: Making directory\"
245         svn copy . $SVN_REPOSITORY/tags/\$(TAG) -m \"Release \$(TAG)\"
246
247 " ) > Makefile
248
249 echo $BOOTSTRAP_NAME: Complete.
250
251 cleanup;
252
253 # Move back to the current directory
254 cd "$CURR_DIR"