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