minor updates
[synfig.git] / synfig-core / trunk / 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/@VERSION@/$VERSION/g;
41 s/@API_VERSION@/$API_VERSION/g;
42 s/@VERSION_MAJ@/$VERSION_MAJ/g;
43 s/@VERSION_MIN@/$VERSION_MIN/g;
44 s/@VERSION_REV@/$VERSION_REV/g;
45 s/@VERSION_REL@/$VERSION_REL/g;
46 s/@CFLAGS@//g;
47 "
48
49 # Define the output function
50 output () {
51         echo $BOOTSTRAP_NAME: $*
52 }
53
54 # Define the cleanup function
55 cleanup () {
56         output Cleaning up...
57         rm -fr config.cache autom4te*.cache configure.in $TEMPFILE
58 }
59
60 output Prepairing build environment for $PACKAGE-$VERSION...
61
62 # Look for the CVS directory. If we don't find it, we need to
63 # ask the user if they know what they are doing.
64 ( test -d CVS || test -d .svn ) ||
65 {
66         output warning: This shell script is intended for those
67         output warning: who either know what they are doing or
68         output warning: or downloaded this program from the CVS
69         output warning: repository. See README for more details.
70         output warning: To avoid seeing this message in the future,
71         output warning: create an empty directory called 'CVS'.
72         output Waiting for 15 seconds...
73         sleep 15
74 }
75
76 # Create the temporary file
77 output Creating temporary file...
78 TEMPFILE=`mktemp /tmp/$BOOTSTRAP_NAME.XXXXXX` ||
79 {
80         output ERROR: Unable to create temporary file!
81         exit 1
82 }
83
84 # Check for autoconf
85 (which autoconf > /dev/null 2>&1 ) ||
86 {
87         output error: 'Could not find GNU autoconf!'
88         output You need to download and install GNU autoconf v2.52 or higher.
89         output '<ftp://ftp.gnu.org/gnu/autoconf/>'
90         cleanup;
91         exit 1
92 }
93
94 # Check autoconf version
95 output Using $(autoconf --version | grep utoconf)
96 autoconf --version | grep -q "$AUTOCONF_VERSION" ||
97 {
98         output warning: Unexpected version of GNU Autoconf "(expected $AUTOCONF_VERSION)"
99         output warning: *** Bootstrap process may fail!
100 }
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" ||
115 {
116         output warning: Unexpected version of GNU Automake "(expected $AUTOMAKE_VERSION)"
117         output warning: *** Bootstrap process may fail!
118 }
119
120 # Check for libtool
121 (which libtool > /dev/null 2>&1 ) ||
122 {
123         output error: 'Could not find GNU libtool!'
124         output You need to download and install GNU libtool v1.4 or higher.
125         output '<ftp://ftp.gnu.org/gnu/libtool/>'
126         exit 1
127 }
128
129 # Check libtool version
130 echo $BOOTSTRAP_NAME: Using $(libtoolize --version | grep ibtool)
131 libtoolize --version | grep -q "$LIBTOOL_VERSION" ||
132 {
133         output warning: Unexpected version of GNU Libtool "(expected $LIBTOOL_VERSION)"
134         output warning: *** Bootstrap process may fail!
135 }
136
137 # Versions of libtool prior to 1.4.2 have a seriously broken libltdl.
138 # If we are using this broken version, we need to patch it.
139 libtoolize --version | grep -q -e "1.4.2" -e "1.4.1" -e "1.4 " && PATCH_LTDL=1
140
141 RECONFIG_LTDL=1
142
143 for FILENAME in doxygen.cfg pkgconfig.pc project.spec ; do {
144 output Creating $FILENAME...
145 sed "$SED_SCRIPT" < $CONFIG_DIR/$FILENAME.in > $FILENAME;
146 } ; done
147
148 output Renaming pkgconfig.pc to $PACKAGE_TARNAME.pc.in...
149 mv pkgconfig.pc "$PACKAGE_TARNAME.pc.in"
150
151 output Renaming project.spec to $PACKAGE-$VERSION.spec...
152 mv project.spec "$PACKAGE-$VERSION.spec"
153
154 output Finishing up $PACKAGE-$VERSION.spec...
155 echo %changelog >> "$PACKAGE-$VERSION.spec"
156 cat NEWS >> "$PACKAGE-$VERSION.spec"
157
158 output Creating configure.in from configure.ac...
159 sed "$SED_SCRIPT" < $CONFIG_DIR/configure.ac > configure.in;
160
161 output Setting up build environment...
162
163 # Set the shell to output what we are doing
164 set -x
165
166 # Create all of the build environment files
167 (
168         libtoolize -c -f --ltdl &&
169         aclocal -I $CONFIG_DIR $ACLOCAL_FLAGS &&
170         autoheader &&
171         autoconf -o configure &&
172         automake --foreign --add-missing --copy --include-deps &&
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 # Reconfigure the LTDL, if necessary
187 [ $RECONFIG_LTDL"x" != "x" ] && (
188         output Reconfiguring LTDL...
189         set -x
190         (
191                 cd libltdl &&
192                 ( echo "AC_CONFIG_AUX_DIR(../config)" >> configure.[ai][cn] ) &&
193                 aclocal -I $CONFIG_DIR &&
194                 autoheader &&
195                 autoconf &&
196                 automake --foreign --add-missing --copy
197         ) ||
198         {
199                 # Something went wrong...
200                 set +x
201                 output Failure.
202                 cleanup;
203                 exit 1
204         }
205         set +x
206 )
207
208 # If this is the broken version of LTDL, then patch it
209 [ $PATCH_LTDL"x" != "x" ] && (
210         output Patching LTDL...
211         sed "
212                 s/handle || /(handle \&\& handle->loader) || /;
213                 s/errors > 0) \&\& file_not_found ())/errors > 0) \&\& !file_not_found ())/;
214                 s/(!handle)/(!handle || !handle->loader)/;
215                 s/ access (filename, R_OK)/ !access (filename, R_OK)/;
216         " < libltdl/ltdl.c > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.c
217         sed "
218                 s/DLL_EXPORT/LTDL_DLL_EXPORT/;
219         " < libltdl/ltdl.h > $TEMPFILE && cp $TEMPFILE libltdl/ltdl.h
220 )
221
222 (
223 output Patching libtool...
224 patch config/ltmain.sh config/ltmain.patch
225 ) || true
226 false && {
227         # Something went wrong...
228         set +x
229         output Failure.
230         cleanup;
231         exit 1
232 }
233
234 #echo '#define LTDL_SHLIB_EXT   ".so"' >> libltdl/config-h.in
235 #echo '
236 #ifdef WIN32
237 #define LTDL_SHLIB_EXT  ".dll"
238 #else
239 #if __APPLE__
240 #define LTDL_SHLIB_EXT  ".so"
241 #else
242 #define LTDL_SHLIB_EXT  ".la"
243 #endif
244 #endif ' >> libltdl/config-h.in
245
246 # output Patching configure script to look for gcc3...
247 # sed "
248 # s/g++ c++/g++3 g++ c++/;
249 # s/gcc cc/gcc3 gcc cc/;
250 # s:"'${prefix}/include'":"'${prefix}/include/sinfg'":;
251 # s:PREFIX/include:PREFIX/include/ETL:;
252 # " < configure > $TEMPFILE
253 # cp $TEMPFILE configure
254
255 # Patch the Makefile.in files
256 for filename in $(find Makefile.in src -name Makefile.in) ; do {
257         echo $BOOTSTRAP_NAME: Patching $filename
258         (
259                 cp $filename $TEMPFILE &&
260                 sed "
261                         # Remove brain-dead include path
262                         s;-I. ;;
263                         
264                         # Gosh... I can't remember why I did this one...
265                         # Everything seems to work, so I'll leave it in.
266                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
267
268                         # Tell the configure script where it's origin realy is
269                         s;configure.in;config/configure.ac;
270                 " < $TEMPFILE > $filename
271         ) ||
272         {
273                 # Patch failure
274                 output Failure. Unable to patch $filename.
275                 cleanup;
276                 exit 1
277         }
278 }; done
279
280 output Creating Makefile...
281 ( echo "
282 all:
283         ./configure --enable-maintainer-mode
284         make all
285         
286 install:
287         ./configure --enable-maintainer-mode
288         make install
289         
290 check:
291         ./configure --enable-maintainer-mode
292         make check
293
294 distcheck:
295         ./configure --enable-maintainer-mode
296         make check
297         
298 dist:
299         ./configure --enable-maintainer-mode
300         make dist
301
302 docs: doxygen.cfg
303         doxygen doxygen.cfg
304
305 " ) > Makefile
306
307 output Complete.
308
309 cleanup;
310
311 # Move back to the current directory
312 cd $CURR_DIR
313
314 make -C src/synfig/proto