Remove SDL macros. Add quoting and cygwin support to ./bootstrap.
[synfig.git] / ETL / trunk / bootstrap
1 #! /bin/sh
2 #
3 # Extended Template Library Bootstrap Script
4 # $Id: bootstrap,v 1.2 2005/01/04 01:54:14 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
18 CONFIG_DIR="$(pwd)/config"
19
20 [ -x /bin/cygpath ] && CONFIG_DIR="`cygpath -m -s "$CONFIG_DIR"`"
21 [ -x /bin/cygpath ] && CONFIG_DIR="`cygpath -u "$CONFIG_DIR"`"
22 [ -x /bin/cygpath ] && CURR_DIR="`cygpath -m -s "$CURR_DIR"`"
23 [ -x /bin/cygpath ] && CURR_DIR="`cygpath -u "$CURR_DIR"`"
24
25 . "$CONFIG_DIR/build.cfg"
26
27 SED_SCRIPT="
28 s/@PACKAGE@/$PACKAGE/g;
29 s/@PACKAGE_NAME@/$PACKAGE_NAME/g;
30 s/@PACKAGE_BUGREPORT@/$PACKAGE_BUGREPORT/g;
31 s/@PACKAGE_TARNAME@/$PACKAGE_TARNAME/g;
32 s/@PACKAGE_VERSION@/$PACKAGE_VERSION/g;
33 s/@VERSION@/$VERSION/g;
34 s/@VERSION_MAJ@/$VERSION_MAJ/g;
35 s/@VERSION_MIN@/$VERSION_MIN/g;
36 s/@VERSION_REV@/$VERSION_REV/g;
37 s/@VERSION_REL@/$VERSION_REL/g;
38 s/@CFLAGS@//g;
39 "
40
41 # Required automake and autoconf versions
42 AUTOCONF_VERSION=2.5
43 AUTOMAKE_VERSION=1.6
44 LIBTOOL_VERSION=1.4
45 export WANT_AUTOMAKE=1.6;
46 export WANT_AUTOCONF_2_5=1;
47
48 # Define the output function
49 output () {
50         echo $BOOTSTRAP_NAME: $*
51 }
52
53 # Define the cleanup function
54 cleanup () {
55         output Cleaning up...
56         rm -fr config.cache autom4te.cache configure.in $TEMPFILE
57 }
58
59 output Prepairing build environment for $PACKAGE-$VERSION...
60
61 # Look for the CVS directory. If we don't find it, we need to
62 # ask the user if they know what they are doing.
63 ( test -d CVS || test -d .svn ) ||
64 {
65         echo "
66 $BOOTSTRAP_NAME: warning: This shell script is intended for those
67 $BOOTSTRAP_NAME: warning: who either know what they are doing or
68 $BOOTSTRAP_NAME: warning: or downloaded this program from the CVS
69 $BOOTSTRAP_NAME: warning: repository. See README for more details.
70 $BOOTSTRAP_NAME: warning: To avoid seeing this message in the future,
71 $BOOTSTRAP_NAME: warning: create an empty directory called 'CVS'."
72         echo 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" || echo \
97 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Autoconf (expected $AUTOCONF_VERSION)
98 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
99
100 # Check for automake
101 (which automake > /dev/null 2>&1 ) ||
102 {
103         output error: 'Could not find GNU automake!'
104         output You need to download and install GNU automake v1.5 or higher.
105         output '<ftp://ftp.gnu.org/gnu/automake>'
106         cleanup;
107         exit 1
108 }
109
110 # Check automake version
111 output Using $(automake --version | grep utomake)
112 automake --version | grep -q "$AUTOMAKE_VERSION" || echo \
113 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Automake (expected $AUTOMAKE_VERSION)
114 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
115
116 for FILENAME in doxygen.cfg pkgconfig.pc project.spec ; do {
117 output Creating $FILENAME...
118 sed "$SED_SCRIPT" < "$CONFIG_DIR/$FILENAME.in" > $FILENAME;
119 } ; done
120
121 output Renaming pkgconfig.pc to $PACKAGE_TARNAME.pc.in...
122 mv pkgconfig.pc "$PACKAGE_TARNAME.pc.in"
123
124 output Renaming project.spec to $PACKAGE-$VERSION.spec...
125 mv project.spec "$PACKAGE-$VERSION.spec"
126
127 output Finishing up $PACKAGE-$VERSION.spec...
128 echo %changelog >> "$PACKAGE-$VERSION.spec"
129 cat ChangeLog >> "$PACKAGE-$VERSION.spec"
130
131 output Creating configure.in from configure.ac...
132 sed "$SED_SCRIPT" < "$CONFIG_DIR/configure.ac" > configure.in;
133
134 output Setting up build environment...
135
136 # Set the shell to output what we are doing
137 set -x
138
139 # Create all of the build environment files
140 (
141         aclocal -I "$CONFIG_DIR" $ACLOCAL_FLAGS &&
142         autoheader &&
143         autoconf -o configure &&
144         automake --foreign --add-missing --copy --include-deps 
145 ) ||
146 {
147         # Something went wrong...
148         set +x
149         echo $BOOTSTRAP_NAME: Failure.
150         cleanup;
151         exit 1
152 }
153
154 # Turn off echoing of commands
155 set +x
156
157 #output Patching configure script to look for gcc3...
158 #sed "
159 #s/g++ c++/g++3 g++ c++/;
160 #s/gcc cc/gcc3 gcc cc/;
161 #s:PREFIX/include:PREFIX/include/ETL:;
162 #" < configure > $TEMPFILE
163 #cp $TEMPFILE configure
164
165 # Patch the Makefile.am files
166 for filename in $(find Makefile.in ETL test -name Makefile.in) ; do {
167         echo $BOOTSTRAP_NAME: Patching $filename
168         (
169                 cp $filename $TEMPFILE &&
170                 sed "
171                         s;-I. ;;
172                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
173                         s;configure.in;config/configure.ac;
174                 " < $TEMPFILE > $filename
175         ) ||
176         {
177                 # Patch failure
178                 echo $BOOTSTRAP_NAME: Failure. Unable to patch $filename.
179                 cleanup;
180                 exit 1
181         }
182 }; done
183
184 echo $BOOTSTRAP_NAME: Creating Makefile...
185 ( echo "
186 all:
187         ./configure --enable-maintainer-mode
188         make all
189         
190 install:
191         ./configure --enable-maintainer-mode
192         make install
193         
194 check:
195         ./configure --enable-maintainer-mode
196         make check
197
198 distcheck:
199         ./configure --enable-maintainer-mode
200         make check
201         
202 dist:
203         ./configure --enable-maintainer-mode
204         make dist
205
206 docs: doxygen.cfg
207         doxygen doxygen.cfg
208 " ) > Makefile
209
210 echo $BOOTSTRAP_NAME: Complete.
211
212 cleanup;
213
214 # Move back to the current directory
215 cd $CURR_DIR