From f091c104cb02b0724e7ea13fb5062a788c37091c Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Tue, 28 Apr 2009 14:22:01 +0200 Subject: [PATCH] introduce and use PYTHON_FOR_BUILD When cross compiling, the python version just build cannot be executed, thus we need a python running on the build system. This patch introduced the variable PYTHON_FOR_BUILD to specify this python, default is to use "python" from $PATH. Signed-off-by: Marc Kleine-Budde --- Makefile.pre.in | 39 ++++++++++++++++++++------------------- configure.in | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 19 deletions(-) Index: b/Makefile.pre.in =================================================================== --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -176,7 +176,8 @@ LIBOBJDIR= Python/ LIBOBJS= @LIBOBJS@ 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 @@ -394,7 +395,7 @@ build_all_generate_profile: $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" run_profile_task: - ./$(BUILDPYTHON) $(PROFILE_TASK) + $(PYTHON_FOR_BUILD) $(PROFILE_TASK) build_all_use_profile: $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use" @@ -411,15 +412,15 @@ $(BUILDPYTHON): Modules/python.o $(LIBRA Modules/python.o \ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) -platform: $(BUILDPYTHON) - $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform + $(RUNSHARED) $(PYTHON_FOR_BUILD) -E -c 'import sys ; from distutils.util import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform +platform: $(PYTHON_FOR_BUILD) # Build the shared modules -sharedmods: $(BUILDPYTHON) +sharedmods: $(BUILDPYTHON) $(PYTHON_FOR_BUILD) @case "$(MAKEFLAGS)" in \ - s|*\ s|s\ *|*\ 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|*\ s|s\ *|*\ s\ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \ + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \ esac # Build static library @@ -706,7 +707,7 @@ $(LIBRARY_OBJS) $(MODOBJS) Modules/pytho TESTOPTS= -l $(EXTRATESTOPTS) TESTPROG= $(srcdir)/Lib/test/regrtest.py -TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -bb +TESTPYTHON= $(RUNSHARED) $(PYTHON_FOR_BUILD) -E -bb test: all platform -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) @@ -729,7 +730,7 @@ testuniversal: all platform -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 $(TESTPROG) $(TESTOPTS) -uall + $(RUNSHARED) /usr/libexec/oah/translate $(PYTHON_FOR_BUILD) -E $(TESTPROG) $(TESTOPTS) -uall # Like testall, but with a single pass only @@ -910,25 +911,25 @@ libinstall: build_all $(srcdir)/Lib/$(PL done $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -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 $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" + $(PYTHON_FOR_BUILD) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" # Create the PLATDIR source directory, if one wasn't distributed.. $(srcdir)/Lib/$(PLATDIR): @@ -1020,7 +1021,7 @@ libainstall: all # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ + $(RUNSHARED) $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) \ @@ -1058,7 +1059,7 @@ frameworkinstallstructure: $(LDLIBRARY) fi; \ done $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers - sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist + sed 's/%VERSION%/'"`$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK) $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers @@ -1101,7 +1102,7 @@ frameworkinstallextras: # This installs a few of the useful scripts in Tools/scripts scriptsinstall: SRCDIR=$(srcdir) $(RUNSHARED) \ - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \ + $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --root=/$(DESTDIR) @@ -1123,7 +1124,7 @@ config.status: $(srcdir)/configure # Run reindent on the library reindent: - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib + $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib # Rerun configure with the same options as it was run last time, # provided the config.status script exists @@ -1239,7 +1240,7 @@ funny: # Perform some verification checks on any modified files. patchcheck: - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py + $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/patchcheck.py # Dependencies Index: b/configure.in =================================================================== --- a/configure.in +++ b/configure.in @@ -4011,6 +4011,22 @@ for dir in $SRCDIRS; do done AC_MSG_RESULT(done) + +# +# PYTHON_FOR_BUILD +# +if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING(python for build) + PYTHON_FOR_BUILD="${PYTHON_FOR_BUILD-python}" + PYTHON_FOR_BUILD="$(which ${PYTHON_FOR_BUILD})" + AC_MSG_RESULT($PYTHON_FOR_BUILD) +else + PYTHON_FOR_BUILD='$(BUILDPYTHON)' +fi +AC_SUBST(PYTHON_FOR_BUILD) +AC_ARG_VAR(PYTHON_FOR_BUILD,[build system python (default: python)]) + + # generate output files AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) AC_OUTPUT