|
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) |
4 | 3 |
|
5 | 4 | 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 ;; |
10 | 9 | esac
|
11 |
| -echo -e "\033[92mInfo\033[0m: Detected Operating System: "${target} |
12 | 10 |
|
13 | 11 | #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) |
17 | 15 |
|
| 16 | +echo -e "\033[92mInfo\033[0m: Detected Operating System: "${target} |
18 | 17 | echo_and_execute() { echo "$@"; "$@"; }
|
19 |
| - |
20 | 18 | if command -v make &>/dev/null; then # if make is available, compile FluidX3D with multiple CPU cores
|
21 | 19 | echo -e "\033[92mInfo\033[0m: Compiling with "$(nproc)" CPU cores."
|
22 |
| - make ${target} |
| 20 | + make ${target} -j$(nproc) # compile FluidX3D with makefile |
23 | 21 | else # else (make is not installed), compile FluidX3D with a single CPU core
|
24 | 22 | echo -e "\033[92mInfo\033[0m: Compiling with 1 CPU core. For faster multi-core compiling, install make with \"sudo apt install make\"."
|
25 | 23 | mkdir -p bin # create directory for executable
|
26 | 24 | 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 |
31 | 31 | fi
|
32 | 32 |
|
33 | 33 | if [[ $? == 0 ]]; then bin/FluidX3D "$@"; fi # run FluidX3D only if last compilation was successful
|
0 commit comments