llvm.org GIT mirror llvm / 3ef8b0a
build: add --with-python option This adds a new --with-python option to allow configuration of the python binary for building. If not specified, $PATH will be searched for common python binary names (python, python2, python3). If specified, and the path is not executable, it will attempt to search $PATH. Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org> Reviewed-by: Eric Christopher <echristo@gmail.com>, Daniel Dunbar <daniel@zuster.org> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173890 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
5 changed file(s) with 36 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
178178 RM := @RM@
179179 SED := @SED@
180180 TAR := @TAR@
181 PYTHON := @PYTHON@
181182
182183 # Paths to miscellaneous programs we hope are present but might not be
183184 BZIP2 := @BZIP2@
9696 $(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
9797 $(PROJ_OBJ_ROOT)/Makefile.config
9898 $(Echo) Constructing LLVMBuild project information.
99 $(Verb) $(LLVMBuildTool) \
99 $(Verb)$(PYTHON) $(LLVMBuildTool) \
100100 --native-target "$(TARGET_NATIVE_ARCH)" \
101101 --enable-targets "$(TARGETS_TO_BUILD)" \
102102 --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
825825 #----------------------------------------------------------
826826
827827 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
828 ECHOPATH := $(Verb)python -u -c "import sys;print ' '.join(sys.argv[1:])"
828 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
829829 else
830830 ECHOPATH := $(Verb)$(ECHO)
831831 endif
12971297 fi
12981298 AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED])
12991299
1300 AC_ARG_WITH([python],
1301 [AS_HELP_STRING([--with-python], [path to python])],
1302 [PYTHON="$withval"])
1303
1304 if test -n "$PYTHON" && test -x "$PYTHON" ; then
1305 AC_MSG_CHECKING([for python])
1306 AC_MSG_RESULT([user defined: $with_python])
1307 else
1308 if test -n "$PYTHON" ; then
1309 AC_MSG_WARN([specified python ($PYTHON) is not usable, searching path])
1310 fi
1311
1312 AC_PATH_PROG([PYTHON], [python python2 python26],
1313 [AC_MSG_RESULT([not found])
1314 AC_MSG_ERROR([could not find python 2.5 or higher])])
1315 fi
1316
1317 AC_MSG_CHECKING([for python >= 2.5])
1318 ac_python_version=`$PYTHON -c 'import sys; print sys.version.split()[[0]]'`
1319 ac_python_version_major=`echo $ac_python_version | cut -d'.' -f1`
1320 ac_python_version_minor=`echo $ac_python_version | cut -d'.' -f2`
1321 ac_python_version_patch=`echo $ac_python_version | cut -d'.' -f3`
1322 if test "$ac_python_version_major" -eq "2" \
1323 && test "$ac_python_version_minor" -ge "5" ; then
1324 AC_MSG_RESULT([$PYTHON ($ac_python_version)])
1325 else
1326 AC_MSG_RESULT([not found])
1327 AC_MSG_FAILURE([found python $ac_python_version ($PYTHON); required >= 2.5])
1328 fi
13001329
13011330 dnl===-----------------------------------------------------------------------===
13021331 dnl===
744744 #----------------------------------------------------------
745745
746746 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
747 ECHOPATH := $(Verb)python -u -c "import sys;print ' '.join(sys.argv[1:])"
747 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
748748 else
749749 ECHOPATH := $(Verb)$(ECHO)
750750 endif
8686
8787 check-local:: lit.site.cfg Unit/lit.site.cfg
8888 ( $(ULIMIT) \
89 $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) )
89 $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) )
9090
9191 # This is a legacy alias dating from when both DejaGNU and lit were in use.
9292 check-local-lit:: check-local
9393
9494 check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-site-cfgs
9595 ( $(ULIMIT) \
96 $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
96 $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
9797
9898 clean::
9999 $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
137137 @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
138138 @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> lit.tmp
139139 @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp
140 @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=python=g >> lit.tmp
140 @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp
141141 @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc $(subst *,'\\\"',*$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))*) -I $(LibDir)/ocaml=g >> lit.tmp
142142 @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp
143143 @$(ECHOPATH) s=@ENABLE_ASSERTIONS@=$(ENABLE_ASSERTIONS)=g >> lit.tmp