Index: configure.in =================================================================== --- configure.in (révision 88430) +++ configure.in (copie de travail) @@ -2084,6 +2084,8 @@ AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +AC_SUBST(DISABLED_EXTENSIONS) + # Check for use of the system expat library AC_MSG_CHECKING(for --with-system-expat) AC_ARG_WITH(system_expat, @@ -4291,6 +4293,26 @@ done AC_MSG_RESULT(done) +if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING(python for build) + PYTHON_FOR_BUILD="${PYTHON_FOR_BUILD}" + AC_MSG_RESULT($PYTHON_FOR_BUILD) + AC_MSG_CHECKING(pgen for build) + PGEN_FOR_BUILD="${PGEN_FOR_BUILD}" + AC_MSG_RESULT($PGEN_FOR_BUILD) +else + PYTHON_FOR_BUILD='$(BUILDPYTHON)' + PGEN_FOR_BUILD='$(BUILDPGEN)' +fi + +AC_SUBST(PYTHON_FOR_BUILD) +AC_SUBST(PGEN_FOR_BUILD) +AC_ARG_VAR(PYTHON_FOR_BUILD,[build system Python]) +AC_ARG_VAR(PGEN_FOR_BUILD,[build system Python pgen]) + +CROSS_COMPILING=$cross_compiling +AC_SUBST(CROSS_COMPILING) + # generate output files AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) Index: setup.py =================================================================== --- setup.py (révision 88430) +++ setup.py (copie de travail) @@ -20,9 +20,23 @@ # Were we compiled --with-pydebug or with #define Py_DEBUG? COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') +sysconfig.get_config_vars() +sysconfig._CONFIG_VARS.update(os.environ) + # This global variable is used to hold the list of modules to be disabled. -disabled_module_list = [] +try: + disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ") +except KeyError: + disabled_module_list = list() +def is_arch_64_bits(): + data = open('pyconfig.h').read() + m = re.search(r"#s*define\s+SIZEOF_LONG\s+4\s*", data) + if m is None: + return True + else: + return False + def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' @@ -304,6 +318,10 @@ self.announce('WARNING: skipping import check for Cygwin-based "%s"' % ext.name) return + if os.environ.get('CROSS_COMPILING') == 'yes': + self.announce('WARNING: skipping import check for cross compiled "%s"' + % ext.name) + return ext_filename = os.path.join( self.build_lib, self.get_ext_filename(self.get_ext_fullname(ext.name))) @@ -346,9 +364,23 @@ return sys.platform def detect_modules(self): + try: + modules_include_dirs = os.environ["PYTHON_MODULES_INCLUDE"].split() + except KeyError: + modules_include_dirs = ['/usr/include'] + try: + modules_lib_dirs = os.environ["PYTHON_MODULES_LIB"].split() + except KeyError: + modules_lib_dirs = ['/usr/lib'] + for dir in modules_include_dirs: + add_dir_to_list(self.compiler.include_dirs, dir) + for dir in modules_lib_dirs: + add_dir_to_list(self.compiler.library_dirs, dir) + # Ensure that /usr/local is always used - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') + if os.environ.get('CROSS_COMPILING') != 'yes': + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') # Add paths specified in the environment variables LDFLAGS and # CPPFLAGS for header and library files. @@ -384,17 +416,6 @@ for directory in reversed(options.dirs): add_dir_to_list(dir_list, directory) - if os.path.normpath(sys.prefix) != '/usr' \ - and not sysconfig.get_config_var('PYTHONFRAMEWORK'): - # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework - # (PYTHONFRAMEWORK is set) to avoid # linking problems when - # building a framework with different architectures than - # the one that is currently installed (issue #7473) - add_dir_to_list(self.compiler.library_dirs, - sysconfig.get_config_var("LIBDIR")) - add_dir_to_list(self.compiler.include_dirs, - sysconfig.get_config_var("INCLUDEDIR")) - try: have_unicode = unicode except NameError: @@ -403,11 +424,16 @@ # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can # be assumed that no additional -I,-L directives are needed. - lib_dirs = self.compiler.library_dirs + [ - '/lib64', '/usr/lib64', - '/lib', '/usr/lib', - ] - inc_dirs = self.compiler.include_dirs + ['/usr/include'] + lib_dirs = self.compiler.library_dirs + inc_dirs = self.compiler.include_dirs + + if os.environ.get('CROSS_COMPILING') != 'yes': + lib_dirs += [ + '/lib64', '/usr/lib64', + '/lib', '/usr/lib', + ] + inc_dirs += ['/usr/include'] + exts = [] missing = [] @@ -590,7 +616,7 @@ exts.append( Extension('audioop', ['audioop.c']) ) # Disabled on 64-bit platforms - if sys.maxint != 9223372036854775807L: + if not is_arch_64_bits(): # Operations on images exts.append( Extension('imageop', ['imageop.c']) ) else: @@ -840,6 +866,9 @@ db_inc_paths.append('/pkg/db-3.%d/include' % x) db_inc_paths.append('/opt/db-3.%d/include' % x) + if os.environ.get('CROSS_COMPILING') == 'yes': + db_inc_paths = [] + # Add some common subdirectories for Sleepycat DB to the list, # based on the standard include directories. This way DB3/4 gets # picked up when it is installed in a non-standard prefix and @@ -956,6 +985,12 @@ print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir db_incs = [db_incdir] dblibs = [dblib] + + if os.environ.get('CROSS_COMPILING') == 'yes': + bsddb_runtime_library_dir = None + else: + bsddb_runtime_library_dir = dblib_dir + # We add the runtime_library_dirs argument because the # BerkeleyDB lib we're linking against often isn't in the # system dynamic library search path. This is usually @@ -965,7 +1000,7 @@ exts.append(Extension('_bsddb', ['_bsddb.c'], depends = ['bsddb.h'], library_dirs=dblib_dir, - runtime_library_dirs=dblib_dir, + runtime_library_dirs=bsddb_runtime_library_dir, include_dirs=db_incs, libraries=dblibs)) else: @@ -992,6 +1027,9 @@ MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) + if os.environ.get('CROSS_COMPILING') == 'yes': + sqlite_inc_paths = [] + # Scan the default include directories before the SQLite specific # ones. This allows one to override the copy of sqlite on OSX, # where /usr/include contains an old version of sqlite. @@ -1068,12 +1106,17 @@ else: sqlite_extra_link_args = () + if os.environ.get('CROSS_COMPILING') == 'yes': + sqlite_runtime_library_dirs = None + else: + sqlite_runtime_library_dirs = sqlite_libdir + exts.append(Extension('_sqlite3', sqlite_srcs, define_macros=sqlite_defines, include_dirs=["Modules/_sqlite", sqlite_incdir], library_dirs=sqlite_libdir, - runtime_library_dirs=sqlite_libdir, + runtime_library_dirs=sqlite_runtime_library_dirs, extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) else: @@ -1091,6 +1134,8 @@ # the more recent berkeleydb's db.h file first in the include path # when attempting to compile and it will fail. f = "/usr/include/db.h" + if os.environ.get('CROSS_COMPILING') == 'yes': + f = '' if sys.platform == 'darwin': if is_macosx_sdk_path(f): @@ -1172,9 +1217,13 @@ elif cand == "bdb": if db_incs is not None: print "building dbm using bdb" + if os.environ.get('CROSS_COMPILING') == 'yes': + db_runtime_library_dir = None + else: + db_runtime_library_dir = dblib_dir dbmext = Extension('dbm', ['dbmmodule.c'], library_dirs=dblib_dir, - runtime_library_dirs=dblib_dir, + runtime_library_dirs=db_runtime_library_dir, include_dirs=db_incs, define_macros=[ ('HAVE_BERKDB_H', None), @@ -1383,7 +1432,7 @@ missing.append('_codecs_%s' % loc) # Dynamic loading module - if sys.maxint == 0x7fffffff: + if not is_arch_64_bits(): # This requires sizeof(int) == sizeof(long) == sizeof(char*) dl_inc = find_file('dlfcn.h', [], inc_dirs) if (dl_inc is not None) and (platform not in ['atheos']): Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (révision 88430) +++ Lib/distutils/sysconfig.py (copie de travail) @@ -193,7 +193,8 @@ else: inc_dir = project_base else: - inc_dir = get_python_inc(plat_specific=1) + lib_dir = get_python_lib(plat_specific=1, standard_lib=1) + inc_dir = os.path.join(lib_dir, "config") if get_python_version() < '2.2': config_h = 'config.h' else: Index: Lib/sysconfig.py =================================================================== --- Lib/sysconfig.py (révision 88430) +++ Lib/sysconfig.py (copie de travail) @@ -371,7 +371,7 @@ else: inc_dir = _PROJECT_BASE else: - inc_dir = get_path('platinclude') + inc_dir = os.path.join(get_path('stdlib'), "config") return os.path.join(inc_dir, 'pyconfig.h') def get_scheme_names(): Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (révision 88430) +++ Makefile.pre.in (copie de travail) @@ -141,6 +141,8 @@ # configure script arguments CONFIG_ARGS= @CONFIG_ARGS@ +# disabled extensions +DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@ # Subdirectories with code SRCDIRS= @SRCDIRS@ @@ -178,7 +180,8 @@ UNICODE_OBJS= @UNICODE_OBJS@ PYTHON= python$(EXE) -BUILDPYTHON= python$(BUILDEXE) +BUILDPYTHON= ./python$(BUILDEXE) +PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ # The task to run while instrument when building the profile-opt target PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck @@ -210,7 +213,8 @@ ########################################################################## # Parser -PGEN= Parser/pgen$(EXE) +BUILDPGEN= Parser/pgen$(EXE) +PGEN_FOR_BUILD=@PGEN_FOR_BUILD@ POBJS= \ Parser/acceler.o \ @@ -404,8 +408,8 @@ # Build the shared modules sharedmods: $(BUILDPYTHON) @case $$MAKEFLAGS in \ - *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \ + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \ esac # Build static library @@ -430,8 +434,8 @@ libpython$(VERSION).dylib: $(LIBRARY_OBJS) $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ - + libpython$(VERSION).sl: $(LIBRARY_OBJS) $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST) @@ -538,13 +542,13 @@ # Use a stamp file to prevent make -j invoking pgen twice $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp -Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT) +Parser/pgen.stamp: $(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) -@$(INSTALL) -d Include - $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) + $(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) -touch Parser/pgen.stamp -$(PGEN): $(PGENOBJS) - $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) +$(BUILDPGEN): $(PGENOBJS) + $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(BUILDPGEN) Parser/grammar.o: $(srcdir)/Parser/grammar.c \ $(srcdir)/Include/token.h \ @@ -790,7 +794,7 @@ then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \ else true; \ fi - (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)) + (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) $(PYTHON)) -rm -f $(DESTDIR)$(BINDIR)/python-config (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config) -test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC) @@ -848,7 +852,7 @@ plat-mac/lib-scriptpackages/Netscape \ plat-mac/lib-scriptpackages/StdSuites \ plat-mac/lib-scriptpackages/SystemEvents \ - plat-mac/lib-scriptpackages/Terminal + plat-mac/lib-scriptpackages/Terminal PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \ lib-tk/test/test_ttk site-packages test test/data \ @@ -924,25 +928,16 @@ done $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) - PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST) -f \ - -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ - $(DESTDIR)$(LIBDEST) -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST)/site-packages -f \ - -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" + $(PYTHON_FOR_BUILD) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" # Create the PLATDIR source directory, if one wasn't distributed.. $(srcdir)/Lib/$(PLATDIR): @@ -975,7 +970,6 @@ echo $(INSTALL_DATA) $$i $(INCLUDEPY); \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \ done - $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h # Install the library and miscellaneous stuff needed for extending/embedding # This goes into $(exec_prefix) @@ -1009,6 +1003,8 @@ $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile + $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(LIBPL)/pyconfig.h + $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config @@ -1047,7 +1043,7 @@ # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: sharedmods - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ + $(RUNSHARED) CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) \ @@ -1186,7 +1182,7 @@ find . -name '*.gc??' -exec rm -f {} ';' clobber: clean profile-removal - -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ + -rm -f $(BUILDPYTHON) $(BUILDPGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ tags TAGS Parser/pgen.stamp \ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform @@ -1257,7 +1253,7 @@ .PHONY: maninstall libinstall inclinstall libainstall sharedinstall .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools -.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean +.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean .PHONY: smelly funny patchcheck .PHONY: gdbhooks