renatofilho@870: dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
renatofilho@870: dnl
renatofilho@870: dnl example
renatofilho@870: dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
renatofilho@870: dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
renatofilho@870: 
renatofilho@870: AC_DEFUN([AS_AC_EXPAND],
renatofilho@870: [
renatofilho@870:   EXP_VAR=[$1]
renatofilho@870:   FROM_VAR=[$2]
renatofilho@870: 
renatofilho@870:   dnl first expand prefix and exec_prefix if necessary
renatofilho@870:   prefix_save=$prefix
renatofilho@870:   exec_prefix_save=$exec_prefix
renatofilho@870: 
renatofilho@870:   dnl if no prefix given, then use /usr/local, the default prefix
renatofilho@870:   if test "x$prefix" = "xNONE"; then
renatofilho@870:     prefix=$ac_default_prefix
renatofilho@870:   fi
renatofilho@870:   dnl if no exec_prefix given, then use prefix
renatofilho@870:   if test "x$exec_prefix" = "xNONE"; then
renatofilho@870:     exec_prefix=$prefix
renatofilho@870:   fi
renatofilho@870: 
renatofilho@870:   full_var="$FROM_VAR"
renatofilho@870:   dnl loop until it doesn't change anymore
renatofilho@870:   while true; do
renatofilho@870:     new_full_var="`eval echo $full_var`"
renatofilho@870:     if test "x$new_full_var"="x$full_var"; then break; fi
renatofilho@870:     full_var=$new_full_var
renatofilho@870:   done
renatofilho@870: 
renatofilho@870:   dnl clean up
renatofilho@870:   full_var=$new_full_var
renatofilho@870:   AC_SUBST([$1], "$full_var")
renatofilho@870: 
renatofilho@870:   dnl restore prefix and exec_prefix
renatofilho@870:   prefix=$prefix_save
renatofilho@870:   exec_prefix=$exec_prefix_save
renatofilho@870: ])