549b442af8d3ec8ff45f932c9184f6bb95786dd8
[synfig.git] / ETL / tags / stable / bootstrap
1 #! /bin/sh
2 #
3 # Extended Template Library 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
18 CONFIG_DIR="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'@SVN_REPOSITORY@'$SVN_REPOSITORY'g;
39 s/@CFLAGS@//g;
40 "
41
42 # Required automake and autoconf versions
43 AUTOCONF_VERSION=2.5
44 AUTOMAKE_VERSION=1.6
45 LIBTOOL_VERSION=1.4
46 export WANT_AUTOMAKE=1.6;
47 export WANT_AUTOCONF_2_5=1;
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 Preparing 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         echo "
67 $BOOTSTRAP_NAME: warning: This shell script is intended for those
68 $BOOTSTRAP_NAME: warning: who either know what they are doing or
69 $BOOTSTRAP_NAME: warning: or downloaded this program from the CVS
70 $BOOTSTRAP_NAME: warning: repository. See README for more details.
71 $BOOTSTRAP_NAME: warning: To avoid seeing this message in the future,
72 $BOOTSTRAP_NAME: warning: create an empty directory called 'CVS'."
73         echo 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" || echo \
98 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Autoconf (expected $AUTOCONF_VERSION)
99 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
100
101 # Check for automake
102 (which automake > /dev/null 2>&1 ) ||
103 {
104         output error: 'Could not find GNU automake!'
105         output You need to download and install GNU automake v1.5 or higher.
106         output '<ftp://ftp.gnu.org/gnu/automake>'
107         cleanup;
108         exit 1
109 }
110
111 # Check automake version
112 output Using $(automake --version | grep utomake)
113 automake --version | grep -q "$AUTOMAKE_VERSION" || echo \
114 "$BOOTSTRAP_NAME: warning: Unexpected version of GNU Automake (expected $AUTOMAKE_VERSION)
115 $BOOTSTRAP_NAME: warning: *** Bootstrap process may fail!"
116
117 for FILENAME in doxygen.cfg pkgconfig.pc project.spec ; do {
118 output Creating $FILENAME...
119 sed "$SED_SCRIPT" < "$CONFIG_DIR/$FILENAME.in" > $FILENAME;
120 } ; done
121
122 output Renaming pkgconfig.pc to $PACKAGE_TARNAME.pc.in...
123 mv pkgconfig.pc "$PACKAGE_TARNAME.pc.in"
124
125 output Renaming project.spec to $PACKAGE.spec...
126 mv project.spec "$PACKAGE.spec"
127
128 output Finishing up $PACKAGE.spec...
129 echo %changelog >> "$PACKAGE.spec"
130 cat NEWS >> "$PACKAGE.spec"
131
132 output Creating configure.in from configure.ac...
133 sed "$SED_SCRIPT" < "$CONFIG_DIR/configure.ac" > configure.in;
134
135 output Generating ChangeLog from SVN
136 if test x != "x$VERSION_REL" ; then export REVISION="--revision $VERSION_REL" ; fi
137 test -f ChangeLog || svn2cl --include-rev $REVISION $SVN_REPOSITORY/trunk/ || touch ChangeLog
138
139 output Setting up build environment...
140
141 # Set the shell to output what we are doing
142 set -x
143
144 # Create all of the build environment files
145 (
146         aclocal -I "$CONFIG_DIR" $ACLOCAL_FLAGS &&
147         autoheader &&
148         autoconf -o configure &&
149         automake --force-missing --add-missing --include-deps 
150 ) ||
151 {
152         # Something went wrong...
153         set +x
154         echo $BOOTSTRAP_NAME: Failure.
155         cleanup;
156         exit 1
157 }
158
159 # Turn off echoing of commands
160 set +x
161
162 #output Patching configure script to look for gcc3...
163 #sed "
164 #s/g++ c++/g++3 g++ c++/;
165 #s/gcc cc/gcc3 gcc cc/;
166 #s:PREFIX/include:PREFIX/include/ETL:;
167 #" < configure > $TEMPFILE
168 #cp $TEMPFILE configure
169
170 # Patch the Makefile.am files
171 for filename in $(find Makefile.in ETL test -name Makefile.in) ; do {
172         echo $BOOTSTRAP_NAME: Patching $filename
173         (
174                 cp $filename $TEMPFILE &&
175                 sed "
176                         s;-I. ;;
177                         s;-I"'$(srcdir)'" ;-I"'$(top_srcdir)'" ;
178                         s;configure.in;config/configure.ac;
179                 " < $TEMPFILE > $filename
180         ) ||
181         {
182                 # Patch failure
183                 echo $BOOTSTRAP_NAME: Failure. Unable to patch $filename.
184                 cleanup;
185                 exit 1
186         }
187 }; done
188
189 echo $BOOTSTRAP_NAME: Creating Makefile...
190 ( echo "
191 all:
192         ./configure --enable-maintainer-mode
193         make all
194         
195 install:
196         ./configure --enable-maintainer-mode
197         make install
198         
199 check:
200         ./configure --enable-maintainer-mode
201         make check
202
203 distcheck:
204         ./configure --enable-maintainer-mode
205         make check
206         
207 dist:
208         ./configure --enable-maintainer-mode
209         make dist
210
211 docs: doxygen.cfg
212         doxygen doxygen.cfg
213 " ) > Makefile
214
215 echo $BOOTSTRAP_NAME: Complete.
216
217 cleanup;
218
219 # Move back to the current directory
220 cd "$CURR_DIR"