Blame buildconf

Packit 514978
#!/bin/sh
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# die prints argument string to stdout and exits this shell script.
Packit 514978
#
Packit 514978
die(){
Packit 514978
  echo "buildconf: $@"
Packit 514978
  exit 1
Packit 514978
}
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# findtool works as 'which' but we use a different name to make it more
Packit 514978
# obvious we aren't using 'which'! ;-)
Packit 514978
#
Packit 514978
findtool(){
Packit 514978
  file="$1"
Packit 514978
Packit 514978
  if { echo "$file" | grep "/" >/dev/null 2>&1; } then
Packit 514978
    # when file is given with a path check it first
Packit 514978
    if test -f "$file"; then
Packit 514978
      echo "$file"
Packit 514978
      return
Packit 514978
    fi
Packit 514978
  fi
Packit 514978
Packit 514978
  old_IFS=$IFS; IFS=':'
Packit 514978
  for path in $PATH
Packit 514978
  do
Packit 514978
    IFS=$old_IFS
Packit 514978
    # echo "checks for $file in $path" >&2
Packit 514978
    if test -f "$path/$file"; then
Packit 514978
      echo "$path/$file"
Packit 514978
      return
Packit 514978
    fi
Packit 514978
  done
Packit 514978
  IFS=$old_IFS
Packit 514978
}
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# removethis() removes all files and subdirectories with the given name,
Packit 514978
# inside and below the current subdirectory at invocation time.
Packit 514978
#
Packit 514978
removethis(){
Packit 514978
  if test "$#" = "1"; then
Packit 514978
    find . -depth -name $1 -print > buildconf.tmp.$$
Packit 514978
    while read fdname
Packit 514978
    do
Packit 514978
      if test -f "$fdname"; then
Packit 514978
        rm -f "$fdname"
Packit 514978
      elif test -d "$fdname"; then
Packit 514978
        rm -f -r "$fdname"
Packit 514978
      fi
Packit 514978
    done < buildconf.tmp.$$
Packit 514978
    rm -f buildconf.tmp.$$
Packit 514978
  fi
Packit 514978
}
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# Ensure that buildconf runs from the subdirectory where configure.ac lives
Packit 514978
#
Packit 514978
if test ! -f configure.ac ||
Packit 514978
  test ! -f ares_init.c ||
Packit 514978
  test ! -f m4/cares-functions.m4; then
Packit 514978
  echo "Can not run buildconf from outside of c-ares source subdirectory!"
Packit 514978
  echo "Change to the subdirectory where buildconf is found, and try again."
Packit 514978
  exit 1
Packit 514978
fi
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# GNU libtool preliminary check
Packit 514978
#
Packit 514978
want_lt_major=1
Packit 514978
want_lt_minor=4
Packit 514978
want_lt_patch=2
Packit 514978
want_lt_version=1.4.2
Packit 514978
Packit 514978
# This approach that tries 'glibtoolize first is intended for systems that
Packit 514978
# have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
Packit 514978
Packit 514978
libtoolize=`findtool glibtoolize 2>/dev/null`
Packit 514978
if test ! -x "$libtoolize"; then
Packit 514978
  libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
Packit 514978
fi
Packit 514978
if test -z "$libtoolize"; then
Packit 514978
  echo "buildconf: libtoolize not found."
Packit 514978
  echo "    You need GNU libtoolize $want_lt_version or newer installed."
Packit 514978
  exit 1
Packit 514978
fi
Packit 514978
Packit 514978
lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
Packit 514978
lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
Packit 514978
lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
Packit 514978
if test -z "$lt_version"; then
Packit 514978
  echo "buildconf: libtoolize not found."
Packit 514978
  echo "    You need GNU libtoolize $want_lt_version or newer installed."
Packit 514978
  exit 1
Packit 514978
fi
Packit 514978
old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
Packit 514978
lt_major=$1
Packit 514978
lt_minor=$2
Packit 514978
lt_patch=$3
Packit 514978
Packit 514978
if test -z "$lt_major"; then
Packit 514978
  lt_status="bad"
Packit 514978
elif test "$lt_major" -gt "$want_lt_major"; then
Packit 514978
  lt_status="good"
Packit 514978
elif test "$lt_major" -lt "$want_lt_major"; then
Packit 514978
  lt_status="bad"
Packit 514978
elif test -z "$lt_minor"; then
Packit 514978
  lt_status="bad"
Packit 514978
elif test "$lt_minor" -gt "$want_lt_minor"; then
Packit 514978
  lt_status="good"
Packit 514978
elif test "$lt_minor" -lt "$want_lt_minor"; then
Packit 514978
  lt_status="bad"
Packit 514978
elif test -z "$lt_patch"; then
Packit 514978
  lt_status="bad"
Packit 514978
elif test "$lt_patch" -gt "$want_lt_patch"; then
Packit 514978
  lt_status="good"
Packit 514978
elif test "$lt_patch" -lt "$want_lt_patch"; then
Packit 514978
  lt_status="bad"
Packit 514978
else
Packit 514978
  lt_status="good"
Packit 514978
fi
Packit 514978
if test "$lt_status" != "good"; then
Packit 514978
  echo "buildconf: libtoolize version $lt_version found."
Packit 514978
  echo "    You need GNU libtoolize $want_lt_version or newer installed."
Packit 514978
  exit 1
Packit 514978
fi
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# perl check
Packit 514978
#
Packit 514978
PERL=`findtool ${PERL:-perl}`
Packit 514978
if test -z "$PERL"; then
Packit 514978
  echo "buildconf: perl not found"
Packit 514978
  exit 1
Packit 514978
fi
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# Remove files generated on previous buildconf/configure run.
Packit 514978
#
Packit 514978
for fname in .deps \
Packit 514978
    .libs \
Packit 514978
    *.la \
Packit 514978
    *.lo \
Packit 514978
    *.a \
Packit 514978
    *.o \
Packit 514978
    Makefile \
Packit 514978
    Makefile.in \
Packit 514978
    aclocal.m4 \
Packit 514978
    aclocal.m4.bak \
Packit 514978
    ares_build.h \
Packit 514978
    ares_config.h \
Packit 514978
    ares_config.h.in \
Packit 514978
    autom4te.cache \
Packit 514978
    compile \
Packit 514978
    config.guess \
Packit 514978
    config.log \
Packit 514978
    config.lt \
Packit 514978
    config.status \
Packit 514978
    config.sub \
Packit 514978
    configure \
Packit 514978
    depcomp \
Packit 514978
    libcares.pc \
Packit 514978
    libtool \
Packit 514978
    libtool.m4 \
Packit 514978
    libtool.m4.tmp \
Packit 514978
    ltmain.sh \
Packit 514978
    ltoptions.m4 \
Packit 514978
    ltsugar.m4 \
Packit 514978
    ltversion.m4 \
Packit 514978
    lt~obsolete.m4 \
Packit 514978
    missing \
Packit 514978
    stamp-h1 \
Packit 514978
    stamp-h2 ; do
Packit 514978
  removethis "$fname"
Packit 514978
done
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# run the correct scripts now
Packit 514978
#
Packit 514978
Packit 514978
echo "buildconf: running libtoolize"
Packit 514978
${libtoolize} --copy --automake --force || die "libtoolize command failed"
Packit 514978
Packit 514978
# When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
Packit 514978
# subdirectory and this local copy is patched to fix some warnings that
Packit 514978
# are triggered when running aclocal and using autoconf 2.62 or later.
Packit 514978
Packit 514978
if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
Packit 514978
  if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
Packit 514978
    echo "buildconf: copying libtool.m4 to local m4 subdir"
Packit 514978
    ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
Packit 514978
    if test -f $ac_dir/libtool.m4; then
Packit 514978
      cp -f $ac_dir/libtool.m4 m4/libtool.m4
Packit 514978
    else
Packit 514978
      echo "buildconf: $ac_dir/libtool.m4 not found"
Packit 514978
    fi
Packit 514978
    if test -f m4/libtool.m4; then
Packit 514978
      echo "buildconf: renaming some variables in local m4/libtool.m4"
Packit 514978
      $PERL -i.tmp -pe \
Packit 514978
        's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
Packit 514978
         s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
Packit 514978
        m4/libtool.m4
Packit 514978
      rm -f m4/libtool.m4.tmp
Packit 514978
    fi
Packit 514978
  fi
Packit 514978
fi
Packit 514978
Packit 514978
if test -f m4/libtool.m4; then
Packit 514978
  echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
Packit 514978
  $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
Packit 514978
  rm -f m4/libtool.m4.tmp
Packit 514978
fi
Packit 514978
Packit 514978
echo "buildconf: running aclocal"
Packit 514978
${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
Packit 514978
Packit 514978
echo "buildconf: converting all mv to mv -f in local aclocal.m4"
Packit 514978
$PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
Packit 514978
Packit 514978
echo "buildconf: running autoheader"
Packit 514978
${AUTOHEADER:-autoheader} || die "autoheader command failed"
Packit 514978
Packit 514978
echo "buildconf: running autoconf"
Packit 514978
${AUTOCONF:-autoconf} || die "autoconf command failed"
Packit 514978
Packit 514978
echo "buildconf: running automake"
Packit 514978
${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# GNU libtool complementary check
Packit 514978
#
Packit 514978
# Depending on the libtool and automake versions being used, config.guess
Packit 514978
# might not be installed in the subdirectory until automake has finished.
Packit 514978
# So we can not attempt to use it until this very last buildconf stage.
Packit 514978
#
Packit 514978
if test ! -f ./config.guess; then
Packit 514978
  echo "buildconf: config.guess not found"
Packit 514978
else
Packit 514978
  buildhost=`./config.guess 2>/dev/null|head -n 1`
Packit 514978
  case $buildhost in
Packit 514978
    *-*-darwin*)
Packit 514978
      need_lt_major=1
Packit 514978
      need_lt_minor=5
Packit 514978
      need_lt_patch=26
Packit 514978
      need_lt_check="yes"
Packit 514978
      ;;
Packit 514978
    *-*-hpux*)
Packit 514978
      need_lt_major=1
Packit 514978
      need_lt_minor=5
Packit 514978
      need_lt_patch=24
Packit 514978
      need_lt_check="yes"
Packit 514978
      ;;
Packit 514978
  esac
Packit 514978
  if test ! -z "$need_lt_check"; then
Packit 514978
    if test -z "$lt_major"; then
Packit 514978
      lt_status="bad"
Packit 514978
    elif test "$lt_major" -gt "$need_lt_major"; then
Packit 514978
      lt_status="good"
Packit 514978
    elif test "$lt_major" -lt "$need_lt_major"; then
Packit 514978
      lt_status="bad"
Packit 514978
    elif test -z "$lt_minor"; then
Packit 514978
      lt_status="bad"
Packit 514978
    elif test "$lt_minor" -gt "$need_lt_minor"; then
Packit 514978
      lt_status="good"
Packit 514978
    elif test "$lt_minor" -lt "$need_lt_minor"; then
Packit 514978
      lt_status="bad"
Packit 514978
    elif test -z "$lt_patch"; then
Packit 514978
      lt_status="bad"
Packit 514978
    elif test "$lt_patch" -gt "$need_lt_patch"; then
Packit 514978
      lt_status="good"
Packit 514978
    elif test "$lt_patch" -lt "$need_lt_patch"; then
Packit 514978
      lt_status="bad"
Packit 514978
    else
Packit 514978
      lt_status="good"
Packit 514978
    fi
Packit 514978
    if test "$lt_status" != "good"; then
Packit 514978
      need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
Packit 514978
      echo "buildconf: libtool version $lt_version found."
Packit 514978
      echo "            $buildhost requires GNU libtool $need_lt_version or newer installed."
Packit 514978
      rm -f configure
Packit 514978
      exit 1
Packit 514978
    fi
Packit 514978
  fi
Packit 514978
fi
Packit 514978
Packit 514978
#--------------------------------------------------------------------------
Packit 514978
# Finished successfully.
Packit 514978
#
Packit 514978
echo "buildconf: OK"
Packit 514978
Packit 514978
if test -f "test/buildconf"; then
Packit 514978
  cd test && ./buildconf
Packit 514978
fi
Packit 514978
Packit 514978
exit 0