Lakka-LibreELEC/scripts/build

508 lines
19 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2009-03-18 12:02:53 +00:00
2018-07-16 18:45:36 +00:00
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
2011-01-09 20:26:03 +00:00
2019-06-16 01:45:52 +00:00
. config/options "${1}"
2019-06-16 01:45:52 +00:00
if [ -z "${1}" ]; then
die "usage: ${0} package_name[:<host|target|init|bootstrap>] [parent_pkg]"
fi
2009-03-18 12:02:53 +00:00
2019-06-16 01:45:52 +00:00
if [ "${1}" = "--all" ]; then
if [ -n "${2}" ]; then
for build_dir in $(ls -1d ${ROOT}/build.*); do
2019-06-16 01:45:52 +00:00
load_build_config ${build_dir} && ${SCRIPTS}/build "${2}"
done
fi
exit 0
fi
if [ -z "${PKG_NAME}" ]; then
die "$(print_color CLR_ERROR "${1}: no package.mk file found")"
2009-03-18 12:02:53 +00:00
fi
2019-06-16 01:45:52 +00:00
if [ -n "${PKG_ARCH}" ]; then
listcontains "${PKG_ARCH}" "!${TARGET_ARCH}" && exit 0
listcontains "${PKG_ARCH}" "${TARGET_ARCH}" || listcontains "${PKG_ARCH}" "any" || exit 0
2014-01-27 13:05:34 +00:00
fi
if [ "${1//:/}" != "${1}" ]; then
TARGET="${1#*:}"
else
TARGET=
fi
TARGET="${TARGET:-target}"
PARENT_PKG="${2:-${PKG_NAME}:${TARGET}}"
pkg_lock "${PKG_NAME}:${TARGET}" "build" "${PARENT_PKG}"
2019-06-16 01:45:52 +00:00
mkdir -p ${STAMPS}/${PKG_NAME}
STAMP=${STAMPS}/${PKG_NAME}/build_${TARGET}
if [ -f ${STAMP} ]; then
. ${STAMP}
PKG_DEEPHASH=$(calculate_stamp)
if [ "${PKG_DEEPHASH}" = "${STAMP_PKG_DEEPHASH}" -a "${BUILD_WITH_DEBUG}" = "${STAMP_BUILD_WITH_DEBUG}" ]; then
# stamp matched: already built, do nothing
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "already built"
exit 0
2017-05-01 01:45:00 +00:00
fi
rm -f ${STAMP}
2009-03-18 12:02:53 +00:00
fi
2019-06-16 01:45:52 +00:00
${SCRIPTS}/unpack "${PKG_NAME}" "${PARENT_PKG}"
# build dependencies, only when PKG_DEPENDS_? is filled
unset _pkg_depends
2019-06-16 01:45:52 +00:00
case "${TARGET}" in
"target") _pkg_depends="${PKG_DEPENDS_TARGET}";;
"host") _pkg_depends="${PKG_DEPENDS_HOST}";;
"init") _pkg_depends="${PKG_DEPENDS_INIT}";;
"bootstrap") _pkg_depends="${PKG_DEPENDS_BOOTSTRAP}";;
esac
if is_sequential_build; then
for p in ${_pkg_depends}; do
${SCRIPTS}/build "${p}" "${PARENT_PKG}"
done
fi
# virtual packages are not built as they only contain dependencies, so dont go further here
2019-06-16 01:45:52 +00:00
if [ "${PKG_SECTION}" = "virtual" ]; then
PKG_DEEPHASH=$(calculate_stamp)
for i in PKG_NAME PKG_DEEPHASH BUILD_WITH_DEBUG; do
2019-06-16 01:45:52 +00:00
echo "STAMP_${i}=\"${!i}\"" >> ${STAMP}
done
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "built"
exit 0
fi
# build this package
if [ "${BUILD_WITH_DEBUG}" = "yes" ]; then
build_msg "CLR_BUILD" "BUILD" "${PKG_NAME} $(print_color "CLR_TARGET" "(${TARGET})") [DEBUG]" "indent"
else
build_msg "CLR_BUILD" "BUILD" "${PKG_NAME} $(print_color "CLR_TARGET" "(${TARGET})")" "indent"
fi
# setup configure scripts
PKG_CONFIGURE_SCRIPT="${PKG_CONFIGURE_SCRIPT:-${PKG_BUILD}/configure}"
PKG_CMAKE_SCRIPT="${PKG_CMAKE_SCRIPT:-${PKG_BUILD}/CMakeLists.txt}"
PKG_MESON_SCRIPT="${PKG_MESON_SCRIPT:-${PKG_BUILD}/meson.build}"
# auto detect toolchain
_auto_toolchain=""
if [ -z "${PKG_TOOLCHAIN}" -o "${PKG_TOOLCHAIN}" = "auto" ]; then
if [ -f "${PKG_MESON_SCRIPT}" ]; then
PKG_TOOLCHAIN="meson"
elif [ -f "${PKG_CMAKE_SCRIPT}" ]; then
PKG_TOOLCHAIN="cmake"
elif [ -f "${PKG_CONFIGURE_SCRIPT}" ]; then
PKG_TOOLCHAIN="configure"
elif [ -f "${PKG_BUILD}/Makefile" ]; then
PKG_TOOLCHAIN="make"
else
die "Not possible to detect toolchain automatically. Add PKG_TOOLCHAIN= to package.mk"
fi
_auto_toolchain=" (auto-detect)"
fi
if ! listcontains "meson cmake cmake-make configure ninja make autotools manual" "${PKG_TOOLCHAIN}"; then
die "$(print_color "CLR_ERROR" "ERROR:") unknown toolchain ${PKG_TOOLCHAIN}"
fi
build_msg "CLR_TOOLCHAIN" "TOOLCHAIN" "${PKG_TOOLCHAIN}${_auto_toolchain}"
# setup toolchain
setup_toolchain ${TARGET} ${PKG_TOOLCHAIN}
# configure install directory
[ -n "${PKG_INSTALL}" ] && INSTALL="${PKG_INSTALL}" || unset INSTALL
# remove previous install files
2019-06-16 01:45:52 +00:00
if [ -n "${INSTALL}" -a -d "${INSTALL}" ]; then
rm -rf "${INSTALL}"
fi
# configure debug build defaults
if [ "${BUILD_WITH_DEBUG}" = "yes" ]; then
CMAKE_BUILD_TYPE="Debug"
MESON_BUILD_TYPE="debug"
else
CMAKE_BUILD_TYPE="MinSizeRel"
MESON_BUILD_TYPE="plain"
fi
CMAKE_GENERATOR_NINJA="-GNinja \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
# configure TARGET build defaults
2019-06-16 01:45:52 +00:00
TARGET_CONFIGURE_OPTS="--host=${TARGET_NAME} \
--build=${HOST_NAME} \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
--localstatedir=/var \
--disable-static \
--enable-shared"
2019-06-16 01:45:52 +00:00
TARGET_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CONF} \
-DCMAKE_INSTALL_PREFIX=/usr \
2019-06-16 01:45:52 +00:00
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
TARGET_MESON_OPTS="--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
--localstatedir=/var \
2019-06-16 01:45:52 +00:00
--buildtype=${MESON_BUILD_TYPE}"
2019-09-04 10:07:06 +00:00
if [ ${BUILD_WITH_DEBUG} != yes ] && flag_enabled "strip" "yes"; then
TARGET_MESON_OPTS+=" -Dstrip=true"
fi
# configure HOST build defaults
2019-06-16 01:45:52 +00:00
HOST_CONFIGURE_OPTS="--host=${HOST_NAME} \
--build=${HOST_NAME} \
--prefix=${TOOLCHAIN} \
--bindir=${TOOLCHAIN}/bin \
--sbindir=${TOOLCHAIN}/sbin \
--sysconfdir=${TOOLCHAIN}/etc \
--libexecdir=${TOOLCHAIN}/lib \
--localstatedir=${TOOLCHAIN}/var \
--disable-static \
--enable-shared"
2019-06-16 01:45:52 +00:00
HOST_CMAKE_OPTS="${CMAKE_GENERATOR} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CONF} \
-DCMAKE_INSTALL_PREFIX=${TOOLCHAIN}"
HOST_MESON_OPTS="--prefix=${TOOLCHAIN} \
--bindir=${TOOLCHAIN}/bin \
--sbindir=${TOOLCHAIN}/sbin \
--sysconfdir=${TOOLCHAIN}/etc \
--libdir=${TOOLCHAIN}/lib \
--libexecdir=${TOOLCHAIN}/lib \
--localstatedir=${TOOLCHAIN}/var \
--buildtype=plain"
# configure INIT build defaults
2019-06-16 01:45:52 +00:00
INIT_CONFIGURE_OPTS="${TARGET_CONFIGURE_OPTS}"
INIT_CMAKE_OPTS="${TARGET_CMAKE_OPTS}"
INIT_MESON_OPTS="${TARGET_MESON_OPTS}"
# configure BOOTSTRAP build defaults
2019-06-16 01:45:52 +00:00
BOOTSTRAP_CONFIGURE_OPTS="${HOST_CONFIGURE_OPTS}"
BOOTSTRAP_CMAKE_OPTS="${HOST_CMAKE_OPTS}"
BOOTSTRAP_MESON_OPTS="${HOST_MESON_OPTS}"
# make autoreconf
2019-06-16 01:45:52 +00:00
if [ "${PKG_TOOLCHAIN}" = "autotools" ]; then
${SCRIPTS}/autoreconf "${PKG_NAME}" "${PARENT_PKG}"
fi
pkg_lock_status "ACTIVE" "${PKG_NAME}:${TARGET}" "build"
# include build template and build
2019-06-16 01:45:52 +00:00
pkg_call_exists pre_build_${TARGET} && pkg_call pre_build_${TARGET}
2019-06-16 01:45:52 +00:00
# ensure ${PKG_BUILD} is there. (installer? PKG_URL="")
mkdir -p "${PKG_BUILD}"
2019-06-16 01:45:52 +00:00
cd "${PKG_BUILD}"
2019-06-16 01:45:52 +00:00
if [ -f "${PKG_CONFIGURE_SCRIPT}" -o -f "${PKG_CMAKE_SCRIPT}" -o -f "${PKG_MESON_SCRIPT}" ]; then
case "${TARGET}" in
"target") PKG_REAL_BUILD="${PKG_BUILD}/.${TARGET_NAME}" ;;
"host") PKG_REAL_BUILD="${PKG_BUILD}/.${HOST_NAME}" ;;
"init") PKG_REAL_BUILD="${PKG_BUILD}/.${TARGET_NAME}-${TARGET}" ;;
"bootstrap") PKG_REAL_BUILD="${PKG_BUILD}/.${HOST_NAME}-${TARGET}" ;;
esac
2019-06-16 01:45:52 +00:00
mkdir -p "${PKG_REAL_BUILD}"
cd "${PKG_REAL_BUILD}"
2019-06-16 01:45:52 +00:00
MESON_CONF="${PKG_REAL_BUILD}/meson.conf"
fi
# configure
pkg_call_exists pre_configure && pkg_call pre_configure
2019-06-16 01:45:52 +00:00
pkg_call_exists pre_configure_${TARGET} && pkg_call pre_configure_${TARGET}
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
if pkg_call_exists configure_${TARGET}; then
pkg_call configure_${TARGET}
else
2019-06-16 01:45:52 +00:00
case "${PKG_TOOLCHAIN}:${TARGET}" in
# meson builds
"meson:target")
create_meson_conf_target ${TARGET} ${MESON_CONF}
2019-06-16 01:45:52 +00:00
echo "Executing (target): meson ${TARGET_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_TARGET} $(dirname ${PKG_MESON_SCRIPT})" | tr -s " "
CC="${HOST_CC}" CXX="${HOST_CXX}" meson ${TARGET_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_TARGET} $(dirname ${PKG_MESON_SCRIPT})
;;
"meson:host")
create_meson_conf_host ${TARGET} ${MESON_CONF}
2019-06-16 01:45:52 +00:00
echo "Executing (host): meson ${HOST_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_HOST} $(dirname ${PKG_MESON_SCRIPT})" | tr -s " "
meson ${HOST_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_HOST} $(dirname ${PKG_MESON_SCRIPT})
;;
"meson:init")
create_meson_conf_target ${TARGET} ${MESON_CONF}
2019-06-16 01:45:52 +00:00
echo "Executing (init): meson ${INIT_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_INIT} $(dirname ${PKG_MESON_SCRIPT})" | tr -s " "
meson ${INIT_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_INIT} $(dirname ${PKG_MESON_SCRIPT})
;;
"meson:bootstrap")
create_meson_conf_host ${TARGET} ${MESON_CONF}
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): meson ${BOOTSTRAP_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_BOOTSTRAP} $(dirname ${PKG_MESON_SCRIPT})" | tr -s " "
meson ${BOOTSTRAP_MESON_OPTS} --cross-file=${MESON_CONF} ${PKG_MESON_OPTS_BOOTSTRAP} $(dirname ${PKG_MESON_SCRIPT})
;;
# cmake builds with ninja
"cmake:target")
2019-06-16 01:45:52 +00:00
echo "Executing (target): cmake ${CMAKE_GENERATOR_NINJA} ${TARGET_CMAKE_OPTS} ${PKG_CMAKE_OPTS_TARGET} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${CMAKE_GENERATOR_NINJA} ${TARGET_CMAKE_OPTS} ${PKG_CMAKE_OPTS_TARGET} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake:host")
2019-06-16 01:45:52 +00:00
echo "Executing (host): cmake ${CMAKE_GENERATOR_NINJA} ${HOST_CMAKE_OPTS} ${PKG_CMAKE_OPTS_HOST} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${CMAKE_GENERATOR_NINJA} ${HOST_CMAKE_OPTS} ${PKG_CMAKE_OPTS_HOST} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake:init")
2019-06-16 01:45:52 +00:00
echo "Executing (init): cmake ${CMAKE_GENERATOR_NINJA} ${INIT_CMAKE_OPTS} ${PKG_CMAKE_OPTS_INIT} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${CMAKE_GENERATOR_NINJA} ${INIT_CMAKE_OPTS} ${PKG_CMAKE_OPTS_INIT} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake:bootstrap")
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): cmake ${CMAKE_GENERATOR_NINJA} ${BOOTSTRAP_CMAKE_OPTS} ${PKG_CMAKE_OPTS_BOOTSTRAP} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${CMAKE_GENERATOR_NINJA} ${BOOTSTRAP_CMAKE_OPTS} ${PKG_CMAKE_OPTS_BOOTSTRAP} $(dirname ${PKG_CMAKE_SCRIPT})
;;
# cmake builds with make
"cmake-make:target")
2019-06-16 01:45:52 +00:00
echo "Executing (target): cmake ${TARGET_CMAKE_OPTS} ${PKG_CMAKE_OPTS_TARGET} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${TARGET_CMAKE_OPTS} ${PKG_CMAKE_OPTS_TARGET} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake-make:host")
2019-06-16 01:45:52 +00:00
echo "Executing (host): cmake ${HOST_CMAKE_OPTS} ${PKG_CMAKE_OPTS_HOST} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${HOST_CMAKE_OPTS} ${PKG_CMAKE_OPTS_HOST} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake-make:init")
2019-06-16 01:45:52 +00:00
echo "Executing (init): cmake ${INIT_CMAKE_OPTS} ${PKG_CMAKE_OPTS_INIT} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${INIT_CMAKE_OPTS} ${PKG_CMAKE_OPTS_INIT} $(dirname ${PKG_CMAKE_SCRIPT})
;;
"cmake-make:bootstrap")
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): cmake ${BOOTSTRAP_CMAKE_OPTS} ${PKG_CMAKE_OPTS_BOOTSTRAP} $(dirname ${PKG_CMAKE_SCRIPT})" | tr -s " "
cmake ${BOOTSTRAP_CMAKE_OPTS} ${PKG_CMAKE_OPTS_BOOTSTRAP} $(dirname ${PKG_CMAKE_SCRIPT})
;;
# configure builds
"configure:target"|"autotools:target")
2019-06-16 01:45:52 +00:00
echo "Executing (target): ${PKG_CONFIGURE_SCRIPT} ${TARGET_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_TARGET}" | tr -s " "
${PKG_CONFIGURE_SCRIPT} ${TARGET_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_TARGET}
;;
"configure:host"|"autotools:host")
2019-06-16 01:45:52 +00:00
echo "Executing (host): ${PKG_CONFIGURE_SCRIPT} ${HOST_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_HOST}" | tr -s " "
${PKG_CONFIGURE_SCRIPT} ${HOST_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_HOST}
;;
"configure:init"|"autotools:init")
2019-06-16 01:45:52 +00:00
echo "Executing (init): ${PKG_CONFIGURE_SCRIPT} ${INIT_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_INIT}" | tr -s " "
${PKG_CONFIGURE_SCRIPT} ${INIT_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_INIT}
;;
"configure:bootstrap"|"autotools:bootstrap")
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): ${PKG_CONFIGURE_SCRIPT} ${BOOTSTRAP_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_BOOTSTRAP}" | tr -s " "
${PKG_CONFIGURE_SCRIPT} ${BOOTSTRAP_CONFIGURE_OPTS} ${PKG_CONFIGURE_OPTS_BOOTSTRAP}
;;
esac
fi
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
pkg_call_exists post_configure_${TARGET} && pkg_call post_configure_${TARGET}
# make
2019-06-16 01:45:52 +00:00
pkg_call_exists pre_make_${TARGET} && pkg_call pre_make_${TARGET}
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
if pkg_call_exists make_${TARGET}; then
pkg_call make_${TARGET}
else
2019-06-16 01:45:52 +00:00
case "${PKG_TOOLCHAIN}:${TARGET}" in
# ninja based builds
"meson:target"|"cmake:target"|"ninja:target")
2019-06-16 01:45:52 +00:00
echo "Executing (target): ninja ${PKG_MAKE_OPTS_TARGET}" | tr -s " "
ninja ${NINJA_OPTS} ${PKG_MAKE_OPTS_TARGET}
;;
"meson:host"|"cmake:host"|"ninja:host")
2019-06-16 01:45:52 +00:00
echo "Executing (host): ninja ${PKG_MAKE_OPTS_HOST}" | tr -s " "
ninja ${NINJA_OPTS} ${PKG_MAKE_OPTS_HOST}
;;
"meson:init"|"cmake:init"|"ninja:init")
2019-06-16 01:45:52 +00:00
echo "Executing (init): ninja ${PKG_MAKE_OPTS_INIT}" | tr -s " "
ninja ${NINJA_OPTS} ${PKG_MAKE_OPTS_INIT}
;;
"meson:bootstrap"|"cmake:bootstrap"|"ninja:bootstrap")
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): ninja ${PKG_MAKE_OPTS_BOOTSTRAP}" | tr -s " "
ninja ${NINJA_OPTS} ${PKG_MAKE_OPTS_BOOTSTRAP}
;;
# make based builds
"configure:target"|"cmake-make:target"|"autotools:target"|"make:target")
2019-06-16 01:45:52 +00:00
echo "Executing (target): make ${PKG_MAKE_OPTS_TARGET}" | tr -s " "
make ${PKG_MAKE_OPTS_TARGET}
;;
"configure:host"|"cmake-make:host"|"autotools:host"|"make:host")
2019-06-16 01:45:52 +00:00
echo "Executing (host): make ${PKG_MAKE_OPTS_HOST}" | tr -s " "
make ${PKG_MAKE_OPTS_HOST}
;;
"configure:init"|"cmake-make:init"|"autotools:init"|"make:init")
2019-06-16 01:45:52 +00:00
echo "Executing (init): make ${PKG_MAKE_OPTS_INIT}" | tr -s " "
make ${PKG_MAKE_OPTS_INIT}
;;
"configure:bootstrap"|"cmake-make:bootstrap"|"autotools:bootstrap"|"make:bootstrap")
2019-06-16 01:45:52 +00:00
echo "Executing (bootstrap): make ${PKG_MAKE_OPTS_BOOTSTRAP}" | tr -s " "
make ${PKG_MAKE_OPTS_BOOTSTRAP}
;;
esac
fi
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
pkg_call_exists post_make_${TARGET} && pkg_call post_make_${TARGET}
2009-03-18 12:02:53 +00:00
# Hack around directly writing/modifying the content of a shared sysroot
# by temporarily installing new files to a package specific sysroot
PKG_ORIG_SYSROOT_PREFIX="${SYSROOT_PREFIX}"
export SYSROOT_PREFIX="${BUILD}/.sysroot/${PKG_NAME}.${TARGET}"
rm -rf "${SYSROOT_PREFIX}"
2019-02-22 20:11:11 +00:00
# Create common sysroot directories as some packages expect them to exist.
# TODO: Fix those packages so we don't need to pre-create directories.
for d in /usr/lib /usr/include /usr/bin /usr/lib/pkgconfig; do
mkdir -p "${SYSROOT_PREFIX}${d}"
done
# make install
2019-06-16 01:45:52 +00:00
pkg_call_exists pre_makeinstall_${TARGET} && pkg_call pre_makeinstall_${TARGET}
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
if pkg_call_exists makeinstall_${TARGET}; then
pkg_call makeinstall_${TARGET}
else
flag_enabled "sysroot" "yes" && INSTALL_TO_SYSROOT="yes" || INSTALL_TO_SYSROOT="no"
2019-06-16 01:45:52 +00:00
case "${PKG_TOOLCHAIN}:${TARGET}" in
# ninja based builds
"meson:target"|"cmake:target")
[ "${INSTALL_TO_SYSROOT}" = "yes" ] && \
DESTDIR=${SYSROOT_PREFIX} ninja install ${PKG_MAKEINSTALL_OPTS_TARGET}
2019-06-16 01:45:52 +00:00
DESTDIR=${INSTALL} ninja install ${PKG_MAKEINSTALL_OPTS_TARGET}
;;
"meson:host"|"cmake:host")
2019-06-16 01:45:52 +00:00
ninja install ${PKG_MAKEINSTALL_OPTS_HOST}
;;
"meson:init"|"cmake:init")
2019-06-16 01:45:52 +00:00
DESTDIR=${INSTALL} ninja install ${PKG_MAKEINSTALL_OPTS_INIT}
;;
"meson:bootstrap"|"cmake:bootstrap")
2019-06-16 01:45:52 +00:00
ninja install ${PKG_MAKEINSTALL_OPTS_BOOTSTRAP}
;;
# make based builds
"configure:target"|"cmake-make:target"|"autotools:target"|"make:target")
[ "${INSTALL_TO_SYSROOT}" = "yes" ] && \
make install DESTDIR=${SYSROOT_PREFIX} -j1 ${PKG_MAKEINSTALL_OPTS_TARGET}
2019-06-16 01:45:52 +00:00
make install DESTDIR=${INSTALL} ${PKG_MAKEINSTALL_OPTS_TARGET}
;;
"configure:host"|"cmake-make:host"|"autotools:host"|"make:host")
2019-06-16 01:45:52 +00:00
make install ${PKG_MAKEINSTALL_OPTS_HOST}
;;
"configure:init"|"cmake-make:init"|"autotools:init"|"make:init")
2019-06-16 01:45:52 +00:00
make install DESTDIR=${INSTALL} ${PKG_MAKEINSTALL_OPTS_INIT}
;;
"configure:bootstrap"|"cmake-make:bootstrap"|"autotools:bootstrap"|"make:bootstrap")
2019-06-16 01:45:52 +00:00
make install ${PKG_MAKEINSTALL_OPTS_BOOTSTRAP}
;;
esac
fi
2018-11-28 14:58:22 +00:00
2019-06-16 01:45:52 +00:00
pkg_call_exists post_makeinstall_${TARGET} && pkg_call post_makeinstall_${TARGET}
2017-05-01 01:45:00 +00:00
# Fixup temporary sysroot references to the shared sysroot
for i in $(find "${SYSROOT_PREFIX}/usr/lib" -type f -name "*.la" 2>/dev/null); do
sed -e "s:\(['= ]\)/usr:\\1${PKG_ORIG_SYSROOT_PREFIX}/usr:g" -i "${i}"
done
for i in $(find "${SYSROOT_PREFIX}/usr/bin" -type f -name "*-config" 2>/dev/null); do
sed -e "s#${SYSROOT_PREFIX}/usr#${PKG_ORIG_SYSROOT_PREFIX}/usr#g" -i "${i}"
done
for i in $(find "${SYSROOT_PREFIX}/usr/lib" -type f -name "*.pc" 2>/dev/null); do
sed -e "s#${SYSROOT_PREFIX}/usr#${PKG_ORIG_SYSROOT_PREFIX}/usr#g" -i "${i}"
done
for i in $(find "${SYSROOT_PREFIX}/usr"/{lib,share} -type f -name "*.cmake" 2>/dev/null); do
sed -e "s#${SYSROOT_PREFIX}/usr#${PKG_ORIG_SYSROOT_PREFIX}/usr#g" -i "${i}"
done
for i in $(find "${SYSROOT_PREFIX}" -type l 2>/dev/null); do
_tmp="$(readlink -m "${i}")"
2019-07-04 19:00:29 +00:00
[[ ${_tmp} =~ ^/usr ]] && _tmp="${SYSROOT_PREFIX}${_tmp}"
if [[ ${_tmp} =~ ^${SYSROOT_PREFIX}/ ]]; then
ln -sfn "${_tmp/${SYSROOT_PREFIX}\//${PKG_ORIG_SYSROOT_PREFIX}\/}" "${i}"
fi
done
# Transfer the new sysroot content to the shared sysroot
acquire_update_lock sysroot
mkdir -p "${PKG_ORIG_SYSROOT_PREFIX}"
2019-03-09 22:02:33 +00:00
cp -PRf "${SYSROOT_PREFIX}"/* "${PKG_ORIG_SYSROOT_PREFIX}"
release_update_lock
rm -rf "${SYSROOT_PREFIX}"
export SYSROOT_PREFIX="${PKG_ORIG_SYSROOT_PREFIX}"
2019-06-16 01:45:52 +00:00
if [ "${TARGET}" = "target" -o "${TARGET}" = "init" ]; then
if [ -d ${INSTALL} ]; then
rm -rf ${INSTALL}/{usr/local/,usr/,}man
rm -rf ${INSTALL}/{usr/local/,usr/,}share/bash-completion
rm -rf ${INSTALL}/{usr/local/,usr/,}share/doc
rm -rf ${INSTALL}/{usr/local/,usr/,}share/gtk-doc
rm -rf ${INSTALL}/{usr/local/,usr/,}share/info
rm -rf ${INSTALL}/{usr/local/,usr/,}share/locale
rm -rf ${INSTALL}/{usr/local/,usr/,}share/man
rm -rf ${INSTALL}/{usr/local/,usr/,}share/zsh
rm -rf ${INSTALL}/{usr/local/,usr/,}var
2019-06-16 01:45:52 +00:00
find ${INSTALL} \( -name "*.orig" \
-o -name "*.rej" \
-o -name "*.o" \
-o -name "*.in" \
-o -name ".git*" \) \
-exec rm -f {} \; 2>/dev/null || :
2019-06-16 01:45:52 +00:00
find ${INSTALL} -type d -exec rmdir -p {} \; 2>/dev/null || :
python_fix_abi "${INSTALL}"
if [ ! "${BUILD_WITH_DEBUG}" = "yes" ]; then
2019-06-16 01:45:52 +00:00
${STRIP} $(find ${INSTALL} \
-type f -name "*.so*" \
! -name "ld-*.so" \
! -name "libc-*.so" \
! -name "libpthread-*.so" \
! -name "libthread_db-*so" \
2>/dev/null) 2>/dev/null || :
2019-06-16 01:45:52 +00:00
if [ "${TARGET}" = "init" ]; then
${STRIP} $(find ${INSTALL} -type f -name "*.so*" 2>/dev/null) 2>/dev/null || :
fi
2019-06-16 01:45:52 +00:00
${STRIP} $(find ${INSTALL} ! -name "*.so*" ! -name "*.ko" \
-type f -executable 2>/dev/null) 2>/dev/null || :
2017-05-01 01:45:00 +00:00
fi
fi
fi
if [ -n "${INSTALL}" -a -d "${INSTALL}" ]; then
echo "INFO_PKG_NAME=\"${PKG_NAME}\"" > "${INSTALL}/.libreelec-package"
fi
2019-06-16 01:45:52 +00:00
cd ${ROOT}
PKG_DEEPHASH=$(calculate_stamp)
for i in PKG_NAME PKG_DEEPHASH BUILD_WITH_DEBUG; do
2019-06-16 01:45:52 +00:00
echo "STAMP_${i}=\"${!i}\"" >> ${STAMP}
done
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "built"