Fixed compilation issues
[distributed.git] / bootstrap
blob89d3bb886dae2d67234e1630eaa1dd48a183b886
1 #!/bin/sh
4 # bootstrap
6 # Copyright (C) 2007, 2008 Francesco Salvestrini
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 ME=bootstrap
26 # Internal functions
28 missing ()
30 PROGRAM=$1
32 if test x"$PROGRAM" = x""; then
33 return 1
35 IFS=":"
37 for i in $PATH
40 if test -f $i/$PROGRAM; then
41 echo $i/$PROGRAM
42 return 0
44 done
46 return 1
50 # External tools
52 AUTOHEADER=`missing autoheader`
53 ACLOCAL=`missing aclocal`
54 AUTOCONF=`missing autoconf`
55 AUTOMAKE=`missing automake`
56 AUTORECONF=`missing autoreconf`
57 LIBTOOL=`( missing glibtool || missing libtool )`
58 LIBTOOLIZE=`( missing glibtoolize || missing libtoolize)`
59 GNULIBTOOL=`missing gnulib-tool`
60 GIT=`missing git`
61 SED=`missing sed`
64 # Dump some useful informations
66 echo "$ME: Dumping build-tools information ..."
67 for tool in \
68 $SED \
69 $GIT \
70 $AUTOHEADER \
71 $AUTOCONF \
72 $LIBTOOL \
73 $LIBTOOLIZE \
74 $ACLOCAL \
75 $AUTOMAKE \
76 $AUTORECONF \
77 $GNULIBTOOL \
80 if test -n "$tool" ; then
81 TOOLVER=`$tool --version | head -1`
82 echo "$ME: $tool -> $TOOLVER"
84 done
87 # Prevent running bootstrap on a non-repository copy
89 $GIT log > /dev/null 2>&1 || {
90 echo "$ME: I must run on a git clone ..."
91 exit 1
93 if test x"`$GIT tag -l 2>/dev/null | $SED -n '$='`" = x""; then
94 echo "$ME: I require a repository tag in order to run ..."
95 exit 1
99 # Remove files left from the previous run
101 echo "$ME: Removing autotools related files and directories ..."
102 rm -f `find ./ -name "Makefile.in"` || exit 1
103 rm -f config.cache aclocal.m4 config.h.in configure || exit 1
104 rm -f config.guess config.sub ltmain.sh || exit 1
105 rm -rf autom4te.cache || exit 1
106 rm -rf `find ./ -name ".deps"` || exit 1
109 # configure.ac
111 echo "$ME: Building configure.ac from configure.ac.in"
112 rm -f configure.ac
113 VERSION=`git tag -l | sort -s -t '.' -k 1,1n -k 2,2n -k 3,3n | tail -n 1`
114 cat configure.ac.in | sed -e 's,[@]VERSION[@],'$VERSION',' > configure.ac || \
115 { rm -f configure.ac ; exit 1 ; }
116 chmod a-w configure.ac
119 # Call gnulib
121 if test -n "$GNULIBTOOL" ; then
122 $GNULIBTOOL \
123 --lgpl \
124 --no-changelog \
125 --macro-prefix GNULIB \
126 --no-vc-files \
127 --aux-dir=./tools/autotools \
128 --m4-base=./tools/autotools/m4 \
129 --source-base=./src/gnulib \
130 --import crypto/md5 crypto/sha1 getopt dirent || exit 1
134 # autoreconf
136 echo "$ME: Handling autotools bootstrap ..."
138 echo "$ME: Running autoreconf ..."
139 $ACLOCAL --force --install -I ./tools/autotools/m4 && \
140 $AUTORECONF --verbose --force --install -Wall || {
141 exit 1
144 exit 0