diff -uNr rpm-4.0.2.ORIG/Makefile.in rpm-4.0.2/Makefile.in
--- rpm-4.0.2.ORIG/Makefile.in	Mon Jan 22 09:17:37 2001
+++ rpm-4.0.2/Makefile.in	Sun Oct 13 00:10:18 2002
@@ -213,23 +213,23 @@
 
 rpmb_SOURCES = build.c
 rpmb_LDFLAGS = $(myLDFLAGS)
-rpmb_LDADD = rpmb.o $(myLDADD)
+rpmb_LDADD = rpmb.o $(myLDADD) @LIBMISC@
 
 rpmdb_SOURCES = 
 rpmdb_LDFLAGS = $(myLDFLAGS)
-rpmdb_LDADD = rpmdb.o $(myLDADD)
+rpmdb_LDADD = rpmdb.o $(myLDADD) @LIBMISC@
 
 rpmi_SOURCES = 
 rpmi_LDFLAGS = $(myLDFLAGS)
-rpmi_LDADD = rpmi.o $(myLDADD)
+rpmi_LDADD = rpmi.o $(myLDADD) @LIBMISC@
 
 rpmk_SOURCES = 
 rpmk_LDFLAGS = $(myLDFLAGS)
-rpmk_LDADD = rpmk.o $(myLDADD)
+rpmk_LDADD = rpmk.o $(myLDADD) @LIBMISC@
 
 rpmq_SOURCES = 
 rpmq_LDFLAGS = $(myLDFLAGS)
-rpmq_LDADD = rpmq.o $(myLDADD)
+rpmq_LDADD = rpmq.o $(myLDADD) @LIBMISC@
 
 rpm2cpio_SOURCES = rpm2cpio.c
 rpm2cpio_LDFLAGS = $(myLDFLAGS)
diff -uNr rpm-4.0.2.ORIG/autodeps/darwin.prov rpm-4.0.2/autodeps/darwin.prov
--- rpm-4.0.2.ORIG/autodeps/darwin.prov	Sun Oct 13 00:10:18 2002
+++ rpm-4.0.2/autodeps/darwin.prov	Sun Oct 13 00:10:18 2002
@@ -0,0 +1,21 @@
+#!/bin/bash
+# ----------------------------------------------------------
+#       find-provides for Darwin/MacOSX
+# ----------------------------------------------------------
+# This script reads filenames from STDIN and outputs any relevant provides
+# information that needs to be included in the package.
+
+filelist=$(sed -n -e '/\.dylib/p' -e '/\.so/p' -e '/\.bundle/p' | sort | uniq | xargs file -L 2>/dev/null | grep "Mach-O.*ppc" | cut -d: -f1)
+
+for f in $filelist; do
+    libname=$(basename $f | sed -e 's;\..*;;')
+    soname=$(otool -l $f | grep $libname | awk '/ name/ {print $2}')
+
+    if [ "$soname" != "" ]; then
+	if [ ! -L $f ]; then
+	    basename $soname
+	fi
+    else
+	echo ${f##*/}
+    fi
+done | sort -u
diff -uNr rpm-4.0.2.ORIG/autodeps/darwin.req rpm-4.0.2/autodeps/darwin.req
--- rpm-4.0.2.ORIG/autodeps/darwin.req	Sun Oct 13 00:10:18 2002
+++ rpm-4.0.2/autodeps/darwin.req	Sun Oct 13 00:10:18 2002
@@ -0,0 +1,26 @@
+#!/bin/sh
+# ----------------------------------------------------------------
+#	find-requires for Darwin/MacOSX
+# ----------------------------------------------------------------
+ulimit -c 0
+
+filelist=`sed "s/['\"]/\\\&/g"`
+exelist=`echo $filelist | xargs file | fgrep executable | cut -d: -f1 `
+scriptlist=`echo $filelist | xargs file | egrep ":.* (commands|script) " | cut -d: -f1 `
+
+for f in $exelist; do
+    if [ -x $f ]; then
+        otool -L $f  \
+	| awk '/^\t/ { print }' \
+	| sed -n -e '/ (compatibility version .* current version .*)/p' \
+	| sed -e 's/ (compatibility version .* current version .*)//'
+    fi
+done | sort -u | sed "s/['\"]/\\\&/g" | xargs -n 1 basename | sort -u
+
+for f in $scriptlist; do
+    if [ -x $f ]; then
+        head -1 $f | sed -e 's/^\#\![   ]*//' \
+	| sed -n -e '/^\/bin/!p' | sed -n -e '/^\/usr\/bin/!p' | uniq \
+	| cut -d" " -f1
+    fi
+done
diff -uNr rpm-4.0.2.ORIG/build/parseScript.c rpm-4.0.2/build/parseScript.c
--- rpm-4.0.2.ORIG/build/parseScript.c	Tue Jan 16 08:10:04 2001
+++ rpm-4.0.2/build/parseScript.c	Sun Oct 13 00:10:18 2002
@@ -89,7 +89,7 @@
     poptContext optCon = NULL;
     
     name = NULL;
-    prog = "/bin/sh";
+    prog = "/bin/bash";
     file = NULL;
     
     switch (parsePart) {
diff -uNr rpm-4.0.2.ORIG/lib/fs.c rpm-4.0.2/lib/fs.c
--- rpm-4.0.2.ORIG/lib/fs.c	Tue Jan 16 08:10:04 2001
+++ rpm-4.0.2/lib/fs.c	Sun Oct 13 00:10:18 2002
@@ -147,12 +147,16 @@
     rpmMessage(RPMMESS_DEBUG, _("getting list of mounted filesystems\n"));
 
 #   if GETMNTENT_ONE || GETMNTENT_TWO
+#     ifdef __APPLE__ /* Assume ONLY ONE MacOS X partition */
+	    return 1;
+#     else
 	mtab = fopen(MOUNTED, "r");
 	if (!mtab) {
 	    rpmError(RPMERR_MTAB, _("failed to open %s: %s\n"), MOUNTED, 
 		     strerror(errno));
 	    return 1;
 	}
+#     endif
 #   elif HAVE_GETMNTINFO_R
 	getmntinfo_r(&mounts, flags, &mntCount, &bufSize);
 #   endif
diff -uNr rpm-4.0.2.ORIG/lib/rpmrc.c rpm-4.0.2/lib/rpmrc.c
--- rpm-4.0.2.ORIG/lib/rpmrc.c	Tue Jan 16 08:10:04 2001
+++ rpm-4.0.2/lib/rpmrc.c	Sun Oct 13 00:10:18 2002
@@ -859,6 +859,9 @@
 	    if (!strncmp(un.machine, "RM", 2))
 		sprintf(un.machine, "mips");
 	}
+	else if (!strncmp(un.machine, "Power Macintosh", 15)) {
+			sprintf(un.machine, "ppc");
+	}
 	else if ((!strncmp(un.machine, "34", 2) ||
 		!strncmp(un.machine, "33", 2)) && \
 		!strncmp(un.release, "4.0", 3))
diff -uNr rpm-4.0.2.ORIG/macros.in rpm-4.0.2/macros.in
--- rpm-4.0.2.ORIG/macros.in	Tue Dec 12 03:40:56 2000
+++ rpm-4.0.2/macros.in	Sun Oct 13 00:11:32 2002
@@ -73,7 +73,7 @@
 %__strip		@__STRIP@
 
 # XXX avoid failures if tools are not installed when rpm is built.
-%__libtoolize		libtoolize
+%__libtoolize		glibtoolize
 %__aclocal		aclocal
 %__autoheader		autoheader
 %__automake		automake
@@ -86,7 +86,7 @@
 #	(e.g. per-platform, per-system, per-packager, per-package) macros.
 #
 %_builddir		%{_topdir}/BUILD
-%_buildshell		/bin/sh
+%_buildshell		/bin/bash
 %_bzip2bin		@BZIP2BIN@
 %_dbpath		%{_var}/lib/rpm
 %_dbpath_rebuild	%{_dbpath}
@@ -118,7 +118,7 @@
 %_specdir		%{_topdir}/SPECS
 %_srcrpmdir		%{_topdir}/SRPMS
 %_tmppath		%{_var}/tmp
-%_topdir		%{_usrsrc}/redhat
+%_topdir		%{_usrsrc}/%{_vendor}
 %_unzipbin		@UNZIPBIN@
 
 #==============================================================================
@@ -308,7 +308,7 @@
 %{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\
 export RPM_BUILD_ROOT}
 
-%___build_shell		%{?_buildshell:%{_buildshell}}%{!?_buildshell:/bin/sh}
+%___build_shell		%{?_buildshell:%{_buildshell}}%{!?_buildshell:/bin/bash}
 %___build_args		-e
 %___build_cmd		%{?_sudo:%{_sudo} }%{?_remsh:%{_remsh} %{_remhost} }%{?_remsudo:%{_remsudo} }%{?_remchroot:%{_remchroot} %{_remroot} }%{___build_shell} %{___build_args}
 %___build_pre	\
@@ -461,7 +461,7 @@
 %_sbindir		%{_exec_prefix}/sbin
 %_libexecdir		%{_exec_prefix}/libexec
 %_datadir		%{_prefix}/share
-%_sysconfdir		%{_prefix}/etc
+%_sysconfdir		/private/etc
 %_sharedstatedir	%{_prefix}/com
 %_localstatedir		%{_prefix}/var
 %_lib			lib
diff -uNr rpm-4.0.2.ORIG/rpmrc.in rpm-4.0.2/rpmrc.in
--- rpm-4.0.2.ORIG/rpmrc.in	Tue Dec 12 03:40:56 2000
+++ rpm-4.0.2/rpmrc.in	Sun Oct 13 00:10:18 2002
@@ -122,6 +122,8 @@
 os_canon:       VM/ESA: VM/ESA	19
 os_canon:    Linux/390: OS/390	20
 os_canon:    Linux/ESA: VM/ESA	20
+os_canon:       Darwin: darwin	21
+os_canon:       MacOSX: macosx	21
 
 #############################################################
 # For a given uname().machine, the default build arch
@@ -246,6 +248,8 @@
 os_compat: MiNT: FreeMiNT mint TOS
 os_compat: mint: FreeMiNT MiNT TOS
 os_compat: TOS: FreeMiNT MiNT mint
+
+os_compat: Darwin: MacOSX
 
 buildarch_compat: ia64: noarch
 
diff -uNr rpm-4.0.2.ORIG/tools/Makefile.in rpm-4.0.2/tools/Makefile.in
--- rpm-4.0.2.ORIG/tools/Makefile.in	Mon Jan 22 09:17:52 2001
+++ rpm-4.0.2/tools/Makefile.in	Sun Oct 13 00:10:18 2002
@@ -183,7 +183,7 @@
 #myLDFLAGS= -L$(top_builddir)/build -L$(top_builddir)/lib \
 #	-L$(top_builddir)/rpmio -L$(top_builddir)/popt
 
-myLDADD = $(top_builddir)/build/librpmbuild.la 	$(top_builddir)/lib/librpm.la 	$(top_builddir)/rpmio/librpmio.la 	$(top_builddir)/popt/libpopt.la 	@INTLLIBS@
+myLDADD = $(top_builddir)/build/librpmbuild.la 	$(top_builddir)/lib/librpm.la 	$(top_builddir)/rpmio/librpmio.la 	$(top_builddir)/popt/libpopt.la 	@INTLLIBS@ @LIBMISC@
 
 
 LIBS = 
