/[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.1 Revision 1.2
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.1 2007/11/04 13:17:35 philantrop Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.2 2007/11/11 20:02:11 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
40# @USAGE: <USE flag> [flag name] 40# @USAGE: <USE flag> [flag name]
41# @DESCRIPTION: 41# @DESCRIPTION:
42# Based on use_enable. See ebuild.sh 42# Based on use_enable. See ebuild.sh
43cmake-utils_use_enable() { _use_me_now ENABLE "$@" ; } 43cmake-utils_use_enable() { _use_me_now ENABLE "$@" ; }
44 44
45# @FUNCTION: cmake-utils_use_want
46# @USAGE: <USE flag> [flag name]
47# @DESCRIPTION:
48# Based on use_enable. See ebuild.sh
49cmake-utils_use_want() { _use_me_now WANT "$@" ; }
50
45# @FUNCTION: cmake-utils_src_compile 51# @FUNCTION: cmake-utils_src_compile
46# @DESCRIPTION: 52# @DESCRIPTION:
47# General function for compiling with cmake. Default behaviour is to start an 53# General function for compiling with cmake. Default behaviour is to start an
48# out-of-source build 54# out-of-source build
49cmake-utils_src_compile() { 55cmake-utils_src_compile() {
50 debug-print-function $FUNCNAME $* 56 debug-print-function $FUNCNAME $*
51 57
58 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then
59 cmake-utils_src_configurein
60 else
52 cmake-utils_src_configureout 61 cmake-utils_src_configureout
62 fi
53 cmake-utils_src_make 63 cmake-utils_src_make
54} 64}
55 65
56# @FUNCTION: cmake-utils_src_configurein 66# @FUNCTION: cmake-utils_src_configurein
57# @DESCRIPTION: 67# @DESCRIPTION:
72# tree - default. 82# tree - default.
73cmake-utils_src_configureout() { 83cmake-utils_src_configureout() {
74 debug-print-function $FUNCNAME $* 84 debug-print-function $FUNCNAME $*
75 85
76 local cmakeargs="${mycmakeargs} $(_common_configure_code)" 86 local cmakeargs="${mycmakeargs} $(_common_configure_code)"
77 mkdir "${WORKDIR}"/${PN}_build 87 mkdir -p "${WORKDIR}"/${PN}_build
78 cd "${WORKDIR}"/${PN}_build 88 pushd "${WORKDIR}"/${PN}_build > /dev/null
79 89
80 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs" 90 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
81 cmake ${cmakeargs} "${S}" || die "Cmake failed" 91 cmake ${cmakeargs} "${S}" || die "Cmake failed"
92
93 popd > /dev/null
82} 94}
83 95
84# Internal use only. Common configuration options for all types of builds. 96# Internal use only. Common configuration options for all types of builds.
85_common_configure_code() { 97_common_configure_code() {
86 local tmp_libdir=$(get_libdir) 98 local tmp_libdir=$(get_libdir)
89 fi 101 fi
90 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) 102 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC))
91 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) 103 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX))
92 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} 104 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}
93 echo -DLIB_SUFFIX=${tmp_libdir/lib} 105 echo -DLIB_SUFFIX=${tmp_libdir/lib}
106 echo -DLIB_INSTALL_DIR=${PREFIX:-/usr}/${tmp_libdir}
94 [[ -n ${CMAKE_NO_COLOR} ]] && echo -DCMAKE_COLOR_MAKEFILE=OFF 107 [[ -n ${CMAKE_NO_COLOR} ]] && echo -DCMAKE_COLOR_MAKEFILE=OFF
95} 108}
96 109
97# @FUNCTION: cmake-utils_src_make 110# @FUNCTION: cmake-utils_src_make
98# @DESCRIPTION: 111# @DESCRIPTION:
101 debug-print-function $FUNCNAME $* 114 debug-print-function $FUNCNAME $*
102 115
103 # At this point we can automatically check if it's an out-of-source or an 116 # At this point we can automatically check if it's an out-of-source or an
104 # in-source build 117 # in-source build
105 if [[ -d ${WORKDIR}/${PN}_build ]]; then 118 if [[ -d ${WORKDIR}/${PN}_build ]]; then
106 cd "${WORKDIR}"/${PN}_build; 119 pushd "${WORKDIR}"/${PN}_build > /dev/null
107 fi 120 fi
108 if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then 121 if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then
109 emake VERBOSE=1 || die "Make failed!"; 122 emake VERBOSE=1 || die "Make failed!"
110 else 123 else
111 emake || die "Make failed!"; 124 emake || die "Make failed!"
125 fi
126 if [[ -d ${WORKDIR}/${PN}_build ]]; then
127 popd > /dev/null
112 fi 128 fi
113} 129}
114 130
115# @FUNCTION: cmake-utils_src_install 131# @FUNCTION: cmake-utils_src_install
116# @DESCRIPTION: 132# @DESCRIPTION:
119 debug-print-function $FUNCNAME $* 135 debug-print-function $FUNCNAME $*
120 136
121 # At this point we can automatically check if it's an out-of-source or an 137 # At this point we can automatically check if it's an out-of-source or an
122 # in-source build 138 # in-source build
123 if [[ -d ${WORKDIR}/${PN}_build ]]; then 139 if [[ -d ${WORKDIR}/${PN}_build ]]; then
124 cd "${WORKDIR}"/${PN}_build; 140 pushd "${WORKDIR}"/${PN}_build > /dev/null
125 fi 141 fi
126 emake install DESTDIR="${D}" || die "Make install failed" 142 emake install DESTDIR="${D}" || die "Make install failed"
143 if [[ -d ${WORKDIR}/${PN}_build ]]; then
144 popd > /dev/null
145 fi
127} 146}
128 147
129# @FUNCTION: cmake-utils_src_test 148# @FUNCTION: cmake-utils_src_test
130# @DESCRIPTION: 149# @DESCRIPTION:
131# Function for testing the package. Automatically detects the build type. 150# Function for testing the package. Automatically detects the build type.
133 debug-print-function $FUNCNAME $* 152 debug-print-function $FUNCNAME $*
134 153
135 # At this point we can automatically check if it's an out-of-source or an 154 # At this point we can automatically check if it's an out-of-source or an
136 # in-source build 155 # in-source build
137 if [[ -d ${WORKDIR}/${PN}_build ]]; then 156 if [[ -d ${WORKDIR}/${PN}_build ]]; then
138 cd "${WORKDIR}"/${PN}_build 157 pushd "${WORKDIR}"/${PN}_build > /dev/null
139 fi 158 fi
140 # Standard implementation of src_test 159 # Standard implementation of src_test
141 if emake -j1 check -n &> /dev/null; then 160 if emake -j1 check -n &> /dev/null; then
142 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" 161 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
143 if ! emake -j1 check; then 162 if ! emake -j1 check; then
149 die "Make test failed. See above for details." 168 die "Make test failed. See above for details."
150 fi 169 fi
151 else 170 else
152 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" 171 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
153 fi 172 fi
173 if [[ -d ${WORKDIR}/${PN}_build ]]; then
174 popd > /dev/null
175 fi
154} 176}

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

  ViewVC Help
Powered by ViewVC 1.1.20