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