+msvc_flags(){
+ for flag; do
+ case $flag in
+ -fomit-frame-pointer) echo -Oy ;;
+ -g) echo -Z7 ;;
+ -Wall) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
+ -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
+ -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
+ -wd4996 ;;
+ -std=c99) ;;
+ -fno-math-errno) ;;
+ -fno-common) ;;
+ -fno-signed-zeros) ;;
+ -lz) echo zlib.lib ;;
+ -l*) echo ${flag#-l}.lib ;;
+ *) echo $flag ;;
+ esac
+ done
+}
+
+pgi_flags(){
+ for flag; do
+ case $flag in
+ -fomit-frame-pointer) echo -Mnoframe ;;
+ -g) echo -gopt ;;
+ *) echo $flag ;;
+ esac
+ done
+}
+
+suncc_flags(){
+ for flag; do
+ case $flag in
+ -march=*|-mcpu=*)
+ case "${flag#*=}" in
+ native) echo -xtarget=native ;;
+ v9|niagara) echo -xarch=sparc ;;
+ ultrasparc) echo -xarch=sparcvis ;;
+ ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
+ i586|pentium) echo -xchip=pentium ;;
+ i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
+ pentium3*|c3-2) echo -xtarget=pentium3 ;;
+ pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
+ pentium4*) echo -xtarget=pentium4 ;;
+ prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
+ *-sse3) echo -xarch=sse3 ;;
+ core2) echo -xarch=ssse3 -xchip=core2 ;;
+ amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
+ athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
+ k8|opteron|athlon64|athlon-fx)
+ echo -xarch=sse2a ;;
+ athlon*) echo -xarch=pentium_proa ;;
+ esac
+ ;;
+ -std=c99) echo -xc99 ;;
+ -fomit-frame-pointer) echo -xregs=frameptr ;;
+ -fPIC) echo -KPIC -xcode=pic32 ;;
+ -W*,*) echo $flag ;;
+ -f*-*|-W*) ;;
+ *) echo $flag ;;
+ esac
+ done
+}
+
+tms470_flags(){
+ for flag; do
+ case $flag in
+ -march=*|-mcpu=*)
+ case "${flag#*=}" in
+ armv7-a|cortex-a*) echo -mv=7a8 ;;
+ armv7-r|cortex-r*) echo -mv=7r4 ;;
+ armv7-m|cortex-m*) echo -mv=7m3 ;;
+ armv6*|arm11*) echo -mv=6 ;;
+ armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
+ echo -mv=5e ;;
+ armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
+ esac
+ ;;
+ -mfpu=neon) echo --float_support=vfpv3 --neon ;;
+ -mfpu=vfp) echo --float_support=vfpv2 ;;
+ -mfpu=vfpv3) echo --float_support=vfpv3 ;;
+ -msoft-float) echo --float_support=vfplib ;;
+ -O[0-3]|-mf=*) echo $flag ;;
+ -g) echo -g -mn ;;
+ -pds=*) echo $flag ;;
+ -D*|-I*) echo $flag ;;
+ --gcc|--abi=*) echo $flag ;;
+ -me) echo $flag ;;
+ esac
+ done
+}
+
+probe_cc(){
+ pfx=$1
+ _cc=$2
+
+ unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
+ unset _ld_o _ldflags _ld_lib _ld_path
+ unset _depflags _DEPCMD _DEPFLAGS
+ _flags_filter=echo
+
+ if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
+ _type=llvm_gcc
+ gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
+ _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
+ _depflags='-MMD -MF $(@:.o=.d) -MT $@'
+ _cflags_speed='-O3'
+ _cflags_size='-Os'
+ elif $_cc -v 2>&1 | grep -qi ^gcc; then
+ _type=gcc
+ gcc_version=$($_cc --version | head -n1)
+ gcc_basever=$($_cc -dumpversion)
+ gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
+ gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
+ _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
+ if ! $_cc -dumpversion | grep -q '^2\.'; then
+ _depflags='-MMD -MF $(@:.o=.d) -MT $@'
+ fi
+ _cflags_speed='-O3'
+ _cflags_size='-Os'
+ elif $_cc --version 2>/dev/null | grep -q Intel; then
+ _type=icc
+ _ident=$($_cc --version | head -n1)
+ _depflags='-MMD'
+ _cflags_speed='-O3'
+ _cflags_size='-Os'
+ _cflags_noopt='-O1'
+ elif $_cc -v 2>&1 | grep -q xlc; then
+ _type=xlc
+ _ident=$($_cc -qversion 2>/dev/null | head -n1)
+ _cflags_speed='-O5'
+ _cflags_size='-O5 -qcompact'
+ elif $_cc -V 2>/dev/null | grep -q Compaq; then
+ _type=ccc
+ _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
+ _DEPFLAGS='-M'
+ debuglevel=3
+ _ldflags='-Wl,-z,now' # calls to libots crash without this
+ _cflags_speed='-fast'
+ _cflags_size='-O1'
+ elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
+ test -d "$sysroot" || die "No valid sysroot specified."
+ _type=armcc
+ _ident=$($_cc --vsn | head -n1)
+ armcc_conf="$PWD/armcc.conf"
+ $_cc --arm_linux_configure \
+ --arm_linux_config_file="$armcc_conf" \
+ --configure_sysroot="$sysroot" \
+ --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
+ die "Error creating armcc configuration file."
+ $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
+ _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
+ as_default="${cross_prefix}gcc"
+ _depflags='-MMD'
+ _cflags_speed='-O3'
+ _cflags_size='-Os'
+ elif $_cc -version 2>/dev/null | grep -q TMS470; then
+ _type=tms470
+ _ident=$($_cc -version | head -n1 | tr -s ' ')
+ _flags='--gcc --abi=eabi -me'
+ _cflags='-D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__='
+ _cc_e='-ppl -fe=$@'
+ _cc_o='-fe=$@'
+ as_default="${cross_prefix}gcc"
+ ld_default="${cross_prefix}gcc"
+ _depflags='-ppa -ppd=$(@:.o=.d)'
+ _cflags_speed='-O3 -mf=5'
+ _cflags_size='-O3 -mf=2'
+ _flags_filter=tms470_flags
+ elif $_cc -v 2>&1 | grep -q clang; then
+ _type=clang
+ _ident=$($_cc --version | head -n1)
+ _depflags='-MMD'
+ _cflags_speed='-O3'
+ _cflags_size='-Os'
+ elif $_cc -V 2>&1 | grep -q Sun; then
+ _type=suncc
+ _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
+ _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
+ _DEPFLAGS='-xM1 -xc99'
+ _ldflags='-std=c99'
+ _cflags_speed='-O5'
+ _cflags_size='-O5 -xspace'
+ _flags_filter=suncc_flags
+ elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
+ _type=pathscale
+ _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
+ _depflags='-MMD -MF $(@:.o=.d) -MT $@'
+ _cflags_speed='-O2'
+ _cflags_size='-Os'
+ _flags_filter='filter_out -Wdisabled-optimization'
+ elif $_cc -v 2>&1 | grep -q Open64; then
+ _type=open64
+ _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
+ _depflags='-MMD -MF $(@:.o=.d) -MT $@'
+ _cflags_speed='-O2'
+ _cflags_size='-Os'
+ _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
+ elif $_cc -V 2>&1 | grep -q Portland; then
+ _type=pgi
+ _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
+ opt_common='-alias=ansi -Mlre -Mpre'
+ _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
+ _cflags_size="-O2 -Munroll=c:1 $opt_common"
+ _cflags_noopt="-O1"
+ _flags_filter=pgi_flags
+ elif $_cc 2>&1 | grep -q Microsoft; then
+ _type=msvc
+ _ident=$($cc 2>&1 | head -n1)
+ _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
+ _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
+ _cflags_speed="-O2"
+ _cflags_size="-O1"
+ # Nonstandard output options, to avoid msys path conversion issues, relies on wrapper to remap it
+ if $_cc 2>&1 | grep -q Linker; then
+ _ld_o='-out $@'
+ else
+ _ld_o='-Fe$@'
+ fi
+ _cc_o='-Fo $@'
+ _cc_e='-P -Fi $@'
+ _flags_filter=msvc_flags
+ _ld_lib='lib%.a'
+ _ld_path='-libpath:'
+ _flags='-nologo'
+ _cflags='-D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
+ if [ $pfx = hostcc ]; then
+ append _cflags -Dsnprintf=_snprintf
+ fi