summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_world_install.sh
blob: a88fb97298d3cf5af4b753bbeb4a9ab6ee5c353e (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
#!/bin/bash
#
# Copyright (C) 2009 by Marc Kleine-Budde <mkl@pengutronix.de>
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# in:
# $echo		optional
# $fakeroot	optional
#
# FIXME: kick ${pkg_install_env}
#
ptxd_make_world_install_pkg() {
    "${echo:-echo}" \
	"${pkg_path}" \
	"${pkg_env}" \
	"${pkg_make_env}" \
	"${pkg_install_env}" \
	"${MAKE}" \
	-C "${pkg_build_dir}" \
	"${pkg_install_opt}" \
	-j1 \
	| "${fakeroot:-fakeroot}" --
    check_pipe_status
}
export -f ptxd_make_world_install_pkg



#
# install
#
# Perform standard install actions
#
ptxd_make_world_install_target() {
    rm -rf -- "${pkg_pkg_dir}" &&
    mkdir -p -- "${pkg_pkg_dir}"/{etc,{,usr/}{lib,{,s}bin,include,{,share/}man/man{1,2,3,4,5,6,7,8,9}}} &&

    ptxd_make_world_install_pkg "${pkg_pkg_dir}" || return

    # remove empty dirs
    find "${pkg_pkg_dir}" -type d -print0 | xargs -r -0 -- \
	rmdir --ignore-fail-on-non-empty -p -- &&
    check_pipe_status &&

    if [ \! -e "${pkg_pkg_dir}" ]; then
	ptxd_warning "PKG didn't install anything to '${pkg_pkg_dir}'"
	return
    fi &&

    # prefix paths in la files with sysroot
    find "${pkg_pkg_dir}" -name "*.la" -print0 | xargs -r -0 -- \
	sed -i \
	-e "/^dependency_libs/s:\( \)\(/lib\|/usr/lib\):\1${pkg_sysroot_dir}\2:g" \
	-e "/^libdir=/s:\(libdir='\)\(/lib\|/usr/lib\):\1${pkg_sysroot_dir}\2:g" &&
    check_pipe_status &&

    # make pkgconfig's pc files relocatable
    find "${pkg_pkg_dir}" -name "*.pc" -print0 | \
	xargs -r -0 gawk -f "${PTXDIST_LIB_DIR}/ptxd_make_world_install_mangle_pc.awk" &&
    check_pipe_status &&

    cp -dprf -- "${pkg_pkg_dir}"/* "${pkg_sysroot_dir}"

    # copy *-config into sysroot_cross
    local config
    for config in $(find "${pkg_pkg_dir}" -name "${pkg_binconfig_glob}"); do
	cp -PR -- "${config}" "${PTXDIST_SYSROOT_CROSS}/bin" || return
    done
}
export -f ptxd_make_world_install_target


#
# for host pkgs
#
ptxd_make_world_install_host() {
    #
    # fakeroot is a host pkg and
    # might not be available, yet
    #
    local echo="eval"
    local fakeroot="cat"

    ptxd_make_world_install_pkg
}
export -f ptxd_make_world_install_host


#
# generic "make install" function
#
ptxd_make_world_install() {
    ptxd_make_world_init &&

    case "${pkg_type}" in
	target) ptxd_make_world_install_target ;;
	*)      ptxd_make_world_install_host ;;
    esac
}
export -f ptxd_make_world_install