diff --git a/etc/DependencyInstaller.sh b/etc/DependencyInstaller.sh index 3a80d3764f..f2459dfe60 100755 --- a/etc/DependencyInstaller.sh +++ b/etc/DependencyInstaller.sh @@ -11,7 +11,11 @@ fi # package versions klayoutVersion=0.30.3 -numThreads=$(nproc) +if [[ "$OSTYPE" == "darwin"* ]]; then + numThreads=$(sysctl -n hw.ncpu) +else + numThreads=$(nproc) +fi _versionCompare() { local a b IFS=. ; set -f diff --git a/setup.sh b/setup.sh index 22a84cfea8..b9f2853e1e 100755 --- a/setup.sh +++ b/setup.sh @@ -5,8 +5,13 @@ set -euo pipefail # allow this script to be invoked from any folder DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ $EUID -ne 0 ]; then - echo "This script must be run with sudo" +if [[ "$OSTYPE" == "darwin"* ]] && [[ $EUID -eq 0 ]]; then + echo "Do NOT run this script with sudo on macOS" + exit 1 +fi + +if [[ "$OSTYPE" != "darwin"* ]] && [[ $EUID -ne 0 ]]; then + echo "This script must be run with sudo on Linux" exit 1 fi @@ -17,7 +22,11 @@ tmpfile=$(mktemp) git submodule status --recursive > "$tmpfile" if grep -q "^-" "$tmpfile"; then - sudo -u $SUDO_USER git submodule update --init --recursive + if [[ "$OSTYPE" == "darwin"* ]]; then + git submodule update --init --recursive + else + sudo -u $SUDO_USER git submodule update --init --recursive + fi elif grep -q "^+" "$tmpfile"; then # Make it easy for users who are not hacking ORFS to do the right thing, # run with current submodules, at the cost of having ORFS @@ -27,4 +36,8 @@ elif grep -q "^+" "$tmpfile"; then fi "$DIR/etc/DependencyInstaller.sh" -base -sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +if [[ "$OSTYPE" == "darwin"* ]]; then + "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +else + sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +fi