build: do full flag handling for all compiler-type tools

This adds a full identification probe of CC, AS, LD and HOSTCC,
and sets up correct flags and dependency tracking for each.

Signed-off-by: Mans Rullgard <mans@mansr.com>
pull/28/head
Mans Rullgard 13 years ago
parent 02ac28229a
commit a758c5e259
  1. 9
      Makefile
  2. 270
      configure

@ -11,7 +11,7 @@ ifndef V
Q = @ Q = @
ECHO = printf "$(1)\t%s\n" $(2) ECHO = printf "$(1)\t%s\n" $(2)
BRIEF = CC AS YASM AR LD HOSTCC BRIEF = CC AS YASM AR LD HOSTCC
SILENT = DEPCC YASMDEP RM RANLIB SILENT = DEPCC DEPAS DEPHOSTCC YASMDEP RM RANLIB
MSG = $@ MSG = $@
M = @$(call ECHO,$(TAG),$@); M = @$(call ECHO,$(TAG),$@);
$(foreach VAR,$(BRIEF), \ $(foreach VAR,$(BRIEF), \
@ -25,14 +25,15 @@ ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale
IFLAGS := -I. -I$(SRC_PATH) IFLAGS := -I. -I$(SRC_PATH)
CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
CFLAGS += $(ECFLAGS) CFLAGS += $(ECFLAGS)
CCFLAGS = $(CFLAGS) CCFLAGS = $(CPPFLAGS) $(CFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
YASMFLAGS += $(IFLAGS) -I$(SRC_PATH)/libavutil/x86/ -Pconfig.asm YASMFLAGS += $(IFLAGS) -I$(SRC_PATH)/libavutil/x86/ -Pconfig.asm
HOSTCFLAGS += $(IFLAGS) HOSTCFLAGS += $(IFLAGS)
LDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS) LDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS)
define COMPILE define COMPILE
$($(1)DEP) $(call $(1)DEP,$(1))
$($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $< $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $<
endef endef
COMPILE_C = $(call COMPILE,CC) COMPILE_C = $(call COMPILE,CC)

270
configure vendored

@ -1731,6 +1731,8 @@ ldflags_filter=echo
AS_O='-o $@' AS_O='-o $@'
CC_O='-o $@' CC_O='-o $@'
LD_O='-o $@'
HOSTCC_O='-o $@'
host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g' host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g'
host_libs='-lm' host_libs='-lm'
@ -1741,8 +1743,8 @@ target_path='$(CURDIR)'
# since the object filename is not given with the -MM flag, the compiler # since the object filename is not given with the -MM flag, the compiler
# is only able to print the basename, and we must add the path ourselves # is only able to print the basename, and we must add the path ourselves
DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)' DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' DEPFLAGS='-MM'
# find source path # find source path
if test -f configure; then if test -f configure; then
@ -2042,120 +2044,150 @@ tms470_flags(){
done done
} }
if $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then probe_cc(){
cc_type=llvm_gcc pfx=$1
gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)') _cc=$2
cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' unset _type _ident _cc_o _flags _cflags _ldflags _depflags _DEPCMD _DEPFLAGS
AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' _flags_filter=echo
cflags_speed='-O3'
cflags_size='-Os' if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
elif $cc -v 2>&1 | grep -qi ^gcc; then _type=llvm_gcc
cc_type=gcc gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
gcc_version=$($cc --version | head -n1) _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
gcc_basever=$($cc -dumpversion) _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_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)") gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver") _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
if ! $cc -dumpversion | grep -q '^2\.'; then if ! $_cc -dumpversion | grep -q '^2\.'; then
CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' _depflags='-MMD -MF $(@:.o=.d) -MT $@'
AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
fi fi
cflags_speed='-O3' _cflags_speed='-O3'
cflags_size='-Os' _cflags_size='-Os'
elif $cc --version 2>/dev/null | grep -q Intel; then elif $_cc --version 2>/dev/null | grep -q Intel; then
cc_type=icc _type=icc
cc_ident=$($cc --version | head -n1) _ident=$($_cc --version | head -n1)
CC_DEPFLAGS='-MMD' _depflags='-MMD'
AS_DEPFLAGS='-MMD' _cflags_speed='-O3'
cflags_speed='-O3' _cflags_size='-Os'
cflags_size='-Os' _cflags_noopt='-O1'
cflags_noopt='-O1' elif $_cc -v 2>&1 | grep -q xlc; then
elif $cc -v 2>&1 | grep -q xlc; then _type=xlc
cc_type=xlc _ident=$($_cc -qversion 2>/dev/null | head -n1)
cc_ident=$($cc -qversion 2>/dev/null | head -n1) _cflags_speed='-O5'
cflags_speed='-O5' _cflags_size='-O5 -qcompact'
cflags_size='-O5 -qcompact' elif $_cc -V 2>/dev/null | grep -q Compaq; then
elif $cc -V 2>/dev/null | grep -q Compaq; then _type=ccc
cc_type=ccc _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3) _DEPFLAGS='-M'
DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
debuglevel=3 debuglevel=3
add_ldflags -Wl,-z,now # calls to libots crash without this _ldflags='-Wl,-z,now' # calls to libots crash without this
cflags_speed='-fast' _cflags_speed='-fast'
cflags_size='-O1' _cflags_size='-O1'
elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
test -d "$sysroot" || die "No valid sysroot specified." test -d "$sysroot" || die "No valid sysroot specified."
cc_type=armcc _type=armcc
cc_ident=$($cc --vsn | head -n1) _ident=$($_cc --vsn | head -n1)
armcc_conf="$PWD/armcc.conf" armcc_conf="$PWD/armcc.conf"
$cc --arm_linux_configure \ $_cc --arm_linux_configure \
--arm_linux_config_file="$armcc_conf" \ --arm_linux_config_file="$armcc_conf" \
--configure_sysroot="$sysroot" \ --configure_sysroot="$sysroot" \
--configure_cpp_headers="$sysinclude" >>$logfile 2>&1 || --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
die "Error creating armcc configuration file." die "Error creating armcc configuration file."
$cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc" _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
as_default="${cross_prefix}gcc" as_default="${cross_prefix}gcc"
CC_DEPFLAGS='-MMD' _depflags='-MMD'
AS_DEPFLAGS='-MMD' _cflags_speed='-O3'
cflags_speed='-O3' _cflags_size='-Os'
cflags_size='-Os' elif $_cc -version 2>/dev/null | grep -q TMS470; then
asflags_filter="filter_out -W${armcc_opt}*" _type=tms470
elif $cc -version 2>/dev/null | grep -q TMS470; then _ident=$($_cc -version | head -n1 | tr -s ' ')
cc_type=tms470 _flags='--gcc --abi=eabi -me'
cc_ident=$($cc -version | head -n1 | tr -s ' ') _cflags='-D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__='
cc="$cc --gcc --abi=eabi -me" _cc_o='-fe=$@'
CC_O='-fe=$@'
as_default="${cross_prefix}gcc" as_default="${cross_prefix}gcc"
ld_default="${cross_prefix}gcc" ld_default="${cross_prefix}gcc"
add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__= _depflags='-ppa -ppd=$(@:.o=.d)'
CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)' _cflags_speed='-O3 -mf=5'
AS_DEPFLAGS='-MMD' _cflags_size='-O3 -mf=2'
cflags_speed='-O3 -mf=5' _flags_filter=tms470_flags
cflags_size='-O3 -mf=2' elif $_cc -v 2>&1 | grep -q clang; then
cflags_filter=tms470_flags _type=clang
elif $cc -v 2>&1 | grep -q clang; then _ident=$($_cc --version | head -n1)
cc_type=clang _depflags='-MMD'
cc_ident=$($cc --version | head -n1) _cflags_speed='-O3'
CC_DEPFLAGS='-MMD' _cflags_size='-Os'
AS_DEPFLAGS='-MMD' elif $_cc -V 2>&1 | grep -q Sun; then
cflags_speed='-O3' _type=suncc
cflags_size='-Os' _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
elif $cc -V 2>&1 | grep -q Sun; then _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
cc_type=suncc _DEPFLAGS='-xM1'
cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) _ldflags='-std=c99'
DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)' _cflags_speed='-O5'
DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1' _cflags_size='-O5 -xspace'
add_ldflags -xc99 _flags_filter=suncc_flags
cflags_speed='-O5' elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
cflags_size='-O5 -xspace' _type=pathscale
cflags_filter=suncc_flags _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then _depflags='-MMD -MF $(@:.o=.d) -MT $@'
cc_type=pathscale _cflags_speed='-O2'
cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :) _cflags_size='-Os'
CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' _flags_filter='filter_out -Wdisabled-optimization'
AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' elif $_cc -v 2>&1 | grep -q Open64; then
cflags_speed='-O2' _type=open64
cflags_size='-Os' _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
cflags_filter='filter_out -Wdisabled-optimization' _depflags='-MMD -MF $(@:.o=.d) -MT $@'
elif $cc -v 2>&1 | grep -q Open64; then _cflags_speed='-O2'
cc_type=open64 _cflags_size='-Os'
cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :) _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' elif $_cc -V 2>&1 | grep -q Portland; then
AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@' _type=pgi
cflags_speed='-O2' _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
cflags_size='-Os'
cflags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
elif $cc -V 2>&1 | grep -q Portland; then
cc_type=pgi
cc_ident="PGI $($cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
opt_common='-alias=ansi -Mlre -Mpre' opt_common='-alias=ansi -Mlre -Mpre'
cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common" _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
cflags_size="-O2 -Munroll=c:1 $opt_common" _cflags_size="-O2 -Munroll=c:1 $opt_common"
cflags_noopt="-O1" _cflags_noopt="-O1"
cflags_filter=pgi_flags _flags_filter=pgi_flags
fi fi
eval ${pfx}_type=\$_type
eval ${pfx}_ident=\$_ident
}
set_ccvars(){
eval ${1}_O=\${_cc_o-\${${1}_O}}
if [ -n "$_depflags" ]; then
eval ${1}_DEPFLAGS=\$_depflags
else
eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
eval DEP${1}FLAGS=\$_flags
fi
}
probe_cc cc "$cc"
cflags_filter=$_flags_filter
cflags_speed=$_cflags_speed
cflags_size=$_cflags_size
cflags_noopt=$_cflags_noopt
add_cflags $_flags $_cflags
cc_ldflags=$_ldflags
set_ccvars CC
probe_cc hostcc "$host_cc"
host_cflags_filter=$_flags_filter
host_ldflags_filter=$_flags_filter
add_host_cflags $_flags $_cflags
add_host_ldflags $_flags $_ldflags
set_ccvars HOSTCC
test -n "$cc_type" && enable $cc_type || test -n "$cc_type" && enable $cc_type ||
warn "Unknown C compiler $cc, unable to select optimal CFLAGS" warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
@ -2165,8 +2197,23 @@ test -n "$cc_type" && enable $cc_type ||
: ${ld_default:=$cc} : ${ld_default:=$cc}
set_default ar as dep_cc ld set_default ar as dep_cc ld
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD probe_cc as "$as"
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD asflags_filter=$_flags_filter
add_asflags $_flags $_cflags
set_ccvars AS
probe_cc ld "$ld"
ldflags_filter=$_flags_filter
add_ldflags $_flags $_ldflags
test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
LD_O=${_cc_o-$LD_O}
if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
probe_cc depcc "$dep_cc"
CCDEP=${_DEPCMD:-$DEPCMD}
CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
DEPCCFLAGS=$_flags
fi
add_cflags $extra_cflags add_cflags $extra_cflags
add_asflags $extra_cflags add_asflags $extra_cflags
@ -3355,6 +3402,9 @@ CC=$cc
AS=$as AS=$as
LD=$ld LD=$ld
DEPCC=$dep_cc DEPCC=$dep_cc
DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
DEPAS=$as
DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
YASM=$yasmexe YASM=$yasmexe
YASMDEP=$yasmexe YASMDEP=$yasmexe
AR=$ar AR=$ar
@ -3363,8 +3413,9 @@ LN_S=$ln_s
CPPFLAGS=$CPPFLAGS CPPFLAGS=$CPPFLAGS
CFLAGS=$CFLAGS CFLAGS=$CFLAGS
ASFLAGS=$ASFLAGS ASFLAGS=$ASFLAGS
AS_O=$CC_O AS_O=$AS_O
CC_O=$CC_O CC_O=$CC_O
LD_O=$LD_O
DLLTOOL=$dlltool DLLTOOL=$dlltool
LDFLAGS=$LDFLAGS LDFLAGS=$LDFLAGS
AVSERVERLDFLAGS=$AVSERVERLDFLAGS AVSERVERLDFLAGS=$AVSERVERLDFLAGS
@ -3379,9 +3430,10 @@ SLIBPREF=$SLIBPREF
SLIBSUF=$SLIBSUF SLIBSUF=$SLIBSUF
EXESUF=$EXESUF EXESUF=$EXESUF
EXTRA_VERSION=$extra_version EXTRA_VERSION=$extra_version
DEPFLAGS=$DEPFLAGS
CCDEP=$CCDEP CCDEP=$CCDEP
CCDEP_FLAGS=$CCDEP_FLAGS
ASDEP=$ASDEP ASDEP=$ASDEP
ASDEP_FLAGS=$ASDEP_FLAGS
CC_DEPFLAGS=$CC_DEPFLAGS CC_DEPFLAGS=$CC_DEPFLAGS
AS_DEPFLAGS=$AS_DEPFLAGS AS_DEPFLAGS=$AS_DEPFLAGS
HOSTCC=$host_cc HOSTCC=$host_cc
@ -3389,6 +3441,12 @@ HOSTCFLAGS=$host_cflags
HOSTEXESUF=$HOSTEXESUF HOSTEXESUF=$HOSTEXESUF
HOSTLDFLAGS=$host_ldflags HOSTLDFLAGS=$host_ldflags
HOSTLIBS=$host_libs HOSTLIBS=$host_libs
DEPHOSTCC=$host_cc
DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
HOSTCCDEP=$HOSTCCDEP
HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
HOSTCC_O=$HOSTCC_O
TARGET_EXEC=$target_exec TARGET_EXEC=$target_exec
TARGET_PATH=$target_path TARGET_PATH=$target_path
SDL_LIBS=$sdl_libs SDL_LIBS=$sdl_libs

Loading…
Cancel
Save