Blame SOURCES/python-2.7.3-debug-build.patch

6e8c2f
diff -up Python-2.7.3/configure.ac.debug-build Python-2.7.3/configure.ac
6e8c2f
--- Python-2.7.3/configure.ac.debug-build	2012-04-18 19:46:22.066498521 -0400
6e8c2f
+++ Python-2.7.3/configure.ac	2012-04-18 19:46:22.078498372 -0400
6e8c2f
@@ -635,7 +635,7 @@ AC_SUBST(LIBRARY)
6e8c2f
 AC_MSG_CHECKING(LIBRARY)
6e8c2f
 if test -z "$LIBRARY"
6e8c2f
 then
6e8c2f
-	LIBRARY='libpython$(VERSION).a'
6e8c2f
+	LIBRARY='libpython$(VERSION)$(DEBUG_EXT).a'
6e8c2f
 fi
6e8c2f
 AC_MSG_RESULT($LIBRARY)
6e8c2f
 
6e8c2f
@@ -780,8 +780,8 @@ if test $enable_shared = "yes"; then
6e8c2f
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
6e8c2f
           ;;
6e8c2f
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
6e8c2f
-	  LDLIBRARY='libpython$(VERSION).so'
6e8c2f
-	  BLDLIBRARY='-L. -lpython$(VERSION)'
6e8c2f
+	  LDLIBRARY='libpython$(VERSION)$(DEBUG_EXT).so'
6e8c2f
+	  BLDLIBRARY='-L. -lpython$(VERSION)$(DEBUG_EXT)'
6e8c2f
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
6e8c2f
 	  case $ac_sys_system in
6e8c2f
 	      FreeBSD*)
6e8c2f
@@ -905,6 +905,14 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
6e8c2f
 fi],
6e8c2f
 [AC_MSG_RESULT(no)])
6e8c2f
 
6e8c2f
+if test "$Py_DEBUG" = 'true'
6e8c2f
+then
6e8c2f
+	DEBUG_EXT=_d
6e8c2f
+	DEBUG_SUFFIX=-debug
6e8c2f
+fi
6e8c2f
+AC_SUBST(DEBUG_EXT)
6e8c2f
+AC_SUBST(DEBUG_SUFFIX)
6e8c2f
+
6e8c2f
 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
6e8c2f
 # merged with this chunk of code?
6e8c2f
 
6e8c2f
diff -up Python-2.7.3/Lib/distutils/command/build_ext.py.debug-build Python-2.7.3/Lib/distutils/command/build_ext.py
6e8c2f
--- Python-2.7.3/Lib/distutils/command/build_ext.py.debug-build	2012-04-09 19:07:29.000000000 -0400
6e8c2f
+++ Python-2.7.3/Lib/distutils/command/build_ext.py	2012-04-18 19:46:22.079498360 -0400
6e8c2f
@@ -676,7 +676,10 @@ class build_ext (Command):
6e8c2f
         so_ext = get_config_var('SO')
6e8c2f
         if os.name == 'nt' and self.debug:
6e8c2f
             return os.path.join(*ext_path) + '_d' + so_ext
6e8c2f
-        return os.path.join(*ext_path) + so_ext
6e8c2f
+
6e8c2f
+        # Similarly, extensions in debug mode are named 'module_d.so', to
6e8c2f
+        # avoid adding the _d to the SO config variable:
6e8c2f
+        return os.path.join(*ext_path) + (sys.pydebug and "_d" or "") + so_ext
6e8c2f
 
6e8c2f
     def get_export_symbols (self, ext):
6e8c2f
         """Return the list of symbols that a shared extension has to
6e8c2f
@@ -761,6 +764,8 @@ class build_ext (Command):
6e8c2f
                 template = "python%d.%d"
6e8c2f
                 pythonlib = (template %
6e8c2f
                              (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
6e8c2f
+                if sys.pydebug:
6e8c2f
+                    pythonlib += '_d'
6e8c2f
                 return ext.libraries + [pythonlib]
6e8c2f
             else:
6e8c2f
                 return ext.libraries
6e8c2f
diff -up Python-2.7.3/Lib/distutils/sysconfig.py.debug-build Python-2.7.3/Lib/distutils/sysconfig.py
6e8c2f
--- Python-2.7.3/Lib/distutils/sysconfig.py.debug-build	2012-04-18 19:46:21.988499499 -0400
6e8c2f
+++ Python-2.7.3/Lib/distutils/sysconfig.py	2012-04-18 19:46:22.080498348 -0400
6e8c2f
@@ -85,7 +85,8 @@ def get_python_inc(plat_specific=0, pref
6e8c2f
                 # Include is located in the srcdir
6e8c2f
                 inc_dir = os.path.join(srcdir, "Include")
6e8c2f
             return inc_dir
6e8c2f
-        return os.path.join(prefix, "include", "python" + get_python_version())
6e8c2f
+        return os.path.join(prefix, "include",
6e8c2f
+                            "python" + get_python_version() + (sys.pydebug and '-debug' or ''))
6e8c2f
     elif os.name == "nt":
6e8c2f
         return os.path.join(prefix, "include")
6e8c2f
     elif os.name == "os2":
6e8c2f
@@ -250,7 +251,7 @@ def get_makefile_filename():
6e8c2f
     if python_build:
6e8c2f
         return os.path.join(project_base, "Makefile")
6e8c2f
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
6e8c2f
-    return os.path.join(lib_dir, "config", "Makefile")
6e8c2f
+    return os.path.join(lib_dir, "config" + (sys.pydebug and "-debug" or ""), "Makefile")
6e8c2f
 
6e8c2f
 
6e8c2f
 def parse_config_h(fp, g=None):
6e8c2f
diff -up Python-2.7.3/Lib/distutils/tests/test_install.py.debug-build Python-2.7.3/Lib/distutils/tests/test_install.py
6e8c2f
--- Python-2.7.3/Lib/distutils/tests/test_install.py.debug-build	2012-04-18 19:46:21.997499385 -0400
6e8c2f
+++ Python-2.7.3/Lib/distutils/tests/test_install.py	2012-04-18 19:46:22.080498348 -0400
6e8c2f
@@ -20,8 +20,9 @@ from distutils.tests import support
6e8c2f
 
6e8c2f
 
6e8c2f
 def _make_ext_name(modname):
6e8c2f
-    if os.name == 'nt' and sys.executable.endswith('_d.exe'):
6e8c2f
+    if sys.pydebug:
6e8c2f
         modname += '_d'
6e8c2f
+    
6e8c2f
     return modname + sysconfig.get_config_var('SO')
6e8c2f
 
6e8c2f
 
6e8c2f
diff -up Python-2.7.3/Makefile.pre.in.debug-build Python-2.7.3/Makefile.pre.in
6e8c2f
--- Python-2.7.3/Makefile.pre.in.debug-build	2012-04-18 19:46:22.073498437 -0400
6e8c2f
+++ Python-2.7.3/Makefile.pre.in	2012-04-18 19:48:46.336694896 -0400
6e8c2f
@@ -102,8 +102,8 @@ SCRIPTDIR=	$(prefix)/lib64
6e8c2f
 # Detailed destination directories
6e8c2f
 BINLIBDEST=	$(LIBDIR)/python$(VERSION)
6e8c2f
 LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
6e8c2f
-INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
6e8c2f
-CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
6e8c2f
+INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
6e8c2f
+CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
6e8c2f
 LIBP=		$(LIBDIR)/python$(VERSION)
6e8c2f
 
6e8c2f
 # Symbols used for using shared libraries
6e8c2f
@@ -117,6 +117,12 @@ DESTSHARED=	$(BINLIBDEST)/lib-dynload
6e8c2f
 EXE=		@EXEEXT@
6e8c2f
 BUILDEXE=	@BUILDEXEEXT@
6e8c2f
 
6e8c2f
+# DEBUG_EXT is used by ELF files (names and SONAMEs); it will be "_d" for a debug build
6e8c2f
+# DEBUG_SUFFIX is used by filesystem paths; it will be "-debug" for a debug build
6e8c2f
+# Both will be empty in an optimized build
6e8c2f
+DEBUG_EXT=	@DEBUG_EXT@
6e8c2f
+DEBUG_SUFFIX=	@DEBUG_SUFFIX@
6e8c2f
+
6e8c2f
 # Short name and location for Mac OS X Python framework
6e8c2f
 UNIVERSALSDK=@UNIVERSALSDK@
6e8c2f
 PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
6e8c2f
@@ -180,8 +186,8 @@ LIBOBJDIR=	Python/
6e8c2f
 LIBOBJS=	@LIBOBJS@
6e8c2f
 UNICODE_OBJS=   @UNICODE_OBJS@
6e8c2f
 
6e8c2f
-PYTHON=		python$(EXE)
6e8c2f
-BUILDPYTHON=	python$(BUILDEXE)
6e8c2f
+PYTHON=		python$(DEBUG_SUFFIX)$(EXE)
6e8c2f
+BUILDPYTHON=	python$(DEBUG_SUFFIX)$(BUILDEXE)
6e8c2f
 
6e8c2f
 PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
6e8c2f
 _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
6e8c2f
@@ -413,7 +419,7 @@ sharedmods: $(BUILDPYTHON)
6e8c2f
 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
6e8c2f
 		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
6e8c2f
 
6e8c2f
-libpython$(VERSION).so: $(LIBRARY_OBJS)
6e8c2f
+libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS)
6e8c2f
 	if test $(INSTSONAME) != $(LDLIBRARY); then \
6e8c2f
 		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
6e8c2f
 		$(LN) -f $(INSTSONAME) $@; \
6e8c2f
@@ -796,18 +802,18 @@ bininstall:	altbininstall
6e8c2f
 	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
6e8c2f
 	else true; \
6e8c2f
 	fi
6e8c2f
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
6e8c2f
-	-rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
6e8c2f
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
6e8c2f
-	-rm -f $(DESTDIR)$(BINDIR)/python2-config
6e8c2f
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
6e8c2f
-	-rm -f $(DESTDIR)$(BINDIR)/python-config
6e8c2f
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
6e8c2f
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(DEBUG_SUFFIX)$(EXE) $(PYTHON))
6e8c2f
+	-rm -f $(DESTDIR)$(BINDIR)/python2$(DEBUG_SUFFIX)$(EXE)
6e8c2f
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)$(EXE) python2$(DEBUG_SUFFIX)$(EXE))
6e8c2f
+	-rm -f $(DESTDIR)$(BINDIR)/python2$(DEBUG_SUFFIX)-config
6e8c2f
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)-config python2$(DEBUG_SUFFIX)-config)
6e8c2f
+	-rm -f $(DESTDIR)$(BINDIR)/python$(DEBUG_SUFFIX)-config
6e8c2f
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(DEBUG_SUFFIX)-config python$(DEBUG_SUFFIX)-config)
6e8c2f
 	-test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
6e8c2f
-	-rm -f $(DESTDIR)$(LIBPC)/python2.pc
6e8c2f
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
6e8c2f
-	-rm -f $(DESTDIR)$(LIBPC)/python.pc
6e8c2f
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python2.pc python.pc)
6e8c2f
+	-rm -f $(DESTDIR)$(LIBPC)/python2$(DEBUG_SUFFIX).pc
6e8c2f
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)$(DEBUG_SUFFIX).pc python2$(DEBUG_SUFFIX).pc)
6e8c2f
+	-rm -f $(DESTDIR)$(LIBPC)/python$(DEBUG_SUFFIX).pc
6e8c2f
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python2$(DEBUG_SUFFIX).pc python$(DEBUG_SUFFIX).pc)
6e8c2f
 
6e8c2f
 # Install the interpreter with $(VERSION) affixed
6e8c2f
 # This goes into $(exec_prefix)
6e8c2f
@@ -820,7 +826,7 @@ altbininstall:	$(BUILDPYTHON)
6e8c2f
 		else	true; \
6e8c2f
 		fi; \
6e8c2f
 	done
6e8c2f
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
6e8c2f
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)
6e8c2f
 	if test -f $(LDLIBRARY); then \
6e8c2f
 		if test -n "$(DLLLIBRARY)" ; then \
6e8c2f
 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
6e8c2f
@@ -970,10 +976,11 @@ $(srcdir)/Lib/$(PLATDIR):
6e8c2f
 	fi; \
6e8c2f
 	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
6e8c2f
 
6e8c2f
-python-config: $(srcdir)/Misc/python-config.in
6e8c2f
+python$(DEBUG_SUFFIX)-config: $(srcdir)/Misc/python-config.in
6e8c2f
 	# Substitution happens here, as the completely-expanded BINDIR
6e8c2f
 	# is not available in configure
6e8c2f
-	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
6e8c2f
+	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)," < $(srcdir)/Misc/python-config.in >python$(DEBUG_SUFFIX)-config
6e8c2f
+
6e8c2f
 
6e8c2f
 # Install the include files
6e8c2f
 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
6e8c2f
@@ -994,13 +1001,13 @@ inclinstall:
6e8c2f
 	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
6e8c2f
 
6e8c2f
 # Install the library and miscellaneous stuff needed for extending/embedding
6e8c2f
-# This goes into $(exec_prefix)
6e8c2f
-LIBPL=		$(LIBP)/config
6e8c2f
+# This goes into $(exec_prefix)$(DEBUG_SUFFIX)
6e8c2f
+LIBPL=		$(LIBP)/config$(DEBUG_SUFFIX)
6e8c2f
 
6e8c2f
 # pkgconfig directory
6e8c2f
 LIBPC=		$(LIBDIR)/pkgconfig
6e8c2f
 
6e8c2f
-libainstall:	all python-config
6e8c2f
+libainstall:	all python$(DEBUG_SUFFIX)-config
6e8c2f
 	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
6e8c2f
 	do \
6e8c2f
 		if test ! -d $(DESTDIR)$$i; then \
6e8c2f
@@ -1016,11 +1023,10 @@ libainstall:	all python-config
6e8c2f
 	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
6e8c2f
 	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
6e8c2f
 	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
6e8c2f
-	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
6e8c2f
+	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)$(DEBUG_SUFFIX).pc
6e8c2f
 	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
6e8c2f
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
6e8c2f
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
6e8c2f
-	rm python-config
6e8c2f
+	$(INSTALL_SCRIPT) python$(DEBUG_SUFFIX)-config $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)-config
6e8c2f
 	@if [ -s Modules/python.exp -a \
6e8c2f
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
6e8c2f
 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
6e8c2f
diff -up Python-2.7.3/Misc/python-config.in.debug-build Python-2.7.3/Misc/python-config.in
6e8c2f
--- Python-2.7.3/Misc/python-config.in.debug-build	2012-04-09 19:07:33.000000000 -0400
6e8c2f
+++ Python-2.7.3/Misc/python-config.in	2012-04-18 19:46:22.082498324 -0400
6e8c2f
@@ -45,7 +45,7 @@ for opt in opt_flags:
6e8c2f
 
6e8c2f
     elif opt in ('--libs', '--ldflags'):
6e8c2f
         libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
6e8c2f
-        libs.append('-lpython'+pyver)
6e8c2f
+        libs.append('-lpython' + pyver + (sys.pydebug and "_d" or ""))
6e8c2f
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
6e8c2f
         # shared library in prefix/lib/.
6e8c2f
         if opt == '--ldflags':
6e8c2f
diff -up Python-2.7.3/Modules/makesetup.debug-build Python-2.7.3/Modules/makesetup
6e8c2f
--- Python-2.7.3/Modules/makesetup.debug-build	2012-04-09 19:07:34.000000000 -0400
6e8c2f
+++ Python-2.7.3/Modules/makesetup	2012-04-18 19:46:22.083498312 -0400
6e8c2f
@@ -233,7 +233,7 @@ sed -e 's/[ 	]*#.*//' -e '/^[ 	]*$/d' |
6e8c2f
 			*$mod.o*)	base=$mod;;
6e8c2f
 			*)		base=${mod}module;;
6e8c2f
 			esac
6e8c2f
-			file="$srcdir/$base\$(SO)"
6e8c2f
+			file="$srcdir/$base\$(DEBUG_EXT)\$(SO)"
6e8c2f
 			case $doconfig in
6e8c2f
 			no)	SHAREDMODS="$SHAREDMODS $file";;
6e8c2f
 			esac
6e8c2f
diff -up Python-2.7.3/Python/dynload_shlib.c.debug-build Python-2.7.3/Python/dynload_shlib.c
6e8c2f
--- Python-2.7.3/Python/dynload_shlib.c.debug-build	2012-04-09 19:07:35.000000000 -0400
6e8c2f
+++ Python-2.7.3/Python/dynload_shlib.c	2012-04-18 19:46:22.083498312 -0400
6e8c2f
@@ -46,11 +46,16 @@ const struct filedescr _PyImport_DynLoad
6e8c2f
     {"module.exe", "rb", C_EXTENSION},
6e8c2f
     {"MODULE.EXE", "rb", C_EXTENSION},
6e8c2f
 #else
6e8c2f
+#ifdef Py_DEBUG
6e8c2f
+    {"_d.so", "rb", C_EXTENSION},
6e8c2f
+    {"module_d.so", "rb", C_EXTENSION},
6e8c2f
+#else
6e8c2f
     {".so", "rb", C_EXTENSION},
6e8c2f
     {"module.so", "rb", C_EXTENSION},
6e8c2f
-#endif
6e8c2f
-#endif
6e8c2f
-#endif
6e8c2f
+#endif /* Py_DEBUG */
6e8c2f
+#endif /* __VMS */
6e8c2f
+#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
6e8c2f
+#endif /* __CYGWIN__ */
6e8c2f
     {0, 0}
6e8c2f
 };
6e8c2f
 
6e8c2f
diff -up Python-2.7.3/Python/sysmodule.c.debug-build Python-2.7.3/Python/sysmodule.c
6e8c2f
--- Python-2.7.3/Python/sysmodule.c.debug-build	2012-04-09 19:07:35.000000000 -0400
6e8c2f
+++ Python-2.7.3/Python/sysmodule.c	2012-04-18 19:46:22.083498312 -0400
6e8c2f
@@ -1506,6 +1506,12 @@ _PySys_Init(void)
6e8c2f
                         PyString_FromString("legacy"));
6e8c2f
 #endif
6e8c2f
 
6e8c2f
+#ifdef Py_DEBUG
6e8c2f
+	PyDict_SetItemString(sysdict, "pydebug", Py_True);
6e8c2f
+#else
6e8c2f
+	PyDict_SetItemString(sysdict, "pydebug", Py_False);
6e8c2f
+#endif
6e8c2f
+
6e8c2f
 #undef SET_SYS_FROM_STRING
6e8c2f
     if (PyErr_Occurred())
6e8c2f
         return NULL;