Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_04 / synfig-core / bootstrap
1 #! /bin/sh
2 #
3 # Sinfg Bootstrap Script
4 # $Id: bootstrap,v 1.2 2005/01/10 07:40:26 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 [ -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 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         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-$VERSION.spec...
153 mv project.spec "$PACKAGE-$VERSION.spec"
154
155 output Finishing up $PACKAGE-$VERSION.spec...
156 echo %changelog >> "$PACKAGE-$VERSION.spec"
157 cat NEWS >> "$PACKAGE-$VERSION.spec"
158
159 output Creating configure.in from configure.ac...
160 sed "$SED_SCRIPT" < $CONFIG_DIR/configure.ac > configure.in;
161
162 output Setting up build environment...
163
164 # Set the shell to output what we are doing
165 set -x
166
167 # Create all of the build environment files
168 (
169         libtoolize -c -f --ltdl &&
170         aclocal -I $CONFIG_DIR $ACLOCAL_FLAGS &&
171         autoheader &&
172         autoconf -o configure &&
173         automake --foreign --add-missing --copy --include-deps &&
174         true
175 ) ||
176 {
177         # Something went wrong...
178         set +x
179         output Failure.
180         cleanup;
181         exit 1
182 }
183
184 # Turn off echoing of commands
185 set +x
186
187 # Reconfigure the LTDL, if necessary
188 [ $RECONFIG_LTDL"x" != "x" ] && (
189         output Reconfiguring LTDL...
190         set -x
191         (
192                 cd libltdl &&
193                 ( echo "AC_CONFIG_AUX_DIR(../config)" >> configure.[ai][cn] ) &&
194                 aclocal -I $CONFIG_DIR &&
195                 autoheader &&
196                 autoconf &&
197                 automake --foreign --add-missing --copy
198         ) ||
199         {
200                 # Something went wrong...
201                 set +x
202                 output Failure.
203                 cleanup;
204                 exit 1
205         }
206         set +x
207 )
208
209 # If this is the broken version of LTDL, then patch it
210 [ $PATCH_LTDL"x" != "x" ] && (
211         output Patching LTDL...
212         sed "
213                 s/handle || /(handle \&\& handle->loader) || /;
214                 s/errors > 0) \&\& file_not_found ())/errors > 0) \&\& !file_not_found ())/;
215                 s/(!handle)/(!handle || !handle->loader)/;
216                 s/ access (filename, R_OK)/ !access (filename, R_OK)/;
217         " < libltdl/ltdl.c > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.c
218         sed "
219                 s/DLL_EXPORT/LTDL_DLL_EXPORT/;
220         " < libltdl/ltdl.h > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.h
221 )
222
223 (
224 output Patching libtool...
225 patch config/ltmain.sh config/ltmain.patch
226 ) || true
227 false && {
228         # Something went wrong...
229         set +x
230         output Failure.
231         cleanup;
232         exit 1
233 }
234
235 #echo '#define LTDL_SHLIB_EXT   ".so"' >> libltdl/config-h.in
236 #echo '
237 #ifdef WIN32
238 #define LTDL_SHLIB_EXT  ".dll"
239 #else
240 #if __APPLE__
241 #define LTDL_SHLIB_EXT  ".so"
242 #else
243 #define LTDL_SHLIB_EXT  ".la"
244 #endif
245 #endif ' >> libltdl/config-h.in
246
247 # output Patching configure script to look for gcc3...
248 # sed "
249 # s/g++ c++/g++3 g++ c++/;
250 # s/gcc cc/gcc3 gcc cc/;
251 # s:"'${prefix}/include'":"'${prefix}/include/sinfg'":;
252 # s:PREFIX/include:PREFIX/include/ETL:;
253 # " < configure > $TEMPFILE
254 # cp $TEMPFILE configure
255
256 # Patch the Makefile.in files
257 for filename in $(find Makefile.in src -name Makefile.in) ; do {
258         echo $BOOTSTRAP_NAME: Patching $filename
259         (
260                 cp $filename $TEMPFILE &&
261                 sed "
262                         # Remove brain-dead include path
263                         s;-I. ;;
264                         
265                         # Gosh... I can't remember why I did this one...
266                         # Everything seems to work, so I'll leave it in.
267                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
268
269                         # Tell the configure script where it's origin realy is
270                         s;configure.in;config/configure.ac;
271                 " < $TEMPFILE > $filename
272         ) ||
273         {
274                 # Patch failure
275                 output Failure. Unable to patch $filename.
276                 cleanup;
277                 exit 1
278         }
279 }; done
280
281 output Creating Makefile...
282 ( echo "
283 all:
284         ./configure --enable-maintainer-mode
285         make all
286         
287 install:
288         ./configure --enable-maintainer-mode
289         make install
290         
291 check:
292         ./configure --enable-maintainer-mode
293         make check
294
295 distcheck:
296         ./configure --enable-maintainer-mode
297         make check
298         
299 dist:
300         ./configure --enable-maintainer-mode
301         make dist
302
303 docs: doxygen.cfg
304         doxygen doxygen.cfg
305
306 " ) > Makefile
307
308 output Complete.
309
310 cleanup;
311
312 # Move back to the current directory
313 cd $CURR_DIR
314
315 make -C src/synfig/proto