From 2dc43e3f1b0bacee19a168aebe3ed282ea412006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Ricardo=20Perez-Lopez?= Date: Tue, 8 Oct 2024 11:36:41 -0700 Subject: [PATCH] Fix processor core count calculation for Mac --- contrib/setup-bison.sh | 10 +++++++++- contrib/setup-flex.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/contrib/setup-bison.sh b/contrib/setup-bison.sh index 77d7d8223..49bd29f9c 100755 --- a/contrib/setup-bison.sh +++ b/contrib/setup-bison.sh @@ -20,6 +20,14 @@ if [ ! -f "$DEPS/bison-$VERSION.tar.xz" ]; then exit 1 fi +if [ "$(uname)" == "Darwin" ]; then + NUM_CORES=$(sysctl -n hw.logicalcpu) +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + NUM_CORES=$(nproc) +else + NUM_CORES=1 +fi + cd $DEPS tar -xf bison-$VERSION.tar.xz rm bison-$VERSION.tar.xz @@ -27,7 +35,7 @@ mv ./bison-$VERSION ./bison cd bison mkdir bison-install ./configure --prefix $DEPS/bison/bison-install --exec-prefix $DEPS/bison/bison-install -make -j$(nproc) +make -j$NUM_CORES make install cd $DIR diff --git a/contrib/setup-flex.sh b/contrib/setup-flex.sh index df5e36153..303244f73 100755 --- a/contrib/setup-flex.sh +++ b/contrib/setup-flex.sh @@ -19,6 +19,14 @@ if [ ! -f "$DEPS/flex-2.6.4.tar.gz" ]; then exit 1 fi +if [ "$(uname)" == "Darwin" ]; then + NUM_CORES=$(sysctl -n hw.logicalcpu) +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + NUM_CORES=$(nproc) +else + NUM_CORES=1 +fi + # Set CFLAGS to work around compiler issue with building flex export CFLAGS="$CFLAGS -D_GNU_SOURCE" cd $DEPS @@ -28,7 +36,7 @@ mv flex-2.6.4 flex cd flex mkdir flex-install ./configure --prefix $DEPS/flex/flex-install --exec-prefix $DEPS/flex/flex-install -make -j$(nproc) +make -j$NUM_CORES make install cd $DIR