Donnie Berkholz wrote:
>> I've wrote an eclass that makes writing ebuilds for such packages a little
>> easier - it provides an ecmake function that takes care of few needed 
>> variables,
>> prefix and such.
> 
> Great! When's the scons one coming? =)

I don't know scons ;)

>> #
>> # Original Author: nelchael
>> # Purpose: Automate src_install and src_compile for packages using cmake
>> #
> 
> This would be a great opportunity to start using real eclass 
> documentation (e.g. that found in eutils.eclass) so we can autogenerate 
> a useful manpage on how to use it.

Done.

>> # If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything:
>> [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]] && CMAKE_BUILD_DIR="${S}"
> 
> Why would I want to do that? Some documentation would help.

Added: some packages refuse to build out of source, so it may be needed in some
cases.

>> function ecmake() {
> 
> Why are some functions declared with 'function' and others not?

Fixed: added '^function '

>>              -DCMAKE_CXX_COMPILER="$(type -P $(tc-getCXX))" \
> 
> Why the 'type -P' bit?

To get the full path to $CC and $CXX

>>      make DESTDIR="${D}" install || die "make install failed"
> 
> Does emake work?

It should -> fixed.

Attached is new version and a diff to previous.

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: cmake.eclass
# @MAINTAINER:
# [EMAIL PROTECTED]
# @BLURB: wrap cmake
# @DESCRIPTION:
# The cmake eclass contains functions wrapping cmake to ease its usage in
# ebuilds. It allows both out of source and in source builds.

inherit toolchain-funcs multilib

EXPORT_FUNCTIONS src_compile src_install

DEPEND="${DEPEND}
        >=dev-util/cmake-2.4.6-r1"

CMAKE_BUILD_DIR="${WORKDIR}/cmake-build"

# Some packages don't build out of source, so if you want to build in source
# tree set CMAKE_IN_SOURCE_BUILD to anything before inheriting cmake.eclass:
[[ -n "${CMAKE_IN_SOURCE_BUILD}" ]] && CMAKE_BUILD_DIR="${S}"

# @FUNCTION: prepare_build_dir
# @USAGE:
# @DESCRIPTION:
# Create the build directory if it doesn't exist, this function should not be
# used outside of this eclass.
function prepare_build_dir() {

        if [[ ! -d "${CMAKE_BUILD_DIR}" ]]; then
                mkdir -p "${CMAKE_BUILD_DIR}" \
                        || die "mkdir \"${CMAKE_BUILD_DIR}\" failed"
        fi

}

# @FUNCTION: ecmake
# @USAGE:
# @DESCRIPTION:
# Run cmake to prepare makefiles, also prepares the build directory.
function ecmake() {

        prepare_build_dir

        pushd "${CMAKE_BUILD_DIR}" > /dev/null

        [[ -n "${CMAKE_VERBOSE}" ]] && \
                CMAKE_FLAGS="-DCMAKE_VERBOSE_MAKEFILE=1 ${CMAKE_FLAGS}"

        echo "cmake -DCMAKE_CXX_COMPILER=\"$(type -P $(tc-getCXX))\" 
-DCMAKE_CXX_FLAGS=\"${CXXFLAGS}\" -DCMAKE_C_COMPILER=\"$(type -P $(tc-getCC))\" 
-DCMAKE_C_FLAGS=\"${CFLAGS}\" -DCMAKE_INSTALL_PREFIX=\"/usr\" 
-DLIB_INSTALL_DIR=\"/usr/$(get_libdir)\" \"${S}\" ${CMAKE_FLAGS}"

        /usr/bin/cmake \
                -DCMAKE_CXX_COMPILER="$(type -P $(tc-getCXX))" \
                -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
                -DCMAKE_C_COMPILER="$(type -P $(tc-getCC))" \
                -DCMAKE_C_FLAGS="${CFLAGS}" \
                -DCMAKE_INSTALL_PREFIX="/usr" \
                -DLIB_INSTALL_DIR="/usr/$(get_libdir)" \
                ${CMAKE_FLAGS} \
                "${S}" || die "cmake failed"

        popd > /dev/null

}

# @FUNCTION: cmake_src_compile
# @USAGE: <make arguments>
# @DESCRIPTION:
# Default src_compile for ebuilds using cmake, runs `ecmake' and then `emake'.
function cmake_src_compile() {

        ecmake

        pushd "${CMAKE_BUILD_DIR}" > /dev/null
        emake [EMAIL PROTECTED] || die "emake failed"
        popd > /dev/null

}

# @FUNCTION: cmake_src_install
# @USAGE:
# @DESCRIPTION:
# Default src_install for ebuilds using cmake, runs `emake install' in build
# directory.
function cmake_src_install() {

        pushd "${CMAKE_BUILD_DIR}" > /dev/null
        emake DESTDIR="${D}" install || die "make install failed"
        popd > /dev/null

}
Index: cmake.eclass
===================================================================
--- cmake.eclass        (revision 285)
+++ cmake.eclass        (working copy)
@@ -2,10 +2,13 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: $
 
-#
-# Original Author: nelchael
-# Purpose: Automate src_install and src_compile for packages using cmake
-#
+# @ECLASS: cmake.eclass
+# @MAINTAINER:
+# [EMAIL PROTECTED]
+# @BLURB: wrap cmake
+# @DESCRIPTION:
+# The cmake eclass contains functions wrapping cmake to ease its usage in
+# ebuilds. It allows both out of source and in source builds.
 
 inherit toolchain-funcs multilib
 
@@ -16,13 +19,15 @@
 
 CMAKE_BUILD_DIR="${WORKDIR}/cmake-build"
 
-# If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything:
+# Some packages don't build out of source, so if you want to build in source
+# tree set CMAKE_IN_SOURCE_BUILD to anything before inheriting cmake.eclass:
 [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]] && CMAKE_BUILD_DIR="${S}"
 
-#
-# Prepare CMAKE_BUILD_DIR:
-#      - create the directory if it's missing
-#
+# @FUNCTION: prepare_build_dir
+# @USAGE:
+# @DESCRIPTION:
+# Create the build directory if it doesn't exist, this function should not be
+# used outside of this eclass.
 function prepare_build_dir() {
 
        if [[ ! -d "${CMAKE_BUILD_DIR}" ]]; then
@@ -32,11 +37,10 @@
 
 }
 
-#
-# Run cmake with some needed defines.
-# If you want to add something use CMAKE_FLAGS.
-# If you want verbose makefile set CMAKE_VERBOSE to anything.
-#
+# @FUNCTION: ecmake
+# @USAGE:
+# @DESCRIPTION:
+# Run cmake to prepare makefiles, also prepares the build directory.
 function ecmake() {
 
        prepare_build_dir
@@ -62,10 +66,11 @@
 
 }
 
-#
-# Run `ecmake' and default make target.
-#
-cmake_src_compile() {
+# @FUNCTION: cmake_src_compile
+# @USAGE: <make arguments>
+# @DESCRIPTION:
+# Default src_compile for ebuilds using cmake, runs `ecmake' and then `emake'.
+function cmake_src_compile() {
 
        ecmake
 
@@ -75,13 +80,15 @@
 
 }
 
-#
-# Change to build directory and run `make install'.
-#
-cmake_src_install() {
+# @FUNCTION: cmake_src_install
+# @USAGE:
+# @DESCRIPTION:
+# Default src_install for ebuilds using cmake, runs `emake install' in build
+# directory.
+function cmake_src_install() {
 
        pushd "${CMAKE_BUILD_DIR}" > /dev/null
-       make DESTDIR="${D}" install || die "make install failed"
+       emake DESTDIR="${D}" install || die "make install failed"
        popd > /dev/null
 
 }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to