Commit: 95864d5a8f74698bdd64409e7efbc83c61341bdb Parent: 1eb870dd331ab9235aa1f1e79b8d947647a46b09 Author: Randy Palamar Date: Thu, 31 Oct 2024 08:15:19 -0600 reorganize build.sh Diffstat:
M | build.sh | | | 49 | +++++++++++++++++++++++++++++++------------------ |
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/build.sh b/build.sh @@ -1,30 +1,43 @@ #!/bin/sh cc=${CC:-cc} -debug=${DEBUG} -version=$(git describe --dirty --always) -cflags="-march=native -O3 -Wall -DVERSION=\"${version}\"" +build=${BUILD:-"release"} +#build="debug" +#build="optimized_debug" + +version="$(git describe --dirty --always)-${build}" + +cflags="-march=native -Wall -DVERSION=\"${version}\"" #cflags="${cflags} -fproc-stat-report" #cflags="${cflags} -Rpass-missed=.*" +#cflags="${cflags} -fsanitize=address,undefined" ldflags="-lm -lGL -lglfw" -testcflags="${cflags} -O0 -ggdb -D_DEBUG -UVERSION -DVERSION=test" -testcflags="${testcflags} -Wno-unused-variable -Wno-unused-function -Wno-undefined-internal" -testldflags="-lm -static" - [ ! -s "./config.h" ] && cp config.def.h config.h -if [ ${debug} ] && [ ${debug} != "0" ]; then - # Hot Reloading/Debugging - cflags="$cflags -O0 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" - #cflags="$cflags -fsanitize=address,undefined" - - libcflags="$cflags -fPIC" - libldflags="$ldflags -shared" - - ${cc} $libcflags vtgl.c -o vtgl.so $libldflags -fi +case ${build} in +"debug") + cflags="${cflags} -O0 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" + build_lib=1 + ;; +"optimized_debug") + cflags="${cflags} -O3 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" + build_lib=1 + ;; +"release") + cflags="${cflags} -O3" + ;; +*) + echo unsupported build type: ${build} + exit 1 + ;; +esac + +testcflags="-march=native -Wall -O0 -ggdb -D_DEBUG -DVERSION=test" +testcflags="${testcflags} -Wno-unused-variable -Wno-unused-function -Wno-undefined-internal" +testldflags="-lm -static" -${cc} $cflags -o vtgl main.c $ldflags +[ ${build_lib} ] && ${cc} ${cflags} -fPIC vtgl.c -o vtgl.so ${ldflags} -shared +${cc} ${cflags} -o vtgl main.c ${ldflags} ${cc} ${testcflags} -o test test.c ${testldflags}