gmyth/m4/as-expand.m4
author renatofilho
Thu Apr 12 22:16:55 2007 +0100 (2007-04-12)
branchtrunk
changeset 539 c67cec9e6073
permissions -rw-r--r--
[svn r544] fixed args parse
leo_sobral@1
     1
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
leo_sobral@1
     2
dnl
leo_sobral@1
     3
dnl example
leo_sobral@1
     4
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
leo_sobral@1
     5
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
leo_sobral@1
     6
leo_sobral@1
     7
AC_DEFUN([AS_AC_EXPAND],
leo_sobral@1
     8
[
leo_sobral@1
     9
  EXP_VAR=[$1]
leo_sobral@1
    10
  FROM_VAR=[$2]
leo_sobral@1
    11
leo_sobral@1
    12
  dnl first expand prefix and exec_prefix if necessary
leo_sobral@1
    13
  prefix_save=$prefix
leo_sobral@1
    14
  exec_prefix_save=$exec_prefix
leo_sobral@1
    15
leo_sobral@1
    16
  dnl if no prefix given, then use /usr/local, the default prefix
leo_sobral@1
    17
  if test "x$prefix" = "xNONE"; then
leo_sobral@1
    18
    prefix=$ac_default_prefix
leo_sobral@1
    19
  fi
leo_sobral@1
    20
  dnl if no exec_prefix given, then use prefix
leo_sobral@1
    21
  if test "x$exec_prefix" = "xNONE"; then
leo_sobral@1
    22
    exec_prefix=$prefix
leo_sobral@1
    23
  fi
leo_sobral@1
    24
leo_sobral@1
    25
  full_var="$FROM_VAR"
leo_sobral@1
    26
  dnl loop until it doesn't change anymore
leo_sobral@1
    27
  while true; do
leo_sobral@1
    28
    new_full_var="`eval echo $full_var`"
leo_sobral@1
    29
    if test "x$new_full_var"="x$full_var"; then break; fi
leo_sobral@1
    30
    full_var=$new_full_var
leo_sobral@1
    31
  done
leo_sobral@1
    32
leo_sobral@1
    33
  dnl clean up
leo_sobral@1
    34
  full_var=$new_full_var
leo_sobral@1
    35
  AC_SUBST([$1], "$full_var")
leo_sobral@1
    36
leo_sobral@1
    37
  dnl restore prefix and exec_prefix
leo_sobral@1
    38
  prefix=$prefix_save
leo_sobral@1
    39
  exec_prefix=$exec_prefix_save
leo_sobral@1
    40
])