libltdl belongs to System/Libraries
[platform/upstream/libtool.git] / bootstrap
1 #! /bin/sh
2 # bootstrap -- Helps bootstrapping libtool, when checked out from repository.
3 #
4 #   Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Free Software
5 #   Foundation, Inc,
6 #   Mritten by Gary V. Vaughan, 2003
7 #
8 #   This file is part of GNU Libtool.
9 #
10 # GNU Libtool is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation; either version 2 of
13 # the License, or (at your option) any later version.
14 #
15 # GNU Libtool is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with GNU Libtool; see the file COPYING.  If not, a copy
22 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
23 # or obtained by writing to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 ####
26
27 # Exit upon failure.
28 set -e
29
30 # It is okay for the bootstrap process to require unreleased autoconf
31 # or automake, as long as any released libtool will work with at least
32 # the newest stable versions of each.  Generally, newer versions offer
33 # better features, and configure.ac documents oldest version of each
34 # required for bootstrap (AC_PREREQ, and AM_INIT_AUTOMAKE).
35
36 SHELL=${CONFIG_SHELL-/bin/sh}
37 export SHELL
38 : ${AUTORECONF=autoreconf}
39 : ${AUTOCONF=autoconf}
40 : ${AUTOMAKE=automake}
41 : ${AUTOM4TE=autom4te}
42 : ${MAKE=make}
43 : ${GREP=grep}
44 : ${EGREP=egrep}
45 : ${FGREP=fgrep}
46 : ${SED=sed}
47 : ${LN_S='ln -s'}
48 : ${MAKEINFO=makeinfo}
49
50 case $1 in
51 --help|-h*)
52   cat <<EOF
53 `echo $0 | sed 's,^.*/,,g'`: This script is designed to bootstrap a fresh repository checkout
54 of Libtool.  Useful environment variable settings:
55   reconfdirs='. libltdl'     Do not bootstrap the old test suite.
56 EOF
57   exit
58   ;;
59 esac
60
61 test -f ./configure.ac || {
62   echo "bootstrap: can't find ./configure.ac, please rerun from top_srcdir"
63   exit 1
64 }
65
66
67 # Extract auxdir and m4dir from configure.ac:
68 lt_tab='        '
69 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
70         /AC_CONFIG_AUX_DIR[^_]/  {
71             s,^.*AC_CONFIG_AUX_DIR([[ '"$lt_tab"']*\([^])]*\).*$,auxdir=\1,; p;
72         };
73         /AC_CONFIG_MACRO_DIR/   {
74             s,^.*AC_CONFIG_MACRO_DIR([[ '"$lt_tab"']*\([^])]*\).*$,m4dir=\1,; p;
75         };
76         d;'
77 eval `cat configure.ac 2>/dev/null | $SED "$my_sed_traces"`
78
79
80 # Upgrade caveat:
81 cat <<'EOF'
82 WARNING: If bootstrapping with this script fails, it may be due to an
83 WARNING: incompatible installed `libtool.m4' being pulled in to
84 WARNING: `aclocal.m4'.  The best way to work around such a problem is to
85 WARNING: uninstall your system libtool files, or failing that, overwrite
86 WARNING: them with all m4 file as shipped with this distribution (except
87 WARNING: `lt~obsolete.m4').  After that, retry this bootstrap.
88 EOF
89
90 find . -depth \( -name autom4te.cache -o -name libtool \) -print \
91   | grep -v '{arch}' \
92   | xargs rm -rf
93
94 # Delete stale files from previous libtool versions.
95 rm -f acinclude.m4 libltdl/config.h
96
97 for file in argz.c lt__dirent.c lt__strl.c; do
98   rm -f $file
99 done
100
101 if test -z "$reconfdirs"; then
102   reconfdirs=". libltdl `ls -1d tests/*demo tests/*demo[0-9]`"
103 fi
104
105 # Extract the package name and version number from configure.ac:
106 set dummy `$SED -n '
107     /AC_INIT/{
108         s/[][,()]/ /g
109         s/ GNU / /
110         p
111     }' configure.ac`
112 shift
113 PACKAGE=`echo "$2" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
114 PACKAGE_NAME=$2
115 PACKAGE_URL=
116 if grep 'AC_INIT.*GNU' configure.ac >/dev/null; then
117   PACKAGE_NAME="GNU $PACKAGE_NAME"
118   PACKAGE_URL="http://www.gnu.org/software/$PACKAGE/"
119 fi
120 VERSION=$3
121
122 # Whip up a dirty Makefile:
123 makes='Makefile.am libltdl/Makefile.inc'
124 rm -f Makefile
125 $SED '/^if /,/^endif$/d;/^else$/,/^endif$/d;/^include /d' $makes > Makefile
126
127 # Building distributed files from configure is bad for automake, so we
128 # generate them here, and have Makefile rules to keep them up to date.
129 # We don't have all the substitution values to build ltmain.sh from this
130 # script yet, but we need config/ltmain.sh for the libtool commands in
131 # configure, and ltversion.m4 to generate configure in the first place:
132 rm -f $auxdir/ltmain.sh $m4dir/ltversion.m4
133
134 $MAKE ./$auxdir/ltmain.sh ./$m4dir/ltversion.m4 \
135     ./libtoolize.in ./tests/defs.in ./tests/package.m4 \
136     ./tests/testsuite ./libltdl/Makefile.am ./doc/notes.txt \
137     srcdir=. top_srcdir=. PACKAGE="$PACKAGE" VERSION="$VERSION" \
138     PACKAGE_NAME="$PACKAGE_NAME" PACKAGE_URL="$PACKAGE_URL" \
139     PACKAGE_BUGREPORT="bug-$PACKAGE@gnu.org" M4SH="$AUTOM4TE --language=m4sh" \
140     AUTOTEST="$AUTOM4TE --language=autotest" SED="$SED" MAKEINFO="$MAKEINFO" \
141     GREP="$GREP" FGREP="$FGREP" EGREP="$EGREP" LN_S="$LN_S"
142
143 rm -f Makefile
144
145 # Make a dummy libtoolize script for autoreconf:
146 cat > $auxdir/libtoolize <<'EOF'
147 #! /bin/sh
148 # This is a dummy file for bootstrapping libtool.
149 echo "$0: Bootstrap detected, no files installed." | sed 's,^.*/,,g'
150 exit 0
151 EOF
152 chmod 755 $auxdir/libtoolize
153
154 # Running the installed `libtoolize' will trash the local (newer) libtool.m4
155 # among others.  Call the dummy script we made earlier.
156 LIBTOOLIZE=`pwd`/$auxdir/libtoolize
157 export LIBTOOLIZE
158
159 for sub in $reconfdirs; do
160   $AUTORECONF --force --verbose --install $sub
161 done
162
163 # Autoheader valiantly tries to prevent needless reconfigurations by
164 # not changing the timestamp of config-h.in unless the file contents
165 # are updated.  Unfortunately config-h.in depends on aclocal.m4 which
166 # *is* updated, so running 'libtoolize --ltdl=. && configure && make'
167 # causes autoheader to be called... undesireable for users that do not
168 # have it!  Fudge the timestamp to prevent that:
169 sleep 2 && touch libltdl/config-h.in
170
171 # Remove our dummy libtoolize
172 rm -f $auxdir/libtoolize
173
174 # These files can cause an infinite configure loop if left behind.
175 rm -f Makefile libltdl/Makefile libtool vcl.tmp
176
177 # This file is misgenerated earlier in bootstrap to satisfy automake 1.9.1
178 # and earlier, but has a new enough timestamp to not be updated.  Force it
179 # to be regenerated at make-time with proper substitutions in place:
180 touch $auxdir/ltmain.m4sh
181
182 for macro in LT_INIT AC_PROG_LIBTOOL AM_PROG_LIBTOOL; do
183   if grep $macro aclocal.m4 libltdl/aclocal.m4; then
184     echo "Bogus $macro macro contents in an aclocal.m4 file." >&2
185     exit 1
186   else :; fi
187 done
188
189 exit 0