Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_07_rc3 / bootstrap
1 #! /bin/sh
2 #
3 # Synfig 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 [ -x /bin/cygpath ] && CONFIG_DIR="`cygpath -m -s "$CONFIG_DIR"`"
20 [ -x /bin/cygpath ] && CONFIG_DIR="`cygpath -u "$CONFIG_DIR"`"
21 [ -x /bin/cygpath ] && CURR_DIR="`cygpath -m -s "$CURR_DIR"`"
22 [ -x /bin/cygpath ] && CURR_DIR="`cygpath -u "$CURR_DIR"`"
23 # Automake,Autoconf, and Libtool versions that we require
24 #AUTOCONF_VERSION=2.5
25 #AUTOMAKE_VERSION=1.6
26 #LIBTOOL_VERSION=1.4
27 export WANT_AUTOMAKE=1.8
28 #export WANT_LIBTOOL_VER=1.5
29 export WANT_AUTOCONF_2_5=1
30 export WANT_AUTOCONF=2.5
31
32 . "$CONFIG_DIR/build.cfg"
33
34 SED_SCRIPT="
35 s/@PACKAGE@/$PACKAGE/g;
36 s/@PACKAGE_NAME@/$PACKAGE_NAME/g;
37 s/@PACKAGE_BUGREPORT@/$PACKAGE_BUGREPORT/g;
38 s/@PACKAGE_TARNAME@/$PACKAGE_TARNAME/g;
39 s/@PACKAGE_VERSION@/$PACKAGE_VERSION/g;
40 s|@SVN_REPOSITORY@|$SVN_REPOSITORY|g;
41 s/@VERSION@/$VERSION/g;
42 s/@API_VERSION@/$API_VERSION/g;
43 s/@VERSION_MAJ@/$VERSION_MAJ/g;
44 s/@VERSION_MIN@/$VERSION_MIN/g;
45 s/@VERSION_REV@/$VERSION_REV/g;
46 s/@VERSION_REL@/$VERSION_REL/g;
47 s/@CFLAGS@//g;
48 "
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 Preparing 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         output warning: This shell script is intended for those
68         output warning: who either know what they are doing or
69         output warning: or downloaded this program from the CVS
70         output warning: repository. See README for more details.
71         output warning: To avoid seeing this message in the future,
72         output warning: create an empty directory called 'CVS'.
73         output 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" ||
98 {
99         output warning: Unexpected version of GNU Autoconf "(expected $AUTOCONF_VERSION)"
100         output warning: *** Bootstrap process may fail!
101 }
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" ||
116 {
117         output warning: Unexpected version of GNU Automake "(expected $AUTOMAKE_VERSION)"
118         output warning: *** Bootstrap process may fail!
119 }
120
121 # Check for libtool
122 (which libtool > /dev/null 2>&1 ) ||
123 {
124         output error: 'Could not find GNU libtool!'
125         output You need to download and install GNU libtool v1.4 or higher.
126         output '<ftp://ftp.gnu.org/gnu/libtool/>'
127         exit 1
128 }
129
130 # Check libtool version
131 echo $BOOTSTRAP_NAME: Using $(libtoolize --version | grep ibtool)
132 libtoolize --version | grep -q "$LIBTOOL_VERSION" ||
133 {
134         output warning: Unexpected version of GNU Libtool "(expected $LIBTOOL_VERSION)"
135         output warning: *** Bootstrap process may fail!
136 }
137
138 # Versions of libtool prior to 1.4.2 have a seriously broken libltdl.
139 # If we are using this broken version, we need to patch it.
140 libtoolize --version | grep -q -e "1.4.2" -e "1.4.1" -e "1.4 " && PATCH_LTDL=1
141
142 RECONFIG_LTDL=1
143
144 for FILENAME in doxygen.cfg pkgconfig.pc project.spec ; do {
145 output Creating $FILENAME...
146 sed "$SED_SCRIPT" < "$CONFIG_DIR/$FILENAME.in" > $FILENAME;
147 } ; done
148
149 output Renaming pkgconfig.pc to $PACKAGE_TARNAME.pc.in...
150 mv pkgconfig.pc "$PACKAGE_TARNAME.pc.in"
151
152 output Renaming project.spec to $PACKAGE.spec...
153 mv project.spec "$PACKAGE.spec"
154
155 output Finishing up $PACKAGE.spec...
156 echo %changelog >> "$PACKAGE.spec"
157 cat NEWS >> "$PACKAGE.spec"
158
159 output Creating configure.in from configure.ac...
160 sed "$SED_SCRIPT" < "$CONFIG_DIR/configure.ac" > configure.in;
161
162 output Generating ChangeLog from SVN
163 if test x != "x$VERSION_REL" ; then export REVISION="--revision $VERSION_REL" ; fi
164 test -f ChangeLog || svn2cl --include-rev $REVISION $SVN_REPOSITORY/trunk/ || touch ChangeLog
165
166 output Setting up build environment...
167
168 # Set the shell to output what we are doing
169 set -x
170
171 # Create all of the build environment files
172 (
173         libtoolize -c -f --ltdl &&
174         aclocal -I "$CONFIG_DIR" $ACLOCAL_FLAGS &&
175         autoheader &&
176         autoconf -o configure &&
177         automake --force-missing --add-missing --include-deps &&
178         true
179 ) ||
180 {
181         # Something went wrong...
182         set +x
183         output Failure.
184         cleanup;
185         exit 1
186 }
187
188 # Turn off echoing of commands
189 set +x
190
191 # Reconfigure the LTDL, if necessary
192 [ $RECONFIG_LTDL"x" != "x" ] && (
193         output Reconfiguring LTDL...
194         set -x
195         (
196                 cd libltdl &&
197                 ( echo "AC_CONFIG_AUX_DIR(../config)" >> configure.* ) &&
198                 aclocal -I "../$CONFIG_DIR" &&
199                 autoheader &&
200                 autoconf &&
201                 automake --force-missing --add-missing --include-deps 
202         ) ||
203         {
204                 # Something went wrong...
205                 set +x
206                 output Failure.
207                 cleanup;
208                 exit 1
209         }
210         set +x
211 )
212
213 # If this is the broken version of LTDL, then patch it
214 [ $PATCH_LTDL"x" != "x" ] && (
215         output Patching LTDL...
216         sed "
217                 s/handle || /(handle \&\& handle->loader) || /;
218                 s/errors > 0) \&\& file_not_found ())/errors > 0) \&\& !file_not_found ())/;
219                 s/(!handle)/(!handle || !handle->loader)/;
220                 s/ access (filename, R_OK)/ !access (filename, R_OK)/;
221         " < libltdl/ltdl.c > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.c
222         sed "
223                 s/DLL_EXPORT/LTDL_DLL_EXPORT/;
224         " < libltdl/ltdl.h > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.h
225 )
226
227 (
228 output Patching libtool...
229 patch config/ltmain.sh config/ltmain.patch
230 ) || true
231 false && {
232         # Something went wrong...
233         set +x
234         output Failure.
235         cleanup;
236         exit 1
237 }
238
239 #echo '#define LTDL_SHLIB_EXT   ".so"' >> libltdl/config-h.in
240 #echo '
241 #ifdef WIN32
242 #define LTDL_SHLIB_EXT  ".dll"
243 #else
244 #if __APPLE__
245 #define LTDL_SHLIB_EXT  ".so"
246 #else
247 #define LTDL_SHLIB_EXT  ".la"
248 #endif
249 #endif ' >> libltdl/config-h.in
250
251 # output Patching configure script to look for gcc3...
252 # sed "
253 # s/g++ c++/g++3 g++ c++/;
254 # s/gcc cc/gcc3 gcc cc/;
255 # s:"'${prefix}/include'":"'${prefix}/include/synfig'":;
256 # s:PREFIX/include:PREFIX/include/ETL:;
257 # " < configure > $TEMPFILE
258 # cp $TEMPFILE configure
259
260 # Patch the Makefile.in files
261 for filename in $(find Makefile.in src -name Makefile.in) ; do {
262         echo $BOOTSTRAP_NAME: Patching $filename
263         (
264                 cp $filename $TEMPFILE &&
265                 sed "
266                         # Remove brain-dead include path
267                         s;-I. ;;
268                         
269                         # Gosh... I can't remember why I did this one...
270                         # Everything seems to work, so I'll leave it in.
271                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
272
273                         # Tell the configure script where it's origin realy is
274                         s;configure.in;config/configure.ac;
275                 " < $TEMPFILE > $filename
276         ) ||
277         {
278                 # Patch failure
279                 output Failure. Unable to patch $filename.
280                 cleanup;
281                 exit 1
282         }
283 }; done
284
285 output Creating Makefile...
286 ( echo "
287 all:
288         ./configure --enable-maintainer-mode
289         make all
290         
291 install:
292         ./configure --enable-maintainer-mode
293         make install
294         
295 check:
296         ./configure --enable-maintainer-mode
297         make check
298
299 distcheck:
300         ./configure --enable-maintainer-mode
301         make check
302         
303 dist:
304         ./configure --enable-maintainer-mode
305         make dist
306
307 docs: doxygen.cfg
308         doxygen doxygen.cfg
309
310 " ) > Makefile
311
312 output Complete.
313
314 cleanup;
315
316 # Move back to the current directory
317 cd "$CURR_DIR"
318
319 make -C src/synfig/proto