diff --git a/retroarch-build.sh b/retroarch-build.sh index eb9504e2..95529fab 100755 --- a/retroarch-build.sh +++ b/retroarch-build.sh @@ -1,30 +1,21 @@ #! /usr/bin/env bash # vim: set ts=3 sw=3 noet ft=sh : bash -. ./libretro-config.sh +SCRIPT="${0#./}" +BASE_DIR="${SCRIPT%/*}" +WORKDIR="$PWD" -# BSDs don't have readlink -f -read_link() -{ - TARGET_FILE="$1" - cd $(dirname "$TARGET_FILE") - TARGET_FILE=$(basename "$TARGET_FILE") +if [ "$BASE_DIR" = "$SCRIPT" ]; then + BASE_DIR="$WORKDIR" +else + if [[ "$0" != /* ]]; then + # Make the path absolute + BASE_DIR="$WORKDIR/$BASE_DIR" + fi +fi - while [ -L "$TARGET_FILE" ] - do - TARGET_FILE=$(readlink "$TARGET_FILE") - cd $(dirname "$TARGET_FILE") - TARGET_FILE=$(basename "$TARGET_FILE") - done +. "$BASE_DIR/libretro-config.sh" - PHYS_DIR=$(pwd -P) - RESULT="$PHYS_DIR/$TARGET_FILE" - echo $RESULT -} - -SCRIPT=$(read_link "$0") -echo "Script: $SCRIPT" -BASE_DIR=$(dirname "$SCRIPT") if [ -z "$RARCH_DIST_DIR" ]; then RARCH_DIR="$BASE_DIR/dist" RARCH_DIST_DIR="$RARCH_DIR/$DIST_DIR"