2
# Copyright (c) 2011, 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
26
# Setup basic configuration paths, and platform-specific stuff related to PATHs.
27
AC_DEFUN([BASIC_SETUP_PATHS_WINDOWS],
29
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
30
# Clarify if it is wsl1 or wsl2, and use that as OS_ENV from this point forward
31
$PATHTOOL -w / > /dev/null 2>&1
32
if test $? -ne 0; then
33
# Without Windows access to our root, it's definitely WSL1
34
OPENJDK_BUILD_OS_ENV=windows.wsl1
36
# This test is not guaranteed, but there is no documented way of
37
# distinguishing between WSL1 and WSL2.
38
# Check whether "Hyper-V" appears in /proc/interrupts because WSL2 runs on Hyper-V.
39
$GREP -q Hyper-V /proc/interrupts
40
if test $? -eq 0; then
41
OPENJDK_BUILD_OS_ENV=windows.wsl2
43
OPENJDK_BUILD_OS_ENV=windows.wsl1
46
# This is a bit silly since we really don't have a target env as such,
47
# but do it to keep consistency.
48
OPENJDK_TARGET_OS_ENV=$OPENJDK_BUILD_OS_ENV
51
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys2"; then
52
# Must be done prior to calling any commands to avoid mangling of command line
53
export MSYS2_ARG_CONV_EXCL="*"
56
AC_MSG_CHECKING([Windows environment type])
57
WINENV_VENDOR=${OPENJDK_BUILD_OS_ENV#windows.}
58
AC_MSG_RESULT([$WINENV_VENDOR])
60
if test "x$WINENV_VENDOR" = x; then
61
AC_MSG_ERROR([Unknown Windows environment. Neither cygwin, msys2, wsl1 nor wsl2 was detected.])
64
if test "x$PATHTOOL" = x; then
65
AC_MSG_ERROR([Incorrect $WINENV_VENDOR installation. Neither cygpath nor wslpath was found])
68
if test "x$CMD" = x; then
69
AC_MSG_ERROR([Incorrect Windows/$WINENV_VENDOR setup. Could not locate cmd.exe])
72
AC_MSG_CHECKING([$WINENV_VENDOR drive prefix])
73
WINENV_PREFIX=`$PATHTOOL -u c:/ | $SED -e 's!/c/!!'`
74
AC_MSG_RESULT(['$WINENV_PREFIX'])
75
AC_SUBST(WINENV_PREFIX)
77
AC_MSG_CHECKING([$WINENV_VENDOR root directory as Windows path])
78
if test "x$OPENJDK_BUILD_OS_ENV" != "xwindows.wsl1"; then
79
WINENV_ROOT=`$PATHTOOL -w / 2> /dev/null`
80
# msys2 has a trailing backslash; strip it
81
WINENV_ROOT=${WINENV_ROOT%\\}
83
WINENV_ROOT='[[unavailable]]'
85
AC_MSG_RESULT(['$WINENV_ROOT'])
88
AC_MSG_CHECKING([$WINENV_VENDOR temp directory])
89
WINENV_TEMP_DIR=$($PATHTOOL -u $($CMD /q /c echo %TEMP% 2> /dev/null) | $TR -d '\r\n')
90
AC_MSG_RESULT([$WINENV_TEMP_DIR])
92
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl2"; then
93
# Don't trust the current directory for WSL2, but change to an OK temp dir
95
# Bring along confdefs.h or autoconf gets all confused
96
cp "$CONFIGURE_START_DIR/confdefs.h" "$WINENV_TEMP_DIR"
99
AC_MSG_CHECKING([$WINENV_VENDOR release])
100
WINENV_UNAME_RELEASE=`$UNAME -r`
101
AC_MSG_RESULT([$WINENV_UNAME_RELEASE])
103
AC_MSG_CHECKING([$WINENV_VENDOR version])
104
WINENV_UNAME_VERSION=`$UNAME -v`
105
AC_MSG_RESULT([$WINENV_UNAME_VERSION])
107
WINENV_VERSION="$WINENV_UNAME_RELEASE, $WINENV_UNAME_VERSION"
109
AC_MSG_CHECKING([Windows version])
111
# We must change directory to one guaranteed to work, otherwise WSL1
112
# can complain (since it does not have a WINENV_ROOT so it can't access
113
# unix-style paths from Windows.
114
# Additional [] needed to keep m4 from mangling shell constructs.
115
[ WINDOWS_VERSION=`cd $WINENV_TEMP_DIR && $CMD /c ver | $EGREP -o '([0-9]+\.)+[0-9]+'` ]
116
AC_MSG_RESULT([$WINDOWS_VERSION])
118
# Additional handling per specific env
119
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
120
# Additional [] needed to keep m4 from mangling shell constructs.
121
[ CYGWIN_VERSION_OLD=`$ECHO $WINENV_UNAME_RELEASE | $GREP -e '^1\.[0-6]'` ]
122
if test "x$CYGWIN_VERSION_OLD" != x; then
123
AC_MSG_NOTICE([Your cygwin is too old. You are running $CYGWIN_RELEASE, but at least cygwin 1.7 is required. Please upgrade.])
124
AC_MSG_ERROR([Cannot continue])
126
if test "x$LDD" = x; then
127
AC_MSG_ERROR([ldd is missing, which is needed on cygwin])
129
WINENV_MARKER_DLL=cygwin1.dll
130
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys2"; then
131
if test "x$LDD" = x; then
132
AC_MSG_ERROR([ldd is missing, which is needed on msys2])
134
WINENV_MARKER_DLL=msys-2.0.dll
135
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl1" || test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl2"; then
136
AC_MSG_CHECKING([wsl distribution])
137
WSL_DISTRIBUTION=`$LSB_RELEASE -d | sed 's/Description:\t//'`
138
AC_MSG_RESULT([$WSL_DISTRIBUTION])
140
WINENV_VERSION="$WINENV_VERSION ($WSL_DISTRIBUTION)"
142
# Tell WSL to automatically translate the PATH variable
146
# Chicken and egg: FIXPATH is needed for UTIL_FIXUP_PATH to work. So for the
147
# first run we use the auto-detect abilities of fixpath.sh.
148
FIXPATH_DIR="$TOPDIR/make/scripts"
149
FIXPATH="$BASH $FIXPATH_DIR/fixpath.sh exec"
150
FIXPATH_BASE="$BASH $FIXPATH_DIR/fixpath.sh"
151
FIXPATH_SAVED_PATH="$PATH"
152
UTIL_FIXUP_PATH(FIXPATH_DIR)
154
# Now we can use FIXPATH_DIR to rewrite path to fixpath.sh properly.
155
if test "x$WINENV_PREFIX" = x; then
156
# On msys the prefix is empty, but we need to pass something to have the
157
# fixpath.sh options parser happy.
158
WINENV_PREFIX_ARG="NONE"
160
WINENV_PREFIX_ARG="$WINENV_PREFIX"
162
FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD -q"
163
FIXPATH_BASE="$BASH $FIXPATH_DIR/fixpath.sh $FIXPATH_ARGS"
164
FIXPATH="$FIXPATH_BASE exec"
166
AC_SUBST(FIXPATH_BASE)
169
SRC_ROOT_LENGTH=`$ECHO "$TOPDIR" | $WC -m`
170
if test $SRC_ROOT_LENGTH -gt 100; then
171
AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
174
# Test if windows or unix "find" is first in path.
175
AC_MSG_CHECKING([what kind of 'find' is first on the PATH])
176
FIND_BINARY_OUTPUT=`find --version 2>&1`
177
if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then
178
AC_MSG_RESULT([unix style])
179
elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then
180
AC_MSG_RESULT([Windows])
181
AC_MSG_NOTICE([Your path contains Windows tools (C:\Windows\system32) before your unix tools.])
182
AC_MSG_NOTICE([This will not work. Please correct and make sure /usr/bin (or similar) is first in path.])
183
AC_MSG_ERROR([Cannot continue])
185
AC_MSG_RESULT([unknown])
186
AC_MSG_WARN([It seems that your find utility is non-standard.])
189
if test "x$GIT" != x && test -e $TOPDIR/.git; then
190
git_autocrlf=`$GIT config core.autocrlf`
191
if test "x$git_autocrlf" != x && test "x$git_autocrlf" != "xfalse"; then
192
AC_MSG_NOTICE([Your git configuration does not set core.autocrlf to false.])
193
AC_MSG_NOTICE([If you checked out this code using that setting, the build WILL fail.])
194
AC_MSG_NOTICE([To correct, run "git config --global core.autocrlf false" and re-clone the repo.])
195
AC_MSG_WARN([Code is potentially incorrectly cloned. HIGH RISK of build failure!])
200
# Verify that the directory is usable on Windows
201
AC_DEFUN([BASIC_WINDOWS_VERIFY_DIR],
203
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl1"; then
204
OUTPUTDIR_WIN=`$FIXPATH_BASE print $1`
205
if test "x$OUTPUTDIR_WIN" = x; then
206
AC_MSG_NOTICE([For wsl1, the $2 dir must be located on a Windows drive. Please see doc/building.md for details.])
207
AC_MSG_ERROR([Cannot continue])
212
# Create fixpath wrapper
213
AC_DEFUN([BASIC_WINDOWS_FINALIZE_FIXPATH],
215
if test "x$OPENJDK_BUILD_OS" = xwindows; then
216
FIXPATH_CMDLINE=". $TOPDIR/make/scripts/fixpath.sh -e $PATHTOOL \
217
-p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR \
219
$ECHO > $OUTPUTDIR/fixpath '#!/bin/bash'
220
$ECHO >> $OUTPUTDIR/fixpath export PATH='"[$]PATH:'$PATH'"'
221
$ECHO >> $OUTPUTDIR/fixpath $FIXPATH_CMDLINE '"[$]@"'
222
$CHMOD +x $OUTPUTDIR/fixpath
223
FIXPATH_BASE="$OUTPUTDIR/fixpath"
224
FIXPATH="$FIXPATH_BASE exec"
228
# Platform-specific finalization
229
AC_DEFUN([BASIC_WINDOWS_FINALIZE],
231
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl2"; then
232
# Change back from temp dir
233
cd $CONFIGURE_START_DIR