commit:     dbf8ea54cb9bfb309dde721cde4ccec594da2010
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 02:22:41 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 02:22:41 2015 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=dbf8ea54

build: pull in ax macros recursively

Make sure we also get the files that the ax macros themselves need.

 autogen.sh | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 3d49418..f552d22 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -40,10 +40,28 @@ v --fold="gnulib-tool" gnulib-tool \
 
 # not everyone has sys-devel/autoconf-archive installed
 v tar xf travis/autotools.tar.xz
-for macro in $(grep -o '\<AX[A-Z_]*\>' configure.ac | sort -u) ; do
-       if m4=$(grep -rl "\[${macro}\]" /usr/share/aclocal/) ; then
-               v cp $m4 ${m4dir}/
+has() { [[ " ${*:2} " == *" $1 "* ]] ; }
+import_ax() {
+       local macro content m4 lm4s=()
+       content=$(sed -e '/^[[:space:]]*#/d' -e 's:\<dnl\>.*::' "$@")
+       for macro in $(echo "${content}" | grep -o '\<AX[A-Z_]*\>' | sort -u) ; 
do
+               for m4 in $(grep -rl "\[${macro}\]" /usr/share/aclocal/) ; do
+                       has ${m4} "${m4s[@]}" || lm4s+=( ${m4} )
+               done
+       done
+       if [[ ${#lm4s[@]} -gt 0 ]] ; then
+               cp -v `printf '%s\n' ${lm4s[@]} | sort -u` autotools/m4/
+               m4s+=( "${lm4s[@]}" )
        fi
+}
+m4s=()
+import_ax configure.ac
+curr=1
+new=0
+while [[ ${curr} -ne ${new} ]] ; do
+       curr=${#m4s[@]}
+       import_ax autotools/m4/ax_*.m4
+       new=${#m4s[@]}
 done
 
 export AUTOMAKE="automake --foreign"

Reply via email to