Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 := http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz
  6. ogg_SHA := 3f687ccdd5ac8b52d76328fbbfebc70c459a40ea891dbf3dccb74a210826e79b
  7. opus_URL := https://archive.mozilla.org/pub/opus/opus-1.1.1.tar.gz
  8. opus_SHA := 9b84ff56bd7720d5554103c557664efac2b8b18acc4bbcc234cb881ab9a3371e
  9. ssl_URL := https://openssl.org/source/openssl-1.0.1q.tar.gz
  10. ssl_SHA := b3658b84e9ea606a5ded3c972a5517cd785282e7ea86b20c78aa4b773a047fb7
  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 := opusfile-0.7rc-f22docker-win32
  71. package: $(DIST).zip
  72. $(DIST).zip: $(DIST)
  73. zip -r $@ $</*
  74. @echo $@ ready to go.
  75. $(DIST): $(addprefix $(CURDIR)/bin/, libogg-0.dll libopus-0.dll ssleay32.dll)
  76. cd .. && make install
  77. mkdir -p $(DIST)
  78. cp ../AUTHORS ../COPYING ../README.txt ../include/opusfile.h $@
  79. cp ../.libs/libopusfile-0.dll $@
  80. cp ../.libs/libopusfile.a $@
  81. cp ../.libs/libopusfile.dll.a $@
  82. cp ../.libs/libopusurl-0.dll $@
  83. cp ../.libs/libopusurl.a $@
  84. cp ../.libs/libopusurl.dll.a $@
  85. cp bin/*.dll $@
  86. cp ../examples/.libs/*.exe $@
  87. cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll $@
  88. cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $@
  89. i686-w64-mingw32-strip $@/*.exe
  90. i686-w64-mingw32-strip $@/*.dll
  91. i686-w64-mingw32-strip $@/*.a
  92. cd $@ && sha256sum * > SHA256SUMS.txt