Skip to content

Commit

Permalink
build_and_install_smpq.sh: Tiger compatibility
Browse files Browse the repository at this point in the history
1. Tiger's tar does not support `--strip-components`.
2. Tiger predates `getconf _NPROCESSORS_ONLN` support.
3. Tiger's default `cc` is too old to build smpq,
   so we default to `CC=gcc` instead (e.g. from macports).

We also bump stormlib version because the previous one fails
to compile with gcc14 on Tiger.
  • Loading branch information
glebm authored and AJenbo committed Dec 8, 2024
1 parent 585a8c9 commit c6924e6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tools/build_and_install_smpq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@
set -ex

PARALLELISM="$(getconf _NPROCESSORS_ONLN)"
STORMLIB_VERSION=8bb328df98e90be08a45a9f6aeb8edda5c1fd27c
STORMLIB_SRC="/tmp/stormlib-src-$STORMLIB_VERSION"
if [ "$PARALLELISM" = "undefined" ] && [ -f /usr/sbin/sysctl ]; then
# On older OSX, such as 10.4, _NPROCESSOR_ONLN is not defined.
if [ -z "$CC" ]; then
# Tiger's default cc is too old to build smpq, so we default to gcc instead (e.g. from macports).
export CC=gcc
fi
PARALLELISM="$(/usr/sbin/sysctl -n hw.ncpu)"
fi

STORMLIB_VERSION=e01d93cc8ae743cfe2da5450854c5d2e3a939265
STORMLIB_SRC="/tmp/StormLib-$STORMLIB_VERSION"
SMPQ_VERSION=1.6
SMPQ_SRC="/tmp/smpq-src-$SMPQ_VERSION"
SMPQ_SRC="/tmp/smpq-$SMPQ_VERSION"

# Download, build, and install the static version of StormLib, an SMPQ dependency, to the staging prefix.
if ! [ -d "$STORMLIB_SRC" ]; then
mkdir "$STORMLIB_SRC"
curl -L -s "https://github.com/ladislav-zezula/StormLib/archive/${STORMLIB_VERSION}.tar.gz" | tar -C "$STORMLIB_SRC" --strip-components=1 -xvzf -
curl -L -s "https://github.com/ladislav-zezula/StormLib/archive/${STORMLIB_VERSION}.tar.gz" | tar -C /tmp -xvzf -
fi

cmake -S"$STORMLIB_SRC" -B"$STORMLIB_SRC"/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/smpq-staging -DBUILD_SHARED_LIBS=OFF \
Expand All @@ -26,8 +34,7 @@ cmake --build "$STORMLIB_SRC"/build --config Release --target install -j"$PARALL

# Download, build, and install SMPQ.
if ! [ -d "$SMPQ_SRC" ]; then
mkdir "$SMPQ_SRC"
curl -L -s "https://launchpad.net/smpq/trunk/${SMPQ_VERSION}/+download/smpq_${SMPQ_VERSION}.orig.tar.gz" | tar -C "$SMPQ_SRC" --strip-components=1 -xvzf -
curl -L -s "https://launchpad.net/smpq/trunk/${SMPQ_VERSION}/+download/smpq_${SMPQ_VERSION}.orig.tar.gz" | tar -C /tmp -xvzf -

# StormLib.a is C++ and must be linked with a C++ linker (e.g. via g++ instead of gcc).
sed -i.bak -e '/^project/a\
Expand Down

0 comments on commit c6924e6

Please sign in to comment.