/[gentoo-x86]/eclass/cmake-utils.eclass
Gentoo

Diff of /eclass/cmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.3
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 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.2 2007/11/11 20:02:11 philantrop Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.3 2007/12/06 20:40:20 philantrop 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# @BLURB: common ebuild functions for cmake-based packages 8# @BLURB: common ebuild functions for cmake-based packages
31} 31}
32 32
33# @FUNCTION: cmake-utils_use_with 33# @FUNCTION: cmake-utils_use_with
34# @USAGE: <USE flag> [flag name] 34# @USAGE: <USE flag> [flag name]
35# @DESCRIPTION: 35# @DESCRIPTION:
36# Based on use_with. See ebuild.sh 36# Based on use_with. See ebuild(5).
37#
38# `cmake-utils_use_with foo FOO` echoes -DWITH_FOO=ON if foo is enabled
39# and -DWITH_FOO=OFF if it is disabled.
37cmake-utils_use_with() { _use_me_now WITH "$@" ; } 40cmake-utils_use_with() { _use_me_now WITH "$@" ; }
38 41
39# @FUNCTION: cmake-utils_use_enable 42# @FUNCTION: cmake-utils_use_enable
40# @USAGE: <USE flag> [flag name] 43# @USAGE: <USE flag> [flag name]
41# @DESCRIPTION: 44# @DESCRIPTION:
42# Based on use_enable. See ebuild.sh 45# Based on use_enable. See ebuild(5).
46#
47# `cmake-utils_use_enable foo FOO` echoes -DENABLE_FOO=ON if foo is enabled
48# and -DENABLE_FOO=OFF if it is disabled.
43cmake-utils_use_enable() { _use_me_now ENABLE "$@" ; } 49cmake-utils_use_enable() { _use_me_now ENABLE "$@" ; }
44 50
45# @FUNCTION: cmake-utils_use_want 51# @FUNCTION: cmake-utils_use_want
46# @USAGE: <USE flag> [flag name] 52# @USAGE: <USE flag> [flag name]
47# @DESCRIPTION: 53# @DESCRIPTION:
48# Based on use_enable. See ebuild.sh 54# Based on use_enable. See ebuild(5).
55#
56# `cmake-utils_use_want foo FOO` echoes -DWANT_FOO=ON if foo is enabled
57# and -DWANT_FOO=OFF if it is disabled.
49cmake-utils_use_want() { _use_me_now WANT "$@" ; } 58cmake-utils_use_want() { _use_me_now WANT "$@" ; }
59
60# @FUNCTION: cmake-utils_has
61# @USAGE: <USE flag> [flag name]
62# @DESCRIPTION:
63# Based on use_enable. See ebuild(5).
64#
65# `cmake-utils_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled
66# and -DHAVE_FOO=OFF if it is disabled.
67cmake-utils_has() { _use_me_now HAVE "$@" ; }
50 68
51# @FUNCTION: cmake-utils_src_compile 69# @FUNCTION: cmake-utils_src_compile
52# @DESCRIPTION: 70# @DESCRIPTION:
53# General function for compiling with cmake. Default behaviour is to start an 71# General function for compiling with cmake. Default behaviour is to start an
54# out-of-source build 72# out-of-source build. All arguments are passed to cmake-utils_src_make.
55cmake-utils_src_compile() { 73cmake-utils_src_compile() {
56 debug-print-function $FUNCNAME $* 74 debug-print-function $FUNCNAME $*
57 75
58 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then 76 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then
59 cmake-utils_src_configurein 77 cmake-utils_src_configurein
60 else 78 else
61 cmake-utils_src_configureout 79 cmake-utils_src_configureout
62 fi 80 fi
63 cmake-utils_src_make 81 cmake-utils_src_make "$@"
64} 82}
65 83
66# @FUNCTION: cmake-utils_src_configurein 84# @FUNCTION: cmake-utils_src_configurein
67# @DESCRIPTION: 85# @DESCRIPTION:
68# Function for software that requires configure and building in the source 86# Function for software that requires configure and building in the source
69# directory. 87# directory.
70cmake-utils_src_configurein() { 88cmake-utils_src_configurein() {
71 debug-print-function $FUNCNAME $* 89 debug-print-function $FUNCNAME $*
72 90
73 local cmakeargs="${mycmakeargs} $(_common_configure_code)" 91 local cmakeargs="$(_common_configure_code) ${mycmakeargs}"
74 92
75 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs" 93 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
76 cmake ${cmakeargs} . || die "Cmake failed" 94 cmake ${cmakeargs} . || die "Cmake failed"
77} 95}
78 96
81# Function for software that requires configure and building outside the source 99# Function for software that requires configure and building outside the source
82# tree - default. 100# tree - default.
83cmake-utils_src_configureout() { 101cmake-utils_src_configureout() {
84 debug-print-function $FUNCNAME $* 102 debug-print-function $FUNCNAME $*
85 103
86 local cmakeargs="${mycmakeargs} $(_common_configure_code)" 104 local cmakeargs="$(_common_configure_code) ${mycmakeargs}"
87 mkdir -p "${WORKDIR}"/${PN}_build 105 mkdir -p "${WORKDIR}"/${PN}_build
88 pushd "${WORKDIR}"/${PN}_build > /dev/null 106 pushd "${WORKDIR}"/${PN}_build > /dev/null
89 107
90 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs" 108 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
91 cmake ${cmakeargs} "${S}" || die "Cmake failed" 109 cmake ${cmakeargs} "${S}" || die "Cmake failed"
94} 112}
95 113
96# Internal use only. Common configuration options for all types of builds. 114# Internal use only. Common configuration options for all types of builds.
97_common_configure_code() { 115_common_configure_code() {
98 local tmp_libdir=$(get_libdir) 116 local tmp_libdir=$(get_libdir)
99 if has debug ${IUSE} && use debug; then 117 if has debug ${IUSE//+} && use debug; then
100 echo -DCMAKE_BUILD_TYPE=debug 118 echo -DCMAKE_BUILD_TYPE=Debug
119 else
120 echo -DCMAKE_BUILD_TYPE=Release
101 fi 121 fi
102 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) 122 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC))
103 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) 123 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX))
104 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} 124 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}
105 echo -DLIB_SUFFIX=${tmp_libdir/lib} 125 echo -DLIB_SUFFIX=${tmp_libdir/lib}
108} 128}
109 129
110# @FUNCTION: cmake-utils_src_make 130# @FUNCTION: cmake-utils_src_make
111# @DESCRIPTION: 131# @DESCRIPTION:
112# Function for building the package. Automatically detects the build type. 132# Function for building the package. Automatically detects the build type.
133# All arguments are passed to emake:
134# "cmake-utils_src_make -j1" can be used to work around parallel make issues.
113cmake-utils_src_make() { 135cmake-utils_src_make() {
114 debug-print-function $FUNCNAME $* 136 debug-print-function $FUNCNAME $*
115 137
116 # At this point we can automatically check if it's an out-of-source or an 138 # At this point we can automatically check if it's an out-of-source or an
117 # in-source build 139 # in-source build
118 if [[ -d ${WORKDIR}/${PN}_build ]]; then 140 if [[ -d ${WORKDIR}/${PN}_build ]]; then
119 pushd "${WORKDIR}"/${PN}_build > /dev/null 141 pushd "${WORKDIR}"/${PN}_build > /dev/null
120 fi 142 fi
121 if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then 143 if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then
122 emake VERBOSE=1 || die "Make failed!" 144 emake VERBOSE=1 "$@" || die "Make failed!"
123 else 145 else
124 emake || die "Make failed!" 146 emake "$@" || die "Make failed!"
125 fi 147 fi
126 if [[ -d ${WORKDIR}/${PN}_build ]]; then 148 if [[ -d ${WORKDIR}/${PN}_build ]]; then
127 popd > /dev/null 149 popd > /dev/null
128 fi 150 fi
129} 151}

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20