diff -ru apt-0.7.20.2/apt-inst/deb/dpkgdb.cc apt-0.7.20.2+iPhone/apt-inst/deb/dpkgdb.cc
--- apt-0.7.20.2/apt-inst/deb/dpkgdb.cc	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/apt-inst/deb/dpkgdb.cc	2009-04-14 16:10:02.000000000 +0000
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <fcntl.h>
diff -ru apt-0.7.20.2/apt-inst/makefile apt-0.7.20.2+iPhone/apt-inst/makefile
--- apt-0.7.20.2/apt-inst/makefile	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/apt-inst/makefile	2009-04-14 16:10:02.000000000 +0000
@@ -11,7 +11,8 @@
 
 # The library name
 LIBRARY=apt-inst
-LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
+LIBEXT=
+#$(GLIBC_VER)$(LIBSTDCPP_VER)
 MAJOR=1.1
 MINOR=0
 SLIBS=$(PTHREADLIB) -lapt-pkg
diff -ru apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc
--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc	2009-04-14 16:10:02.000000000 +0000
@@ -766,6 +766,8 @@
       clog << flush;
       cerr << flush;
 
+      typedef void (*sighandler_t)(int);
+
       /* Mask off sig int/quit. We do this because dpkg also does when 
          it forks scripts. What happens is that when you hit ctrl-c it sends
 	 it to all processes in the group. Since dpkg ignores the signal 
diff -ru apt-0.7.20.2/apt-pkg/makefile apt-0.7.20.2+iPhone/apt-pkg/makefile
--- apt-0.7.20.2/apt-pkg/makefile	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/apt-pkg/makefile	2009-04-14 16:16:15.000000000 +0000
@@ -12,7 +12,8 @@
 # The library name, don't forget to update init.h and the copy in 
 # methods/makefile - FIXME
 LIBRARY=apt-pkg
-LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
+LIBEXT=
+#$(GLIBC_VER)$(LIBSTDCPP_VER)
 MAJOR=4.6
 MINOR=0
 SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
diff -ru apt-0.7.20.2/buildlib/environment.mak.in apt-0.7.20.2+iPhone/buildlib/environment.mak.in
--- apt-0.7.20.2/buildlib/environment.mak.in	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/buildlib/environment.mak.in	2009-04-14 16:11:50.000000000 +0000
@@ -67,8 +67,14 @@
 ifneq ($(words $(filter gnu% linux-gnu% kfreebsd-gnu% %-gnu,$(HOST_OS))),0)
    SONAME_MAGIC=-Wl,-soname -Wl,
    LFLAGS_SO=
+   SOEXT=so
+else
+ifneq ($(words $(filter darwin%,$(HOST_OS))),0)
+   SONAME_MAGIC=-Wl,-dylib_install_name,
+   LFLAGS_SO=
+   SOEXT=dylib
 else
    # Do not know how to create shared libraries here.
    ONLYSTATICLIBS = yes
 endif
-	
+endif
diff -ru apt-0.7.20.2/buildlib/library.mak apt-0.7.20.2+iPhone/buildlib/library.mak
--- apt-0.7.20.2/buildlib/library.mak	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/buildlib/library.mak	2009-04-14 16:14:05.000000000 +0000
@@ -16,11 +16,11 @@
 # See defaults.mak for information about LOCAL
 
 # Some local definitions
-LOCAL := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
+LOCAL := lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
 $(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
 $(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
 $(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
-$(LOCAL)-SONAME := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
+$(LOCAL)-SONAME := lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR)
 $(LOCAL)-SLIBS := $(SLIBS)
 $(LOCAL)-LIBRARY := $(LIBRARY)
 
@@ -29,7 +29,7 @@
 
 # Install the command hooks
 headers: $($(LOCAL)-HEADERS)
-library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
+library: $(LIB)/lib$(LIBRARY).$(SOEXT) $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR)
 clean: clean/$(LOCAL)
 veryclean: veryclean/$(LOCAL)
 
@@ -41,21 +41,21 @@
 clean/$(LOCAL):
 	-rm -f $($(@F)-OBJS) $($(@F)-DEP)
 veryclean/$(LOCAL): clean/$(LOCAL)
-	-rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
+	-rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.$(SOEXT)*
 
 # Build rules for the two symlinks
-.PHONY: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
-$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR): $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
+.PHONY: $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR) $(LIB)/lib$(LIBRARY).$(SOEXT)
+$(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR): $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
 	ln -sf $(<F) $@
-$(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
+$(LIB)/lib$(LIBRARY).$(SOEXT): $(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR)
 	ln -sf $(<F) $@
 
 # The binary build rule
-$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
-	-rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
+$(LIB)/lib$(LIBRARY)$(LIBEXT).$(SOEXT).$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
+	-rm -f $(LIB)/lib$($(@F)-LIBRARY)*.$(SOEXT)* 2> /dev/null
 	echo Building shared library $@
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
-	   -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
+	   -o $@ $(SONAME_MAGIC)$(patsubst $(LIB)/%,/usr/lib/%,$@) -dynamiclib \
 	   $(filter %.opic,$^) \
 	   $($(@F)-SLIBS) 
 
diff -ru apt-0.7.20.2/buildlib/podomain.mak apt-0.7.20.2+iPhone/buildlib/podomain.mak
--- apt-0.7.20.2/buildlib/podomain.mak	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/buildlib/podomain.mak	2009-04-14 16:10:02.000000000 +0000
@@ -14,7 +14,8 @@
 $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list: SRC := $(addprefix $(SUBDIR)/,$(SOURCE))
 $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list: makefile
 	(echo $(SRC) | xargs -n1 echo) > $@
-binary program clean: $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
+binary program clean:
+#$(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
 
 veryclean: veryclean/$(LOCAL)
 veryclean/po/$(LOCAL): LIST := $(PO_DOMAINS)/$(MY_DOMAIN)/$(LOCAL).$(TYPE)list
diff -ru apt-0.7.20.2/buildlib/program.mak apt-0.7.20.2+iPhone/buildlib/program.mak
--- apt-0.7.20.2/buildlib/program.mak	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/buildlib/program.mak	2009-04-14 16:10:02.000000000 +0000
@@ -44,6 +44,7 @@
 # The binary build rule
 $($(LOCAL)-BIN): $($(LOCAL)-OBJS) $($(LOCAL)-MKS)
 	echo Building program $@
+	echo $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
 
 # Compilation rules
diff -ru apt-0.7.20.2/cmdline/apt-get.cc apt-0.7.20.2+iPhone/cmdline/apt-get.cc
--- apt-0.7.20.2/cmdline/apt-get.cc	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/cmdline/apt-get.cc	2009-04-15 19:38:48.000000000 +0000
@@ -53,7 +53,8 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
-#include <sys/statfs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 #include <sys/statvfs.h>
 #include <signal.h>
 #include <unistd.h>
@@ -66,12 +66,13 @@
 
 #define RAMFS_MAGIC     0x858458f6
 
+#define _trace() printf("_trace(%s:%d)\n", __FILE__, __LINE__)
+
 using namespace std;
 
 ostream c0out(0);
 ostream c1out(0);
 ostream c2out(0);
-ofstream devnull("/dev/null");
 unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
 
 // class CacheFile - Cover class for some dependency cache functions	/*{{{*/
@@ -2786,6 +2787,9 @@
    if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
       _config->Set("quiet","1");
 
+   ofstream devnull;
+   devnull.open("/dev/null");
+
    // Setup the output streams
    c0out.rdbuf(cout.rdbuf());
    c1out.rdbuf(cout.rdbuf());
diff -ru apt-0.7.20.2/ftparchive/contents.cc apt-0.7.20.2+iPhone/ftparchive/contents.cc
--- apt-0.7.20.2/ftparchive/contents.cc	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/ftparchive/contents.cc	2009-04-14 16:10:02.000000000 +0000
@@ -41,7 +41,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <malloc.h>    
+#include <memory.h>    
 									/*}}}*/
 
 // GenContents::~GenContents - Free allocated memory			/*{{{*/
diff -ru apt-0.7.20.2/Makefile apt-0.7.20.2+iPhone/Makefile
--- apt-0.7.20.2/Makefile	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/Makefile	2009-04-14 16:10:02.000000000 +0000
@@ -18,7 +18,6 @@
 	$(MAKE) -C ftparchive $@
 	$(MAKE) -C dselect $@
 	$(MAKE) -C doc $@
-	$(MAKE) -C po $@
 
 # Some very common aliases
 .PHONY: maintainer-clean dist-clean distclean pristine sanity 
diff -ru apt-0.7.20.2/configure.in apt-0.7.20.2+iPhone/configure.in
--- apt-0.7.20.2/configure.in	2009-02-07 15:10:44.000000000 +0000
+++ apt-0.7.20.2+iPhone/configure.in	2009-04-15 18:58:36.000000000 +0000
@@ -88,7 +88,7 @@
 dnl First check against the full canonical canoncial-system-type in $target
 dnl and if that fails, just look for the cpu
 AC_MSG_CHECKING(debian architecture)
-archset="`dpkg-architecture -qDEB_HOST_ARCH`"
+archset="`cd "$DPKG_ARCH"; PERL5LIB=$(pwd) ./dpkg-architecture -qDEB_HOST_ARCH -t$host`"
 if test "x$archset" = "x"; then
    AC_MSG_ERROR([failed: use --host= or output from dpkg-architecture])
 fi
diff -ru apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc
--- apt-0.7.20.2/apt-pkg/deb/dpkgpm.cc	2009-02-07 15:09:35.000000000 +0000
+++ apt-0.7.20.2+iPhone/apt-pkg/deb/dpkgpm.cc	2009-04-15 19:25:41.000000000 +0000
@@ -33,7 +33,8 @@
 #include <termios.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
-#include <pty.h>
+#include <sys/stat.h>
+#include <util.h>
 
 #include <config.h>
 #include <apti18n.h>