Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. # meg4/platform/emscripten/Makefile
  3. #
  4. # Copyright (C) 2023 bzt
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. #
  20. # @brief The emscripten Makefile
  21. #
  22. TARGET = meg4.js
  23. USE_EMCC = 1
  24. ifneq ($(NOEDITORS),)
  25. LINK = -g0 -O3
  26. else
  27. FUNC=,"_meg4_insert"
  28. EDS=../../src/editors/*.o
  29. endif
  30. ifeq ($(NOLUA),)
  31. ifneq ($(wildcard ../../src/lua/lvm.c),)
  32. LUAO=../../src/lua/*.o
  33. endif
  34. endif
  35. include ../common.mk
  36. meg4.js:
  37. @make --no-print-directory -C ../sdl clean
  38. CC=emcc USE_EMCC=1 make -C ../sdl all DEBUG=$(DEBUG) NOEDITORS=$(NOEDITORS)
  39. emcc -s USE_SDL=2 -s EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s WASM_BIGINT -s EXPORTED_FUNCTIONS='["_main"$(FUNC),"_malloc","_free"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]' $(LINK) --pre-js=pre.js \
  40. ../sdl/*.o ../../src/*.o $(EDS) $(LUAO) -o meg4.js
  41. @make --no-print-directory -C ../sdl clean
  42. ifeq ($(NOEDITORS),)
  43. cp meg4.js meg4.wasm ../../public
  44. else
  45. ifneq ($(wildcard ../../src/editors/pro.c),)
  46. @cc ../../src/bin2h.c -o bin2h
  47. ./bin2h -o ../../src/editors/pro.wasm meg4.js meg4.wasm
  48. @rm bin2h bin2h.exe 2>/dev/null || true
  49. endif
  50. endif