diff -Naur rpm-4.1.1.orig/Makefile.in rpm-4.1.1.new/Makefile.in
--- rpm-4.1.1.orig/Makefile.in	Fri Oct 10 10:02:01 2003
+++ rpm-4.1.1.new/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -71,7 +71,7 @@
 OBJEXT = @OBJEXT@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 
-pkglibdir = @RPMCONFIGDIR@
+pkglibdir =  @RPMCONFIGDIROLD@
 AMTAR = @AMTAR@
 AR = @AR@
 AS = @AS@
@@ -238,13 +238,12 @@
 myLDFLAGS = # @LDFLAGS_STATIC@
 
 myLDADD = \
-	$(top_builddir)/lib/librpm.la \
-	$(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la \
+	$(top_builddir)/lib/.libs/librpm.a \
+	$(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a \
 	@WITH_LIBELF_LIB@ \
 	@WITH_ZLIB_LIB@ \
-	@INTLLIBS@ \
 	@LIBMISC@
 
 
@@ -263,15 +262,15 @@
 
 rpm_SOURCES = 
 rpm_LDFLAGS = $(myLDFLAGS)
-rpm_LDADD = rpm.o $(top_builddir)/build/librpmbuild.la $(myLDADD) $(staticLDFLAGS)
+rpm_LDADD = rpm.o $(top_builddir)/build/.libs/librpmbuild.a $(myLDADD) 
 
 rpmb_SOURCES = build.c
 rpmb_LDFLAGS = $(myLDFLAGS)
-rpmb_LDADD = rpmb.o $(top_builddir)/build/librpmbuild.la $(myLDADD)
+rpmb_LDADD = rpmb.o $(top_builddir)/build/.libs/librpmbuild.a $(myLDADD)
 
 rpmd_SOURCES = 
 rpmd_LDFLAGS = $(myLDFLAGS)
-rpmd_LDADD = rpmd.o $(myLDADD)
+rpmd_LDADD = rpmd.o $(myLDADD) 
 
 rpmi_SOURCES = 
 rpmi_LDFLAGS = $(myLDFLAGS)
@@ -279,11 +278,11 @@
 
 rpmk_SOURCES = 
 rpmk_LDFLAGS = $(myLDFLAGS)
-rpmk_LDADD = rpmk.o $(myLDADD)
+rpmk_LDADD = rpmk.o $(myLDADD) 
 
 rpmq_SOURCES = 
 rpmq_LDFLAGS = $(myLDFLAGS)
-rpmq_LDADD = rpmq.o $(top_builddir)/build/librpmbuild.la $(myLDADD)
+rpmq_LDADD = rpmq.o $(top_builddir)/build/.libs/librpmbuild.a $(myLDADD)
 
 rpm2cpio_SOURCES = rpm2cpio.c
 rpm2cpio_LDFLAGS = $(myLDFLAGS)
@@ -291,7 +290,7 @@
 
 CVSTAG = r$(subst .,-,$(VERSION))
 
-pkgsrcdir = $(prefix)/src/rpm
+pkgsrcdir = $(prefix)/src/denx
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -306,46 +305,46 @@
 
 am_rpm_OBJECTS =
 rpm_OBJECTS = $(am_rpm_OBJECTS)
-rpm_DEPENDENCIES = rpm.o $(top_builddir)/build/librpmbuild.la \
-	$(top_builddir)/lib/librpm.la $(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpm_DEPENDENCIES = rpm.o $(top_builddir)/build/.libs/librpmbuild.a \
+	$(top_builddir)/lib/.libs/librpm.a $(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpm2cpio_OBJECTS = rpm2cpio.$(OBJEXT)
 rpm2cpio_OBJECTS = $(am_rpm2cpio_OBJECTS)
-rpm2cpio_DEPENDENCIES = $(top_builddir)/lib/librpm.la \
-	$(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpm2cpio_DEPENDENCIES = $(top_builddir)/lib/.libs/librpm.a \
+	$(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpmb_OBJECTS = build.$(OBJEXT)
 rpmb_OBJECTS = $(am_rpmb_OBJECTS)
-rpmb_DEPENDENCIES = rpmb.o $(top_builddir)/build/librpmbuild.la \
-	$(top_builddir)/lib/librpm.la $(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpmb_DEPENDENCIES = rpmb.o $(top_builddir)/build/.libs/librpmbuild.a \
+	$(top_builddir)/lib/.libs/librpm.a $(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpmd_OBJECTS =
 rpmd_OBJECTS = $(am_rpmd_OBJECTS)
-rpmd_DEPENDENCIES = rpmd.o $(top_builddir)/lib/librpm.la \
-	$(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpmd_DEPENDENCIES = rpmd.o $(top_builddir)/lib/.libs/librpm.a \
+	$(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpmi_OBJECTS =
 rpmi_OBJECTS = $(am_rpmi_OBJECTS)
-rpmi_DEPENDENCIES = rpmi.o $(top_builddir)/lib/librpm.la \
-	$(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpmi_DEPENDENCIES = rpmi.o $(top_builddir)/lib/.libs/librpm.a \
+	$(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpmk_OBJECTS =
 rpmk_OBJECTS = $(am_rpmk_OBJECTS)
-rpmk_DEPENDENCIES = rpmk.o $(top_builddir)/lib/librpm.la \
-	$(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpmk_DEPENDENCIES = rpmk.o $(top_builddir)/lib/.libs/librpm.a \
+	$(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 am_rpmq_OBJECTS =
 rpmq_OBJECTS = $(am_rpmq_OBJECTS)
-rpmq_DEPENDENCIES = rpmq.o $(top_builddir)/build/librpmbuild.la \
-	$(top_builddir)/lib/librpm.la $(top_builddir)/rpmdb/librpmdb.la \
-	$(top_builddir)/rpmio/librpmio.la \
-	$(top_builddir)/popt/libpopt.la
+rpmq_DEPENDENCIES = rpmq.o $(top_builddir)/build/.libs/librpmbuild.a \
+	$(top_builddir)/lib/.libs/librpm.a $(top_builddir)/rpmdb/.libs/librpmdb.a \
+	$(top_builddir)/rpmio/.libs/librpmio.a \
+	$(top_builddir)/popt/.libs/libpopt.a
 SCRIPTS = $(bin_SCRIPTS) $(pkglib_SCRIPTS)
 
 
diff -Naur rpm-4.1.1.orig/autodeps/linux.req rpm-4.1.1.new/autodeps/linux.req
--- rpm-4.1.1.orig/autodeps/linux.req	Sat Jan 18 15:03:27 2003
+++ rpm-4.1.1.new/autodeps/linux.req	Fri Oct 10 10:03:09 2003
@@ -71,21 +71,21 @@
 
 #
 # --- Script interpreters.
-for f in $scriptlist; do
-    [ -r $f -a -x $f ] || continue
-    interp=`head -n 1 $f | sed -e 's/^\#\![ 	]*//' | cut -d" " -f1`
-    interplist="$interplist $interp"
-    case $interp in
-    */perl)	perllist="$perllist $f" ;;
-    esac
-done
-[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
+#for f in $scriptlist; do
+#    [ -r $f -a -x $f ] || continue
+#    interp=`head -n 1 $f | sed -e 's/^\#\![ 	]*//' | cut -d" " -f1`
+#    interplist="$interplist $interp"
+#    case $interp in
+#    */perl)	perllist="$perllist $f" ;;
+#    esac
+#done
+#[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
 
 #
 # --- Add perl module files to perllist.
-for f in $filelist; do
-    [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
-done
+#for f in $filelist; do
+#    [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
+#done
 
 #
 # --- Weak symbol versions (from glibc).
diff -Naur rpm-4.1.1.orig/build/pack.c rpm-4.1.1.new/build/pack.c
--- rpm-4.1.1.orig/build/pack.c	Tue Mar  4 18:03:17 2003
+++ rpm-4.1.1.new/build/pack.c	Fri Oct 10 10:03:09 2003
@@ -25,6 +25,11 @@
 #include "rpmlead.h"
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_cpu;
+extern char * target_arch;
+#endif
+
 /*@access rpmts @*/
 /*@access rpmfi @*/	/* compared with NULL */
 /*@access Header @*/	/* compared with NULL */
@@ -773,6 +778,62 @@
 
 	providePackageNVR(pkg->header);
 
+#ifdef HAVE_RUNTIME_PREFIX
+	if (target_arch) {
+		int type, count;
+		char * name, * tmp;
+		headerGetEntry(pkg->header, RPMTAG_NAME, &type, 
+			(void **) &name, &count);
+		tmp = xmalloc(strlen(name)+strlen(target_arch)+
+			strlen(target_cpu)+5);
+		strcpy(tmp, name);
+		sprintf(tmp+strlen(tmp), "-%s_%s",target_arch,target_cpu);
+		headerModifyEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, 
+			tmp, 1);
+	}
+
+	if (getenv("CROSS_COMPILE")) {
+		char ** rname, ** cname;
+		char *  tmp;
+		char *  cc = getenv("CROSS_COMPILE");
+		int type, count = 0, i;
+
+		if (cc[strlen(cc)-1]=='-')
+	   		cc[strlen(cc)-1]=0;
+
+	 	headerGetEntry(pkg->header, RPMTAG_REQUIRENAME, &type, 
+			(void **) &rname, &count);
+	 	for (i=0; i<count; i++) {
+	 		if (!strstr(rname[i],cc) && !strchr(rname[i],'(') &&
+			   !strchr(rname[i],'/') &&
+			   !strstr(rname[i],".so")) {
+				tmp = xmalloc(strlen(rname[i])+1+strlen(cc)+1);
+				sprintf(tmp,"%s-%s",rname[i],cc);
+				rname[i]=tmp;
+	   		}
+	 	}
+	 	if (count != 0)
+	 		headerModifyEntry(pkg->header, RPMTAG_REQUIRENAME, 
+				RPM_STRING_ARRAY_TYPE, rname, count);
+
+	 	count = 0;
+	 	headerGetEntry(pkg->header, RPMTAG_CONFLICTNAME, &type, 
+			(void **) &cname, &count);
+	 	for (i=0; i<count; i++) {
+	 		if (!strstr(cname[i],cc) && !strchr(cname[i],'(') &&
+			   !strchr(cname[i],'/') &&
+			   !strstr(cname[i],".so")) {
+				tmp = xmalloc(strlen(cname[i])+1+strlen(cc)+1);
+				sprintf(tmp,"%s-%s",cname[i],cc);
+				cname[i]=tmp;
+	 		}
+	 	}
+	 	if (count != 0)
+	 		headerModifyEntry(pkg->header, RPMTAG_CONFLICTNAME, 
+				RPM_STRING_ARRAY_TYPE, cname, count);
+	}
+#endif
+
     {	const char * optflags = rpmExpand("%{optflags}", NULL);
 	(void) headerAddEntry(pkg->header, RPMTAG_OPTFLAGS, RPM_STRING_TYPE,
 			optflags, 1);
diff -Naur rpm-4.1.1.orig/build/parseSpec.c rpm-4.1.1.new/build/parseSpec.c
--- rpm-4.1.1.orig/build/parseSpec.c	Tue Mar  4 16:31:13 2003
+++ rpm-4.1.1.new/build/parseSpec.c	Fri Oct 10 10:03:09 2003
@@ -284,12 +284,18 @@
 	match = !matchTok(arch, s);
 	arch = _free(arch);
     } else if (! strncmp("%ifos", s, sizeof("%ifos")-1)) {
-	const char *os = rpmExpand("%{_target_os}", NULL);
+	const char *os = rpmExpand("%{_build_os}", NULL);
+	char *tmp;
+	if ((tmp = strstr(os,"-gnu")) != NULL)
+		os[strlen(os)-strlen(tmp)]=0;
 	s += 5;
 	match = matchTok(os, s);
 	os = _free(os);
     } else if (! strncmp("%ifnos", s, sizeof("%ifnos")-1)) {
-	const char *os = rpmExpand("%{_target_os}", NULL);
+	const char *os = rpmExpand("%{_build_os}", NULL);
+	char *tmp;
+	if ((tmp = strstr(os,"-gnu")) != NULL)
+		os[strlen(os)-strlen(tmp)]=0;
 	s += 6;
 	match = !matchTok(os, s);
 	os = _free(os);
diff -Naur rpm-4.1.1.orig/build/rpmfc.c rpm-4.1.1.new/build/rpmfc.c
--- rpm-4.1.1.orig/build/rpmfc.c	Mon Mar  3 23:07:22 2003
+++ rpm-4.1.1.new/build/rpmfc.c	Fri Oct 10 10:03:09 2003
@@ -16,6 +16,10 @@
 
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_arch;
+#endif
+
 /*@access fmagic @*/
 /*@access rpmds @*/
 
@@ -1359,6 +1363,9 @@
 	    tagflags = RPMSENSE_FIND_PROVIDES;
 	    /*@switchbreak@*/ break;
 	case RPMTAG_REQUIREFLAGS:
+#ifdef HAVE_RUNTIME_PREFIX
+	    if (!target_arch) continue;
+#endif
 	    if (!pkg->autoReq)
 		continue;
 	    failnonzero = 0;
diff -Naur rpm-4.1.1.orig/config.h.in rpm-4.1.1.new/config.h.in
--- rpm-4.1.1.orig/config.h.in	Fri Mar  7 20:39:17 2003
+++ rpm-4.1.1.new/config.h.in	Fri Oct 10 10:03:09 2003
@@ -541,6 +541,15 @@
 /* Version number of package */
 #undef VERSION
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
+/* the target arhitecture */
+#undef TARGET_ARCH
+
+/* the target os */
+#undef TARGET_OS
+
 /* Define to 1 if on AIX 3.
    System headers sometimes define this.
    We just want to avoid a redefinition error message.  */
diff -Naur rpm-4.1.1.orig/configure rpm-4.1.1.new/configure
--- rpm-4.1.1.orig/configure	Fri Mar  7 20:17:41 2003
+++ rpm-4.1.1.new/configure	Fri Oct 10 10:03:09 2003
@@ -1351,6 +1351,40 @@
 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
 _ACEOF
 
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RUNTIME_PREFIX 1
+_ACEOF
+
+# Check whether --with-target_arch or --without-target_arch was given.
+if test "${with_target_arch+set}" = set; then
+  withval="$with_target_arch"
+  target_arch="$withval"
+else
+  target_arch=ppc
+fi
+
+cat >> confdefs.h <<_ACEOF
+#define TARGET_ARCH "$target_arch"
+_ACEOF
+
+# Check whether --with-target_os or --without-target_os was given.
+if test "${with_target_os+set}" = set; then
+  withval="$with_target_os"
+  target_os="$withval"
+else
+  target_os=linux
+fi
+
+cat >> confdefs.h <<_ACEOF
+#define TARGET_OS "$target_os"
+_ACEOF
+
+OSSHELL=/bin/sh
+
+case "$target" in
+       *-*-solaris*)   OSSHELL="/usr/local/bin/bash";;
+       *-*-linux*)     OSSHELL="/bin/sh";;
+esac
 
 # Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
@@ -23217,17 +23251,7 @@
 case "${build_os_noversion}" in
 mint)		RPMCANONARCH=m68kmint ;;
 esac
-RPMCANONVENDOR="$build_vendor"
-case "${build_vendor}" in
-unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog)
-	test -f /etc/redhat-release &&		RPMCANONVENDOR=redhat
-	test -f /etc/pld-release &&		RPMCANONVENDOR=pld
-	test -f /etc/mandrake-release &&	RPMCANONVENDOR=mandrake
-	test -f /etc/conectiva-release &&	RPMCANONVENDOR=conectiva
-	test -f /etc/lvr-release &&		RPMCANONVENDOR=lvr
-	test -f /etc/yellowdog-release &&	RPMCANONVENDOR=yellowdog
-	;;
-esac
+RPMCANONVENDOR="denx"
 RPMCANONOS="$build_os_noversion"
 
 
@@ -23239,7 +23263,9 @@
 else
     usrprefix=$prefix
 fi
-LOCALEDIR="`echo ${usrprefix}/share/locale`"
+
+runtime_prefix='%{_runtimeprefix}/usr'
+LOCALEDIR="`echo ${runtime_prefix}/share/locale`"
 
 cat >>confdefs.h <<_ACEOF
 #define LOCALEDIR "$LOCALEDIR"
@@ -23248,15 +23274,15 @@
 
 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
 
-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIROLD="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIR="`echo ${runtime_prefix}/lib/rpm`"
 
 cat >>confdefs.h <<_ACEOF
 #define RPMCONFIGDIR "$RPMCONFIGDIR"
 _ACEOF
 
 
-
-SYSCONFIGDIR="`echo /etc/rpm`"
+SYSCONFIGDIR="`echo ${runtime_prefix}/etc/rpm`"
 
 cat >>confdefs.h <<_ACEOF
 #define SYSCONFIGDIR "$SYSCONFIGDIR"
@@ -23264,7 +23290,7 @@
 
 
 
-MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.rpmmacros"
+MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.eldk_rpmmacros"
 
 cat >>confdefs.h <<_ACEOF
 #define MACROFILES "$MACROFILES"
@@ -24159,6 +24185,7 @@
 s,@LOCALEDIR@,$LOCALEDIR,;t t
 s,@LIBDIR@,$LIBDIR,;t t
 s,@RPMCONFIGDIR@,$RPMCONFIGDIR,;t t
+s,@RPMCONFIGDIROLD@,$RPMCONFIGDIROLD,;t t
 s,@SYSCONFIGDIR@,$SYSCONFIGDIR,;t t
 s,@MACROFILES@,$MACROFILES,;t t
 s,@LIBRPMRC_FILENAME@,$LIBRPMRC_FILENAME,;t t
@@ -24171,6 +24198,7 @@
 s,@LIBMISC@,$LIBMISC,;t t
 s,@RPM@,$RPM,;t t
 s,@OBJDUMP@,$OBJDUMP,;t t
+s,@OSSHELL@,$OSSHELL,;t t
 s,@subdirs@,$subdirs,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
diff -Naur rpm-4.1.1.orig/elfutils/config.h.in rpm-4.1.1.new/elfutils/config.h.in
--- rpm-4.1.1.orig/elfutils/config.h.in	Fri Mar  7 20:39:20 2003
+++ rpm-4.1.1.new/elfutils/config.h.in	Fri Oct 10 10:03:09 2003
@@ -83,9 +83,9 @@
 
 #ifdef __i386__
 # define internal_function \
-  __attribute__ ((regparm (3), stdcall, visibility ("internal")))
+  __attribute__ ((regparm (3), stdcall))
 # define internal_strong_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((alias (#name), stdcall, visibility ("internal")));
+  extern __typeof (name) aliasname __attribute__ ((alias (#name), stdcall));
 #else
 # define internal_function \
   __attribute__ ((visibility ("internal")))
@@ -93,8 +93,7 @@
   extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hiden")));
 #endif
 
-#define attribute_hidden \
-  __attribute__ ((visibility ("hidden")))
+#define attribute_hidden
 
 /* Define ALLOW_UNALIGNED if the architecture allows operations on
    unaligned memory locations.  */
diff -Naur rpm-4.1.1.orig/elfutils/libasm/Makefile.in rpm-4.1.1.new/elfutils/libasm/Makefile.in
--- rpm-4.1.1.orig/elfutils/libasm/Makefile.in	Fri Mar  7 20:16:52 2003
+++ rpm-4.1.1.new/elfutils/libasm/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -443,7 +443,7 @@
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 	      -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
 	      -Wl,--soname,$@.$(VERSION) \
-	      ../libebl/libebl.so ../libelf/libelf.so
+	      ../libebl/libebl.so ../libelf/libelf.so -ldl /lib/ld-linux.so.2
 	ln -fs $@ $@.$(VERSION)
 
 %.os: %.c %.o
diff -Naur rpm-4.1.1.orig/elfutils/libdw/Makefile.in rpm-4.1.1.new/elfutils/libdw/Makefile.in
--- rpm-4.1.1.orig/elfutils/libdw/Makefile.in	Fri Mar  7 20:16:52 2003
+++ rpm-4.1.1.new/elfutils/libdw/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -387,7 +387,7 @@
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 	      -Wl,--version-script,$(srcdir)/libdw.map,--no-undefined \
 	      -Wl,--soname,$@.$(VERSION) \
-	      ../libelf/libelf.so
+	      ../libelf/libelf.so  /lib/ld-linux.so.2
 	ln -fs $@ $@.$(VERSION)
 
 %.os: %.c %.o
diff -Naur rpm-4.1.1.orig/elfutils/libdwarf/Makefile.in rpm-4.1.1.new/elfutils/libdwarf/Makefile.in
--- rpm-4.1.1.orig/elfutils/libdwarf/Makefile.in	Fri Mar  7 20:16:53 2003
+++ rpm-4.1.1.new/elfutils/libdwarf/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -611,7 +611,7 @@
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 	      -Wl,--version-script,$(srcdir)/libdwarf.map,--no-undefined \
 	      -Wl,--soname,$@.$(VERSION) \
-	      ../libelf/libelf.so
+	      ../libelf/libelf.so /lib/ld-linux.so.2
 	ln -fs $@ $@.$(VERSION)
 
 %.os: %.c %.o
diff -Naur rpm-4.1.1.orig/elfutils/libebl/Makefile.in rpm-4.1.1.new/elfutils/libebl/Makefile.in
--- rpm-4.1.1.orig/elfutils/libebl/Makefile.in	Fri Mar  7 20:16:54 2003
+++ rpm-4.1.1.new/elfutils/libebl/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -622,32 +622,40 @@
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 	      -Wl,--version-script,$(srcdir)/libebl.map,--no-undefined \
 	      -Wl,--soname,$@.$(VERSION) \
-	      ../libelf/libelf.so -ldl
+	      ../libelf/libelf.so -ldl /lib/ld-linux.so.2
 	ln -fs $@ $@.$(VERSION)
 libebl_i386.so: libebl_i386_pic.a libebl_i386.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_i386.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_i386.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_sh.so: libebl_sh_pic.a libebl_sh.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_sh.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_sh.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_mips.so: libebl_mips_pic.a libebl_mips.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_mips.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_mips.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_x86_64.so: libebl_x86_64_pic.a libebl_x86_64.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_x86_64.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_x86_64.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_ia64.so: libebl_ia64_pic.a libebl_ia64.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_ia64.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_ia64.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_alpha.so: libebl_alpha_pic.a libebl_alpha.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_alpha.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_alpha.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_arm.so: libebl_arm_pic.a libebl_arm.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_arm.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_arm.map,--no-undefined \
+	      /lib/ld-linux.so.2
 libebl_sparc.so: libebl_sparc_pic.a libebl_sparc.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-	      -Wl,--version-script,$(srcdir)/libebl_sparc.map,--no-undefined
+	      -Wl,--version-script,$(srcdir)/libebl_sparc.map,--no-undefined \
+	      /lib/ld-linux.so.2
 
 %.os: %.c %.o
 	if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
diff -Naur rpm-4.1.1.orig/elfutils/libelf/Makefile.in rpm-4.1.1.new/elfutils/libelf/Makefile.in
--- rpm-4.1.1.orig/elfutils/libelf/Makefile.in	Fri Mar  7 20:16:54 2003
+++ rpm-4.1.1.new/elfutils/libelf/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -642,7 +642,7 @@
 libelf.so: libelf_pic.a libelf.map
 	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 	      -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
-	      -Wl,--soname,$@.$(VERSION)
+	      -Wl,--soname,$@.$(VERSION) /lib/ld-linux.so.2
 	ln -fs $@ $@.$(VERSION)
 
 %.os: %.c %.o
diff -Naur rpm-4.1.1.orig/elfutils/libelf/libelfP.h rpm-4.1.1.new/elfutils/libelf/libelfP.h
--- rpm-4.1.1.orig/elfutils/libelf/libelfP.h	Tue Mar  4 23:07:41 2003
+++ rpm-4.1.1.new/elfutils/libelf/libelfP.h	Fri Oct 10 10:03:09 2003
@@ -530,7 +530,7 @@
      attribute_hidden
 	/*@*/;
 extern unsigned long int __elf_hash_internal (const char *__string)
-       __attribute__ ((__pure__, visibility ("hidden")))
+       __attribute__ ((__pure__))
 	/*@*/;
 extern long int __elf32_checksum_internal (Elf *__elf) attribute_hidden
 	/*@*/;
diff -Naur rpm-4.1.1.orig/intl/Makefile.in rpm-4.1.1.new/intl/Makefile.in
--- rpm-4.1.1.orig/intl/Makefile.in	Sun Jul 21 16:20:41 2002
+++ rpm-4.1.1.new/intl/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -105,9 +105,9 @@
 
 INCLUDES = -I.. -I. -I$(top_srcdir)/intl
 
-all: all-@USE_INCLUDED_LIBINTL@
+all: all-no
 all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
-all-no: all-no-@BUILD_INCLUDED_LIBINTL@
+all-no: all-no-no
 all-no-yes: libgnuintl.$la
 all-no-no:
 
diff -Naur rpm-4.1.1.orig/lib/depends.c rpm-4.1.1.new/lib/depends.c
--- rpm-4.1.1.orig/lib/depends.c	Mon Mar  3 22:24:42 2003
+++ rpm-4.1.1.new/lib/depends.c	Fri Oct 10 10:03:09 2003
@@ -600,6 +600,10 @@
 	dscolor = rpmdsColor(requires);
 	if (tscolor && dscolor && !(tscolor & dscolor))
 	    continue;
+#ifdef HAVE_RUNTIME_PREFIX
+	if (*Name == '/' && !access(Name, F_OK))
+		continue;
+#endif
 
 	rc = unsatisfiedDepend(ts, requires, adding);
 
diff -Naur rpm-4.1.1.orig/lib/rpmfi.c rpm-4.1.1.new/lib/rpmfi.c
--- rpm-4.1.1.orig/lib/rpmfi.c	Mon Mar  3 20:19:15 2003
+++ rpm-4.1.1.new/lib/rpmfi.c	Fri Oct 10 10:03:09 2003
@@ -800,6 +800,7 @@
 		    fn, relocations[j].newPath);
 	nrelocated++;
 
+#ifndef HAVE_RUNTIME_PREFIX
 	strcpy(fn, relocations[j].newPath);
 	{   char * te = strrchr(fn, '/');
 	    if (te) {
@@ -813,6 +814,22 @@
 	    *te = '\0';			/* terminate new directory name */
 	    /*@=nullpass =nullderef@*/
 	}
+#else
+	{
+	    char * s = strrchr(fn, '/');
+
+	    if (s)
+	 	s++;
+	    else
+	 	s = fn;
+
+	    /* fn is the new dirName, and s is the new baseName */
+	    if (strcmp(baseNames[i], s))
+		baseNames[i] = alloca_strdup(s);
+
+	    *s = 0;
+	}
+#endif
 
 	/* Does this directory already exist in the directory list? */
 	for (j = 0; j < dirCount; j++) {
diff -Naur rpm-4.1.1.orig/lib/rpminstall.c rpm-4.1.1.new/lib/rpminstall.c
--- rpm-4.1.1.orig/lib/rpminstall.c	Mon Mar  3 20:16:51 2003
+++ rpm-4.1.1.new/lib/rpminstall.c	Fri Oct 10 10:03:09 2003
@@ -31,6 +31,10 @@
 /*@unchecked@*/
 int rpmcliProgressTotal = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+#endif
+
 /**
  * Print a CLI progress bar.
  * @todo Unsnarl isatty(STDOUT_FILENO) from the control flow.
@@ -329,12 +333,14 @@
 			rpmShowProgress, (void *) ((long)notifyFlags));
     }
 
+#ifndef HAVE_RUNTIME_PREFIX
     if ((eiu->relocations = relocations) != NULL) {
 	while (eiu->relocations->oldPath)
 	    eiu->relocations++;
 	if (eiu->relocations->newPath == NULL)
 	    eiu->relocations = NULL;
     }
+#endif
 
     /* Build fully globbed list of arguments in argv[argc]. */
     /*@-branchstate@*/
@@ -491,6 +497,55 @@
 	default:
 	    /*@switchbreak@*/ break;
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	{
+		int type, count, i;
+		char * name, * arch , * tmp, * cpu;
+		int num_relocs;
+
+		for (num_relocs = 0; relocations && 
+			relocations[num_relocs].oldPath &&
+			relocations[num_relocs].newPath; num_relocs++);
+
+		relocations = xrealloc(relocations, sizeof(*relocations) *
+					(num_relocs + 2));
+		relocations[num_relocs].oldPath = "/";
+		relocations[num_relocs].newPath = runtime_prefix;
+
+
+		headerGetEntry(eiu->h, RPMTAG_ARCH , &type, (void **) &arch, 
+			&count);
+		headerGetEntry(eiu->h, RPMTAG_NAME , &type, (void **) &name, 
+			&count);
+
+		for (i = strlen(name); i > 0; i--)
+			if (name[i] == '-') {
+				if (count == 1) break;
+				else count++;
+			}
+
+		if (count == 1 && !strncmp(name + i + 1, arch, strlen(arch))) {
+			tmp = xmalloc(strlen(relocations[num_relocs].newPath) +
+				strlen(name) + 20);
+
+			cpu = name + i + strlen(arch) + 2;
+			sprintf(tmp, "%s/%s_%s/",
+				relocations[num_relocs].newPath, arch, cpu);
+			relocations[num_relocs].newPath = tmp;
+			probFilter |= RPMPROB_FILTER_FORCERELOCATE |
+				RPMPROB_FILTER_IGNOREARCH | 
+				RPMPROB_FILTER_IGNOREOS;
+		} else {
+			tmp = xmalloc(strlen(relocations[num_relocs].newPath) 
+				+ 10);
+			sprintf(tmp, "%s/", relocations[num_relocs].newPath);
+			relocations[num_relocs].newPath = tmp;
+			probFilter |= RPMPROB_FILTER_FORCERELOCATE ;
+		}
+		relocations[num_relocs+1].oldPath = NULL;
+		relocations[num_relocs+1].newPath = NULL;
+    	}
+#endif
 
 	eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
 
diff -Naur rpm-4.1.1.orig/lib/rpmrc.c rpm-4.1.1.new/lib/rpmrc.c
--- rpm-4.1.1.orig/lib/rpmrc.c	Fri Oct 10 10:02:01 2003
+++ rpm-4.1.1.new/lib/rpmrc.c	Fri Oct 10 10:03:09 2003
@@ -21,7 +21,7 @@
 #include "debug.h"
 
 /*@observer@*/ /*@unchecked@*/
-static const char *defrcfiles = LIBRPMRC_FILENAME ":" VENDORRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"; 
+static const char *defrcfiles = LIBRPMRC_FILENAME ":" VENDORRPMRC_FILENAME ":%{_runtimeprefix}/etc/rpmrc:~/.eldk_rpmrc"; 
 
 /*@observer@*/ /*@checked@*/
 const char * macrofiles = MACROFILES;
@@ -513,6 +513,184 @@
 export RPM_BUILD_ROOT\n}\
 ";
 
+#ifdef HAVE_RUNTIME_PREFIX
+#define LIB_PATH "/usr/lib/rpm/"
+#define USR_PATH "/usr/bin/"
+extern char * runtime_prefix;
+extern char * target_arch;
+extern char * target_cpu;
+extern int    install_mode;
+
+int get_path_len();
+void obtain_runtime_prefix(char *argv0);
+
+int get_path_len ()
+{
+	int path_max;
+
+#ifdef PATH_MAX
+	return PATH_MAX;
+#else
+	path_max = pathconf (path, _PC_PATH_MAX);
+	if (path_max <= 0)
+		path_max = 4096;
+	return path_max;
+#endif
+}
+
+void find_file_path (char * filename, char * path)
+{
+	char  * p;
+	char  * dirs;
+	char  * entry, * tmp;
+	DIR * dir;
+	int found;
+	struct dirent * file;
+
+	p = getenv("PATH");
+	dirs  = xmalloc(strlen(p)+1);
+	entry = xmalloc(strlen(p)+1);
+	tmp = xmalloc(strlen(p)+1);
+	strcpy(dirs, p);
+
+	for (found = 0, p = strtok_r(dirs, ":", &entry); !found && p;
+		p = strtok_r(NULL, ":", &entry)) {
+		dir = opendir(p);
+		if (!dir) continue;
+		while (file = readdir(dir)) {
+			if (!strncmp(filename, file->d_name, file->d_reclen)) {
+				struct stat fstat;
+				sprintf(tmp, "%s/%s", p, file->d_name);
+				if (stat(tmp, &fstat) < 0) continue;
+				if (!S_ISREG(fstat.st_mode)) continue;
+				if ((fstat.st_mode & S_IXUSR) || 
+				    (fstat.st_mode & S_IXGRP) ||
+				    (fstat.st_mode & S_IXOTH)) {
+					found = 1;
+					break;
+				}
+			}
+
+		 }
+		 closedir(dir);
+	}
+
+	strcpy(path, tmp);
+}
+
+void obtain_runtime_prefix (char *argv0)
+{
+	char * tmp, *p;
+	int i, path_len;
+
+	install_mode = 0;
+	path_len = get_path_len();
+	runtime_prefix = xmalloc(path_len+1);
+	tmp = xmalloc(path_len+1);
+	strcpy(runtime_prefix,argv0);
+
+again:
+	for (i = strlen(runtime_prefix); i > 0; i--) 
+		if (runtime_prefix[i] == '/') break;
+
+	if (i > 0)
+		runtime_prefix[i+1]=0; 
+	else {
+		find_file_path(runtime_prefix, runtime_prefix);
+		goto again;
+
+	}
+	realpath(runtime_prefix,tmp);
+	strcat(tmp,"/");
+
+	if (!strcmp(tmp + (strlen(tmp) - strlen(LIB_PATH)), LIB_PATH))
+		strcat(tmp,"../../../"); 
+	else
+		if (!strcmp(tmp + (strlen(tmp) - strlen(USR_PATH)), USR_PATH))
+			 strcat(tmp, "../../");
+		else
+			 strcat(tmp, "../");
+
+	realpath(tmp, runtime_prefix);
+	if (getenv("CROSS_COMPILE")) {
+		tmp = strdup(getenv("CROSS_COMPILE"));
+
+		p = rindex(tmp, '/');
+
+		if (!p) 
+			p =  tmp; 
+		else  
+			p ++;
+
+		target_arch = p;
+		for(i = strlen(target_arch); i > 0; i--)
+		if (target_arch[i] == '_') {
+			target_arch[i] = 0;
+			break;
+		}
+
+
+		if (i <= 0) {
+			printf("CROSS_COMPILE variable has wrong format\n");
+			exit(2);
+		}
+
+		target_cpu = strdup(target_arch + strlen(target_arch) + 1);
+		if (target_cpu[strlen(target_cpu) - 1] == '-')
+			target_cpu[strlen(target_cpu) - 1] = 0;
+
+		addMacro(NULL, "_targetarch", NULL, target_arch, RMIL_DEFAULT);
+		addMacro(NULL, "_targetcpu" , NULL, target_arch, RMIL_DEFAULT);
+		addMacro(NULL, "_realtargetcpu", NULL, target_cpu, 
+			RMIL_DEFAULT);
+
+	} else {
+		/* If CROSS_COMPILE variable is not set, analyse the argv[0].
+		   If argv[0] is <arch>-rpm, set _targetarch to <arch>.
+		   If argv[0] is <arch>_<cpu>-rpm, set _targetarch to <arch> and
+		   set CROSS_COMPILE to <arch>_<cpu>.
+		*/
+		p = basename(argv0);
+		tmp = strrchr(p, '-');
+
+		if (tmp && --tmp != p) {
+			target_arch = strdup(p);
+			target_arch[tmp - p + 1] = '\0';
+			if (p = strchr(target_arch, '_')) {
+				/* <cpu> component present */
+
+				setenv("CROSS_COMPILE", target_arch, 0);
+				*p = '\0';
+				target_cpu = strdup(p + 1);
+				addMacro(NULL, "_targetcpu", NULL, target_arch,
+					 RMIL_DEFAULT);
+			 	addMacro(NULL, "_realtargetcpu", NULL, 
+					target_cpu, RMIL_DEFAULT);
+			} else {
+				target_cpu  = NULL;
+			}
+			setenv("CURRENT_ARCH",target_arch, 0);
+			addMacro(NULL, "_targetarch", NULL, target_arch, 
+				RMIL_DEFAULT);
+		 } else {
+			target_arch = NULL;
+			target_cpu  = NULL;
+			if (getenv("CURRENT_ARCH")) {
+				addMacro(NULL, "_targetarch", NULL, 
+					getenv("CURRENT_ARCH"), RMIL_DEFAULT);
+			} else {
+				addMacro(NULL, "_targetarch", NULL, 
+					TARGET_ARCH, RMIL_DEFAULT);
+			}
+		 }
+
+	}
+
+	addMacro(NULL, "_runtimeprefix",NULL, runtime_prefix,RMIL_DEFAULT);
+	setenv("RUNTIME_PREFIX",runtime_prefix,1);
+}
+#endif
+
 static void setDefaults(void)
 	/*@globals rpmGlobalMacroContext, internalState @*/
 	/*@modifies rpmGlobalMacroContext, internalState @*/
@@ -788,7 +966,13 @@
     char * p, * pe;
     int rc;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    char * pl = alloca(strlen(platform) + strlen(runtime_prefix) + 2);
+    sprintf(pl, "%s/%s\n", runtime_prefix, platform);
+    rc = rpmioSlurp((const char *)pl, &b, &blen);
+#else
     rc = rpmioSlurp(platform, &b, &blen);
+#endif
 
     if (rc || b == NULL || blen <= 0) {
 	rc = -1;
@@ -1617,10 +1801,22 @@
     delMacro(NULL, "_target_cpu");
     addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC);
     delMacro(NULL, "_target_os");
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE"))
+	addMacro(NULL, "_target_os", NULL, TARGET_OS, RMIL_RPMRC);
+    else
+	addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
+#else
     addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
+#endif
 /*
  * XXX Make sure that per-arch optflags is initialized correctly.
  */
+
+#ifdef HAVE_RUNTIME_PREFIX
+  ca = rpmExpand("%{_target_cpu}", NULL);
+#endif
+
   { const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
     if (optflags != NULL) {
 	delMacro(NULL, "optflags");
@@ -1777,6 +1973,9 @@
 	    strcpy(fn, home);
 	    r++;
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	r = rpmExpand(r, NULL);
+#endif
 	strncat(fn, r, sizeof(fn) - (strlen(fn) + 1));
 	fn[sizeof(fn)-1] = '\0';
 
diff -Naur rpm-4.1.1.orig/lib/transaction.c rpm-4.1.1.new/lib/transaction.c
--- rpm-4.1.1.orig/lib/transaction.c	Mon Mar  3 20:32:07 2003
+++ rpm-4.1.1.new/lib/transaction.c	Fri Oct 10 10:03:09 2003
@@ -45,6 +45,10 @@
 /*@access rpmtsi @*/
 /*@access rpmts @*/
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+#endif
+
 /**
  */
 static int archOkay(/*@null@*/ const char * pkgArch)
@@ -521,6 +525,8 @@
     uint_32 fixupSize = 0;
     rpmps ps;
     const char * fn;
+    char *t = 0;
+    int len;
     int i, j;
   
     ps = rpmtsProblems(ts);
@@ -539,6 +545,13 @@
 	    continue;
 
 	fn = rpmfiFN(fi);
+#ifdef HAVE_RUNTIME_PREFIX
+	len = strlen(runtime_prefix);
+	if (strncmp(fn, runtime_prefix, len)) {
+	    t = malloc(len + 1 + strlen(fn));
+	    sprintf(t, "%s%s", runtime_prefix, fn);
+	}
+#endif
 	fiFps = fi->fps + i;
 	FFlags = rpmfiFFlags(fi);
 	FMode = rpmfiFMode(fi);
@@ -611,7 +624,7 @@
 		/* XXX is this test still necessary? */
 		if (fi->actions[i] != FA_UNKNOWN)
 		    /*@switchbreak@*/ break;
-		if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+		if ((FFlags & RPMFILE_CONFIG) && !lstat(t?t:fn, &sb)) {
 		    /* Here is a non-overlapped pre-existing config file. */
 		    fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_BACKUP;
@@ -636,7 +649,7 @@
 	    /* Try to get the disk accounting correct even if a conflict. */
 	    fixupSize = rpmfiFSize(otherFi);
 
-	    if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+	    if ((FFlags & RPMFILE_CONFIG) && !lstat(t?t:fn, &sb)) {
 		/* Here is an overlapped  pre-existing config file. */
 		fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_SKIP;
@@ -682,6 +695,12 @@
 	/* Update disk space info for a file. */
 	rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
 		fi->replacedSizes[i], fixupSize, fi->actions[i]);
+#ifdef HAVE_RUNTIME_PREFIX
+        if (t) {
+                free(t);
+        }
+        t = 0;
+#endif
 
     }
     ps = rpmpsFree(ps);
diff -Naur rpm-4.1.1.orig/macros.in rpm-4.1.1.new/macros.in
--- rpm-4.1.1.orig/macros.in	Fri Oct 10 10:02:01 2003
+++ rpm-4.1.1.new/macros.in	Fri Oct 10 10:03:09 2003
@@ -96,7 +96,7 @@
 %_builddir		%{_topdir}/BUILD
 
 #	The interpreter used for build scriptlets.
-%_buildshell		/bin/sh
+%_buildshell		@OSSHELL@
 
 #	The path to the bzip2 executable (legacy, use %{__bzip2} instead).
 %_bzip2bin		%{__bzip2}
diff -Naur rpm-4.1.1.orig/popt/Makefile.in rpm-4.1.1.new/popt/Makefile.in
--- rpm-4.1.1.orig/popt/Makefile.in	Fri Mar  7 20:16:14 2003
+++ rpm-4.1.1.new/popt/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -133,7 +133,7 @@
 
 noinst_HEADERS = findme.h poptint.h system.h
 
-noinst_PROGRAMS = test1 test2 test3
+#noinst_PROGRAMS = test1 test2 test3
 test1_SOURCES = test1.c
 test1_LDFLAGS = -all-static
 test1_LDADD = $(usrlib_LTLIBRARIES)
@@ -173,7 +173,7 @@
 am_libpopt_la_OBJECTS = popt.lo findme.lo poptparse.lo poptconfig.lo \
 	popthelp.lo
 libpopt_la_OBJECTS = $(am_libpopt_la_OBJECTS)
-noinst_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT) test3$(EXEEXT)
+#noinst_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT) test3$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 
 am_test1_OBJECTS = test1.$(OBJEXT)
diff -Naur rpm-4.1.1.orig/popt/config.h.in rpm-4.1.1.new/popt/config.h.in
--- rpm-4.1.1.orig/popt/config.h.in	Fri Mar  7 20:39:24 2003
+++ rpm-4.1.1.new/popt/config.h.in	Fri Oct 10 10:03:09 2003
@@ -208,6 +208,9 @@
 /* Full path to popt top_sourcedir. */
 #undef POPT_SOURCE_PATH
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
 /* Define if <inttypes.h> exists and defines unusable PRI* macros. */
 #undef PRI_MACROS_BROKEN
 
diff -Naur rpm-4.1.1.orig/popt/configure rpm-4.1.1.new/popt/configure
--- rpm-4.1.1.orig/popt/configure	Fri Mar  7 20:16:17 2003
+++ rpm-4.1.1.new/popt/configure	Fri Oct 10 10:03:09 2003
@@ -9198,7 +9198,9 @@
 fi
 
 
-
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RUNTIME_PREFIX 1
+_ACEOF
 
 
 # This can be used to rebuild libtool when needed
diff -Naur rpm-4.1.1.orig/popt/intl/Makefile.in rpm-4.1.1.new/popt/intl/Makefile.in
--- rpm-4.1.1.orig/popt/intl/Makefile.in	Sun Jul 21 16:21:15 2002
+++ rpm-4.1.1.new/popt/intl/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -105,9 +105,9 @@
 
 INCLUDES = -I.. -I. -I$(top_srcdir)/intl
 
-all: all-@USE_INCLUDED_LIBINTL@
+all: all-no
 all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
-all-no: all-no-@BUILD_INCLUDED_LIBINTL@
+all-no: all-no-no
 all-no-yes: libgnuintl.$la
 all-no-no:
 
diff -Naur rpm-4.1.1.orig/popt/popt.c rpm-4.1.1.new/popt/popt.c
--- rpm-4.1.1.orig/popt/popt.c	Sat Jan 18 15:04:34 2003
+++ rpm-4.1.1.new/popt/popt.c	Fri Oct 10 10:03:09 2003
@@ -51,6 +51,9 @@
 
 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
 {
+#ifdef HAVE_RUNTIME_PREFIX
+    path = (const char *) rpmExpand(path, NULL);
+#endif
     con->execPath = _free(con->execPath);
     con->execPath = xstrdup(path);
     con->execAbsolute = allowAbsolute;
diff -Naur rpm-4.1.1.orig/popt/poptconfig.c rpm-4.1.1.new/popt/poptconfig.c
--- rpm-4.1.1.orig/popt/poptconfig.c	Sat Jan 18 15:04:34 2003
+++ rpm-4.1.1.new/popt/poptconfig.c	Fri Oct 10 10:03:09 2003
@@ -100,6 +100,10 @@
     int fd, rc;
     off_t fileLength;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    fn = rpmExpand(fn, NULL);
+#endif
+
     fd = open(fn, O_RDONLY);
     if (fd < 0)
 	return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
diff -Naur rpm-4.1.1.orig/rpm.c rpm-4.1.1.new/rpm.c
--- rpm-4.1.1.orig/rpm.c	Thu May 16 18:55:25 2002
+++ rpm-4.1.1.new/rpm.c	Fri Oct 10 10:03:09 2003
@@ -234,6 +234,14 @@
 static void printUsage(void);
 static void printHelpLine(char * prefix, char * help);
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+extern char * target_arch;
+extern char * target_cpu;
+extern int    install_mode;
+extern void obtain_runtime_prefix(char *argv0);
+#endif
+
 static void printVersion(void) {
     fprintf(stdout, _("RPM version %s\n"), rpmEVR);
 }
@@ -604,6 +612,10 @@
     int upgrade = 0;
     int freshen = 0;
     int probFilter = 0;
+
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
 	
 #if HAVE_MCHECK_H && HAVE_MTRACE
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
@@ -673,10 +685,20 @@
     /* set up the correct locale */
     setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+	localedir = xmalloc(get_path_len() + 1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     textdomain(PACKAGE);
 
     rpmSetVerbosity(RPMMESS_NORMAL);	/* XXX silly use by showrc */
diff -Naur rpm-4.1.1.orig/rpmdb/Makefile.in rpm-4.1.1.new/rpmdb/Makefile.in
--- rpm-4.1.1.orig/rpmdb/Makefile.in	Fri Mar  7 20:17:35 2003
+++ rpm-4.1.1.new/rpmdb/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -229,7 +229,7 @@
 pkginc_HEADERS = db.h header.h hdrinline.h rpmdb.h rpmhash.h
 noinst_HEADERS = fprint.h header_internal.h legacy.h
 
-pkgbindir = @RPMCONFIGDIR@
+pkgbindir = @RPMCONFIGDIROLD@
 pkgbin_PROGRAMS = \
 	rpmdb_deadlock rpmdb_dump rpmdb_load rpmdb_svc rpmdb_stat rpmdb_verify
 
@@ -282,6 +282,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
 	librpmdb.la
+rpmdb_deadlock_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
 rpmdb_dump_SOURCES = 
@@ -290,7 +291,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
 	librpmdb.la
-
+rpmdb_dump_LDFLAGS =       $(LDFLAGS_STATIC)
 
 rpmdb_load_SOURCES = 
 rpmdb_load_LDADD = \
@@ -298,6 +299,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
 	librpmdb.la
+rpmdb_load_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
 rpmdb_printlog_SOURCES = 
@@ -321,6 +323,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
 	librpmdb.la
+rpmdb_stat_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
 rpmdb_svc_SOURCES = 
@@ -331,6 +334,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/gen_db_server.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
 	librpmdb.la
+rpmdb_svc_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
 rpmdb_upgrade_SOURCES = 
@@ -347,6 +351,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
 	librpmdb.la
+rpmdb_verify_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
 # XXX TODO: figger why .created addition here dinna work
@@ -389,19 +394,19 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_deadlock.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo librpmdb.la
-rpmdb_deadlock_LDFLAGS =
+rpmdb_deadlock_LDFLAGS = $(LDFLAGS_STATIC)
 am_rpmdb_dump_OBJECTS =
 rpmdb_dump_OBJECTS = $(am_rpmdb_dump_OBJECTS)
 rpmdb_dump_DEPENDENCIES = $(top_builddir)/$(WITH_DB_SUBDIR)/db_dump.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo librpmdb.la
-rpmdb_dump_LDFLAGS =
+rpmdb_dump_LDFLAGS = $(LDFLAGS_STATIC)
 am_rpmdb_load_OBJECTS =
 rpmdb_load_OBJECTS = $(am_rpmdb_load_OBJECTS)
 rpmdb_load_DEPENDENCIES = $(top_builddir)/$(WITH_DB_SUBDIR)/db_load.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo librpmdb.la
-rpmdb_load_LDFLAGS =
+rpmdb_load_LDFLAGS =$(LDFLAGS_STATIC)
 am_rpmdb_printlog_OBJECTS =
 rpmdb_printlog_OBJECTS = $(am_rpmdb_printlog_OBJECTS)
 rpmdb_printlog_DEPENDENCIES = \
@@ -420,7 +425,7 @@
 rpmdb_stat_DEPENDENCIES = $(top_builddir)/$(WITH_DB_SUBDIR)/db_stat.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo librpmdb.la
-rpmdb_stat_LDFLAGS =
+rpmdb_stat_LDFLAGS = $(LDFLAGS_STATIC)
 am_rpmdb_svc_OBJECTS =
 rpmdb_svc_OBJECTS = $(am_rpmdb_svc_OBJECTS)
 rpmdb_svc_DEPENDENCIES = \
@@ -429,7 +434,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_server_util.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/gen_db_server.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo librpmdb.la
-rpmdb_svc_LDFLAGS =
+rpmdb_svc_LDFLAGS = $(LDFLAGS_STATIC)
 am_rpmdb_upgrade_OBJECTS =
 rpmdb_upgrade_OBJECTS = $(am_rpmdb_upgrade_OBJECTS)
 rpmdb_upgrade_DEPENDENCIES = \
@@ -443,7 +448,7 @@
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_verify.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo librpmdb.la
-rpmdb_verify_LDFLAGS =
+rpmdb_verify_LDFLAGS = $(LDFLAGS_STATIC)
 am_tjfn_OBJECTS = tjfn.$(OBJEXT)
 tjfn_OBJECTS = $(am_tjfn_OBJECTS)
 tjfn_DEPENDENCIES = librpmdb.la
diff -Naur rpm-4.1.1.orig/rpmdb/rpmdb.c rpm-4.1.1.new/rpmdb/rpmdb.c
--- rpm-4.1.1.orig/rpmdb/rpmdb.c	Fri Mar 14 19:05:32 2003
+++ rpm-4.1.1.new/rpmdb/rpmdb.c	Fri Oct 10 10:03:09 2003
@@ -42,6 +42,10 @@
 #include "header_internal.h"	/* XXX for HEADERFLAG_ALLOCATED */
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+#include "rpmlib.h"
+#endif
+
 /*@access dbiIndexSet@*/
 /*@access dbiIndexItem@*/
 /*@access rpmts@*/		/* XXX compared with NULL */
@@ -2341,6 +2345,20 @@
     mi->mi_prevoffset = mi->mi_offset;
     mi->mi_modified = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE")) {
+	int type, count;
+	char * name, * tmp = getenv("CROSS_COMPILE");
+
+	if (tmp[strlen(tmp) - 1] == '-')
+	     tmp[strlen(tmp) - 1] = 0;
+
+	headerGetEntry(mi->mi_h, RPMTAG_NAME, &type, (void **) &name, &count);
+	if (strcmp(name + strlen(name) - strlen(tmp), tmp) != 0)
+	    return rpmdbNextIterator(mi);
+    }
+#endif
+
 /*@-compdef -retalias -retexpose -usereleased @*/
     return mi->mi_h;
 /*@=compdef =retalias =retexpose =usereleased @*/
@@ -2474,6 +2492,23 @@
     (void) rpmdbCheckSignals();
 
     /* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE") && keyp && rpmtag != RPMDBI_PACKAGES) {
+	char * tmp_keyp;
+	char * tmp = getenv("CROSS_COMPILE");
+
+	if (tmp[strlen(tmp) - 1] == '-')
+	    tmp[strlen(tmp) - 1] = 0;
+
+	if (!strstr(keyp, tmp) && !strstr(keyp, ".so") &&
+	    !strchr(keyp, '/') && !strchr(keyp, '(')) {
+	    tmp_keyp = xmalloc(strlen(keyp) + 1 + strlen(tmp) + 1);
+	    sprintf(tmp_keyp, "%s-%s", keyp, tmp);
+	    keyp = tmp_keyp;
+	}
+   }
+#endif
+
     if (rpmtag == RPMDBI_LABEL) {
 	rpmtag = RPMTAG_NAME;
 	isLabel = 1;
diff -Naur rpm-4.1.1.orig/rpmio/macro.c rpm-4.1.1.new/rpmio/macro.c
--- rpm-4.1.1.orig/rpmio/macro.c	Sat Jan 18 15:04:35 2003
+++ rpm-4.1.1.new/rpmio/macro.c	Fri Oct 10 10:03:09 2003
@@ -111,6 +111,59 @@
 
 #define	MACRO_CHUNK_SIZE	16
 
+#ifdef HAVE_RUNTIME_PREFIX
+typedef struct {
+	char * name;
+	char * subst;
+	int target_only;
+} Subst;
+
+Subst Substitutions[16] = {
+	{"_usr",	   "/usr",0},
+	{"_prefix",	   "/usr",0},
+	{"_sysconfdir",	   "/etc",0},
+	{"_mandir",	   "%{_prefix}/share/man",0},
+	{"_localstatedir", "/var",0},
+	{"_usrsrc",	   "%{_runtimeprefix}%{_usr}/src",0},
+	{"_var",	   "%{_runtimeprefix}/var",0},
+	{"__find_provides","%{_runtimeprefix}/usr/lib/rpm/find-provides",0},
+	{"__find_requires",   "%{_runtimeprefix}/usr/lib/rpm/find-requires",0},
+	{"__os_install_post", "%{_runtimeprefix}/usr/lib/rpm/brp-compress \n\
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip \n\
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip-comment-note \n\
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip-shared \n\
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip-static-archive \n\
+		%{nil}",0},
+	{"find_lang","%{_runtimeprefix}/usr/lib/rpm/find-lang.sh %{buildroot}"
+			,0},
+	{"_arch",	"%{_targetarch}",1},
+	{"_target_cpu",	"%{_targetcpu}",1},
+	{"_vendor",	"denx"},
+	{"_topdir",	"%{_usrsrc}/%{_vendor}"},
+	{"_dbapi",	"3"}
+};
+
+char * runtime_prefix;
+char * target_arch;
+char * target_cpu;
+int    install_mode;
+
+static char * replace_poor_macros(const char * macroname, const char * body);
+
+static char * replace_poor_macros(const char * macroname, const char * body)
+{
+       int i;
+
+       for (i=0;i<sizeof(Substitutions)/sizeof(Substitutions[0]);i++) {
+	       if (!target_arch && Substitutions[i].target_only) continue;
+	       if (!strcmp(macroname,Substitutions[i].name))
+		       return Substitutions[i].subst;
+       }
+
+       return body;
+}
+#endif
+
 /* forward ref */
 static int expandMacro(MacroBuf mb)
 	/*@globals rpmGlobalMacroContext,
@@ -1515,6 +1568,11 @@
 {
     MacroEntry * mep;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    const char * bb;
+    bb = replace_poor_macros(n, b);
+#endif
+
     if (mc == NULL) mc = rpmGlobalMacroContext;
 
     /* If new name, expand macro table */
@@ -1527,7 +1585,11 @@
 
     if (mep != NULL) {
 	/* Push macro over previous definition */
+#ifdef HAVE_RUNTIME_PREFIX
+	pushMacro(mep, n, o, bb, level);
+#else
 	pushMacro(mep, n, o, b, level);
+#endif
 
 	/* If new name, sort macro table */
 	if ((*mep)->prev == NULL)
@@ -1620,6 +1682,10 @@
 		strncat(buf, "/", sizeof(buf) - strlen(buf));
 	    }
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	/* Or another shell variable */
+	mfile = rpmExpand(mfile, NULL);
+#endif
 	strncat(buf, mfile, sizeof(buf) - strlen(buf));
 	buf[sizeof(buf)-1] = '\0';
 
@@ -1987,6 +2053,10 @@
     extern char *optarg;
     extern int optind;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
+
     while ((c = getopt(argc, argv, "f:")) != EOF ) {
 	switch (c) {
 	case 'f':
diff -Naur rpm-4.1.1.orig/rpmqv.c rpm-4.1.1.new/rpmqv.c
--- rpm-4.1.1.orig/rpmqv.c	Tue Mar  4 16:32:57 2003
+++ rpm-4.1.1.new/rpmqv.c	Fri Oct 10 10:03:09 2003
@@ -122,6 +122,11 @@
     exit(EXIT_FAILURE);
 }
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+extern void obtain_runtime_prefix(char *argv0);
+#endif
+
 static void printVersion(FILE * fp)
 	/*@globals rpmEVR, fileSystem @*/
 	/*@modifies *fp, fileSystem @*/
@@ -203,6 +208,10 @@
     int i;
 #endif
 	
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
+
 #if HAVE_MCHECK_H && HAVE_MTRACE
     /*@-noeffect@*/
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
@@ -220,6 +229,13 @@
 	else __progname = argv[0];
     }
 
+#ifdef HAVE_RUNTIME_PREFIX
+    {
+	char * tmp;
+	if ((tmp = strrchr(__progname, '-')) != NULL) __progname = ++tmp;
+    }
+#endif
+
     /* Set the major mode based on argv[0] */
     /*@-nullpass@*/
 #ifdef	IAM_RPMBT
@@ -269,10 +285,20 @@
     /* set up the correct locale */
     (void) setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+	localedir = xmalloc(get_path_len() + 1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     textdomain(PACKAGE);
 #endif
 
diff -Naur rpm-4.1.1.orig/rpmrc.in rpm-4.1.1.new/rpmrc.in
--- rpm-4.1.1.orig/rpmrc.in	Tue Mar  4 20:04:50 2003
+++ rpm-4.1.1.new/rpmrc.in	Fri Oct 10 10:03:09 2003
@@ -28,7 +28,7 @@
 
 optflags: sparc -O2 -g -m32 -mtune=ultrasparc
 optflags: sparcv9 -O2 -g -m32 -mcpu=ultrasparc
-optflags: sparc64 -O2 -g -m64 -mcpu=ultrasparc
+optflags: sparc64 -O2 -g -m32 -mcpu=ultrasparc
 
 optflags: m68k -O2 -g -fomit-frame-pointer
 
@@ -97,7 +97,7 @@
 arch_canon:     ia64:	ia64	9
 
 arch_canon:	sparc64:sparc64 10
-arch_canon:	sun4u:	sparc64 10
+arch_canon:	sun4u:	sparc	 3
 arch_canon:	mipsel:	mipsel	11
 
 arch_canon:	armv3l: armv3l	12
@@ -176,7 +176,7 @@
 buildarchtranslate: sun4d: sparc
 buildarchtranslate: sun4m: sparc
 buildarchtranslate: sparcv9: sparc
-buildarchtranslate: sun4u: sparc64
+buildarchtranslate: sun4u: sparc
 
 buildarchtranslate: osfmach3_ppc: ppc
 buildarchtranslate: powerpc: ppc
@@ -351,7 +351,7 @@
 
 buildarch_compat: x86_64: noarch
 
-macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.prelink:@SYSCONFIGDIR@/macros.solve:@SYSCONFIGDIR@/macros.up2date:@SYSCONFIGDIR@/macros:@SYSCONFIGDIR@/%{_target}/macros:~/.rpmmacros
+macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.prelink:@SYSCONFIGDIR@/macros.solve:@SYSCONFIGDIR@/macros.up2date:@SYSCONFIGDIR@/%{_target}/macros:~/.eldk_rpmmacros
 
 # \endverbatim
 #*/
diff -Naur rpm-4.1.1.orig/scripts/brp-strip-shared rpm-4.1.1.new/scripts/brp-strip-shared
--- rpm-4.1.1.orig/scripts/brp-strip-shared	Sat Mar  1 03:56:21 2003
+++ rpm-4.1.1.new/scripts/brp-strip-shared	Fri Oct 10 10:03:09 2003
@@ -12,6 +12,7 @@
 # our libraries are not (should not be, at least) +x.
 for f in `find $RPM_BUILD_ROOT -type f -a -exec file {} \; | \
         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
+	grep -v 'libpthread' | \
 	grep ' shared object,' | \
 	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'`; do
 	strip --strip-unneeded $f
diff -Naur rpm-4.1.1.orig/scripts/find-lang.sh rpm-4.1.1.new/scripts/find-lang.sh
--- rpm-4.1.1.orig/scripts/find-lang.sh	Fri Jun 28 16:51:17 2002
+++ rpm-4.1.1.new/scripts/find-lang.sh	Fri Oct 10 10:03:09 2003
@@ -82,17 +82,13 @@
 s:'"$TOP_DIR"'::
 '"$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%lang(\2) \1\2:
-s:^\([^%].*\)::
-s:%lang(C) ::
-' > $MO_NAME
+' | sed -n '/^%/p' | sed -e 's:%lang(C) ::' > $MO_NAME
 
 find $TOP_DIR -type d|sed '
 s:'"$TOP_DIR"'::
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%dir %lang(\2) \1\2:
-s:^\([^%].*\)::
-s:%lang(C) ::
-' >> $MO_NAME
+' | sed -n '/^%/p' | sed -e 's:%lang(C) ::' >> $MO_NAME
 
 if ! grep -q / $MO_NAME; then
 	echo "No translations found for ${NAME} in ${TOP_DIR}"
diff -Naur rpm-4.1.1.orig/tools/Makefile.in rpm-4.1.1.new/tools/Makefile.in
--- rpm-4.1.1.orig/tools/Makefile.in	Fri Mar  7 20:17:37 2003
+++ rpm-4.1.1.new/tools/Makefile.in	Fri Oct 10 10:03:09 2003
@@ -226,8 +226,7 @@
 
 LDADD = \
 	$(top_builddir)/lib/librpm.la \
-	@WITH_LIBELF_LIB@ \
-	@INTLLIBS@
+	@WITH_LIBELF_LIB@ 
 
 
 staticLDFLAGS = @LDFLAGS_STATIC@ @LDFLAGS_NPTL@
@@ -236,7 +235,7 @@
 	convertdb1 dump dumpdb rpmarchive rpmheader rpmlead rpmsignature
 
 
-pkgbindir = @RPMCONFIGDIR@
+pkgbindir = @RPMCONFIGDIROLD@
 pkgbin_PROGRAMS = debugedit javadeps rpmcache rpmdeps rpmfile
 
 bin_PROGRAMS = rpmgraph
@@ -249,20 +248,17 @@
 
 rpmcache_SOURCES = rpmcache.c
 
-#rpmcache_LDFLAGS =	$(staticLDFLAGS)
 rpmdeps_SOURCES = rpmdeps.c
-rpmdeps_LDADD = $(top_builddir)/build/librpmbuild.la
+rpmdeps_LDADD = $(top_builddir)/build/librpmbuild.la $(LDADD)
 
+rpmdeps_LDFLAGS =     
 rpmfile_SOURCES = rpmfile.c
-rpmfile_LDADD = $(top_builddir)/rpmio/librpmio.la
+rpmfile_LDADD = $(top_builddir)/rpmio/librpmio.la $(LDADD)
 
-#rpmfile_LDFLAGS =	$(staticLDFLAGS)
 rpmgraph_SOURCES = rpmgraph.c
 
-#rpmgraph_LDFLAGS =	$(staticLDFLAGS)
 rpminject_SOURCES = rpminject.c
 
-#rpminject_LDFLAGS =	$(staticLDFLAGS)
 rpmsort_SOURCES = rpmsort.c
 subdir = tools
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -284,7 +280,7 @@
 convertdb1_LDFLAGS =
 am_debugedit_OBJECTS = debugedit.$(OBJEXT) hashtab.$(OBJEXT)
 debugedit_OBJECTS = $(am_debugedit_OBJECTS)
-debugedit_LDADD = $(LDADD)
+debugedit_LDADD = $(LDADD) $(top_builddir)/rpmio/.libs/librpmio.a
 debugedit_DEPENDENCIES = $(top_builddir)/lib/librpm.la
 debugedit_LDFLAGS =
 dump_SOURCES = dump.c
@@ -704,12 +700,19 @@
 	uninstall-am uninstall-binPROGRAMS uninstall-info-am \
 	uninstall-pkgbinPROGRAMS
 
-#rpmdeps_LDFLAGS =	$(staticLDFLAGS)
+rpmdeps_LDFLAGS =
 
 rpmfile.c: $(top_builddir)/file/file.c
 	rm -f $@
 	ln -s $< $@
-#rpmsort_LDFLAGS =	$(staticLDFLAGS)
+rpmsort_LDFLAGS =
+convertdb1_LDFLAGS =  
+debugedit_LDFLAGS =  
+javadeps_LDFLAGS =  
+rpmcache_LDFLAGS = 
+rpmfile_LDFLAGS = 
+rpmgraph_LDFLAGS =
+rpminject_LDFLAGS = 
 
 $(PROGRAMS): $(LDADD)
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff -Naur rpm-4.1.1.orig/tools/rpmsort.c rpm-4.1.1.new/tools/rpmsort.c
--- rpm-4.1.1.orig/tools/rpmsort.c	Mon Mar  3 17:11:45 2003
+++ rpm-4.1.1.new/tools/rpmsort.c	Fri Oct 10 10:03:09 2003
@@ -287,16 +287,31 @@
     int arg;
     int ec = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
+
 #if HAVE_MCHECK_H && HAVE_MTRACE
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
 #endif
     setprogname(argv[0]);	/* Retrofit glibc __progname */
     (void)setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef  __LCLINT__
 #define LOCALEDIR	"/usr/share/locale"
 #endif
     (void)bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+
+	localedir = xmalloc(get_path_len()+1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     (void)textdomain(PACKAGE);
 
     _depends_debug = 1;
@@ -311,8 +326,10 @@
 	    rpmIncreaseVerbosity();
 	    break;
 	default:
+#if 0
 	    fprintf(stderr, _("unknown popt return (%d)"), arg);
 	    exit(EXIT_FAILURE);
+#endif
 	    /*@notreached@*/ break;
 	}
     }
--- rpm-4.1.1/rpmdb/Makefile.in.orig	Fri Oct 10 15:06:06 2003
+++ rpm-4.1.1/rpmdb/Makefile.in	Fri Oct 10 15:09:14 2003
@@ -255,7 +255,6 @@ librpmdb_la_SOURCES = \
 librpmdb_la_LDFLAGS = -release 4.1 -L/var/tmp/rpm-root$(usrlibdir) \
 	$(top_builddir)/rpmio/librpmio.la \
 	$(top_builddir)/popt/libpopt.la \
-	@WITH_LIBELF_LIB@ \
 	@libdb3@
 
 librpmdb_la_LIBADD = $(DBLIBOBJS) $(DB3LOBJS)
@@ -265,7 +264,8 @@ rpmdb_archive_SOURCES = 
 rpmdb_archive_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_archive.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 
 
 rpmdb_checkpoint_SOURCES = 
@@ -273,7 +273,8 @@ rpmdb_checkpoint_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_checkpoint.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 
 
 rpmdb_deadlock_SOURCES = 
@@ -281,7 +282,8 @@ rpmdb_deadlock_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_deadlock.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_deadlock_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
@@ -290,7 +292,8 @@ rpmdb_dump_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_dump.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_dump_LDFLAGS =       $(LDFLAGS_STATIC)
 
 rpmdb_load_SOURCES = 
@@ -298,7 +301,8 @@ rpmdb_load_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_load.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_load_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
@@ -306,7 +310,8 @@ rpmdb_printlog_SOURCES = 
 rpmdb_printlog_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_printlog.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 
 
 rpmdb_recover_SOURCES = 
@@ -314,7 +319,8 @@ rpmdb_recover_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_recover.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 
 
 rpmdb_stat_SOURCES = 
@@ -322,7 +328,8 @@ rpmdb_stat_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_stat.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_stat_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
@@ -333,7 +340,8 @@ rpmdb_svc_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_server_util.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/gen_db_server.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_log.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_svc_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
@@ -342,7 +350,8 @@ rpmdb_upgrade_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_upgrade.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 
 
 rpmdb_verify_SOURCES = 
@@ -350,7 +359,8 @@ rpmdb_verify_LDADD = \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/db_verify.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_cache.lo \
 	$(top_builddir)/$(WITH_DB_SUBDIR)/util_sig.lo \
-	librpmdb.la
+	librpmdb.la \
+	@WITH_LIBELF_LIB@
 rpmdb_verify_LDFLAGS =       $(LDFLAGS_STATIC)
 
 
--- rpm-4.1.1/build/Makefile.in.orig	Fri Oct 10 15:26:06 2003
+++ rpm-4.1.1/build/Makefile.in	Fri Oct 10 15:26:24 2003
@@ -235,7 +235,6 @@ librpmbuild_la_LDFLAGS = -release 4.1 -L
 	$(top_builddir)/lib/librpm.la \
 	$(top_builddir)/rpmdb/librpmdb.la \
 	$(top_builddir)/rpmio/librpmio.la \
-	@WITH_LIBELF_LIB@
 
 subdir = build
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
--- rpm-4.1.1/scripts/brp-strip.orig	Fri Oct 10 15:35:30 2003
+++ rpm-4.1.1/scripts/brp-strip	Mon Oct 13 15:39:59 2003
@@ -1,6 +1,6 @@
 #!/bin/sh
 # If using normal root, avoid changing anything.
-if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
+if [ -z "$CROSS_COMPILE" -o -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
 	exit 0
 fi
 
@@ -9,5 +9,5 @@ for f in `find $RPM_BUILD_ROOT -type f \
         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
 	grep -v ' shared object,' | \
 	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'`; do
-	strip -g $f || :
+	$RPM_ARCH-$RPM_OS-strip -g $f || :
 done
--- rpm-4.1.1/scripts/brp-strip-shared.orig	Fri Oct 10 15:35:30 2003
+++ rpm-4.1.1/scripts/brp-strip-shared	Mon Oct 13 15:40:01 2003
@@ -3,7 +3,7 @@
 # Thu Apr 20 - Guilherme Manika <gwm@conectiva.com.br>
 #              Created file
 
-if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
+if [  -z "$CROSS_COMPILE" -o -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
 	exit 0
 fi
 
@@ -15,5 +15,5 @@ for f in `find $RPM_BUILD_ROOT -type f -
 	grep -v 'libpthread' | \
 	grep ' shared object,' | \
 	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'`; do
-	strip --strip-unneeded $f
+	$RPM_ARCH-$RPM_OS-strip --strip-unneeded $f
 done
--- rpm-4.1.1/scripts/brp-strip-static-archive.orig	Fri Oct 10 15:35:30 2003
+++ rpm-4.1.1/scripts/brp-strip-static-archive	Mon Oct 13 13:28:38 2003
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
+if [ -z "$CROSS_COMPILE" -o -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
 	exit 0
 fi
 
@@ -9,5 +9,5 @@ for f in `find $RPM_BUILD_ROOT -type f -
         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
 	grep 'current ar archive' | \
 	sed -n -e 's/^\(.*\):[ 	]*current ar archive/\1/p'`; do
-	strip -g $f
+	$RPM_ARCH-$RPM_OS-strip -g $f
 done
