x11-terms/mlterm: Fix typo in metadata.xml
[gentoo.git] / eclass / bsdmk.eclass
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: bsdmk.eclass
5 # @MAINTAINER:
6 # bsd@gentoo.org
7 # @BLURB: Some functions for BSDmake
8
9 inherit toolchain-funcs portability flag-o-matic
10
11 EXPORT_FUNCTIONS src_compile src_install
12
13 RDEPEND=""
14 # this should actually be BDEPEND, but this works.
15 DEPEND="virtual/pmake"
16
17 ESED="/usr/bin/sed"
18
19 # @ECLASS-VARIABLE: mymakeopts
20 # @DESCRIPTION:
21 # Options for bsd-make
22
23 # @FUNCTION: append-opt
24 # @USAGE: < options >
25 # @DESCRIPTION:
26 # append options to enable or disable features
27 append-opt() {
28         mymakeopts="${mymakeopts} $@"
29 }
30
31 # @FUNCTION: mkmake
32 # @USAGE: [ options ]
33 # @DESCRIPTION:
34 # calls bsd-make command with the given options, passing ${mymakeopts} to
35 # enable ports to useflags bridge.
36 mkmake() {
37         [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)"
38
39         tc-export CC CXX LD RANLIB
40
41         ${BMAKE} ${MAKEOPTS} ${EXTRA_EMAKE} ${mymakeopts} NO_WERROR= STRIP= "$@"
42 }
43
44 # @FUNCTION: mkinstall
45 # @USAGE: [ options ]
46 # @DESCRIPTION:
47 # Calls "bsd-make install" with the given options, passing ${mamakeopts} to
48 # enable ports to useflags bridge
49 mkinstall() {
50         [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)"
51
52         # STRIP= will replace the default value of -s, leaving to portage the
53         # task of stripping executables.
54         ${BMAKE} ${mymakeopts} NO_WERROR= STRIP= MANSUBDIR= DESTDIR="${D}" "$@" install
55 }
56
57 # @FUNCTION: dummy_mk
58 # @USAGE: < dirnames >
59 # @DESCRIPTION:
60 # removes the specified subdirectories and creates a dummy makefile in them
61 # useful to remove the need for "minimal" patches
62 dummy_mk() {
63         for dir in $@; do
64                 [ -d ${dir} ] || ewarn "dummy_mk called on a non-existing directory: $dir"
65                 [ -f ${dir}/Makefile ] || ewarn "dummy_mk called on a directory without Makefile: $dir"
66                 echo ".include <bsd.lib.mk>" > ${dir}/Makefile
67         done
68 }
69
70 # @FUNCTION: bsdmk_src_compile
71 # @DESCRIPTION:
72 # The bsdmk src_compile function, which is exported
73 bsdmk_src_compile() {
74         mkmake "$@" || die "make failed"
75 }
76
77 # @FUNCTION: bsdmk_src_install
78 # @DESCRIPTION:
79 # The bsdmk src_install function, which is exported
80 bsdmk_src_install() {
81         mkinstall "$@" || die "install failed"
82 }