]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add configure check for python program
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 22 Dec 2016 17:37:52 +0000 (23:07 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 22 Dec 2016 17:37:52 +0000 (23:07 +0530)
Add a configure check that looks for python3 and python in that order
since we had agreed in the past to prefer python3 over python in all
our code.  The patch also adjusts invocations through the various
Makefiles to use the set variable.

* configure.ac: Check for python3 or python.
* configure: Regenerated.
* config.make.in (PYTHON): New variable.
* benchtests/Makefile: Don't define PYTHON.
(bench): Define target only if PYTHON was defined.
* Rules: Don't define PYTHON.
Define pretty printer targets only if PYTHON was defined.
(tests-printers): Add to tests-unsupported if PYTHON is not
found.
(python-flags, python-invoke): Remove.
(tests-printers-out): Use PYTHON instead of python-invoke.

ChangeLog
Rules
benchtests/Makefile
config.make.in
configure
configure.ac

index 4f86f7a8cfa3df31b928cd78d5c5a03f634294ea..1fcd9eda10a9c738a973d7e4853e56e2e6273ec7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2016-12-22  Siddhesh Poyarekar  <siddhesh@sourceware.org>
+
+       * configure.ac: Check for python3 or python.
+       * configure: Regenerated.
+       * config.make.in (PYTHON): New variable.
+       * benchtests/Makefile: Don't define PYTHON.
+       (bench): Define target only if PYTHON was defined.
+       * Rules: Don't define PYTHON.
+       Define pretty printer targets only if PYTHON was defined.
+       (tests-printers): Add to tests-unsupported if PYTHON is not
+       found.
+       (python-flags, python-invoke): Remove.
+       (tests-printers-out): Use PYTHON instead of python-invoke.
+
 2016-12-21  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #20978]
diff --git a/Rules b/Rules
index fe18ce55de9234c3a62b04abc16b05c80fd76855..558924d6536616ffa4fad066c9570c9e85f51f2f 100644 (file)
--- a/Rules
+++ b/Rules
@@ -114,6 +114,11 @@ tests-printers-programs := $(addprefix $(objpfx),$(tests-printers))
 # .out files with the output of running the pretty printer tests.
 tests-printers-out := $(patsubst %,$(objpfx)%.out,$(tests-printers))
 
+ifndef PYTHON
+# Mark tests-printers tests as unsupported if we don't have PYTHON.
+tests-unsupported += $(tests-printers)
+endif
+
 ifeq ($(build-programs),yes)
 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
 else
@@ -124,9 +129,9 @@ endif
 others: $(py-const)
 
 ifeq ($(run-built-tests),no)
-tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported),$(tests)) \
-                            $(test-srcs)) $(tests-special) \
-       $(tests-printers-programs)
+tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported),$(tests) \
+                              $(tests-printers-programs)) \
+                            $(test-srcs)) $(tests-special)
 xtests: tests $(xtests-special)
 else
 tests: $(tests:%=$(objpfx)%.out) $(tests-special) $(tests-printers-out)
@@ -255,16 +260,8 @@ endif
 
 endif  # tests
 
+ifdef PYTHON
 ifneq "$(strip $(tests-printers))" ""
-# We're defining this here for now; later it'll be defined at configure time
-# inside Makeconfig.
-PYTHON := python
-
-# Invoke Python using -B to avoid generating .pyc files on the source dir,
-# so that we can keep it read-only.
-python-flags := -B
-
-python-invoke := $(PYTHON) $(python-flags)
 
 # Static pattern rule for building the test programs for the pretty printers.
 $(tests-printers-programs): %: %.o $(tests-printers-libs) \
@@ -283,9 +280,10 @@ py-env := PYTHONPATH=$(py-const-dir):$(..)scripts:$${PYTHONPATH}
 $(tests-printers-out): $(objpfx)%.out: $(objpfx)% %.py %.c $(pretty-printers) \
                       $(..)scripts/test_printers_common.py
        $(test-wrapper-env) $(py-env) \
-           $(python-invoke) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \
+           $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \
        $(evaluate-test)
 endif
+endif
 
 \f
 .PHONY: distclean realclean subdir_distclean subdir_realclean \
index f5d6dac6c79ccbdfa1bb9e4b73bf62a474c95bc1..9eef1e1243ab6e7ec8e7ddb24e3a1d86fa2dd752 100644 (file)
@@ -18,8 +18,6 @@
 # Makefile for benchmark tests.  The only useful target here is `bench`.
 # Add benchmark functions in alphabetical order.
 
-PYTHON := python
-
 subdir := benchtests
 
 include ../Makeconfig
@@ -146,7 +144,15 @@ bench-clean:
        rm -f $(timing-type) $(addsuffix .o,$(timing-type))
        rm -f $(addprefix $(objpfx),$(bench-extra-objs))
 
+# Define the bench target only if the target has a usable python installation.
+ifdef PYTHON
 bench: bench-build bench-set bench-func bench-malloc
+else
+bench:
+       @echo "The bench target needs python to run."
+       @exit 1
+endif
+
 # Target to only build the benchmark without running it.  We generate locales
 # only if we're building natively.
 ifeq (no,$(cross-compiling))
index d2d9b8ab36895f8bd2be41e8638cc3e9b9fa1875..35e7e59663db7057f0c06f1996555e1dafcbe205 100644 (file)
@@ -126,6 +126,7 @@ MSGFMT = @MSGFMT@
 BASH = @BASH_SHELL@
 AWK = @AWK@
 PERL = @PERL@
+PYTHON = @PYTHON@
 
 # Additional libraries.
 LIBGD = @LIBGD@
index 5cf3230b5627ccbe0911d8d94374a0664152ce80..10b0fb70694f90806879ab376a179d0abcbaf5d5 100755 (executable)
--- a/configure
+++ b/configure
@@ -639,6 +639,8 @@ CXX_CMATH_HEADER
 CXX_CSTDLIB_HEADER
 CXX_SYSINCLUDES
 SYSINCLUDES
+PYTHON
+PYTHON_PROG
 AUTOCONF
 NM
 AWK
@@ -5086,17 +5088,73 @@ else
   AUTOCONF=no
 fi
 
+# Check for python3 if available, or else python.
+for ac_prog in python3 python
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PYTHON_PROG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$PYTHON_PROG"; then
+  ac_cv_prog_PYTHON_PROG="$PYTHON_PROG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_PYTHON_PROG="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+PYTHON_PROG=$ac_cv_prog_PYTHON_PROG
+if test -n "$PYTHON_PROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_PROG" >&5
+$as_echo "$PYTHON_PROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PYTHON_PROG" && break
+done
+test -n "$PYTHON_PROG" || PYTHON_PROG="no"
+
+case "x$PYTHON_PROG" in
+xno|x|x:) PYTHON_PROG=no ;;
+*) ;;
+esac
+
+if test "x$PYTHON_PROG" = xno; then
+  aux_missing="$aux_missing python"
+else
+  PYTHON="$PYTHON_PROG -B"
+
+fi
+
 test -n "$critic_missing" && as_fn_error $? "
 *** These critical programs are missing or too old:$critic_missing
 *** Check the INSTALL file for required versions." "$LINENO" 5
 
 test -n "$aux_missing" && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
 *** These auxiliary programs are missing or incompatible versions:$aux_missing
-*** some features will be disabled.
+*** some features or tests will be disabled.
 *** Check the INSTALL file for required versions." >&5
 $as_echo "$as_me: WARNING:
 *** These auxiliary programs are missing or incompatible versions:$aux_missing
-*** some features will be disabled.
+*** some features or tests will be disabled.
 *** Check the INSTALL file for required versions." >&2;}
 
 # if using special system headers, find out the compiler's sekrit
index d719fadeef3f438683c4261be673c66a40e614b1..aa6e2d7e56cf0a71a28ff82b4f6529d1f02160f9 100644 (file)
@@ -1050,13 +1050,27 @@ else
   AUTOCONF=no
 fi
 
+# Check for python3 if available, or else python.
+AC_CHECK_PROGS(PYTHON_PROG, python3 python,no)
+case "x$PYTHON_PROG" in
+xno|x|x:) PYTHON_PROG=no ;;
+*) ;;
+esac
+
+if test "x$PYTHON_PROG" = xno; then
+  aux_missing="$aux_missing python"
+else
+  PYTHON="$PYTHON_PROG -B"
+  AC_SUBST(PYTHON)
+fi
+
 test -n "$critic_missing" && AC_MSG_ERROR([
 *** These critical programs are missing or too old:$critic_missing
 *** Check the INSTALL file for required versions.])
 
 test -n "$aux_missing" && AC_MSG_WARN([
 *** These auxiliary programs are missing or incompatible versions:$aux_missing
-*** some features will be disabled.
+*** some features or tests will be disabled.
 *** Check the INSTALL file for required versions.])
 
 # if using special system headers, find out the compiler's sekrit