Index: configure.in =================================================================== --- configure.in (revision 45705) +++ configure.in (working copy) @@ -60,6 +60,29 @@ AC_SUBST(CONFIG_ARGS) CONFIG_ARGS="$ac_configure_args" +AC_ARG_ENABLE(universalsdk, + AC_HELP_STRING(--enable-universalsdk@<:@SDKDIR@:>@, Build agains Mac OS X 10.4u SDK (ppc/i386)), +[ + case $enableval in + yes) + enableval=/Developer/SDKs/MacOSX10.4u.sdk + ;; + esac + case $enableval in + no) + UNIVERSALSDK= + enable_universalsdk= + ;; + *) + UNIVERSALSDK=$enableval + ;; + esac +],[ + UNIVERSALSDK= + enable_universalsdk= +]) +AC_SUBST(UNIVERSALSDK) + dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output AC_ARG_ENABLE(framework, AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework), @@ -258,7 +281,9 @@ # it may influence the way we can build extensions, so distutils # needs to check it AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) +AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) CONFIGURE_MACOSX_DEPLOYMENT_TARGET= +EXPORT_MACOSX_DEPLOYMENT_TARGET='#' # checks for alternative programs @@ -740,6 +765,10 @@ # is there any other compiler on Darwin besides gcc? Darwin*) BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd" + if test "${enable_universalsdk}"; then + BASECFLAGS="-arch ppc -arch i386 -isysroot ${UNIVERSALSDK} ${BASECFLAGS}" + fi + ;; OSF*) BASECFLAGS="$BASECFLAGS -mieee" @@ -1263,7 +1292,12 @@ AC_SUBST(LIBTOOL_CRUFT) case $ac_sys_system/$ac_sys_release in Darwin/@<:@01567@:>@\..*) - LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only `arch`" + LIBTOOL_CRUFT="-framework System -lcc_dynamic" + if test "${enable_universalsdk}"; then + : + else + LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`" + fi LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) @@ -1386,9 +1420,16 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + if test ${cur_target} '>' 10.2; then + cur_target=10.3 + fi CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} + EXPORT_MACOSX_DEPLOYMENT_TARGET='' if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then + if test "${enable_universalsdk}"; then + LDFLAGS="-arch i386 -arch ppc -isysroot ${UNIVERSALSDK} ${LDFLAGS}" + fi LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" else @@ -2873,7 +2914,24 @@ # check for endianness AC_C_BIGENDIAN +AH_VERBATIM([WORDS_BIGENDIAN], +[ + /* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. + */ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else +#ifndef __LITTLE_ENDIAN__ +#undef WORDS_BIGENDIAN +#endif +#endif]) + # Check whether right shifting a negative integer extends the sign bit # or fills with zeros (like the Cray J90, according to Tim Peters). AC_MSG_CHECKING(whether right shift extends the sign bit) Index: setup.py =================================================================== --- setup.py (revision 45705) +++ setup.py (working copy) @@ -913,20 +913,11 @@ # # More information on Expat can be found at www.libexpat.org. # - if sys.byteorder == "little": - xmlbo = "1234" - else: - xmlbo = "4321" expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') define_macros = [ - ('XML_NS', '1'), - ('XML_DTD', '1'), - ('BYTEORDER', xmlbo), - ('XML_CONTEXT_BYTES','1024'), - ] - for feature_macro in ['HAVE_MEMMOVE', 'HAVE_BCOPY']: - if config_h_vars.has_key(feature_macro): - define_macros.append((feature_macro, '1')) + ('HAVE_EXPAT_CONFIG_H', '1'), + ] + exts.append(Extension('pyexpat', define_macros = define_macros, include_dirs = [expatinc], Index: README =================================================================== --- README (revision 45705) +++ README (working copy) @@ -579,8 +579,13 @@ want to use any Aqua-based GUI toolkit (whether Tkinter, wxPython, Carbon, Cocoa or anything else). - See Mac/OSX/README for more information on framework builds. + You may also want to try the configure option "--enable-universalsdk" + which builds Python as a universal binary with support for the + i386 and PPC architetures. This requires Xcode 2.1 or later to build. + See Mac/OSX/README for more information on framework and + universal builds. + Cygwin: With recent (relative to the time of writing, 2001-12-19) Cygwin installations, there are problems with the interaction of dynamic linking and fork(). This manifests itself in build Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (revision 45705) +++ Lib/distutils/sysconfig.py (working copy) @@ -366,8 +366,8 @@ # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so # it needs to be compatible. # If it isn't set we set it to the configure-time value - if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): - cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] + if sys.platform == 'darwin' and g.has_key('MACOSX_DEPLOYMENT_TARGET'): + cfg_target = g['MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') if cur_target == '': cur_target = cfg_target Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (revision 45705) +++ Makefile.pre.in (working copy) @@ -108,13 +108,17 @@ BUILDEXE= @BUILDEXEEXT@ # Short name and location for Mac OS X Python framework +UNIVERSALSDK=@UNIVERSALSDK@ PYTHONFRAMEWORK= @PYTHONFRAMEWORK@ PYTHONFRAMEWORKDIR= @PYTHONFRAMEWORKDIR@ PYTHONFRAMEWORKPREFIX= @PYTHONFRAMEWORKPREFIX@ PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@ # Deployment target selected during configure, to be checked -# by distutils -CONFIGURE_MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ +# by distutils. The export statement is needed to ensure that the +# deployment target is active during build. +MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ +@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET + # Options to enable prebinding (for fast startup prior to Mac OS X 10.3) OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@ @@ -377,8 +381,17 @@ $(RESSRCDIR)/version.plist \ $(RESSRCDIR)/English.lproj/InfoPlist.strings $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION) - libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \ - @LIBTOOL_CRUFT@ + if test "${UNIVERSALSDK}"; then \ + $(CC) -o $(LDLIBRARY) -arch i386 -arch ppc -dynamiclib \ + -isysroot "${UNIVERSALSDK}" \ + -all_load $(LIBRARY) -Wl,-single_module \ + -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python \ + -compatibility_version $(VERSION) \ + -current_version $(VERSION); \ + else \ + libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \ + @LIBTOOL_CRUFT@ ;\ + fi $(INSTALL) -d -m $(DIRMODE) \ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ @@ -568,6 +581,19 @@ -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall +# Run the unitests for both architectures in a Universal build on OSX +# Must be run on an Intel box. +testuniversal: all platform + if [ `arch` != 'i386' ];then \ + echo "This can only be used on OSX/i386" ;\ + exit 1 ;\ + fi + -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f + -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall + $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall + $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall + + # Like testall, but with a single pass only buildbottest: all platform $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw Index: Modules/expat/expat_config.h =================================================================== --- Modules/expat/expat_config.h (revision 0) +++ Modules/expat/expat_config.h (revision 0) @@ -0,0 +1,19 @@ +/* + * Expat configuration for python. This file is not part of the expat + * distribution. + */ +#ifndef EXPAT_CONFIG_H +#define EXPAT_CONFIG_H + +#include +#ifdef WORDS_BIGENDIAN +#define BYTEORDER 4321 +#else +#define BYTEORDER 1234 +#endif + +#define XML_NS 1 +#define XML_DTD 1 +#define XML_CONTEXT_BYTES 1024 + +#endif /* EXPAT_CONFIG_H */