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