Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Cross-compile opusfile under mingw
  2. TOOL_PREFIX ?= i686-w64-mingw32
  3. # To build opusfile under mingw, we first need to build:
  4. DEPS = ogg opus ssl
  5. ogg_URL := https://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz
  6. ogg_SHA := 4f3fc6178a533d392064f14776b23c397ed4b9f48f5de297aba73b643f955c08
  7. opus_URL := https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
  8. opus_SHA := cfafd339ccd9c5ef8d6ab15d7e1a412c054bf4cb4ecbbbcc78c12ef2def70732
  9. ssl_URL := https://openssl.org/source/openssl-1.0.2p.tar.gz
  10. ssl_SHA := 50a98e07b1a89eb8f6a99477f262df71c6fa7bef77df4dc83025a2845c827d00
  11. all: $(DEPS)
  12. libopusfile-0.dll: ../unix/Makefile $(DEPS)
  13. CC=$(TOOL_PREFIX)-gcc \
  14. RANLIB=$(TOOL_PREFIX)-ranlib \
  15. PKG_CONFIG_PATH=$(CURDIR)/lib/pkgconfig \
  16. $(MAKE) -f $<
  17. opusfile: $(DEPS)
  18. ../configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR) \
  19. PKG_CONFIG_PATH=$(CURDIR)/lib/pkgconfig
  20. $(MAKE)
  21. clean:
  22. $(RM) -r objs
  23. $(RM) -r bin include lib share ssl
  24. $(RM) -r $(DEP_DIRS)
  25. $(RM) opusfile_example.exe seeking_example.exe
  26. $(RM) libopusfile.a libopusurl.a
  27. # Generate rules to download and verify each dependency.
  28. define WGET_template =
  29. # Generate tarball name from the url.
  30. DEP_TARBALLS += $$(notdir $$($(1)_URL))
  31. $(1)_DIR := $$(basename $$(basename $$(notdir $$($(1)_URL))))
  32. DEP_DIRS += $$($(1)_DIR)
  33. # Verify and unpack tarball.
  34. $$($(1)_DIR): $$(notdir $$($(1)_URL))
  35. @if test "$$($(1)_SHA)" = "$$$$(sha256sum $$< | cut -f 1 -d ' ')"; \
  36. then \
  37. echo "+ $$< checksum verified."; \
  38. else \
  39. echo "! $$< checksum didn't match!"; \
  40. $(RM) $$<; exit 1; \
  41. fi
  42. tar xf $$<
  43. # Fetch tarball from the url.
  44. $$(notdir $$($(1)_URL)):
  45. wget $$($(1)_URL)
  46. # Hook project-specific build rule.
  47. $(1): $(1)_BUILD
  48. endef
  49. $(foreach dep,$(DEPS),$(eval $(call WGET_template,$(dep))))
  50. fetch: $(DEP_TARBALLS)
  51. realclean: clean
  52. $(RM) $(DEP_TARBALLS)
  53. # Build scripts for each specific target.
  54. # NOTE: 'make check' generally requires wine with cross-compiling.
  55. ogg_BUILD: $(ogg_DIR)
  56. cd $< && ./configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR)
  57. $(MAKE) -C $< install
  58. opus_BUILD: $(opus_DIR)
  59. cd $< && ./configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR)
  60. $(MAKE) -C $< install
  61. ssl_BUILD: $(ssl_DIR)
  62. cd $< && ./Configure shared mingw64 no-asm \
  63. --prefix=$(CURDIR) \
  64. --cross-compile-prefix=$(TOOL_PREFIX)-
  65. $(MAKE) -C $< depend
  66. $(MAKE) -C $<
  67. $(MAKE) -C $< install
  68. # CROSS_COMPILE="i686-w64-mingw32-" ./Configure mingw no-asm no-shared --prefix=$PWD/mingw && make depend && make -j8 && make install
  69. # Package the binaries.
  70. DIST_VERSION := $(shell git describe --dirty)
  71. DIST := opusfile-$(DIST_VERSION)-win32
  72. package: $(DIST).zip
  73. $(DIST).zip: $(DIST)
  74. zip -r $@ $</*
  75. @echo $@ ready to go.
  76. $(DIST): $(addprefix $(CURDIR)/bin/, libogg-0.dll libopus-0.dll ssleay32.dll)
  77. cd .. && make install
  78. mkdir -p $(DIST)
  79. cp ../AUTHORS ../COPYING ../README.md ../include/opusfile.h $@
  80. cp ../.libs/libopusfile-0.dll $@
  81. cp ../.libs/libopusfile.a $@
  82. cp ../.libs/libopusfile.dll.a $@
  83. cp ../.libs/libopusurl-0.dll $@
  84. cp ../.libs/libopusurl.a $@
  85. cp ../.libs/libopusurl.dll.a $@
  86. cp bin/*.dll $@
  87. cp ../examples/.libs/*.exe $@
  88. cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll $@
  89. cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $@
  90. i686-w64-mingw32-strip $@/*.exe
  91. i686-w64-mingw32-strip $@/*.dll
  92. i686-w64-mingw32-strip $@/*.a
  93. cd $@ && sha256sum * > SHA256SUMS.txt