Skip to content

Commit f3fa55b

Browse files
committed
Fixed make.sh failing on some systems due to nonstandard interpreter path, fixed that make would not compile with multiple cores on some systems, cosmetics
1 parent f990dfb commit f3fa55b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

make.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
#!/bin/bash
2-
3-
# command line argument(s): device ID(s); if empty, FluidX3D will automatically choose the fastest available device(s)
1+
#!/usr/bin/env bash
2+
# command line argument(s) for make.sh: device ID(s); if empty, FluidX3D will automatically choose the fastest available device(s)
43

54
case "$(uname -a)" in # automatically detect operating system and X11 support on Linux
6-
Darwin*) target=macOS;;
7-
*Android) target=Android;;
8-
Linux*) if xhost >&/dev/null; then target=Linux-X11; else target=Linux; fi;;
9-
*) target=Linux;;
5+
Darwin*) target=macOS ;;
6+
*Android) target=Android ;;
7+
Linux* ) if xhost >&/dev/null; then target=Linux-X11; else target=Linux; fi ;;
8+
* ) target=Linux ;;
109
esac
11-
echo -e "\033[92mInfo\033[0m: Detected Operating System: "${target}
1210

1311
#target=Linux-X11 # manually set to compile on Linux with X11 graphics
14-
#target=Linux # manually set to compile on Linux (without X11)
15-
#target=macOS # manually set to compile on macOS (without X11)
16-
#target=Android # manually set to compile on Android (without X11)
12+
#target=Linux # manually set to compile on Linux (without X11)
13+
#target=macOS # manually set to compile on macOS (without X11)
14+
#target=Android # manually set to compile on Android (without X11)
1715

16+
echo -e "\033[92mInfo\033[0m: Detected Operating System: "${target}
1817
echo_and_execute() { echo "$@"; "$@"; }
19-
2018
if command -v make &>/dev/null; then # if make is available, compile FluidX3D with multiple CPU cores
2119
echo -e "\033[92mInfo\033[0m: Compiling with "$(nproc)" CPU cores."
22-
make ${target}
20+
make ${target} -j$(nproc) # compile FluidX3D with makefile
2321
else # else (make is not installed), compile FluidX3D with a single CPU core
2422
echo -e "\033[92mInfo\033[0m: Compiling with 1 CPU core. For faster multi-core compiling, install make with \"sudo apt install make\"."
2523
mkdir -p bin # create directory for executable
2624
rm -rf temp bin/FluidX3D # prevent execution of old executable if compiling fails
27-
if [[ ${target} == Linux-X11 ]]; then echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL -I./src/X11/include -L./src/X11/lib -lX11 -lXrandr; fi
28-
if [[ ${target} == Linux ]]; then echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL; fi
29-
if [[ ${target} == macOS ]]; then echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -framework OpenCL; fi
30-
if [[ ${target} == Android ]]; then echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L/system/vendor/lib64 -lOpenCL; fi
25+
case "${target}" in
26+
Linux-X11) echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL -I./src/X11/include -L./src/X11/lib -lX11 -lXrandr ;;
27+
Linux ) echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL ;;
28+
macOS ) echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -framework OpenCL ;;
29+
Android ) echo_and_execute g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -Wno-comment -I./src/OpenCL/include -L/system/vendor/lib64 -lOpenCL ;;
30+
esac
3131
fi
3232

3333
if [[ $? == 0 ]]; then bin/FluidX3D "$@"; fi # run FluidX3D only if last compilation was successful

0 commit comments

Comments
 (0)