2019-05-11 17:07:46 +03:00
#!/bin/sh -efu
2002-03-25 23:16:26 +03:00
DESTDIR="${DESTDIR:-/}"
pkglibdir="${pkglibdir:-/usr/lib/rpm}"
RPMRC="${1:-rpmrc}"
MACROS="${2:-macros}"
PLATFORM="${3:-platform}"
if grep /share/ $PLATFORM > /dev/null 2>&1 ; then
DEFAULTDOCDIR='%{_usr}/share/doc'
else
DEFAULTDOCDIR='%{_usr}/doc'
fi
2002-03-26 01:32:55 +03:00
#TEMPRC="/tmp/rpmrc.$$"
#cat << E_O_F > $TEMPRC
#include: $RPMRC
#macrofiles: $MACROS
#E_O_F
#
#RPM="./rpm --rcfile $TEMPRC"
RPM=rpm
arch="`$RPM --eval '%{_target_cpu}'`"
2002-03-25 23:16:26 +03:00
VENDOR="`$RPM --eval '%{_vendor}'`"
OS="`$RPM --eval '%{_os}'`"
RPMRC_GNU="`$RPM --eval '%{_gnu}'`"
target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'`"
target="`$RPM --eval '%{_target}'`"
case "$arch" in
2006-09-17 01:50:43 +04:00
i[3456]86|k6|athlon|athlon_xp|pentium[234])
SUBSTS='s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),i386, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),i486, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),i586, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),i686, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),k6, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),athlon, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),athlon_xp, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),pentium2, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),pentium3, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),pentium4, s,\(i[3456]86\|k6\|athlon_xp\|athlon\|pentium[234]\),noarch,'
2006-03-20 17:23:07 +03:00
;;
2014-10-10 20:47:03 +04:00
aarch64)
SUBSTS='s,aarch64,aarch64, s,aarch64,noarch,'
;;
2006-03-20 17:23:07 +03:00
alpha*)
2006-09-17 01:50:43 +04:00
SUBSTS='s,alpha,alpha, s,alpha,alphaev5, s,alpha,alphaev56, s,alpha,alphapca56, s,alpha,alphaev6, s,alpha,alphaev67,'
2006-03-20 17:23:07 +03:00
;;
2018-01-16 13:10:58 +03:00
armv8*|armv7*)
add /usr/lib/rpm/armv8l-alt-linux/macros for builds on armv8l machines
If rpmbuild is invoked without --target, it looks for the macros based
on `uname -m`. The resulting error message on armv8l machines (when
building a noarch package) was like this:
> Invalid or unknown architecture: noarch-alt-linux
> Executing(%install): /bin/sh -e /tmp/sh.txFqhrP3/rpm-tmp.63120
> error: Bad exit status from /tmp/sh.txFqhrP3/rpm-tmp.63120 (%install)
--a bit misleading due to the following fallback code from macros.in
being executed:
%___build_pre \
%{warn:Invalid or unknown architecture: %{_target_cpu}-%{_vendor}-%{_target_os}\
}exit 1\
%nil
(Are there additional customizations that we might want to enable on
armv8l compared to our armv7l or armh configuration?
armv8l means having AArch32 architecture, typically on a CPU with
AArch64, too. AArch32 means that A32 (ARM) and T32 (Thumb-2)
instruction sets are admitted. See, e.g.,
<https://bgamari.github.io/posts/2019-06-12-arm-terminology.html>.
Currently, our armv8l-alt-linux/macros won't differ essentially from
armv7l-alt-linux/macros. Probably, that's fine, because it seems that
all ARMv8 and all ARMv7 processors support Thumb-2 instructions in the
T32 instruction set, so there are no essential differences in the
optimizations that can be applied.)
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: c18f1b7d ("installplatform, rpmrc.in: made armv8l compatible with armh")
2020-06-28 15:12:40 +03:00
SUBSTS='s,arm.*,armh, s,arm.*,armv7l, s,arm.*,armv8l, s,arm.*,noarch,'
2012-08-05 18:34:32 +04:00
;;
2007-04-08 00:55:46 +04:00
arm*)
2012-08-05 18:34:32 +04:00
SUBSTS='s,arm.*,arm, s,arm.*,armv3l, s,arm.*,armv4l, s,arm.*,armv5l, s,arm.*,armv5tel, s,arm.*,armv5tejl, s,arm.*,armv6l, s,arm.*,noarch,'
2007-04-08 00:55:46 +04:00
;;
2018-03-26 20:52:52 +03:00
e2k*)
SUBSTS='s,e2k.*,e2k, s,e2k.*,e2kv4, s,e2k.*,e2kv5, s,e2k.*,e2kv6, s,e2k.*,noarch,'
;;
2017-11-17 17:43:56 +03:00
mips)
SUBSTS='s,mips,mips, s,mips,noarch,'
;;
mipsel)
SUBSTS='s,mipsel,mipsel, s,mipsel,noarch,'
;;
mipsn32)
SUBSTS='s,mipsn32,mipsn32, s,mipsn32,noarch,'
;;
mipsn32el)
SUBSTS='s,mipsn32el,mipsn32el, s,mipsn32el,noarch,'
;;
mips64)
SUBSTS='s,mips64,mips64, s,mips64,noarch,'
;;
mips64el)
SUBSTS='s,mips64el,mips64el, s,mips64el,noarch,'
;;
s390x)
SUBSTS='s,s390x,s390x, s,s390x,noarch,'
;;
2006-03-20 17:23:07 +03:00
sparc*)
2006-09-17 01:50:43 +04:00
SUBSTS='s,sparc\(64\|v9\),sparc, s,sparc64,sparcv9,;s,sparc\([^v]\|$\),sparcv9\1, s,sparcv9,sparc64,;s,sparc\([^6]\|$\),sparc64\1,'
2006-03-20 17:23:07 +03:00
;;
2018-12-01 16:10:26 +03:00
ppc64le)
SUBSTS='s,ppc64le,ppc64le, s,ppc64le,noarch,'
;;
2006-03-20 17:23:07 +03:00
powerpc*|ppc*)
2006-09-17 01:50:43 +04:00
SUBSTS='s,ppc64,ppc, s,ppc\([^6]\|$\),ppc64\1,'
2006-03-20 17:23:07 +03:00
;;
2017-11-17 17:43:56 +03:00
riscv64)
SUBSTS='s,riscv64,riscv64, s,riscv64,noarch,'
;;
2006-03-20 17:23:07 +03:00
x86_64)
SUBSTS='s,x86_64,x86_64, s,x86_64,noarch,'
;;
*)
SUBSTS='y___'
;;
2002-03-25 23:16:26 +03:00
esac
for SUBST in $SUBSTS ; do
ARCH=`echo $arch | sed -e $SUBST`
2019-01-31 16:28:27 +03:00
LIBSUFF=
2019-05-11 17:09:34 +03:00
POINTER_SIZE=32
2002-03-25 23:16:26 +03:00
PPD="${DESTDIR}/${pkglibdir}/${ARCH}-${VENDOR}-${OS}"
[ -d $PPD ] || mkdir $PPD
RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
ARCH_INSTALL_POST='%{nil}'
case "${ARCH}-${OS}" in
2019-05-11 17:09:34 +03:00
aarch64-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
mipsn32-linux*)
LIBSUFF=32
;;
mipsn32el-linux*)
LIBSUFF=32
;;
mips64-linux*)
LIBSUFF=64
POINTER_SIZE=64
;;
mips64el-linux*)
LIBSUFF=64
POINTER_SIZE=64
;;
ppc64le-linux*)
LIBSUFF=64
POINTER_SIZE=64
;;
riscv64-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
s390x-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
sparc64-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
x86_64-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
e2k*-linux)
LIBSUFF=64
POINTER_SIZE=64
;;
noarch-linux)
POINTER_SIZE=
2002-03-25 23:16:26 +03:00
esac
2019-05-11 17:07:46 +03:00
VENDORSED=
2002-03-25 23:16:26 +03:00
case $VENDOR in
2002-03-26 01:32:55 +03:00
alt)
VENDORSED='-e s,^@alt@,,'
;;
2002-03-25 23:16:26 +03:00
pld)
VENDORSED='-e s,^@pld@,,'
;;
mandrake)
VENDORSED='-e s,^@mandrake@,,'
RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
;;
conectiva)
VENDORSED='-e s,^@conectiva@,,'
;;
redhat)
VENDORSED='-e s,^@redhat@,,'
;;
esac
2017-11-17 17:44:24 +03:00
LIBSUFF_EXISTS=@
2019-01-31 16:28:27 +03:00
[ "$LIBSUFF" = '' ] || LIBSUFF_EXISTS=
2017-11-17 17:44:24 +03:00
2019-05-11 17:09:34 +03:00
ARCH_ILP32=
ARCH_LP64=
case "$POINTER_SIZE" in
32) ARCH_ILP32=1 ;;
64) ARCH_LP64=1 ;;
esac
2002-03-25 23:16:26 +03:00
cat $PLATFORM \
| sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
2002-03-26 01:32:55 +03:00
-e "s,@RPMRC_ARCH@,$ARCH," \
2002-03-25 23:16:26 +03:00
-e "s,@RPMRC_GNU@,$RPMRC_GNU," \
2019-01-31 16:28:27 +03:00
-e "s,@LIBSUFF_DEFINITION@,${LIBSUFF:-%nil}," \
2017-11-17 17:44:24 +03:00
-e "s,@LIBSUFF@,$LIBSUFF," \
-e "s,@LIBSUFF_EXISTS@,$LIBSUFF_EXISTS," \
2019-05-11 17:09:34 +03:00
-e "s,@POINTER_SIZE@,$POINTER_SIZE," \
-e "s,@ARCH_ILP32@,$ARCH_ILP32," \
-e "s,@ARCH_LP64@,$ARCH_LP64," \
2002-03-25 23:16:26 +03:00
-e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
-e "s,@DEFAULTDOCDIR@,$DEFAULTDOCDIR," \
2019-05-11 17:09:34 +03:00
-e '/ $/d' \
2002-03-25 23:16:26 +03:00
$VENDORSED \
| grep -v '^@' \
> ${PPD}/macros
done
2002-03-26 01:32:55 +03:00
#rm $TEMPRC