Home | History | Annotate | Download | only in m4
      1 dnl as-ac-expand.m4 0.2.0
      2 dnl autostars m4 macro for expanding directories using configure's prefix
      3 dnl thomas (a] apestaart.org
      4 
      5 dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
      6 dnl example
      7 dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
      8 dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
      9 
     10 AC_DEFUN([AS_AC_EXPAND],
     11 [
     12   EXP_VAR=[$1]
     13   FROM_VAR=[$2]
     14 
     15   dnl first expand prefix and exec_prefix if necessary
     16   prefix_save=$prefix
     17   exec_prefix_save=$exec_prefix
     18 
     19   dnl if no prefix given, then use /usr/local, the default prefix
     20   if test "x$prefix" = "xNONE"; then
     21     prefix="$ac_default_prefix"
     22   fi
     23   dnl if no exec_prefix given, then use prefix
     24   if test "x$exec_prefix" = "xNONE"; then
     25     exec_prefix=$prefix
     26   fi
     27 
     28   full_var="$FROM_VAR"
     29   dnl loop until it doesn't change anymore
     30   while true; do
     31     new_full_var="`eval echo $full_var`"
     32     if test "x$new_full_var" = "x$full_var"; then break; fi
     33     full_var=$new_full_var
     34   done
     35 
     36   dnl clean up
     37   full_var=$new_full_var
     38   AC_SUBST([$1], "$full_var")
     39 
     40   dnl restore prefix and exec_prefix
     41   prefix=$prefix_save
     42   exec_prefix=$exec_prefix_save
     43 ])
     44