static-deps-build.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/usr/bin/make -f
  2. # If this is set to true (via the environment) then CRC checking will be
  3. # disabled in libogg giving fuzzers a better chance at finding something.
  4. disable_ogg_crc ?= false
  5. # Build libsndfile as a dynamic/shared library, but statically link to
  6. # libFLAC, libogg, libopus and libvorbis
  7. ogg_version = libogg-1.3.4
  8. ogg_sha256sum = c163bc12bc300c401b6aa35907ac682671ea376f13ae0969a220f7ddf71893fe
  9. vorbis_version = libvorbis-1.3.7
  10. vorbis_sha256sum = b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b
  11. flac_version = flac-1.3.3
  12. flac_sha256sum = 213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748
  13. opus_version = opus-1.3.1
  14. opus_sha256sum = 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d
  15. #-------------------------------------------------------------------------------
  16. # Code follows.
  17. ogg_tarball = $(ogg_version).tar.xz
  18. vorbis_tarball = $(vorbis_version).tar.xz
  19. flac_tarball = $(flac_version).tar.xz
  20. opus_tarball = $(opus_version).tar.gz
  21. download_url = http://downloads.xiph.org/releases/
  22. tarball_dir = Build/Tarballs
  23. stamp_dir = Build/Stamp
  24. build_dir = $(shell pwd)/Build
  25. config_options = --prefix=$(build_dir) --disable-shared --enable-option-checking
  26. pwd = $(shell pwd)
  27. help :
  28. @echo
  29. @echo "This script will build libsndfile as a dynamic/shared library but statically linked"
  30. @echo "to libFLAC, libogg and libvorbis. It should work on Linux and Mac OS X. It might"
  31. @echo "work on Windows with a correctly set up MinGW."
  32. @echo
  33. @echo "It requires all the normal build tools require to build libsndfile plus wget."
  34. @echo
  35. config : Build/Stamp/configure
  36. build : Build/Stamp/build
  37. clean :
  38. rm -rf Build/flac-* Build/libogg-* Build/libvorbis-* Build/opus-*
  39. rm -rf Build/bin Build/include Build/lib Build/share
  40. rm -f Build/Stamp/install Build/Stamp/extract Build/Stamp/sha256sum Build/Stamp/build-ogg
  41. Build/Stamp/init :
  42. mkdir -p $(stamp_dir) $(tarball_dir)
  43. touch $@
  44. Build/Tarballs/$(flac_tarball) : Build/Stamp/init
  45. (cd $(tarball_dir) && wget $(download_url)flac/$(flac_tarball) -O $(flac_tarball))
  46. touch $@
  47. Build/Tarballs/$(ogg_tarball) : Build/Stamp/init
  48. (cd $(tarball_dir) && wget $(download_url)ogg/$(ogg_tarball) -O $(ogg_tarball))
  49. touch $@
  50. Build/Tarballs/$(vorbis_tarball) : Build/Stamp/init
  51. (cd $(tarball_dir) && wget $(download_url)vorbis/$(vorbis_tarball) -O $(vorbis_tarball))
  52. touch $@
  53. Build/Tarballs/$(opus_tarball) : Build/Stamp/init
  54. (cd $(tarball_dir) && wget https://archive.mozilla.org/pub/opus/$(opus_tarball) -O $(opus_tarball))
  55. touch $@
  56. Build/Stamp/tarballs : Build/Tarballs/$(flac_tarball) Build/Tarballs/$(ogg_tarball) Build/Tarballs/$(vorbis_tarball) Build/Tarballs/$(opus_tarball)
  57. touch $@
  58. Build/Stamp/sha256sum : Build/Stamp/tarballs
  59. test `sha256sum $(tarball_dir)/$(ogg_tarball) | sed "s/ .*//"` = $(ogg_sha256sum)
  60. test `sha256sum $(tarball_dir)/$(vorbis_tarball) | sed "s/ .*//"` = $(vorbis_sha256sum)
  61. test `sha256sum $(tarball_dir)/$(flac_tarball) | sed "s/ .*//"` = $(flac_sha256sum)
  62. test `sha256sum $(tarball_dir)/$(opus_tarball) | sed "s/ .*//"` = $(opus_sha256sum)
  63. touch $@
  64. Build/Stamp/extract : Build/Stamp/sha256sum
  65. # (cd Build && tar xf Tarballs/$(ogg_tarball))
  66. (cd Build && tar xf Tarballs/$(flac_tarball))
  67. (cd Build && tar xf Tarballs/$(vorbis_tarball))
  68. (cd Build && tar xf Tarballs/$(opus_tarball))
  69. touch $@
  70. Build/Stamp/build-ogg : Build/Stamp/sha256sum
  71. ifeq ($(disable_ogg_crc), true)
  72. echo "Ogg/CRC enabled"
  73. (cd Build && git clone https://github.com/xiph/ogg $(ogg_version))
  74. (cd Build/$(ogg_version) && autoreconf -vif && CFLAGS=-fPIC ./configure $(config_options) --disable-crc && make all install)
  75. else
  76. echo "Ogg/CRC disabled"
  77. (cd Build && tar xf Tarballs/$(ogg_tarball))
  78. (cd Build/$(ogg_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install)
  79. endif
  80. touch $@
  81. Build/Stamp/install-libs : Build/Stamp/extract Build/Stamp/build-ogg
  82. (cd Build/$(vorbis_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install)
  83. (cd Build/$(flac_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install)
  84. (cd Build/$(opus_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install)
  85. touch $@
  86. configure : configure.ac
  87. autoreconf -vif
  88. Build/Stamp/configure : Build/Stamp/install-libs configure
  89. PKG_CONFIG_LIBDIR=Build/lib/pkgconfig ./configure
  90. sed -i 's#^EXTERNAL_XIPH_CFLAGS.*#EXTERNAL_XIPH_CFLAGS = -I$(pwd)/Build/include#' Makefile
  91. sed -i 's#^EXTERNAL_XIPH_LIBS.*#EXTERNAL_XIPH_LIBS = -static $(pwd)/Build/lib/libFLAC.la $(pwd)/Build/lib/libvorbis.la $(pwd)/Build/lib/libvorbisenc.la $(pwd)/Build/lib/libopus.la $(pwd)/Build/lib/libogg.la -dynamic #' Makefile
  92. make clean
  93. touch $@
  94. Build/Stamp/build : Build/Stamp/configure
  95. make all check
  96. touch $@