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

pkgp_install_clean_lib() {
	local __;
	if [ -d ${PKG_PREFIX}/lib ]; then
		for __ in $(find ${PKG_PREFIX}/lib -type f -name \*.la); do
			build_fileop rm ${__};
		done;
	fi;
};

pkgp_install_dlltool() {
	local _so_fname _so_name;
	if [ "${PKG_BUILD_TYPE}" != "host" ]						\
	&& test_cmd perk								\
	&& test_cmd ${PKG_TARGET}-mdso; then
		for _so_fname in							\
			$(find	\(  -name "*.so"					\
				-or -name "*.so.[0-9]*"					\
				-or -name "*.so.[0-9]*.[0-9]*"				\
				-or -name "*.so.[0-9]*.[0-9]*.[0-9]*" \) -print);
		do	_so_fname="${_so_fname#./}";
			case "${_so_fname}" in
			*.so)		_so_fname_ver=""; ;;
			*.so.*)		_so_fname_ver="${_so_fname##*.so.}"; ;;
			esac;
			_so_name="${_so_fname%%.so*}";
			_lib_fname="${_so_name}${_so_fname_ver:+.${_so_fname_ver}}.lib.a";
			if [ -e "${_lib_fname}" ]					\
			|| [ -e "${PKG_PREFIX}/lib/${_lib_fname}" ]			\
			|| [ "$(readlink -f "${_so_fname}")" = "/dev/null" ]; then
				continue;
			else
				echo perk -e "${_so_fname}"				\|\
					${PKG_TARGET}-mdso -i ${_lib_fname} -n "${_so_fname##*/}" -
				perk -e "${_so_fname}"					|\
					${PKG_TARGET}-mdso -i ${_lib_fname} -n "${_so_fname##*/}" -
				build_fileop cp "${_lib_fname}" "${PKG_PREFIX}/lib";
			fi;
		done;
	fi;
};

pkgp_install_pkgconfig() {
	local __;
	for __ in $(find "${WORKDIR}/${PKG_BUILD_DIR}" -name \*.pc); do 
		if grep -Eq '^libdir=[^$]+$' "${__}"; then
			sed -i	-e '/^libdir=[^$]\+$/s/^libdir=\(.\+\)$/libdir=${exec_prefix}\1/'	\
				-e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/'			\
					"${__}";
		fi;
	done;
};

pkg_install() {
	pkgp_install_pkgconfig;
	if [ ${PKG_NO_MAKE_INSTALL:-0} -eq 0 ]; then
		run_cmd_unsplit make							\
			${PKG_MAKEFLAGS_INSTALL}					\
			${PKG_MAKEFLAGS_INSTALL_EXTRA}					\
			AR=${AR} CC=${CC} RANLIB=${RANLIB}				\
			"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"				\
			"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"		\
			"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"			\
			"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"		\
			"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"				\
			${PKG_INSTALL_TARGET:=install};
		if [ -n "${PKG_PREFIX_EXTRA}" ]; then
			run_cmd_unsplit make						\
				${PKG_MAKEFLAGS_INSTALL}				\
				${PKG_MAKEFLAGS_INSTALL_EXTRA}				\
				AR=${AR} CC=${CC} RANLIB=${RANLIB}			\
				"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"			\
				"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"	\
				"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"		\
				"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"	\
				"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"			\
				${PKG_INSTALL_TARGET_EXTRA:=install}			\
				DESTDIR=${PKG_PREFIX_EXTRA};
		fi;
	fi;
	pkgp_install_clean_lib;
	if [ -n "${PKG_INSTALL_FILES}" ]; then
		(install_files -v ${PKG_PREFIX} ${PKG_INSTALL_FILES});
	fi;
	pkgp_install_dlltool;
	pkgp_install_pkgconfig;
};

# vim:filetype=sh