]> git.ipfire.org Git - thirdparty/util-linux.git/blame - autogen.sh
Merge branch 'fadvise/fixes' of https://github.com/t-8ch/util-linux
[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
30d7f61f 76if ! (bison --version) < /dev/null > /dev/null 2>&1; then
36606364 77 error_mesg "You must have bison installed to build the util-linux."
30d7f61f 78else
5ff48b5f 79 lexver=$(bison --version | awk '/^bison \(GNU [Bb]ison\)/ { print $4 }')
30d7f61f
KZ
80 case "$lexver" in
81 [2-9].*)
82 ;;
83 *)
36606364 84 error_mesg "You must have bison version >= 2.x, but you have $lexver."
30d7f61f
KZ
85 ;;
86 esac
87fi
88
0024583c
RM
89LIBTOOLIZE=libtoolize
90case `uname` in Darwin*) LIBTOOLIZE=glibtoolize ;; esac
91if ! ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1; then
36606364 92 error_mesg "You must have libtool-2 installed to generate the util-linux build system."
0024583c 93else
6b5cad00 94 ltver=$($LIBTOOLIZE --version | awk '/^[g]*libtoolize/ { print $4 }')
0024583c 95 ltver=${ltver:-"none"}
36606364
KZ
96 test ${ltver##2.} = "$ltver" &&
97 error_mesg "You must have libtool version >= 2.x.x, but you have $ltver."
0024583c
RM
98fi
99
36606364
KZ
100(automake --version) < /dev/null > /dev/null 2>&1 ||
101 error_mesg "You must have automake installed to generate the util-linux build system."
8eeb575c 102
93e0319d
KZ
103if test "$DIE" -eq 1; then
104 exit 1
105fi
106
952a06cf 107echo
a0aee0a9 108echo "Generating build-system with:"
952a06cf
KZ
109echo " autopoint: $(autopoint --version | head -1)"
110echo " aclocal: $(aclocal --version | head -1)"
111echo " autoconf: $(autoconf --version | head -1)"
112echo " autoheader: $(autoheader --version | head -1)"
113echo " automake: $(automake --version | head -1)"
0024583c 114echo " libtoolize: $($LIBTOOLIZE --version | head -1)"
30d7f61f 115echo " bison: $(bison --version | head -1)"
36606364 116echo
952a06cf 117
38c75b59
SK
118rm -rf autom4te.cache
119
f2c166ff 120set -e
7c2ee1d2 121po/update-potfiles
91c520bc 122autopoint_fun --force $AP_OPTS
cc3c3fdd 123if ! grep -q datarootdir po/Makefile.in.in; then
36606364 124 echo "INFO: autopoint does not honor dataroot variable, patching."
cc3c3fdd
SK
125 sed -i -e 's/^datadir *=\(.*\)/datarootdir = @datarootdir@\
126datadir = @datadir@/g' po/Makefile.in.in
127fi
0024583c 128$LIBTOOLIZE --force $LT_OPTS
06953d22
KZ
129
130# patch libtool
131if test -f tools/libtool.m4.patch; then
132 if test -L m4/libtool.m4; then
133 cp m4/libtool.m4 m4/libtool.m4.org
134 rm m4/libtool.m4
135 mv m4/libtool.m4.org m4/libtool.m4
136 fi
34389ad0 137 set +e
30ec5b83 138 patch --batch --dry -p1 < tools/libtool.m4.patch > /dev/null 2>&1
403f9c7a
KZ
139 if [ "$?" -eq 0 ]; then
140 patch -p1 --batch < tools/libtool.m4.patch
141 fi
34389ad0 142 set -e
06953d22
KZ
143fi
144
1eca726f
KZ
145aclocal -I m4 $AL_OPTS
146autoconf $AC_OPTS
147autoheader $AH_OPTS
1e018c15 148
1eca726f 149automake --add-missing $AM_OPTS
8eeb575c 150
06953d22 151
9583461d 152cd "$THEDIR"
8eeb575c 153
952a06cf 154echo
e1bc6da9 155echo "Now type '$srcdir/configure' and 'make' to compile."
952a06cf 156echo
8eeb575c
KZ
157
158