diff -Nuar rpm-4.0.3.orig/Makefile.am rpm-4.0.3/Makefile.am
--- rpm-4.0.3.orig/Makefile.am	Wed Sep  5 22:09:27 2001
+++ rpm-4.0.3/Makefile.am	Tue Jan 14 15:59:08 2003
@@ -32,7 +32,7 @@
 	$(top_builddir)/rpmdb/librpmdb.la \
 	$(top_builddir)/rpmio/librpmio.la \
 	$(top_builddir)/popt/libpopt.la \
-	@INTLLIBS@ @LIBMISC@
+	@LIBMISC@
 
 rpmbindir = `echo $(bindir) | sed -e s,usr/bin,bin,`
 rpmbin_PROGRAMS = rpm
@@ -40,7 +40,7 @@
 bin_PROGRAMS =		rpm2cpio
 bin_SCRIPTS =		gendiff
 
-pkglibdir =		@RPMCONFIGDIR@
+pkglibdir =		@RPMCONFIGDIROLD@
 pkglib_PROGRAMS =	rpmb rpmd rpmi rpmk rpmq
 pkglib_DATA =		rpmrc rpmpopt-$(VERSION) macros
 pkglib_SCRIPTS =	find-provides find-requires mkinstalldirs \
@@ -63,37 +63,37 @@
 #rpm_LDADD =		$(myLDADD)
 
 rpmb_SOURCES =		build.c
-rpmb_LDFLAGS =		$(myLDFLAGS)
+rpmb_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmb_LDADD =		rpmb.o $(myLDADD)
 rpmb.o:	rpmqv.c
 	$(COMPILE) -DIAM_RPMBT -o $@ -c rpmqv.c
 
 rpmd_SOURCES =
-rpmd_LDFLAGS =		$(myLDFLAGS)
+rpmd_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmd_LDADD =		rpmd.o $(myLDADD)
 rpmd.o:	rpmqv.c
 	$(COMPILE) -DIAM_RPMDB -o $@ -c rpmqv.c
 
 rpmi_SOURCES =
-rpmi_LDFLAGS =		$(myLDFLAGS)
+rpmi_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmi_LDADD =		rpmi.o $(myLDADD)
 rpmi.o:	rpmqv.c
 	$(COMPILE) -DIAM_RPMEIU -o $@ -c rpmqv.c
 
 rpmk_SOURCES =
-rpmk_LDFLAGS =		$(myLDFLAGS)
+rpmk_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmk_LDADD =		rpmk.o $(myLDADD)
 rpmk.o:	rpmqv.c
 	$(COMPILE) -DIAM_RPMK -o $@ -c rpmqv.c
 
 rpmq_SOURCES =
-rpmq_LDFLAGS =		$(myLDFLAGS)
+rpmq_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmq_LDADD =		rpmq.o $(myLDADD)
 rpmq.o:	rpmqv.c
 	$(COMPILE) -DIAM_RPMQV -o $@ -c rpmqv.c
 
 rpm2cpio_SOURCES =	rpm2cpio.c
-rpm2cpio_LDFLAGS =	$(myLDFLAGS)
+rpm2cpio_LDFLAGS =	@LDFLAGS_STATIC@ $(myLDFLAGS)
 rpm2cpio_LDADD =	$(myLDADD) @LIBMISC@
 
 $(PROGRAMS): 		$(myLDADD) @WITH_APIDOCS_TARGET@
diff -Nuar rpm-4.0.3.orig/acconfig.h rpm-4.0.3/acconfig.h
--- rpm-4.0.3.orig/acconfig.h	Wed Aug 15 17:05:27 2001
+++ rpm-4.0.3/acconfig.h	Tue Jan 14 15:59:08 2003
@@ -153,6 +153,15 @@
 /* Build with dmalloc support? */
 #undef DMALLOC
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
+/* the target arhitecture */
+#undef TARGET_ARCH
+
+/* the target os */
+#undef TARGET_OS
+
 ^L
 /* Leave that blank line there!!  Autoheader needs it.
    If you're adding to this file, keep in mind:
diff -Nuar rpm-4.0.3.orig/acinclude.m4 rpm-4.0.3/acinclude.m4
--- rpm-4.0.3.orig/acinclude.m4	Thu Jan  1 03:00:00 1970
+++ rpm-4.0.3/acinclude.m4	Tue Jan 14 15:59:08 2003
@@ -0,0 +1,18 @@
+AC_DEFUN([AC_TARGET_ARCH],
+[AC_ARG_WITH(target_arch,
+[  --with-target-arch  	  The target architecture  [default=ppc]],
+target_arch="$withval", target_arch=ppc)
+AC_DEFINE_UNQUOTED(TARGET_ARCH,"$target_arch")
+
+
+])
+
+AC_DEFUN([AC_TARGET_OS],
+[AC_ARG_WITH(target_os,
+[  --with-target-os
+  	  The target os  [default=linux]],
+target_os="$withval", target_os=linux)
+AC_DEFINE_UNQUOTED(TARGET_OS,"$target_os")
+
+
+])
diff -Nuar rpm-4.0.3.orig/build/files.c rpm-4.0.3/build/files.c
--- rpm-4.0.3.orig/build/files.c	Mon Jul 16 18:38:04 2001
+++ rpm-4.0.3/build/files.c	Tue Jan 14 15:59:08 2003
@@ -21,6 +21,10 @@
 #include "md5.h"
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_arch;
+#endif
+
 /*@access Header @*/
 /*@access TFI_t @*/
 /*@access FD_t @*/
@@ -2382,6 +2386,9 @@
 	    tagflags = RPMSENSE_FIND_PROVIDES;
 	    break;
 	case RPMTAG_REQUIREFLAGS:
+#ifdef HAVE_RUNTIME_PREFIX
+	    if (!target_arch) continue;
+#endif
 	    if (!pkg->autoReq)
 		continue;
 	    failnonzero = 0;
diff -Nuar rpm-4.0.3.orig/build/pack.c rpm-4.0.3/build/pack.c
--- rpm-4.0.3.orig/build/pack.c	Mon Aug 27 20:30:44 2001
+++ rpm-4.0.3/build/pack.c	Tue Jan 14 15:59:08 2003
@@ -17,6 +17,11 @@
 /*@-redecl@*/
 extern int _noDirTokens;
 /*@=redecl@*/
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_cpu;
+extern char * target_arch;
+#endif
+
 
 /*@access StringBuf @*/	/* compared with NULL */
 /*@access TFI_t @*/	/* compared with NULL */
@@ -696,6 +701,56 @@
 
 	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 -Nuar rpm-4.0.3.orig/build/parseSpec.c rpm-4.0.3/build/parseSpec.c
--- rpm-4.0.3.orig/build/parseSpec.c	Thu Jul 19 02:07:23 2001
+++ rpm-4.0.3/build/parseSpec.c	Tue Jan 14 15:59:08 2003
@@ -255,12 +255,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 -Nuar rpm-4.0.3.orig/configure.in rpm-4.0.3/configure.in
--- rpm-4.0.3.orig/configure.in	Wed Aug 15 17:08:49 2001
+++ rpm-4.0.3/configure.in	Tue Jan 14 15:59:08 2003
@@ -81,6 +81,13 @@
 dnl to attempt static executables using libtool. Otherwise
 dnl	LDFLAGS_STATIC=""
 dnl
+
+AC_DEFINE(HAVE_RUNTIME_PREFIX)
+
+AC_TARGET_ARCH
+
+AC_TARGET_OS
+
 AC_MSG_CHECKING(flag used by libtool to link rpm)
 if test X"$GCC" = Xyes ; then
 	case "$target" in
@@ -114,6 +121,14 @@
 	# just link it dynamically
 	LDFLAGS_STATIC=""
 fi
+
+OSSHELL=/bin/sh
+
+case "$target" in
+	*-*-solaris*)	OSSHELL="/usr/local/bin/bash";;
+	*-*-linux*)	OSSHELL="/bin/sh";;
+esac
+AC_SUBST(OSSHELL)
 LDFLAGS_STATIC="${LDFLAGS} ${LDFLAGS_STATIC}"	# libtool format
 AC_MSG_RESULT($LDFLAGS_STATIC)
 AC_SUBST(LDFLAGS_STATIC)
@@ -1048,15 +1063,7 @@
 case "${build_os_noversion}" in
 mint)		RPMCANONARCH=m68kmint ;;
 esac
-RPMCANONVENDOR="$build_vendor"
-case "${build_vendor}" in
-unknown|pc|ibm|redhat|pld|mandrake|conectiva)
-	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
-	;;
-esac
+RPMCANONVENDOR="denx"
 RPMCANONOS="$build_os_noversion"
 AC_SUBST(RPMCANONARCH)
 AC_SUBST(RPMCANONVENDOR)
@@ -1073,20 +1080,25 @@
 else
     usrprefix=$prefix
 fi
-LOCALEDIR="`echo ${usrprefix}/share/locale`"
+
+runtime_prefix='%{_runtimeprefix}/usr'
+
+LOCALEDIR="`echo ${runtime_prefix}/share/locale`"
 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
 AC_SUBST(LOCALEDIR)
 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
 AC_SUBST(LIBDIR)
-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIROLD="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIR="`echo ${runtime_prefix}/lib/rpm`"
 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
 AC_SUBST(RPMCONFIGDIR)
+AC_SUBST(RPMCONFIGDIROLD)
 
-SYSCONFIGDIR="`echo /etc/rpm`"
+SYSCONFIGDIR="`echo ${runtime_prefix}/etc/rpm`"
 AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR")
 AC_SUBST(SYSCONFIGDIR)
 
-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:~/.eldt_rpmmacros"
 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES")
 AC_SUBST(MACROFILES)
 
diff -Nuar rpm-4.0.3.orig/intl/Makefile.in rpm-4.0.3/intl/Makefile.in
--- rpm-4.0.3.orig/intl/Makefile.in	Sat Jun 30 01:02:32 2001
+++ rpm-4.0.3/intl/Makefile.in	Tue Jan 14 15:59:08 2003
@@ -103,9 +103,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 -Nuar rpm-4.0.3.orig/lib/Makefile.am rpm-4.0.3/lib/Makefile.am
--- rpm-4.0.3.orig/lib/Makefile.am	Sat Aug 25 06:05:45 2001
+++ rpm-4.0.3/lib/Makefile.am	Tue Jan 14 15:59:08 2003
@@ -27,7 +27,7 @@
 	-L$(top_builddir)/rpmio/.libs \
 	-L$(top_builddir)/popt/.libs
 
-mylibs = -lrpm -lrpmdb -lrpmio -lpopt @LIBS@ @INTLLIBS@ @LIBMISC@
+mylibs = -lrpm -lrpmdb -lrpmio -lpopt @LIBS@  @LIBMISC@
 LIBS =
 
 lib_LTLIBRARIES = librpm.la
diff -Nuar rpm-4.0.3.orig/lib/depends.c rpm-4.0.3/lib/depends.c
--- rpm-4.0.3.orig/lib/depends.c	Thu Sep  6 00:19:11 2001
+++ rpm-4.0.3/lib/depends.c	Tue Jan 14 15:59:08 2003
@@ -1413,6 +1413,12 @@
 	if (multiLib && !isDependsMULTILIB(requireFlags[i]))
 	    continue;
 
+#ifdef HAVE_RUNTIME_PREFIX
+	else if (*requires[i] == '/' && !access(requires[i], F_OK)) {
+		continue;
+	}
+#endif
+	
 	keyDepend = printDepend("R",
 		requires[i], requiresEVR[i], requireFlags[i]);
 
diff -Nuar rpm-4.0.3.orig/lib/rpminstall.c rpm-4.0.3/lib/rpminstall.c
--- rpm-4.0.3.orig/lib/rpminstall.c	Thu Sep  6 18:40:16 2001
+++ rpm-4.0.3/lib/rpminstall.c	Tue Jan 14 15:59:08 2003
@@ -31,6 +31,10 @@
 static int progressCurrent = 0;
 #endif
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+#endif
+
 /**
  */
 static void printHash(const unsigned long amount, const unsigned long total)
@@ -213,7 +217,11 @@
 		rpmtransFlags transFlags,
 		rpmInstallInterfaceFlags interfaceFlags,
 		rpmprobFilterFlags probFilter,
+#ifdef HAVE_RUNTIME_PREFIX
+		rpmRelocation * relocs)
+#else
 		rpmRelocation * relocations)
+#endif
 {
     int notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
 #ifdef DYING
@@ -230,18 +238,22 @@
     int rc;
     int xx;
     int i;
-
+#ifdef HAVE_RUNTIME_PREFIX
+    rpmRelocation * relocations;
+#endif
     if (fileArgv == NULL) return 0;
 
     memset(eiu, 0, sizeof(*eiu));
 
+#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]. */
     for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
 	av = _free(av);
@@ -364,6 +376,54 @@
 	    eiu->numFailed++; *eiu->fnp = NULL;
 	    continue;
 	}
+
+#ifdef HAVE_RUNTIME_PREFIX
+{
+        int type, count, i;
+        char * name, * arch , * tmp, * cpu;
+        int num_relocs;
+	relocations = 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
+
 	if ((eiu->rpmrc == RPMRC_OK || eiu->rpmrc == RPMRC_BADSIZE) && eiu->isSource) {
 	    rpmMessage(RPMMESS_DEBUG, "\tadded source package [%d]\n",
 		eiu->numSRPMS);
diff -Nuar rpm-4.0.3.orig/lib/rpmrc.c rpm-4.0.3/lib/rpmrc.c
--- rpm-4.0.3.orig/lib/rpmrc.c	Wed Aug 15 17:01:35 2001
+++ rpm-4.0.3/lib/rpmrc.c	Tue Jan 14 15:59:08 2003
@@ -17,7 +17,7 @@
 /*@access FD_t@*/		/* compared with NULL */
 
 /*@observer@*/ static const char *defrcfiles =
-	LIBRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc";
+	LIBRPMRC_FILENAME ":%{_runtimeprefix}/etc/rpmrc:~/.eldt_rpmrc";
 
 /*@observer@*/ const char * macrofiles = MACROFILES;
 
@@ -509,6 +509,175 @@
 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)
 	/*@modifies internalState @*/
 {
@@ -595,6 +764,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';
 
@@ -1522,11 +1694,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.
  */
-  { const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
+#ifdef HAVE_RUNTIME_PREFIX
+ca = rpmExpand("%{_target_cpu}", NULL);
+#endif	     
+  { 
+   const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
     if (optflags != NULL) {
 	delMacro(NULL, "optflags");
 	addMacro(NULL, "optflags", NULL, optflags, RMIL_RPMRC);
diff -Nuar rpm-4.0.3.orig/lib/transaction.c rpm-4.0.3/lib/transaction.c
--- rpm-4.0.3.orig/lib/transaction.c	Wed Sep  5 18:21:37 2001
+++ rpm-4.0.3/lib/transaction.c	Tue Jan 14 15:59:08 2003
@@ -594,6 +594,7 @@
 		    fn, relocations[j].newPath);
 	nrelocated++;
 
+#ifndef HAVE_RUNTIME_PREFIX
 	strcpy(fn, relocations[j].newPath);
 	{   char * te = strrchr(fn, '/');
 	    if (te) {
@@ -607,6 +608,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++) {
@@ -1913,15 +1930,24 @@
 
 		dip = ts->di + i;
 
+#ifndef HAVE_RUNTIME_PREFIX
 		/* XXX Avoid FAT and other file systems that have not inodes. */
 		if (dip->iavail <= 0)
 		    continue;
+#endif
 
 		if (adj_fs_blocks(dip->bneeded) > dip->bavail)
 		    psAppend(ts->probs, RPMPROB_DISKSPACE, fi->ap,
 				ts->filesystems[i], NULL, NULL,
 	 	   (adj_fs_blocks(dip->bneeded) - dip->bavail) * dip->bsize);
 
+#ifdef HAVE_RUNTIME_PREFIX
+                /* XXX Avoid FAT and other file systems that have not inodes. */
+                if (dip->iavail <= 0)
+                    continue;
+#endif
+
+		
 		if (adj_fs_blocks(dip->ineeded) > dip->iavail)
 		    psAppend(ts->probs, RPMPROB_DISKNODES, fi->ap,
 				ts->filesystems[i], NULL, NULL,
diff -Nuar rpm-4.0.3.orig/macros.in rpm-4.0.3/macros.in
--- rpm-4.0.3.orig/macros.in	Tue Jul 31 22:07:57 2001
+++ rpm-4.0.3/macros.in	Tue Jan 14 15:59:08 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 -Nuar rpm-4.0.3.orig/popt/Makefile.am rpm-4.0.3/popt/Makefile.am
--- rpm-4.0.3.orig/popt/Makefile.am	Thu May  3 18:29:03 2001
+++ rpm-4.0.3/popt/Makefile.am	Tue Jan 14 15:59:08 2003
@@ -13,13 +13,13 @@
 
 noinst_HEADERS = findme.h poptint.h system.h
 
-noinst_PROGRAMS = test1 test2
-test1_SOURCES = test1.c
-test1_LDFLAGS = -all-static
-test1_LDADD = $(lib_LTLIBRARIES)
-test2_SOURCES = test2.c
-test2_LDFLAGS = -all-static
-test2_LDADD = $(lib_LTLIBRARIES)
+#noinst_PROGRAMS = test1 test2
+#test1_SOURCES = test1.c
+#test1_LDFLAGS = -all-static
+#test1_LDADD = $(lib_LTLIBRARIES)
+#test2_SOURCES = test2.c
+#test2_LDFLAGS = -all-static
+#test2_LDADD = $(lib_LTLIBRARIES)
 
 noinst_SCRIPTS = testit.sh
 
diff -Nuar rpm-4.0.3.orig/popt/acconfig.h rpm-4.0.3/popt/acconfig.h
--- rpm-4.0.3.orig/popt/acconfig.h	Wed Dec 20 01:24:55 2000
+++ rpm-4.0.3/popt/acconfig.h	Tue Jan 14 15:59:08 2003
@@ -45,6 +45,9 @@
 /* Absolute path to popt top_sourcedir. */
 #undef POPT_SOURCE_PATH
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
 ^L
 /* Leave that blank line there!!  Autoheader needs it.
    If you're adding to this file, keep in mind:
diff -Nuar rpm-4.0.3.orig/popt/configure.in rpm-4.0.3/popt/configure.in
--- rpm-4.0.3.orig/popt/configure.in	Sat Jul  7 15:00:36 2001
+++ rpm-4.0.3/popt/configure.in	Tue Jan 14 15:59:08 2003
@@ -47,6 +47,7 @@
     echo > .depend-done
 fi
 AC_SUBST(TARGET)
+AC_DEFINE(HAVE_RUNTIME_PREFIX)
 
 AC_CHECK_HEADERS(alloca.h float.h libintl.h mcheck.h unistd.h)
 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
@@ -82,5 +83,4 @@
 AC_DEFINE_UNQUOTED(POPT_SOURCE_PATH, "$POPT_SOURCE_PATH")
 AC_SUBST(POPT_SOURCE_PATH)
 
-AC_OUTPUT([Doxyfile Makefile intl/Makefile po/Makefile.in],
-	[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
+AC_OUTPUT([Doxyfile Makefile intl/Makefile po/Makefile.in])
diff -Nuar rpm-4.0.3.orig/popt/intl/Makefile.in rpm-4.0.3/popt/intl/Makefile.in
--- rpm-4.0.3.orig/popt/intl/Makefile.in	Sat Jun 30 01:13:15 2001
+++ rpm-4.0.3/popt/intl/Makefile.in	Tue Jan 14 15:59:08 2003
@@ -103,9 +103,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 -Nuar rpm-4.0.3.orig/popt/popt.c rpm-4.0.3/popt/popt.c
--- rpm-4.0.3.orig/popt/popt.c	Tue Jul 17 05:51:58 2001
+++ rpm-4.0.3/popt/popt.c	Tue Jan 14 15:59:08 2003
@@ -46,6 +46,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 -Nuar rpm-4.0.3.orig/popt/poptconfig.c rpm-4.0.3/popt/poptconfig.c
--- rpm-4.0.3.orig/popt/poptconfig.c	Tue Jul 17 05:47:45 2001
+++ rpm-4.0.3/popt/poptconfig.c	Tue Jan 14 15:59:08 2003
@@ -90,6 +90,9 @@
     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 -Nuar rpm-4.0.3.orig/python/Makefile.am rpm-4.0.3/python/Makefile.am
--- rpm-4.0.3.orig/python/Makefile.am	Sat Jul 21 22:41:49 2001
+++ rpm-4.0.3/python/Makefile.am	Tue Jan 14 15:59:08 2003
@@ -11,6 +11,7 @@
 	-I$(top_srcdir)/rpmio \
 	-I$(top_srcdir)/popt \
 	-I/usr/include/python${PYVER} \
+	-I/usr/local/include/python${PYVER} \
 	@INCPATH@
 
 EXTRA_DIST = hash.h upgrade.h
diff -Nuar rpm-4.0.3.orig/rpm.c rpm-4.0.3/rpm.c
--- rpm-4.0.3.orig/rpm.c	Tue Jul 17 05:07:28 2001
+++ rpm-4.0.3/rpm.c	Tue Jan 14 15:59:08 2003
@@ -233,6 +233,13 @@
 static void printBanner(void);
 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 +611,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 +684,22 @@
     /* set up the correct locale */
     setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
+#else
+  {
+	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 -Nuar rpm-4.0.3.orig/rpmdb/rpmdb.c rpm-4.0.3/rpmdb/rpmdb.c
--- rpm-4.0.3.orig/rpmdb/rpmdb.c	Wed Sep  5 22:00:35 2001
+++ rpm-4.0.3/rpmdb/rpmdb.c	Tue Jan 14 15:59:08 2003
@@ -21,6 +21,10 @@
 #include "misc.h"
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+#include "rpmlib.h"
+#endif
+
 /*@access dbiIndexSet@*/
 /*@access dbiIndexItem@*/
 /*@access Header@*/		/* XXX compared with NULL */
@@ -2002,6 +2006,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
+    
 exit:
 #ifdef	NOTNOW
     if (mi->mi_h) {
@@ -2106,6 +2124,24 @@
     if (rpmdb == NULL)
 	return NULL;
     /* 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
+    
     switch (rpmtag) {
     case RPMDBI_LABEL:
 	rpmtag = RPMTAG_NAME;
diff -Nuar rpm-4.0.3.orig/rpmio/macro.c rpm-4.0.3/rpmio/macro.c
--- rpm-4.0.3.orig/rpmio/macro.c	Fri Jul 20 00:44:20 2001
+++ rpm-4.0.3/rpmio/macro.c	Tue Jan 14 15:59:08 2003
@@ -92,6 +92,58 @@
 
 #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 \
+	%{_runtimeprefix}/usr/lib/rpm/brp-strip \
+	%{_runtimeprefix}/usr/lib/rpm/brp-strip-comment-note \
+%{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
+
 /**
  * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
  * @param p		memory to free
@@ -1421,6 +1473,10 @@
 	const char * n, const char * o, const char * b, int level)
 {
     MacroEntry * mep;
+#ifdef HAVE_RUNTIME_PREFIX
+    const char * bb;
+    bb=replace_poor_macros(n, b);
+#endif
 
     if (mc == NULL) mc = &rpmGlobalMacroContext;
 
@@ -1434,7 +1490,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)
@@ -1525,6 +1585,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';
 
@@ -1877,6 +1941,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 -Nuar rpm-4.0.3.orig/rpmqv.c rpm-4.0.3/rpmqv.c
--- rpm-4.0.3.orig/rpmqv.c	Fri Aug 17 23:06:03 2001
+++ rpm-4.0.3/rpmqv.c	Tue Jan 14 15:59:25 2003
@@ -218,6 +218,11 @@
     exit(EXIT_FAILURE);
 }
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+extern void obtain_runtime_prefix(char *argv0);
+#endif
+
 static void printVersion(void)
 	/*@modifies fileSystem @*/
 {
@@ -308,6 +313,10 @@
     int ec = 0;
     int status;
     int p[2];
+
+#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. */
@@ -319,6 +328,12 @@
 	if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
 	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@*/
@@ -359,12 +374,25 @@
     /* set up the correct locale */
     (void) setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
     textdomain(PACKAGE);
 
+#else
+  {
+	char * localedir;
+	
+	localedir = xmalloc(get_path_len()+1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+    
+#endif
+
     rpmSetVerbosity(RPMMESS_NORMAL);	/* XXX silly use by showrc */
 
     /* Make a first pass through the arguments, looking for --rcfile */
diff -Nuar rpm-4.0.3.orig/rpmrc.in rpm-4.0.3/rpmrc.in
--- rpm-4.0.3.orig/rpmrc.in	Wed Aug 15 18:00:27 2001
+++ rpm-4.0.3/rpmrc.in	Tue Jan 14 15:59:08 2003
@@ -30,7 +30,7 @@
 
 optflags: sparc -O2 -m32 -mtune=ultrasparc
 optflags: sparcv9 -O2 -m32 -mcpu=ultrasparc
-optflags: sparc64 -O2 -m64 -mcpu=ultrasparc
+optflags: sparc64 -O2 -m32 -mcpu=ultrasparc
 
 optflags: m68k -O2 -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
@@ -172,7 +172,7 @@
 buildarchtranslate: sun4d: sparc
 buildarchtranslate: sun4m: sparc
 buildarchtranslate: sparcv9: sparc
-buildarchtranslate: sun4u: sparc64
+buildarchtranslate: sun4u: sparc
 
 buildarchtranslate: osfmach3_ppc: ppc
 buildarchtranslate: powerpc: ppc
@@ -333,7 +333,7 @@
 buildarch_compat: s390: noarch
 buildarch_compat: s390x: noarch
 
-macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.db1:@SYSCONFIGDIR@/macros.cdb:@SYSCONFIGDIR@/macros:@SYSCONFIGDIR@/%{_target}/macros:~/.rpmmacros
+macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.db1:@SYSCONFIGDIR@/macros.cdb:@SYSCONFIGDIR@/%{_target}/macros:~/.eldt_rpmmacros
 
 # \endverbatim
 #*/
diff -Nuar rpm-4.0.3.orig/tools/Makefile.am rpm-4.0.3/tools/Makefile.am
--- rpm-4.0.3.orig/tools/Makefile.am	Tue Aug 14 09:13:00 2001
+++ rpm-4.0.3/tools/Makefile.am	Tue Jan 14 15:59:08 2003
@@ -25,16 +25,16 @@
 	$(top_builddir)/rpmdb/librpmdb.la \
 	$(top_builddir)/rpmio/librpmio.la \
 	$(top_builddir)/popt/libpopt.la \
-	@INTLLIBS@
+	@LIBMISC@
 
 LIBS =
 #LDFLAGS = $(myLDFLAGS)
-LDADD = $(myLDADD)
+LDADD = @LDFLAGS_STATIC@ $(myLDADD)
 
 noinst_PROGRAMS = \
 	dump dumpdb rpmarchive rpmheader rpmlead rpmsignature
 
-pkgbindir = @RPMCONFIGDIR@
+pkgbindir = @RPMCONFIGDIROLD@
 pkgbin_PROGRAMS = javadeps
 
 rpmsort_SOURCES =	rpmsort.c
diff -Nuar rpm-4.0.3.orig/tools/rpmsort.c rpm-4.0.3/tools/rpmsort.c
--- rpm-4.0.3.orig/tools/rpmsort.c	Thu May 31 22:22:21 2001
+++ rpm-4.0.3/tools/rpmsort.c	Tue Jan 14 15:59:08 2003
@@ -313,8 +313,10 @@
 	    rpmIncreaseVerbosity();
 	    break;
 	default:
+#if 0
 	    errx(EXIT_FAILURE, _("unknown popt return (%d)"), arg);
 	    /*@notreached@*/ break;
+#endif
 	}
     }
 
