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

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

  ViewVC Help
Powered by ViewVC 1.1.20