build.sh (1896B)
1 #!/bin/sh 2 cflags="-march=native -std=c11 -O3 -Wall -I./external/include" 3 #cflags="${cflags} -fproc-stat-report" 4 #cflags="${cflags} -Rpass-missed=.*" 5 libcflags="$cflags -fPIC -shared" 6 ldflags="-lraylib -lm" 7 8 debug=${DEBUG} 9 10 cc=${CC:-cc} 11 system_raylib=${USE_SYSTEM_RAYLIB:-$debug} 12 13 case $(uname -s) in 14 MINGW64*) 15 os="win32" 16 ldflags="$ldflags -lgdi32 -lwinmm" 17 libname="beamformer.dll" 18 ;; 19 Linux*) 20 os="unix" 21 cflags="$cflags -D_DEFAULT_SOURCE" 22 libcflags="$libcflags -I/opt/matlab/extern/include" 23 libname="beamformer.so" 24 ;; 25 esac 26 27 if [ "$system_raylib" ]; then 28 ldflags="-L/usr/local/lib $ldflags" 29 else 30 ldflags="-L./external/lib $ldflags" 31 if [ ! -f external/lib/libraylib.a ]; then 32 git submodule update --init --depth=1 external/raylib 33 cmake --install-prefix="${PWD}/external" \ 34 -G "Ninja" -B external/raylib/build -S external/raylib \ 35 -D CMAKE_INSTALL_LIBDIR=lib -D CMAKE_BUILD_TYPE="Release" \ 36 -DCUSTOMIZE_BUILD=ON -DBUILD_EXAMPLES=OFF -DWITH_PIC=ON \ 37 -DOPENGL_VERSION=4.3 -DUSE_AUDIO=OFF -DSUPPORT_MODULE_RAUDIO=OFF 38 cmake --build external/raylib/build 39 cmake --install external/raylib/build 40 fi 41 fi 42 43 # NOTE: this needs to be separate for now in case matlab junk is not available 44 case "$1" in 45 *lib) 46 case "$os" in 47 "win32") 48 ${cc} $libcflags -I'C:/Program Files/MATLAB/R2022a/extern/include' \ 49 helpers/ogl_beamformer_lib.c -o helpers/ogl_beamformer_lib.dll \ 50 -L'C:/Program Files/MATLAB/R2022a/extern/lib/win64/microsoft' \ 51 -llibmat -llibmex 52 ;; 53 "unix") 54 ${cc} $libcflags helpers/ogl_beamformer_lib.c -o helpers/ogl_beamformer_lib.so 55 ;; 56 esac 57 esac 58 59 # Hot Reloading/Debugging 60 if [ "$debug" ]; then 61 cflags="$cflags -O0 -ggdb -D_DEBUG -Wno-unused-function" 62 #cflags="$cflags -fsanitize=address,undefined" 63 64 libcflags="$cflags -fPIC" 65 libldflags="$ldflags -shared" 66 ${cc} $libcflags beamformer.c -o $libname $libldflags 67 fi 68 69 ${cc} $cflags -o ogl main.c $ldflags