2
# Copyright (c) 2011, 2024, 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
###############################################################################
27
# It is recommended to use exactly this version of pandoc, especially for
28
# re-generating checked in html files
29
RECOMMENDED_PANDOC_VERSION=2.19.2
31
###############################################################################
32
# Setup the most fundamental tools, used for setting up build platform and
34
AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
36
# Bootstrapping: These tools are needed by UTIL_LOOKUP_PROGS
37
AC_PATH_PROGS(BASENAME, basename)
38
UTIL_CHECK_NONEMPTY(BASENAME)
39
AC_PATH_PROGS(DIRNAME, dirname)
40
UTIL_CHECK_NONEMPTY(DIRNAME)
41
AC_PATH_PROGS(FILE, file)
42
UTIL_CHECK_NONEMPTY(FILE)
43
AC_PATH_PROGS(LDD, ldd)
46
UTIL_REQUIRE_PROGS(ECHO, echo)
47
UTIL_REQUIRE_PROGS(TR, tr)
48
UTIL_REQUIRE_PROGS(UNAME, uname)
49
UTIL_REQUIRE_PROGS(WC, wc)
51
# Required tools with some special treatment
52
UTIL_REQUIRE_SPECIAL(GREP, [AC_PROG_GREP])
53
UTIL_REQUIRE_SPECIAL(EGREP, [AC_PROG_EGREP])
54
UTIL_REQUIRE_SPECIAL(SED, [AC_PROG_SED])
56
# Tools only needed on some platforms
57
UTIL_LOOKUP_PROGS(LOCALE, locale)
58
UTIL_LOOKUP_PROGS(PATHTOOL, cygpath wslpath)
59
UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:/cygdrive/c/windows/system32:/mnt/c/windows/system32:/c/windows/system32)
62
###############################################################################
63
# Setup further tools that should be resolved early but after setting up
64
# build platform and path handling.
65
AC_DEFUN_ONCE([BASIC_SETUP_TOOLS],
68
UTIL_REQUIRE_PROGS(BASH, bash)
69
UTIL_REQUIRE_PROGS(CAT, cat)
70
UTIL_REQUIRE_PROGS(CHMOD, chmod)
71
UTIL_REQUIRE_PROGS(CP, cp)
72
UTIL_REQUIRE_PROGS(CUT, cut)
73
UTIL_REQUIRE_PROGS(DATE, date)
74
UTIL_REQUIRE_PROGS(DIFF, gdiff diff)
75
UTIL_REQUIRE_PROGS(EXPR, expr)
76
UTIL_REQUIRE_PROGS(FIND, find)
77
UTIL_REQUIRE_PROGS(GUNZIP, gunzip)
78
UTIL_REQUIRE_PROGS(GZIP, pigz gzip)
79
UTIL_REQUIRE_PROGS(HEAD, head)
80
UTIL_REQUIRE_PROGS(LN, ln)
81
UTIL_REQUIRE_PROGS(LS, ls)
82
# gmkdir is known to be safe for concurrent invocations with -p flag.
83
UTIL_REQUIRE_PROGS(MKDIR, gmkdir mkdir)
84
UTIL_REQUIRE_PROGS(MKTEMP, mktemp)
85
UTIL_REQUIRE_PROGS(MV, mv)
86
UTIL_REQUIRE_PROGS(AWK, gawk nawk awk)
87
UTIL_REQUIRE_PROGS(PRINTF, printf)
88
UTIL_REQUIRE_PROGS(RM, rm)
89
UTIL_REQUIRE_PROGS(RMDIR, rmdir)
90
UTIL_REQUIRE_PROGS(SH, sh)
91
UTIL_REQUIRE_PROGS(SORT, sort)
92
UTIL_REQUIRE_PROGS(TAIL, tail)
93
UTIL_REQUIRE_PROGS(TAR, gtar tar)
94
UTIL_REQUIRE_PROGS(TEE, tee)
95
UTIL_REQUIRE_PROGS(TOUCH, touch)
96
UTIL_REQUIRE_PROGS(XARGS, xargs)
98
# Required tools with some special treatment
99
UTIL_REQUIRE_SPECIAL(FGREP, [AC_PROG_FGREP])
101
# Optional tools, we can do without them
102
UTIL_LOOKUP_PROGS(DF, df)
103
UTIL_LOOKUP_PROGS(GIT, git)
104
UTIL_LOOKUP_PROGS(NICE, nice)
105
UTIL_LOOKUP_PROGS(READLINK, greadlink readlink)
106
UTIL_LOOKUP_PROGS(WHOAMI, whoami)
108
# Tools only needed on some platforms
109
UTIL_LOOKUP_PROGS(LSB_RELEASE, lsb_release)
111
# For compare.sh only
112
UTIL_LOOKUP_PROGS(CMP, cmp)
113
UTIL_LOOKUP_PROGS(UNIQ, uniq)
119
###############################################################################
120
# Check if we have found a usable version of make
121
# $1: the path to a potential make binary (or empty)
122
# $2: the description on how we found this
123
AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
128
# On Cygwin, we require a newer version of make than on other platforms
129
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
130
MAKE_VERSION_EXPR="-e 4\."
131
MAKE_REQUIRED_VERSION="4.0"
133
MAKE_VERSION_EXPR="-e 3\.8[[12]] -e 4\."
134
MAKE_REQUIRED_VERSION="3.81"
137
if test "x$MAKE_CANDIDATE" != x; then
138
AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
139
MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
140
IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
141
if test "x$IS_GNU_MAKE" = x; then
142
AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.])
144
IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP $MAKE_VERSION_EXPR`
145
if test "x$IS_MODERN_MAKE" = x; then
146
AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version $MAKE_REQUIRED_VERSION or later. (it is: $MAKE_VERSION_STRING). Ignoring.])
148
if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
149
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
150
MAKE_EXPECTED_ENV='cygwin'
151
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys2"; then
152
MAKE_EXPECTED_ENV='msys'
153
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl1" || test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl2"; then
154
if test "x$OPENJDK_BUILD_CPU" = "xaarch64"; then
155
MAKE_EXPECTED_ENV='aarch64-.*-linux-gnu'
157
MAKE_EXPECTED_ENV='x86_64-.*-linux-gnu'
160
AC_MSG_ERROR([Unknown Windows environment])
162
MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'`
163
IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV`
165
# Not relevant for non-Windows
166
IS_MAKE_CORRECT_ENV=true
168
if test "x$IS_MAKE_CORRECT_ENV" = x; then
169
AC_MSG_NOTICE([Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring.])
171
FOUND_MAKE=$MAKE_CANDIDATE
172
UTIL_FIXUP_EXECUTABLE(FOUND_MAKE)
179
###############################################################################
180
AC_DEFUN([BASIC_CHECK_MAKE_OUTPUT_SYNC],
182
# Check if make supports the output sync option and if so, setup using it.
183
UTIL_ARG_WITH(NAME: output-sync, TYPE: literal,
184
VALID_VALUES: [none recurse line target], DEFAULT: none,
185
OPTIONAL: true, ENABLED_DEFAULT: true,
186
ENABLED_RESULT: OUTPUT_SYNC_SUPPORTED,
187
CHECKING_MSG: [for make --output-sync value],
188
DESC: [set make --output-sync type if supported by make],
191
AC_MSG_CHECKING([if make --output-sync is supported])
192
if ! $MAKE --version -O > /dev/null 2>&1; then
200
AC_SUBST(OUTPUT_SYNC_SUPPORTED)
201
AC_SUBST(OUTPUT_SYNC)
204
###############################################################################
205
# Goes looking for a usable version of GNU make.
206
AC_DEFUN([BASIC_CHECK_GNU_MAKE],
208
UTIL_SETUP_TOOL(MAKE,
210
# Try our hardest to locate a correct version of GNU make
211
UTIL_LOOKUP_PROGS(CHECK_GMAKE, gmake)
212
BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH])
214
if test "x$FOUND_MAKE" = x; then
215
UTIL_LOOKUP_PROGS(CHECK_MAKE, make)
216
BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH])
219
if test "x$FOUND_MAKE" = x; then
220
if test "x$TOOLCHAIN_PATH" != x; then
221
# We have a toolchain path, check that as well before giving up.
223
PATH=$TOOLCHAIN_PATH:$PATH
224
UTIL_LOOKUP_PROGS(CHECK_TOOLSDIR_GMAKE, gmake)
225
BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir])
226
if test "x$FOUND_MAKE" = x; then
227
UTIL_LOOKUP_PROGS(CHECK_TOOLSDIR_MAKE, make)
228
BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir])
234
if test "x$FOUND_MAKE" = x; then
235
AC_MSG_ERROR([Cannot find GNU make $MAKE_REQUIRED_VERSION or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure.])
238
# If MAKE was set by user, verify the version
239
BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE])
240
if test "x$FOUND_MAKE" = x; then
241
AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make $MAKE_REQUIRED_VERSION or newer.])
247
AC_MSG_NOTICE([Using GNU make at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
249
BASIC_CHECK_MAKE_OUTPUT_SYNC
252
###############################################################################
253
AC_DEFUN([BASIC_CHECK_FIND_DELETE],
255
# Test if find supports -delete
256
AC_MSG_CHECKING([if find supports -delete])
257
FIND_DELETE="-delete"
259
DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
261
echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
263
TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
264
if test -f $DELETEDIR/TestIfFindSupportsDelete; then
266
$RM $DELETEDIR/TestIfFindSupportsDelete
267
if test "x$OPENJDK_TARGET_OS" = "xaix"; then
268
# AIX 'find' is buggy if called with '-exec {} \+' and an empty file list
269
FIND_DELETE="-print | $XARGS $RM"
271
FIND_DELETE="-exec $RM \{\} \+"
278
AC_SUBST(FIND_DELETE)
281
###############################################################################
282
AC_DEFUN([BASIC_CHECK_TAR],
284
# Test which kind of tar was found
285
if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
287
elif test "x$($TAR --version | $GREP "bsdtar")" != "x"; then
289
elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
291
elif test "x$($TAR --version | $GREP "busybox")" != "x"; then
293
elif test "x$OPENJDK_BUILD_OS" = "xaix"; then
296
AC_MSG_CHECKING([what type of tar was found])
297
AC_MSG_RESULT([$TAR_TYPE])
299
if test "x$TAR_TYPE" = "xgnu"; then
300
TAR_INCLUDE_PARAM="T"
301
TAR_SUPPORTS_TRANSFORM="true"
302
elif test "x$TAR_TYPE" = "xaix"; then
303
# -L InputList of aix tar: name of file listing the files and directories
304
# that need to be archived or extracted
305
TAR_INCLUDE_PARAM="L"
306
TAR_SUPPORTS_TRANSFORM="false"
307
elif test "x$TAR_TYPE" = "xbusybox"; then
308
TAR_INCLUDE_PARAM="T"
309
TAR_SUPPORTS_TRANSFORM="false"
311
TAR_INCLUDE_PARAM="I"
312
TAR_SUPPORTS_TRANSFORM="false"
315
AC_SUBST(TAR_INCLUDE_PARAM)
316
AC_SUBST(TAR_SUPPORTS_TRANSFORM)
319
###############################################################################
320
AC_DEFUN([BASIC_CHECK_GREP],
322
# Test that grep supports -Fx with a list of pattern which includes null pattern.
323
# This is a problem for the grep resident on AIX.
324
AC_MSG_CHECKING([that grep ($GREP) -Fx handles empty lines in the pattern list correctly])
325
# Multiple subsequent spaces..
326
STACK_SPACES='aaa bbb ccc'
327
# ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty
329
STACK_LIST=${STACK_SPACES// /$'\n'}
330
NEEDLE_SPACES='ccc bbb aaa'
331
NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'}
332
RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")"
333
if test "x$RESULT" == "x"; then
336
if test "x$OPENJDK_TARGET_OS" = "xaix"; then
337
ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin."
339
AC_MSG_ERROR([grep does not handle -Fx correctly. ${ADDINFO}])
343
###############################################################################
344
AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
348
BASIC_CHECK_FIND_DELETE
353
# These tools might not be installed by default,
354
# need hint on how to install them.
355
UTIL_REQUIRE_PROGS(UNZIP, unzip)
356
# Since zip uses "ZIP" as a environment variable for passing options, we need
357
# to name our variable differently, hence ZIPEXE.
358
UTIL_REQUIRE_PROGS(ZIPEXE, zip)
360
# Non-required basic tools
362
UTIL_LOOKUP_PROGS(READELF, greadelf readelf)
363
UTIL_LOOKUP_PROGS(DOT, dot)
364
UTIL_LOOKUP_PROGS(STAT, stat)
365
UTIL_LOOKUP_PROGS(TIME, time)
366
UTIL_LOOKUP_PROGS(FLOCK, flock)
367
# Dtrace is usually found in /usr/sbin, but that directory may not
368
# be in the user path.
369
UTIL_LOOKUP_PROGS(DTRACE, dtrace, $PATH:/usr/sbin)
370
UTIL_LOOKUP_PROGS(PATCH, gpatch patch)
371
# Check if it's GNU time
372
[ IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU [Tt]ime'` ]
373
if test "x$IS_GNU_TIME" != x; then
378
AC_SUBST(IS_GNU_TIME)
380
# Check if it's a GNU date compatible version
381
AC_MSG_CHECKING([if date is a GNU compatible version])
382
check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox"`
383
if test "x$check_date" != x; then
390
AC_SUBST(IS_GNU_DATE)
392
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
393
UTIL_REQUIRE_PROGS(DSYMUTIL, dsymutil)
394
AC_MSG_CHECKING([if dsymutil supports --reproducer option])
395
if $DSYMUTIL --help | $GREP -q '\--reproducer '; then
397
# --reproducer option is supported
398
# set "--reproducer Off" to prevent unnecessary temporary
399
# directories creation
400
DSYMUTIL="$DSYMUTIL --reproducer Off"
402
# --reproducer option isn't supported
405
UTIL_REQUIRE_PROGS(MIG, mig)
406
UTIL_REQUIRE_PROGS(XATTR, xattr)
407
UTIL_LOOKUP_PROGS(CODESIGN, codesign)
408
UTIL_REQUIRE_PROGS(SETFILE, SetFile)
410
if ! test "x$OPENJDK_TARGET_OS" = "xwindows"; then
411
UTIL_REQUIRE_PROGS(ULIMIT, ulimit)
415
###############################################################################
416
# Check for support for specific options in bash
417
AC_DEFUN_ONCE([BASIC_CHECK_BASH_OPTIONS],
420
# Extra [ ] to stop m4 mangling
421
[ BASH_VER=`$BASH --version | $SED -n -e 's/^.*bash.*ersion *\([0-9.]*\).*$/\1/ p'` ]
422
AC_MSG_CHECKING([bash version])
423
AC_MSG_RESULT([$BASH_VER])
425
BASH_MAJOR=`$ECHO $BASH_VER | $CUT -d . -f 1`
426
BASH_MINOR=`$ECHO $BASH_VER | $CUT -d . -f 2`
427
if test $BASH_MAJOR -lt 3 || (test $BASH_MAJOR -eq 3 && test $BASH_MINOR -lt 2); then
428
AC_MSG_ERROR([bash version 3.2 or better is required])
431
# Test if bash supports pipefail.
432
AC_MSG_CHECKING([if bash supports pipefail])
433
if ${BASH} -c 'set -o pipefail'; then
434
BASH_ARGS="$BASH_ARGS -o pipefail"
440
AC_MSG_CHECKING([if bash supports errexit (-e)])
441
if ${BASH} -e -c 'true'; then
442
BASH_ARGS="$BASH_ARGS -e"
451
################################################################################
455
AC_DEFUN_ONCE([BASIC_SETUP_PANDOC],
457
UTIL_LOOKUP_PROGS(PANDOC, pandoc)
459
if test "x$PANDOC" != x; then
460
AC_MSG_CHECKING([for pandoc version])
461
PANDOC_VERSION=`$PANDOC --version 2>&1 | $TR -d '\r' | $HEAD -1 | $CUT -d " " -f 2`
462
AC_MSG_RESULT([$PANDOC_VERSION])
464
if test "x$PANDOC_VERSION" != x$RECOMMENDED_PANDOC_VERSION; then
465
AC_MSG_WARN([pandoc is version $PANDOC_VERSION, not the recommended version $RECOMMENDED_PANDOC_VERSION])
468
PANDOC_MARKDOWN_FLAG="markdown"
469
AC_MSG_CHECKING([if the pandoc smart extension needs to be disabled for markdown])
470
if $PANDOC --list-extensions | $GREP -q '+smart'; then
472
PANDOC_MARKDOWN_FLAG="markdown-smart"
479
ENABLE_PANDOC="false"
482
AC_SUBST(ENABLE_PANDOC)
483
AC_SUBST(PANDOC_MARKDOWN_FLAG)