blob: 604ad73a7bd1f0125264dee3c9dedb80943ff0c9 [file] [log] [blame]
Guillaume Martres3526f1c2013-08-13 18:46:58 -07001#!/bin/sh
John Koleszar0ea50ce2010-05-18 11:58:33 -04002##
John Koleszar0d719652010-05-28 10:11:58 -04003## configure
John Koleszar0ea50ce2010-05-18 11:58:33 -04004##
John Koleszar0d719652010-05-28 10:11:58 -04005## This script is the front-end to the build system. It provides a similar
6## interface to standard configure scripts with some extra bits for dealing
7## with toolchains that differ from the standard POSIX interface and
8## for extracting subsets of the source tree. In theory, reusable parts
9## of this script were intended to live in build/make/configure.sh,
10## but in practice, the line is pretty blurry.
11##
12## This build system is based in part on the FFmpeg configure script.
John Koleszar0ea50ce2010-05-18 11:58:33 -040013##
14
John Koleszar0ea50ce2010-05-18 11:58:33 -040015#source_path="`dirname \"$0\"`"
16source_path=${0%/*}
17. "${source_path}/build/make/configure.sh"
18
19show_help(){
20 show_help_pre
21 cat << EOF
22Advanced options:
Johannec658122012-10-10 09:16:37 -070023 ${toggle_libs} libraries
24 ${toggle_examples} examples
25 ${toggle_docs} documentation
26 ${toggle_unit_tests} unit tests
Joshua Litta782d632013-11-15 12:29:26 -080027 ${toggle_decode_perf_tests} build decoder perf tests with unit tests
John Koleszar0ea50ce2010-05-18 11:58:33 -040028 --libc=PATH path to alternate libc
Jim Bankoski943e4322014-07-17 06:31:50 -070029 --size-limit=WxH max size to allow in the decoder
Jan Kratochvil7be093e2010-10-05 19:15:08 +020030 --as={yasm|nasm|auto} use specified assembler [auto, yasm preferred]
Johann5d0c33b2013-11-13 14:05:27 -080031 --sdk-path=PATH path to root of sdk (android builds only)
John Koleszar0ea50ce2010-05-18 11:58:33 -040032 ${toggle_fast_unaligned} don't use unaligned accesses, even when
33 supported by hardware [auto]
34 ${toggle_codec_srcs} in/exclude codec library source code
35 ${toggle_debug_libs} in/exclude debug version of libraries
John Koleszar0ea50ce2010-05-18 11:58:33 -040036 ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
37 ${toggle_vp8} VP8 codec support
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -070038 ${toggle_vp9} VP9 codec support
Yaowu Xu57ad1892011-04-29 09:37:59 -070039 ${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
John Koleszar0ea50ce2010-05-18 11:58:33 -040040 ${toggle_mem_tracker} track memory usage
John Koleszar0ea50ce2010-05-18 11:58:33 -040041 ${toggle_postproc} postprocessing
Jim Bankoski79401542013-09-04 10:02:08 -070042 ${toggle_vp9_postproc} vp9 specific postprocessing
Yunqing Wangaa7335e2011-10-25 15:14:16 -040043 ${toggle_multithread} multithreaded encoding and decoding
John Koleszar0ea50ce2010-05-18 11:58:33 -040044 ${toggle_spatial_resampling} spatial sampling (scaling) support
45 ${toggle_realtime_only} enable this option while building for real-time encoding
Attila Nagy52cf4dc2012-02-09 12:37:03 +020046 ${toggle_onthefly_bitpacking} enable on-the-fly bitpacking in real-time encoding
Stefan Holmerd04f8522011-05-02 15:30:51 +020047 ${toggle_error_concealment} enable this option to get a decoder which is able to conceal losses
John Koleszar0ea50ce2010-05-18 11:58:33 -040048 ${toggle_runtime_cpu_detect} runtime cpu detection
John Koleszar7aa97a32010-06-03 10:29:04 -040049 ${toggle_shared} shared library support
James Zern495b2412011-07-25 15:40:36 -070050 ${toggle_static} static library support
John Koleszarf9b2ca52010-09-21 10:06:41 -040051 ${toggle_small} favor smaller size over speed
Fritz Koenig647df002010-11-04 16:03:36 -070052 ${toggle_postproc_visualizer} macro block / block level visualizers
Yunqing Wangaa7335e2011-10-25 15:14:16 -040053 ${toggle_multi_res_encoding} enable multiple-resolution encoding
Stefan Holmer9c411432012-03-06 10:48:18 +010054 ${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser
Vignesh Venkatasubramanian0ffa3832014-03-14 08:10:35 -070055 ${toggle_webm_io} enable input from and output to WebM container
Deb Mukherjee47031c02014-05-16 18:52:01 -070056 ${toggle_libyuv} enable libyuv
John Koleszar0ea50ce2010-05-18 11:58:33 -040057
58Codecs:
59 Codecs can be selectively enabled or disabled individually, or by family:
60 --disable-<codec>
61 is equivalent to:
62 --disable-<codec>-encoder
63 --disable-<codec>-decoder
64
65 Codecs available in this distribution:
66EOF
67#restore editor state '
68
69 local family;
70 local last_family;
71 local c;
72 local str;
73 for c in ${CODECS}; do
74 family=${c%_*}
75 if [ "${family}" != "${last_family}" ]; then
76 [ -z "${str}" ] || echo "${str}"
77 str="$(printf ' %10s:' ${family})"
78 fi
79 str="${str} $(printf '%10s' ${c#*_})"
80 last_family=${family}
81 done
82 echo "${str}"
83 show_help_post
84}
85
86##
87## BEGIN APPLICATION SPECIFIC CONFIGURATION
88##
89
90# all_platforms is a list of all supported target platforms. Maintain
91# alphabetically by architecture, generic-gnu last.
Fritz Koenigd8305732012-01-06 11:50:05 -080092all_platforms="${all_platforms} armv5te-android-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -040093all_platforms="${all_platforms} armv5te-linux-rvct"
94all_platforms="${all_platforms} armv5te-linux-gcc"
Tero Rintaluoma11a222f2011-01-24 11:21:40 +020095all_platforms="${all_platforms} armv5te-none-rvct"
John Koleszar0ea50ce2010-05-18 11:58:33 -040096all_platforms="${all_platforms} armv6-darwin-gcc"
97all_platforms="${all_platforms} armv6-linux-rvct"
98all_platforms="${all_platforms} armv6-linux-gcc"
Tero Rintaluoma11a222f2011-01-24 11:21:40 +020099all_platforms="${all_platforms} armv6-none-rvct"
Tom Finegane87d6812014-06-25 18:32:16 -0700100all_platforms="${all_platforms} arm64-darwin-gcc"
Fritz Koenigd8305732012-01-06 11:50:05 -0800101all_platforms="${all_platforms} armv7-android-gcc" #neon Cortex-A8
John Koleszar0ea50ce2010-05-18 11:58:33 -0400102all_platforms="${all_platforms} armv7-darwin-gcc" #neon Cortex-A8
103all_platforms="${all_platforms} armv7-linux-rvct" #neon Cortex-A8
104all_platforms="${all_platforms} armv7-linux-gcc" #neon Cortex-A8
Tero Rintaluoma11a222f2011-01-24 11:21:40 +0200105all_platforms="${all_platforms} armv7-none-rvct" #neon Cortex-A8
Martin Storsjoad484fc2013-05-18 23:32:49 +0300106all_platforms="${all_platforms} armv7-win32-vs11"
Yaowu Xua638bdf2013-11-13 11:36:32 -0800107all_platforms="${all_platforms} armv7-win32-vs12"
Tom Finegancd2088b2014-06-10 18:52:58 -0700108all_platforms="${all_platforms} armv7s-darwin-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400109all_platforms="${all_platforms} mips32-linux-gcc"
110all_platforms="${all_platforms} ppc32-darwin8-gcc"
111all_platforms="${all_platforms} ppc32-darwin9-gcc"
Johann0511cbf2010-09-21 14:56:42 -0400112all_platforms="${all_platforms} ppc32-linux-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400113all_platforms="${all_platforms} ppc64-darwin8-gcc"
114all_platforms="${all_platforms} ppc64-darwin9-gcc"
115all_platforms="${all_platforms} ppc64-linux-gcc"
Aaron Watry53f61ce2010-09-30 15:36:00 -0400116all_platforms="${all_platforms} sparc-solaris-gcc"
Andoni Morales Alastruey652589d2013-01-14 12:25:52 +0100117all_platforms="${all_platforms} x86-android-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400118all_platforms="${all_platforms} x86-darwin8-gcc"
119all_platforms="${all_platforms} x86-darwin8-icc"
120all_platforms="${all_platforms} x86-darwin9-gcc"
121all_platforms="${all_platforms} x86-darwin9-icc"
Johann4341e5a2011-10-14 12:06:24 -0700122all_platforms="${all_platforms} x86-darwin10-gcc"
Johann101c2bd2012-04-27 11:40:04 -0700123all_platforms="${all_platforms} x86-darwin11-gcc"
124all_platforms="${all_platforms} x86-darwin12-gcc"
Morton Jonuschatfe4a5202013-07-19 21:09:23 +0200125all_platforms="${all_platforms} x86-darwin13-gcc"
Tom Finegan4e6c5552014-06-04 18:57:25 -0700126all_platforms="${all_platforms} x86-iphonesimulator-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400127all_platforms="${all_platforms} x86-linux-gcc"
128all_platforms="${all_platforms} x86-linux-icc"
KO Myung-Hun2dad8d62012-02-03 13:31:11 +0900129all_platforms="${all_platforms} x86-os2-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400130all_platforms="${all_platforms} x86-solaris-gcc"
131all_platforms="${all_platforms} x86-win32-gcc"
132all_platforms="${all_platforms} x86-win32-vs7"
133all_platforms="${all_platforms} x86-win32-vs8"
Tom Finegan72d4ba92010-07-22 13:34:25 -0400134all_platforms="${all_platforms} x86-win32-vs9"
Martin Storsjobd91beb2013-05-17 00:57:57 +0300135all_platforms="${all_platforms} x86-win32-vs10"
136all_platforms="${all_platforms} x86-win32-vs11"
Yaowu Xua638bdf2013-11-13 11:36:32 -0800137all_platforms="${all_platforms} x86-win32-vs12"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400138all_platforms="${all_platforms} x86_64-darwin9-gcc"
tomfineganfaaa57b2010-11-16 14:52:05 -0500139all_platforms="${all_platforms} x86_64-darwin10-gcc"
Christian Duvivier82edabc2012-08-06 15:05:24 -0700140all_platforms="${all_platforms} x86_64-darwin11-gcc"
Johann101c2bd2012-04-27 11:40:04 -0700141all_platforms="${all_platforms} x86_64-darwin12-gcc"
Morton Jonuschatfe4a5202013-07-19 21:09:23 +0200142all_platforms="${all_platforms} x86_64-darwin13-gcc"
Tom Finegan9b259762014-06-06 16:54:16 -0700143all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400144all_platforms="${all_platforms} x86_64-linux-gcc"
Yunqing Wang7630e362010-06-17 13:34:19 -0400145all_platforms="${all_platforms} x86_64-linux-icc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400146all_platforms="${all_platforms} x86_64-solaris-gcc"
Rafaël Carré3cad6942011-11-11 22:45:44 -0500147all_platforms="${all_platforms} x86_64-win64-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400148all_platforms="${all_platforms} x86_64-win64-vs8"
Tom Finegan72d4ba92010-07-22 13:34:25 -0400149all_platforms="${all_platforms} x86_64-win64-vs9"
Martin Storsjobd91beb2013-05-17 00:57:57 +0300150all_platforms="${all_platforms} x86_64-win64-vs10"
151all_platforms="${all_platforms} x86_64-win64-vs11"
Yaowu Xua638bdf2013-11-13 11:36:32 -0800152all_platforms="${all_platforms} x86_64-win64-vs12"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400153all_platforms="${all_platforms} universal-darwin8-gcc"
154all_platforms="${all_platforms} universal-darwin9-gcc"
Johann101c2bd2012-04-27 11:40:04 -0700155all_platforms="${all_platforms} universal-darwin10-gcc"
156all_platforms="${all_platforms} universal-darwin11-gcc"
157all_platforms="${all_platforms} universal-darwin12-gcc"
Morton Jonuschatfe4a5202013-07-19 21:09:23 +0200158all_platforms="${all_platforms} universal-darwin13-gcc"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400159all_platforms="${all_platforms} generic-gnu"
160
161# all_targets is a list of all targets that can be configured
162# note that these should be in dependency order for now.
163all_targets="libs examples docs"
164
165# all targets available are enabled, by default.
166for t in ${all_targets}; do
James Zern95735c32014-04-23 14:51:45 -0700167 [ -f "${source_path}/${t}.mk" ] && enable_feature ${t}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400168done
169
James Zern4b418002014-03-18 18:19:16 -0700170if ! perl --version >/dev/null; then
171 die "Perl is required to build"
172fi
James Zern14be7ba2014-02-28 12:24:46 -0800173
James Zern9402e252014-03-05 14:13:01 -0800174
James Zern95735c32014-04-23 14:51:45 -0700175if [ "`cd \"${source_path}\" && pwd`" != "`pwd`" ]; then
James Zern9402e252014-03-05 14:13:01 -0800176 # test to see if source_path already configured
James Zern95735c32014-04-23 14:51:45 -0700177 if [ -f "${source_path}/vpx_config.h" ]; then
James Zern9402e252014-03-05 14:13:01 -0800178 die "source directory already configured; run 'make distclean' there first"
179 fi
180fi
181
John Koleszar0ea50ce2010-05-18 11:58:33 -0400182# check installed doxygen version
183doxy_version=$(doxygen --version 2>/dev/null)
184doxy_major=${doxy_version%%.*}
185if [ ${doxy_major:-0} -ge 1 ]; then
186 doxy_version=${doxy_version#*.}
187 doxy_minor=${doxy_version%%.*}
188 doxy_patch=${doxy_version##*.}
189
James Zern42ab4012013-08-21 18:11:45 -0700190 [ $doxy_major -gt 1 ] && enable_feature doxygen
191 [ $doxy_minor -gt 5 ] && enable_feature doxygen
192 [ $doxy_minor -eq 5 ] && [ $doxy_patch -ge 3 ] && enable_feature doxygen
John Koleszar0ea50ce2010-05-18 11:58:33 -0400193fi
194
John Koleszaree8bcb12010-05-24 10:16:44 -0400195# install everything except the sources, by default. sources will have
196# to be enabled when doing dist builds, since that's no longer a common
197# case.
James Zernf8630c72014-05-10 11:15:11 -0700198enabled doxygen && enable_feature install_docs
James Zern42ab4012013-08-21 18:11:45 -0700199enable_feature install_bins
200enable_feature install_libs
John Koleszar0ea50ce2010-05-18 11:58:33 -0400201
James Zern42ab4012013-08-21 18:11:45 -0700202enable_feature static
203enable_feature optimizations
204enable_feature fast_unaligned #allow unaligned accesses, if supported by hw
James Zern42ab4012013-08-21 18:11:45 -0700205enable_feature spatial_resampling
206enable_feature multithread
207enable_feature os_support
208enable_feature temporal_denoising
John Koleszar0ea50ce2010-05-18 11:58:33 -0400209
James Zern95735c32014-04-23 14:51:45 -0700210[ -d "${source_path}/../include" ] && enable_feature alt_tree_layout
John Koleszar7b8dfcb2012-11-06 16:59:01 -0800211for d in vp8 vp9; do
James Zern95735c32014-04-23 14:51:45 -0700212 [ -d "${source_path}/${d}" ] && disable_feature alt_tree_layout;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400213done
214
215if ! enabled alt_tree_layout; then
216# development environment
James Zern95735c32014-04-23 14:51:45 -0700217[ -d "${source_path}/vp8" ] && CODECS="${CODECS} vp8_encoder vp8_decoder"
218[ -d "${source_path}/vp9" ] && CODECS="${CODECS} vp9_encoder vp9_decoder"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400219else
220# customer environment
James Zern95735c32014-04-23 14:51:45 -0700221[ -f "${source_path}/../include/vpx/vp8cx.h" ] && CODECS="${CODECS} vp8_encoder"
222[ -f "${source_path}/../include/vpx/vp8dx.h" ] && CODECS="${CODECS} vp8_decoder"
223[ -f "${source_path}/../include/vpx/vp9cx.h" ] && CODECS="${CODECS} vp9_encoder"
224[ -f "${source_path}/../include/vpx/vp9dx.h" ] && CODECS="${CODECS} vp9_decoder"
225[ -f "${source_path}/../include/vpx/vp8cx.h" ] || disable_feature vp8_encoder
226[ -f "${source_path}/../include/vpx/vp8dx.h" ] || disable_feature vp8_decoder
227[ -f "${source_path}/../include/vpx/vp9cx.h" ] || disable_feature vp9_encoder
228[ -f "${source_path}/../include/vpx/vp9dx.h" ] || disable_feature vp9_decoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400229
James Zern95735c32014-04-23 14:51:45 -0700230[ -f "${source_path}/../lib/*/*mt.lib" ] && soft_enable static_msvcrt
John Koleszar0ea50ce2010-05-18 11:58:33 -0400231fi
232
233CODECS="$(echo ${CODECS} | tr ' ' '\n')"
234CODEC_FAMILIES="$(for c in ${CODECS}; do echo ${c%_*}; done | sort | uniq)"
235
236ARCH_LIST="
237 arm
238 mips
239 x86
240 x86_64
241 ppc32
242 ppc64
243"
244ARCH_EXT_LIST="
Fritz Koenig89210282012-01-19 15:18:31 -0800245 edsp
246 media
247 neon
Johannce239312014-05-07 11:01:31 -0700248 neon_asm
John Koleszar0ea50ce2010-05-18 11:58:33 -0400249
250 mips32
Dragan Mrdjan07ff7fa2012-04-11 09:53:15 -0700251 dspr2
John Koleszar0ea50ce2010-05-18 11:58:33 -0400252
253 mmx
254 sse
255 sse2
256 sse3
257 ssse3
Yunqing Wang71ecb5d2010-10-27 08:45:24 -0400258 sse4_1
Erik Niemeyere6863ef2013-10-29 09:48:12 -0600259 avx
260 avx2
John Koleszar0ea50ce2010-05-18 11:58:33 -0400261
262 altivec
263"
264HAVE_LIST="
265 ${ARCH_EXT_LIST}
266 vpx_ports
267 stdint_h
268 alt_tree_layout
269 pthread_h
270 sys_mman_h
Attila Nagy297b2762011-03-25 12:53:03 +0200271 unistd_h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400272"
John Koleszar0952acb2010-06-01 11:14:25 -0400273EXPERIMENT_LIST="
James Zernf12ebfc2014-05-14 19:45:20 -0700274 multiple_arf
275 spatial_svc
Tim Koppab8bfb02014-06-05 14:00:08 -0700276 denoising
Pengchong Jinaaabbd62014-06-30 09:52:27 -0700277 fp_mb_stats
John Koleszar0952acb2010-06-01 11:14:25 -0400278"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400279CONFIG_LIST="
280 external_build
281 install_docs
282 install_bins
283 install_libs
284 install_srcs
Jim Bankoskia93b1152013-08-05 17:28:52 -0700285 use_x86inc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400286 debug
287 gprof
288 gcov
289 rvct
290 gcc
291 msvs
292 pic
293 big_endian
294
295 codec_srcs
296 debug_libs
297 fast_unaligned
298 mem_manager
299 mem_tracker
300 mem_checks
John Koleszar0ea50ce2010-05-18 11:58:33 -0400301
302 dequant_tokens
303 dc_recon
John Koleszar0ea50ce2010-05-18 11:58:33 -0400304 runtime_cpu_detect
305 postproc
Jim Bankoski79401542013-09-04 10:02:08 -0700306 vp9_postproc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400307 multithread
Yaowu Xu57ad1892011-04-29 09:37:59 -0700308 internal_stats
John Koleszar0ea50ce2010-05-18 11:58:33 -0400309 ${CODECS}
310 ${CODEC_FAMILIES}
311 encoders
312 decoders
313 static_msvcrt
314 spatial_resampling
315 realtime_only
Attila Nagy52cf4dc2012-02-09 12:37:03 +0200316 onthefly_bitpacking
Stefan Holmerd04f8522011-05-02 15:30:51 +0200317 error_concealment
John Koleszar7aa97a32010-06-03 10:29:04 -0400318 shared
James Zern495b2412011-07-25 15:40:36 -0700319 static
John Koleszarf9b2ca52010-09-21 10:06:41 -0400320 small
Fritz Koenig647df002010-11-04 16:03:36 -0700321 postproc_visualizer
Tero Rintaluoma11a222f2011-01-24 11:21:40 +0200322 os_support
James Berrya0769f72012-05-02 17:25:58 -0400323 unit_tests
Vignesh Venkatasubramanian0ffa3832014-03-14 08:10:35 -0700324 webm_io
Deb Mukherjee47031c02014-05-16 18:52:01 -0700325 libyuv
Joshua Litta782d632013-11-15 12:29:26 -0800326 decode_perf_tests
Yunqing Wangaa7335e2011-10-25 15:14:16 -0400327 multi_res_encoding
Stefan Holmer9c411432012-03-06 10:48:18 +0100328 temporal_denoising
John Koleszar0952acb2010-06-01 11:14:25 -0400329 experimental
Jim Bankoski943e4322014-07-17 06:31:50 -0700330 size_limit
John Koleszar0952acb2010-06-01 11:14:25 -0400331 ${EXPERIMENT_LIST}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400332"
333CMDLINE_SELECT="
John Koleszard9847632012-12-10 12:07:59 -0800334 external_build
John Koleszar0ea50ce2010-05-18 11:58:33 -0400335 extra_warnings
336 werror
337 install_docs
338 install_bins
339 install_libs
340 install_srcs
341 debug
342 gprof
343 gcov
344 pic
Jim Bankoskic9126e02013-08-06 07:31:54 -0700345 use_x86inc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400346 optimizations
347 ccache
348 runtime_cpu_detect
Martin Storsjo132422d2013-05-13 01:16:09 +0300349 thumb
John Koleszar0ea50ce2010-05-18 11:58:33 -0400350
351 libs
352 examples
Johannec658122012-10-10 09:16:37 -0700353 docs
John Koleszar0ea50ce2010-05-18 11:58:33 -0400354 libc
Jan Kratochvil7be093e2010-10-05 19:15:08 +0200355 as
Jim Bankoski943e4322014-07-17 06:31:50 -0700356 size_limit
John Koleszar0ea50ce2010-05-18 11:58:33 -0400357 fast_unaligned
358 codec_srcs
359 debug_libs
John Koleszar0ea50ce2010-05-18 11:58:33 -0400360
361 dequant_tokens
362 dc_recon
John Koleszar0ea50ce2010-05-18 11:58:33 -0400363 postproc
Jim Bankoski79401542013-09-04 10:02:08 -0700364 vp9_postproc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400365 multithread
Yaowu Xu57ad1892011-04-29 09:37:59 -0700366 internal_stats
John Koleszar0ea50ce2010-05-18 11:58:33 -0400367 ${CODECS}
368 ${CODEC_FAMILIES}
369 static_msvcrt
370 mem_tracker
371 spatial_resampling
372 realtime_only
Attila Nagy52cf4dc2012-02-09 12:37:03 +0200373 onthefly_bitpacking
Stefan Holmerd04f8522011-05-02 15:30:51 +0200374 error_concealment
John Koleszar7aa97a32010-06-03 10:29:04 -0400375 shared
James Zern495b2412011-07-25 15:40:36 -0700376 static
John Koleszarf9b2ca52010-09-21 10:06:41 -0400377 small
Fritz Koenig647df002010-11-04 16:03:36 -0700378 postproc_visualizer
James Berrya0769f72012-05-02 17:25:58 -0400379 unit_tests
Vignesh Venkatasubramanian0ffa3832014-03-14 08:10:35 -0700380 webm_io
Deb Mukherjee47031c02014-05-16 18:52:01 -0700381 libyuv
Joshua Litta782d632013-11-15 12:29:26 -0800382 decode_perf_tests
Yunqing Wangaa7335e2011-10-25 15:14:16 -0400383 multi_res_encoding
Stefan Holmer9c411432012-03-06 10:48:18 +0100384 temporal_denoising
Jim Bankoskia5d11f22012-05-11 08:08:12 -0700385 experimental
John Koleszar0ea50ce2010-05-18 11:58:33 -0400386"
387
388process_cmdline() {
389 for opt do
390 optval="${opt#*=}"
391 case "$opt" in
James Zern42ab4012013-08-21 18:11:45 -0700392 --disable-codecs) for c in ${CODECS}; do disable_feature $c; done ;;
John Koleszar0952acb2010-06-01 11:14:25 -0400393 --enable-?*|--disable-?*)
394 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
395 if echo "${EXPERIMENT_LIST}" | grep "^ *$option\$" >/dev/null; then
396 if enabled experimental; then
James Zernccb6bdc2013-08-21 19:00:08 -0700397 ${action}_feature $option
John Koleszar0952acb2010-06-01 11:14:25 -0400398 else
399 log_echo "Ignoring $opt -- not in experimental mode."
400 fi
401 else
Yaowu Xu7793b382011-06-22 15:07:04 -0700402 process_common_cmdline $opt
John Koleszar0952acb2010-06-01 11:14:25 -0400403 fi
404 ;;
James Berrya0769f72012-05-02 17:25:58 -0400405 *) process_common_cmdline "$opt"
Yaowu Xu7793b382011-06-22 15:07:04 -0700406 ;;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400407 esac
408 done
409}
410
411post_process_cmdline() {
412 local c
413
414 # If the codec family is disabled, disable all components of that family.
415 # If the codec family is enabled, enable all components of that family.
416 log_echo "Configuring selected codecs"
417 for c in ${CODECS}; do
James Zern42ab4012013-08-21 18:11:45 -0700418 disabled ${c%%_*} && disable_feature ${c}
419 enabled ${c%%_*} && enable_feature ${c}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400420 done
421
422 # Enable all detected codecs, if they haven't been disabled
423 for c in ${CODECS}; do soft_enable $c; done
424
425 # Enable the codec family if any component of that family is enabled
426 for c in ${CODECS}; do
James Zern42ab4012013-08-21 18:11:45 -0700427 enabled $c && enable_feature ${c%_*}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400428 done
429
430 # Set the {en,de}coders variable if any algorithm in that class is enabled
431 for c in ${CODECS}; do
James Zern42ab4012013-08-21 18:11:45 -0700432 enabled ${c} && enable_feature ${c##*_}s
John Koleszar0ea50ce2010-05-18 11:58:33 -0400433 done
John Koleszar0ea50ce2010-05-18 11:58:33 -0400434}
435
436
437process_targets() {
438 enabled child || write_common_config_banner
439 enabled universal || write_common_target_config_h ${BUILD_PFX}vpx_config.h
440
441 # TODO: add host tools target (obj_int_extract, etc)
442
443 # For fat binaries, call configure recursively to configure for each
444 # binary architecture to be included.
445 if enabled universal; then
446 # Call configure (ourselves) for each subarchitecture
447 for arch in $fat_bin_archs; do
448 BUILD_PFX=${arch}/ toolchain=${arch} $self --child $cmdline_args || exit $?
449 done
450 fi
451
452 # The write_common_config (config.mk) logic is deferred until after the
Erik Niemeyere6863ef2013-10-29 09:48:12 -0600453 # recursive calls to configure complete, because we want our universal
John Koleszar0ea50ce2010-05-18 11:58:33 -0400454 # targets to be executed last.
455 write_common_config_targets
456 enabled universal && echo "FAT_ARCHS=${fat_bin_archs}" >> config.mk
457
458 # Calculate the default distribution name, based on the enabled features
459 local cf
460 local DIST_DIR=vpx
461 for cf in $CODEC_FAMILIES; do
462 if enabled ${cf}_encoder && enabled ${cf}_decoder; then
463 DIST_DIR="${DIST_DIR}-${cf}"
464 elif enabled ${cf}_encoder; then
465 DIST_DIR="${DIST_DIR}-${cf}cx"
466 elif enabled ${cf}_decoder; then
467 DIST_DIR="${DIST_DIR}-${cf}dx"
468 fi
469 done
470 enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
471 enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
Jim Bankoski79401542013-09-04 10:02:08 -0700472 ! enabled postproc && ! enabled vp9_postproc && DIST_DIR="${DIST_DIR}-nopost"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400473 ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400474 ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
475 DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
476 case "${tgt_os}" in
477 win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
478 DIST_DIR="${DIST_DIR}-${tgt_cc}"
479 ;;
480 esac
481 if [ -f "${source_path}/build/make/version.sh" ]; then
James Zern95735c32014-04-23 14:51:45 -0700482 local ver=`"$source_path/build/make/version.sh" --bare "$source_path"`
John Koleszar0ea50ce2010-05-18 11:58:33 -0400483 DIST_DIR="${DIST_DIR}-${ver}"
Ralph Giles53e99872011-03-28 11:36:53 -0700484 VERSION_STRING=${ver}
John Koleszar7aa97a32010-06-03 10:29:04 -0400485 ver=${ver%%-*}
486 VERSION_PATCH=${ver##*.}
487 ver=${ver%.*}
488 VERSION_MINOR=${ver##*.}
489 ver=${ver#v}
490 VERSION_MAJOR=${ver%.*}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400491 fi
John Koleszaree8bcb12010-05-24 10:16:44 -0400492 enabled child || cat <<EOF >> config.mk
Ralph Giles607f8422011-03-28 12:04:51 -0700493
494PREFIX=${prefix}
John Koleszaree8bcb12010-05-24 10:16:44 -0400495ifeq (\$(MAKECMDGOALS),dist)
John Koleszar670af3a2010-05-26 15:57:42 -0400496DIST_DIR?=${DIST_DIR}
John Koleszaree8bcb12010-05-24 10:16:44 -0400497else
John Koleszar670af3a2010-05-26 15:57:42 -0400498DIST_DIR?=\$(DESTDIR)${prefix}
John Koleszaree8bcb12010-05-24 10:16:44 -0400499endif
John Koleszar670af3a2010-05-26 15:57:42 -0400500LIBSUBDIR=${libdir##${prefix}/}
John Koleszar7aa97a32010-06-03 10:29:04 -0400501
Ralph Giles53e99872011-03-28 11:36:53 -0700502VERSION_STRING=${VERSION_STRING}
503
John Koleszar7aa97a32010-06-03 10:29:04 -0400504VERSION_MAJOR=${VERSION_MAJOR}
505VERSION_MINOR=${VERSION_MINOR}
506VERSION_PATCH=${VERSION_PATCH}
507
John Koleszar23d68a52010-06-22 09:53:23 -0400508CONFIGURE_ARGS=${CONFIGURE_ARGS}
John Koleszaree8bcb12010-05-24 10:16:44 -0400509EOF
John Koleszar0ea50ce2010-05-18 11:58:33 -0400510 enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
511
512 #
513 # Write makefiles for all enabled targets
514 #
515 for tgt in libs examples docs solution; do
516 local tgt_fn="$tgt-$toolchain.mk"
517
518 if enabled $tgt; then
519 echo "Creating makefiles for ${toolchain} ${tgt}"
520 write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
521 #write_${tgt}_config
522 fi
523 done
524
525}
526
527process_detect() {
John Koleszar7aa97a32010-06-03 10:29:04 -0400528 if enabled shared; then
529 # Can only build shared libs on a subset of platforms. Doing this check
530 # here rather than at option parse time because the target auto-detect
531 # magic happens after the command line has been parsed.
Mike Frysingerb4ab43f2012-08-14 14:24:28 -0400532 if ! enabled linux; then
533 if enabled gnu; then
534 echo "--enable-shared is only supported on ELF; assuming this is OK"
535 else
536 die "--enable-shared only supported on ELF for now"
537 fi
538 fi
John Koleszar7aa97a32010-06-03 10:29:04 -0400539 fi
John Koleszard9847632012-12-10 12:07:59 -0800540 if [ -z "$CC" ] || enabled external_build; then
John Koleszar0ea50ce2010-05-18 11:58:33 -0400541 echo "Bypassing toolchain for environment detection."
James Zern42ab4012013-08-21 18:11:45 -0700542 enable_feature external_build
John Koleszar0ea50ce2010-05-18 11:58:33 -0400543 check_header() {
544 log fake_check_header "$@"
545 header=$1
546 shift
547 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
James Zern42ab4012013-08-21 18:11:45 -0700548 disable_feature $var
John Koleszard9847632012-12-10 12:07:59 -0800549 # Headers common to all environments
John Koleszar0ea50ce2010-05-18 11:58:33 -0400550 case $header in
551 stdio.h)
552 true;
553 ;;
554 *)
555 local result=false
556 for d in "$@"; do
557 [ -f "${d##-I}/$header" ] && result=true && break
558 done
559 ${result:-true}
James Zern42ab4012013-08-21 18:11:45 -0700560 esac && enable_feature $var
John Koleszard9847632012-12-10 12:07:59 -0800561
562 # Specialize windows and POSIX environments.
563 case $toolchain in
564 *-win*-*)
565 case $header-$toolchain in
566 stdint*-gcc) true;;
567 *) false;;
James Zern42ab4012013-08-21 18:11:45 -0700568 esac && enable_feature $var
John Koleszard9847632012-12-10 12:07:59 -0800569 ;;
570 *)
571 case $header in
572 stdint.h) true;;
573 pthread.h) true;;
574 sys/mman.h) true;;
575 unistd.h) true;;
576 *) false;;
James Zern42ab4012013-08-21 18:11:45 -0700577 esac && enable_feature $var
John Koleszard9847632012-12-10 12:07:59 -0800578 esac
579 enabled $var
John Koleszar0ea50ce2010-05-18 11:58:33 -0400580 }
581 check_ld() {
582 true
583 }
584 fi
585 check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
586 check_ld <<EOF || die "Toolchain is unable to link executables"
587int main(void) {return 0;}
588EOF
589 # check system headers
590 check_header stdint.h
591 check_header pthread.h
592 check_header sys/mman.h
John Koleszard9847632012-12-10 12:07:59 -0800593 check_header unistd.h # for sysconf(3) and friends.
John Koleszar0ea50ce2010-05-18 11:58:33 -0400594
James Zern42ab4012013-08-21 18:11:45 -0700595 check_header vpx/vpx_integer.h -I${source_path} && enable_feature vpx_ports
John Koleszar0ea50ce2010-05-18 11:58:33 -0400596}
597
598process_toolchain() {
599 process_common_toolchain
600
601 # Handle universal binaries for this architecture
602 case $toolchain in
603 universal-darwin*)
604 local darwin_ver=${tgt_os##darwin}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400605
Johann101c2bd2012-04-27 11:40:04 -0700606 # Snow Leopard (10.6/darwin10) dropped support for PPC
607 # Include PPC support for all prior versions
608 if [ $darwin_ver -lt 10 ]; then
609 fat_bin_archs="$fat_bin_archs ppc32-${tgt_os}-gcc"
610 fi
611
612 # Tiger (10.4/darwin8) brought support for x86
613 if [ $darwin_ver -ge 8 ]; then
614 fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}"
615 fi
616
617 # Leopard (10.5/darwin9) brought 64 bit support
618 if [ $darwin_ver -ge 9 ]; then
John Koleszar0ea50ce2010-05-18 11:58:33 -0400619 fat_bin_archs="$fat_bin_archs x86_64-${tgt_os}-${tgt_cc}"
620 fi
621 ;;
622 esac
623
624
625 # Enable some useful compiler flags
626 if enabled gcc; then
627 enabled werror && check_add_cflags -Werror
628 check_add_cflags -Wall
629 check_add_cflags -Wdeclaration-after-statement
630 check_add_cflags -Wdisabled-optimization
631 check_add_cflags -Wpointer-arith
632 check_add_cflags -Wtype-limits
633 check_add_cflags -Wcast-qual
Daniel Kang2f963912012-08-13 14:18:09 -0700634 check_add_cflags -Wvla
Attila Nagy14c9fce2012-04-27 13:41:58 +0300635 check_add_cflags -Wimplicit-function-declaration
636 check_add_cflags -Wuninitialized
637 check_add_cflags -Wunused-variable
James Zerndfa2fb52013-05-03 14:00:33 -0700638 case ${CC} in
Johann8b47e1c2013-10-28 15:44:41 -0700639 *clang*)
640 # libvpx and/or clang have issues with aliasing:
641 # https://code.google.com/p/webm/issues/detail?id=603
642 # work around them until they are fixed
643 check_add_cflags -fno-strict-aliasing
644 ;;
James Zerndfa2fb52013-05-03 14:00:33 -0700645 *) check_add_cflags -Wunused-but-set-variable ;;
646 esac
John Koleszarb601eb82011-02-04 11:51:21 -0500647 enabled extra_warnings || check_add_cflags -Wno-unused-function
John Koleszar0ea50ce2010-05-18 11:58:33 -0400648 fi
649
650 if enabled icc; then
651 enabled werror && check_add_cflags -Werror
652 check_add_cflags -Wall
653 check_add_cflags -Wpointer-arith
654
655 # ICC has a number of floating point optimizations that we disable
656 # in favor of deterministic output WRT to other compilers
657 add_cflags -fp-model precise
658 fi
659
660 # Enable extra, harmless warnings. These might provide additional insight
661 # to what the compiler is doing and why, but in general, but they shouldn't
662 # be treated as fatal, even if we're treating warnings as errors.
663 GCC_EXTRA_WARNINGS="
664 -Wdisabled-optimization
665 -Winline
666 "
667 enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
668 RVCT_EXTRA_WARNINGS="
669 --remarks
670 "
671 enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
672 if enabled extra_warnings; then
673 for w in ${EXTRA_WARNINGS}; do
674 check_add_cflags ${w}
675 enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
676 done
677 fi
678
679 # ccache only really works on gcc toolchains
680 enabled gcc || soft_disable ccache
681 if enabled mips; then
James Zern42ab4012013-08-21 18:11:45 -0700682 enable_feature dequant_tokens
683 enable_feature dc_recon
John Koleszar0ea50ce2010-05-18 11:58:33 -0400684 fi
685
Yaowu Xu132ef422013-09-06 15:05:05 -0700686 if enabled internal_stats; then
687 enable_feature vp9_postproc
688 fi
689
John Koleszar0ea50ce2010-05-18 11:58:33 -0400690 # Enable the postbuild target if building for visual studio.
691 case "$tgt_cc" in
James Zern42ab4012013-08-21 18:11:45 -0700692 vs*) enable_feature msvs
693 enable_feature solution
John Koleszar0ea50ce2010-05-18 11:58:33 -0400694 vs_version=${tgt_cc##vs}
Martin Storsjobd91beb2013-05-17 00:57:57 +0300695 case $vs_version in
696 [789])
697 VCPROJ_SFX=vcproj
698 gen_vcproj_cmd=${source_path}/build/make/gen_msvs_proj.sh
699 ;;
Yaowu Xua638bdf2013-11-13 11:36:32 -0800700 10|11|12)
Martin Storsjobd91beb2013-05-17 00:57:57 +0300701 VCPROJ_SFX=vcxproj
702 gen_vcproj_cmd=${source_path}/build/make/gen_msvs_vcxproj.sh
James Zern37c60d82014-03-08 12:52:33 -0800703 enabled werror && gen_vcproj_cmd="${gen_vcproj_cmd} --enable-werror"
Martin Storsjobd91beb2013-05-17 00:57:57 +0300704 ;;
705 esac
John Koleszar0ea50ce2010-05-18 11:58:33 -0400706 all_targets="${all_targets} solution"
Ronald S. Bultjeaac73df2013-02-06 12:45:28 -0800707 INLINE="__forceinline"
John Koleszar0ea50ce2010-05-18 11:58:33 -0400708 ;;
709 esac
710
711 # Other toolchain specific defaults
712 case $toolchain in x86*|ppc*|universal*) soft_enable postproc;; esac
Fritz Koenig647df002010-11-04 16:03:36 -0700713
Fritz Koenig692b1082010-11-10 14:51:49 -0800714 if enabled postproc_visualizer; then
715 enabled postproc || die "postproc_visualizer requires postproc to be enabled"
716 fi
John Koleszar2bf62c12012-05-22 11:51:14 -0700717
Johannb46d58a2013-01-18 11:31:22 -0800718 # Enable unit tests by default if we have a working C++ compiler.
Johannd6e80de2012-06-12 08:58:11 -0700719 case "$toolchain" in
720 *-vs*)
721 soft_enable unit_tests
Vignesh Venkatasubramanian2dcbf8c2014-03-19 11:56:02 -0700722 soft_enable webm_io
Deb Mukherjee47031c02014-05-16 18:52:01 -0700723 soft_enable libyuv
Johannd6e80de2012-06-12 08:58:11 -0700724 ;;
725 *-android-*)
Vignesh Venkatasubramanian4721f9e2014-04-29 00:03:01 -0700726 soft_enable webm_io
Deb Mukherjee47031c02014-05-16 18:52:01 -0700727 soft_enable libyuv
Johannd6e80de2012-06-12 08:58:11 -0700728 # GTestLog must be modified to use Android logging utilities.
729 ;;
Johanna1d929e2012-12-13 11:35:59 -0800730 *-darwin-*)
731 # iOS/ARM builds do not work with gtest. This does not match
732 # x86 targets.
733 ;;
Tom Finegan4e6c5552014-06-04 18:57:25 -0700734 *-iphonesimulator-*)
735 soft_enable webm_io
736 soft_enable libyuv
737 ;;
James Zerne4d2c252013-06-26 18:35:11 -0700738 *-win*)
739 # Some mingw toolchains don't have pthread available by default.
740 # Treat these more like visual studio where threading in gtest
741 # would be disabled for the same reason.
742 check_cxx "$@" <<EOF && soft_enable unit_tests
743int z;
744EOF
Vignesh Venkatasubramanian2dcbf8c2014-03-19 11:56:02 -0700745 check_cxx "$@" <<EOF && soft_enable webm_io
746int z;
747EOF
Deb Mukherjee47031c02014-05-16 18:52:01 -0700748 check_cxx "$@" <<EOF && soft_enable libyuv
749int z;
750EOF
James Zerne4d2c252013-06-26 18:35:11 -0700751 ;;
John Koleszar2bf62c12012-05-22 11:51:14 -0700752 *)
James Zernf2dc3822013-06-20 12:49:15 -0700753 enabled pthread_h && check_cxx "$@" <<EOF && soft_enable unit_tests
John Koleszar2bf62c12012-05-22 11:51:14 -0700754int z;
755EOF
Vignesh Venkatasubramanian2dcbf8c2014-03-19 11:56:02 -0700756 check_cxx "$@" <<EOF && soft_enable webm_io
757int z;
758EOF
Deb Mukherjee47031c02014-05-16 18:52:01 -0700759 check_cxx "$@" <<EOF && soft_enable libyuv
760int z;
761EOF
Johannd6e80de2012-06-12 08:58:11 -0700762 ;;
John Koleszar2bf62c12012-05-22 11:51:14 -0700763 esac
Vignesh Venkatasubramanian2dcbf8c2014-03-19 11:56:02 -0700764 # libwebm needs to be linked with C++ standard library
765 enabled webm_io && LD=${CXX}
John Koleszar0ea50ce2010-05-18 11:58:33 -0400766}
767
768
769##
770## END APPLICATION SPECIFIC CONFIGURATION
771##
772CONFIGURE_ARGS="$@"
773process "$@"
Tom Finegan3d9c3f42011-10-19 22:47:02 -0400774print_webm_license ${BUILD_PFX}vpx_config.c "/*" " */"
775cat <<EOF >> ${BUILD_PFX}vpx_config.c
John Koleszar0ea50ce2010-05-18 11:58:33 -0400776static const char* const cfg = "$CONFIGURE_ARGS";
777const char *vpx_codec_build_config(void) {return cfg;}
778EOF