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