diff options
-rw-r--r-- | build-clang.bat | 4 | ||||
-rw-r--r-- | build-mingw.bat | 4 | ||||
-rw-r--r-- | build-msvc.bat | 7 | ||||
-rwxr-xr-x | build.sh | 21 |
4 files changed, 35 insertions, 1 deletions
diff --git a/build-clang.bat b/build-clang.bat index f8b8f31..16cdae0 100644 --- a/build-clang.bat +++ b/build-clang.bat @@ -152,6 +152,10 @@ if "_%1_" == "__" ( set "cxx=%1" ) +rem Convert a relative path to an absolute. +rem +for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD" + rem Certificate to trust. rem if not "_%trust%_" == "__" ( diff --git a/build-mingw.bat b/build-mingw.bat index 7e62685..21704b4 100644 --- a/build-mingw.bat +++ b/build-mingw.bat @@ -161,6 +161,10 @@ if not "_%3_" == "__" ( set "trust=%3" ) +rem Convert a relative path to an absolute. +rem +for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD" + rem Certificate to trust. rem if not "_%trust%_" == "__" ( diff --git a/build-msvc.bat b/build-msvc.bat index 2f0ed6b..e9416a3 100644 --- a/build-msvc.bat +++ b/build-msvc.bat @@ -8,7 +8,8 @@ goto start :usage echo. -echo Usage: %0 [/?] [^<options^>] [^<cl-compiler^>] +rem echo Usage: %0 [/?] [^<options^>] [^<cl-compiler^>] +echo Usage: %0 [/?] [^<options^>] echo Options: echo --local Don't build from packages, only from local source. echo --install-dir ^<dir^> Alternative installation directory. @@ -140,6 +141,10 @@ rem ) else ( rem set "cxx=%1" rem ) +rem Convert a relative path to an absolute. +rem +for /F "delims=|" %%D in ("%idir%") do set "idir=%%~dpnxD" + rem Certificate to trust. rem if not "_%trust%_" == "__" ( @@ -225,6 +225,12 @@ if test -n "$make"; then fi fi +# If the installation directory is unspecified, then assume it is /usr/local. +# Otherwise, if it is a relative path, then convert it to an absolute path, +# unless the realpath program is not present on the system or doesn't +# recognize any of the options we pass, in which case fail, advising to +# specify an absolute installation directory. +# if test -z "$idir"; then idir=/usr/local private=config.install.private=build2 @@ -235,6 +241,21 @@ if test -z "$idir"; then if test -z "$sudo"; then sudo="sudo" fi +elif test -n "$(echo "$idir" | sed -n 's#^[^/].*$#true#p')"; then + + if ! command -v realpath >/dev/null 2>&1; then + diag "error: unable to execute realpath: command not found" + diag " info: specify absolute installation directory path" + exit 1 + fi + + # Don't resolve symlinks and allow non-existent path components. + # + if ! idir="$(realpath -s -m "$idir" 2>/dev/null)"; then + diag "error: realpath does not recognize -s -m" + diag " info: specify absolute installation directory path" + exit 1 + fi fi if test "$sudo" = false; then |