3 DESTDIR="${DESTDIR:-/}"
4 pkglibdir="${pkglibdir:-/usr/lib/rpm}"
8 PLATFORM="${3:-platform}"
10 if grep /share/ $PLATFORM > /dev/null 2>&1 ; then
11 DEFAULTDOCDIR='%{_usr}/share/doc'
13 DEFAULTDOCDIR='%{_usr}/doc'
16 TEMPRC="/tmp/rpmrc.$$"
17 cat << E_O_F > $TEMPRC
22 RPM="./rpm --rcfile $TEMPRC"
24 arch="`$RPM --eval '%{_arch}'`"
25 VENDOR="`$RPM --eval '%{_vendor}'`"
26 OS="`$RPM --eval '%{_os}'`"
27 RPMRC_GNU="`$RPM --eval '%{_gnu}'`"
28 target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'`"
29 target="`$RPM --eval '%{_target}'`"
31 rm -f ${DESTDIR}/${pkglibdir}/noarch-${VENDOR}-${OS}
32 ln -s ${arch}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/noarch-${VENDOR}-${OS}
33 rm -f ${DESTDIR}/${pkglibdir}/noarch-${OS}
34 ln -s ${arch}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/noarch-${OS}
37 i[3456]86) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_athlon_' ;;
38 alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
39 sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
40 powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6]\|$\)_ppc64\1_' ;;
43 base_arch=`echo $arch | sed -e 's_i?86_i386_;s_sparc.*_sparc_;s_alpha.*_alpha_;s_\(powerpc\|ppc\).*_ppc_'`
45 for SUBST in $SUBSTS ; do
46 ARCH=`echo $arch | sed -e $SUBST`
47 TARGET_PLATFORM=`echo $target_platform | sed -e $SUBST`
48 TARGET=`echo $target | sed -e $SUBST`
51 PPD="${DESTDIR}/${pkglibdir}/${ARCH}-${VENDOR}-${OS}"
53 [ -d $PPD ] || mkdir $PPD
55 RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
56 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
57 case $RPMRC_OPTFLAGS in
59 *) RPMRC_OPTFLAGS="$RPMRC_OPTFLAGS -g" ;;
62 ARCH_INSTALL_POST='%{nil}'
64 case "${ARCH}-${OS}" in
65 sparc-linux) MULTILIBNO=1 ;;
66 sparcv9-linux) MULTILIBNO=1 ;;
67 sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
70 if [ -n "$MULTILIBNO" ]; then
71 MULTILIBSED='-e /^@MULTILIB/d -e s,@MULTILIBNO@,'$MULTILIBNO,
73 MULTILIBSED='-e /^@MULTILIBSTART@/,/^@MULTILIBEND@/d'
78 VENDORSED='-e s,^@pld@,,'
81 VENDORSED='-e s,^@mandrake@,,'
82 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
85 VENDORSED='-e s,^@conectiva@,,'
88 VENDORSED='-e s,^@redhat@,,'
93 | sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
94 -e "s,@RPMRC_ARCH@,$base_arch," \
95 -e "s,@RPMRC_GNU@,$RPMRC_GNU," \
97 -e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
98 -e "s,@DEFAULTDOCDIR@,$DEFAULTDOCDIR," \
99 -e '/FLAGS:-/!s,\${,%{_,' \
106 # Better try to create these too until the smoke clears. Yuck.
107 [ "${ARCH}-${VENDOR}-${OS}" = "${TARGET}" ] || {
108 rm -f ${DESTDIR}/${pkglibdir}/${TARGET}
109 ln -s ${ARCH}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/${TARGET}
111 [ "${ARCH}-${VENDOR}-${OS}" = "${TARGET_PLATFORM}" ] || {
112 rm -f ${DESTDIR}/${pkglibdir}/${TARGET_PLATFORM}
113 ln -s ${ARCH}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/${TARGET_PLATFORM}