diff --git a/make/Init.gmk b/make/Init.gmk
index 5027dd68af9..6de559e2c60 100644
--- a/make/Init.gmk
+++ b/make/Init.gmk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -226,6 +226,15 @@ else # HAS_SPEC=true
# Parse COMPARE_BUILD (for makefile development)
$(eval $(call ParseCompareBuild))
+ # If no LOG= was given on command line, but we have a non-standard default
+ # value, use that instead and re-parse log level.
+ ifeq ($(LOG), )
+ ifneq ($(DEFAULT_LOG), )
+ override LOG := $(DEFAULT_LOG)
+ $(eval $(call ParseLogLevel))
+ endif
+ endif
+
ifeq ($(LOG_NOFILE), true)
# Disable build log if LOG=[level,]nofile was given
override BUILD_LOG_PIPE :=
diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk
index c63941f47ca..37bb7ebdd2f 100644
--- a/make/InitSupport.gmk
+++ b/make/InitSupport.gmk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -131,73 +131,6 @@ ifeq ($(HAS_SPEC),)
endif
endef
- # Look for a given option in the LOG variable, and if found, set a variable
- # and remove the option from the LOG variable
- # $1: The option to look for
- # $2: The option to set to "true" if the option is found
- define ParseLogOption
- ifneq ($$(findstring $1, $$(LOG)),)
- $2 := true
- # COMMA is defined in spec.gmk, but that is not included yet
- COMMA := ,
- # First try to remove "," if it exists, otherwise just remove " "
- LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$(strip $1),, $$(LOG)))
- # We might have ended up with a leading comma. Remove it. Need override
- # since LOG is set from the command line.
- override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
- endif
- endef
-
- define ParseLogLevel
- # Catch old-style VERBOSE= command lines.
- ifneq ($$(origin VERBOSE), undefined)
- $$(info Error: VERBOSE is deprecated. Use LOG= instead.)
- $$(error Cannot continue)
- endif
-
- # Setup logging according to LOG
-
- # If the "nofile" argument is given, act on it and strip it away
- $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
-
- # If the "cmdline" argument is given, act on it and strip it away
- $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
-
- # If the "profile-to-log" argument is given, write shell times in build log
- $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
-
- # If the "profile" argument is given, write shell times in separate log file
- # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
- # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
- # Error: LOG contains unknown option or log level: debug-to-log.
- $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
-
- # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
- LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
-
- LOG_LEVEL := $$(LOG)
-
- ifeq ($$(LOG_LEVEL),)
- # Set LOG to "warn" as default if not set
- LOG_LEVEL := warn
- endif
-
- ifeq ($$(LOG_LEVEL), warn)
- MAKE_LOG_FLAGS := -s
- else ifeq ($$(LOG_LEVEL), info)
- MAKE_LOG_FLAGS := -s
- else ifeq ($$(LOG_LEVEL), debug)
- MAKE_LOG_FLAGS :=
- else ifeq ($$(LOG_LEVEL), trace)
- MAKE_LOG_FLAGS :=
- else
- $$(info Error: LOG contains unknown option or log level: $$(LOG).)
- $$(info LOG can be [,[...]] where is nofile | cmdlines | profile | profile-to-log)
- $$(info and is warn | info | debug | trace)
- $$(error Cannot continue)
- endif
- endef
-
define ParseConfAndSpec
ifneq ($$(origin SPEC), undefined)
# We have been given a SPEC, check that it works out properly
@@ -477,30 +410,38 @@ else # $(HAS_SPEC)=true
endef
define PrintFailureReports
- $(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
- $(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
- $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
- $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
- ($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
- if test `$(WC) -l < $(logfile)` -gt 12; then \
- $(ECHO) " ... (rest of output omitted)" ; \
- fi $(NEWLINE) \
+ $(if $(filter none, $(LOG_REPORT)), , \
+ $(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
+ $(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
+ $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
+ $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
+ $(if $(filter all, $(LOG_REPORT)), \
+ $(GREP) -v -e "^Note: including file:" < $(logfile) || true $(NEWLINE) \
+ , \
+ ($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
+ if test `$(WC) -l < $(logfile)` -gt 12; then \
+ $(ECHO) " ... (rest of output omitted)" ; \
+ fi $(NEWLINE) \
+ ) \
+ ) \
+ $(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" $(NEWLINE) \
+ $(PRINTF) "=== End of repeated output ===\n" \
) \
- $(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" $(NEWLINE) \
- $(PRINTF) "=== End of repeated output ===\n" \
)
endef
define PrintBuildLogFailures
- if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then \
- $(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
- $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
- $(PRINTF) "=== End of repeated output ===\n" ; \
- $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
- else \
- $(PRINTF) "\nNo indication of failed target found.\n" ; \
- $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
- fi
+ $(if $(filter none, $(LOG_REPORT)), , \
+ if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then \
+ $(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
+ $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
+ $(PRINTF) "=== End of repeated output ===\n" ; \
+ $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
+ else \
+ $(PRINTF) "\nNo indication of failed target found.\n" ; \
+ $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
+ fi \
+ )
endef
define RotateLogFiles
@@ -583,8 +524,107 @@ else # $(HAS_SPEC)=true
endif # HAS_SPEC
+# Look for a given option in the LOG variable, and if found, set a variable
+# and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to "true" if the option is found
+define ParseLogOption
+ ifneq ($$(findstring $1, $$(LOG)),)
+ override $2 := true
+ # COMMA is defined in spec.gmk, but that is not included yet
+ COMMA := ,
+ # First try to remove "," if it exists, otherwise just remove " "
+ LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$$(strip $1),, $$(LOG)))
+ # We might have ended up with a leading comma. Remove it. Need override
+ # since LOG is set from the command line.
+ override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+ endif
+endef
+
+# Look for a given option with an assignment in the LOG variable, and if found,
+# set a variable to that value and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to the value of the option, if found
+define ParseLogValue
+ ifneq ($$(findstring $1=, $$(LOG)),)
+ # Make words of out comma-separated list and find the one with opt=val
+ value := $$(strip $$(subst $$(strip $1)=,, $$(filter $$(strip $1)=%, $$(subst $$(COMMA), , $$(LOG)))))
+ override $2 := $$(value)
+ # COMMA is defined in spec.gmk, but that is not included yet
+ COMMA := ,
+ # First try to remove ", " if it exists, otherwise just remove " "
+ LOG_STRIPPED := $$(subst $$(strip $1)=$$(value),, \
+ $$(subst $$(COMMA)$$(strip $1)=$$(value),, $$(LOG)))
+ # We might have ended up with a leading comma. Remove it. Need override
+ # since LOG is set from the command line.
+ override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+ endif
+endef
+
+
+define ParseLogLevel
+ # Catch old-style VERBOSE= command lines.
+ ifneq ($$(origin VERBOSE), undefined)
+ $$(info Error: VERBOSE is deprecated. Use LOG= instead.)
+ $$(error Cannot continue)
+ endif
+
+ # Setup logging according to LOG
+
+ # If "nofile" is present, do not log to a file
+ $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
+
+ # If "cmdline" is present, print all executes "important" command lines.
+ $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
+
+ # If "report" is present, use non-standard reporting options at build failure.
+ $$(eval $$(call ParseLogValue, report, LOG_REPORT))
+ ifneq ($$(LOG_REPORT), )
+ ifeq ($$(filter $$(LOG_REPORT), none all default), )
+ $$(info Error: LOG=report has invalid value: $$(LOG_REPORT).)
+ $$(info Valid values: LOG=report=||)
+ $$(error Cannot continue)
+ endif
+ endif
+
+ # If "profile-to-log" is present, write shell times in build log
+ $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
+
+ # If "profile" is present, write shell times in separate log file
+ # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
+ # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
+ # Error: LOG contains unknown option or log level: debug-to-log.
+ $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
+
+ # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
+ LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
+
+ override LOG_LEVEL := $$(LOG)
+
+ ifeq ($$(LOG_LEVEL),)
+ # Set LOG to "warn" as default if not set
+ override LOG_LEVEL := warn
+ endif
+
+ ifeq ($$(LOG_LEVEL), warn)
+ override MAKE_LOG_FLAGS := -s
+ else ifeq ($$(LOG_LEVEL), info)
+ override MAKE_LOG_FLAGS := -s
+ else ifeq ($$(LOG_LEVEL), debug)
+ override MAKE_LOG_FLAGS :=
+ else ifeq ($$(LOG_LEVEL), trace)
+ override MAKE_LOG_FLAGS :=
+ else
+ $$(info Error: LOG contains unknown option or log level: $$(LOG).)
+ $$(info LOG can be [,[...]] where is nofile | cmdlines | profile | profile-to-log)
+ $$(info and is warn | info | debug | trace)
+ $$(error Cannot continue)
+ endif
+endef
+
MAKE_LOG_VARS = $(foreach v, \
- LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_PROFILE_TIMES_LOG LOG_PROFILE_TIMES_FILE, \
+ LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_REPORT LOG_PROFILE_TIMES_LOG \
+ LOG_PROFILE_TIMES_FILE, \
$v=$($v) \
)
diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4
index c8877c92ecb..de2c26607cd 100644
--- a/make/autoconf/basics.m4
+++ b/make/autoconf/basics.m4
@@ -1260,6 +1260,24 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_MAKE_TARGET],
AC_SUBST(DEFAULT_MAKE_TARGET)
])
+# Setup the default value for LOG=
+#
+AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_LOG],
+[
+ AC_ARG_WITH(log, [AS_HELP_STRING([--with-log],
+ [[default vaue for make LOG argument [warn]]])])
+ AC_MSG_CHECKING([for default LOG value])
+ if test "x$with_log" = x; then
+ DEFAULT_LOG=""
+ else
+ # Syntax for valid LOG options is a bit too complex for it to be worth
+ # implementing a test for correctness in configure. Just accept it.
+ DEFAULT_LOG=$with_log
+ fi
+ AC_MSG_RESULT([$DEFAULT_LOG])
+ AC_SUBST(DEFAULT_LOG)
+])
+
# Code to run after AC_OUTPUT
AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
[
diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac
index bfa3de31957..62178677837 100644
--- a/make/autoconf/configure.ac
+++ b/make/autoconf/configure.ac
@@ -120,6 +120,7 @@ PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION
# Misc basic settings
BASIC_SETUP_DEFAULT_MAKE_TARGET
+BASIC_SETUP_DEFAULT_LOG
###############################################################################
#
diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in
index d8934e7da18..59524a0a737 100644
--- a/make/autoconf/spec.gmk.in
+++ b/make/autoconf/spec.gmk.in
@@ -332,6 +332,7 @@ TEST_JOBS?=@TEST_JOBS@
# Default make target
DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@
+DEFAULT_LOG:=@DEFAULT_LOG@
FREETYPE_TO_USE:=@FREETYPE_TO_USE@
FREETYPE_LIBS:=@FREETYPE_LIBS@