3 DESTDIR="${DESTDIR:-/}"
4 pkglibdir="${pkglibdir:-/usr/lib/rpm}"
5 platformdir="${pkglibdir}/platform"
9 PLATFORM="${3:-platform}"
11 TEMPRC="/tmp/rpmrc.$$"
12 cat << E_O_F > $TEMPRC
16 RPM="./rpm --rcfile=$TEMPRC --macros=$MACROS"
18 canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_arm[^-]*_arm_;s_\(powerpc\|ppc\)[^-]*_ppc_;s,\(ia32e\|amd64\),x86_64,;s_sh4a_sh4_'
19 arch="`$RPM --eval '%{_arch}'|sed -e "$canonarch_sed"`"
20 VENDOR="`$RPM --eval '%{_vendor}'`"
21 OS="`$RPM --eval '%{_os}'`"
22 RPMRC_GNU="`$RPM --eval '%{_gnu}'`"
23 target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'|sed -e "$canonarch_sed"`"
24 target="`$RPM --eval '%{_target}'|sed -e "$canonarch_sed"`"
27 i[3456]86|pentium[34]|athlon|geode) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_ s_i386_geode_' ;;
28 alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
29 arm*) SUBSTS='s_arm_armv3l_ s_arm_armv4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;;
30 sh4*) SUBSTS='s_sh4_sh4_ s_sh4_sh4a_' ;;
31 sparc*) SUBSTS='s_sparc\(64\|64v\|v9v\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
32 powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6ip]\|$\)_ppc64\1_ s_ppc\([^6ip]\|$\)_ppciseries_ s_ppc\([^6ip]\|$\)_ppcpseries_ s_ppc\([^6ip]\|$\)_ppc64iseries_ s_ppc\([^6ip]\|$\)_ppc64pseries_' ;;
33 s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
34 x86_64|amd64|ia32e) SUBSTS='s,x86_64,x86_64, s,x86_64,ia32e, s,x86_64,amd64, s,x86_64,i386, s,x86_64,i486, s,x86_64,i586, s,x86_64,i686, s,x86_64,pentium3, s,x86_64,pentium4, s,x86_64,athlon, s,x86_64,geode,' ;;
38 for SUBST in $SUBSTS ; do
39 ARCH=`echo $arch | sed -e $SUBST`
40 TARGET_PLATFORM=`echo $target_platform | sed -e $SUBST`
41 TARGET=`echo $target | sed -e $SUBST`
43 PPD="${DESTDIR}/${platformdir}/${ARCH}-${OS}"
45 [ -d $PPD ] || mkdir -p $PPD
47 RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
48 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
49 case $RPMRC_OPTFLAGS in
51 *) RPMRC_OPTFLAGS="$RPMRC_OPTFLAGS -g" ;;
54 ARCH_INSTALL_POST='%{nil}'
55 case "${ARCH}-${OS}" in
56 sparc64*-linux) LIB=lib64 ;;
57 s390x-linux) LIB=lib64 ;;
58 ppc64-linux|powerpc64-linux) LIB=lib64 ;;
59 x86_64-linux|amd64-linux|ia32e-linux) LIB=lib64 ;;
63 # XXX FIXME: incomplete and quite likely wrong too in places,
64 # consult various arch folks for correct names etc.
92 i?86|pentium?|athlon|geode)
108 VENDORSED='-e s,^@yellowdog@,,'
111 VENDORSED='-e s,^@pld@,,'
112 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e "s/ -g/ /"`"
115 VENDORSED='-e s,^@mandrake@,,'
116 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
119 VENDORSED='-e s,^@conectiva@,,'
122 VENDORSED='-e s,^@redhat@,,'
125 VENDORSED='-e s,^@apple@,,'
129 CANONARCH="`echo $ARCH|sed -e "$canonarch_sed"`"
132 | sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
133 -e "s,$arch,$CANONARCH," \
134 -e "s,@RPMRC_GNU@,$RPMRC_GNU," \
136 -e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
137 -e '/\${\w*:-/!s,\${,%{_,' \
138 -e "s,@ISANAME@,$ISANAME," \
139 -e "s,@ISABITS@,$ISABITS," \
146 { cd ${DESTDIR}/${platformdir}
147 [ -L noarch-${OS} ] && rm -f noarch-${OS} 2>/dev/null
148 mkdir -p noarch-${OS}
149 sed -e "/^%_arch/s,${arch},noarch," ${arch}-${OS}/macros | grep -v '^%optflags' | grep -v "^%__isa" > noarch-${OS}/macros