summaryrefslogtreecommitdiff
path: root/Toolchain/BuildIt.sh
diff options
context:
space:
mode:
authorjoshua stein <jcs@jcs.org>2020-12-28 17:36:15 -0600
committerAndreas Kling <kling@serenityos.org>2021-02-14 09:29:22 +0100
commit0d215b55487ca3ea66a77463c85d98956fa07f0b (patch)
treec156e8fcb62e5714cdff5884697429fc5e5a2d29 /Toolchain/BuildIt.sh
parent4021264201d99372fb1e84899be9ae84a5510415 (diff)
downloadserenity-0d215b55487ca3ea66a77463c85d98956fa07f0b.zip
Build: Sprinkle some portability, fix on OpenBSD
realpath(1) is specific to coreutils and its behavior can be had with readlink -f Create the Toolchain Build directory if it doesn't exist before calling readlink, since realpath(3) on at least OpenBSD will error on a non-existent path
Diffstat (limited to 'Toolchain/BuildIt.sh')
-rwxr-xr-xToolchain/BuildIt.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/Toolchain/BuildIt.sh b/Toolchain/BuildIt.sh
index 694c674e36..9974c03c29 100755
--- a/Toolchain/BuildIt.sh
+++ b/Toolchain/BuildIt.sh
@@ -12,12 +12,13 @@ echo "$DIR"
ARCH=${ARCH:-"i686"}
TARGET="$ARCH-pc-serenity"
PREFIX="$DIR/Local/$ARCH"
-BUILD=$(realpath "$DIR/../Build")
+BUILD="$DIR/../Build"
SYSROOT="$BUILD/Root"
MAKE="make"
MD5SUM="md5sum"
NPROC="nproc"
+REALPATH="realpath"
if command -v ginstall &>/dev/null; then
INSTALL=ginstall
@@ -29,6 +30,7 @@ if [ "$(uname -s)" = "OpenBSD" ]; then
MAKE=gmake
MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpuonline"
+ REALPATH="readlink -f"
export CC=egcc
export CXX=eg++
export with_gmp=/usr/local
@@ -41,6 +43,12 @@ elif [ "$(uname -s)" = "FreeBSD" ]; then
export with_mpfr=/usr/local
fi
+# On at least OpenBSD, the path must exist to call realpath(3) on it
+if [ ! -d "$BUILD" ]; then
+ mkdir -p "$BUILD"
+fi
+BUILD=$($REALPATH "$BUILD")
+
git_patch=
while [ "$1" != "" ]; do
case $1 in
@@ -236,7 +244,7 @@ pushd "$DIR/Build/$ARCH"
mkdir -p "$BUILD"
pushd "$BUILD"
mkdir -p Root/usr/include/
- SRC_ROOT=$(realpath "$DIR"/..)
+ SRC_ROOT=$($REALPATH "$DIR"/..)
FILES=$(find "$SRC_ROOT"/Userland/Libraries/LibC "$SRC_ROOT"/Userland/Libraries/LibM -name '*.h' -print)
for header in $FILES; do
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Userland/Libraries/LibC@@" -e "s@$SRC_ROOT/Userland/Libraries/LibM@@")