as-ac-expand.m4 1.1 KB

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