From 023d5e2f14f292b0fd710d8c44917ea6331f4b6c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 May 2013 13:45:58 +0200 Subject: [PATCH] acinclude: fix variable expansion issues Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/474600ee2ad385155455c638f09aa160f0c494a3 Author: Stefan Seyfried Date: 2013-05-11 (Sat, 11 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index a8c6cc97f..17e05703b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -82,21 +82,33 @@ check_path () { ]) +dnl expand nested ${foo}/bar +AC_DEFUN([TUXBOX_EXPAND_VARIABLE],[__$1="$2" + for __CNT in false false false false true; do dnl max 5 levels of indirection + + $1=`eval echo "$__$1"` + echo ${$1} | grep -q '\$' || break # 'grep -q' is POSIX, exit if no $ in variable + __$1="${$1}" + done + $__CNT && AC_MSG_ERROR([can't expand variable $1=$2]) dnl bail out if we did not expand +]) + AC_DEFUN([TUXBOX_APPS_DIRECTORY_ONE],[ AC_ARG_WITH($1,[ $6$7 [[PREFIX$4$5]]],[ _$2=$withval if test "$TARGET" = "cdk"; then - $2=`eval echo "$TARGET_PREFIX$withval"` + $2=`eval echo "$TARGET_PREFIX$withval"` # no indirection possible IMNSHO else $2=$withval fi TARGET_$2=${$2} ],[ - $2="\${$3}$5" + # RFC 1925: "you can always add another level of indirection..." + TUXBOX_EXPAND_VARIABLE($2,"${$3}$5") if test "$TARGET" = "cdk"; then - _$2=`eval echo "${target$3}$5"` + TUXBOX_EXPAND_VARIABLE(_$2,"${target$3}$5") else - _$2=`eval echo "${$3}$5"` + _$2=${$2} fi TARGET_$2=$_$2 ])