compile.sh 485 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. arg=-1
  3. if [ -v 1 ]; then
  4. arg=$1
  5. fi
  6. if [ $arg = "clean" ]; then
  7. rm -rf ./target/*
  8. exit
  9. fi
  10. oflag="-Og"
  11. debug_flag="-ggdb"
  12. if [ $arg = "release" ]; then
  13. oflag="-O3"
  14. debug_flag=""
  15. fi
  16. src="src/*.c"
  17. flags="-std=c23 $oflag $debug_flag -Wall -Wextra -Werror -Wpedantic -pedantic-errors"
  18. includes="-I src/headers"
  19. cmd="gcc $flags $includes $src -o target/sanke"
  20. echo $cmd
  21. $cmd
  22. if [ $? -gt 0 ]; then
  23. exit
  24. fi
  25. if [ $arg = "run" ]; then
  26. echo
  27. ./target/sanke
  28. fi