2017-04-28 07:28:42 +00:00
|
|
|
#
|
2017-11-24 06:43:34 +00:00
|
|
|
# This helper is for templates using meson.
|
2017-04-28 07:28:42 +00:00
|
|
|
#
|
2019-02-26 14:56:47 +00:00
|
|
|
do_patch() {
|
2017-09-23 23:42:47 +00:00
|
|
|
: ${meson_crossfile:=xbps_meson.cross}
|
|
|
|
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
|
|
_MESON_TARGET_ENDIAN=little
|
2018-07-28 11:49:47 +00:00
|
|
|
# drop the -musl suffix to the target cpu, meson doesn't recognize it
|
|
|
|
_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
|
2017-09-23 23:42:47 +00:00
|
|
|
case "$XBPS_TARGET_MACHINE" in
|
2017-11-14 18:39:02 +00:00
|
|
|
mips|mips-musl|mipshf-musl)
|
2017-09-23 23:42:47 +00:00
|
|
|
_MESON_TARGET_ENDIAN=big
|
2018-07-28 11:49:47 +00:00
|
|
|
_MESON_CPU_FAMILY=mips
|
|
|
|
;;
|
|
|
|
armv*)
|
|
|
|
_MESON_CPU_FAMILY=arm
|
|
|
|
;;
|
2018-12-22 00:03:06 +00:00
|
|
|
ppc|ppc-musl)
|
|
|
|
_MESON_TARGET_ENDIAN=big
|
|
|
|
_MESON_CPU_FAMILY=ppc
|
|
|
|
;;
|
2018-07-28 11:49:47 +00:00
|
|
|
i686*)
|
|
|
|
_MESON_CPU_FAMILY=x86
|
|
|
|
;;
|
2018-12-31 23:24:00 +00:00
|
|
|
ppc64le)
|
|
|
|
_MESON_CPU_FAMILY=ppc64
|
|
|
|
;;
|
|
|
|
ppc64)
|
|
|
|
_MESON_TARGET_ENDIAN=big
|
|
|
|
_MESON_CPU_FAMILY=ppc64
|
|
|
|
;;
|
2018-07-28 11:49:47 +00:00
|
|
|
*)
|
|
|
|
# if we reached here that means that the cpu and cpu_family
|
|
|
|
# are the same like 'x86_64' and 'aarch64'
|
|
|
|
_MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
|
2017-09-23 23:42:47 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Record cross-compiling information in cross file.
|
|
|
|
# CFLAGS and LDFLAGS must be set as c_args and c_link_args.
|
|
|
|
cat > ${meson_crossfile} <<EOF
|
|
|
|
[binaries]
|
|
|
|
c = '${CC}'
|
|
|
|
cpp = '${CXX}'
|
2018-09-16 09:29:40 +00:00
|
|
|
ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
|
2018-09-10 04:29:52 +00:00
|
|
|
nm = '${NM}'
|
2017-09-23 23:42:47 +00:00
|
|
|
ld = '${LD}'
|
|
|
|
strip = '${STRIP}'
|
|
|
|
readelf = '${READELF}'
|
2019-02-25 16:27:42 +00:00
|
|
|
objcopy = '${OBJCOPY}'
|
2017-09-23 23:42:47 +00:00
|
|
|
pkgconfig = 'pkg-config'
|
2019-01-21 04:16:03 +00:00
|
|
|
rust = 'rustc'
|
2019-01-29 18:57:37 +00:00
|
|
|
g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
|
|
|
|
g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
|
|
|
|
g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
|
2017-09-23 23:42:47 +00:00
|
|
|
|
|
|
|
[properties]
|
|
|
|
needs_exe_wrapper = true
|
|
|
|
c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
|
|
|
|
c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
|
2017-09-30 10:09:47 +00:00
|
|
|
|
|
|
|
cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
|
|
|
|
cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
|
2017-09-23 23:42:47 +00:00
|
|
|
|
|
|
|
[host_machine]
|
|
|
|
system = 'linux'
|
2018-07-28 11:49:47 +00:00
|
|
|
cpu_family = '${_MESON_CPU_FAMILY}'
|
2017-09-23 23:42:47 +00:00
|
|
|
cpu = '${_MESON_TARGET_CPU}'
|
|
|
|
endian = '${_MESON_TARGET_ENDIAN}'
|
|
|
|
EOF
|
2019-02-26 14:56:47 +00:00
|
|
|
|
|
|
|
unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
do_configure() {
|
|
|
|
: ${meson_cmd:=meson}
|
|
|
|
: ${meson_builddir:=build}
|
2019-02-28 12:42:55 +00:00
|
|
|
: ${meson_crossfile:=xbps_meson.cross}
|
2019-02-26 14:56:47 +00:00
|
|
|
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
2017-09-23 23:42:47 +00:00
|
|
|
configure_args+=" --cross-file=${meson_crossfile}"
|
|
|
|
|
2018-09-10 04:29:52 +00:00
|
|
|
# Meson tries to compile natively with CC, CXX, LD, AR
|
|
|
|
# so when cross compiling, we need to set those to the
|
|
|
|
# host versions.
|
|
|
|
export CC=${CC_host} CXX=${CXX_host} LD=${LD_host} AR=${AR_host}
|
2017-09-23 23:42:47 +00:00
|
|
|
|
2018-09-10 04:29:52 +00:00
|
|
|
# Meson tries to use CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS when compiling under
|
|
|
|
# native: true, so we use XBPS_CFLAGS, XBPS_CXXFLAGS, XBPS_CPPFLAGS and XBPS_LDFLAGS
|
|
|
|
# which are set to (C|CXX|CPP|LD)FLAGS_host
|
|
|
|
export CFLAGS=${CFLAGS_host} CXXFLAGS=${CXXFLAGS_host} CPPFLAGS=${CPPFLAGS_host} LDFLAGS=${LDFLAGS_host}
|
2018-08-14 09:43:07 +00:00
|
|
|
|
2018-09-09 23:25:54 +00:00
|
|
|
# Meson tries to use our wrapped cross-only pkg-config to find
|
|
|
|
# libraries even when 'native: true' (build against the host platform)
|
|
|
|
# is set, so set the PKG_CONFIG variable to tell Meson which pkg-config
|
|
|
|
# it should use when searching for stuff in the build machine
|
|
|
|
export PKG_CONFIG="/usr/bin/pkg-config"
|
2017-09-23 23:42:47 +00:00
|
|
|
fi
|
2017-04-28 07:28:42 +00:00
|
|
|
|
2018-09-16 09:29:40 +00:00
|
|
|
# The binutils ar cannot perform LTO on static libraries so we have to use
|
|
|
|
# the gcc-ar wrapper that that calls the correct plugin
|
|
|
|
# https://github.com/mesonbuild/meson/issues/1646
|
|
|
|
export AR="gcc-ar"
|
|
|
|
|
2018-10-09 10:13:52 +00:00
|
|
|
${meson_cmd} \
|
|
|
|
--prefix=/usr \
|
|
|
|
--libdir=/usr/lib \
|
|
|
|
--libexecdir=/usr/libexec \
|
|
|
|
--bindir=/usr/bin \
|
|
|
|
--sbindir=/usr/bin \
|
|
|
|
--includedir=/usr/include \
|
|
|
|
--datadir=/usr/share \
|
|
|
|
--mandir=/usr/share/man \
|
|
|
|
--infodir=/usr/share/info \
|
|
|
|
--localedir=/usr/share/locale \
|
|
|
|
--sysconfdir=/etc \
|
|
|
|
--localstatedir=/var \
|
|
|
|
--sharedstatedir=/var/lib \
|
|
|
|
--buildtype=plain \
|
|
|
|
--auto-features=enabled \
|
|
|
|
--wrap-mode=nodownload \
|
|
|
|
-Db_lto=true -Db_ndebug=true \
|
2019-02-05 06:40:31 +00:00
|
|
|
-Db_staticpic=true \
|
2018-10-09 10:13:52 +00:00
|
|
|
${configure_args} . ${meson_builddir}
|
2017-04-28 07:28:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_build() {
|
|
|
|
: ${make_cmd:=ninja}
|
|
|
|
: ${make_build_target:=all}
|
|
|
|
: ${meson_builddir:=build}
|
|
|
|
|
|
|
|
${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target}
|
|
|
|
}
|
|
|
|
|
2017-11-27 22:22:24 +00:00
|
|
|
do_check() {
|
|
|
|
: ${make_cmd:=ninja}
|
|
|
|
: ${make_check_target:=test}
|
|
|
|
: ${meson_builddir:=build}
|
|
|
|
|
|
|
|
${make_cmd} -C ${meson_builddir} ${makejobs} ${make_check_args} ${make_check_target}
|
|
|
|
}
|
|
|
|
|
2017-04-28 07:28:42 +00:00
|
|
|
do_install() {
|
|
|
|
: ${make_cmd:=ninja}
|
|
|
|
: ${make_install_target:=install}
|
|
|
|
: ${meson_builddir:=build}
|
|
|
|
|
|
|
|
DESTDIR=${DESTDIR} ${make_cmd} -C ${meson_builddir} ${make_install_args} ${make_install_target}
|
|
|
|
}
|