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