make.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. # Optional helper build script for Anarch.
  3. # by drummyfish, released under CC0 1.0, public domain
  4. #
  5. # usage:
  6. #
  7. # ./make.sh platform [compiler]
  8. if [ $# -lt 1 ]; then
  9. echo "need a parameter (sdl, pokitto, gb, emscripten, ...)"
  10. exit 0
  11. fi
  12. clear; clear;
  13. C_FLAGS="-std=c99 -Wall -Wextra -pedantic -O3 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -o anarch"
  14. COMPILER='g++'
  15. if [ $# -eq 2 ]; then
  16. COMPILER=$2
  17. if [ $2 = "tcc" ]; then # you'll probably want to modify this
  18. C_FLAGS="${C_FLAGS} -L/usr/lib/x86_64-linux-gnu/pulseaudio/
  19. -I/home/tastyfish/git/tcc/tcc-0.9.27/include
  20. -I/usr/lib/gcc/x86_64-linux-gnu/8/include/"
  21. fi
  22. fi
  23. echo "compiling"
  24. if [ $1 = "sdl" ]; then
  25. # PC SDL build, requires:
  26. # - g++
  27. # - SDL2 (dev) package
  28. SDL_FLAGS=`sdl2-config --cflags --libs`
  29. COMMAND="${COMPILER} ${C_FLAGS} main_sdl.c -I/usr/local/include ${SDL_FLAGS}"
  30. echo ${COMMAND}
  31. ${COMMAND}
  32. elif [ $1 = "ncurses" ]; then
  33. # ncurses build, requires:
  34. # - libncurses-dev
  35. COMMAND="${COMPILER} ${C_FLAGS} -lncurses main_ncurses.c"
  36. echo ${COMMAND}
  37. ${COMMAND}
  38. elif [ $1 = "saf" ]; then
  39. # SAF build using SDL, requires:
  40. # - saf.h
  41. # - SDL2 (dev) package
  42. SDL_FLAGS=`sdl2-config --cflags --libs --static-libs`
  43. COMMAND="${COMPILER} ${C_FLAGS} main_saf.c -I/usr/local/include ${SDL_FLAGS}"
  44. echo ${COMMAND}
  45. ${COMMAND}
  46. elif [ $1 = "terminal" ]; then
  47. # PC terminal build, requires:
  48. # - g++
  49. COMMAND="${COMPILER} ${C_FLAGS} main_terminal.c"
  50. echo ${COMMAND}
  51. ${COMMAND}
  52. elif [ $1 = "csfml" ]; then
  53. # csfml build, requires:
  54. # - csfml
  55. COMMAND="${COMPILER} ${C_FLAGS} main_csfml.c -lcsfml-graphics -lcsfml-window -lcsfml-system -lcsfml-audio"
  56. echo ${COMMAND}
  57. ${COMMAND}
  58. elif [ $1 = "test" ]; then
  59. # test build, requires:
  60. # - g++
  61. COMMAND="${COMPILER} ${C_FLAGS} main_test.c"
  62. echo ${COMMAND}
  63. ${COMMAND}
  64. elif [ $1 = "pokitto" ]; then
  65. # Pokitto build, requires:
  66. # - PokittoLib, in this folder create a symlink named "PokittoLib" to the
  67. # "Pokitto" subfolder of PokittoLib
  68. # - Pokitto Makefile
  69. # - GNU embedded toolchain, in this folder create a symlink named "gtc" to the
  70. # "bin" subfolder
  71. # - files like My_settings.h required by Pokitto
  72. make
  73. ./PokittoEmu BUILD/firmware.bin
  74. elif [ $1 = "emscripten" ]; then
  75. # emscripten (browser Javascript) build, requires:
  76. # - emscripten
  77. ../emsdk/upstream/emscripten/emcc ./main_sdl.c -s USE_SDL=2 -O3 -lopenal --shell-file HTMLshell.html -o anarch.html -s EXPORTED_FUNCTIONS='["_main","_webButton"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]'
  78. else
  79. echo "unknown parameter: $1"
  80. fi