Patches by William Lewis for Nextstep descendants.
diff --git a/Modules/Makefile.pre.in b/Modules/Makefile.pre.in
index 4d306e7..4ea78c5 100644
--- a/Modules/Makefile.pre.in
+++ b/Modules/Makefile.pre.in
@@ -100,7 +100,7 @@
 SYSLIBS=	$(LIBM) $(LIBC)
 
 LIBRARY=	../libpython$(VERSION).a
-REALLIBRARY=	../@REALLIBRARY@
+LDLIBRARY=	../@LDLIBRARY@
 
 # === Rules ===
 
@@ -123,7 +123,7 @@
 # This target is used by the master Makefile to link the final binary.
 link:		$(MAINOBJ)
 		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \
-		  $(LIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
+		  $(LDLIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
 		mv python$(EXE) ../python$(EXE)
 
 clean:
diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c
index 3f9ee52..49793b8 100644
--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -30,7 +30,7 @@
 const char *
 Py_GetBuildInfo()
 {
-	static char buildinfo[40];
-	sprintf(buildinfo, "#%d, %.12s, %.8s", BUILD, DATE, TIME);
+	static char buildinfo[50];
+	sprintf(buildinfo, "#%d, %.20s, %.9s", BUILD, DATE, TIME);
 	return buildinfo;
 }
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 09b795d..78b4915 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -42,6 +42,10 @@
 #include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 
+#ifdef WITH_NEXT_FRAMEWORK
+#include <mach-o/dyld.h>
+#endif
+
 /* Search in some common locations for the associated Python libraries.
  *
  * Two directories must be found, the platform independent directory
@@ -394,7 +398,24 @@
 	int bufsz;
 	int prefixsz;
 	char *defpath = pythonpath;
+#ifdef WITH_NEXT_FRAMEWORK
+        NSModule pythonModule;
+#endif
+	
+#ifdef WITH_NEXT_FRAMEWORK
+        pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
+	/* Use dylib functions to find out where the framework was loaded from */
+        buf = NSLibraryNameForModule(pythonModule);
+        if (buf != NULL) {
+            /* We're in a framework. */
+            strcpy(progpath, buf);
 
+            /* Frameworks have support for versioning */
+            strcpy(lib_python, "lib");
+        } else {
+            /* If we're not in a framework, fall back to the old way (even though NSNameOfModule() probably does the same thing.) */
+#endif
+	
 	/* Initialize this dynamically for K&R C */
 	sprintf(lib_python, "lib/python%s", VERSION);
 
@@ -430,6 +451,9 @@
 	}
 	else
 		progpath[0] = '\0';
+#ifdef WITH_NEXT_FRAMEWORK
+        }
+#endif
 
 	strcpy(argv0_path, progpath);
 	
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 8ac5d96..19c7809 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -146,6 +146,7 @@
 #undef HAVE_UTIME_H
 #define HAVE_WAITPID
 /* #undef HAVE_GETCWD */
+#define UNION_WAIT /* This should really be checked for by autoconf */
 #endif
 
 #ifdef HAVE_UNISTD_H
@@ -255,6 +256,23 @@
 #include <io.h>
 #endif /* OS2 */
 
+#ifdef UNION_WAIT
+/* Emulate some macros on systems that have a union instead of macros */
+
+#ifndef WIFEXITED
+#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump)
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(u_wait) ((u_wait).w_termsig)
+#endif
+
+#endif /* UNION_WAIT */
+
 /* Return a dictionary corresponding to the POSIX environment table */
 
 #if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
@@ -1986,20 +2004,25 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int pid, options, sts = 0;
+	int pid, options;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
+
 	if (!PyArg_Parse(args, "(ii)", &pid, &options))
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
-#ifdef NeXT
-	pid = wait4(pid, (union wait *)&sts, options, NULL);
-#else
-	pid = waitpid(pid, &sts, options);
-#endif
+	pid = wait4(pid, &status, options, NULL);
 	Py_END_ALLOW_THREADS
 	if (pid == -1)
 		return posix_error();
 	else
-		return Py_BuildValue("ii", pid, sts);
+		return Py_BuildValue("ii", pid, status_i);
 }
 #endif /* HAVE_WAITPID */
 
@@ -2015,17 +2038,21 @@
 	PyObject *args;
 {
 	int pid, sts;
-	Py_BEGIN_ALLOW_THREADS
-#ifdef NeXT
-	pid = wait((union wait *)&sts);
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
 #else
-	pid = wait(&sts);
+	int status;
+#define status_i status
 #endif
+	status_i = 0;
+	Py_BEGIN_ALLOW_THREADS
+	pid = wait(&status);
 	Py_END_ALLOW_THREADS
 	if (pid == -1)
 		return posix_error();
 	else
-		return Py_BuildValue("ii", pid, sts);
+		return Py_BuildValue("ii", pid, status_i);
 }
 #endif
 
@@ -2821,9 +2848,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
@@ -2842,9 +2876,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
@@ -2863,9 +2904,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
@@ -2874,7 +2922,7 @@
 }
 #endif /* WIFEXITED */
 
-#ifdef WIFSTOPPED
+#ifdef WEXITSTATUS
 static char posix_WEXITSTATUS__doc__[] =
 "WEXITSTATUS(status) -> integer\n\
 See Unix documentation.";
@@ -2884,9 +2932,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
@@ -2905,9 +2960,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
@@ -2926,9 +2988,16 @@
 	PyObject *self;
 	PyObject *args;
 {
-	int status = 0;
+#ifdef UNION_WAIT
+	union wait status;
+#define status_i (status.w_status)
+#else
+	int status;
+#define status_i status
+#endif
+	status_i = 0;
    
-	if (!PyArg_Parse(args, "i", &status))
+	if (!PyArg_Parse(args, "i", &status_i))
 	{
 		return NULL;
 	}
diff --git a/Modules/readline.c b/Modules/readline.c
index 08569f6..608dd88 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -34,6 +34,7 @@
 extern int rl_bind_key_in_map();
 extern int rl_initialize();
 extern int add_history();
+extern Function *rl_event_hook;
 #endif
 
 /* Pointers needed from outside (but not declared in a header file). */