| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2010 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/waf-utils.eclass,v 1.1 2010/12/07 06:48:08 eva Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/waf-utils.eclass,v 1.6 2011/08/09 18:53:06 jer Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: waf-utils.eclass |
5 | # @ECLASS: waf-utils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # gnome@gentoo.org |
7 | # gnome@gentoo.org |
| 8 | # |
8 | # |
| 9 | # @CODE |
9 | # @CODE |
| 10 | # Original Author: Gilles Dartiguelongue <eva@gentoo.org> |
10 | # Original Author: Gilles Dartiguelongue <eva@gentoo.org> |
|
|
11 | # Various improvements based on cmake-utils.eclass: Tomáš Chvátal <scarabeus@gentoo.org> |
|
|
12 | # Proper prefix support: Jonathan Callen <abcd@gentoo.org> |
| 11 | # @CODE |
13 | # @CODE |
| 12 | # @BLURB: common ebuild functions for waf-based packages |
14 | # @BLURB: common ebuild functions for waf-based packages |
| 13 | # @DESCRIPTION: |
15 | # @DESCRIPTION: |
| 14 | # The waf-utils eclass contains functions that make creating ebuild for |
16 | # The waf-utils eclass contains functions that make creating ebuild for |
| 15 | # waf-based packages much easier. |
17 | # waf-based packages much easier. |
| 16 | # Its main features are support of common portage default settings. |
18 | # Its main features are support of common portage default settings. |
| 17 | |
19 | |
| 18 | inherit base eutils multilib python |
20 | inherit base eutils multilib toolchain-funcs |
| 19 | |
21 | |
| 20 | case ${EAPI:-0} in |
22 | case ${EAPI:-0} in |
| 21 | 3|2) EXPORT_FUNCTIONS pkg_setup src_configure src_compile src_install ;; |
23 | 4|3) EXPORT_FUNCTIONS src_configure src_compile src_install ;; |
| 22 | *) die "EAPI=${EAPI} is not supported" ;; |
24 | *) die "EAPI=${EAPI} is not supported" ;; |
| 23 | esac |
25 | esac |
| 24 | |
|
|
| 25 | # @ECLASS-VARIABLE: DOCS |
|
|
| 26 | # @DESCRIPTION: |
|
|
| 27 | # Documents passed to dodoc command. |
|
|
| 28 | |
|
|
| 29 | # @FUNCTION: waf-utils_src_configure |
|
|
| 30 | # @DESCRIPTION: |
|
|
| 31 | # General function for configuring with waf. |
|
|
| 32 | waf-utils_pkg_setup() { |
|
|
| 33 | python_set_active_version 2 |
|
|
| 34 | } |
|
|
| 35 | |
26 | |
| 36 | # @FUNCTION: waf-utils_src_configure |
27 | # @FUNCTION: waf-utils_src_configure |
| 37 | # @DESCRIPTION: |
28 | # @DESCRIPTION: |
| 38 | # General function for configuring with waf. |
29 | # General function for configuring with waf. |
| 39 | waf-utils_src_configure() { |
30 | waf-utils_src_configure() { |
| 40 | debug-print-function ${FUNCNAME} "$@" |
31 | debug-print-function ${FUNCNAME} "$@" |
| 41 | |
32 | |
|
|
33 | # @ECLASS-VARIABLE: WAF_BINARY |
|
|
34 | # @DESCRIPTION: |
|
|
35 | # Eclass can use different waf executable. Usually it is located in "${S}/waf". |
|
|
36 | : ${WAF_BINARY:="${S}/waf"} |
|
|
37 | |
|
|
38 | tc-export AR CC CPP CXX RANLIB |
|
|
39 | echo "CCFLAGS=\"${CFLAGS}\" LINKFLAGS=\"${LDFLAGS}\" \"${WAF_BINARY}\" --prefix=${EPREFIX}/usr --libdir=${EPREFIX}/usr/$(get_libdir) $@ configure" |
|
|
40 | |
| 42 | CCFLAGS="${CFLAGS}" LINKFLAGS="${LDFLAGS}" "${S}"/waf \ |
41 | CCFLAGS="${CFLAGS}" LINKFLAGS="${LDFLAGS}" "${WAF_BINARY}" \ |
| 43 | --prefix=/usr \ |
42 | "--prefix=${EPREFIX}/usr" \ |
| 44 | --libdir=/usr/$(get_libdir) \ |
43 | "--libdir=${EPREFIX}/usr/$(get_libdir)" \ |
| 45 | $@ \ |
44 | "$@" \ |
| 46 | configure || die "configure failed" |
45 | configure || die "configure failed" |
| 47 | } |
46 | } |
| 48 | |
47 | |
| 49 | # @FUNCTION: waf-utils_src_compile |
48 | # @FUNCTION: waf-utils_src_compile |
| 50 | # @DESCRIPTION: |
49 | # @DESCRIPTION: |
| 51 | # General function for compiling with waf. |
50 | # General function for compiling with waf. |
| 52 | waf-utils_src_compile() { |
51 | waf-utils_src_compile() { |
| 53 | debug-print-function ${FUNCNAME} "$@" |
52 | debug-print-function ${FUNCNAME} "$@" |
| 54 | |
53 | |
| 55 | local jobs=$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/--jobs=\2/" ) |
54 | local jobs=$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/--jobs=\2/" ) |
|
|
55 | echo "\"${WAF_BINARY}\" build ${jobs}" |
| 56 | "${S}"/waf build ${jobs} || die "build failed" |
56 | "${WAF_BINARY}" ${jobs} || die "build failed" |
| 57 | } |
57 | } |
| 58 | |
58 | |
| 59 | # @FUNCTION: waf-utils_src_install |
59 | # @FUNCTION: waf-utils_src_install |
| 60 | # @DESCRIPTION: |
60 | # @DESCRIPTION: |
| 61 | # Function for installing the package. |
61 | # Function for installing the package. |
| 62 | waf-utils_src_install() { |
62 | waf-utils_src_install() { |
| 63 | debug-print-function ${FUNCNAME} "$@" |
63 | debug-print-function ${FUNCNAME} "$@" |
| 64 | has ${EAPI:-0} 2 && ! use prefix && ED="${D}" |
|
|
| 65 | |
64 | |
|
|
65 | echo "\"${WAF_BINARY}\" --destdir=\"${D}\" install" |
| 66 | "${S}"/waf --destdir="${ED}" install || die "Make install failed" |
66 | "${WAF_BINARY}" --destdir="${D}" install || die "Make install failed" |
| 67 | |
67 | |
| 68 | # Manual document installation |
68 | # Manual document installation |
| 69 | [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } |
69 | base_src_install_docs |
| 70 | } |
70 | } |
| 71 | |
|
|