2013-07-19 00:35:52 +00:00
|
|
|
#!/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)
|
2018-11-02 22:24:35 +00:00
|
|
|
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
2011-01-09 20:26:03 +00:00
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
. config/options "$1"
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2019-02-08 17:17:43 +00:00
|
|
|
die "usage: $0 package_name[:<host|target|init|bootstrap>] [parent_pkg]"
|
2018-12-18 03:43:28 +00:00
|
|
|
fi
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2018-02-22 12:11:39 +00:00
|
|
|
if [ "$1" = "--all" ]; then
|
2018-11-02 22:24:35 +00:00
|
|
|
if [ -n "$2" ]; then
|
2018-02-22 12:11:39 +00:00
|
|
|
for build_dir in $(ls -1d ${ROOT}/build.*); do
|
2018-12-18 03:43:28 +00:00
|
|
|
load_build_config ${build_dir} && ${SCRIPTS}/build "$2"
|
2018-02-22 12:11:39 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
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
|
|
|
|
|
2018-12-18 03:43:28 +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
|
|
|
|
|
2017-10-09 04:25:52 +00:00
|
|
|
if [ "${1//:/}" != "${1}" ]; then
|
|
|
|
PACKAGE_NAME="${1%:*}"
|
|
|
|
TARGET="${1#*:}"
|
|
|
|
else
|
2019-02-08 17:17:43 +00:00
|
|
|
PACKAGE_NAME="${1}"
|
2017-10-09 04:25:52 +00:00
|
|
|
TARGET=
|
|
|
|
fi
|
2018-11-02 22:24:35 +00:00
|
|
|
TARGET="${TARGET:-target}"
|
2019-02-08 17:17:43 +00:00
|
|
|
PARENT_PKG="${2:-${PKG_NAME}:${TARGET}}"
|
|
|
|
|
|
|
|
pkg_lock "${PACKAGE_NAME}:${TARGET}" "build" "${PARENT_PKG}"
|
2013-07-17 04:12:14 +00:00
|
|
|
|
|
|
|
mkdir -p $STAMPS/$PACKAGE_NAME
|
|
|
|
STAMP=$STAMPS/$PACKAGE_NAME/build_$TARGET
|
2018-12-18 03:43:28 +00:00
|
|
|
if [ -f $STAMP ]; then
|
2015-08-02 20:59:29 +00:00
|
|
|
. $STAMP
|
2018-04-02 09:09:11 +00:00
|
|
|
PKG_DEEPHASH=$(calculate_stamp)
|
2018-11-02 22:24:35 +00:00
|
|
|
if [ ! "$PKG_DEEPHASH" = "$STAMP_PKG_DEEPHASH" ]; then
|
2015-08-02 20:59:29 +00:00
|
|
|
rm -f $STAMP
|
2018-11-02 22:24:35 +00:00
|
|
|
elif [ ! "$BUILD_WITH_DEBUG" = "$STAMP_BUILD_WITH_DEBUG" ]; then
|
2018-02-19 07:08:48 +00:00
|
|
|
rm -f $STAMP
|
2019-02-08 17:17:43 +00:00
|
|
|
elif [ "${PKG_NAME}" = "u-boot" -a ! "$UBOOT_SYSTEM" = "$STAMP_UBOOT_SYSTEM" ]; then
|
2017-05-01 01:45:00 +00:00
|
|
|
rm -f $STAMP
|
2018-12-18 03:43:28 +00:00
|
|
|
else
|
|
|
|
# stamp matched: already built, do nothing
|
2019-02-08 17:17:43 +00:00
|
|
|
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "already built"
|
2018-12-18 03:43:28 +00:00
|
|
|
exit 0
|
2017-05-01 01:45:00 +00:00
|
|
|
fi
|
2009-03-18 12:02:53 +00:00
|
|
|
fi
|
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
$SCRIPTS/unpack $PACKAGE_NAME
|
|
|
|
|
|
|
|
# build dependencies, only when PKG_DEPENDS_? is filled
|
|
|
|
unset _pkg_depends
|
|
|
|
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
|
|
|
|
for p in $_pkg_depends; do
|
2019-02-08 17:17:43 +00:00
|
|
|
$SCRIPTS/build "${p}" "${PARENT_PKG}"
|
2018-12-18 03:43:28 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# virtual packages are not built as they only contain dependencies, so dont go further here
|
|
|
|
if [ "$PKG_SECTION" = "virtual" ]; then
|
|
|
|
PKG_DEEPHASH=$(calculate_stamp)
|
|
|
|
for i in PKG_NAME PKG_DEEPHASH BUILD_WITH_DEBUG; do
|
|
|
|
echo "STAMP_$i=\"${!i}\"" >> $STAMP
|
|
|
|
done
|
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "built"
|
2017-10-27 16:39:14 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
# build this package
|
|
|
|
if [ "${BUILD_WITH_DEBUG}" = "yes" ]; then
|
|
|
|
build_msg "CLR_BUILD" "BUILD" "${PACKAGE_NAME} $(print_color "CLR_TARGET" "(${TARGET})") [DEBUG]" "indent"
|
|
|
|
else
|
|
|
|
build_msg "CLR_BUILD" "BUILD" "${PACKAGE_NAME} $(print_color "CLR_TARGET" "(${TARGET})")" "indent"
|
|
|
|
fi
|
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
setup_toolchain $TARGET
|
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
# configure install directory
|
|
|
|
if [ "$TARGET" = "target" ]; then
|
|
|
|
INSTALL="$PKG_BUILD/.install_pkg"
|
|
|
|
elif [ "$TARGET" = "init" ]; then
|
|
|
|
INSTALL="$PKG_BUILD/.install_init"
|
|
|
|
else
|
|
|
|
unset INSTALL
|
|
|
|
fi
|
|
|
|
# remove previous install files
|
|
|
|
if [ -n "$INSTALL" -a -d "$INSTALL" ]; then
|
|
|
|
rm -rf "$INSTALL"
|
|
|
|
fi
|
2017-10-27 16:39:14 +00:00
|
|
|
|
2018-02-19 07:08:48 +00:00
|
|
|
# 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
|
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
CMAKE_GENERATOR_NINJA="-GNinja \
|
|
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
# configure TARGET build defaults
|
|
|
|
TARGET_CONFIGURE_OPTS="--host=$TARGET_NAME \
|
|
|
|
--build=$HOST_NAME \
|
|
|
|
--prefix=/usr \
|
2017-10-07 19:32:39 +00:00
|
|
|
--bindir=/usr/bin \
|
|
|
|
--sbindir=/usr/sbin \
|
|
|
|
--sysconfdir=/etc \
|
|
|
|
--libdir=/usr/lib \
|
|
|
|
--libexecdir=/usr/lib \
|
|
|
|
--localstatedir=/var \
|
2017-10-27 16:39:14 +00:00
|
|
|
--disable-static \
|
|
|
|
--enable-shared"
|
|
|
|
|
|
|
|
TARGET_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=$CMAKE_CONF \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
|
|
-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 \
|
2018-03-20 21:11:25 +00:00
|
|
|
--buildtype=$MESON_BUILD_TYPE"
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
# configure HOST build defaults
|
|
|
|
HOST_CONFIGURE_OPTS="--host=$HOST_NAME \
|
|
|
|
--build=$HOST_NAME \
|
|
|
|
--prefix=$TOOLCHAIN \
|
2017-10-07 19:32:39 +00:00
|
|
|
--bindir=$TOOLCHAIN/bin \
|
|
|
|
--sbindir=$TOOLCHAIN/sbin \
|
|
|
|
--sysconfdir=$TOOLCHAIN/etc \
|
|
|
|
--libexecdir=$TOOLCHAIN/lib \
|
|
|
|
--localstatedir=$TOOLCHAIN/var \
|
2017-10-27 16:39:14 +00:00
|
|
|
--disable-static \
|
|
|
|
--enable-shared"
|
|
|
|
|
|
|
|
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 \
|
2018-03-20 21:11:25 +00:00
|
|
|
--buildtype=plain"
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
# configure INIT build defaults
|
|
|
|
INIT_CONFIGURE_OPTS="$TARGET_CONFIGURE_OPTS"
|
|
|
|
INIT_CMAKE_OPTS="$TARGET_CMAKE_OPTS"
|
|
|
|
INIT_MESON_OPTS="$TARGET_MESON_OPTS"
|
|
|
|
|
|
|
|
# configure BOOTSTRAP build defaults
|
|
|
|
BOOTSTRAP_CONFIGURE_OPTS="$HOST_CONFIGURE_OPTS"
|
|
|
|
BOOTSTRAP_CMAKE_OPTS="$HOST_CMAKE_OPTS"
|
|
|
|
BOOTSTRAP_MESON_OPTS="$HOST_MESON_OPTS"
|
|
|
|
|
2018-11-02 22:24:35 +00:00
|
|
|
# setup configure scripts
|
2018-12-18 03:43:28 +00:00
|
|
|
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}"
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
# auto detect toolchain
|
|
|
|
_auto_toolchain=""
|
|
|
|
if [ -z "$PKG_TOOLCHAIN" -o "$PKG_TOOLCHAIN" = "auto" ]; then
|
|
|
|
if [ -f "$PKG_MESON_SCRIPT" ]; then
|
|
|
|
PKG_TOOLCHAIN="meson"
|
2017-10-27 21:15:40 +00:00
|
|
|
elif [ -f "$PKG_CMAKE_SCRIPT" ]; then
|
2017-10-27 16:39:14 +00:00
|
|
|
PKG_TOOLCHAIN="cmake"
|
|
|
|
elif [ -f "$PKG_CONFIGURE_SCRIPT" ]; then
|
|
|
|
PKG_TOOLCHAIN="configure"
|
2018-11-02 22:24:35 +00:00
|
|
|
elif [ -f "$PKG_BUILD/Makefile" ]; then
|
2017-10-27 16:39:14 +00:00
|
|
|
PKG_TOOLCHAIN="make"
|
|
|
|
else
|
2018-11-02 22:24:35 +00:00
|
|
|
die "Not possible to detect toolchain automatically. Add PKG_TOOLCHAIN= to package.mk"
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
|
|
|
_auto_toolchain=" (auto-detect)"
|
|
|
|
fi
|
|
|
|
if ! listcontains "meson cmake cmake-make configure ninja make autotools manual" "$PKG_TOOLCHAIN"; then
|
2018-11-21 12:43:41 +00:00
|
|
|
die "$(print_color "CLR_ERROR" "ERROR:") unknown toolchain $PKG_TOOLCHAIN"
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
2018-11-19 05:14:10 +00:00
|
|
|
build_msg "CLR_TOOLCHAIN" "TOOLCHAIN" "${PKG_TOOLCHAIN}${_auto_toolchain}"
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
# make autoreconf
|
|
|
|
if [ "$PKG_TOOLCHAIN" = "autotools" ]; then
|
2019-02-08 17:17:43 +00:00
|
|
|
$SCRIPTS/autoreconf "${PACKAGE_NAME}" "${PARENT_PKG}"
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
pkg_lock_status "ACTIVE" "${PKG_NAME}:${TARGET}" "build"
|
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
# include build template and build
|
2019-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists pre_build_$TARGET && pkg_call pre_build_$TARGET
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
# ensure $PKG_BUILD is there. (installer? PKG_URL="")
|
2018-11-02 22:24:35 +00:00
|
|
|
if [ ! -d "$PKG_BUILD" ] ; then
|
|
|
|
mkdir -p "$PKG_BUILD"
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-02 22:24:35 +00:00
|
|
|
cd "$PKG_BUILD"
|
2017-10-27 16:39:14 +00:00
|
|
|
|
|
|
|
if [ -f "$PKG_CONFIGURE_SCRIPT" -o -f "$PKG_CMAKE_SCRIPT" -o -f "$PKG_MESON_SCRIPT" ]; then
|
|
|
|
case "$TARGET" in
|
2018-03-20 21:11:25 +00:00
|
|
|
"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" ;;
|
2017-10-27 16:39:14 +00:00
|
|
|
esac
|
2018-11-02 22:24:35 +00:00
|
|
|
mkdir -p "$PKG_REAL_BUILD"
|
|
|
|
cd "$PKG_REAL_BUILD"
|
|
|
|
|
2018-03-20 21:11:25 +00:00
|
|
|
MESON_CONF="$PKG_REAL_BUILD/meson.conf"
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# configure
|
2019-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists pre_configure_$TARGET && pkg_call pre_configure_$TARGET
|
2018-11-28 14:58:22 +00:00
|
|
|
|
2019-01-21 13:15:11 +00:00
|
|
|
if pkg_call_exists configure_$TARGET; then
|
|
|
|
pkg_call configure_$TARGET
|
|
|
|
else
|
2017-10-27 16:39:14 +00:00
|
|
|
case "$PKG_TOOLCHAIN:$TARGET" in
|
|
|
|
# meson builds
|
|
|
|
"meson:target")
|
2018-03-20 21:11:25 +00:00
|
|
|
create_meson_conf $TARGET $MESON_CONF
|
|
|
|
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)
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:host")
|
2018-03-20 21:11:25 +00:00
|
|
|
create_meson_conf $TARGET $MESON_CONF
|
|
|
|
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)
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:init")
|
2018-03-20 21:11:25 +00:00
|
|
|
create_meson_conf $TARGET $MESON_CONF
|
|
|
|
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)
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:bootstrap")
|
2018-03-20 21:11:25 +00:00
|
|
|
create_meson_conf $TARGET $MESON_CONF
|
|
|
|
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)
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
# cmake builds with ninja
|
|
|
|
"cmake:target")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
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-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists post_configure_$TARGET && pkg_call post_configure_$TARGET
|
2013-07-17 04:12:14 +00:00
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
# make
|
2019-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists pre_make_$TARGET && pkg_call pre_make_$TARGET
|
2018-11-28 14:58:22 +00:00
|
|
|
|
2019-01-21 13:15:11 +00:00
|
|
|
if pkg_call_exists make_$TARGET; then
|
|
|
|
pkg_call make_$TARGET
|
|
|
|
else
|
2017-10-27 16:39:14 +00:00
|
|
|
case "$PKG_TOOLCHAIN:$TARGET" in
|
|
|
|
# ninja based builds
|
|
|
|
"meson:target"|"cmake:target"|"ninja:target")
|
|
|
|
echo "Executing (target): ninja $PKG_MAKE_OPTS_TARGET" | tr -s " "
|
2018-02-23 13:02:16 +00:00
|
|
|
ninja $NINJA_OPTS $PKG_MAKE_OPTS_TARGET
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:host"|"cmake:host"|"ninja:host")
|
|
|
|
echo "Executing (host): ninja $PKG_MAKE_OPTS_HOST" | tr -s " "
|
2018-02-23 13:02:16 +00:00
|
|
|
ninja $NINJA_OPTS $PKG_MAKE_OPTS_HOST
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:init"|"cmake:init"|"ninja:init")
|
|
|
|
echo "Executing (init): ninja $PKG_MAKE_OPTS_INIT" | tr -s " "
|
2018-02-23 13:02:16 +00:00
|
|
|
ninja $NINJA_OPTS $PKG_MAKE_OPTS_INIT
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
"meson:bootstrap"|"cmake:bootstrap"|"ninja:bootstrap")
|
|
|
|
echo "Executing (bootstrap): ninja $PKG_MAKE_OPTS_BOOTSTRAP" | tr -s " "
|
2018-02-23 13:02:16 +00:00
|
|
|
ninja $NINJA_OPTS $PKG_MAKE_OPTS_BOOTSTRAP
|
2017-10-27 16:39:14 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
# make based builds
|
|
|
|
"configure:target"|"cmake-make:target"|"autotools:target"|"make:target")
|
|
|
|
echo "Executing (target): make $PKG_MAKE_OPTS_TARGET" | tr -s " "
|
|
|
|
make $PKG_MAKE_OPTS_TARGET
|
|
|
|
;;
|
|
|
|
"configure:host"|"cmake-make:host"|"autotools:host"|"make:host")
|
|
|
|
echo "Executing (host): make $PKG_MAKE_OPTS_HOST" | tr -s " "
|
|
|
|
make $PKG_MAKE_OPTS_HOST
|
|
|
|
;;
|
|
|
|
"configure:init"|"cmake-make:init"|"autotools:init"|"make:init")
|
|
|
|
echo "Executing (init): make $PKG_MAKE_OPTS_INIT" | tr -s " "
|
|
|
|
make $PKG_MAKE_OPTS_INIT
|
|
|
|
;;
|
|
|
|
"configure:bootstrap"|"cmake-make:bootstrap"|"autotools:bootstrap"|"make:bootstrap")
|
|
|
|
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-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists post_make_$TARGET && pkg_call post_make_$TARGET
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
# make install writes directly to sysroot which then needs fixing up - this is racy
|
|
|
|
if listcontains "configure:target cmake-make:target autotools:target make:target" "${PKG_TOOLCHAIN}:${TARGET}"; then
|
|
|
|
acquire_exclusive_lock "${PKG_NAME}:${TARGET}" "build"
|
|
|
|
PKG_NEED_UNLOCK=yes
|
|
|
|
else
|
|
|
|
PKG_NEED_UNLOCK=no
|
|
|
|
fi
|
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
# make install
|
2019-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists pre_makeinstall_$TARGET && pkg_call pre_makeinstall_$TARGET
|
2018-11-28 14:58:22 +00:00
|
|
|
|
2019-01-21 13:15:11 +00:00
|
|
|
if pkg_call_exists makeinstall_$TARGET; then
|
|
|
|
pkg_call makeinstall_$TARGET
|
|
|
|
else
|
2017-10-27 16:39:14 +00:00
|
|
|
case "$PKG_TOOLCHAIN:$TARGET" in
|
|
|
|
# ninja based builds
|
|
|
|
"meson:target"|"cmake:target")
|
|
|
|
DESTDIR=$SYSROOT_PREFIX ninja install $PKG_MAKEINSTALL_OPTS_TARGET
|
|
|
|
DESTDIR=$INSTALL ninja install $PKG_MAKEINSTALL_OPTS_TARGET
|
|
|
|
;;
|
|
|
|
"meson:host"|"cmake:host")
|
|
|
|
ninja install $PKG_MAKEINSTALL_OPTS_HOST
|
|
|
|
;;
|
|
|
|
"meson:init"|"cmake:init")
|
|
|
|
DESTDIR=$INSTALL ninja install $PKG_MAKEINSTALL_OPTS_INIT
|
|
|
|
;;
|
|
|
|
"meson:bootstrap"|"cmake:bootstrap")
|
|
|
|
ninja install $PKG_MAKEINSTALL_OPTS_BOOTSTRAP
|
|
|
|
;;
|
|
|
|
|
|
|
|
# make based builds
|
|
|
|
"configure:target"|"cmake-make:target"|"autotools:target"|"make:target")
|
2019-02-08 17:17:43 +00:00
|
|
|
make install DESTDIR=$SYSROOT_PREFIX -j1 $PKG_MAKEINSTALL_OPTS_TARGET
|
2017-10-27 16:39:14 +00:00
|
|
|
make install DESTDIR=$INSTALL $PKG_MAKEINSTALL_OPTS_TARGET
|
|
|
|
;;
|
|
|
|
"configure:host"|"cmake-make:host"|"autotools:host"|"make:host")
|
|
|
|
make install $PKG_MAKEINSTALL_OPTS_HOST
|
|
|
|
;;
|
|
|
|
"configure:init"|"cmake-make:init"|"autotools:init"|"make:init")
|
|
|
|
make install DESTDIR=$INSTALL $PKG_MAKEINSTALL_OPTS_INIT
|
|
|
|
;;
|
|
|
|
"configure:bootstrap"|"cmake-make:bootstrap"|"autotools:bootstrap"|"make:bootstrap")
|
|
|
|
make install $PKG_MAKEINSTALL_OPTS_BOOTSTRAP
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2018-11-28 14:58:22 +00:00
|
|
|
|
2019-01-21 13:15:11 +00:00
|
|
|
pkg_call_exists post_makeinstall_$TARGET && pkg_call post_makeinstall_$TARGET
|
2017-05-01 01:45:00 +00:00
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
# This is the racy part - one or more processes may be creating, modifying or deleting
|
|
|
|
# $SYSROOT_PREFIX/usr/lib/*.la files while another (eg. this) process is rewriting the same
|
|
|
|
# files as it fixes up the libdir prefix. Eugh.
|
|
|
|
for i in $(find $SYSROOT_PREFIX/usr/lib/ -name "*.la" 2>/dev/null); do
|
|
|
|
sed -e "s:\(['= ]\)/usr:\\1$SYSROOT_PREFIX/usr:g" -i $i
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "${PKG_NEED_UNLOCK}" = "yes" ] && release_exclusive_lock "${PKG_NAME}:${TARGET}" "build" || true
|
|
|
|
|
2017-10-27 16:39:14 +00:00
|
|
|
if [ "$TARGET" = "target" -o "$TARGET" = "init" ]; then
|
2018-11-02 22:24:35 +00:00
|
|
|
if [ -d $INSTALL ]; then
|
2017-10-27 16:39:14 +00:00
|
|
|
rm -rf $INSTALL/{usr/,}include
|
|
|
|
rm -rf $INSTALL/{usr/,}lib/cmake
|
|
|
|
rm -rf $INSTALL/{usr/,}lib/pkgconfig
|
|
|
|
rm -rf $INSTALL/{usr/,}man
|
|
|
|
rm -rf $INSTALL/{usr/,}share/aclocal
|
|
|
|
rm -rf $INSTALL/{usr/,}share/bash-completion
|
|
|
|
rm -rf $INSTALL/{usr/,}share/doc
|
|
|
|
rm -rf $INSTALL/{usr/,}share/gtk-doc
|
|
|
|
rm -rf $INSTALL/{usr/,}share/info
|
|
|
|
rm -rf $INSTALL/{usr/,}share/locale
|
|
|
|
rm -rf $INSTALL/{usr/,}share/man
|
|
|
|
rm -rf $INSTALL/{usr/,}share/pkgconfig
|
|
|
|
rm -rf $INSTALL/{usr/,}share/zsh
|
|
|
|
rm -rf $INSTALL/{usr/,}var
|
|
|
|
find $INSTALL \( -name "*.orig" \
|
|
|
|
-o -name "*.rej" \
|
|
|
|
-o -name "*.a" \
|
|
|
|
-o -name "*.la" \
|
|
|
|
-o -name "*.o" \
|
|
|
|
-o -name "*.in" \
|
|
|
|
-o -name ".git*" \) \
|
|
|
|
-exec rm -f {} \; 2>/dev/null || :
|
|
|
|
find $INSTALL -type d -exec rmdir -p {} \; 2>/dev/null || :
|
|
|
|
|
2018-02-19 07:08:48 +00:00
|
|
|
if [ ! "${BUILD_WITH_DEBUG}" = "yes" ]; then
|
2018-11-02 22:24:35 +00:00
|
|
|
$STRIP $(find $INSTALL \
|
2017-10-27 16:39:14 +00:00
|
|
|
-type f -name "*.so*" \
|
|
|
|
! -name "ld-*.so" \
|
|
|
|
! -name "libc-*.so" \
|
|
|
|
! -name "libpthread-*.so" \
|
|
|
|
! -name "libthread_db-*so" \
|
2018-11-02 22:24:35 +00:00
|
|
|
2>/dev/null) 2>/dev/null || :
|
2017-10-27 16:39:14 +00:00
|
|
|
if [ "$TARGET" = "init" ]; then
|
2018-11-02 22:24:35 +00:00
|
|
|
$STRIP $(find $INSTALL -type f -name "*.so*" 2>/dev/null) 2>/dev/null || :
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
2018-11-02 22:24:35 +00:00
|
|
|
$STRIP $(find $INSTALL/bin $INSTALL/usr/bin $INSTALL/sbin $INSTALL/usr/sbin \
|
|
|
|
-type f -executable 2>/dev/null) 2>/dev/null || :
|
2017-05-01 01:45:00 +00:00
|
|
|
fi
|
2017-10-27 16:39:14 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $ROOT
|
|
|
|
|
2018-04-02 09:09:11 +00:00
|
|
|
PKG_DEEPHASH=$(calculate_stamp)
|
|
|
|
for i in PKG_NAME PKG_DEEPHASH BUILD_WITH_DEBUG; do
|
2017-10-27 16:39:14 +00:00
|
|
|
echo "STAMP_$i=\"${!i}\"" >> $STAMP
|
|
|
|
done
|
2019-02-08 17:17:43 +00:00
|
|
|
if [ "${PKG_NAME}" = "u-boot" ]; then
|
2017-10-27 16:39:14 +00:00
|
|
|
echo "STAMP_UBOOT_SYSTEM=\"${UBOOT_SYSTEM}\"" >> $STAMP
|
2009-03-18 12:02:53 +00:00
|
|
|
fi
|
2019-02-08 17:17:43 +00:00
|
|
|
|
|
|
|
pkg_lock_status "UNLOCK" "${PKG_NAME}:${TARGET}" "build" "built"
|