From 0ada2ddbd1a41b9dacf78ce8f3f85cf4dd6b52f0 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Mon, 2 Feb 2015 09:33:50 -0800 Subject: [PATCH] libretro-fetch.sh should now run anywhere --- libretro-fetch.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index 3ceb5392..1caf84a7 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -1,7 +1,27 @@ #! /bin/bash # vi: sw=3 ts=3 et -. ./libretro-config.sh +# BSDs don't have readlink -f +read_link() +{ + TARGET_FILE="${1}" + cd "`dirname "${TARGET_FILE}"`" + TARGET_FILE="`basename "${TARGET_FILE}"`" + + while [ -L "${TARGET_FILE}" ]; do + TARGET_FILE="`readlink "${TARGET_FILE}"`" + cd "`dirname "${TARGET_FILE}"`" + TARGET_FILE="`basename "${TARGET_FILE}"`" + done + + PHYS_DIR="`pwd -P`" + RESULT="${PHYS_DIR}/${TARGET_FILE}" + echo ${RESULT} +} +SCRIPT="`read_link "$0"`" +BASE_DIR="`dirname "${SCRIPT}"`" + +. ${BASE_DIR}/libretro-config.sh WORKDIR=$(pwd)