5 ## This script is sourced by the main configure script and contains
6 ## utility functions and other common bits that aren't strictly libvpx
9 ## This build system is based in part on the FFmpeg configure script.
14 # Logging / Output Functions
17 echo "Unknown option \"$1\"."
18 echo "See $0 --help for available options."
27 echo "Configuration failed. This could reflect a misconfiguration of your"
28 echo "toolchains, improper options selected, or another problem. If you"
29 echo "don't see any useful error messages above, the next step is to look"
30 echo "at the configure error log file ($logfile) to determine what"
31 echo "configure was trying to do when it died."
44 pr -n -t $1 >>$logfile
58 echo "$@" >> ${outfile}
63 for opt
in ${CMDLINE_SELECT}; do
64 opt2
=`echo $opt | sed -e 's;_;-;g'`
66 eval "toggle_${opt}=\"--disable-${opt2}\""
68 eval "toggle_${opt}=\"--enable-${opt2} \""
73 Usage: configure [options]
77 --help print this message
78 --log=yes|no|FILE file configure log is written to [config.err]
79 --target=TARGET target platform tuple [generic-gnu]
80 --cpu=CPU optimize for a specific cpu rather than a family
81 ${toggle_extra_warnings} emit harmless warnings (always non-fatal)
82 ${toggle_werror} treat warnings as errors, if possible
83 (not available with all compilers)
84 ${toggle_optimizations} turn on/off compiler optimization flags
85 ${toggle_pic} turn on/off Position Independant Code
86 ${toggle_ccache} turn on/off compiler cache
87 ${toggle_debug} enable/disable debug mode
88 ${toggle_gprof} enable/disable gprof profiling instrumentation
89 ${toggle_gcov} enable/disable gcov coverage instrumentation
92 ${toggle_install_docs} control whether docs are installed
93 ${toggle_install_bins} control whether binaries are installed
94 ${toggle_install_libs} control whether libraries are installed
95 ${toggle_install_srcs} control whether sources are installed
107 Object files are built at the place where configure is launched.
109 All boolean options can be negated. The default value is the opposite
110 of that shown above. If the option --disable-foo is listed, then
111 the default value for foo is enabled.
115 show_targets
${all_platforms}
122 while [ -n "$*" ]; do
123 if [ "${1%%-*}" = "${2%%-*}" ]; then
124 if [ "${2%%-*}" = "${3%%-*}" ]; then
125 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
128 printf " %-24s %-24s\n" "$1" "$2"
132 printf " %-24s\n" "$1"
145 # List Processing Functions
160 [ $var = $value ] && return 0
167 CFLAGS
="${CFLAGS} $@"
172 LDFLAGS
="${LDFLAGS} $@"
177 ASFLAGS
="${ASFLAGS} $@"
182 extralibs
="${extralibs} $@"
186 # Boolean Manipulation Functions
197 eval test "x\$$1" = "xyes"
201 eval test "x\$$1" = "xno"
207 if ! disabled
$var; then
208 log_echo
" enabling $var"
216 if ! enabled
$var; then
217 log_echo
" disabling $var"
225 # Text Processing Functions
228 echo "$@" |
tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
233 echo "$@" |
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
238 # Temporary File Functions
241 enable source_path_used
242 if test -z "$source_path" -o "$source_path" = "." ; then
244 disable source_path_used
247 if test ! -z "$TMPDIR" ; then
249 elif test ! -z "$TEMPDIR" ; then
254 TMP_H
="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h"
255 TMP_C
="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c"
256 TMP_O
="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o"
257 TMP_X
="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x"
260 rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X}
264 # Toolchain Check Functions
268 "$@" >>${logfile} 2>&1
275 check_cmd
${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
282 check_cmd
${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
288 && check_cmd
${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
292 log check_header
"$@"
295 var
=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
297 check_cpp
"$@" <<EOF && enable $var
305 log check_cflags
"$@"
312 check_cflags
"$@" && add_cflags
"$@"
315 check_add_asflags
() {
320 check_add_ldflags
() {
325 write_common_config_banner
() {
326 echo '# This file automatically generated by configure. Do not edit!' > config.mk
327 echo "TOOLCHAIN := ${toolchain}" >> config.mk
331 echo "ALT_LIBC := ${alt_libc}" >> config.mk
336 write_common_config_targets
() {
337 for t
in ${all_targets}; do
338 if enabled
${t}; then
339 if enabled universal || enabled child
; then
340 fwrite config.mk
"ALL_TARGETS += ${t}-${toolchain}"
342 fwrite config.mk
"ALL_TARGETS += ${t}"
350 write_common_target_config_mk
() {
352 enabled ccache
&& CC
="ccache ${CC}"
355 # This file automatically generated by configure. Do not edit!
356 SRC_PATH="$source_path"
357 SRC_PATH_BARE=$source_path
358 BUILD_PFX=${BUILD_PFX}
359 TOOLCHAIN=${toolchain}
360 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
370 ARFLAGS = -rus\$(if \$(quiet),c,v)
373 extralibs = ${extralibs}
374 AS_SFX = ${AS_SFX:-.asm}
377 if enabled rvct
; then cat >> $1 << EOF
378 fmt_deps = sed -e 's;^__image.axf;\$(dir \$@)\$(notdir \$<).o \$@;' #hide
380 else cat >> $1 << EOF
381 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\$(dir \$@)\1\$(suffix \$<).o \$@;'
385 print_config_mk ARCH
"${1}" ${ARCH_LIST}
386 print_config_mk HAVE
"${1}" ${HAVE_LIST}
387 print_config_mk CONFIG
"${1}" ${CONFIG_LIST}
388 print_config_mk HAVE
"${1}" gnu_strip
390 enabled msvs
&& echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
395 write_common_target_config_h
() {
396 cat > ${TMP_H} << EOF
397 /* This file automatically generated by configure. Do not edit! */
398 #define RESTRICT ${RESTRICT}
400 print_config_h ARCH
"${TMP_H}" ${ARCH_LIST}
401 print_config_h HAVE
"${TMP_H}" ${HAVE_LIST}
402 print_config_h CONFIG
"${TMP_H}" ${CONFIG_LIST}
403 mkdir
-p `dirname "$1"`
404 cmp "$1" ${TMP_H} >/dev
/null
2>&1 ||
mv ${TMP_H} "$1"
407 process_common_cmdline
() {
411 --child) enable child
415 if ! disabled logging
; then
416 enabled logging || logfile
="$logging"
421 --target=*) toolchain
="${toolchain:-${optval}}"
423 --force-target=*) toolchain
="${toolchain:-${optval}}"; enable force_toolchain
427 --cpu=*) tune_cpu
="$optval"
429 --enable-?
*|
--disable-?
*)
430 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
431 echo "${CMDLINE_SELECT} ${ARCH_EXT_LIST}" |
grep "^ *$option\$" >/dev
/null || die_unknown
$opt
434 --force-enable-?
*|
--force-disable-?
*)
435 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
439 [ -d "${optval}" ] || die
"Not a directory: ${optval}"
449 --libc|
--prefix|
--libdir)
450 die
"Option ${opt} requires argument"
464 *) process_common_cmdline
$opt
471 post_process_common_cmdline
() {
472 prefix
="${prefix:-/usr/local}"
474 libdir
="${libdir:-${prefix}/lib}"
476 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
477 die
"Libdir ${libdir} must be a subdirectory of ${prefix}"
482 post_process_cmdline
() {
486 setup_gnu_toolchain
() {
487 CC
=${CC:-${CROSS}gcc}
489 LD
=${LD:-${CROSS}${link_with_cc:-ld}}
491 STRIP
=${STRIP:-${CROSS}strip}
496 process_common_toolchain
() {
497 if [ -z "$toolchain" ]; then
498 gcctarget
="$(gcc -dumpmachine 2> /dev/null)"
528 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
529 toolchain
=${tgt_isa}-${tgt_os}-gcc
533 toolchain
=${toolchain:-generic-gnu}
535 is_in
${toolchain} ${all_platforms} || enabled force_toolchain \
536 || die
"Unrecognized toolchain '${toolchain}'"
538 enabled child || log_echo
"Configuring for target '${toolchain}'"
541 # Set up toolchain variables
543 tgt_isa
=$
(echo ${toolchain} |
awk 'BEGIN{FS="-"}{print $1}')
544 tgt_os
=$
(echo ${toolchain} |
awk 'BEGIN{FS="-"}{print $2}')
545 tgt_cc
=$
(echo ${toolchain} |
awk 'BEGIN{FS="-"}{print $3}')
547 # Mark the specific ISA requested as enabled
548 soft_enable
${tgt_isa}
552 # Enable the architecture family
554 arm
*|iwmmxt
*) enable arm
;;
558 # Handle darwin variants
561 add_cflags
"-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
562 add_cflags
"-mmacosx-version-min=10.4"
563 add_ldflags
"-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
564 add_ldflags
"-mmacosx-version-min=10.4"
567 add_cflags
"-isysroot /Developer/SDKs/MacOSX10.5.sdk"
568 add_cflags
"-mmacosx-version-min=10.5"
569 add_ldflags
"-isysroot /Developer/SDKs/MacOSX10.5.sdk"
570 add_ldflags
"-mmacosx-version-min=10.5"
574 # Process ARM architecture variants
577 # on arm, isa versions are supersets
578 enabled armv7a
&& soft_enable armv7
### DEBUG
579 enabled armv7
&& soft_enable armv6
580 enabled armv6
&& soft_enable armv5te
581 enabled armv6
&& soft_enable fast_unaligned
582 enabled iwmmxt2
&& soft_enable iwmmxt
583 enabled iwmmxt
&& soft_enable armv5te
585 asm_conversion_cmd
="cat"
589 if enabled iwmmxt || enabled iwmmxt2
591 CROSS
=${CROSS:-arm-iwmmxt-linux-gnueabi-}
592 elif enabled symbian
; then
593 CROSS
=${CROSS:-arm-none-symbianelf-}
595 CROSS
=${CROSS:-arm-none-linux-gnueabi-}
599 arch_int
=${tgt_isa##armv}
600 arch_int
=${arch_int%%te}
601 check_add_asflags
--defsym ARCHITECTURE
=${arch_int}
602 tune_cflags
="-mtune="
603 if enabled iwmmxt || enabled iwmmxt2
605 check_add_asflags
-mcpu=${tgt_isa}
608 check_add_cflags
-march=armv7-a
-mcpu=cortex-a8
-mfpu=neon
-mfloat-abi=softfp
#-ftree-vectorize
609 check_add_asflags
-mcpu=cortex-a8
-mfpu=neon
-mfloat-abi=softfp
#-march=armv7-a
611 check_add_cflags
-march=${tgt_isa}
612 check_add_asflags
-march=${tgt_isa}
615 asm_conversion_cmd
="${source_path}/build/make/ads2gas.pl"
621 LD
=${source_path}/build
/make
/armlink_adapter.sh
622 STRIP
=arm-none-linux-gnueabi-strip
623 NM
=arm-none-linux-gnueabi-nm
625 tune_asflags
="--cpu="
626 if [ -z "${tune_cpu}" ]; then
629 check_add_cflags
--cpu=Cortex-A8
--fpu=softvfp
+vfpv3
630 check_add_asflags
--cpu=Cortex-A8
--fpu=none
632 check_add_cflags
--cpu=${tgt_isa##armv}
633 check_add_asflags
--cpu=${tgt_isa##armv}
636 arch_int
=${tgt_isa##armv}
637 arch_int
=${arch_int%%te}
638 check_add_asflags
--pd "\"ARCHITECTURE SETA ${arch_int}\""
644 SDK_PATH
=/Developer
/Platforms
/iPhoneOS.platform
/Developer
645 TOOLCHAIN_PATH
=${SDK_PATH}/usr
/bin
646 CC
=${TOOLCHAIN_PATH}/gcc
647 AR
=${TOOLCHAIN_PATH}/ar
648 LD
=${TOOLCHAIN_PATH}/arm-apple-darwin9-gcc-4.2
.1
649 AS
=${TOOLCHAIN_PATH}/as
650 STRIP
=${TOOLCHAIN_PATH}/strip
651 NM
=${TOOLCHAIN_PATH}/nm
654 # ASFLAGS is written here instead of using check_add_asflags
655 # because we need to overwrite all of ASFLAGS and purge the
656 # options that were put in above
657 ASFLAGS
="-version -arch ${tgt_isa} -g"
659 add_cflags
-arch ${tgt_isa}
660 add_ldflags
-arch_only ${tgt_isa}
662 add_cflags
"-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk"
664 # This should be overridable
665 alt_libc
=${SDK_PATH}/SDKs
/iPhoneOS3.1.sdk
667 # Add the paths for the alternate libc
668 # for d in usr/include usr/include/gcc/darwin/4.0/; do
669 for d
in usr
/include usr
/include
/gcc
/darwin
/4.0/ usr
/lib
/gcc
/arm-apple-darwin
9/4.0.1/include
/; do
670 try_dir
="${alt_libc}/${d}"
671 [ -d "${try_dir}" ] && add_cflags
-I"${try_dir}"
674 for d
in lib usr
/lib
; do
675 try_dir
="${alt_libc}/${d}"
676 [ -d "${try_dir}" ] && add_ldflags
-L"${try_dir}"
679 asm_conversion_cmd
="${source_path}/build/make/ads2gas_apple.pl"
684 if enabled rvct
; then
685 # Compiling with RVCT requires an alternate libc (glibc) when
687 disabled builtin_libc \
688 || die
"Must supply --libc when targetting *-linux-rvct"
692 add_cflags
--enum_is_int
693 add_cflags
--library_interface=aeabi_glibc
694 add_cflags
--no_hide_all
700 add_ldflags
--sysv --no_startup --no_ref_cpp_init
701 add_ldflags
--entry=_start
702 add_ldflags
--keep '"*(.init)"' --keep '"*(.fini)"'
703 add_ldflags
--keep '"*(.init_array)"' --keep '"*(.fini_array)"'
704 add_ldflags
--dynamiclinker=/lib
/ld-linux.so
.3
705 add_extralibs libc.so
.6 -lc_nonshared crt1.o crti.o crtn.o
707 # Add the paths for the alternate libc
708 for d
in usr
/include
; do
709 try_dir
="${alt_libc}/${d}"
710 [ -d "${try_dir}" ] && add_cflags
-J"${try_dir}"
712 add_cflags
-J"${RVCT31INC}"
713 for d
in lib usr
/lib
; do
714 try_dir
="${alt_libc}/${d}"
715 [ -d "${try_dir}" ] && add_ldflags
-L"${try_dir}"
719 # glibc has some struct members named __align, which is a
720 # storage modifier in RVCT. If we need to use this modifier,
721 # we'll have to #undef it in our code. Note that this must
722 # happen AFTER all libc inclues.
723 add_cflags
-D__align=x_align_x
729 # Add the paths for the alternate libc
730 for d
in include
/libc
; do
731 try_dir
="${alt_libc}/${d}"
732 [ -d "${try_dir}" ] && add_cflags
-I"${try_dir}"
734 for d
in release
/armv
5/urel
; do
735 try_dir
="${alt_libc}/${d}"
736 [ -d "${try_dir}" ] && add_ldflags
-L"${try_dir}"
738 add_cflags
-DIMPORT_C=
743 CROSS
=${CROSS:-mipsel-linux-uclibc-}
746 tune_cflags
="-mtune="
747 check_add_cflags
-march=${tgt_isa}
748 check_add_asflags
-march=${tgt_isa}
749 check_add_asflags
-KPIC
756 add_asflags
-force_cpusubtype_ALL -I"\$(dir \$<)darwin"
757 add_cflags
-maltivec -faltivec
762 add_asflags
-maltivec -mregnames -I"\$(dir \$<)linux"
765 darwin_arch
="-arch ppc"
766 enabled ppc64
&& darwin_arch
="${darwin_arch}64"
767 add_cflags
${darwin_arch} -m${bits} -fasm-blocks
768 add_asflags
${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
769 add_ldflags
${darwin_arch} -m${bits}
775 enabled x86_64
&& bits
=64
776 soft_enable runtime_cpu_detect
785 CC
=${CC:-${CROSS}gcc}
786 LD
=${LD:-${CROSS}gcc}
796 add_cflags
-use-msasm -use-asm
797 add_ldflags
-i-static
798 enabled x86_64
&& add_cflags
-ipo -no-prec-div -static -xSSE3 -axSSE3
799 enabled x86_64
&& AR
=xiar
806 tune_cflags
="-march="
812 add_ldflags
-m${bits}
814 tune_cflags
="-march="
823 add_asflags
-f win
${bits}
824 enabled debug
&& add_asflags
-g dwarf2
827 add_asflags
-f elf
${bits}
828 enabled debug
&& add_asflags
-g dwarf2
831 add_asflags
-f macho
${bits}
832 enabled x86
&& darwin_arch
="-arch i386" || darwin_arch
="-arch x86_64"
833 add_cflags
${darwin_arch}
834 add_ldflags
${darwin_arch}
835 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
836 # one time, but does not seem to be now, and it breaks some of the
837 # code that still relies on inline assembly.
838 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
839 enabled icc
&& ! enabled pic
&& add_cflags
-fno-pic
841 *) log
"Warning: Unknown os $tgt_os while setting up yasm flags"
845 universal
*|
*-gcc|generic-gnu
)
852 # Try to enable CPU specific tuning
853 if [ -n "${tune_cpu}" ]; then
854 if [ -n "${tune_cflags}" ]; then
855 check_add_cflags
${tune_cflags}${tune_cpu} || \
856 die
"Requested CPU '${tune_cpu}' not supported by compiler"
858 if [ -n "${tune_asflags}" ]; then
859 check_add_asflags
${tune_asflags}${tune_cpu} || \
860 die
"Requested CPU '${tune_cpu}' not supported by assembler"
862 if [ -z "${tune_cflags}${tune_asflags}" ]; then
863 log_echo
"Warning: CPU tuning not supported by this toolchain"
867 enabled debug
&& check_add_cflags
-g && check_add_ldflags
-g
868 enabled gprof
&& check_add_cflags
-pg && check_add_ldflags
-pg
870 check_add_cflags
-fprofile-arcs -ftest-coverage &&
871 check_add_ldflags
-fprofile-arcs -ftest-coverage
872 enabled optimizations
&& check_add_cflags
-O3
873 if enabled rvct
; then
874 enabled optimizations
&& check_add_cflags
-Otime
877 # Position Independant Code (PIC) support, for building relocatable
879 enabled gcc
&& enabled pic
&& check_add_cflags
-fPIC
881 # Check for strip utility variant
882 ${STRIP} -V 2>/dev
/null |
grep GNU
>/dev
/null
&& enable gnu_strip
884 # Try to determine target endianness
886 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
888 [ -f "${TMP_O}" ] && od -A n
-t x1
"${TMP_O}" |
tr -d '\n' |
889 grep '4f *32 *42 *45' >/dev
/null
2>&1 && enable big_endian
891 # Almost every platform uses pthreads.
892 if enabled multithread
; then
895 *) check_header pthread.h
&& add_extralibs
-lpthread
900 if enabled linux
; then
901 add_cflags
-D_LARGEFILE_SOURCE
902 add_cflags
-D_FILE_OFFSET_BITS=64
906 process_toolchain
() {
907 process_common_toolchain
915 upname
="`toupper $cfg`"
916 if enabled
$cfg; then
917 echo "${prefix}_${upname}=yes" >> $makefile
927 upname
="`toupper $cfg`"
928 if enabled
$cfg; then
929 echo "#define ${prefix}_${upname} 1" >> $header
931 echo "#define ${prefix}_${upname} 0" >> $header
950 if enabled child
; then
951 echo "# ${self} $@" >> ${logfile}
953 echo "# ${self} $@" > ${logfile}
955 post_process_common_cmdline
961 OOT_INSTALLS
="${OOT_INSTALLS}"
962 if enabled source_path_used
; then
963 # Prepare the PWD for building.
964 for f
in ${OOT_INSTALLS}; do
965 install -D ${source_path}/$f $f
968 cp ${source_path}/build
/make
/Makefile .