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 canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_\(powerpc\|ppc\)[^-]*_ppc_'
25 arch="`$RPM --eval '%{_arch}'|sed -e "$canonarch_sed"`"
26 VENDOR="`$RPM --eval '%{_vendor}'`"
27 OS="`$RPM --eval '%{_os}'`"
28 RPMRC_GNU="`$RPM --eval '%{_gnu}'`"
29 target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'|sed -e "$canonarch_sed"`"
30 target="`$RPM --eval '%{_target}'|sed -e "$canonarch_sed"`"
33 i[3456]86|pentium[34]|athlon) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_' ;;
34 alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
35 sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
36 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_' ;;
37 s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
41 for SUBST in $SUBSTS ; do
42 ARCH=`echo $arch | sed -e $SUBST`
43 TARGET_PLATFORM=`echo $target_platform | sed -e $SUBST`
44 TARGET=`echo $target | sed -e $SUBST`
47 PPD="${DESTDIR}/${pkglibdir}/${ARCH}-${OS}"
49 [ -d $PPD ] || mkdir $PPD
51 RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
52 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
53 case $RPMRC_OPTFLAGS in
55 *) RPMRC_OPTFLAGS="$RPMRC_OPTFLAGS -g" ;;
58 ARCH_INSTALL_POST='%{nil}'
60 case "${ARCH}-${OS}" in
61 sparc-linux) MULTILIBNO=1 ;;
62 sparcv9-linux) MULTILIBNO=1 ;;
63 sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
64 s390-linux) MULTILIBNO=1 ;;
65 s390x-linux) LIB=lib64; MULTILIBNO=2 ;;
66 ppc-linux) MULTILIBNO=1 ;;
67 ppc64-linux) LIB=lib64; MULTILIBNO=2 ;;
68 i?86-linux|pentium?-linux|athlon-linux) MULTILIBNO=1 ;;
69 x86_64-linux|amd64-linux|ia32e-linux) LIB=lib64; MULTILIBNO=2 ;;
72 if [ -n "$MULTILIBNO" ]; then
73 MULTILIBSED='-e /^@MULTILIB/d -e s,@MULTILIBNO@,'$MULTILIBNO,
75 MULTILIBSED='-e /^@MULTILIBSTART@/,/^@MULTILIBEND@/d'
80 VENDORSED='-e s,^@yellowdog@,,'
83 VENDORSED='-e s,^@pld@,,'
84 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e "s/ -g/ /"`"
87 VENDORSED='-e s,^@mandrake@,,'
88 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
91 VENDORSED='-e s,^@conectiva@,,'
94 VENDORSED='-e s,^@redhat@,,'
99 | sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
100 -e "s,@RPMRC_ARCH@,$ARCH," \
101 -e "s,@RPMRC_GNU@,$RPMRC_GNU," \
103 -e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
104 -e "s,@DEFAULTDOCDIR@,$DEFAULTDOCDIR," \
105 -e '/\${\w*:-/!s,\${,%{_,' \
113 { cd ${DESTDIR}/${pkglibdir}
114 [ -L noarch-${OS} ] && rm -f noarch-${OS} 2>/dev/null
115 mkdir -p noarch-${OS}
116 sed -e "/^%_arch/s,${arch},noarch," ${arch}-${OS}/macros | grep -v '^%optflags' > noarch-${OS}/macros
117 # [ -d ${VENDOR} ] || mkdir ${VENDOR}
118 # for i in brp-* find-lang.sh find-provides find-requires perl.prov perl.req
120 # sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < $i > ${VENDOR}/$i
121 # chmod +x ${VENDOR}/$i
123 ## chmod -x ${VENDOR}/perl.req
124 # echo "macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/${VENDOR}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros.cdb" > ${VENDOR}/rpmrc
125 # sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < ${arch}-${OS}/macros | grep -v '^%(_arch|optflags)' > ${VENDOR}/macros