Gilad Arnold | 968bf19 | 2015-07-17 00:23:30 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | #-------------------------------------------------------------------------- |
| 4 | # findtool works as 'which' but we use a different name to make it more |
| 5 | # obvious we aren't using 'which'! ;-) |
| 6 | # |
| 7 | findtool(){ |
| 8 | file="$1" |
| 9 | |
| 10 | old_IFS=$IFS; IFS=':' |
| 11 | for path in $PATH |
| 12 | do |
| 13 | IFS=$old_IFS |
| 14 | # echo "checks for $file in $path" >&2 |
| 15 | if test -f "$path/$file"; then |
| 16 | echo "$path/$file" |
| 17 | return |
| 18 | fi |
| 19 | done |
| 20 | IFS=$old_IFS |
| 21 | } |
| 22 | |
| 23 | #-------------------------------------------------------------------------- |
| 24 | # removethis() removes all files and subdirectories with the given name, |
| 25 | # inside and below the current subdirectory at invocation time. |
| 26 | # |
| 27 | removethis(){ |
| 28 | if test "$#" = "1"; then |
| 29 | find . -depth -name $1 -print > buildconf.tmp.$$ |
| 30 | while read fdname |
| 31 | do |
| 32 | if test -f "$fdname"; then |
| 33 | rm -f "$fdname" |
| 34 | elif test -d "$fdname"; then |
| 35 | rm -f -r "$fdname" |
| 36 | fi |
| 37 | done < buildconf.tmp.$$ |
| 38 | rm -f buildconf.tmp.$$ |
| 39 | fi |
| 40 | } |
| 41 | |
| 42 | #-------------------------------------------------------------------------- |
| 43 | # Ensure that buildconf runs from the subdirectory where configure.ac lives |
| 44 | # |
| 45 | if test ! -f configure.ac || |
| 46 | test ! -f ares_init.c || |
| 47 | test ! -f m4/cares-functions.m4; then |
| 48 | echo "Can not run buildconf from outside of c-ares source subdirectory!" |
| 49 | echo "Change to the subdirectory where buildconf is found, and try again." |
| 50 | exit 1 |
| 51 | fi |
| 52 | |
| 53 | #-------------------------------------------------------------------------- |
| 54 | # this approach that tries 'glibtool' first is some kind of work-around for |
| 55 | # some BSD-systems I believe that use to provide the GNU libtool named |
| 56 | # glibtool, with 'libtool' being something completely different. |
| 57 | libtool=`findtool glibtool 2>/dev/null` |
| 58 | if test ! -x "$libtool"; then |
| 59 | libtool=`findtool ${LIBTOOL:-libtool}` |
| 60 | fi |
| 61 | |
| 62 | if test -z "$LIBTOOLIZE"; then |
| 63 | # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found |
| 64 | # $libtool is already the full path |
| 65 | libtoolize="${libtool}ize" |
| 66 | else |
| 67 | libtoolize=`findtool $LIBTOOLIZE` |
| 68 | fi |
| 69 | |
| 70 | #-------------------------------------------------------------------------- |
| 71 | # Remove files generated on previous buildconf/configure run. |
| 72 | # |
| 73 | for fname in .deps \ |
| 74 | .libs \ |
| 75 | *.la \ |
| 76 | *.lo \ |
| 77 | *.a \ |
| 78 | *.o \ |
| 79 | Makefile \ |
| 80 | Makefile.in \ |
| 81 | aclocal.m4 \ |
| 82 | aclocal.m4.bak \ |
| 83 | ares_build.h \ |
| 84 | ares_config.h \ |
| 85 | ares_config.h.in \ |
| 86 | autom4te.cache \ |
| 87 | compile \ |
| 88 | config.guess \ |
| 89 | config.log \ |
| 90 | config.lt \ |
| 91 | config.status \ |
| 92 | config.sub \ |
| 93 | configure \ |
| 94 | depcomp \ |
| 95 | libcares.pc \ |
| 96 | libtool \ |
| 97 | libtool.m4 \ |
| 98 | ltmain.sh \ |
| 99 | ltoptions.m4 \ |
| 100 | ltsugar.m4 \ |
| 101 | ltversion.m4 \ |
| 102 | lt~obsolete.m4 \ |
| 103 | missing \ |
| 104 | stamp-h1 \ |
| 105 | stamp-h2 ; do |
| 106 | removethis "$fname" |
| 107 | done |
| 108 | |
| 109 | #-------------------------------------------------------------------------- |
| 110 | # run the correct scripts now |
| 111 | # |
| 112 | |
| 113 | ${libtoolize} --copy --automake --force |
| 114 | ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS |
| 115 | ${AUTOHEADER:-autoheader} |
| 116 | ${AUTOCONF:-autoconf} |
| 117 | ${AUTOMAKE:-automake} --add-missing --copy |