build.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. #this script is for when you don't have cate or make installed
  3. CC=cc
  4. if ! command -v $CC &> /dev/null ; then
  5. echo "No C compiler found"
  6. exit 1
  7. fi
  8. build_folder="cate/build"; mkdir -p $build_folder
  9. out_exec="out/cate"; mkdir -p out
  10. cflags="-Iinclude -lstdc++ -march=native -fpermissive -funsafe-math-optimizations -ffast-math -fno-signed-zeros -ffinite-math-only -std=c++17 -lstdc++fs -Wall -O3 -pthread -ffunction-sections -fdata-sections -Wl,--gc-sections -fno-ident -fomit-frame-pointer -fmerge-all-constants -Wl,--build-id=none"
  11. build_() {
  12. if [ src/$1.cpp -nt $build_folder/src_$1.o ]; then
  13. $CC src/$1.cpp $cflags -c -o $build_folder/src_$1.o
  14. fi
  15. }
  16. _build() {
  17. if ! build_ $1 ; then
  18. echo "Error in $1"
  19. exit 1
  20. fi
  21. }
  22. _build Lexer &
  23. _build Class &
  24. _build Parser &
  25. _build ParserExpect &
  26. _build Recursive &
  27. _build Util &
  28. _build Library &
  29. _build Project &
  30. _build ClassMethods &
  31. _build Catel &
  32. _build main &
  33. wait < <(jobs -p)
  34. $CC $build_folder/*.o externals/linux_amd64_libfl.a $cflags -o$out_exec
  35. if ! test -f "./out/cate"; then
  36. echo "Cate didn't build corectly."
  37. exit 1
  38. fi
  39. if command -v strip &> /dev/null; then
  40. strip -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag out/cate
  41. fi
  42. install_command="cp ./out/cate /usr/bin/cate"
  43. read -r -p "Done. Would you like to install Cate? [Y/n]: " response
  44. case "$response" in
  45. [yY][eE][sS]|[yY])
  46. if command -v doas &> /dev/null; then
  47. sudo $install_command
  48. elif command -v sudo &> /dev/null; then
  49. doas $install_command
  50. elif [ "$EUID" -e 0]; then
  51. $install_command
  52. else
  53. echo "No way to run as root found, sorry"
  54. fi
  55. ;;
  56. *)
  57. exit
  58. ;;
  59. esac