1 #
  2 # Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
  3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4 #
  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.
 10 #
 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).
 16 #
 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.
 20 #
 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
 23 # questions.
 24 #
 25 
 26 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
 27 # Converts autoconf style CPU name to OpenJDK style, into
 28 # VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
 29 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
 30 [
 31   # First argument is the cpu name from the trip/quad
 32   case "$1" in
 33     x86_64*x32)
 34       VAR_CPU=x32
 35       VAR_CPU_ARCH=x86
 36       VAR_CPU_BITS=32
 37       VAR_CPU_ENDIAN=little
 38       ;;
 39     x86_64)
 40       VAR_CPU=x86_64
 41       VAR_CPU_ARCH=x86
 42       VAR_CPU_BITS=64
 43       VAR_CPU_ENDIAN=little
 44       ;;
 45     i?86)
 46       VAR_CPU=x86
 47       VAR_CPU_ARCH=x86
 48       VAR_CPU_BITS=32
 49       VAR_CPU_ENDIAN=little
 50       ;;
 51     alpha*)
 52       VAR_CPU=alpha
 53       VAR_CPU_ARCH=alpha
 54       VAR_CPU_BITS=64
 55       VAR_CPU_ENDIAN=little
 56       ;;
 57     arm*)
 58       VAR_CPU=arm
 59       VAR_CPU_ARCH=arm
 60       VAR_CPU_BITS=32
 61       VAR_CPU_ENDIAN=little
 62       ;;
 63     aarch64)
 64       VAR_CPU=aarch64
 65       VAR_CPU_ARCH=aarch64
 66       VAR_CPU_BITS=64
 67       VAR_CPU_ENDIAN=little
 68       ;;
 69     ia64)
 70       VAR_CPU=ia64
 71       VAR_CPU_ARCH=ia64
 72       VAR_CPU_BITS=64
 73       VAR_CPU_ENDIAN=little
 74       ;;
 75     loongarch64)
 76       VAR_CPU=loongarch64
 77       VAR_CPU_ARCH=loongarch
 78       VAR_CPU_BITS=64
 79       VAR_CPU_ENDIAN=little
 80       ;;
 81     m68k)
 82       VAR_CPU=m68k
 83       VAR_CPU_ARCH=m68k
 84       VAR_CPU_BITS=32
 85       VAR_CPU_ENDIAN=big
 86       ;;
 87     mips)
 88       VAR_CPU=mips
 89       VAR_CPU_ARCH=mips
 90       VAR_CPU_BITS=32
 91       VAR_CPU_ENDIAN=big
 92       ;;
 93     mipsel)
 94       VAR_CPU=mipsel
 95       VAR_CPU_ARCH=mipsel
 96       VAR_CPU_BITS=32
 97       VAR_CPU_ENDIAN=little
 98       ;;
 99     mips64)
100       VAR_CPU=mips64
101       VAR_CPU_ARCH=mips64
102       VAR_CPU_BITS=64
103       VAR_CPU_ENDIAN=big
104       ;;
105     mips64el)
106       VAR_CPU=mips64el
107       VAR_CPU_ARCH=mips64el
108       VAR_CPU_BITS=64
109       VAR_CPU_ENDIAN=little
110       ;;
111     powerpc)
112       VAR_CPU=ppc
113       VAR_CPU_ARCH=ppc
114       VAR_CPU_BITS=32
115       VAR_CPU_ENDIAN=big
116       ;;
117     powerpc64)
118       VAR_CPU=ppc64
119       VAR_CPU_ARCH=ppc
120       VAR_CPU_BITS=64
121       VAR_CPU_ENDIAN=big
122       ;;
123     powerpc64le)
124       VAR_CPU=ppc64le
125       VAR_CPU_ARCH=ppc
126       VAR_CPU_BITS=64
127       VAR_CPU_ENDIAN=little
128       ;;
129     riscv64)
130       VAR_CPU=riscv64
131       VAR_CPU_ARCH=riscv
132       VAR_CPU_BITS=64
133       VAR_CPU_ENDIAN=little
134       ;;
135     s390)
136       VAR_CPU=s390
137       VAR_CPU_ARCH=s390
138       VAR_CPU_BITS=32
139       VAR_CPU_ENDIAN=big
140       ;;
141     s390x)
142       VAR_CPU=s390x
143       VAR_CPU_ARCH=s390
144       VAR_CPU_BITS=64
145       VAR_CPU_ENDIAN=big
146       ;;
147     sh*eb)
148       VAR_CPU=sh
149       VAR_CPU_ARCH=sh
150       VAR_CPU_BITS=32
151       VAR_CPU_ENDIAN=big
152       ;;
153     sh*)
154       VAR_CPU=sh
155       VAR_CPU_ARCH=sh
156       VAR_CPU_BITS=32
157       VAR_CPU_ENDIAN=little
158       ;;
159     sparc)
160       VAR_CPU=sparc
161       VAR_CPU_ARCH=sparc
162       VAR_CPU_BITS=32
163       VAR_CPU_ENDIAN=big
164       ;;
165     sparcv9|sparc64)
166       VAR_CPU=sparcv9
167       VAR_CPU_ARCH=sparc
168       VAR_CPU_BITS=64
169       VAR_CPU_ENDIAN=big
170       ;;
171     sparc)
172       VAR_CPU=sparc
173       VAR_CPU_ARCH=sparc
174       VAR_CPU_BITS=32
175       VAR_CPU_ENDIAN=big
176       ;;
177     sparcv9|sparc64)
178       VAR_CPU=sparcv9
179       VAR_CPU_ARCH=sparc
180       VAR_CPU_BITS=64
181       VAR_CPU_ENDIAN=big
182       ;;
183     *)
184       AC_MSG_ERROR([unsupported cpu $1])
185       ;;
186   esac
187 ])
188 
189 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
190 # Converts autoconf style OS name to OpenJDK style, into
191 # VAR_OS, VAR_OS_TYPE and VAR_OS_ENV.
192 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
193 [
194   case "$1" in
195     *linux*)
196       VAR_OS=linux
197       VAR_OS_TYPE=unix
198       ;;
199     *darwin*)
200       VAR_OS=macosx
201       VAR_OS_TYPE=unix
202       ;;
203     *bsd*)
204       VAR_OS=bsd
205       VAR_OS_TYPE=unix
206       ;;
207     *cygwin*)
208       VAR_OS=windows
209       VAR_OS_ENV=windows.cygwin
210       ;;
211     *wsl*)
212       VAR_OS=windows
213       VAR_OS_ENV=windows.wsl
214       ;;
215     *msys*)
216       VAR_OS=windows
217       VAR_OS_ENV=windows.msys2
218       ;;
219     *aix*)
220       VAR_OS=aix
221       VAR_OS_TYPE=unix
222       ;;
223     *)
224       AC_MSG_ERROR([unsupported operating system $1])
225       ;;
226   esac
227 ])
228 
229 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
230 # Converts autoconf style OS name to OpenJDK style, into
231 # VAR_LIBC.
232 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_LIBC],
233 [
234   case "$1" in
235     *linux*-musl)
236       VAR_LIBC=musl
237       ;;
238     *linux*-gnu)
239       VAR_LIBC=gnu
240       ;;
241     *)
242       VAR_LIBC=default
243       ;;
244   esac
245 ])
246 
247 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
248 # Converts autoconf style OS name to OpenJDK style, into
249 # VAR_ABI.
250 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_ABI],
251 [
252   case "$1" in
253     *linux*-musl)
254       VAR_ABI=musl
255       ;;
256     *linux*-gnu)
257       VAR_ABI=gnu
258       ;;
259     *linux*-gnueabi)
260       VAR_ABI=gnueabi
261       ;;
262     *linux*-gnueabihf)
263       VAR_ABI=gnueabihf
264       ;;
265     *linux*-gnuabi64)
266       VAR_ABI=gnuabi64
267       ;;
268     *)
269       VAR_ABI=default
270       ;;
271   esac
272 ])
273 
274 # Expects $host_os $host_cpu $build_os and $build_cpu
275 # and $with_target_bits to have been setup!
276 #
277 # Translate the standard triplet(quadruplet) definition
278 # of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
279 # OPENJDK_BUILD_OS, etc.
280 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
281 [
282   # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
283   # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
284   # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
285   # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
286   OPENJDK_TARGET_AUTOCONF_NAME="$host"
287   OPENJDK_BUILD_AUTOCONF_NAME="$build"
288   AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
289   AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
290 
291   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables.
292   PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
293   PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
294   PLATFORM_EXTRACT_VARS_FROM_LIBC($build_os)
295   PLATFORM_EXTRACT_VARS_FROM_ABI($build_os)
296   # ..and setup our own variables. (Do this explicitly to facilitate searching)
297   OPENJDK_BUILD_OS="$VAR_OS"
298   if test "x$VAR_OS_TYPE" != x; then
299     OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE"
300   else
301     OPENJDK_BUILD_OS_TYPE="$VAR_OS"
302   fi
303   if test "x$VAR_OS_ENV" != x; then
304     OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
305   else
306     OPENJDK_BUILD_OS_ENV="$VAR_OS"
307   fi
308   OPENJDK_BUILD_CPU="$VAR_CPU"
309   OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
310   OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
311   OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
312   OPENJDK_BUILD_CPU_AUTOCONF="$build_cpu"
313   OPENJDK_BUILD_LIBC="$VAR_LIBC"
314   OPENJDK_BUILD_ABI="$VAR_ABI"
315   AC_SUBST(OPENJDK_BUILD_OS)
316   AC_SUBST(OPENJDK_BUILD_OS_TYPE)
317   AC_SUBST(OPENJDK_BUILD_OS_ENV)
318   AC_SUBST(OPENJDK_BUILD_CPU)
319   AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
320   AC_SUBST(OPENJDK_BUILD_CPU_BITS)
321   AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
322   AC_SUBST(OPENJDK_BUILD_CPU_AUTOCONF)
323   AC_SUBST(OPENJDK_BUILD_LIBC)
324   AC_SUBST(OPENJDK_BUILD_ABI)
325 
326   AC_MSG_CHECKING([openjdk-build os-cpu])
327   AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
328 
329   if test "x$OPENJDK_BUILD_OS" = "xlinux"; then
330     AC_MSG_CHECKING([openjdk-build C library])
331     AC_MSG_RESULT([$OPENJDK_BUILD_LIBC])
332   fi
333 
334   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables.
335   PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
336   PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
337   PLATFORM_EXTRACT_VARS_FROM_LIBC($host_os)
338   PLATFORM_EXTRACT_VARS_FROM_ABI($host_os)
339   # ... and setup our own variables. (Do this explicitly to facilitate searching)
340   OPENJDK_TARGET_OS="$VAR_OS"
341   if test "x$VAR_OS_TYPE" != x; then
342     OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE"
343   else
344     OPENJDK_TARGET_OS_TYPE="$VAR_OS"
345   fi
346   if test "x$VAR_OS_ENV" != x; then
347     OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
348   else
349     OPENJDK_TARGET_OS_ENV="$VAR_OS"
350   fi
351   OPENJDK_TARGET_CPU="$VAR_CPU"
352   OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
353   OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
354   OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
355   OPENJDK_TARGET_CPU_AUTOCONF="$host_cpu"
356   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
357   OPENJDK_TARGET_LIBC="$VAR_LIBC"
358   OPENJDK_TARGET_ABI="$VAR_ABI"
359 
360   AC_SUBST(OPENJDK_TARGET_OS)
361   AC_SUBST(OPENJDK_TARGET_OS_TYPE)
362   AC_SUBST(OPENJDK_TARGET_OS_ENV)
363   AC_SUBST(OPENJDK_TARGET_OS_UPPERCASE)
364   AC_SUBST(OPENJDK_TARGET_CPU)
365   AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
366   AC_SUBST(OPENJDK_TARGET_CPU_BITS)
367   AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
368   AC_SUBST(OPENJDK_TARGET_CPU_AUTOCONF)
369   AC_SUBST(OPENJDK_TARGET_LIBC)
370   AC_SUBST(OPENJDK_TARGET_ABI)
371 
372   AC_MSG_CHECKING([openjdk-target os-cpu])
373   AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
374 
375   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
376     AC_MSG_CHECKING([openjdk-target C library])
377     AC_MSG_RESULT([$OPENJDK_TARGET_LIBC])
378   fi
379 ])
380 
381 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
382 # accordingly. Must be done after setting up build and target system, but before
383 # doing anything else with these values.
384 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
385 [
386   AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
387        [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
388 
389   # We have three types of compiles:
390   # native  == normal compilation, target system == build system
391   # cross   == traditional cross compilation, target system != build system; special toolchain needed
392   # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
393   #
394   if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
395     # We're doing a proper cross-compilation
396     COMPILE_TYPE="cross"
397   else
398     COMPILE_TYPE="native"
399   fi
400 
401   if test "x$with_target_bits" != x; then
402     if test "x$COMPILE_TYPE" = "xcross"; then
403       AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
404     fi
405 
406     if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
407       # A reduced build is requested
408       COMPILE_TYPE="reduced"
409       OPENJDK_TARGET_CPU_BITS=32
410       if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
411         OPENJDK_TARGET_CPU=x86
412       elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
413         OPENJDK_TARGET_CPU=sparc
414       else
415         AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
416       fi
417     elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
418       AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
419     elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
420       AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
421     else
422       AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
423     fi
424   fi
425   AC_SUBST(COMPILE_TYPE)
426 
427   AC_MSG_CHECKING([compilation type])
428   AC_MSG_RESULT([$COMPILE_TYPE])
429 ])
430 
431 # Setup the legacy variables, for controlling the old makefiles.
432 #
433 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
434 [
435   PLATFORM_SETUP_LEGACY_VARS_HELPER([TARGET])
436   PLATFORM_SETUP_LEGACY_VARS_HELPER([BUILD])
437 ])
438 
439 # $1 - Either TARGET or BUILD to setup the variables for.
440 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
441 [
442   # Also store the legacy naming of the cpu.
443   # Ie i586 and amd64 instead of x86 and x86_64
444   OPENJDK_$1_CPU_LEGACY="$OPENJDK_$1_CPU"
445   if test "x$OPENJDK_$1_CPU" = xx86; then
446     OPENJDK_$1_CPU_LEGACY="i586"
447   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
448     # On all platforms except MacOSX replace x86_64 with amd64.
449     OPENJDK_$1_CPU_LEGACY="amd64"
450   elif test "x$OPENJDK_$1_CPU" = xalpha; then
451     # Avoid name collisions with variables named alpha
452     OPENJDK_$1_CPU_LEGACY="_alpha_"
453   elif test "x$OPENJDK_$1_CPU" = xsh; then
454     # Avoid name collisions with variables named sh
455     OPENJDK_$1_CPU_LEGACY="_sh_"
456   fi
457   AC_SUBST(OPENJDK_$1_CPU_LEGACY)
458 
459   # And the second legacy naming of the cpu.
460   # Ie i386 and amd64 instead of x86 and x86_64.
461   OPENJDK_$1_CPU_LEGACY_LIB="$OPENJDK_$1_CPU"
462   if test "x$OPENJDK_$1_CPU" = xx86; then
463     OPENJDK_$1_CPU_LEGACY_LIB="i386"
464   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
465     OPENJDK_$1_CPU_LEGACY_LIB="amd64"
466   fi
467   AC_SUBST(OPENJDK_$1_CPU_LEGACY_LIB)
468 
469   # Setup OPENJDK_$1_CPU_OSARCH, which is used to set the os.arch Java system property
470   OPENJDK_$1_CPU_OSARCH="$OPENJDK_$1_CPU"
471   if test "x$OPENJDK_$1_OS" = xlinux && test "x$OPENJDK_$1_CPU" = xx86; then
472     # On linux only, we replace x86 with i386.
473     OPENJDK_$1_CPU_OSARCH="i386"
474   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
475     # On all platforms except macosx, we replace x86_64 with amd64.
476     OPENJDK_$1_CPU_OSARCH="amd64"
477   fi
478   AC_SUBST(OPENJDK_$1_CPU_OSARCH)
479 
480   OPENJDK_$1_CPU_JLI="$OPENJDK_$1_CPU"
481   if test "x$OPENJDK_$1_CPU" = xx86; then
482     OPENJDK_$1_CPU_JLI="i386"
483   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
484     # On all platforms except macosx, we replace x86_64 with amd64.
485     OPENJDK_$1_CPU_JLI="amd64"
486   fi
487 
488   # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
489   # The macOS bundle name was revised in JDK 17
490   #
491   # macosx is macos and x86_64 is x64
492   if test "x$OPENJDK_$1_OS" = xmacosx; then
493     OPENJDK_$1_OS_BUNDLE="macos"
494   else
495     OPENJDK_$1_OS_BUNDLE="$OPENJDK_TARGET_OS"
496   fi
497   if test "x$OPENJDK_$1_CPU" = xx86_64; then
498     OPENJDK_$1_CPU_BUNDLE="x64"
499   else
500     OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU"
501   fi
502 
503   OPENJDK_$1_LIBC_BUNDLE=""
504   if test "x$OPENJDK_$1_LIBC" = "xmusl"; then
505     OPENJDK_$1_LIBC_BUNDLE="-$OPENJDK_$1_LIBC"
506   fi
507 
508   OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}${OPENJDK_$1_LIBC_BUNDLE}"
509   AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
510 
511   if test "x$COMPILE_TYPE" = "xcross"; then
512     # FIXME: ... or should this include reduced builds..?
513     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_$1_CPU_LEGACY"
514   else
515     DEFINE_CROSS_COMPILE_ARCH=""
516   fi
517   AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
518 
519   # Convert openjdk platform names to hotspot names
520 
521   HOTSPOT_$1_OS=${OPENJDK_$1_OS}
522   if test "x$OPENJDK_$1_OS" = xmacosx; then
523     HOTSPOT_$1_OS=bsd
524   fi
525   AC_SUBST(HOTSPOT_$1_OS)
526 
527   HOTSPOT_$1_OS_TYPE=${OPENJDK_$1_OS_TYPE}
528   if test "x$OPENJDK_$1_OS_TYPE" = xunix; then
529     HOTSPOT_$1_OS_TYPE=posix
530   fi
531   AC_SUBST(HOTSPOT_$1_OS_TYPE)
532 
533   HOTSPOT_$1_CPU=${OPENJDK_$1_CPU}
534   if test "x$OPENJDK_$1_CPU" = xx86; then
535     HOTSPOT_$1_CPU=x86_32
536   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
537     HOTSPOT_$1_CPU=sparc
538   elif test "x$OPENJDK_$1_CPU" = xppc64; then
539     HOTSPOT_$1_CPU=ppc_64
540   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
541     HOTSPOT_$1_CPU=ppc_64
542   fi
543   AC_SUBST(HOTSPOT_$1_CPU)
544 
545   # This is identical with OPENJDK_*, but define anyway for consistency.
546   HOTSPOT_$1_CPU_ARCH=${OPENJDK_$1_CPU_ARCH}
547   AC_SUBST(HOTSPOT_$1_CPU_ARCH)
548 
549   # Setup HOTSPOT_$1_CPU_DEFINE
550   if test "x$OPENJDK_$1_CPU" = xx86; then
551     HOTSPOT_$1_CPU_DEFINE=IA32
552   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
553     HOTSPOT_$1_CPU_DEFINE=AMD64
554   elif test "x$OPENJDK_$1_CPU" = xx32; then
555     HOTSPOT_$1_CPU_DEFINE=X32
556   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
557     HOTSPOT_$1_CPU_DEFINE=SPARC
558   elif test "x$OPENJDK_$1_CPU" = xaarch64; then
559     HOTSPOT_$1_CPU_DEFINE=AARCH64
560   elif test "x$OPENJDK_$1_CPU" = xppc64; then
561     HOTSPOT_$1_CPU_DEFINE=PPC64
562   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
563     HOTSPOT_$1_CPU_DEFINE=PPC64
564 
565   # The cpu defines below are for zero, we don't support them directly.
566   elif test "x$OPENJDK_$1_CPU" = xsparc; then
567     HOTSPOT_$1_CPU_DEFINE=SPARC
568   elif test "x$OPENJDK_$1_CPU" = xppc; then
569     HOTSPOT_$1_CPU_DEFINE=PPC32
570   elif test "x$OPENJDK_$1_CPU" = xs390; then
571     HOTSPOT_$1_CPU_DEFINE=S390
572   elif test "x$OPENJDK_$1_CPU" = xs390x; then
573     HOTSPOT_$1_CPU_DEFINE=S390
574   elif test "x$OPENJDK_$1_CPU" = xriscv64; then
575     HOTSPOT_$1_CPU_DEFINE=RISCV
576   elif test "x$OPENJDK_$1_CPU" != x; then
577     HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z)
578   fi
579   AC_SUBST(HOTSPOT_$1_CPU_DEFINE)
580 
581   HOTSPOT_$1_LIBC=$OPENJDK_$1_LIBC
582   AC_SUBST(HOTSPOT_$1_LIBC)
583 
584   # For historical reasons, the OS include directories have odd names.
585   OPENJDK_$1_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS"
586   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
587     OPENJDK_$1_OS_INCLUDE_SUBDIR="win32"
588   elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
589     OPENJDK_$1_OS_INCLUDE_SUBDIR="darwin"
590   fi
591   AC_SUBST(OPENJDK_$1_OS_INCLUDE_SUBDIR)
592 ])
593 
594 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
595 [
596   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
597     RELEASE_FILE_OS_NAME=Linux
598   fi
599   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
600     RELEASE_FILE_OS_NAME=Windows
601   fi
602   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
603     RELEASE_FILE_OS_NAME="Darwin"
604   fi
605   if test "x$OPENJDK_TARGET_OS" = "xaix"; then
606     RELEASE_FILE_OS_NAME="AIX"
607   fi
608   RELEASE_FILE_OS_ARCH=${OPENJDK_TARGET_CPU}
609   RELEASE_FILE_LIBC=${OPENJDK_TARGET_LIBC}
610 
611   AC_SUBST(RELEASE_FILE_OS_NAME)
612   AC_SUBST(RELEASE_FILE_OS_ARCH)
613   AC_SUBST(RELEASE_FILE_LIBC)
614 ])
615 
616 AC_DEFUN([PLATFORM_SET_MODULE_TARGET_OS_VALUES],
617 [
618   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
619     OPENJDK_MODULE_TARGET_OS_NAME="macos"
620   else
621     OPENJDK_MODULE_TARGET_OS_NAME="$OPENJDK_TARGET_OS"
622   fi
623 
624   if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
625     OPENJDK_MODULE_TARGET_OS_ARCH="amd64"
626   else
627     OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU"
628   fi
629 
630   OPENJDK_MODULE_TARGET_PLATFORM="${OPENJDK_MODULE_TARGET_OS_NAME}-${OPENJDK_MODULE_TARGET_OS_ARCH}"
631   AC_SUBST(OPENJDK_MODULE_TARGET_PLATFORM)
632 ])
633 
634 #%%% Build and target systems %%%
635 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
636 [
637   # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
638   # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
639   # product you're building. The target of this build is called "host". Since this is confusing to most people, we
640   # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
641   # to use the configure naming style.
642   AC_CANONICAL_BUILD
643   AC_CANONICAL_HOST
644   AC_CANONICAL_TARGET
645 
646   PLATFORM_EXTRACT_TARGET_AND_BUILD
647   PLATFORM_SETUP_TARGET_CPU_BITS
648   PLATFORM_SET_MODULE_TARGET_OS_VALUES
649   PLATFORM_SET_RELEASE_FILE_OS_VALUES
650   PLATFORM_SETUP_LEGACY_VARS
651 
652   # Deprecated in JDK 15
653   UTIL_DEPRECATED_ARG_ENABLE(deprecated-ports)
654 ])
655 
656 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
657 [
658   ###############################################################################
659 
660   # Note that this is the build platform OS version!
661 
662   OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
663   OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
664   OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
665   OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
666   AC_SUBST(OS_VERSION_MAJOR)
667   AC_SUBST(OS_VERSION_MINOR)
668   AC_SUBST(OS_VERSION_MICRO)
669 ])
670 
671 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
672 [
673   ###############################################################################
674   #
675   # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
676   # (The JVM can use 32 or 64 bit Java pointers but that decision
677   # is made at runtime.)
678   #
679 
680   # Make compilation sanity check
681   AC_CHECK_HEADERS([stdio.h], , [
682     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
683     if test "x$COMPILE_TYPE" = xreduced; then
684       HELP_MSG_MISSING_DEPENDENCY([reduced])
685       AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
686     elif test "x$COMPILE_TYPE" = xcross; then
687       AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
688     fi
689     AC_MSG_ERROR([Cannot continue.])
690   ])
691 
692   AC_CHECK_SIZEOF([int *], [1111])
693 
694   # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
695   if test "x$ac_cv_sizeof_int_p" = x; then
696     # The test failed, lets stick to the assumed value.
697     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
698   else
699     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
700 
701     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
702       AC_MSG_NOTICE([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
703       if test "x$COMPILE_TYPE" = xreduced; then
704         HELP_MSG_MISSING_DEPENDENCY([reduced])
705         AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
706       elif test "x$COMPILE_TYPE" = xcross; then
707         AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
708       fi
709       AC_MSG_ERROR([Cannot continue.])
710     fi
711   fi
712 
713   AC_MSG_CHECKING([for target address size])
714   AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
715 ])
716 
717 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
718 [
719   ###############################################################################
720   #
721   # Is the target little of big endian?
722   #
723   AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
724 
725   if test "x$ENDIAN" = xuniversal_endianness; then
726     AC_MSG_ERROR([Building with both big and little endianness is not supported])
727   fi
728   if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
729     AC_MSG_ERROR([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
730   fi
731 ])