Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #
  2. # tngp/emscripten/Makefile
  3. #
  4. # Copyright (C) 2022 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 Dirty hacks to compile tngp with emscripten...
  21. #
  22. all: tngp.js
  23. # download an unofficial, but patched for wasm libtheora repo, because the original library does not compile with emscripten
  24. ./libtheora/autogen.sh:
  25. curl https://github.com/brion/theora/archive/2d97ea8166e307ba52dcbbf598a907d8c803c76c.zip | unzip /dev/stdin
  26. mv theora-* libtheora
  27. ./libtheora/lib/.libs/libtheoradec.a:
  28. ./libtheora/lib/.libs/libtheora.a: libtheora/autogen.sh
  29. ifeq ($(wildcard libtheora/configure),)
  30. cd libtheora && ./autogen.sh
  31. @rm libtheora/Makefile 2>/dev/null || true
  32. endif
  33. ifeq ($(wildcard libtheora/Makefile),)
  34. cd libtheora && emconfigure ./configure --disable-shared --enable-static --disable-telemetry --disable-doc --disable-spec \
  35. --disable-valgrind-testing --disable-asm --disable-encode --disable-oggtest --disable-examples --with-ogg=$(abspath ../../src)
  36. endif
  37. @emmake make --no-print-directory -s -C libtheora all
  38. tngp.js: ./libtheora/lib/.libs/libtheora.a
  39. CC=emcc USE_EMCC=1 make -C ../src objs
  40. @cd ../src/mbedtls && emcc -I.. -c sha256.c -o sha256.o
  41. emcc ./libtheora/lib/.libs/libtheoradec.a ./libtheora/lib/.libs/libtheora.a ../src/mbedtls/sha256.o ../src/*.o -o tngp.js \
  42. -s USE_SDL=2 -s USE_SDL_MIXER=2 -s USE_OGG=1 -s USE_VORBIS=1 -s ASYNCIFY=1 -s EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s WASM_BIGINT
  43. @rm ../src/mbedtls/sha256.o
  44. package: tngp.js
  45. tar -czvf ../tngp-wasm-emscripten.tgz tngp.html tngp.js tngp.wasm
  46. clean:
  47. make -C ../src clean
  48. rm tngp*.js tngp.wasm || true
  49. distclean:
  50. rm -rf libtheora 2>/dev/null || true
  51. make clean