# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: cmake-multilib.eclass # @MAINTAINER: # none # @BLURB: cmake-utils wrapper for multilib builds # @DESCRIPTION: # The cmake-multilib.eclass is a cmake-utils.eclass(5) wrapper # introducing support for building for more than one ABI (multilib). # # Inheriting this eclass sets IUSE and exports cmake-utils phase # function wrappers which build the package for each supported ABI # if the appropriate flag is enabled. # EAPI=4 is required for meaningful MULTILIB_USEDEP. case ${EAPI:-0} in 4|5) ;; *) die "EAPI=${EAPI} is not supported" ;; esac inherit my-god-its-full-of-quotation-marks ehooker cmake-utils multilib-build EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install cmake-multilib_src_prepare() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" cmake-utils_src_prepare "$@" [[ ${CMAKE_IN_SOURCE_BUILD} ]] && multilib_copy_sources } _cmake-multilib_munge_build_dir() { debug-print-function ${FUNCNAME} "$(mg-qm "$@")" debug-print "${FUNCNAME} unmunged: S=\"${S}\" BUILD_DIR=\"${BUILD_DIR}\" ECONF_SOURCE=\"${ECONF_SOURCE}\" CMAKE_USE_DIR=\"${CMAKE_USE_DIR}\" (CMAKE_IN_SOURCE_BUILD=\"${CMAKE_IN_SOURCE_BUILD}\")" # Forgetting munged variables after each ABI is processed local S="${S}" local BUILD_DIR="${BUILD_DIR}" local ECONF_SOURCE="${ECONF_SOURCE}" local CMAKE_USE_DIR="${CMAKE_USE_DIR}" if [[ ${CMAKE_IN_SOURCE_BUILD} ]] ; then CMAKE_USE_DIR="${CMAKE_USE_DIR:-${BUILD_DIR}}" # it's debatable if we should change S here. But I think doing so leads to a more intuitive # result. Certainly, it'd allow more code to work unmodified, when porting non-multibuild ebuilds S="${CMAKE_USE_DIR}" fi debug-print "${FUNCNAME} result: S=\"${S}\" BUILD_DIR=\"${BUILD_DIR}\" ECONF_SOURCE=\"${ECONF_SOURCE}\" CMAKE_USE_DIR=\"${CMAKE_USE_DIR}\" (CMAKE_IN_SOURCE_BUILD=\"${CMAKE_IN_SOURCE_BUILD}\")" "$@" } cmake-multilib_src_configure() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" _cmake-multilib_src_configure_wrapper() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" declare -a mycmakeargs=("${mycmakeargs[@]}") declare -a morecmakeargs=("$@") debug-print "${FUNCNAME} (pre-pre-hook): mycmakeargs=($(mg-qm "${mycmakeargs[@]}"))" debug-print "${FUNCNAME} (pre-pre-hook): morecmakeargs=($(mg-qm "${morecmakeargs[@]}"))" if ehook_fire cmake-multilib-pre_src_configure ; then debug-print "${FUNCNAME} (post-pre-hook): mycmakeargs=($(mg-qm "${mycmakeargs[@]}"))" debug-print "${FUNCNAME} (post-pre-hook): morecmakeargs=($(mg-qm "${morecmakeargs[@]}"))" _cmake-multilib_munge_build_dir \ cmake-utils_src_configure "${morecmakeargs[@]}" fi ehook_fire cmake-multilib-post_src_configure -u } multilib_parallel_foreach_abi _cmake-multilib_src_configure_wrapper "${@}" } cmake-multilib_src_compile() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" _cmake-multilib_src_compile_wrapper() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" declare -a cmake_compile_args=("$@") debug-print "${FUNCNAME} (pre-pre-hook): cmake_compile_args=($(mg-qm "${cmake_compile_args[@]}"))" if ehook_fire cmake-multilib-pre_src_compile ; then debug-print "${FUNCNAME} (post-pre-hook): cmake_compile_args=($(mg-qm "${cmake_compile_args[@]}"))" _cmake-multilib_munge_build_dir \ cmake-utils_src_compile "${cmake_compile_args[@]}" fi ehook_fire cmake-multilib-post_src_compile -u } multilib_foreach_abi _cmake-multilib_src_compile_wrapper "${@}" } cmake-multilib_src_test() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" _cmake-multilib_src_test_wrapper() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" declare -a cmake_test_args=("$@") debug-print "${FUNCNAME} (pre-pre-hook): cmake_test_args=($(mg-qm "${cmake_test_args[@]}"))" if ehook_fire cmake-multilib-pre_src_test ; then debug-print "${FUNCNAME} (post-pre-hook): cmake_test_args=($(mg-qm "${cmake_test_args[@]}"))" _cmake-multilib_munge_build_dir \ cmake-utils_src_test "${cmake_test_args[@]}" fi ehook_fire cmake-multilib-post_src_test -u } multilib_foreach_abi _cmake-multilib_src_test_wrapper "${@}" } cmake-multilib_src_install() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" cmake-multilib_secure_install() { debug-print-function "${FUNCNAME}" "$(mg-qm "$@")" declare -a cmake_install_args=("$@") debug-print "${FUNCNAME} (pre-pre-hook): cmake_install_args=($(mg-qm "${cmake_install_args[@]}"))" if ehook_fire cmake-multilib-pre_src_install ; then debug-print "${FUNCNAME} (post-pre-hook): cmake_install_args=($(mg-qm "${cmake_install_args[@]}"))" _cmake-multilib_munge_build_dir \ cmake-utils_src_install "${cmake_install_args[@]}" fi ehook_fire cmake-multilib-post_src_install -u # Make sure all headers are the same for each ABI. multilib_prepare_wrappers multilib_check_headers } multilib_foreach_abi cmake-multilib_secure_install "${@}" multilib_install_wrappers }