diff options
| author | iamcheeseman <[email protected]> | 2026-05-08 19:30:44 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-08 19:30:44 -0400 |
| commit | 5625a8626fe303748b205c80f87035593cf2f561 (patch) | |
| tree | 5e5a5adb6f1265358ae21ec47cd384362345df5a /build.sh | |
Initial commit
Diffstat (limited to 'build.sh')
| -rwxr-xr-x | build.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0a51ab1 --- /dev/null +++ b/build.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +cc=tcc +cflags=(-Wall -Wextra -O2) +ldflags=(-lm) + +platform=gl +debug= +run= +clean= +tags= + +if [ -z "$RUN_CMD" ]; then + RUN_CMD=./ +fi + +for flag in $@; do + case "$flag" in + '-run') run=true ;; + '-debug') debug=true ;; + '-clean') clean=true ;; + '-use-x11') platform=x11 ;; + '-use-gl') platform=gl ;; + esac +done + +if [ ! -z "$clean" ]; then + rm demonchime + rm libteensy.so + exit +fi + +[ ! -z "$debug" ] && cflags+=(-g -ggdb -rdynamic) + +teensy_cflags=(${cflags[@]} -Iteensy -Iplatform/$platform) +[ ! -z "$debug" ] && teensy_cflags+=(-DTEENSY_DEBUG) +teensy_ldflags=(${ldflags[@]}) + +case "$platform" in + 'x11') + teensy_ldflags+=(-lX11) + ;; + 'gl') + teensy_ldflags+=(-lglfw) + ;; +esac + +dc_cflags=(${cflags[@]} -Iteensy -Idc) +[ ! -z "$debug" ] && teensy_cflags+=(-DDC_DEBUG) +dc_ldflags=(${ldflags[@]} -L. -lteensy) + +dc_src=$(find dc -name '*.c') +teensy_src=$(find teensy -name '*.c') +platform_src=$(find platform/$platform -name '*.c') + +echo -e "dc:\t\t$(tr '\n' ' ' <<< "$dc_src")" +echo -e "teensy:\t\t$(tr '\n' ' ' <<< "$teensy_src")" +echo -e "platform:\t$platform_src" + +echo -e "building libteensy\t: ${teensy_ldflags[@]} ${teensy_cflags[@]}" +$cc -shared -o libteensy.so \ + ${teensy_ldflags[@]} \ + ${teensy_cflags[@]} \ + ${teensy_src[@]} ${platform_src[@]} || exit 1 + +echo -e "building demonchime\t: ${dc_ldflags[@]} ${dc_cflags[@]}" +$cc -o demonchime \ + ${dc_ldflags[@]} \ + ${dc_cflags[@]} \ + ${dc_src[@]} || exit 1 + +[ $? -eq 0 ] && [ ! -z "$run" ] && LD_LIBRARY_PATH=. ${RUN_CMD}demonchime |
