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