Allow --cpu= to work for x86.
[libvpx.git] / build / make / configure.sh
blobcebdd57bae2244f16aa4ee1cff5e933b3de2c787
1 #!/bin/bash
2 ##
3 ## configure.sh
4 ##
5 ## This script is sourced by the main configure script and contains
6 ## utility functions and other common bits that aren't strictly libvpx
7 ## related.
8 ##
9 ## This build system is based in part on the FFmpeg configure script.
14 # Logging / Output Functions
16 die_unknown(){
17 echo "Unknown option \"$1\"."
18 echo "See $0 --help for available options."
19 clean_temp_files
20 exit 1
24 die() {
25 echo "$@"
26 echo
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."
32 clean_temp_files
33 exit 1
37 log(){
38 echo "$@" >>$logfile
42 log_file(){
43 log BEGIN $1
44 pr -n -t $1 >>$logfile
45 log END $1
49 log_echo() {
50 echo "$@"
51 log "$@"
55 fwrite () {
56 outfile=$1
57 shift
58 echo "$@" >> ${outfile}
62 show_help_pre(){
63 for opt in ${CMDLINE_SELECT}; do
64 opt2=`echo $opt | sed -e 's;_;-;g'`
65 if enabled $opt; then
66 eval "toggle_${opt}=\"--disable-${opt2}\""
67 else
68 eval "toggle_${opt}=\"--enable-${opt2} \""
70 done
72 cat <<EOF
73 Usage: configure [options]
74 Options:
76 Build 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
91 Install options:
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
98 EOF
102 show_help_post(){
103 cat <<EOF
106 NOTES:
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.
113 Supported targets:
115 show_targets ${all_platforms}
116 echo
117 exit 1
121 show_targets() {
122 while [ -n "$*" ]; do
123 if [ "${1%%-*}" = "${2%%-*}" ]; then
124 if [ "${2%%-*}" = "${3%%-*}" ]; then
125 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
126 shift; shift; shift
127 else
128 printf " %-24s %-24s\n" "$1" "$2"
129 shift; shift
131 else
132 printf " %-24s\n" "$1"
133 shift
135 done
139 show_help() {
140 show_help_pre
141 show_help_post
145 # List Processing Functions
147 set_all(){
148 value=$1
149 shift
150 for var in $*; do
151 eval $var=$value
152 done
156 is_in(){
157 value=$1
158 shift
159 for var in $*; do
160 [ $var = $value ] && return 0
161 done
162 return 1
166 add_cflags() {
167 CFLAGS="${CFLAGS} $@"
171 add_ldflags() {
172 LDFLAGS="${LDFLAGS} $@"
176 add_asflags() {
177 ASFLAGS="${ASFLAGS} $@"
181 add_extralibs() {
182 extralibs="${extralibs} $@"
186 # Boolean Manipulation Functions
188 enable(){
189 set_all yes $*
192 disable(){
193 set_all no $*
196 enabled(){
197 eval test "x\$$1" = "xyes"
200 disabled(){
201 eval test "x\$$1" = "xno"
205 soft_enable() {
206 for var in $*; do
207 if ! disabled $var; then
208 log_echo " enabling $var"
209 enable $var
211 done
214 soft_disable() {
215 for var in $*; do
216 if ! enabled $var; then
217 log_echo " disabling $var"
218 disable $var
220 done
225 # Text Processing Functions
227 toupper(){
228 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
232 tolower(){
233 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
238 # Temporary File Functions
240 source_path=${0%/*}
241 enable source_path_used
242 if test -z "$source_path" -o "$source_path" = "." ; then
243 source_path="`pwd`"
244 disable source_path_used
247 if test ! -z "$TMPDIR" ; then
248 TMPDIRx="${TMPDIR}"
249 elif test ! -z "$TEMPDIR" ; then
250 TMPDIRx="${TEMPDIR}"
251 else
252 TMPDIRx="/tmp"
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"
259 clean_temp_files() {
260 rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X}
264 # Toolchain Check Functions
266 check_cmd() {
267 log "$@"
268 "$@" >>${logfile} 2>&1
271 check_cc() {
272 log check_cc "$@"
273 cat >${TMP_C}
274 log_file ${TMP_C}
275 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
278 check_cpp() {
279 log check_cpp "$@"
280 cat > ${TMP_C}
281 log_file ${TMP_C}
282 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
285 check_ld() {
286 log check_ld "$@"
287 check_cc $@ \
288 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
291 check_header(){
292 log check_header "$@"
293 header=$1
294 shift
295 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
296 disable $var
297 check_cpp "$@" <<EOF && enable $var
298 #include "$header"
299 int x;
304 check_cflags() {
305 log check_cflags "$@"
306 check_cc "$@" <<EOF
307 int x;
311 check_add_cflags() {
312 check_cflags "$@" && add_cflags "$@"
315 check_add_asflags() {
316 log add_asflags "$@"
317 add_asflags "$@"
320 check_add_ldflags() {
321 log add_ldflags "$@"
322 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
329 case ${toolchain} in
330 *-linux-rvct)
331 echo "ALT_LIBC := ${alt_libc}" >> config.mk
333 esac
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}"
341 else
342 fwrite config.mk "ALL_TARGETS += ${t}"
345 true;
346 done
347 true
350 write_common_target_config_mk() {
351 local CC=${CC}
352 enabled ccache && CC="ccache ${CC}"
354 cat > $1 << EOF
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}
362 CC=${CC}
363 AR=${AR}
364 LD=${LD}
365 AS=${AS}
366 STRIP=${STRIP}
367 NM=${NM}
369 CFLAGS = ${CFLAGS}
370 ARFLAGS = -rus\$(if \$(quiet),c,v)
371 LDFLAGS = ${LDFLAGS}
372 ASFLAGS = ${ASFLAGS}
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() {
408 for opt in "$@"; do
409 optval="${opt#*=}"
410 case "$opt" in
411 --child) enable child
413 --log*)
414 logging="$optval"
415 if ! disabled logging ; then
416 enabled logging || logfile="$logging"
417 else
418 logfile=/dev/null
421 --target=*) toolchain="${toolchain:-${optval}}"
423 --force-target=*) toolchain="${toolchain:-${optval}}"; enable force_toolchain
425 --cpu)
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
432 $action $option
434 --force-enable-?*|--force-disable-?*)
435 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
436 $action $option
438 --libc=*)
439 [ -d "${optval}" ] || die "Not a directory: ${optval}"
440 disable builtin_libc
441 alt_libc="${optval}"
443 --prefix=*)
444 prefix="${optval}"
446 --libdir=*)
447 libdir="${optval}"
449 --libc|--prefix|--libdir)
450 die "Option ${opt} requires argument"
452 --help|-h) show_help
454 *) die_unknown $opt
456 esac
457 done
460 process_cmdline() {
461 for opt do
462 optval="${opt#*=}"
463 case "$opt" in
464 *) process_common_cmdline $opt
466 esac
467 done
471 post_process_common_cmdline() {
472 prefix="${prefix:-/usr/local}"
473 prefix="${prefix%/}"
474 libdir="${libdir:-${prefix}/lib}"
475 libdir="${libdir%/}"
476 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
477 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
482 post_process_cmdline() {
483 true;
486 setup_gnu_toolchain() {
487 CC=${CC:-${CROSS}gcc}
488 AR=${AR:-${CROSS}ar}
489 LD=${LD:-${CROSS}${link_with_cc:-ld}}
490 AS=${AS:-${CROSS}as}
491 STRIP=${STRIP:-${CROSS}strip}
492 NM=${NM:-${CROSS}nm}
493 AS_SFX=.s
496 process_common_toolchain() {
497 if [ -z "$toolchain" ]; then
498 gcctarget="$(gcc -dumpmachine 2> /dev/null)"
500 # detect tgt_isa
501 case "$gcctarget" in
502 *x86_64*|*amd64*)
503 tgt_isa=x86_64
505 *i[3456]86*)
506 tgt_isa=x86
508 esac
510 # detect tgt_os
511 case "$gcctarget" in
512 *darwin8*)
513 tgt_isa=universal
514 tgt_os=darwin8
516 *darwin9*)
517 tgt_isa=universal
518 tgt_os=darwin9
520 *mingw32*|*cygwin*)
521 tgt_os=win32
523 *linux*|*bsd*)
524 tgt_os=linux
526 esac
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}
549 enable ${tgt_os}
550 enable ${tgt_cc}
552 # Enable the architecture family
553 case ${tgt_isa} in
554 arm*|iwmmxt*) enable arm;;
555 mips*) enable mips;;
556 esac
558 # Handle darwin variants
559 case ${toolchain} in
560 *-darwin8-gcc)
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"
566 *-darwin9-gcc)
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"
572 esac
574 # Process ARM architecture variants
575 case ${toolchain} in
576 arm*|iwmmxt*)
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"
587 case ${tgt_cc} in
588 gcc)
589 if enabled iwmmxt || enabled iwmmxt2
590 then
591 CROSS=${CROSS:-arm-iwmmxt-linux-gnueabi-}
592 elif enabled symbian; then
593 CROSS=${CROSS:-arm-none-symbianelf-}
594 else
595 CROSS=${CROSS:-arm-none-linux-gnueabi-}
597 link_with_cc=gcc
598 setup_gnu_toolchain
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
604 then
605 check_add_asflags -mcpu=${tgt_isa}
606 elif enabled armv7
607 then
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
610 else
611 check_add_cflags -march=${tgt_isa}
612 check_add_asflags -march=${tgt_isa}
615 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
617 rvct)
618 CC=armcc
619 AR=armar
620 AS=armasm
621 LD=${source_path}/build/make/armlink_adapter.sh
622 STRIP=arm-none-linux-gnueabi-strip
623 NM=arm-none-linux-gnueabi-nm
624 tune_cflags="--cpu="
625 tune_asflags="--cpu="
626 if [ -z "${tune_cpu}" ]; then
627 if enabled armv7
628 then
629 check_add_cflags --cpu=Cortex-A8 --fpu=softvfp+vfpv3
630 check_add_asflags --cpu=Cortex-A8 --fpu=none
631 else
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}\""
640 esac
642 case ${tgt_os} in
643 darwin*)
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
652 AS_SFX=.s
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-darwin9/4.0.1/include/; do
670 try_dir="${alt_libc}/${d}"
671 [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
672 done
674 for d in lib usr/lib; do
675 try_dir="${alt_libc}/${d}"
676 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
677 done
679 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
682 linux*)
683 enable linux
684 if enabled rvct; then
685 # Compiling with RVCT requires an alternate libc (glibc) when
686 # targetting linux.
687 disabled builtin_libc \
688 || die "Must supply --libc when targetting *-linux-rvct"
690 # Set up compiler
691 add_cflags --gnu
692 add_cflags --enum_is_int
693 add_cflags --library_interface=aeabi_glibc
694 add_cflags --no_hide_all
695 add_cflags --wchar32
696 add_cflags --dwarf2
697 add_cflags --gnu
699 # Set up linker
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}"
711 done
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}"
716 done
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
727 symbian*)
728 enable symbian
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}"
733 done
734 for d in release/armv5/urel; do
735 try_dir="${alt_libc}/${d}"
736 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
737 done
738 add_cflags -DIMPORT_C=
740 esac
742 mips*)
743 CROSS=${CROSS:-mipsel-linux-uclibc-}
744 link_with_cc=gcc
745 setup_gnu_toolchain
746 tune_cflags="-mtune="
747 check_add_cflags -march=${tgt_isa}
748 check_add_asflags -march=${tgt_isa}
749 check_add_asflags -KPIC
751 ppc*)
752 enable ppc
753 bits=${tgt_isa##ppc}
754 link_with_cc=gcc
755 setup_gnu_toolchain
756 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
757 add_cflags -maltivec -faltivec
758 soft_enable altivec
760 case "$tgt_os" in
761 linux*)
762 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
764 darwin*)
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}
771 esac
773 x86*)
774 bits=32
775 enabled x86_64 && bits=64
776 soft_enable runtime_cpu_detect
777 soft_enable mmx
778 soft_enable sse
779 soft_enable sse2
780 soft_enable sse3
781 soft_enable ssse3
783 case ${tgt_os} in
784 solaris*)
785 CC=${CC:-${CROSS}gcc}
786 LD=${LD:-${CROSS}gcc}
787 CROSS=${CROSS:-g}
789 esac
791 case ${tgt_cc} in
792 icc*)
793 CC=${CC:-icc}
794 LD=${LD:-icc}
795 setup_gnu_toolchain
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
800 case ${tune_cpu} in
801 atom*)
802 tune_cflags="-x"
803 tune_cpu="SSE3_ATOM"
806 tune_cflags="-march="
808 esac
810 gcc*)
811 add_cflags -m${bits}
812 add_ldflags -m${bits}
813 link_with_cc=gcc
814 tune_cflags="-march="
815 setup_gnu_toolchain
817 esac
819 AS=yasm
820 AS_SFX=.asm
821 case ${tgt_os} in
822 win*)
823 add_asflags -f win${bits}
824 enabled debug && add_asflags -g dwarf2
826 linux*|solaris*)
827 add_asflags -f elf${bits}
828 enabled debug && add_asflags -g dwarf2
830 darwin*)
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"
843 esac
845 universal*|*-gcc|generic-gnu)
846 link_with_cc=gcc
847 enable gcc
848 setup_gnu_toolchain
850 esac
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
869 enabled gcov &&
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
878 # shared objects
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
885 check_cc <<EOF
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
893 case ${toolchain} in
894 *-win*);;
895 *) check_header pthread.h && add_extralibs -lpthread
896 esac
899 # glibc needs these
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
910 print_config_mk() {
911 local prefix=$1
912 local makefile=$2
913 shift 2
914 for cfg; do
915 upname="`toupper $cfg`"
916 if enabled $cfg; then
917 echo "${prefix}_${upname}=yes" >> $makefile
919 done
922 print_config_h() {
923 local prefix=$1
924 local header=$2
925 shift 2
926 for cfg; do
927 upname="`toupper $cfg`"
928 if enabled $cfg; then
929 echo "#define ${prefix}_${upname} 1" >> $header
930 else
931 echo "#define ${prefix}_${upname} 0" >> $header
933 done
936 process_targets() {
937 true;
940 process_detect() {
941 true;
944 enable logging
945 logfile="config.err"
946 self=$0
947 process() {
948 cmdline_args="$@"
949 process_cmdline "$@"
950 if enabled child; then
951 echo "# ${self} $@" >> ${logfile}
952 else
953 echo "# ${self} $@" > ${logfile}
955 post_process_common_cmdline
956 post_process_cmdline
957 process_toolchain
958 process_detect
959 process_targets
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
966 done
968 cp ${source_path}/build/make/Makefile .
970 clean_temp_files
971 true