net-wireless/hostapd: use #!/sbin/openrc-run instead of #!/sbin/runscript
[gentoo.git] / eclass / golang-base.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: golang-build.eclass
6 # @MAINTAINER:
7 # William Hubbs <williamh@gentoo.org>
8 # @BLURB: Eclass that provides base functions for Go packages.
9 # @DESCRIPTION:
10 # This eclass provides base functions for software written in the Go
11 # programming language; it also provides the build-time dependency on
12 # dev-lang/go.
13
14 case "${EAPI:-0}" in
15         5|6)
16                 ;;
17         *)
18                 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
19                 ;;
20 esac
21
22 if [[ -z ${_GOLANG_BASE} ]]; then
23
24 _GOLANG_BASE=1
25
26 DEPEND=">=dev-lang/go-1.4.2:="
27
28 # Do not complain about CFLAGS etc since go projects do not use them.
29 QA_FLAGS_IGNORED='.*'
30
31 STRIP_MASK="*.a"
32
33 # @ECLASS-VARIABLE: EGO_PN
34 # @REQUIRED
35 # @DESCRIPTION:
36 # This is the import path for the go package to build. Please emerge
37 # dev-lang/go and read "go help importpath" for syntax.
38 #
39 # Example:
40 # @CODE
41 # EGO_PN=github.com/user/package
42 # @CODE
43
44 # @FUNCTION: ego_pn_check
45 # @DESCRIPTION:
46 # Make sure EGO_PN has a value.
47 ego_pn_check() {
48         [[ -z "${EGO_PN}" ]] &&
49                 die "${ECLASS}.eclass: EGO_PN is not set"
50         return 0
51 }
52
53 # @FUNCTION: get_golibdir
54 # @DESCRIPTION:
55 # Return the non-prefixed library directory where Go packages
56 # should be installed
57 get_golibdir() {
58         echo /usr/lib/go-gentoo
59 }
60
61 # @FUNCTION: get_golibdir_gopath
62 # @DESCRIPTION:
63 # Return the library directory where Go packages should be installed
64 # This is the prefixed version which should be included in GOPATH
65 get_golibdir_gopath() {
66         echo "${EPREFIX}$(get_golibdir)"
67 }
68
69 # @FUNCTION: golang_install_pkgs
70 # @DESCRIPTION:
71 # Install Go packages.
72 # This function assumes that $cwd is a Go workspace.
73 golang_install_pkgs() {
74         debug-print-function ${FUNCNAME} "$@"
75
76         ego_pn_check
77         insinto "$(get_golibdir)"
78         insopts -m0644 -p # preserve timestamps for bug 551486
79         doins -r pkg src
80 }
81
82 fi