Skip to content

Commit a72f750

Browse files
committed
8356379: Need a proper way to test existence of binary from configure
Reviewed-by: erikj
1 parent fa765e7 commit a72f750

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

make/autoconf/boot-jdk.m4

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -180,11 +180,13 @@ AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME],
180180
# Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
181181
AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK],
182182
[
183-
UTIL_LOOKUP_PROGS(JAVAC_CHECK, javac, , NOFIXPATH)
184-
UTIL_LOOKUP_PROGS(JAVA_CHECK, java, , NOFIXPATH)
185-
BINARY="$JAVAC_CHECK"
186-
if test "x$JAVAC_CHECK" = x; then
187-
BINARY="$JAVA_CHECK"
183+
UTIL_LOOKUP_PROGS(JAVAC_CHECK, javac)
184+
UTIL_GET_EXECUTABLE(JAVAC_CHECK) # Will setup JAVAC_CHECK_EXECUTABLE
185+
UTIL_LOOKUP_PROGS(JAVA_CHECK, java)
186+
UTIL_GET_EXECUTABLE(JAVA_CHECK) # Will setup JAVA_CHECK_EXECUTABLE
187+
BINARY="$JAVAC_CHECK_EXECUTABLE"
188+
if test "x$JAVAC_CHECK_EXECUTABLE" = x; then
189+
BINARY="$JAVA_CHECK_EXECUTABLE"
188190
fi
189191
if test "x$BINARY" != x; then
190192
# So there is a java(c) binary, it might be part of a JDK.

make/autoconf/util_paths.m4

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -186,7 +186,6 @@ AC_DEFUN([UTIL_CHECK_WINENV_EXEC_TYPE],
186186
# it need to be in the PATH.
187187
# $1: The name of the variable to fix
188188
# $2: Where to look for the command (replaces $PATH)
189-
# $3: set to NOFIXPATH to skip prefixing FIXPATH, even if needed on platform
190189
AC_DEFUN([UTIL_FIXUP_EXECUTABLE],
191190
[
192191
input="[$]$1"
@@ -282,10 +281,6 @@ AC_DEFUN([UTIL_FIXUP_EXECUTABLE],
282281
fi
283282
fi
284283
285-
if test "x$3" = xNOFIXPATH; then
286-
fixpath_prefix=""
287-
fi
288-
289284
# Now join together the path and the arguments once again
290285
new_complete="$fixpath_prefix$new_path$arguments"
291286
$1="$new_complete"
@@ -379,7 +374,6 @@ AC_DEFUN([UTIL_SETUP_TOOL],
379374
# $1: variable to set
380375
# $2: executable name (or list of names) to look for
381376
# $3: [path]
382-
# $4: set to NOFIXPATH to skip prefixing FIXPATH, even if needed on platform
383377
AC_DEFUN([UTIL_LOOKUP_PROGS],
384378
[
385379
UTIL_SETUP_TOOL($1, [
@@ -421,10 +415,8 @@ AC_DEFUN([UTIL_LOOKUP_PROGS],
421415
422416
# If we have FIXPATH enabled, strip all instances of it and prepend
423417
# a single one, to avoid double fixpath prefixing.
424-
if test "x$4" != xNOFIXPATH; then
425-
[ if [[ $FIXPATH != "" && $result =~ ^"$FIXPATH " ]]; then ]
426-
result="\$FIXPATH ${result#"$FIXPATH "}"
427-
fi
418+
[ if [[ $FIXPATH != "" && $result =~ ^"$FIXPATH " ]]; then ]
419+
result="\$FIXPATH ${result#"$FIXPATH "}"
428420
fi
429421
AC_MSG_RESULT([$result])
430422
break 2;
@@ -515,6 +507,24 @@ AC_DEFUN([UTIL_ADD_FIXPATH],
515507
fi
516508
])
517509

510+
################################################################################
511+
# Return a path to the executable binary from a command line, stripping away
512+
# any FIXPATH prefix or arguments. The resulting value can be checked for
513+
# existence using "test -e". The result is returned in a variable named
514+
# "$1_EXECUTABLE".
515+
#
516+
# $1: variable describing the command to get the binary for
517+
AC_DEFUN([UTIL_GET_EXECUTABLE],
518+
[
519+
# Strip the FIXPATH prefix, if any
520+
fixpath_stripped="[$]$1"
521+
[ if [[ $FIXPATH != "" && $fixpath_stripped =~ ^"$FIXPATH " ]]; then ]
522+
fixpath_stripped="${fixpath_stripped#"$FIXPATH "}"
523+
fi
524+
# Remove any arguments following the binary
525+
$1_EXECUTABLE="${fixpath_stripped%% *}"
526+
])
527+
518528
################################################################################
519529
AC_DEFUN([UTIL_REMOVE_SYMBOLIC_LINKS],
520530
[

0 commit comments

Comments
 (0)