5 ## 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.
12 ## This build system is based in part on the FFmpeg configure script.
15 #source_path="`dirname \"$0\"`"
17 . "${source_path}/build/make/configure.sh"
23 ${toggle_libs} don't build libraries
24 ${toggle_examples} don't build examples
25 --libc=PATH path to alternate libc
26 ${toggle_fast_unaligned} don't use unaligned accesses, even when
27 supported by hardware [auto]
28 ${toggle_codec_srcs} in/exclude codec library source code
29 ${toggle_debug_libs} in/exclude debug version of libraries
30 ${toggle_md5} support for output of checksum data
31 ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
32 ${toggle_vp8} VP8 codec support
33 ${toggle_psnr} output of PSNR data, if supported (encoders)
34 ${toggle_mem_tracker} track memory usage
35 ${toggle_postproc} postprocessing
36 ${toggle_multithread} multithreaded encoding and decoding.
37 ${toggle_spatial_resampling} spatial sampling (scaling) support
38 ${toggle_realtime_only} enable this option while building for real-time encoding
39 ${toggle_runtime_cpu_detect} runtime cpu detection
40 ${toggle_shared} shared library support
41 ${toggle_arm_asm_detok} assembly version of the detokenizer (ARM platforms only)
44 Codecs can be selectively enabled or disabled individually, or by family:
47 --disable-<codec>-encoder
48 --disable-<codec>-decoder
50 Codecs available in this distribution:
52 #restore editor state '
58 for c in ${CODECS}; do
60 if [ "${family}" != "${last_family}" ]; then
61 [ -z "${str}" ] || echo "${str}"
62 str="$(printf ' %10s:' ${family})"
64 str="${str} $(printf '%10s' ${c#*_})"
72 ## BEGIN APPLICATION SPECIFIC CONFIGURATION
75 # all_platforms is a list of all supported target platforms. Maintain
76 # alphabetically by architecture, generic-gnu last.
77 all_platforms="${all_platforms} armv5te-linux-rvct"
78 all_platforms="${all_platforms} armv5te-linux-gcc"
79 all_platforms="${all_platforms} armv5te-symbian-gcc"
80 all_platforms="${all_platforms} armv5te-wince-vs8"
81 all_platforms="${all_platforms} armv6-darwin-gcc"
82 all_platforms="${all_platforms} armv6-linux-rvct"
83 all_platforms="${all_platforms} armv6-linux-gcc"
84 all_platforms="${all_platforms} armv6-symbian-gcc"
85 all_platforms="${all_platforms} armv6-wince-vs8"
86 all_platforms="${all_platforms} iwmmxt-linux-rvct"
87 all_platforms="${all_platforms} iwmmxt-linux-gcc"
88 all_platforms="${all_platforms} iwmmxt-wince-vs8"
89 all_platforms="${all_platforms} iwmmxt2-linux-rvct"
90 all_platforms="${all_platforms} iwmmxt2-linux-gcc"
91 all_platforms="${all_platforms} iwmmxt2-wince-vs8"
92 all_platforms="${all_platforms} armv7-darwin-gcc" #neon Cortex-A8
93 all_platforms="${all_platforms} armv7-linux-rvct" #neon Cortex-A8
94 all_platforms="${all_platforms} armv7-linux-gcc" #neon Cortex-A8
95 all_platforms="${all_platforms} mips32-linux-gcc"
96 all_platforms="${all_platforms} ppc32-darwin8-gcc"
97 all_platforms="${all_platforms} ppc32-darwin9-gcc"
98 all_platforms="${all_platforms} ppc64-darwin8-gcc"
99 all_platforms="${all_platforms} ppc64-darwin9-gcc"
100 all_platforms="${all_platforms} ppc64-linux-gcc"
101 all_platforms="${all_platforms} x86-darwin8-gcc"
102 all_platforms="${all_platforms} x86-darwin8-icc"
103 all_platforms="${all_platforms} x86-darwin9-gcc"
104 all_platforms="${all_platforms} x86-darwin9-icc"
105 all_platforms="${all_platforms} x86-linux-gcc"
106 all_platforms="${all_platforms} x86-linux-icc"
107 all_platforms="${all_platforms} x86-solaris-gcc"
108 all_platforms="${all_platforms} x86-win32-gcc"
109 all_platforms="${all_platforms} x86-win32-vs7"
110 all_platforms="${all_platforms} x86-win32-vs8"
111 all_platforms="${all_platforms} x86-win32-vs9"
112 all_platforms="${all_platforms} x86_64-darwin9-gcc"
113 all_platforms="${all_platforms} x86_64-linux-gcc"
114 all_platforms="${all_platforms} x86_64-linux-icc"
115 all_platforms="${all_platforms} x86_64-solaris-gcc"
116 all_platforms="${all_platforms} x86_64-win64-vs8"
117 all_platforms="${all_platforms} x86_64-win64-vs9"
118 all_platforms="${all_platforms} universal-darwin8-gcc"
119 all_platforms="${all_platforms} universal-darwin9-gcc"
120 all_platforms="${all_platforms} generic-gnu"
122 # all_targets is a list of all targets that can be configured
123 # note that these should be in dependency order for now.
124 all_targets="libs examples docs"
126 # all targets available are enabled, by default.
127 for t in ${all_targets}; do
128 [ -f ${source_path}/${t}.mk ] && enable ${t}
131 # check installed doxygen version
132 doxy_version=$(doxygen --version 2>/dev/null)
133 doxy_major=${doxy_version%%.*}
134 if [ ${doxy_major:-0} -ge 1 ]; then
135 doxy_version=${doxy_version#*.}
136 doxy_minor=${doxy_version%%.*}
137 doxy_patch=${doxy_version##*.}
139 [ $doxy_major -gt 1 ] && enable doxygen
140 [ $doxy_minor -gt 5 ] && enable doxygen
141 [ $doxy_minor -eq 5 ] && [ $doxy_patch -ge 3 ] && enable doxygen
144 # install everything except the sources, by default. sources will have
145 # to be enabled when doing dist builds, since that's no longer a common
147 enabled doxygen && php -v >/dev/null 2>&1 && enable install_docs
152 enable fast_unaligned #allow unaligned accesses, if supported by hw
154 enable spatial_resampling
157 [ -d ${source_path}/../include ] && enable alt_tree_layout
159 [ -d ${source_path}/${d} ] && disable alt_tree_layout;
162 if ! enabled alt_tree_layout; then
163 # development environment
164 [ -d ${source_path}/vp8 ] && CODECS="${CODECS} vp8_encoder vp8_decoder"
166 # customer environment
167 [ -f ${source_path}/../include/vpx/vp8cx.h ] && CODECS="${CODECS} vp8_encoder"
168 [ -f ${source_path}/../include/vpx/vp8dx.h ] && CODECS="${CODECS} vp8_decoder"
170 [ -f ${source_path}/../lib/*/*mt.lib ] && soft_enable static_msvcrt
173 CODECS="$(echo ${CODECS} | tr ' ' '\n')"
174 CODEC_FAMILIES="$(for c in ${CODECS}; do echo ${c%_*}; done | sort | uniq)"
290 --disable-codecs) for c in ${CODECS}; do disable $c; done ;;
291 *) process_common_cmdline $opt
297 post_process_cmdline() {
300 # If the codec family is disabled, disable all components of that family.
301 # If the codec family is enabled, enable all components of that family.
302 log_echo "Configuring selected codecs"
303 for c in ${CODECS}; do
304 disabled ${c%%_*} && disable ${c}
305 enabled ${c%%_*} && enable ${c}
308 # Enable all detected codecs, if they haven't been disabled
309 for c in ${CODECS}; do soft_enable $c; done
311 # Enable the codec family if any component of that family is enabled
312 for c in ${CODECS}; do
313 enabled $c && enable ${c%_*}
316 # Set the {en,de}coders variable if any algorithm in that class is enabled
317 for c in ${CODECS}; do
318 enabled ${c} && enable ${c##*_}s
326 enabled child || write_common_config_banner
327 enabled universal || write_common_target_config_h ${BUILD_PFX}vpx_config.h
329 # TODO: add host tools target (obj_int_extract, etc)
331 # For fat binaries, call configure recursively to configure for each
332 # binary architecture to be included.
333 if enabled universal; then
334 # Call configure (ourselves) for each subarchitecture
335 for arch in $fat_bin_archs; do
336 BUILD_PFX=${arch}/ toolchain=${arch} $self --child $cmdline_args || exit $?
340 # The write_common_config (config.mk) logic is deferred until after the
341 # recursive calls to configure complete, becuase we want our universal
342 # targets to be executed last.
343 write_common_config_targets
344 enabled universal && echo "FAT_ARCHS=${fat_bin_archs}" >> config.mk
346 # Calculate the default distribution name, based on the enabled features
349 for cf in $CODEC_FAMILIES; do
350 if enabled ${cf}_encoder && enabled ${cf}_decoder; then
351 DIST_DIR="${DIST_DIR}-${cf}"
352 elif enabled ${cf}_encoder; then
353 DIST_DIR="${DIST_DIR}-${cf}cx"
354 elif enabled ${cf}_decoder; then
355 DIST_DIR="${DIST_DIR}-${cf}dx"
358 enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
359 enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
360 ! enabled postproc && DIST_DIR="${DIST_DIR}-nopost"
361 ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
362 ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
363 DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
365 win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
366 DIST_DIR="${DIST_DIR}-${tgt_cc}"
369 if [ -f "${source_path}/build/make/version.sh" ]; then
370 local ver=`"$source_path/build/make/version.sh" --bare $source_path`
371 DIST_DIR="${DIST_DIR}-${ver}"
373 VERSION_PATCH=${ver##*.}
375 VERSION_MINOR=${ver##*.}
377 VERSION_MAJOR=${ver%.*}
379 enabled child || cat <<EOF >> config.mk
380 ifeq (\$(MAKECMDGOALS),dist)
381 DIST_DIR?=${DIST_DIR}
383 DIST_DIR?=\$(DESTDIR)${prefix}
385 LIBSUBDIR=${libdir##${prefix}/}
387 VERSION_MAJOR=${VERSION_MAJOR}
388 VERSION_MINOR=${VERSION_MINOR}
389 VERSION_PATCH=${VERSION_PATCH}
391 CONFIGURE_ARGS=${CONFIGURE_ARGS}
393 enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
396 # Write makefiles for all enabled targets
398 for tgt in libs examples docs solution; do
399 local tgt_fn="$tgt-$toolchain.mk"
401 if enabled $tgt; then
402 echo "Creating makefiles for ${toolchain} ${tgt}"
403 write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
411 if enabled shared; then
412 # Can only build shared libs on a subset of platforms. Doing this check
413 # here rather than at option parse time because the target auto-detect
414 # magic happens after the command line has been parsed.
415 enabled linux || die "--enable-shared only supported on ELF for now"
417 if [ -z "$CC" ]; then
418 echo "Bypassing toolchain for environment detection."
419 enable external_build
421 log fake_check_header "$@"
424 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
433 [ -f "${d##-I}/$header" ] && result=true && break
442 check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
443 check_ld <<EOF || die "Toolchain is unable to link executables"
444 int main(void) {return 0;}
446 # check system headers
447 check_header stdint.h
448 check_header pthread.h
449 check_header sys/mman.h
451 check_header vpx/vpx_integer.h -I${source_path} && enable vpx_ports
454 process_toolchain() {
455 process_common_toolchain
457 # Handle universal binaries for this architecture
460 local darwin_ver=${tgt_os##darwin}
461 fat_bin_archs="$fat_bin_archs ppc32-${tgt_os}-gcc"
464 fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}"
465 if [ $darwin_ver -gt 8 ]; then
466 fat_bin_archs="$fat_bin_archs x86_64-${tgt_os}-${tgt_cc}"
472 # Enable some useful compiler flags
474 enabled werror && check_add_cflags -Werror
475 check_add_cflags -Wall
476 check_add_cflags -Wdeclaration-after-statement
477 check_add_cflags -Wdisabled-optimization
478 check_add_cflags -Wpointer-arith
479 check_add_cflags -Wtype-limits
480 check_add_cflags -Wcast-qual
481 enabled extra_warnings || check_add_cflags -Wno-unused
485 enabled werror && check_add_cflags -Werror
486 check_add_cflags -Wall
487 check_add_cflags -Wpointer-arith
489 # ICC has a number of floating point optimizations that we disable
490 # in favor of deterministic output WRT to other compilers
491 add_cflags -fp-model precise
494 # Enable extra, harmless warnings. These might provide additional insight
495 # to what the compiler is doing and why, but in general, but they shouldn't
496 # be treated as fatal, even if we're treating warnings as errors.
498 -Wdisabled-optimization
501 enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
502 RVCT_EXTRA_WARNINGS="
505 enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
506 if enabled extra_warnings; then
507 for w in ${EXTRA_WARNINGS}; do
508 check_add_cflags ${w}
509 enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
513 # ccache only really works on gcc toolchains
514 enabled gcc || soft_disable ccache
515 if enabled mips; then
516 enable dequant_tokens
520 # Enable the postbuild target if building for visual studio.
524 vs_version=${tgt_cc##vs}
525 all_targets="${all_targets} solution"
529 # Other toolchain specific defaults
530 case $toolchain in x86*|ppc*|universal*) soft_enable postproc;; esac
535 ## END APPLICATION SPECIFIC CONFIGURATION
539 cat <<EOF > ${BUILD_PFX}vpx_config.c
540 static const char* const cfg = "$CONFIGURE_ARGS";
541 const char *vpx_codec_build_config(void) {return cfg;}