build with GCC on AIX

--- Python-3.3.3/configure	2012-11-28 09:05:45.990529603 +0000
+++ Python-3.3.3/configure	2012-11-28 09:06:23.037963934 +0000
@@ -3426,8 +3426,6 @@
 else
 
 	case $ac_sys_system in
-	AIX*)   CC=${CC:-xlc_r}
-		without_gcc=;;
 	*)	without_gcc=no;;
 	esac
 fi
@@ -5541,10 +5539,18 @@
 	      PY3LIBRARY=libpython3.so
 	  fi
           ;;
-    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|AIX*)
 	  LDLIBRARY='libpython$(LDVERSION).so'
-	  BLDLIBRARY='-L. -lpython$(LDVERSION)'
-	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+	  case $ac_sys_system in
+	    AIX*)
+	      BLDLIBRARY='-Wl,-brtl -L. -lpython$(LDVERSION)'
+	      RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
+	      ;;
+	    *)
+	      BLDLIBRARY='-L. -lpython$(LDVERSION)'
+	      RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+	      ;;
+	  esac
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
 	  if test "$with_pydebug" != yes
           then
@@ -8301,8 +8307,13 @@
 then
 	case $ac_sys_system/$ac_sys_release in
 	AIX*)
-		BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
-		LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
+		if test "$GCC" = "yes"; then
+		  LDSHARED='$(CC) -shared'
+		  BLDSHARED='$(CC) -Wl,-brtl -shared'
+		else
+		  BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
+		  LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
+		fi
 		;;
 	IRIX/5*) LDSHARED="ld -shared";;
 	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
--- Python-3.3.3/configure.ac	2012-11-28 09:05:45.990529603 +0000
+++ Python-3.3.3/configure.ac	2012-11-28 09:06:23.038963946 +0000
@@ -545,8 +545,6 @@
 		without_gcc=$withval;;
 	esac], [
 	case $ac_sys_system in
-	AIX*)   CC=${CC:-xlc_r}
-		without_gcc=;;
 	*)	without_gcc=no;;
 	esac])
 AC_MSG_RESULT($without_gcc)
@@ -910,10 +908,18 @@
 	      PY3LIBRARY=libpython3.so
 	  fi
           ;;
-    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|AIX*)
 	  LDLIBRARY='libpython$(LDVERSION).so'
-	  BLDLIBRARY='-L. -lpython$(LDVERSION)'
-	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+	  case $ac_sys_system in
+	    AIX*)
+	      BLDLIBRARY='-Wl,-brtl -L. -lpython$(LDVERSION)'
+	      RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
+	      ;;
+	    *)
+	      BLDLIBRARY='-L. -lpython$(LDVERSION)'
+	      RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+	      ;;
+	  esac
 	  case $ac_sys_system in
 	      FreeBSD*)
 		SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
@@ -1866,8 +1872,13 @@
 then
 	case $ac_sys_system/$ac_sys_release in
 	AIX*)
-		BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
-		LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
+		if test "$GCC" = "yes"; then
+			LDSHARED='$(CC) -shared'
+			BLDSHARED='$(CC) -Wl,-brtl -shared'
+		else
+			BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
+			LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
+		fi
 		;;
 	IRIX/5*) LDSHARED="ld -shared";;
 	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
--- Python-3.3.3/Makefile.pre.in	2012-11-28 09:05:45.861528086 +0000
+++ Python-3.3.3/Makefile.pre.in	2012-11-28 09:06:23.046964040 +0000
@@ -493,14 +493,20 @@
 
 libpython$(LDVERSION).so: $(LIBRARY_OBJS)
 	if test $(INSTSONAME) != $(LDLIBRARY); then \
-		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
+		if [ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" != "aix" ]; then \
+			SONAME="-Wl,-h$(INSTSONAME)"; \
+		fi; \
+		$(BLDSHARED) $(SONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
 		$(LN) -f $(INSTSONAME) $@; \
 	else \
 		$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
 	fi
 
 libpython3.so:	libpython$(LDVERSION).so
-	$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
+	if [ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" != "aix" ]; then \
+		SONAME="-Wl,-h$@"; \
+	fi; \
+	$(BLDSHARED) $(NO_AS_NEEDED) -o $@ $(SONAME) $^
 
 libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
 	 $(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
@@ -1106,6 +1112,8 @@
 	export PATH; PATH="`pwd`:$$PATH"; \
 	export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
 	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
+	export LD_LIBRARY_PATH; LD_LIBRARY_PATH="`pwd`${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"; \
+	export LIBPATH; LIBPATH="`pwd`${LIBPATH:+:$LIBPATH}"; \
 	export EXE; EXE="$(BUILDEXE)"; \
 	if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
 	export PYTHON_FOR_BUILD; \
--- Python-3.3.3/Modules/Setup.dist	2012-11-28 09:05:45.935528957 +0000
+++ Python-3.3.3/Modules/Setup.dist	2012-11-28 09:06:23.052964111 +0000
@@ -177,7 +177,7 @@
 #_bisect _bisectmodule.c	# Bisection algorithms
 #_heapq _heapqmodule.c	# Heap queue algorithm
 
-#unicodedata unicodedata.c    # static Unicode character database
+unicodedata unicodedata.c    # static Unicode character database
 
 
 # Modules with some UNIX dependencies -- on by default:
