add_extralibs $(get_safe ${pkg}_libs)
}
+hostcc_e(){
+ eval printf '%s\\n' $HOSTCC_E
+}
+
hostcc_o(){
eval printf '%s\\n' $HOSTCC_O
}
check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
}
+check_host_cpp(){
+ log check_host_cpp "$@"
+ cat > $TMPC
+ log_file $TMPC
+ check_cmd $host_cc $HOSTCPPFLAGS $HOSTCFLAGS "$@" $(hostcc_e $TMPO) $TMPC
+}
+
check_host_cppflags(){
log check_host_cppflags "$@"
check_host_cc "$@" <<EOF && append host_cppflags "$@"
EOF
}
+check_host_cpp_condition(){
+ log check_host_cpp_condition "$@"
+ header=$1
+ condition=$2
+ shift 2
+ check_host_cpp "$@" <<EOF
+#include <$header>
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
apply(){
file=$1
shift
fast_clz_if_any="alpha avr32 mips ppc x86"
fast_unaligned_if_any="ppc x86"
-inline_asm_deps="!tms470"
need_memalign="altivec neon sse"
-symver_if_any="symver_asm_label symver_gnu_asm"
-
+# system capabilities
log2_deps="!libc_msvcrt"
+symver_if_any="symver_asm_label symver_gnu_asm"
+
# subsystems
dct_select="rdft"
error_resilience_select="dsputil"
LD_LIB='-l%'
LD_PATH='-L'
HOSTCC_C='-c'
+HOSTCC_E='-E -o $@'
HOSTCC_O='-o $@'
HOSTLD_O='-o $@'
-host_cflags='-O3 -g'
-host_cppflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600'
+host_cflags='-O3'
+host_cppflags='-D_ISOC99_SOURCE'
host_libs='-lm'
host_cflags_filter=echo
host_ldflags_filter=echo
# determine libc flavour
-# uclibc defines __GLIBC__, so it needs to be checked before glibc.
-if check_cpp_condition features.h "defined __UCLIBC__"; then
- libc_type=uclibc
- add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-elif check_cpp_condition features.h "defined __GLIBC__"; then
- libc_type=glibc
- add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-# MinGW headers can be installed on Cygwin, so check for newlib first.
-elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
- libc_type=newlib
- add_cppflags -U__STRICT_ANSI__
-# MinGW64 is backwards compatible with MinGW32, so check for it first.
-elif check_cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
- libc_type=mingw64
- if check_cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
- add_compat msvcrt/snprintf.o
- add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
- else
- add_cppflags -D__USE_MINGW_ANSI_STDIO=1
+probe_libc(){
+ pfx=$1
+ # uclibc defines __GLIBC__, so it needs to be checked before glibc.
+ if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
+ eval ${pfx}libc_type=uclibc
+ add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
+ elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
+ eval ${pfx}libc_type=glibc
+ add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
+ # MinGW headers can be installed on Cygwin, so check for newlib first.
+ elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
+ eval ${pfx}libc_type=newlib
+ add_${pfx}cppflags -U__STRICT_ANSI__
+ # MinGW64 is backwards compatible with MinGW32, so check for it first.
+ elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
+ eval ${pfx}libc_type=mingw64
+ if check_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
+ add_compat msvcrt/snprintf.o
+ add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
+ fi
+ add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
+ elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION" ||
+ check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
+ eval ${pfx}libc_type=mingw32
+ check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
+ (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
+ die "ERROR: MinGW32 runtime version must be >= 3.15."
+ add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
+ elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
+ eval ${pfx}libc_type=msvcrt
+ # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
+ # 0x601 by default unless something else is set by the user.
+ # This can easily lead to us detecting functions only present
+ # in such new versions and producing binaries requiring windows 7.0.
+ # Therefore explicitly set the default to XP unless the user has
+ # set something else on the command line.
+ check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
+ add_${pfx}cppflags -D_WIN32_WINNT=0x0502
+ elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
+ eval ${pfx}libc_type=klibc
+ elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
+ eval ${pfx}libc_type=bionic
+ elif check_${pfx}cpp_condition sys/brand.h "defined SOLARIS_BRAND_NAME"; then
+ eval ${pfx}libc_type=solaris
+ add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
fi
- add_cppflags -U__STRICT_ANSI__
-elif check_cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
- libc_type=mingw32
- check_cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
- (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
- die "ERROR: MinGW32 runtime version must be >= 3.15."
- add_cppflags -U__STRICT_ANSI__
-elif check_cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
- libc_type=msvcrt
- # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
- # 0x601 by default unless something else is set by the user.
- # This can easily lead to us detecting functions only present
- # in such new versions and producing binaries requiring windows 7.0.
- # Therefore explicitly set the default to XP unless the user has
- # set something else on the command line.
- check_cpp_condition stdlib.h "defined(_WIN32_WINNT)" || add_cppflags -D_WIN32_WINNT=0x0502
-elif check_cpp_condition stddef.h "defined __KLIBC__"; then
- libc_type=klibc
-elif check_cpp_condition sys/cdefs.h "defined __BIONIC__"; then
- libc_type=bionic
-elif check_cpp_condition sys/brand.h "defined SOLARIS_BRAND_NAME"; then
- libc_type=solaris
- add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
-fi
+}
+probe_libc
test -n "$libc_type" && enable libc_$libc_type
+probe_libc host_
+test -n "$host_libc_type" && enable host_libc_$host_libc_type
case $libc_type in
bionic)
check_header X11/extensions/XvMClib.h
check_header asm/types.h
-disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
-disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
-
if ! disabled w32threads && ! enabled pthreads; then
check_func_headers "windows.h process.h" _beginthreadex && enable w32threads
fi
# do this before the optional library checks as some of them require pthreads
if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
enable pthreads
- if check_func pthread_join && check_func pthread_create; then
- :
- elif check_func pthread_join -pthread && check_func pthread_create -pthread; then
+ if check_func pthread_join -pthread && check_func pthread_create -pthread; then
add_cflags -pthread
add_extralibs -pthread
elif check_func pthread_join -pthreads && check_func pthread_create -pthreads; then
add_extralibs -pthreads
elif check_func pthread_join -lpthreadGC2 && check_func pthread_create -lpthreadGC2; then
add_extralibs -lpthreadGC2
- elif ! check_lib pthread.h pthread_join -lpthread && ! check_lib pthread.h pthread_create -lpthread; then
+ elif check_lib pthread.h pthread_join -lpthread && check_lib pthread.h pthread_create -lpthread; then
+ :
+ elif ! check_func pthread_join && ! check_func pthread_create; then
disable pthreads
fi
fi
check_func pthread_cancel
fi
+disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
+disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
+
enabled sync_val_compare_and_swap && enable atomics_gcc
enabled_all atomic_cas_ptr machine_rw_barrier && enable atomics_suncc
enabled MemoryBarrier && enable atomics_win32
add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
elif enabled tms470; then
add_cflags -pds=824 -pds=837
+ disable inline_asm
elif enabled pathscale; then
add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
elif enabled_any msvc icl; then
echo "install prefix $prefix"
echo "source path $source_path"
echo "C compiler $cc"
+echo "C library $libc_type"
if test "$host_cc" != "$cc"; then
echo "host C compiler $host_cc"
+ echo "host C library $host_libc_type"
fi
-echo "C library $libc_type"
echo "ARCH $arch ($cpu)"
if test "$build_suffix" != ""; then
echo "build suffix $build_suffix"