| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2011 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/bsdmk.eclass,v 1.1 2006/04/01 15:24:18 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bsdmk.eclass,v 1.11 2011/12/27 17:55:12 fauli Exp $ |
| 4 | # |
4 | |
|
|
5 | # @ECLASS: bsdmk.eclass |
|
|
6 | # @MAINTAINER: |
| 5 | # Otavio R. Piske "AngusYoung" <angusyoung@gentoo.org> |
7 | # Otavio R. Piske "AngusYoung" <angusyoung@gentoo.org> |
| 6 | # Diego Pettenò <flameeyes@gentoo.org> |
8 | # Diego Pettenò <flameeyes@gentoo.org> |
| 7 | # Benigno B. Junior <bbj@gentoo.org> |
9 | # Benigno B. Junior <bbj@gentoo.org> |
|
|
10 | # @BLURB: Some functions for BSDmake |
| 8 | |
11 | |
| 9 | inherit toolchain-funcs portability |
12 | inherit toolchain-funcs portability flag-o-matic |
| 10 | |
13 | |
| 11 | EXPORT_FUNCTIONS src_compile src_install |
14 | EXPORT_FUNCTIONS src_compile src_install |
| 12 | |
15 | |
|
|
16 | RDEPEND="" |
| 13 | # this should actually be BDEPEND, but this works. |
17 | # this should actually be BDEPEND, but this works. |
| 14 | DEPEND="!userland_BSD? ( sys-devel/pmake )" |
18 | DEPEND="virtual/pmake" |
| 15 | |
19 | |
| 16 | #### append-opt <options> |
20 | ESED="/usr/bin/sed" |
|
|
21 | |
|
|
22 | # @ECLASS-VARIABLE: mymakeopts |
|
|
23 | # @DESCRIPTION: |
|
|
24 | # Options for bsd-make |
|
|
25 | |
|
|
26 | # @FUNCTION: append-opt |
|
|
27 | # @USAGE: < options > |
|
|
28 | # @DESCRIPTION: |
| 17 | # append options to enable or disable features |
29 | # append options to enable or disable features |
| 18 | # |
|
|
| 19 | ########################################################################### |
|
|
| 20 | append-opt() { |
30 | append-opt() { |
| 21 | mymakeopts="${mymakeopts} $@" |
31 | mymakeopts="${mymakeopts} $@" |
| 22 | } |
32 | } |
| 23 | |
33 | |
| 24 | #### mkmake <options> |
34 | # @FUNCTION: mkmake |
|
|
35 | # @USAGE: [ options ] |
|
|
36 | # @DESCRIPTION: |
| 25 | # calls bsd-make command with the given options, passing ${mymakeopts} to |
37 | # calls bsd-make command with the given options, passing ${mymakeopts} to |
| 26 | # enable ports to useflags bridge. |
38 | # enable ports to useflags bridge. |
| 27 | # |
|
|
| 28 | ########################################################################### |
|
|
| 29 | mkmake() { |
39 | mkmake() { |
| 30 | [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)" |
40 | [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)" |
| 31 | |
41 | |
| 32 | tc-export CC CXX LD RANLIB |
42 | tc-export CC CXX LD RANLIB |
| 33 | |
43 | |
| 34 | ${BMAKE} ${MAKEOPTS} ${EXTRA_EMAKE} ${mymakeopts} NO_WERROR= "$@" |
44 | ${BMAKE} ${MAKEOPTS} ${EXTRA_EMAKE} ${mymakeopts} NO_WERROR= STRIP= "$@" |
| 35 | } |
45 | } |
| 36 | |
46 | |
|
|
47 | # @FUNCTION: mkinstall |
|
|
48 | # @USAGE: [ options ] |
|
|
49 | # @DESCRIPTION: |
|
|
50 | # Calls "bsd-make install" with the given options, passing ${mamakeopts} to |
|
|
51 | # enable ports to useflags bridge |
| 37 | mkinstall() { |
52 | mkinstall() { |
| 38 | [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)" |
53 | [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)" |
| 39 | |
54 | |
|
|
55 | # STRIP= will replace the default value of -s, leaving to portage the |
|
|
56 | # task of stripping executables. |
| 40 | ${BMAKE} ${mymakeopts} NO_WERROR= DESTDIR="${D}" "$@" install |
57 | ${BMAKE} ${mymakeopts} NO_WERROR= STRIP= MANSUBDIR= DESTDIR="${D}" "$@" install |
| 41 | } |
58 | } |
| 42 | |
59 | |
| 43 | #### dummy_mk <dirnames> |
60 | # @FUNCTION: dummy_mk |
|
|
61 | # @USAGE: < dirnames > |
|
|
62 | # @DESCRIPTION: |
| 44 | # removes the specified subdirectories and creates a dummy makefile in them |
63 | # removes the specified subdirectories and creates a dummy makefile in them |
| 45 | # useful to remove the need for "minimal" patches |
64 | # useful to remove the need for "minimal" patches |
| 46 | # |
|
|
| 47 | ############################################################################ |
|
|
| 48 | dummy_mk() { |
65 | dummy_mk() { |
| 49 | for dir in $@; do |
66 | for dir in $@; do |
|
|
67 | [ -d ${dir} ] || ewarn "dummy_mk called on a non-existing directory: $dir" |
|
|
68 | [ -f ${dir}/Makefile ] || ewarn "dummy_mk called on a directory without Makefile: $dir" |
| 50 | echo ".include <bsd.lib.mk>" > ${dir}/Makefile |
69 | echo ".include <bsd.lib.mk>" > ${dir}/Makefile |
| 51 | done |
70 | done |
| 52 | } |
71 | } |
| 53 | |
72 | |
| 54 | #### fix_lazy_bindings <dirnames> |
73 | # @FUNCTION: bsdmk_src_compile |
| 55 | # set LDFLAGS in order to fix lazy binding warnings in binaries |
74 | # @DESCRIPTION: |
| 56 | # |
75 | # The bsdmk src_compile function, which is exported |
| 57 | ############################################################################ |
|
|
| 58 | fix_lazy_bindings() { |
|
|
| 59 | for dir in $@; do |
|
|
| 60 | echo "LDFLAGS+= -Wl,-z,now" >> ${dir}/Makefile |
|
|
| 61 | done |
|
|
| 62 | } |
|
|
| 63 | |
|
|
| 64 | bsdmk_src_compile() { |
76 | bsdmk_src_compile() { |
| 65 | cd ${S} |
|
|
| 66 | mkmake || die "make failed" |
77 | mkmake || die "make failed" |
| 67 | } |
78 | } |
| 68 | |
79 | |
|
|
80 | # @FUNCTION: bsdmk_src_install |
|
|
81 | # @DESCRIPTION: |
|
|
82 | # The bsdmk src_install function, which is exported |
| 69 | bsdmk_src_install() { |
83 | bsdmk_src_install() { |
| 70 | cd ${S} |
|
|
| 71 | mkinstall || die "install failed" |
84 | mkinstall || die "install failed" |
| 72 | } |
85 | } |