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