Rework the build system for osx applications:

* Don't use xcodebuild for building PythonLauncher, but use a normal unix
  makefile. This makes it a lot easier to use the same build flags as for the
  rest of python (e.g. make a universal version of python launcher)
* Convert the mac makefile-s to makefile.in-s and use configure to set makefile
  variables instead of forwarding them as command-line arguments
* Add a C version of pythonw, that we you can use '#!/usr/local/bin/pythonw'
* Build IDLE.app using bundlebuilder instead of BuildApplet, that will allow
  easier modification of the bundle contents later on.
diff --git a/Lib/plat-mac/bundlebuilder.py b/Lib/plat-mac/bundlebuilder.py
index 03d8c81..aac92bd 100755
--- a/Lib/plat-mac/bundlebuilder.py
+++ b/Lib/plat-mac/bundlebuilder.py
@@ -145,11 +145,24 @@
         self.message("Building %s" % repr(self.bundlepath), 1)
         if os.path.exists(self.bundlepath):
             shutil.rmtree(self.bundlepath)
-        os.mkdir(self.bundlepath)
-        self.preProcess()
-        self._copyFiles()
-        self._addMetaFiles()
-        self.postProcess()
+        if os.path.exists(self.bundlepath + '~'):
+            shutil.rmtree(self.bundlepath + '~')
+        bp = self.bundlepath
+
+        # Create the app bundle in a temporary location and then
+        # rename the completed bundle. This way the Finder will 
+        # never see an incomplete bundle (where it might pick up
+        # and cache the wrong meta data)
+        self.bundlepath = bp + '~'
+        try:
+            os.mkdir(self.bundlepath)
+            self.preProcess()
+            self._copyFiles()
+            self._addMetaFiles()
+            self.postProcess()
+            os.rename(self.bundlepath, bp)
+        finally:
+            self.bundlepath = bp
         self.message("Done.", 1)
 
     def preProcess(self):
diff --git a/Mac/OSX/IDLE/Makefile.in b/Mac/OSX/IDLE/Makefile.in
new file mode 100644
index 0000000..26ecad4
--- /dev/null
+++ b/Mac/OSX/IDLE/Makefile.in
@@ -0,0 +1,48 @@
+CC=@CC@
+LD=@CC@
+BASECFLAGS=@BASECFLAGS@
+OPT=@OPT@
+CFLAGS=$(BASECFLAGS) $(OPT)
+LDFLAGS=@LDFLAGS@
+srcdir=         @srcdir@
+VERSION=	@VERSION@
+UNIVERSALSDK=@UNIVERSALSDK@
+builddir=	../../..
+
+RUNSHARED=      @RUNSHARED@
+BUILDEXE=       @BUILDEXEEXT@
+BUILDPYTHON=    ../../../python$(BUILDEXE)
+
+# Deployment target selected during configure, to be checked
+# by distutils  
+MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
+@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
+
+BUNDLEBULDER=$(srcdir)/../../../Lib/plat-mac/bundlebuilder.py
+
+PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+
+all: IDLE.app
+
+install: IDLE.app
+	test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
+	-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
+	cp -r IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)"
+
+clean:
+	rm -rf IDLE.app
+
+IDLE.app:  \
+		$(srcdir)/../Icons/IDLE.icns $(srcdir)/idlemain.py \
+		$(srcdir)/../Icons/PythonSource.icns \
+		$(srcdir)/../Icons/PythonCompiled.icns
+	rm -fr PythonLauncher.app
+	$(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \
+		--builddir=. \
+		--name=IDLE \
+		--mainprogram=$(srcdir)/idlemain.py \
+		--iconfile=$(srcdir)/../Icons/IDLE.icns \
+		--bundle-id=org.python.IDLE \
+		--resource=$(srcdir)/../Icons/PythonSource.icns \
+		--resource=$(srcdir)/../Icons/PythonCompiled.icns \
+		build
diff --git a/Mac/OSX/IDLE/idlemain.py b/Mac/OSX/IDLE/idlemain.py
new file mode 100644
index 0000000..b7a3c04
--- /dev/null
+++ b/Mac/OSX/IDLE/idlemain.py
@@ -0,0 +1,19 @@
+import argvemulator
+from idlelib.PyShell import main
+import sys, os
+
+# Make sure sys.executable points to the python interpreter inside the 
+# framework, instead of at the helper executable inside the application
+# bundle (the latter works, but doesn't allow access to the window server)
+sys.executable = os.path.join(sys.prefix, 'bin', 'python')
+
+# Look for the -psn argument that the launcher adds and remove it, it will
+# only confuse the IDLE startup code.
+for idx, value in enumerate(sys.argv):
+    if value.startswith('-psn_'):
+        del sys.argv[idx]
+        break
+
+argvemulator.ArgvCollector().mainloop()
+if __name__ == '__main__':
+        main()
diff --git a/Mac/OSX/Icons/IDLE.icns b/Mac/OSX/Icons/IDLE.icns
new file mode 100644
index 0000000..ffe7ef0
--- /dev/null
+++ b/Mac/OSX/Icons/IDLE.icns
Binary files differ
diff --git a/Mac/OSX/PythonLauncher/PythonCompiled.icns b/Mac/OSX/Icons/PythonCompiled.icns
similarity index 100%
rename from Mac/OSX/PythonLauncher/PythonCompiled.icns
rename to Mac/OSX/Icons/PythonCompiled.icns
Binary files differ
diff --git a/Mac/OSX/PythonLauncher/PythonInterpreter.icns b/Mac/OSX/Icons/PythonLauncher.icns
similarity index 100%
rename from Mac/OSX/PythonLauncher/PythonInterpreter.icns
rename to Mac/OSX/Icons/PythonLauncher.icns
Binary files differ
diff --git a/Mac/OSX/PythonLauncher/PythonSource.icns b/Mac/OSX/Icons/PythonSource.icns
similarity index 100%
rename from Mac/OSX/PythonLauncher/PythonSource.icns
rename to Mac/OSX/Icons/PythonSource.icns
Binary files differ
diff --git a/Mac/OSX/Makefile b/Mac/OSX/Makefile
deleted file mode 100644
index 10b0f5d..0000000
--- a/Mac/OSX/Makefile
+++ /dev/null
@@ -1,273 +0,0 @@
-# This file can be invoked from the various frameworkinstall... targets in the 
-# main Makefile. The next couple of variables are overridden on the 
-# commandline in that case.
-
-VERSION=2.5
-builddir = ../..
-srcdir = ../..
-prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION)
-LIBDEST=$(prefix)/lib/python$(VERSION)
-BUILDPYTHON=$(builddir)/python.exe
-DESTDIR=
-# Test whether to use xcodebuild (preferred) or pbxbuild:
-ifeq ($(shell ls /usr/bin/xcodebuild),/usr/bin/xcodebuild)
-PBXBUILD=xcodebuild
-else
-PBXBUILD=pbxbuild
-endif
-
-# These are normally glimpsed from the previous set
-bindir=/usr/local/bin
-PYTHONAPPSPATH=/Applications/MacPython-$(VERSION)
-PYTHONAPPSDIR=$(PYTHONAPPSPATH)
-APPINSTALLDIR=$(prefix)/Resources/Python.app
-
-# Variables for installing the "normal" unix binaries
-INSTALLED_PYTHON=$(prefix)/bin/python
-INSTALLED_PYTHONW=$(APPINSTALLDIR)/Contents/MacOS/Python
-
-# Items more-or-less copied from the main Makefile
-DIRMODE=755
-FILEMODE=644
-INSTALL=/usr/bin/install -c
-INSTALL_SYMLINK=ln -fsn
-INSTALL_PROGRAM=${INSTALL}
-INSTALL_SCRIPT= ${INSTALL_PROGRAM}
-INSTALL_DATA=	${INSTALL} -m ${FILEMODE}
-LN=ln
-STRIPFLAG=-s
-##OPT=-g -O3 -Wall -Wstrict-prototypes -Wno-long-double -no-cpp-precomp \
-##	-fno-common -dynamic
-##INCLUDES=-I$(builddir) -I$(srcdir)/Include -I$(srcdir)/Mac/Include
-##DEFINES=
-##
-##CFLAGS=$(OPT) $(DEFINES) $(INCLUDES)
-##LDFLAGS=-F$(builddir) -framework System -framework Python -framework Carbon \
-##	-framework Foundation
-##CC=cc
-##LD=cc
-CPMAC=/Developer/Tools/CpMac
-
-APPTEMPLATE=$(srcdir)/Mac/OSXResources/app
-APPSUBDIRS=MacOS Resources Resources/English.lproj \
-	Resources/English.lproj/Documentation \
-	Resources/English.lproj/Documentation/doc \
-	Resources/English.lproj/Documentation/ide
-DOCDIR=$(srcdir)/Mac/OSXResources/app/Resources/English.lproj/Documentation
-DOCINDEX=$(DOCDIR)/"Documentation idx"
-CACHERSRC=$(srcdir)/Mac/scripts/cachersrc.py
-compileall=$(srcdir)/Lib/compileall.py
-bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py
-
-installapps: install_PythonLauncher install_Python install_BuildApplet install_IDE \
-	install_IDLE install_PackageManager checkapplepython
-
-install_PythonLauncher:
-	cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \
-	$(PBXBUILD) -target PythonLauncher -buildstyle Deployment install \
-		DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH)
-
-install_Python:
-	@if test ! -f $(DOCINDEX); then \
-		echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \
-	fi
-	@for i in $(PYTHONAPPSDIR) $(APPINSTALLDIR) $(APPINSTALLDIR)/Contents; do \
-		if test ! -d $(DESTDIR)$$i; then \
-			echo "Creating directory $(DESTDIR)$$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
-		fi;\
-	done
-	@for i in $(APPSUBDIRS); do \
-		if test ! -d $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i; then \
-			echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i; \
-		else	true; \
-		fi; \
-	done
-	@for d in . $(APPSUBDIRS); \
-	do \
-		a=$(APPTEMPLATE)/$$d; \
-		if test ! -d $$a; then continue; else true; fi; \
-		b=$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d; \
-		for i in $$a/*; \
-		do \
-			case $$i in \
-			*CVS) ;; \
-			*.py[co]) ;; \
-			*.orig) ;; \
-			*~) ;; \
-			*idx) \
-				echo $(CPMAC) "$$i" $$b; \
-				$(CPMAC) "$$i" $$b; \
-				;; \
-			*) \
-				if test -d $$i; then continue; fi; \
-				if test -x $$i; then \
-				    echo $(INSTALL_SCRIPT) $$i $$b; \
-				    $(INSTALL_SCRIPT) $$i $$b; \
-				else \
-				    echo $(INSTALL_DATA) $$i $$b; \
-				    $(INSTALL_DATA) $$i $$b; \
-				fi;; \
-			esac; \
-		done; \
-	done
-	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) $(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python
-
-install_IDE:
-	@if ! $(BUILDPYTHON) -c "import waste"; then  \
-		echo PythonIDE needs the \"waste\" extension module; \
-		echo See Mac/OSX/README for details; \
-	else \
-		echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
-		    --destroot "$(DESTDIR)" \
-			--python $(INSTALLED_PYTHONW) \
-			--output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \
-			$(srcdir)/Mac/Tools/IDE/PythonIDE.py ; \
-		$(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
-		    --destroot "$(DESTDIR)" \
-			--python $(INSTALLED_PYTHONW) \
-			--output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \
-			$(srcdir)/Mac/Tools/IDE/PythonIDE.py; \
-	fi
-
-install_PackageManager:
-	@if ! $(BUILDPYTHON) -c "import waste"; then  \
-		echo PackageManager needs the \"waste\" extension module; \
-		echo See Mac/OSX/README for details; \
-	else \
-		echo $(BUILDPYTHON) $(bundlebuilder) \
-			--builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \
-		    --destroot "$(DESTDIR)" \
-			--python $(INSTALLED_PYTHONW) \
-			--resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \
-			--mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \
-			--iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \
-			--creator Pimp build; \
-		$(BUILDPYTHON) $(bundlebuilder) \
-			--builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \
-		    --destroot "$(DESTDIR)" \
-			--python $(INSTALLED_PYTHONW) \
-			--resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \
-			--mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \
-			--iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \
-			--creator Pimp build; \
-	fi
-
-install_IDLE:
-	@if ! $(BUILDPYTHON) -c "import _tkinter"; then \
-		echo IDLE needs the \"Tkinter\" extension module; \
-		echo See Mac/OSX/README for details; \
-	else \
-		echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
-			--python $(INSTALLED_PYTHONW) \
-		    --destroot "$(DESTDIR)" \
-			--output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \
-			--extra $(srcdir)/Lib/idlelib \
-			$(srcdir)/Tools/scripts/idle ; \
-		$(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
-			--python $(INSTALLED_PYTHONW) \
-		    --destroot "$(DESTDIR)" \
-			--output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \
-			--extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \
-			$(srcdir)/Tools/scripts/idle ; \
-	fi
-
-
-install_BuildApplet:
-	$(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
-		--destroot "$(DESTDIR)" \
-		--python $(INSTALLED_PYTHONW) \
-		--output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \
-		$(srcdir)/Mac/scripts/BuildApplet.py
-
-MACLIBDEST=$(LIBDEST)/plat-mac
-MACTOOLSDEST=$(prefix)/Mac/Tools
-MACTOOLSSRC=$(srcdir)/Mac/Tools
-MACTOOLSSUBDIRS=IDE
-installmacsubtree:
-	@for i in $(MACTOOLSDEST); \
-	do \
-		if test ! -d $(DESTDIR)$$i; then \
-			echo "Creating directory $(DESTDIR)$$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
-		else	true; \
-		fi; \
-	done
-	@for d in $(MACTOOLSSUBDIRS); \
-	do \
-		a=$(MACTOOLSSRC)/$$d; \
-		if test ! -d $$a; then continue; else true; fi; \
-		b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
-		if test ! -d $$b; then \
-			echo "Creating directory $$b"; \
-			$(INSTALL) -d -m $(DIRMODE) $$b; \
-		else	true; \
-		fi; \
-	done
-	@for d in $(MACTOOLSSUBDIRS); \
-	do \
-		a=$(MACTOOLSSRC)/$$d; \
-		if test ! -d $$a; then continue; else true; fi; \
-		b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
-		for i in $$a/*; \
-		do \
-			case $$i in \
-			*CVS) ;; \
-			*.py[co]) ;; \
-			*.orig) ;; \
-			*~) ;; \
-			*.rsrc) \
-				echo $(CPMAC) $$i $$b ; \
-				$(CPMAC) $$i $$b ; \
-				;; \
-			*) \
-				if test -d $$i; then continue; fi; \
-				if test -x $$i; then \
-				    echo $(INSTALL_SCRIPT) $$i $$b; \
-				    $(INSTALL_SCRIPT) $$i $$b; \
-				else \
-				    echo $(INSTALL_DATA) $$i $$b; \
-				    $(INSTALL_DATA) $$i $$b; \
-				fi;; \
-			esac; \
-		done; \
-	done
-
-
-	$(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST)
-	$(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
-	$(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
-
-#
-# We use the full name here in stead of $(INSTALLED_PYTHONW), because
-# the latter may be overridden by Makefile.jaguar when building for a pre-installed
-# /usr/bin/python
-$(APPINSTALLDIR)/Contents/MacOS/Python: install_Python
-
-# $(INSTALLED_PYTHON) has to be done by the main Makefile, we cannot do that here.
-# At least this rule will give an error if it doesn't exist.
-
-installunixtools:
-	$(INSTALL) -d $(DESTDIR)$(bindir)
-	$(INSTALL_SYMLINK) $(INSTALLED_PYTHON) $(DESTDIR)$(bindir)/python$(VERSION)
-	$(INSTALL_SYMLINK) python$(VERSION) $(DESTDIR)$(bindir)/python
-	echo "#!/bin/sh" > pythonw.sh
-	echo "exec \"$(INSTALLED_PYTHONW)\" \"\$$@\"" >> pythonw.sh
-	$(INSTALL) pythonw.sh $(DESTDIR)$(bindir)/pythonw$(VERSION)
-	$(INSTALL_SYMLINK) pythonw$(VERSION) $(DESTDIR)$(bindir)/pythonw
-
-installextras:
-	$(INSTALL) -d $(DESTDIR)$(PYTHONAPPSDIR)/Extras
-	$(INSTALL) $(srcdir)/Mac/OSX/Extras.ReadMe.txt $(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe
-	$(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Demo \
-		$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo
-	$(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Tools \
-		$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Tools
-
-checkapplepython:
-	@if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \
-		echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
-		echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \
-	fi
-    
diff --git a/Mac/OSX/Makefile.in b/Mac/OSX/Makefile.in
new file mode 100644
index 0000000..fd430f7
--- /dev/null
+++ b/Mac/OSX/Makefile.in
@@ -0,0 +1,235 @@
+# This file can be invoked from the various frameworkinstall... targets in the 
+# main Makefile. The next couple of variables are overridden on the 
+# commandline in that case.
+
+VERSION=@VERSION@
+builddir = ../..
+srcdir = @srcdir@
+prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION)
+LIBDEST=$(prefix)/lib/python$(VERSION)
+BUILDPYTHON=$(builddir)/python.exe
+DESTDIR=
+
+# These are normally glimpsed from the previous set
+bindir=@exec_prefix@/bin
+PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+APPINSTALLDIR=$(prefix)/Resources/Python.app
+
+# Variables for installing the "normal" unix binaries
+INSTALLED_PYDOC=$(prefix)/bin/pydoc
+INSTALLED_IDLE=$(prefix)/bin/idle
+INSTALLED_PYTHON=$(prefix)/bin/python
+INSTALLED_PYTHONW=$(prefix)/bin/pythonw
+INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/Python
+
+# Items more-or-less copied from the main Makefile
+DIRMODE=755
+FILEMODE=644
+INSTALL=@INSTALL@
+INSTALL_SYMLINK=ln -fsn
+INSTALL_PROGRAM=@INSTALL_PROGRAM@
+INSTALL_SCRIPT= @INSTALL_SCRIPT@
+INSTALL_DATA=@INSTALL_DATA@
+LN=@LN@
+STRIPFLAG=-s
+CPMAC=/Developer/Tools/CpMac
+
+APPTEMPLATE=$(srcdir)/OSXResources/app
+APPSUBDIRS=MacOS Resources Resources/English.lproj \
+	Resources/English.lproj/Documentation \
+	Resources/English.lproj/Documentation/doc \
+	Resources/English.lproj/Documentation/ide
+DOCDIR=$(srcdir)/Mac/OSXResources/app/Resources/English.lproj/Documentation
+DOCINDEX=$(DOCDIR)/"Documentation idx"
+CACHERSRC=$(srcdir)/../scripts/cachersrc.py
+compileall=$(srcdir)/../../Lib/compileall.py
+
+installapps: install_Python install_BuildApplet install_PythonLauncher \
+	install_IDLE checkapplepython install_pythonw install_versionedtools
+
+install_pythonw: pythonw
+	$(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
+	$(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
+	ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python"
+	ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw"
+
+#
+# Install unix tools in /usr/local/bin. These are just aliases for the 
+# actual installation inside the framework.
+#
+installunixtools:
+	if [ ! -d "$(DESTDIR)/usr/local/bin" ]; then  \
+		$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)/usr/local/bin" ;\
+	fi
+	for fn in `ls "$(DESTDIR)$(prefix)/bin/"` ; \
+	do \
+		ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)/usr/local/bin/$${fn}" ;\
+	done
+
+# By default most tools are installed without a version in their basename, to
+# make it easier to install (and use) several python versions side-by-side move
+# the tools to a version-specific name and add the non-versioned name as an
+# alias.
+install_versionedtools:
+	for fn in idle pydoc python-config ;\
+	do \
+		mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)"  ;\
+		ln -sf "$${fn}$(VERSION)" "$${fn}" ;\
+	done
+	rm -f "$(DESTDIR)$(prefix)/bin/smtpd.py"
+
+
+pythonw: $(srcdir)/Tools/pythonw.c
+	$(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \
+		-DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"'
+
+
+install_PythonLauncher:
+	cd PythonLauncher && make install DESTDIR=$(DESTDIR)
+
+install_Python:
+	@if test ! -f $(DOCINDEX); then \
+		echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \
+	fi
+	@for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
+		if test ! -d "$(DESTDIR)$$i"; then \
+			echo "Creating directory $(DESTDIR)$$i"; \
+			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
+		fi;\
+	done
+	@for i in $(APPSUBDIRS); do \
+		if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
+			echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
+			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
+		else	true; \
+		fi; \
+	done
+	@for d in . $(APPSUBDIRS); \
+	do \
+		a=$(APPTEMPLATE)/$$d; \
+		if test ! -d $$a; then continue; else true; fi; \
+		b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
+		for i in $$a/*; \
+		do \
+			case $$i in \
+			*CVS) ;; \
+			*.svn) ;; \
+			*.py[co]) ;; \
+			*.orig) ;; \
+			*~) ;; \
+			*idx) \
+				echo $(CPMAC) "$$i" $$b; \
+				$(CPMAC) "$$i" "$$b"; \
+				;; \
+			*) \
+				if test -d $$i; then continue; fi; \
+				if test -x $$i; then \
+				    echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
+				    $(INSTALL_SCRIPT) "$$i" "$$b"; \
+				else \
+				    echo $(INSTALL_DATA) "$$i" "$$b"; \
+				    $(INSTALL_DATA) "$$i" "$$b"; \
+				fi;; \
+			esac; \
+		done; \
+	done
+	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python"
+
+install_IDLE:
+	cd IDLE && make install
+
+install_BuildApplet:
+	$(BUILDPYTHON) $(srcdir)/../scripts/BuildApplet.py \
+		--destroot "$(DESTDIR)" \
+		--python $(INSTALLED_PYTHONAPP) \
+		--output "$(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app" \
+		$(srcdir)/../scripts/BuildApplet.py
+
+MACLIBDEST=$(LIBDEST)/plat-mac
+MACTOOLSDEST=$(prefix)/Mac/Tools
+MACTOOLSSRC=$(srcdir)/Mac/Tools
+MACTOOLSSUBDIRS=IDE
+
+installmacsubtree:
+	@for i in $(MACTOOLSDEST); \
+	do \
+		if test ! -d $(DESTDIR)$$i; then \
+			echo "Creating directory $(DESTDIR)$$i"; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
+		else	true; \
+		fi; \
+	done
+	@for d in $(MACTOOLSSUBDIRS); \
+	do \
+		a=$(MACTOOLSSRC)/$$d; \
+		if test ! -d $$a; then continue; else true; fi; \
+		b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
+		if test ! -d $$b; then \
+			echo "Creating directory $$b"; \
+			$(INSTALL) -d -m $(DIRMODE) $$b; \
+		else	true; \
+		fi; \
+	done
+	@for d in $(MACTOOLSSUBDIRS); \
+	do \
+		a=$(MACTOOLSSRC)/$$d; \
+		if test ! -d $$a; then continue; else true; fi; \
+		b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
+		for i in $$a/*; \
+		do \
+			case $$i in \
+			*CVS) ;; \
+			*.svn) ;; \
+			*.py[co]) ;; \
+			*.orig) ;; \
+			*~) ;; \
+			*.rsrc) \
+				echo $(CPMAC) $$i $$b ; \
+				$(CPMAC) $$i $$b ; \
+				;; \
+			*) \
+				if test -d $$i; then continue; fi; \
+				if test -x $$i; then \
+				    echo $(INSTALL_SCRIPT) $$i $$b; \
+				    $(INSTALL_SCRIPT) $$i $$b; \
+				else \
+				    echo $(INSTALL_DATA) $$i $$b; \
+				    $(INSTALL_DATA) $$i $$b; \
+				fi;; \
+			esac; \
+		done; \
+	done
+
+
+	$(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST)
+	$(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
+	$(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
+
+#
+# We use the full name here in stead of $(INSTALLED_PYTHONAPP), because
+# the latter may be overridden by Makefile.jaguar when building for a pre-installed
+$(INSTALLED_PYTHONAPP)/Contents/MacOS/Python: install_Python
+
+# $(INSTALLED_PYTHON) has to be done by the main Makefile, we cannot do that here.
+# At least this rule will give an error if it doesn't exist.
+
+installextras:
+	$(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
+	$(INSTALL) $(srcdir)/Mac/OSX/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
+	$(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Demo \
+		"$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
+
+
+checkapplepython:
+	@if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \
+		echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
+		echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \
+	fi
+
+
+clean:
+	rm pythonw
+	cd PythonLauncher && make clean
+	cd IDLE && make clean
+
+
diff --git a/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
new file mode 100644
index 0000000..467aa8b
--- /dev/null
+++ b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
@@ -0,0 +1,26 @@
+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {"do_apply" = id; "do_filetype" = id; "do_reset" = id; }; 
+            CLASS = PreferencesWindowController; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {
+                commandline = NSTextField; 
+                debug = NSButton; 
+                filetype = NSPopUpButton; 
+                honourhashbang = NSButton; 
+                inspect = NSButton; 
+                interpreter = NSTextField; 
+                nosite = NSButton; 
+                optimize = NSButton; 
+                others = NSTextField; 
+                tabs = NSButton; 
+                verbose = NSButton; 
+                "with_terminal" = NSButton; 
+            }; 
+            SUPERCLASS = NSWindowController; 
+        }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
new file mode 100644
index 0000000..bc558f7
--- /dev/null
+++ b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBDocumentLocation</key>
+	<string>565 235 519 534 0 0 1280 1002 </string>
+	<key>IBFramework Version</key>
+	<string>364.0</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>5</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>7H63</string>
+</dict>
+</plist>
diff --git a/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
new file mode 100644
index 0000000..3dfed33
--- /dev/null
+++ b/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
Binary files differ
diff --git a/Mac/OSX/PythonLauncher/Info.plist b/Mac/OSX/PythonLauncher/Info.plist
new file mode 100644
index 0000000..5e9e457
--- /dev/null
+++ b/Mac/OSX/PythonLauncher/Info.plist
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleDocumentTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeExtensions</key>
+			<array>
+				<string>py</string>
+				<string>pyw</string>
+			</array>
+			<key>CFBundleTypeIconFile</key>
+			<string>PythonSource.icns</string>
+			<key>CFBundleTypeName</key>
+			<string>Python Script</string>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>NSDocumentClass</key>
+			<string>MyDocument</string>
+		</dict>
+		<dict>
+			<key>CFBundleTypeExtensions</key>
+			<array>
+				<string>pyc</string>
+				<string>pyo</string>
+			</array>
+			<key>CFBundleTypeIconFile</key>
+			<string>PythonCompiled.icns</string>
+			<key>CFBundleTypeName</key>
+			<string>Python Bytecode Document</string>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>NSDocumentClass</key>
+			<string>MyDocument</string>
+		</dict>
+	</array>
+	<key>CFBundleExecutable</key>
+	<string>PythonLauncher</string>
+	<key>CFBundleGetInfoString</key>
+	<string>2.5, © 2001-2006 Python Software Foundation</string>
+	<key>CFBundleIconFile</key>
+	<string>PythonLauncher.icns</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.python.PythonLauncher</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>PythonLauncher</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>2.5</string>
+	<key>CFBundleSignature</key>
+	<string>PytL</string>
+	<key>CFBundleVersion</key>
+	<string>2.5</string>
+	<key>NSMainNibFile</key>
+	<string>MainMenu</string>
+	<key>NSPrincipalClass</key>
+	<string>NSApplication</string>
+</dict>
+</plist>
diff --git a/Mac/OSX/PythonLauncher/Makefile.in b/Mac/OSX/PythonLauncher/Makefile.in
new file mode 100644
index 0000000..41ea9d5
--- /dev/null
+++ b/Mac/OSX/PythonLauncher/Makefile.in
@@ -0,0 +1,77 @@
+CC=@CC@
+LD=@CC@
+BASECFLAGS=@BASECFLAGS@
+OPT=@OPT@
+CFLAGS=$(BASECFLAGS) $(OPT)
+LDFLAGS=@LDFLAGS@
+srcdir=         @srcdir@
+VERSION=	@VERSION@
+UNIVERSALSDK=@UNIVERSALSDK@
+builddir=	../../..
+
+RUNSHARED=      @RUNSHARED@
+BUILDEXE=       @BUILDEXEEXT@
+BUILDPYTHON=    ../../../python$(BUILDEXE)
+
+# Deployment target selected during configure, to be checked
+# by distutils  
+MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
+@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
+
+BUNDLEBULDER=$(srcdir)/../../../Lib/plat-mac/bundlebuilder.py
+
+PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
+
+all: Python\ Launcher.app
+
+install: Python\ Launcher.app
+	test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
+	-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+	cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
+
+clean:
+	rm -f *.o "Python Launcher"
+	rm -rf "Python Launcher.app"
+
+Python\ Launcher.app:  \
+		Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \
+		$(srcdir)/../Icons/PythonSource.icns \
+		$(srcdir)/../Icons/PythonCompiled.icns \
+		$(srcdir)/factorySettings.plist
+	rm -fr "Python Launcher.app"
+	$(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \
+		--builddir=. \
+		--name="Python Launcher" \
+		--executable="Python Launcher" \
+		--iconfile=$(srcdir)/../Icons/PythonLauncher.icns \
+		--bundle-id=org.python.PythonLauncher \
+		--resource=$(srcdir)/../Icons/PythonSource.icns \
+		--resource=$(srcdir)/../Icons/PythonCompiled.icns \
+		--resource=$(srcdir)/English.lproj \
+		--resource=$(srcdir)/factorySettings.plist \
+		--plist=$(srcdir)/Info.plist \
+		build
+	find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r
+		
+
+FileSettings.o: $(srcdir)/FileSettings.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
+
+MyAppDelegate.o: $(srcdir)/MyAppDelegate.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
+
+MyDocument.o: $(srcdir)/MyDocument.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
+
+PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
+
+doscript.o: $(srcdir)/doscript.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
+
+main.o: $(srcdir)/main.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
+
+Python\ Launcher: $(OBJECTS)
+	$(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
diff --git a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj
deleted file mode 100755
index 06e45dc..0000000
--- a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj
+++ /dev/null
@@ -1,681 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 38;
-	objects = {
-		080E96D9FE201CDB7F000001 = {
-			fileRef = 2A37F4B9FDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		080E96DAFE201CDB7F000001 = {
-			fileRef = 2A37F4B6FDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		080E96DBFE201CDB7F000001 = {
-			fileRef = 2A37F4B4FDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		089C165FFE840EACC02AAC07 = {
-			children = (
-				089C1660FE840EACC02AAC07,
-			);
-			isa = PBXVariantGroup;
-			name = InfoPlist.strings;
-			refType = 4;
-		};
-		089C1660FE840EACC02AAC07 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			name = English;
-			path = English.lproj/InfoPlist.strings;
-			refType = 4;
-		};
-		089C1661FE840EACC02AAC07 = {
-			fileRef = 089C165FFE840EACC02AAC07;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-//080
-//081
-//082
-//083
-//084
-//100
-//101
-//102
-//103
-//104
-		1058C7A6FEA54F5311CA2CBB = {
-			children = (
-				1058C7A7FEA54F5311CA2CBB,
-				F5AA9D0102F807EE0110C447,
-			);
-			isa = PBXGroup;
-			name = "Linked Frameworks";
-			refType = 4;
-		};
-		1058C7A7FEA54F5311CA2CBB = {
-			isa = PBXFrameworkReference;
-			name = Cocoa.framework;
-			path = /System/Library/Frameworks/Cocoa.framework;
-			refType = 0;
-		};
-		1058C7A8FEA54F5311CA2CBB = {
-			children = (
-				2A37F4C5FDCFA73011CA2CEA,
-				2A37F4C4FDCFA73011CA2CEA,
-			);
-			isa = PBXGroup;
-			name = "Other Frameworks";
-			refType = 4;
-		};
-		1058C7A9FEA54F5311CA2CBB = {
-			fileRef = 1058C7A7FEA54F5311CA2CBB;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-//100
-//101
-//102
-//103
-//104
-//170
-//171
-//172
-//173
-//174
-		1758732AFF379DA111CA2CBB = {
-			isa = PBXApplicationReference;
-			path = PythonLauncher.app;
-			refType = 3;
-		};
-//170
-//171
-//172
-//173
-//174
-//190
-//191
-//192
-//193
-//194
-		19C28FB0FE9D524F11CA2CBB = {
-			children = (
-				1758732AFF379DA111CA2CBB,
-			);
-			isa = PBXGroup;
-			name = Products;
-			refType = 4;
-		};
-//190
-//191
-//192
-//193
-//194
-//2A0
-//2A1
-//2A2
-//2A3
-//2A4
-		2A37F4A9FDCFA73011CA2CEA = {
-			buildStyles = (
-				4A9504D0FFE6A4CB11CA0CBA,
-				4A9504D1FFE6A4CB11CA0CBA,
-			);
-			isa = PBXProject;
-			mainGroup = 2A37F4AAFDCFA73011CA2CEA;
-			projectDirPath = "";
-			targets = (
-				2A37F4C6FDCFA73011CA2CEA,
-			);
-		};
-		2A37F4AAFDCFA73011CA2CEA = {
-			children = (
-				2A37F4ABFDCFA73011CA2CEA,
-				2A37F4AFFDCFA73011CA2CEA,
-				2A37F4B8FDCFA73011CA2CEA,
-				2A37F4C3FDCFA73011CA2CEA,
-				19C28FB0FE9D524F11CA2CBB,
-			);
-			isa = PBXGroup;
-			name = PythonLauncher;
-			path = "";
-			refType = 4;
-		};
-		2A37F4ABFDCFA73011CA2CEA = {
-			children = (
-				2A37F4AEFDCFA73011CA2CEA,
-				2A37F4ACFDCFA73011CA2CEA,
-				F52A90CD02EB5C6A01000102,
-				F52A90CE02EB5C6A01000102,
-				F5A4C14002F2055C01000102,
-				F5A4C14102F2055C01000102,
-				F5A4C14402F2070D01000102,
-				F5A4C14502F2070D01000102,
-			);
-			isa = PBXGroup;
-			name = Classes;
-			path = "";
-			refType = 4;
-		};
-		2A37F4ACFDCFA73011CA2CEA = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = MyDocument.m;
-			refType = 4;
-		};
-		2A37F4AEFDCFA73011CA2CEA = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = MyDocument.h;
-			refType = 4;
-		};
-		2A37F4AFFDCFA73011CA2CEA = {
-			children = (
-				F5AA9C6A02F8042D0110C447,
-				2A37F4B0FDCFA73011CA2CEA,
-				F5AAA21D02F8115D0110C447,
-			);
-			isa = PBXGroup;
-			name = "Other Sources";
-			path = "";
-			refType = 4;
-		};
-		2A37F4B0FDCFA73011CA2CEA = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = main.m;
-			refType = 4;
-		};
-		2A37F4B4FDCFA73011CA2CEA = {
-			children = (
-				2A37F4B5FDCFA73011CA2CEA,
-			);
-			isa = PBXVariantGroup;
-			name = MyDocument.nib;
-			path = "";
-			refType = 4;
-		};
-		2A37F4B5FDCFA73011CA2CEA = {
-			isa = PBXFileReference;
-			name = English;
-			path = English.lproj/MyDocument.nib;
-			refType = 4;
-		};
-		2A37F4B6FDCFA73011CA2CEA = {
-			children = (
-				2A37F4B7FDCFA73011CA2CEA,
-			);
-			isa = PBXVariantGroup;
-			name = MainMenu.nib;
-			path = "";
-			refType = 4;
-		};
-		2A37F4B7FDCFA73011CA2CEA = {
-			isa = PBXFileReference;
-			name = English;
-			path = English.lproj/MainMenu.nib;
-			refType = 4;
-		};
-		2A37F4B8FDCFA73011CA2CEA = {
-			children = (
-				F58D4A3A02F1F94B01000102,
-				F58D4A3B02F1F94B01000102,
-				F58D4A3C02F1F94B01000102,
-				F5449B4B02FB3F7E01000102,
-				2A37F4B9FDCFA73011CA2CEA,
-				2A37F4B6FDCFA73011CA2CEA,
-				2A37F4B4FDCFA73011CA2CEA,
-				F5A4C13E02F203F601000102,
-				089C165FFE840EACC02AAC07,
-				F5A42167038BDD8E0110C447,
-			);
-			isa = PBXGroup;
-			name = Resources;
-			path = "";
-			refType = 4;
-		};
-		2A37F4B9FDCFA73011CA2CEA = {
-			children = (
-				2A37F4BAFDCFA73011CA2CEA,
-			);
-			isa = PBXVariantGroup;
-			name = Credits.rtf;
-			path = "";
-			refType = 4;
-		};
-		2A37F4BAFDCFA73011CA2CEA = {
-			isa = PBXFileReference;
-			name = English;
-			path = English.lproj/Credits.rtf;
-			refType = 4;
-		};
-		2A37F4C3FDCFA73011CA2CEA = {
-			children = (
-				1058C7A6FEA54F5311CA2CBB,
-				1058C7A8FEA54F5311CA2CBB,
-			);
-			isa = PBXGroup;
-			name = Frameworks;
-			path = "";
-			refType = 4;
-		};
-		2A37F4C4FDCFA73011CA2CEA = {
-			isa = PBXFrameworkReference;
-			name = AppKit.framework;
-			path = /System/Library/Frameworks/AppKit.framework;
-			refType = 0;
-		};
-		2A37F4C5FDCFA73011CA2CEA = {
-			isa = PBXFrameworkReference;
-			name = Foundation.framework;
-			path = /System/Library/Frameworks/Foundation.framework;
-			refType = 0;
-		};
-		2A37F4C6FDCFA73011CA2CEA = {
-			buildPhases = (
-				2A37F4C7FDCFA73011CA2CEA,
-				2A37F4C9FDCFA73011CA2CEA,
-				2A37F4CEFDCFA73011CA2CEA,
-				2A37F4D1FDCFA73011CA2CEA,
-			);
-			buildSettings = {
-				FRAMEWORK_SEARCH_PATHS = "";
-				HEADER_SEARCH_PATHS = "";
-				INSTALL_MODE_FLAG = "a+rX";
-				INSTALL_PATH = /Applications/Python;
-				LIBRARY_SEARCH_PATHS = "";
-				OPTIMIZATION_CFLAGS = "-O0";
-				OTHER_LDFLAGS = "";
-				PRODUCT_NAME = PythonLauncher;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = app;
-			};
-			dependencies = (
-			);
-			isa = PBXApplicationTarget;
-			name = PythonLauncher;
-			productInstallPath = /Applications/Python;
-			productName = PythonLauncher;
-			productReference = 1758732AFF379DA111CA2CBB;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>py</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>PythonSource.icns</string>
-			<key>CFBundleTypeName</key>
-			<string>Python Script</string>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>NSDocumentClass</key>
-			<string>MyDocument</string>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>pyw</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>PythonWSource.icns</string>
-			<key>CFBundleTypeName</key>
-			<string>Python GUI Script</string>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>NSDocumentClass</key>
-			<string>MyDocument</string>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>pyc</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>PythonCompiled.icns</string>
-			<key>CFBundleTypeName</key>
-			<string>Python Bytecode Document</string>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>NSDocumentClass</key>
-			<string>MyDocument</string>
-		</dict>
-	</array>
-	<key>CFBundleExecutable</key>
-	<string>PythonLauncher</string>
-	<key>CFBundleGetInfoString</key>
-	<string>2.3, © 2001-2003 Python Software Foundation</string>
-	<key>CFBundleIconFile</key>
-	<string>PythonInterpreter.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.python.PythonLauncher</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>PythonLauncher</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.3</string>
-	<key>CFBundleSignature</key>
-	<string>PytL</string>
-	<key>CFBundleVersion</key>
-	<string>2.3</string>
-	<key>NSMainNibFile</key>
-	<string>MainMenu</string>
-	<key>NSPrincipalClass</key>
-	<string>NSApplication</string>
-</dict>
-</plist>
-";
-			shouldUseHeadermap = 0;
-		};
-		2A37F4C7FDCFA73011CA2CEA = {
-			buildActionMask = 2147483647;
-			files = (
-				2A37F4C8FDCFA73011CA2CEA,
-				F52A90D002EB5C6A01000102,
-				F5A4C14202F2055D01000102,
-				F5A4C14702F2070D01000102,
-				F5AA9C6C02F8042D0110C447,
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		2A37F4C8FDCFA73011CA2CEA = {
-			fileRef = 2A37F4AEFDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		2A37F4C9FDCFA73011CA2CEA = {
-			buildActionMask = 2147483647;
-			files = (
-				080E96D9FE201CDB7F000001,
-				080E96DAFE201CDB7F000001,
-				080E96DBFE201CDB7F000001,
-				089C1661FE840EACC02AAC07,
-				F58D4A3D02F1F94B01000102,
-				F58D4A3E02F1F94B01000102,
-				F58D4A3F02F1F94B01000102,
-				F5A4C13F02F203F701000102,
-				F5449B4C02FB3F7E01000102,
-				F5A42168038BDD8E0110C447,
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		2A37F4CEFDCFA73011CA2CEA = {
-			buildActionMask = 2147483647;
-			files = (
-				2A37F4CFFDCFA73011CA2CEA,
-				2A37F4D0FDCFA73011CA2CEA,
-				F52A90CF02EB5C6A01000102,
-				F5A4C14302F2055D01000102,
-				F5A4C14602F2070D01000102,
-				F5AAA21E02F8115D0110C447,
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		2A37F4CFFDCFA73011CA2CEA = {
-			fileRef = 2A37F4ACFDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-				ATTRIBUTES = (
-				);
-			};
-		};
-		2A37F4D0FDCFA73011CA2CEA = {
-			fileRef = 2A37F4B0FDCFA73011CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-				ATTRIBUTES = (
-				);
-			};
-		};
-		2A37F4D1FDCFA73011CA2CEA = {
-			buildActionMask = 2147483647;
-			files = (
-				1058C7A9FEA54F5311CA2CBB,
-				F5AA9D9B02F807EF0110C447,
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-//2A0
-//2A1
-//2A2
-//2A3
-//2A4
-//4A0
-//4A1
-//4A2
-//4A3
-//4A4
-		4A9504D0FFE6A4CB11CA0CBA = {
-			buildRules = (
-			);
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-				OPTIMIZATION_CFLAGS = "-O0";
-			};
-			isa = PBXBuildStyle;
-			name = Development;
-		};
-		4A9504D1FFE6A4CB11CA0CBA = {
-			buildRules = (
-			);
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-			};
-			isa = PBXBuildStyle;
-			name = Deployment;
-		};
-//4A0
-//4A1
-//4A2
-//4A3
-//4A4
-//F50
-//F51
-//F52
-//F53
-//F54
-		F52A90CD02EB5C6A01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = FileSettings.m;
-			refType = 4;
-		};
-		F52A90CE02EB5C6A01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = FileSettings.h;
-			refType = 4;
-		};
-		F52A90CF02EB5C6A01000102 = {
-			fileRef = F52A90CD02EB5C6A01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F52A90D002EB5C6A01000102 = {
-			fileRef = F52A90CE02EB5C6A01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5449B4B02FB3F7E01000102 = {
-			isa = PBXFileReference;
-			path = PythonWSource.icns;
-			refType = 4;
-		};
-		F5449B4C02FB3F7E01000102 = {
-			fileRef = F5449B4B02FB3F7E01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F58D4A3A02F1F94B01000102 = {
-			isa = PBXFileReference;
-			path = PythonCompiled.icns;
-			refType = 4;
-		};
-		F58D4A3B02F1F94B01000102 = {
-			isa = PBXFileReference;
-			path = PythonInterpreter.icns;
-			refType = 4;
-		};
-		F58D4A3C02F1F94B01000102 = {
-			isa = PBXFileReference;
-			path = PythonSource.icns;
-			refType = 4;
-		};
-		F58D4A3D02F1F94B01000102 = {
-			fileRef = F58D4A3A02F1F94B01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F58D4A3E02F1F94B01000102 = {
-			fileRef = F58D4A3B02F1F94B01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F58D4A3F02F1F94B01000102 = {
-			fileRef = F58D4A3C02F1F94B01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A42167038BDD8E0110C447 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = factorySettings.plist;
-			refType = 4;
-		};
-		F5A42168038BDD8E0110C447 = {
-			fileRef = F5A42167038BDD8E0110C447;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A4C13E02F203F601000102 = {
-			isa = PBXFileReference;
-			path = PreferenceWindow.nib;
-			refType = 4;
-		};
-		F5A4C13F02F203F701000102 = {
-			fileRef = F5A4C13E02F203F601000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A4C14002F2055C01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = PreferencesWindowController.h;
-			refType = 4;
-		};
-		F5A4C14102F2055C01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = PreferencesWindowController.m;
-			refType = 4;
-		};
-		F5A4C14202F2055D01000102 = {
-			fileRef = F5A4C14002F2055C01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A4C14302F2055D01000102 = {
-			fileRef = F5A4C14102F2055C01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A4C14402F2070D01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = MyAppDelegate.m;
-			refType = 4;
-		};
-		F5A4C14502F2070D01000102 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = MyAppDelegate.h;
-			refType = 4;
-		};
-		F5A4C14602F2070D01000102 = {
-			fileRef = F5A4C14402F2070D01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5A4C14702F2070D01000102 = {
-			fileRef = F5A4C14502F2070D01000102;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5AA9C6A02F8042D0110C447 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = doscript.h;
-			refType = 4;
-		};
-		F5AA9C6C02F8042D0110C447 = {
-			fileRef = F5AA9C6A02F8042D0110C447;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5AA9D0102F807EE0110C447 = {
-			isa = PBXFrameworkReference;
-			name = Carbon.framework;
-			path = /System/Library/Frameworks/Carbon.framework;
-			refType = 0;
-		};
-		F5AA9D9B02F807EF0110C447 = {
-			fileRef = F5AA9D0102F807EE0110C447;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5AAA21D02F8115D0110C447 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = doscript.m;
-			refType = 4;
-		};
-		F5AAA21E02F8115D0110C447 = {
-			fileRef = F5AAA21D02F8115D0110C447;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-	};
-	rootObject = 2A37F4A9FDCFA73011CA2CEA;
-}
diff --git a/Mac/OSX/PythonLauncher/PythonWSource.icns b/Mac/OSX/PythonLauncher/PythonWSource.icns
deleted file mode 100644
index b0a8593..0000000
--- a/Mac/OSX/PythonLauncher/PythonWSource.icns
+++ /dev/null
Binary files differ
diff --git a/Mac/OSX/Tools/pythonw.c b/Mac/OSX/Tools/pythonw.c
new file mode 100644
index 0000000..e70a76f
--- /dev/null
+++ b/Mac/OSX/Tools/pythonw.c
@@ -0,0 +1,17 @@
+/*
+ * This wrapper program executes a python executable hidden inside an
+ * application bundle inside the Python framework. This is needed to run
+ * GUI code: some GUI API's don't work unless the program is inside an
+ * application bundle.
+ */
+#include <unistd.h>
+#include <err.h>
+
+static char Python[] = PYTHONWEXECUTABLE;
+
+int main(int argc, char **argv) {
+	argv[0] = Python;
+	execv(Python, argv);
+	err(1, "execv: %s", Python);
+	/* NOTREACHED */
+}
diff --git a/Mac/OSXResources/framework/Info.plist b/Mac/OSXResources/framework/Info.plist
index 34eacd5..302ff48 100644
--- a/Mac/OSXResources/framework/Info.plist
+++ b/Mac/OSXResources/framework/Info.plist
@@ -17,10 +17,10 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>2.2</string>
+	<string>2.5</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>2.2</string>
+	<string>2.5</string>
 </dict>
 </plist>
diff --git a/Makefile.pre.in b/Makefile.pre.in
index e088c9c..782bc60 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -856,7 +856,7 @@
 	# Substitution happens here, as the completely-expanded BINDIR
 	# is not available in configure
 	sed -e "s,@BINDIR@,$(BINDIR)," < $(srcdir)/Misc/python-config.in >python-config
-	$(INSTALL_SCRIPT) python-config $(BINDIR)/python-config
+	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python-config
 	rm python-config
 	@if [ -s Modules/python.exp -a \
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
@@ -936,27 +936,20 @@
 
 # This installs Mac/Lib into the framework
 frameworkinstallmaclib:
-	$(MAKE) -f $(srcdir)/Mac/OSX/Makefile installmacsubtree \
-		$(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \
-		srcdir=$(srcdir) builddir=. prefix=$(prefix) LIBDEST=$(LIBDEST) \
-		DESTDIR=$(DESTDIR)
+	cd Mac/OSX && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
 
 # This installs the IDE, the Launcher and other apps into /Applications
 frameworkinstallapps:
-	$(MAKE) -f $(srcdir)/Mac/OSX/Makefile installapps \
-		$(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \
-		srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix)
+	cd Mac/OSX && $(MAKE) installapps DESTDIR="$(DESTDIR)"
 
 # This install the unix python and pythonw tools in /usr/local/bin
 frameworkinstallunixtools:
-	$(MAKE) -f $(srcdir)/Mac/OSX/Makefile installunixtools \
-		DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \
-		srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix)
+	cd Mac/OSX && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
 
 # This installs the Demos and Tools into the applications directory.
 # It is not part of a normal frameworkinstall
 frameworkinstallextras:
-	$(MAKE) -f $(srcdir)/Mac/OSX/Makefile installextras \
+	$(MAKE) -f Mac/OSX/Makefile installextras \
 		$(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \
 		srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR)
 
diff --git a/configure b/configure
index 6297d9f..c1ad419 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 45392 .
+# From configure.in Revision: 45800 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -1451,6 +1451,15 @@
 		PYTHONFRAMEWORKPREFIX=$enableval
 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
 		prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
+
+		# Add makefiles for Mac specific code to the list of output
+		# files:
+		          ac_config_files="$ac_config_files Mac/OSX/Makefile"
+
+		          ac_config_files="$ac_config_files Mac/OSX/PythonLauncher/Makefile"
+
+		          ac_config_files="$ac_config_files Mac/OSX/IDLE/Makefile"
+
 	esac
 
 else
@@ -22416,6 +22425,9 @@
 do
   case "$ac_config_target" in
   # Handling of arguments.
+  "Mac/OSX/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/Makefile" ;;
+  "Mac/OSX/PythonLauncher/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/PythonLauncher/Makefile" ;;
+  "Mac/OSX/IDLE/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/IDLE/Makefile" ;;
   "Makefile.pre" ) CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
   "Modules/Setup.config" ) CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;;
   "pyconfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS pyconfig.h" ;;
diff --git a/configure.in b/configure.in
index 168c621..8b82841 100644
--- a/configure.in
+++ b/configure.in
@@ -105,6 +105,12 @@
 		PYTHONFRAMEWORKPREFIX=$enableval
 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
 		prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
+
+		# Add makefiles for Mac specific code to the list of output
+		# files:
+		AC_CONFIG_FILES(Mac/OSX/Makefile)
+		AC_CONFIG_FILES(Mac/OSX/PythonLauncher/Makefile)
+		AC_CONFIG_FILES(Mac/OSX/IDLE/Makefile)
 	esac
 	],[
 	PYTHONFRAMEWORK=