3 #--------------------------------------------------------------------------
4 # die prints argument string to stdout and exits this shell script.
11 #--------------------------------------------------------------------------
12 # findtool works as 'which' but we use a different name to make it more
13 # obvious we aren't using 'which'! ;-)
18 if { echo "$file" | grep "/" >/dev/null 2>&1; } then
19 # when file is given with a path check it first
20 if test -f "$file"; then
30 # echo "checks for $file in $path" >&2
31 if test -f "$path/$file"; then
39 #--------------------------------------------------------------------------
40 # removethis() removes all files and subdirectories with the given name,
41 # inside and below the current subdirectory at invocation time.
44 if test "$#" = "1"; then
45 find . -depth -name $1 -print > buildconf.tmp.$$
48 if test -f "$fdname"; then
50 elif test -d "$fdname"; then
53 done < buildconf.tmp.$$
54 rm -f buildconf.tmp.$$
58 #--------------------------------------------------------------------------
59 # Ensure that buildconf runs from the subdirectory where configure.ac lives
61 if test ! -f configure.ac ||
62 test ! -f ares_init.c ||
63 test ! -f m4/cares-functions.m4; then
64 echo "Can not run buildconf from outside of c-ares source subdirectory!"
65 echo "Change to the subdirectory where buildconf is found, and try again."
69 #--------------------------------------------------------------------------
70 # GNU libtool preliminary check
77 # This approach that tries 'glibtoolize first is intended for systems that
78 # have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
80 libtoolize=`findtool glibtoolize 2>/dev/null`
81 if test ! -x "$libtoolize"; then
82 libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
84 if test -z "$libtoolize"; then
85 echo "buildconf: libtoolize not found."
86 echo " You need GNU libtoolize $want_lt_version or newer installed."
90 lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
91 lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
92 lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
93 if test -z "$lt_version"; then
94 echo "buildconf: libtoolize not found."
95 echo " You need GNU libtoolize $want_lt_version or newer installed."
98 old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
103 if test -z "$lt_major"; then
105 elif test "$lt_major" -gt "$want_lt_major"; then
107 elif test "$lt_major" -lt "$want_lt_major"; then
109 elif test -z "$lt_minor"; then
111 elif test "$lt_minor" -gt "$want_lt_minor"; then
113 elif test "$lt_minor" -lt "$want_lt_minor"; then
115 elif test -z "$lt_patch"; then
117 elif test "$lt_patch" -gt "$want_lt_patch"; then
119 elif test "$lt_patch" -lt "$want_lt_patch"; then
124 if test "$lt_status" != "good"; then
125 echo "buildconf: libtoolize version $lt_version found."
126 echo " You need GNU libtoolize $want_lt_version or newer installed."
130 #--------------------------------------------------------------------------
133 PERL=`findtool ${PERL:-perl}`
134 if test -z "$PERL"; then
135 echo "buildconf: perl not found"
139 #--------------------------------------------------------------------------
140 # Remove files generated on previous buildconf/configure run.
179 #--------------------------------------------------------------------------
180 # run the correct scripts now
183 echo "buildconf: running libtoolize"
184 ${libtoolize} --copy --automake --force || die "libtoolize command failed"
186 # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
187 # subdirectory and this local copy is patched to fix some warnings that
188 # are triggered when running aclocal and using autoconf 2.62 or later.
190 if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
191 if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
192 echo "buildconf: copying libtool.m4 to local m4 subdir"
193 ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
194 if test -f $ac_dir/libtool.m4; then
195 cp -f $ac_dir/libtool.m4 m4/libtool.m4
197 echo "buildconf: $ac_dir/libtool.m4 not found"
199 if test -f m4/libtool.m4; then
200 echo "buildconf: renaming some variables in local m4/libtool.m4"
202 's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
203 s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
205 rm -f m4/libtool.m4.tmp
210 if test -f m4/libtool.m4; then
211 echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
212 $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
213 rm -f m4/libtool.m4.tmp
216 echo "buildconf: running aclocal"
217 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
219 echo "buildconf: converting all mv to mv -f in local aclocal.m4"
220 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
222 echo "buildconf: running autoheader"
223 ${AUTOHEADER:-autoheader} || die "autoheader command failed"
225 echo "buildconf: running autoconf"
226 ${AUTOCONF:-autoconf} || die "autoconf command failed"
228 echo "buildconf: running automake"
229 ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
231 #--------------------------------------------------------------------------
232 # GNU libtool complementary check
234 # Depending on the libtool and automake versions being used, config.guess
235 # might not be installed in the subdirectory until automake has finished.
236 # So we can not attempt to use it until this very last buildconf stage.
238 if test ! -f ./config.guess; then
239 echo "buildconf: config.guess not found"
241 buildhost=`./config.guess 2>/dev/null|head -n 1`
256 if test ! -z "$need_lt_check"; then
257 if test -z "$lt_major"; then
259 elif test "$lt_major" -gt "$need_lt_major"; then
261 elif test "$lt_major" -lt "$need_lt_major"; then
263 elif test -z "$lt_minor"; then
265 elif test "$lt_minor" -gt "$need_lt_minor"; then
267 elif test "$lt_minor" -lt "$need_lt_minor"; then
269 elif test -z "$lt_patch"; then
271 elif test "$lt_patch" -gt "$need_lt_patch"; then
273 elif test "$lt_patch" -lt "$need_lt_patch"; then
278 if test "$lt_status" != "good"; then
279 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
280 echo "buildconf: libtool version $lt_version found."
281 echo " $buildhost requires GNU libtool $need_lt_version or newer installed."
288 #--------------------------------------------------------------------------
289 # Finished successfully.
293 if test -f "test/buildconf"; then
294 cd test && ./buildconf