summaryrefslogtreecommitdiffhomepage
path: root/subr/ex_pkg_vars.subr
blob: 9c23b0d5a1a2d1f855e718be28bbe3f2dace02f6 (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
#
# set -o errexit -o noglob are assumed.
#

exp_pkg_vars() {
	local _pkg_name="${1}" _pkg_name_uc _build_uc _vname_dst _vname_src;
	_pkg_name_uc="$(ex_toupper "${_pkg_name}")";
	_build_uc="$(ex_toupper "${BUILD}")";
	for _vname_dst in PREFIX ${PKG_BUILD_VARS}; do
		for _vname_src in					\
				"DEFAULT_${_vname_dst}"			\
				"${BUILD_TARGET}_${_vname_dst}"		\
				"PKG_${_pkg_name_uc}_${_vname_dst}"	\
				"PKG_${_pkg_name_uc}_${_vname_dst}_${_build_uc}"; do
			if [ -n "$(ex_get_var_unsafe "${_vname_src}")" ]; then
				ex_set_var_unsafe "PKG_${_vname_dst}" "$(ex_get_var_unsafe ${_vname_src})";
				if ! ex_lmatch "${PKG_ENV_VARS}" " " "${_vname_src}"; then
					PKG_ENV_VARS="${PKG_ENV_VARS:+${PKG_ENV_VARS} }${_vname_src}";
				fi;
			fi;
		done;
	done;
};

ex_pkg_vars() {
	local _vars_path;
	for _vars_path in vars/${PKG_NAME}.vars; do
		if [ -e "${_vars_path}" ]\
		|| [ -L "${_vars_path}" ]; then
			. "${_vars_path}";
		fi;
	done;
	if [ "${PKG_NAME#*_flavour_*}" != "${PKG_NAME}" ]; then
		PKG_NAME_PARENT="${_pkg_name%_flavour_*}";
		exp_pkg_vars "${PKG_NAME_PARENT}";
	fi;
	exp_pkg_vars "${PKG_NAME}";
};

# vim:filetype=sh