2
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
31
# Hook to include the corresponding custom file, if present.
32
$(eval $(call IncludeCustomExtension, Doctor.gmk))
34
################################################################################
36
# Help user diagnose possible errors and problems with the build environment.
41
$(ECHO) '"make doctor" will help you analyze your build environment. It can highlight'
42
$(ECHO) 'certain well-known problems, but it can never find all possible errors.'
48
$(ECHO) '* Verifying that configure has picked up git...'
50
$(ECHO) 'WARNING: "git" is not present. This will disable several checks.'
51
$(ECHO) '! Correct by installing git and verifying that it is in the PATH'
57
AUTOCRLF := $(shell $(GIT) config core.autocrlf)
60
check-autocrlf: check-git
62
ifeq ($(call isBuildOs, windows), true)
64
$(ECHO) '* Verifying git core.autocrlf value...'
65
ifneq ($(AUTOCRLF), false)
66
$(ECHO) 'WARNING: core.autocrlf is not "false". HIGH RISK of build failure!'
67
$(ECHO) '! Correct by running 'git config --global core.autocrlf false' and re-cloning the repo'
72
TARGETS += check-autocrlf
74
check-configure-warnings: check-autocrlf
76
$(ECHO) '* Checking for warnings from configure...'
77
warning_output=`$(GREP) -e "^\* Memory limit:" -A 300 $(OUTPUTDIR)/configure.log | $(TAIL) -n +3 | $(SED) -e '$(DOLLAR){/^$(DOLLAR)/d;}'` && \
78
if test -n "$$warning_output" ; then \
80
$(GREP) -e "^\* Memory limit:" -A 300 $(OUTPUTDIR)/configure.log | $(TAIL) -n +3 | $(SED) -e '$(DOLLAR){/^$(DOLLAR)/d;}' ; \
82
$(ECHO) '! Inspect the warnings, fix any problems, and re-run configure' ; \
85
TARGETS += check-configure-warnings
88
# This might have been set by custom component
89
UNTRACKED_FILES ?= $(shell $(GIT) status --porcelain --ignored | $(CUT) -c 4-)
92
check-core-files: check-configure-warnings
95
$(ECHO) '* Checking for left-over core files...'
96
core_files_found=`echo "$(UNTRACKED_FILES)" | $(TR) ' ' '\n' | $(GREP) core` && \
97
if test -n "$$core_files_found" ; then \
98
$(ECHO) 'Found these potential core files. They might interfere with the build process:' ; \
100
$(ECHO) $$core_files_found | $(TR) ' ' '\n'; \
102
$(ECHO) '! Remove left-over core files' ; \
103
fi || : # do nothing if grep returns non-0 value
106
TARGETS += check-core-files
108
check-bad-file-names: check-core-files
111
$(ECHO) '* Checking for untracked files with illegal names...'
112
core_files_found=`echo "$(UNTRACKED_FILES)" | $(TR) ' ' '\n' | $(GREP) '#'` && \
113
if test -n "$$core_files_found" ; then \
114
$(ECHO) 'Found these files with illegal names. They *will* cause build failures:' ; \
116
$(ECHO) $$core_files_found | $(TR) ' ' '\n'; \
118
$(ECHO) '! Remove all files with '#' in their name from the JDK source tree' ; \
119
fi || : # do nothing if grep returns non-0 value
122
TARGETS += check-bad-file-names
124
epilogue: check-bad-file-names
126
$(ECHO) '* If all else fails, try removing the entire build directory and re-creating'
127
$(ECHO) 'the same configuration using:'
129
$(ECHO) configure_command_line=\$$\(make print-configuration\)
130
$(ECHO) make dist-clean
131
$(ECHO) bash configure \$$configure_command_line
134
$(ECHO) '* The build README (doc/building.md) is a great source of information,'
135
$(ECHO) 'especially the chapter "Fixing Unexpected Build Failures". Check it out!'
137
$(ECHO) '* If you still need assistance please contact build-dev@openjdk.org.'
142
################################################################################
148
.PHONY: default all doctor $(TARGETS)