aboutsummaryrefslogtreecommitdiff
blob: cb7354542e7e25ec121c46efbf1c447a0a2360ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: numeric.eclass
# @MAINTAINER:
# jlec@gentoo.org
# @BLURB: Maintance bits needed for *lapack* and *blas* packages
# @DESCRIPTION:
# Various functions which make the maintenance  numerical algebra packages
# easier.

if [[ ! ${_NUMERIC_ECLASS} ]]; then

case ${EAPI:-0} in
	0|1|2|3|4|5)
		inherit multilib ;;
	6) ;;
	*) die "EAPI=${EAPI} is not supported" ;;
esac

# @VARIABLE: NUMERIC_MODULE_NAME
# @DESCRIPTION:
# The base pkg-config module name of the package being built.
# NUMERIC_MODULE_NAME is used by the numeric-int64_get_module_name to
# determine the pkg-config module name based on whether the package
# has dynamic, threads or openmp USE flags and if so, if the user has
# turned them or, and if the current multibuild is a int64 build or not.
#
# @CODE
# NUMERIC_MODULE_NAME="openblas"
# inherit ... numeric-int64-multibuild
# @CODE
: ${NUMERIC_MODULE_NAME:=blas}

# @FUNCTION: create_pkgconfig
# @USAGE: [ additional arguments ]
# @DESCRIPTION:
# Creates and installs pkg-config file. The function should only be executed in
# src_install(). For further information about optional arguments please consult
# http://people.freedesktop.org/~dbn/pkg-config-guide.html
#
# @CODE
# Optional arguments are:
#
#   -p | --prefix       Offset for current package               (${EPREFIX}/usr)
#   -e | --exec-prefix  Offset for current package               (${prefix})
#   -L | --libdir       Libdir to use                            (${prefix}/$(get_libdir))
#   -I | --includedir   Includedir to use                        (${prefix}/include)
#   -n | --name         A human-readable name                    (PN}
#   -d | --description  A brief description                      (DESCRIPTION)
#   -V | --version      Version of the package                   (PV)
#   -u | --url          Web presents                             (HOMEPAGE)
#   -r | --requires     Packages required by this package        (unset)
#   -l | --libs         Link flags specific to this package      (unset)
#   -c | --cflags       Compiler flags specific to this package  (unset)
#   --requires-private  Like --requires, but not exposed         (unset)
#   --conflicts         Packages that this one conflicts with    (unset)
#   --libs-private      Like --libs, but not exposed             (unset)
# @CODE
create_pkgconfig() {
	debug-print-function ${FUNCNAME} "${@}"
	local pcfilename pcrequires pcrequirespriv pcconflicts pclibs pclibspriv pccflags
	local pcprefix="${EPREFIX}/usr"
	local pcexecprefix="${pcprefix}"
	local pclibdir="${EPREFIX}/usr/$(get_libdir)"
	local pcincldir="${pcprefix}/include"
	local pcname=${PN}
	local pcdescription="${DESCRIPTION}"
	local pcurl=${HOMEPAGE}
	local pcversion=${PV}

	[[ "${EBUILD_PHASE}" != "install" ]] && \
		die "create_pkgconfig should only be used in src_install()"

	while (($#)); do
		case ${1} in
			-p | --prefix )
				shift; pcprefix=${1} ;;
			-e | --exec-prefix )
				shift; pcexecprefix=${1} ;;
			-L | --libdir )
				shift; pclibdir=${1} ;;
			-I | --includedir )
				shift; pcincldir=${1} ;;
			-n | --name )
				shift; pcname=${1} ;;
			-d | --description )
				shift; pcdescription=${1} ;;
			-V | --version )
				shift; pcversion=${1} ;;
			-u | --url )
				shift; pcurl=${1} ;;
			-r | --requires )
				shift; pcrequires=${1} ;;
			--requires-private )
				shift; pcrequirespriv=${1} ;;
			--conflicts )
				shift; pcconflicts=${1};;
			-l | --libs )
				shift; pclibs=${1} ;;
			--libs-private )
				shift; pclibspriv=${1} ;;
			-c | --cflags )
				shift; pccflags=${1} ;;
			-* )
				ewarn "Unknown option ${1}" ;;
			* )
				pcfilename=${1} ;;
		esac
		shift
	done

	[[ -z ${pcfilename} ]] && die "Missing name for pkg-config file"

	cat > "${T}"/${pcfilename}.pc <<- EOF
	prefix="${pcprefix}"
	exec_prefix="${pcexecprefix}"
	libdir="${pclibdir}"
	includedir="${pcincldir}"

	Name: ${pcname}
	Description: ${pcdescription}
	Version: ${pcversion}
	URL: ${pcurl}
	Requires: ${pcrequires}
	Requires.private: ${pcrequirespriv}
	Conflicts: ${pcconflicts}
	Libs: -L\${libdir} ${pclibs}
	Libs.private: ${pclibspriv}
	Cflags: -I\${includedir} ${pccflags}
	EOF

	insinto /usr/$(get_libdir)/pkgconfig
	doins "${T}"/${pcfilename}.pc
}

_NUMERIC_ECLASS=1
fi