--- /usr/portage/eclass/toolchain-funcs.eclass 2010-05-23 04:08:44.000000000 +0200 +++ toolchain-funcs.eclass 2010-05-31 20:55:34.000000000 +0200 @@ -653,3 +653,55 @@ gen_usr_ldscript() { fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" done } + +# @FUNCTION: tc-cc +# @USAGE: [...] +# @DESCRIPTION: +# Compiled passed C source files into specified binary, respecting CC, CFLAGS, +# CPPFLAGS and LDFLAGS. +# +# If CC is not set, the compiler is obtained using $(tc-getCC) (you might want +# to call 'tc-export CC' if you want to call tc-cc() multiple times). +# +# Additional flags to cpp/cc/ld might be set as 'my_cppflags', 'my_cflags' and +# 'my_ldflags' respectively. Libraries to link against may be set as 'my_libs', +# in the '-lfoo -lbar' form. +tc-cc() { + [[ -z $1 ]] && die "tc-cc: output file not specified" + [[ -z $2 ]] && die "tc-cc: no input files specified" + + local output=$1 + shift + [[ -z ${CC} ]] && local CC=$(tc-getCC) + + einfo ${CC} ${CPPFLAGS} ${my_cppflags} ${CFLAGS} ${my_cflags} \ + ${LDFLAGS} ${my_ldflags} -o "${output}" "$@" ${my_libs} + ${CC} ${CPPFLAGS} ${my_cppflags} ${CFLAGS} ${my_cflags} \ + ${LDFLAGS} ${my_ldflags} -o "${output}" "$@" ${my_libs} +} + +# @FUNCTION: tc-cxx +# @USAGE: [...] +# @DESCRIPTION: +# Compiled passed C++ source files into specified binary, respecting CXX, +# CXXFLAGS, CPPFLAGS and LDFLAGS. +# +# If CXX is not set, the compiler is obtained using $(tc-getCXX) (you might want +# to call 'tc-export CXX' if you want to call tc-cxx() multiple times). +# +# Additional flags to cpp/c++/ld might be set as 'my_cppflags', 'my_cxxflags' +# and 'my_ldflags' respectively. Libraries to link against may be set as +# 'my_libs', in the '-lfoo -lbar' form. +tc-cxx() { + [[ -z $1 ]] && die "tc-cxx: output file not specified" + [[ -z $2 ]] && die "tc-cxx: no input files specified" + + local output=$1 + shift + [[ -z ${CXX} ]] && local CXX=$(tc-getCXX) + + einfo ${CXX} ${CPPFLAGS} ${my_cppflags} ${CXXFLAGS} ${my_cxxflags} \ + ${LDFLAGS} ${my_ldflags} -o "${output}" "$@" ${my_libs} + ${CXX} ${CPPFLAGS} ${my_cppflags} ${CXXFLAGS} ${my_cxxflags} \ + ${LDFLAGS} ${my_ldflags} -o "${output}" "$@" ${my_libs} +}