build.sh (1142B)
1 #!/bin/sh 2 3 cc=${CC:-cc} 4 5 build=${BUILD:-"release"} 6 #build="debug" 7 #build="optimized_debug" 8 9 version="$(git describe --dirty --always)-${build}" 10 11 cflags="-march=native -Wall -DVERSION=\"${version}\"" 12 #cflags="${cflags} -fproc-stat-report" 13 #cflags="${cflags} -Rpass-missed=.*" 14 #cflags="${cflags} -fsanitize=address,undefined" 15 ldflags="-lm -lGL -lglfw -lX11" 16 17 [ ! -s "./config.h" ] && cp config.def.h config.h 18 19 case ${build} in 20 "debug") 21 cflags="${cflags} -O0 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" 22 build_lib=1 23 ;; 24 "optimized_debug") 25 cflags="${cflags} -O3 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" 26 build_lib=1 27 ;; 28 "release") 29 cflags="${cflags} -O3" 30 ;; 31 *) 32 echo unsupported build type: ${build} 33 exit 1 34 ;; 35 esac 36 37 testcflags="-march=native -Wall -O0 -ggdb -D_DEBUG -DVERSION=test" 38 testcflags="${testcflags} -Wno-unused-variable -Wno-unused-function -Wno-undefined-internal" 39 testldflags="-lm -static" 40 41 [ ${build_lib} ] && ${cc} ${cflags} -fPIC vtgl.c -o vtgl.so ${ldflags} -shared 42 ${cc} ${cflags} -o vtgl platform_linux_x11.c ${ldflags} 43 ${cc} ${testcflags} -I. -o tests/test tests/test.c ${testldflags}