Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # -----------------------
  2. # Compilation options
  3. # -----------------------
  4. RELEASE := 1
  5. STATIC := 0
  6. NO_DBG_SYMBOLS := 0
  7. # Enable multi-threading.
  8. # Warning: Experimental feature!!
  9. # invidious is not stable when MT is enabled.
  10. MT := 0
  11. FLAGS ?=
  12. ifeq ($(RELEASE), 1)
  13. FLAGS += --release
  14. endif
  15. ifeq ($(STATIC), 1)
  16. FLAGS += --static
  17. endif
  18. ifeq ($(MT), 1)
  19. FLAGS += -Dpreview_mt
  20. endif
  21. ifeq ($(NO_DBG_SYMBOLS), 1)
  22. FLAGS += --no-debug
  23. else
  24. FLAGS += --debug
  25. endif
  26. ifeq ($(API_ONLY), 1)
  27. FLAGS += -Dapi_only
  28. endif
  29. # -----------------------
  30. # Main
  31. # -----------------------
  32. all: invidious
  33. get-libs:
  34. shards install --production
  35. # TODO: add support for ARM64 via cross-compilation
  36. invidious: get-libs
  37. crystal build src/invidious.cr $(FLAGS) --progress --stats --error-trace
  38. run: invidious
  39. ./invidious
  40. # -----------------------
  41. # Development
  42. # -----------------------
  43. format:
  44. crystal tool format
  45. test:
  46. crystal spec
  47. verify:
  48. crystal build src/invidious.cr -Dskip_videojs_download \
  49. --no-codegen --progress --stats --error-trace
  50. # -----------------------
  51. # (Un)Install
  52. # -----------------------
  53. # TODO
  54. # -----------------------
  55. # Cleaning
  56. # -----------------------
  57. clean:
  58. rm invidious
  59. distclean: clean
  60. rm -rf libs
  61. rm -rf ~/.cache/{crystal,shards}
  62. # -----------------------
  63. # Help page
  64. # -----------------------
  65. help:
  66. @echo "Targets available in this Makefile:"
  67. @echo ""
  68. @echo " get-libs Fetch Crystal libraries"
  69. @echo " invidious Build Invidious"
  70. @echo " run Launch Invidious"
  71. @echo ""
  72. @echo " format Run the Crystal formatter"
  73. @echo " test Run tests"
  74. @echo " verify Just make sure that the code compiles, but without"
  75. @echo " generating any binaries. Useful to search for errors"
  76. @echo ""
  77. @echo " clean Remove build artifacts"
  78. @echo " distclean Remove build artifacts and libraries"
  79. @echo ""
  80. @echo ""
  81. @echo "Build options available for this Makefile:"
  82. @echo ""
  83. @echo " RELEASE Make a release build (Default: 1)"
  84. @echo " STATIC Link libraries statically (Default: 0)"
  85. @echo ""
  86. @echo " API_ONLY Build invidious without a GUI (Default: 0)"
  87. @echo " NO_DBG_SYMBOLS Strip debug symbols (Default: 0)"
  88. # No targets generates an output named after themselves
  89. .PHONY: all get-libs build amd64 run
  90. .PHONY: format test verify clean distclean help