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