# HG changeset patch # User "Yann E. MORIN" # Date 1243458457 0 # Node ID 3c28b9f917d29dcb55df1eca830ddfe6e2e61ca1 # Parent 38e2e6d5c9b4a8a66de49c9ea073c747bc46377e /devel/gcc-4.4: - functions: add a utility function that sets and exports LD_LIBRARY_PATH -------- diffstat follows -------- /devel/gcc-4.4/scripts/functions | 30 30 0 0 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff -r 38e2e6d5c9b4 -r 3c28b9f917d2 scripts/functions --- a/scripts/functions Mon May 25 20:27:14 2009 +0000 +++ b/scripts/functions Wed May 27 21:07:37 2009 +0000 @@ -265,6 +265,36 @@ yes "$1" || true } +# Add the specified directory to LD_LIBRARY_PATH, and export it +# If the specified patch is already present, just export +# $1: path to add +# $2: add as 'first' or 'last' path, 'first' is assumed if $2 is empty +# Usage CT_SetLibPath /some/where/lib [first|last] +CT_SetLibPath() { + local path="$1" + local pos="$2" + + case ":${LD_LIBRARY_PATH}:" in + *:"${path}":*) ;; + *) case "${pos}" in + last) + CT_DoLog DEBUG "Adding '${path}' at end of LD_LIBRARY_PATH" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}${path}" + ;; + first|"") + CT_DoLog DEBUG "Adding '${path}' at start of LD_LIBRARY_PATH" + LD_LIBRARY_PATH="${path}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" + ;; + *) + CT_Abort "Incorrect position '${pos}' to add '${path}' to LD_LIBRARY_PATH" + ;; + esac + ;; + esac + CT_DoLog DEBUG "==> LD_LIBRARY_PATH='${LD_LIBRARY_PATH}'" + export LD_LIBRARY_PATH +} + # Get the file name extension of a component # Usage: CT_GetFileExtension [extension] # If found, echoes the extension to stdout