-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make.sh now automatically detects operating system and X11 support on…
… Linux and only runs FluidX3D if last compilation was successful, fixed compiler warnings on Android
- Loading branch information
1 parent
1043f9a
commit f990dfb
Showing
4 changed files
with
41 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# command line argument(s): device ID(s); if empty, FluidX3D will automatically choose the fastest available device(s) | ||
|
||
#TARGET=Linux-X11 # compile on Linux with X11 graphics | ||
TARGET=Linux # compile on Linux (without X11) | ||
#TARGET=macOS # compile on macOS (without X11) | ||
#TARGET=Android # compile on Android (without X11) | ||
case "$(uname -a)" in # automatically detect operating system and X11 support on Linux | ||
Darwin*) target=macOS;; | ||
*Android) target=Android;; | ||
Linux*) if xhost >&/dev/null; then target=Linux-X11; else target=Linux; fi;; | ||
*) target=Linux;; | ||
esac | ||
echo -e "\033[92mInfo\033[0m: Detected Operating System: "${target} | ||
|
||
#target=Linux-X11 # manually set to compile on Linux with X11 graphics | ||
#target=Linux # manually set to compile on Linux (without X11) | ||
#target=macOS # manually set to compile on macOS (without X11) | ||
#target=Android # manually set to compile on Android (without X11) | ||
|
||
echo_and_execute() { echo "$@"; "$@"; } | ||
|
||
if command -v make &>/dev/null; then # if make is available, compile FluidX3D with multiple CPU cores | ||
make $TARGET | ||
echo -e "\033[92mInfo\033[0m: Compiling with "$(nproc)" CPU cores." | ||
make ${target} | ||
else # else (make is not installed), compile FluidX3D with a single CPU core | ||
echo -e "\033[92mInfo\033[0m: Compiling with 1 CPU core. For faster multi-core compiling, install make with \"sudo apt install make\"." | ||
mkdir -p bin # create directory for executable | ||
rm -rf temp bin/FluidX3D # prevent execution of old executable if compiling fails | ||
if [ $TARGET == Linux-X11 ]; then g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL -I./src/X11/include -L./src/X11/lib -lX11 -lXrandr; fi | ||
if [ $TARGET == Linux ]; then g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL; fi | ||
if [ $TARGET == macOS ]; then g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -I./src/OpenCL/include -framework OpenCL; fi | ||
if [ $TARGET == Android ]; then g++ src/*.cpp -o bin/FluidX3D -std=c++17 -pthread -I./src/OpenCL/include -L/system/vendor/lib64 -lOpenCL; fi | ||
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 | ||
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 | ||
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 | ||
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 | ||
fi | ||
|
||
bin/FluidX3D "$@" # run FluidX3D | ||
if [[ $? == 0 ]]; then bin/FluidX3D "$@"; fi # run FluidX3D only if last compilation was successful |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters