2014-04-09 16:40:27 +02:00
|
|
|
# vim: set ts=4 sw=4 et:
|
2014-03-22 12:31:42 +01:00
|
|
|
|
|
|
|
run_func() {
|
2014-12-11 11:02:22 +01:00
|
|
|
local func="$1" desc="$2" funcname="$3" restoretrap= logpipe= logfile= teepid=
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-12-11 11:02:22 +01:00
|
|
|
: ${funcname:=$func}
|
|
|
|
|
|
|
|
logpipe=$(mktemp -u --tmpdir=${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe)
|
|
|
|
logfile=${XBPS_STATEDIR}/${pkgname}_${XBPS_CROSS_BUILD}_${funcname}.log
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
msg_normal "${pkgver:-xbps-src}: running ${desc:-${func}} ...\n"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
set -E
|
|
|
|
restoretrap=$(trap -p ERR)
|
2014-12-11 11:02:22 +01:00
|
|
|
trap 'error_func $funcname $LINENO' ERR
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
mkfifo "$logpipe"
|
|
|
|
tee "$logfile" < "$logpipe" &
|
|
|
|
teepid=$!
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
$func &>"$logpipe"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
wait $teepid
|
|
|
|
rm "$logpipe"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
eval "$restoretrap"
|
|
|
|
set +E
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
error_func() {
|
2014-04-09 16:40:27 +02:00
|
|
|
if [ -n "$1" -a -n "$2" ]; then
|
|
|
|
msg_red "$pkgver: failed to run $1() at line $2.\n"
|
|
|
|
fi
|
2015-03-20 09:17:40 +01:00
|
|
|
exit 1
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2015-03-01 16:06:30 +01:00
|
|
|
exit_and_cleanup() {
|
|
|
|
local rval=$1
|
|
|
|
|
2015-03-01 16:45:16 +01:00
|
|
|
if [ -n "$XBPS_TEMP_MASTERDIR" -a "$XBPS_TEMP_MASTERDIR" != "1" ]; then
|
|
|
|
rm -rf "$XBPS_TEMP_MASTERDIR"
|
2015-03-01 16:06:30 +01:00
|
|
|
fi
|
|
|
|
exit ${rval:=0}
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
msg_red() {
|
2014-04-09 16:40:27 +02:00
|
|
|
# error messages in bold/red
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
|
|
|
printf >&2 "=> ERROR: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_red_nochroot() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
|
|
|
printf >&2 "$@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_error() {
|
2014-04-09 16:40:27 +02:00
|
|
|
msg_red "$@"
|
|
|
|
exit 1
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_warn() {
|
2014-04-09 16:40:27 +02:00
|
|
|
# warn messages in bold/yellow
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
|
|
|
printf >&2 "=> WARNING: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_warn_nochroot() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
|
|
|
printf >&2 "=> WARNING: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_normal() {
|
2014-04-09 16:40:27 +02:00
|
|
|
# normal messages in bold
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
|
|
|
printf "=> $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_normal_append() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
|
|
|
printf "$@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set_build_options() {
|
2015-02-16 10:48:21 +01:00
|
|
|
local f j opt optval _optsset pkgopts _pkgname
|
|
|
|
local -A options
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -z "$build_options" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2015-03-23 17:57:23 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
for f in ${build_options}; do
|
2014-07-19 10:39:22 +02:00
|
|
|
_pkgname=${pkgname//\-/\_}
|
|
|
|
eval pkgopts="\$XBPS_PKG_OPTIONS_${_pkgname}"
|
2014-06-30 11:32:07 +02:00
|
|
|
if [ -z "$pkgopts" -o "$pkgopts" = "" ]; then
|
|
|
|
pkgopts=${XBPS_PKG_OPTIONS}
|
|
|
|
fi
|
2014-04-09 16:40:27 +02:00
|
|
|
OIFS="$IFS"; IFS=','
|
2014-06-30 11:32:07 +02:00
|
|
|
for j in ${pkgopts}; do
|
2014-04-09 16:40:27 +02:00
|
|
|
opt=${j#\~}
|
|
|
|
opt_disabled=${j:0:1}
|
|
|
|
if [ "$opt" = "$f" ]; then
|
|
|
|
if [ "$opt_disabled" != "~" ]; then
|
2014-06-30 11:32:07 +02:00
|
|
|
eval options[$opt]=1
|
2014-04-09 16:40:27 +02:00
|
|
|
else
|
2014-06-30 11:32:07 +02:00
|
|
|
eval options[$opt]=0
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$OIFS"
|
|
|
|
done
|
|
|
|
|
|
|
|
for f in ${build_options_default}; do
|
|
|
|
optval=${options[$f]}
|
|
|
|
if [[ -z "$optval" ]] || [[ $optval -eq 1 ]]; then
|
|
|
|
options[$f]=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Prepare final options.
|
|
|
|
for f in ${!options[@]}; do
|
|
|
|
optval=${options[$f]}
|
|
|
|
if [[ $optval -eq 1 ]]; then
|
2015-02-16 10:48:21 +01:00
|
|
|
eval export build_option_${f}=1
|
2015-03-18 16:14:51 +01:00
|
|
|
else
|
|
|
|
eval unset build_option_${f}
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Re-read pkg template to get conditional vars.
|
|
|
|
if [ -z "$XBPS_BUILD_OPTIONS_PARSED" ]; then
|
|
|
|
source_file $XBPS_SRCPKGDIR/$pkgname/template
|
|
|
|
XBPS_BUILD_OPTIONS_PARSED=1
|
|
|
|
unset PKG_BUILD_OPTIONS
|
|
|
|
set_build_options
|
2014-07-24 18:40:52 +02:00
|
|
|
unset XBPS_BUILD_OPTIONS_PARSED
|
2014-04-09 16:40:27 +02:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in ${build_options}; do
|
2014-06-30 11:32:07 +02:00
|
|
|
eval optval=${options[$f]}
|
2014-04-09 16:40:27 +02:00
|
|
|
if [[ $optval -eq 1 ]]; then
|
2014-06-30 11:32:07 +02:00
|
|
|
_optsset+=" ${f}"
|
2014-04-09 16:40:27 +02:00
|
|
|
else
|
2014-06-30 11:32:07 +02:00
|
|
|
_optsset+=" ~${f}"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for f in ${_optsset}; do
|
|
|
|
if [ -z "$PKG_BUILD_OPTIONS" ]; then
|
|
|
|
PKG_BUILD_OPTIONS="$f"
|
|
|
|
else
|
2014-06-30 11:32:07 +02:00
|
|
|
PKG_BUILD_OPTIONS+=" $f"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Sort pkg build options alphabetically.
|
|
|
|
export PKG_BUILD_OPTIONS="$(echo "$PKG_BUILD_OPTIONS"|tr ' ' '\n'|sort|tr '\n' ' ')"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
source_file() {
|
2014-04-09 16:40:27 +02:00
|
|
|
local f="$1"
|
|
|
|
|
|
|
|
if [ ! -f "$f" -o ! -r "$f" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if ! source "$f"; then
|
|
|
|
msg_error "xbps-src: failed to read $f!\n"
|
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run_pkg_hooks() {
|
2015-02-25 18:54:00 +01:00
|
|
|
local phase="$1" hookn f
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
eval unset -f hook
|
|
|
|
for f in ${XBPS_COMMONDIR}/hooks/${phase}/*.sh; do
|
|
|
|
[ ! -r $f ] && continue
|
|
|
|
hookn=$(basename $f)
|
|
|
|
hookn=${hookn%.sh}
|
|
|
|
. $f
|
2014-12-11 11:02:22 +01:00
|
|
|
run_func hook "$phase hook: $hookn" ${phase}_${hookn}
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2015-02-25 18:54:00 +01:00
|
|
|
unset_package_funcs() {
|
|
|
|
local f
|
|
|
|
|
|
|
|
for f in $(typeset -F|grep -E '_package$'); do
|
|
|
|
eval unset -f $f
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
get_subpkgs() {
|
2014-04-09 16:40:27 +02:00
|
|
|
local args list
|
|
|
|
|
|
|
|
args="$(typeset -F|grep -E '_package$')"
|
|
|
|
set -- ${args}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
list+=" ${3%_package}"; shift 3
|
|
|
|
done
|
|
|
|
for f in ${list}; do
|
2014-08-25 22:34:13 +02:00
|
|
|
echo "$f"
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_pkg() {
|
2014-04-09 16:40:27 +02:00
|
|
|
local pkg="$1" cross="$2"
|
2015-03-01 16:57:27 +01:00
|
|
|
local val _vars f dbgflags arch
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
|
|
|
# Start with a sane environment
|
2015-04-09 09:21:53 +02:00
|
|
|
unset -v PKG_BUILD_OPTIONS XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_CPPFLAGS XBPS_CROSS_LDFLAGS
|
2015-02-25 18:54:00 +01:00
|
|
|
unset -v subpackages run_depends build_depends host_build_depends
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-02-25 18:54:00 +01:00
|
|
|
unset_package_funcs
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-03-23 18:02:45 +01:00
|
|
|
. $XBPS_CONFIG_FILE 2>/dev/null
|
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
source_file $XBPS_CROSSPFDIR/${cross}.sh
|
|
|
|
|
2015-02-25 18:54:00 +01:00
|
|
|
_vars="TARGET_ARCH CROSS_TRIPLET CROSS_CFLAGS CROSS_CXXFLAGS"
|
|
|
|
for f in ${_vars}; do
|
2014-04-09 16:40:27 +02:00
|
|
|
eval val="\$XBPS_$f"
|
|
|
|
if [ -z "$val" ]; then
|
|
|
|
echo "ERROR: XBPS_$f is not defined!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
export XBPS_TARGET_MACHINE=$XBPS_TARGET_ARCH
|
|
|
|
export XBPS_CROSS_BASE=/usr/$XBPS_CROSS_TRIPLET
|
|
|
|
|
|
|
|
XBPS_INSTALL_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH $XBPS_INSTALL_CMD -c /host/repocache -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_QUERY_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH $XBPS_QUERY_CMD -c /host/repocache -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_RECONFIGURE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH $XBPS_RECONFIGURE_CMD -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH $XBPS_RINDEX_CMD"
|
|
|
|
XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH xbps-uhelper -r $XBPS_CROSS_BASE"
|
|
|
|
|
|
|
|
else
|
|
|
|
export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
|
|
|
|
unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS
|
|
|
|
unset XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_CPPFLAGS
|
|
|
|
|
|
|
|
XBPS_INSTALL_XCMD="$XBPS_INSTALL_CMD"
|
|
|
|
XBPS_QUERY_XCMD="$XBPS_QUERY_CMD"
|
|
|
|
XBPS_RECONFIGURE_XCMD="$XBPS_RECONFIGURE_CMD"
|
|
|
|
XBPS_REMOVE_XCMD="$XBPS_REMOVE_CMD"
|
|
|
|
XBPS_RINDEX_XCMD="$XBPS_RINDEX_CMD"
|
|
|
|
XBPS_UHELPER_XCMD="$XBPS_UHELPER_CMD"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \
|
|
|
|
XBPS_REMOVE_XCMD XBPS_RINDEX_XCMD XBPS_UHELPER_XCMD
|
|
|
|
|
|
|
|
# Source all sourcepkg environment setup snippets.
|
|
|
|
# Source all subpkg environment setup snippets.
|
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
2015-02-25 18:54:00 +01:00
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ ! -f ${XBPS_SRCPKGDIR}/${pkg}/template ]; then
|
|
|
|
msg_error "xbps-src: unexistent file: ${XBPS_SRCPKGDIR}/${pkg}/template\n"
|
|
|
|
fi
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
export CROSS_BUILD="$cross"
|
|
|
|
source_file ${XBPS_SRCPKGDIR}/${pkg}/template
|
|
|
|
else
|
|
|
|
unset CROSS_BUILD
|
|
|
|
source_file ${XBPS_SRCPKGDIR}/${pkg}/template
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if required vars weren't set.
|
|
|
|
_vars="pkgname version short_desc revision homepage license"
|
|
|
|
for f in ${_vars}; do
|
|
|
|
eval val="\$$f"
|
|
|
|
if [ -z "$val" -o -z "$f" ]; then
|
|
|
|
msg_error "\"$f\" not set on $pkgname template.\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-03-20 19:06:18 +01:00
|
|
|
# Check if version is valid.
|
|
|
|
case "$version" in
|
|
|
|
*-*) msg_error "version contains invalid character: -\n";;
|
|
|
|
*_*) msg_error "version contains invalid character: _\n";;
|
|
|
|
esac
|
|
|
|
case "$version" in
|
|
|
|
*[0-9]*) : good ;;
|
|
|
|
*) msg_error "version must contain at least one digit.\n";;
|
|
|
|
esac
|
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
# Check if base-chroot is already installed.
|
|
|
|
if [ -z "$bootstrap" ]; then
|
|
|
|
check_installed_pkg base-chroot-0.1_1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_red "${pkg} is not a bootstrap package and cannot be built without it.\n"
|
|
|
|
msg_error "Please install bootstrap packages and try again.\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
sourcepkg="${pkgname}"
|
2014-07-23 15:44:36 +02:00
|
|
|
if [ -z "$subpackages" ]; then
|
|
|
|
subpackages="$(get_subpkgs)"
|
|
|
|
fi
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -h $XBPS_SRCPKGDIR/$pkg ]; then
|
|
|
|
# Source all subpkg environment setup snippets.
|
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
|
|
|
pkgname=$pkg
|
|
|
|
if ! declare -f ${pkg}_package >/dev/null; then
|
|
|
|
msg_error "$pkgname: missing ${pkg}_package() function!\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
pkgver="${pkg}-${version}_${revision}"
|
|
|
|
|
|
|
|
# If build_style() unset, a do_install() function must be defined.
|
|
|
|
if [ -z "$build_style" ]; then
|
|
|
|
# Check that at least do_install() is defined.
|
|
|
|
if ! declare -f do_install >/dev/null; then
|
|
|
|
msg_error "$pkgver: missing do_install() function!\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
FILESDIR=$XBPS_SRCPKGDIR/$sourcepkg/files
|
|
|
|
PATCHESDIR=$XBPS_SRCPKGDIR/$sourcepkg/patches
|
|
|
|
DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
|
|
|
|
PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
|
|
|
|
|
2015-07-10 10:07:02 +02:00
|
|
|
if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
|
|
|
|
XBPS_MAKEJOBS=1
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
2015-07-10 10:07:02 +02:00
|
|
|
makejobs="-j$XBPS_MAKEJOBS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-03-01 16:06:30 +01:00
|
|
|
if [ -n "$noarch" ]; then
|
2015-03-01 16:57:27 +01:00
|
|
|
arch="noarch"
|
2015-03-01 16:06:30 +01:00
|
|
|
else
|
2015-03-01 16:57:27 +01:00
|
|
|
arch="$XBPS_TARGET_MACHINE"
|
2015-03-01 16:06:30 +01:00
|
|
|
fi
|
2015-03-15 09:54:02 +01:00
|
|
|
if [ -n "$XBPS_BINPKG_EXISTS" ]; then
|
|
|
|
if [ "$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
|
|
|
|
exit_and_cleanup
|
|
|
|
fi
|
2015-02-28 10:29:27 +01:00
|
|
|
fi
|
|
|
|
|
2014-11-05 17:29:28 +01:00
|
|
|
if [ -z "$XBPS_DEBUG_PKGS" -o "$repository" = "nonfree" ]; then
|
2014-11-16 11:52:36 +01:00
|
|
|
nodebug=yes
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
# If a package sets force_debug_pkgs, always build -dbg pkgs.
|
|
|
|
if [ -n "$force_debug_pkgs" ]; then
|
2014-11-16 11:52:36 +01:00
|
|
|
unset nodebug
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
# -g is required to build -dbg packages.
|
2014-11-16 11:52:36 +01:00
|
|
|
if [ -z "$nodebug" ]; then
|
2014-04-09 16:40:27 +02:00
|
|
|
dbgflags="-g"
|
|
|
|
fi
|
|
|
|
|
2015-03-04 15:17:05 +01:00
|
|
|
if [ -z "$cross" ]; then
|
2014-12-24 09:53:35 +01:00
|
|
|
if [ -z "$CHROOT_READY" ]; then
|
|
|
|
source_file ${XBPS_COMMONDIR}/build-profiles/bootstrap.sh
|
|
|
|
else
|
|
|
|
source_file ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
|
2014-11-10 11:15:53 +01:00
|
|
|
fi
|
|
|
|
fi
|
2015-03-04 15:17:05 +01:00
|
|
|
|
|
|
|
export CFLAGS="$XBPS_TARGET_CFLAGS $XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
|
|
|
|
export CXXFLAGS="$XBPS_TARGET_CXXFLAGS $XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
|
|
|
|
export CPPFLAGS="$XBPS_TARGET_CPPFLAGS $XBPS_CPPFLAGS $XBPS_CROSS_CPPFLAGS $CPPFLAGS"
|
2015-03-12 10:45:17 +01:00
|
|
|
export LDFLAGS="$LDFLAGS $XBPS_TARGET_LDFLAGS $XBPS_LDFLAGS $XBPS_CROSS_LDFLAGS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-01-08 11:54:28 +01:00
|
|
|
if [ -n "$broken_as_needed" ]; then
|
|
|
|
LDFLAGS="${LDFLAGS/-Wl,--as-needed/}"
|
|
|
|
fi
|
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
export BUILD_CC="cc"
|
|
|
|
export BUILD_CFLAGS="$XBPS_CFLAGS"
|
2014-09-25 16:31:20 +02:00
|
|
|
export CC_FOR_BUILD="cc"
|
|
|
|
export CXX_FOR_BUILD="g++"
|
|
|
|
export CPP_FOR_BUILD="cpp"
|
|
|
|
export LD_FOR_BUILD="ld"
|
|
|
|
export CFLAGS_FOR_BUILD="$XBPS_CFLAGS"
|
|
|
|
export CXXFLAGS_FOR_BUILD="$XBPS_CXXFLAGS"
|
|
|
|
export CPPFLAGS_FOR_BUILD="$XBPS_CPPFLAGS"
|
|
|
|
export LDFLAGS_FOR_BUILD="$XBPS_LDFLAGS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
export CC="${XBPS_CROSS_TRIPLET}-gcc"
|
|
|
|
export CXX="${XBPS_CROSS_TRIPLET}-c++"
|
|
|
|
export CPP="${XBPS_CROSS_TRIPLET}-cpp"
|
|
|
|
export GCC="$CC"
|
|
|
|
export LD="${XBPS_CROSS_TRIPLET}-ld"
|
|
|
|
export AR="${XBPS_CROSS_TRIPLET}-ar"
|
|
|
|
export AS="${XBPS_CROSS_TRIPLET}-as"
|
|
|
|
export RANLIB="${XBPS_CROSS_TRIPLET}-ranlib"
|
|
|
|
export STRIP="${XBPS_CROSS_TRIPLET}-strip"
|
|
|
|
export OBJDUMP="${XBPS_CROSS_TRIPLET}-objdump"
|
|
|
|
export OBJCOPY="${XBPS_CROSS_TRIPLET}-objcopy"
|
|
|
|
export NM="${XBPS_CROSS_TRIPLET}-nm"
|
|
|
|
export READELF="${XBPS_CROSS_TRIPLET}-readelf"
|
|
|
|
else
|
|
|
|
export CC="cc"
|
|
|
|
export CXX="g++"
|
|
|
|
export CPP="cpp"
|
|
|
|
export GCC="$CC"
|
|
|
|
export LD="ld"
|
|
|
|
export AR="ar"
|
|
|
|
export AS="as"
|
|
|
|
export RANLIB="ranlib"
|
|
|
|
export STRIP="strip"
|
|
|
|
export OBJDUMP="objdump"
|
|
|
|
export OBJCOPY="objcopy"
|
|
|
|
export NM="nm"
|
|
|
|
export READELF="readelf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
set_build_options
|
|
|
|
|
|
|
|
# Setup some specific package vars.
|
|
|
|
if [ -z "$wrksrc" ]; then
|
|
|
|
wrksrc="$XBPS_BUILDDIR/${sourcepkg}-${version}"
|
|
|
|
else
|
|
|
|
wrksrc="$XBPS_BUILDDIR/$wrksrc"
|
|
|
|
fi
|
2014-03-27 10:06:27 +01:00
|
|
|
|
2014-08-21 12:07:44 +02:00
|
|
|
if [ "$cross" -a "$nocross" ]; then
|
2014-08-22 16:47:35 +02:00
|
|
|
msg_red "$pkgver: cannot be cross compiled, exiting...\n"
|
2015-03-19 10:08:02 +01:00
|
|
|
exit 2
|
2014-08-22 16:47:35 +02:00
|
|
|
elif [ "$broken" ]; then
|
2014-11-11 22:10:30 +01:00
|
|
|
msg_red "$pkgver: cannot be built, it's currently broken; see the build log:\n"
|
|
|
|
msg_red "$pkgver: $broken\n"
|
2015-03-19 10:08:02 +01:00
|
|
|
exit 2
|
2014-08-21 12:07:44 +02:00
|
|
|
fi
|
2014-09-28 08:02:12 +02:00
|
|
|
|
2014-12-22 12:15:34 +01:00
|
|
|
export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}"
|
2014-12-11 11:02:22 +01:00
|
|
|
export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers"
|
2015-04-24 11:01:59 +02:00
|
|
|
|
2015-07-12 10:13:43 +02:00
|
|
|
if [ -n "$bootstrap" -a -z "$CHROOT_READY" -o -n "$IN_CHROOT" ]; then
|
2015-04-24 11:01:59 +02:00
|
|
|
mkdir -p $XBPS_WRAPPERDIR
|
|
|
|
fi
|
2015-02-21 12:03:05 +01:00
|
|
|
|
2015-02-21 12:13:07 +01:00
|
|
|
source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|