]> git.ipfire.org Git - thirdparty/util-linux.git/blame - autogen.sh
exch: cosmetic changes
[thirdparty/util-linux.git] / autogen.sh
CommitLineData
8eeb575c
KZ
1#!/bin/sh
2
3#
4# Helps generate autoconf/automake stuff, when code is checked out from SCM.
5#
93e0319d 6# Copyright (C) 2006-2010 - Karel Zak <kzak@redhat.com>
8eeb575c
KZ
7#
8
9srcdir=`dirname $0`
b12991dd 10test -z "$srcdir" && srcdir=.
8eeb575c
KZ
11
12THEDIR=`pwd`
13cd $srcdir
14DIE=0
15
36606364
KZ
16warn_mesg ()
17{
18 echo
19 echo "WARNING: $1"
20 test -z "$2" ||
21 echo " $2"
22 echo
23}
24
25error_mesg ()
26{
27 echo
28 echo "ERROR: $1"
29 test -z "$2" ||
30 echo " $2"
31 echo
32 DIE=1
33}
34
f8d75a66 35# provide simple gettext backward compatibility
91c520bc
RM
36autopoint_fun ()
37{
38 # we have to deal with set -e ...
91c520bc 39 ret="0"
91c520bc 40
f8d75a66
RM
41 # check against this hardcoded set of alternative gettext versions
42 gt_ver=`gettext --version |\
e46a7f8e 43 sed -n -e 's/.* \(0\.17\|0\.18\|0\.18\.[1-2]\)$/\1/p'`
91c520bc 44
f8d75a66 45 if [ -n "$gt_ver" ]; then
36606364 46 warn_mesg "warning: forcing autopoint to use old gettext $gt_ver"
f8d75a66 47 rm -f configure.ac.autogenbak
91c520bc 48 sed -i.autogenbak configure.ac \
f8d75a66 49 -e "s/\(AM_GNU_GETTEXT_VERSION\).*/\1([$gt_ver])/"
91c520bc
RM
50 fi
51
52 autopoint "$@" || ret=$?
91c520bc 53
f8d75a66 54 if [ -n "$gt_ver" ]; then
91c520bc
RM
55 mv configure.ac.autogenbak configure.ac
56 fi
57
58 return $ret
59}
60
36606364
KZ
61test -f sys-utils/mount.c ||
62 error_mesg "You must run this script in the top-level util-linux directory."
93e0319d 63
36606364
KZ
64(autopoint --version) < /dev/null > /dev/null 2>&1 ||
65 error_mesg "You must have autopoint installed to generate the util-linux build system." "The autopoint command is part of the GNU gettext package."
0024583c 66
36606364
KZ
67(autoconf --version) < /dev/null > /dev/null 2>&1 ||
68 error_mesg "You must have autoconf installed to generate the util-linux build system."
69
70(autoheader --version) < /dev/null > /dev/null 2>&1 ||
71 error_mesg "You must have autoheader installed to generate the util-linux build system." "The autoheader command is part of the GNU autoconf package."
72
73[ -x "$(command -v gettext)" -o -x "$(command -v xgettext)" ] ||
74 warn_mesg "You need have [x]gettext binary installed to update po/ stuff."
67735475 75
88128214
KZ
76(flex --version) < /dev/null > /dev/null 2>&1 ||
77 error_mesg "You must have flex installed to build the util-linux."
78
30d7f61f 79if ! (bison --version) < /dev/null > /dev/null 2>&1; then
36606364 80 error_mesg "You must have bison installed to build the util-linux."
30d7f61f 81else
5ff48b5f 82 lexver=$(bison --version | awk '/^bison \(GNU [Bb]ison\)/ { print $4 }')
30d7f61f
KZ
83 case "$lexver" in
84 [2-9].*)
85 ;;
86 *)
36606364 87 error_mesg "You must have bison version >= 2.x, but you have $lexver."
30d7f61f
KZ
88 ;;
89 esac
90fi
91
88128214 92
0024583c
RM
93LIBTOOLIZE=libtoolize
94case `uname` in Darwin*) LIBTOOLIZE=glibtoolize ;; esac
95if ! ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1; then
36606364 96 error_mesg "You must have libtool-2 installed to generate the util-linux build system."
0024583c 97else
6b5cad00 98 ltver=$($LIBTOOLIZE --version | awk '/^[g]*libtoolize/ { print $4 }')
0024583c 99 ltver=${ltver:-"none"}
36606364
KZ
100 test ${ltver##2.} = "$ltver" &&
101 error_mesg "You must have libtool version >= 2.x.x, but you have $ltver."
0024583c
RM
102fi
103
36606364
KZ
104(automake --version) < /dev/null > /dev/null 2>&1 ||
105 error_mesg "You must have automake installed to generate the util-linux build system."
8eeb575c 106
93e0319d
KZ
107if test "$DIE" -eq 1; then
108 exit 1
109fi
110
952a06cf 111echo
a0aee0a9 112echo "Generating build-system with:"
952a06cf
KZ
113echo " autopoint: $(autopoint --version | head -1)"
114echo " aclocal: $(aclocal --version | head -1)"
115echo " autoconf: $(autoconf --version | head -1)"
116echo " autoheader: $(autoheader --version | head -1)"
117echo " automake: $(automake --version | head -1)"
0024583c 118echo " libtoolize: $($LIBTOOLIZE --version | head -1)"
88128214 119echo " flex: $(flex --version | head -1)"
30d7f61f 120echo " bison: $(bison --version | head -1)"
36606364 121echo
952a06cf 122
38c75b59
SK
123rm -rf autom4te.cache
124
f2c166ff 125set -e
7c2ee1d2 126po/update-potfiles
91c520bc 127autopoint_fun --force $AP_OPTS
cc3c3fdd 128if ! grep -q datarootdir po/Makefile.in.in; then
36606364 129 echo "INFO: autopoint does not honor dataroot variable, patching."
cc3c3fdd
SK
130 sed -i -e 's/^datadir *=\(.*\)/datarootdir = @datarootdir@\
131datadir = @datadir@/g' po/Makefile.in.in
132fi
0024583c 133$LIBTOOLIZE --force $LT_OPTS
06953d22
KZ
134
135# patch libtool
136if test -f tools/libtool.m4.patch; then
137 if test -L m4/libtool.m4; then
138 cp m4/libtool.m4 m4/libtool.m4.org
139 rm m4/libtool.m4
140 mv m4/libtool.m4.org m4/libtool.m4
141 fi
34389ad0 142 set +e
30ec5b83 143 patch --batch --dry -p1 < tools/libtool.m4.patch > /dev/null 2>&1
403f9c7a
KZ
144 if [ "$?" -eq 0 ]; then
145 patch -p1 --batch < tools/libtool.m4.patch
146 fi
34389ad0 147 set -e
06953d22
KZ
148fi
149
1eca726f
KZ
150aclocal -I m4 $AL_OPTS
151autoconf $AC_OPTS
152autoheader $AH_OPTS
1e018c15 153
1eca726f 154automake --add-missing $AM_OPTS
8eeb575c 155
06953d22 156
9583461d 157cd "$THEDIR"
8eeb575c 158
952a06cf 159echo
e1bc6da9 160echo "Now type '$srcdir/configure' and 'make' to compile."
952a06cf 161echo
8eeb575c
KZ
162
163