Perhaps a straw-man argument, since, the above code could be made more beautiful, and then it would not be so ugly :P--- /usr/portage/eclass/cmake-utils.eclass 2014-05-06 08:31:17.000000000 -0700+++ /usr/local/portage/gogogmt/eclass/cmake-utils.eclass 2014-06-01 12:36:40.753904765 -0700@@ -373,14 +373,115 @@ enable_cmake-utils_src_prepare() {}++# retrieve a variable (i.e.: FOO) using i.e.: tc_getFOO,+# unless the variable is already defined to a nonempty value,+# in which case, it is returned unaltered+_cmake-utils_tc_get_if_needed() {+ local v="$1" s+ if [[ ${!v} ]] ; then+ s="${!v}"+ else+ s=$(tc-get${v})+ fi+ echo "${s}"+} + ++# trim the preceeding and trailing whitespace from a string,+# leaving inner spaces intact+_cmake-utils_trimmed() {+ local s="$*"+ while [[ ${s:0:1} =~ [[:space:]] ]] ; do+ s="${s:1}"+ done+ while [[ ${s:$((${#s}-1))} =~ [[:space:]] ]] ; do+ s="${s:0:$((${#s}-1))}"+ done+ echo "${s}"+}++# given a string, retrieve the first word (consisting of non-space characters)+# after trimming any leading whitespace.+_cmake-utils_first_word_of() {+ local s=$(_cmake-utils_trimmed "$*")+ echo "${s%% *}"+}++# given a string, retrieve the rest of the string after the first word,+# with any whitespace trimmed, retaining any whitespace between words+# (except whitespace that was between the first and second word)+_cmake-utils_subsequent_words_of() {+ local s=$(_cmake-utils_trimmed "$*")+ if [[ ${s} ]] ; then+ s="${s#$(_cmake-utils_first_word_of "${s}")}"+ echo "$(_cmake-utils_trimmed "${s}")"+ else+ echo ""+ fi+}++# given a variable-name, retrieve it with _cmake-utils_tc_get_if_needed+# and then from that retreive the first word+_cmake-utils_get_first_word() {+ local s=$(_cmake-utils_tc_get_if_needed "$1")+ echo "$(_cmake-utils_first_word_of "${s}")"+}++# given a command-containing variable as the first argument,+# uses _cmake-utils_tc_get_if_needed to retrieve the var, and then+# returns type -P of the first word of it, ignoring rest.+_cmake-utils_get_first_word_executable() {+ local w=$(_cmake-utils_get_first_word "$1")+ if [[ ${w} ]] ; then+ echo "$(type -P "${w}")"+ else+ echo ""+ fi+}++# fetches any additional bits of a variable not included in+# _cmake-utils_get_first_word. takes the variable name as an input.+# May return an empty string.+_cmake-utils_get_subsequent_words() {+ local s=$(_cmake-utils_tc_get_if_needed "$1")+ echo "$(_cmake-utils_subsequent_words_of "${s}")"}# @VARIABLE: mycmakeargs@@ -433,17 +534,46 @@ enable_cmake-utils_src_configure() {# Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.)local build_rules=${BUILD_DIR}/gentoo_rules.cmake++ local _CMAKE_C_COMPILER=$(_cmake-utils_get_first_word_executable CC)+ local _CCORPHANS=$(_cmake-utils_get_subsequent_words CC)+ local _CMAKE_C_COMPILER_ARG1_COMMAND=+ local _CMAKE_CXX_COMPILER=$(_cmake-utils_get_first_word_executable CXX)+ local _CXXORPHANS=$(_cmake-utils_get_subsequent_words CXX)+ local _CMAKE_CXX_COMPILER_ARG1_COMMAND=++ # This seems fairly rediculous to me, but if C{,XX}ORPHANS is nonempty, then, in order to prevent+ # duplication of the first argument, we must handle the first word specially+ if [[ ${_CCORPHANS} ]] ; then+ _CMAKE_C_COMPILER_ARG1_COMMAND="SET (CMAKE_C_COMPILER_ARG1 $(_cmake-utils_first_word_of "${_CCORPHANS}") CACHE STRING \"C compiler first argument\" FORCE)"+ _CCORPHANS=$(_cmake-utils_subsequent_words_of "${_CCORPHANS}")+ fi+ if [[ ${_CXXORPHANS} ]] ; then+ _CMAKE_CXX_COMPILER_ARG1_COMMAND="SET (CMAKE_CXX_COMPILER_ARG1 $(_cmake-utils_first_word_of "${_CXXORPHANS}") CACHE STRING \"C++ compiler first argument\" FORCE)"+ _CXXORPHANS=$(_cmake-utils_subsequent_words_of "${_CXXORPHANS}")+ fi+cat > "${build_rules}" <<- _EOF_- SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)- SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)- SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)- SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)- SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)- SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)- SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)- SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE)+ SET (CMAKE_C_COMPILER "${_CMAKE_C_COMPILER}" CACHE FILEPATH "C compiler" FORCE)+ ${_CMAKE_C_COMPILER_ARG1_COMMAND}+ SET (CMAKE_CXX_COMPILER "${_CMAKE_CXX_COMPILER}" CACHE FILEPATH "C++ compiler" FORCE)+ ${_CMAKE_CXX_COMPILER_ARG1_COMMAND}+ SET (CMAKE_AR "$(_cmake-utils_get_first_word_executable AR)" CACHE FILEPATH "Archive manager" FORCE)+ SET (CMAKE_RANLIB "$(_cmake-utils_get_first_word_executable RANLIB)" CACHE FILEPATH "Archive index generator" FORCE)+ SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> ${_CCORPHANS}${_CCORPHANS:+ }<DEFINES> ${CFLAGS}${CFLAGS:+ }<FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)+ SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> ${_CCORPHANS}${_CCORPHANS:+ }<DEFINES> ${CFLAGS}${CFLAGS:+ }<FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)+ SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> ${_CXXORPHANS}${_CXXORPHANS:+ }<DEFINES> ${CXXFLAGS}${CXXFLAGS:+ }<FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)+ SET (CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> ${_CCORPHANS}${_CCORPHANS:+ }<FLAGS> ${LDFLAGS}${LDFLAGS:+ }<CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" CACHE STRING "C link command for executables" FORCE)+ SET (CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> ${_CCORPHANS}${_CCORPHANS:+ }<CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${LDFLAGS}${LDFLAGS:+ }<CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" CACHE STRING "C shared library link command" FORCE)+ SET (CMAKE_C_CREATE_SHARED_MODULE "\${CMAKE_C_CREATE_SHARED_LIBRARY}" CACHE STRING "C shared module link command" FORCE)+ SET (CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> ${_CXXORPHANS}${_CXXORPHANS:+ }<FLAGS> ${LDFLAGS}${LDFLAGS:+ }<CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" CACHE STRING "C++ link command for executables" FORCE)+ SET (CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> ${_CXXORPHANS}${_CXXORPHANS:+ }<CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${LDFLAGS}${LDFLAGS:+ }<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" CACHE STRING "C++ shared library link command" FORCE)+ SET (CMAKE_CXX_CREATE_SHARED_MODULE "\${CMAKE_CXX_CREATE_SHARED_LIBRARY}" CACHE STRING "C++ shared module link command" FORCE)+ SET (PKG_CONFIG_EXECUTABLE "$(_cmake-utils_get_first_word_executable PKG_CONFIG)" CACHE FILEPATH "pkg-config executable" FORCE)_EOF_has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=