diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | Rules | 24 | ||||
-rw-r--r-- | benchtests/Makefile | 10 | ||||
-rw-r--r-- | config.make.in | 1 | ||||
-rwxr-xr-x | configure | 62 | ||||
-rw-r--r-- | configure.ac | 16 |
6 files changed, 109 insertions, 18 deletions
@@ -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] @@ -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 .PHONY: distclean realclean subdir_distclean subdir_realclean \ diff --git a/benchtests/Makefile b/benchtests/Makefile index f5d6dac6c7..9eef1e1243 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -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)) diff --git a/config.make.in b/config.make.in index d2d9b8ab36..35e7e59663 100644 --- a/config.make.in +++ b/config.make.in @@ -126,6 +126,7 @@ MSGFMT = @MSGFMT@ BASH = @BASH_SHELL@ AWK = @AWK@ PERL = @PERL@ +PYTHON = @PYTHON@ # Additional libraries. LIBGD = @LIBGD@ @@ -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 diff --git a/configure.ac b/configure.ac index d719fadeef..aa6e2d7e56 100644 --- a/configure.ac +++ b/configure.ac @@ -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 |