| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2009 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.27 2009/05/27 14:34:33 scarabeus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.28 2009/05/29 08:06:46 scarabeus Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: cmake-utils.eclass |
5 | # @ECLASS: cmake-utils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # kde@gentoo.org |
7 | # kde@gentoo.org |
| 8 | # |
8 | # |
| … | |
… | |
| 130 | # |
130 | # |
| 131 | # For installing binary doins "${CMAKE_BUILD_DIR}/${PN}" |
131 | # For installing binary doins "${CMAKE_BUILD_DIR}/${PN}" |
| 132 | if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then |
132 | if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then |
| 133 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" |
133 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" |
| 134 | else |
134 | else |
|
|
135 | [[ ${1} = init || -d ${CMAKE_USE_DIR}_build ]] && SUF="_build" || SUF="" |
| 135 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}_build" |
136 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}${SUF}" |
|
|
137 | |
| 136 | fi |
138 | fi |
| 137 | echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" |
139 | echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" |
| 138 | } |
140 | } |
| 139 | # @FUNCTION: cmake-utils_use_with |
141 | # @FUNCTION: cmake-utils_use_with |
| 140 | # @USAGE: <USE flag> [flag name] |
142 | # @USAGE: <USE flag> [flag name] |
| … | |
… | |
| 237 | # General function for configuring with cmake. Default behaviour is to start an |
239 | # General function for configuring with cmake. Default behaviour is to start an |
| 238 | # out-of-source build. |
240 | # out-of-source build. |
| 239 | cmake-utils_src_configure() { |
241 | cmake-utils_src_configure() { |
| 240 | debug-print-function ${FUNCNAME} "$@" |
242 | debug-print-function ${FUNCNAME} "$@" |
| 241 | |
243 | |
| 242 | _check_build_dir |
244 | _check_build_dir init |
| 243 | |
245 | |
| 244 | # check if CMakeLists.txt exist and if no then die |
246 | # check if CMakeLists.txt exist and if no then die |
| 245 | if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then |
247 | if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then |
| 246 | eerror "I was unable to locate CMakeLists.txt under:" |
248 | eerror "I was unable to locate CMakeLists.txt under:" |
| 247 | eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" |
249 | eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" |
| … | |
… | |
| 329 | # All arguments are passed to emake: |
331 | # All arguments are passed to emake: |
| 330 | cmake-utils_src_make() { |
332 | cmake-utils_src_make() { |
| 331 | debug-print-function ${FUNCNAME} "$@" |
333 | debug-print-function ${FUNCNAME} "$@" |
| 332 | |
334 | |
| 333 | _check_build_dir |
335 | _check_build_dir |
| 334 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
336 | pushd "${CMAKE_BUILD_DIR}" &> /dev/null |
| 335 | # first check if Makefile exist otherwise die |
337 | # first check if Makefile exist otherwise die |
| 336 | [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." |
338 | [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." |
| 337 | if [[ -n ${CMAKE_VERBOSE} ]]; then |
339 | if [[ -n ${CMAKE_VERBOSE} ]]; then |
| 338 | emake VERBOSE=1 "$@" || die "Make failed!" |
340 | emake VERBOSE=1 "$@" || die "Make failed!" |
| 339 | else |
341 | else |
| 340 | emake "$@" || die "Make failed!" |
342 | emake "$@" || die "Make failed!" |
| 341 | fi |
343 | fi |
| 342 | popd > /dev/null |
344 | popd &> /dev/null |
| 343 | } |
345 | } |
| 344 | |
346 | |
| 345 | # @FUNCTION: cmake-utils_src_install |
347 | # @FUNCTION: cmake-utils_src_install |
| 346 | # @DESCRIPTION: |
348 | # @DESCRIPTION: |
| 347 | # Function for installing the package. Automatically detects the build type. |
349 | # Function for installing the package. Automatically detects the build type. |
| 348 | cmake-utils_src_install() { |
350 | cmake-utils_src_install() { |
| 349 | debug-print-function ${FUNCNAME} "$@" |
351 | debug-print-function ${FUNCNAME} "$@" |
| 350 | |
352 | |
| 351 | _check_build_dir |
353 | _check_build_dir |
| 352 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
354 | pushd "${CMAKE_BUILD_DIR}" &> /dev/null |
| 353 | emake install DESTDIR="${D}" || die "Make install failed" |
355 | emake install DESTDIR="${D}" || die "Make install failed" |
| 354 | popd > /dev/null |
356 | popd &> /dev/null |
| 355 | |
357 | |
| 356 | # Manual document installation |
358 | # Manual document installation |
| 357 | [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } |
359 | [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } |
| 358 | [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } |
360 | [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } |
| 359 | } |
361 | } |
| … | |
… | |
| 363 | # Function for testing the package. Automatically detects the build type. |
365 | # Function for testing the package. Automatically detects the build type. |
| 364 | cmake-utils_src_test() { |
366 | cmake-utils_src_test() { |
| 365 | debug-print-function ${FUNCNAME} "$@" |
367 | debug-print-function ${FUNCNAME} "$@" |
| 366 | |
368 | |
| 367 | _check_build_dir |
369 | _check_build_dir |
| 368 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
370 | pushd "${CMAKE_BUILD_DIR}" &> /dev/null |
| 369 | # Standard implementation of src_test |
371 | # Standard implementation of src_test |
| 370 | if emake -j1 check -n &> /dev/null; then |
372 | if emake -j1 check -n &> /dev/null; then |
| 371 | einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" |
373 | einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" |
| 372 | if ! emake -j1 check; then |
374 | if ! emake -j1 check; then |
| 373 | die "Make check failed. See above for details." |
375 | die "Make check failed. See above for details." |
| … | |
… | |
| 378 | die "Make test failed. See above for details." |
380 | die "Make test failed. See above for details." |
| 379 | fi |
381 | fi |
| 380 | else |
382 | else |
| 381 | einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" |
383 | einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" |
| 382 | fi |
384 | fi |
| 383 | popd > /dev/null |
385 | popd &> /dev/null |
| 384 | } |
386 | } |