1 #
   2 # Copyright (c) 2011, 2017, 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)
  34       VAR_CPU=x86_64
  35       VAR_CPU_ARCH=x86
  36       VAR_CPU_BITS=64
  37       VAR_CPU_ENDIAN=little
  38       ;;
  39     i?86)
  40       VAR_CPU=x86
  41       VAR_CPU_ARCH=x86
  42       VAR_CPU_BITS=32
  43       VAR_CPU_ENDIAN=little
  44       ;;
  45     arm*)
  46       VAR_CPU=arm
  47       VAR_CPU_ARCH=arm
  48       VAR_CPU_BITS=32
  49       VAR_CPU_ENDIAN=little
  50       ;;
  51     aarch64)
  52       VAR_CPU=aarch64
  53       VAR_CPU_ARCH=aarch64
  54       VAR_CPU_BITS=64
  55       VAR_CPU_ENDIAN=little
  56       ;;
  57     powerpc)
  58       VAR_CPU=ppc
  59       VAR_CPU_ARCH=ppc
  60       VAR_CPU_BITS=32
  61       VAR_CPU_ENDIAN=big
  62       ;;
  63     powerpc64)
  64       VAR_CPU=ppc64
  65       VAR_CPU_ARCH=ppc
  66       VAR_CPU_BITS=64
  67       VAR_CPU_ENDIAN=big
  68       ;;
  69     powerpc64le)
  70       VAR_CPU=ppc64le
  71       VAR_CPU_ARCH=ppc
  72       VAR_CPU_BITS=64
  73       VAR_CPU_ENDIAN=little
  74       ;;
  75     s390)
  76       VAR_CPU=s390
  77       VAR_CPU_ARCH=s390
  78       VAR_CPU_BITS=32
  79       VAR_CPU_ENDIAN=big
  80       ;;
  81     s390x)
  82       VAR_CPU=s390x
  83       VAR_CPU_ARCH=s390
  84       VAR_CPU_BITS=64
  85       VAR_CPU_ENDIAN=big
  86       ;;
  87     sparc)
  88       VAR_CPU=sparc
  89       VAR_CPU_ARCH=sparc
  90       VAR_CPU_BITS=32
  91       VAR_CPU_ENDIAN=big
  92       ;;
  93     sparcv9|sparc64)
  94       VAR_CPU=sparcv9
  95       VAR_CPU_ARCH=sparc
  96       VAR_CPU_BITS=64
  97       VAR_CPU_ENDIAN=big
  98       ;;
  99     *)
 100       AC_MSG_ERROR([unsupported cpu $1])
 101       ;;
 102   esac
 103 ])
 104 
 105 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
 106 # Converts autoconf style OS name to OpenJDK style, into
 107 # VAR_OS, VAR_OS_TYPE and VAR_OS_ENV.
 108 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
 109 [
 110   case "$1" in
 111     *linux*)
 112       VAR_OS=linux
 113       VAR_OS_TYPE=unix
 114       ;;
 115     *solaris*)
 116       VAR_OS=solaris
 117       VAR_OS_TYPE=unix
 118       ;;
 119     *darwin*)
 120       VAR_OS=macosx
 121       VAR_OS_TYPE=unix
 122       ;;
 123     *bsd*)
 124       VAR_OS=bsd
 125       VAR_OS_TYPE=unix
 126       ;;
 127     *cygwin*)
 128       VAR_OS=windows
 129       VAR_OS_ENV=windows.cygwin
 130       ;;
 131     *mingw*)
 132       VAR_OS=windows
 133       VAR_OS_ENV=windows.msys
 134       ;;
 135     *aix*)
 136       VAR_OS=aix
 137       VAR_OS_TYPE=unix
 138       ;;
 139     *)
 140       AC_MSG_ERROR([unsupported operating system $1])
 141       ;;
 142   esac
 143 
 144   case "$1" in
 145     *linux*-musl)
 146       VAR_CLIB=musl
 147       ;;
 148     *linux*-gnu)
 149       VAR_CLIB=gnu
 150       ;;
 151     *)
 152       VAR_CLIB=default
 153       ;;
 154   esac
 155 ])
 156 
 157 # Expects $host_os $host_cpu $build_os and $build_cpu
 158 # and $with_target_bits to have been setup!
 159 #
 160 # Translate the standard triplet(quadruplet) definition
 161 # of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
 162 # OPENJDK_BUILD_OS, etc.
 163 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
 164 [
 165   # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
 166   # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
 167   # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
 168   # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
 169   OPENJDK_TARGET_AUTOCONF_NAME="$host"
 170   OPENJDK_BUILD_AUTOCONF_NAME="$build"
 171   AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
 172   AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
 173 
 174   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
 175   PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
 176   PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
 177   # ..and setup our own variables. (Do this explicitly to facilitate searching)
 178   OPENJDK_BUILD_OS="$VAR_OS"
 179   if test "x$VAR_OS_TYPE" != x; then
 180     OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE"
 181   else
 182     OPENJDK_BUILD_OS_TYPE="$VAR_OS"
 183   fi
 184   if test "x$VAR_OS_ENV" != x; then
 185     OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
 186   else
 187     OPENJDK_BUILD_OS_ENV="$VAR_OS"
 188   fi
 189   OPENJDK_BUILD_CPU="$VAR_CPU"
 190   OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
 191   OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
 192   OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
 193   OPENJDK_BUILD_CLIB="$VAR_CLIB"
 194   AC_SUBST(OPENJDK_BUILD_OS)
 195   AC_SUBST(OPENJDK_BUILD_OS_TYPE)
 196   AC_SUBST(OPENJDK_BUILD_OS_ENV)
 197   AC_SUBST(OPENJDK_BUILD_CPU)
 198   AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
 199   AC_SUBST(OPENJDK_BUILD_CPU_BITS)
 200   AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
 201   AC_SUBST(OPENJDK_BUILD_CLIB)
 202 
 203   AC_MSG_CHECKING([openjdk-build os-cpu])
 204   AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
 205 
 206   if test "x$OPENJDK_BUILD_OS" = "xlinux"; then
 207     AC_MSG_CHECKING([openjdk-build C library])
 208     AC_MSG_RESULT([$OPENJDK_BUILD_CLIB])
 209   fi
 210 
 211   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
 212   PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
 213   PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
 214   # ... and setup our own variables. (Do this explicitly to facilitate searching)
 215   OPENJDK_TARGET_OS="$VAR_OS"
 216   if test "x$VAR_OS_TYPE" != x; then
 217     OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE"
 218   else
 219     OPENJDK_TARGET_OS_TYPE="$VAR_OS"
 220   fi
 221   if test "x$VAR_OS_ENV" != x; then
 222     OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
 223   else
 224     OPENJDK_TARGET_OS_ENV="$VAR_OS"
 225   fi
 226   OPENJDK_TARGET_CPU="$VAR_CPU"
 227   OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
 228   OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
 229   OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
 230   OPENJDK_TARGET_CLIB="$VAR_CLIB"
 231   AC_SUBST(OPENJDK_TARGET_OS)
 232   AC_SUBST(OPENJDK_TARGET_OS_TYPE)
 233   AC_SUBST(OPENJDK_TARGET_OS_ENV)
 234   AC_SUBST(OPENJDK_TARGET_CPU)
 235   AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
 236   AC_SUBST(OPENJDK_TARGET_CPU_BITS)
 237   AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
 238   AC_SUBST(OPENJDK_TARGET_CLIB)
 239 
 240   AC_MSG_CHECKING([openjdk-target os-cpu])
 241   AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
 242 
 243   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
 244     AC_MSG_CHECKING([openjdk-target C library])
 245     AC_MSG_RESULT([$OPENJDK_TARGET_CLIB])
 246   fi
 247 ])
 248 
 249 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
 250 # accordingly. Must be done after setting up build and target system, but before
 251 # doing anything else with these values.
 252 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
 253 [
 254   AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
 255        [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
 256 
 257   # We have three types of compiles:
 258   # native  == normal compilation, target system == build system
 259   # cross   == traditional cross compilation, target system != build system; special toolchain needed
 260   # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
 261   #
 262   if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
 263     # We're doing a proper cross-compilation
 264     COMPILE_TYPE="cross"
 265   else
 266     COMPILE_TYPE="native"
 267   fi
 268 
 269   if test "x$with_target_bits" != x; then
 270     if test "x$COMPILE_TYPE" = "xcross"; then
 271       AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
 272     fi
 273 
 274     if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 275       # A reduced build is requested
 276       COMPILE_TYPE="reduced"
 277       OPENJDK_TARGET_CPU_BITS=32
 278       if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 279         OPENJDK_TARGET_CPU=x86
 280       elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 281         OPENJDK_TARGET_CPU=sparc
 282       else
 283         AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
 284       fi
 285     elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 286       AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
 287     elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
 288       AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
 289     else
 290       AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
 291     fi
 292   fi
 293   AC_SUBST(COMPILE_TYPE)
 294 
 295   AC_MSG_CHECKING([compilation type])
 296   AC_MSG_RESULT([$COMPILE_TYPE])
 297 ])
 298 
 299 # Setup the legacy variables, for controlling the old makefiles.
 300 #
 301 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
 302 [
 303   PLATFORM_SETUP_LEGACY_VARS_HELPER([TARGET])
 304   PLATFORM_SETUP_LEGACY_VARS_HELPER([BUILD])
 305 ])
 306 
 307 # $1 - Either TARGET or BUILD to setup the variables for.
 308 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
 309 [
 310   # Also store the legacy naming of the cpu.
 311   # Ie i586 and amd64 instead of x86 and x86_64
 312   OPENJDK_$1_CPU_LEGACY="$OPENJDK_$1_CPU"
 313   if test "x$OPENJDK_$1_CPU" = xx86; then
 314     OPENJDK_$1_CPU_LEGACY="i586"
 315   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
 316     # On all platforms except MacOSX replace x86_64 with amd64.
 317     OPENJDK_$1_CPU_LEGACY="amd64"
 318   fi
 319   AC_SUBST(OPENJDK_$1_CPU_LEGACY)
 320 
 321   # And the second legacy naming of the cpu.
 322   # Ie i386 and amd64 instead of x86 and x86_64.
 323   OPENJDK_$1_CPU_LEGACY_LIB="$OPENJDK_$1_CPU"
 324   if test "x$OPENJDK_$1_CPU" = xx86; then
 325     OPENJDK_$1_CPU_LEGACY_LIB="i386"
 326   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
 327     OPENJDK_$1_CPU_LEGACY_LIB="amd64"
 328   fi
 329   AC_SUBST(OPENJDK_$1_CPU_LEGACY_LIB)
 330 
 331   # OPENJDK_$1_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
 332   # /amd64 or /sparcv9. This string is appended to some library paths, like this:
 333   # /usr/lib${OPENJDK_$1_CPU_ISADIR}/libexample.so
 334   OPENJDK_$1_CPU_ISADIR=""
 335   if test "x$OPENJDK_$1_OS" = xsolaris; then
 336     if test "x$OPENJDK_$1_CPU" = xx86_64; then
 337       OPENJDK_$1_CPU_ISADIR="/amd64"
 338     elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
 339       OPENJDK_$1_CPU_ISADIR="/sparcv9"
 340     fi
 341   fi
 342   AC_SUBST(OPENJDK_$1_CPU_ISADIR)
 343 
 344   # Setup OPENJDK_$1_CPU_OSARCH, which is used to set the os.arch Java system property
 345   OPENJDK_$1_CPU_OSARCH="$OPENJDK_$1_CPU"
 346   if test "x$OPENJDK_$1_OS" = xlinux && test "x$OPENJDK_$1_CPU" = xx86; then
 347     # On linux only, we replace x86 with i386.
 348     OPENJDK_$1_CPU_OSARCH="i386"
 349   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
 350     # On all platforms except macosx, we replace x86_64 with amd64.
 351     OPENJDK_$1_CPU_OSARCH="amd64"
 352   fi
 353   AC_SUBST(OPENJDK_$1_CPU_OSARCH)
 354 
 355   OPENJDK_$1_CPU_JLI="$OPENJDK_$1_CPU"
 356   if test "x$OPENJDK_$1_CPU" = xx86; then
 357     OPENJDK_$1_CPU_JLI="i386"
 358   elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
 359     # On all platforms except macosx, we replace x86_64 with amd64.
 360     OPENJDK_$1_CPU_JLI="amd64"
 361   fi
 362 
 363   if test "x$OPENJDK_$1_OS" = xmacosx; then
 364       OPENJDK_$1_OS_EXPORT_DIR=macosx
 365   else
 366       OPENJDK_$1_OS_EXPORT_DIR=${OPENJDK_$1_OS_TYPE}
 367   fi
 368   AC_SUBST(OPENJDK_$1_OS_EXPORT_DIR)
 369 
 370   # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
 371   # Macosx is osx and x86_64 is x64
 372   if test "x$OPENJDK_$1_OS" = xmacosx; then
 373     OPENJDK_$1_OS_BUNDLE="osx"
 374   else
 375     OPENJDK_$1_OS_BUNDLE="$OPENJDK_TARGET_OS"
 376   fi
 377   if test "x$OPENJDK_$1_CPU" = xx86_64; then
 378     OPENJDK_$1_CPU_BUNDLE="x64"
 379   else
 380     OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU"
 381   fi
 382   OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}"
 383   AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
 384 
 385   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
 386     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
 387     # unpack200.exe. This variable is used in
 388     # FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER.
 389     if test "x$OPENJDK_$1_OS" = xlinux || test "x$OPENJDK_$1_OS" = xmacosx; then
 390       OPENJDK_$1_ADD_LP64="-D_LP64=1"
 391     fi
 392   fi
 393 
 394   if test "x$COMPILE_TYPE" = "xcross"; then
 395     # FIXME: ... or should this include reduced builds..?
 396     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_$1_CPU_LEGACY"
 397   else
 398     DEFINE_CROSS_COMPILE_ARCH=""
 399   fi
 400   AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
 401 
 402   # Convert openjdk platform names to hotspot names
 403 
 404   HOTSPOT_$1_OS=${OPENJDK_$1_OS}
 405   if test "x$OPENJDK_$1_OS" = xmacosx; then
 406     HOTSPOT_$1_OS=bsd
 407   fi
 408   AC_SUBST(HOTSPOT_$1_OS)
 409 
 410   HOTSPOT_$1_OS_TYPE=${OPENJDK_$1_OS_TYPE}
 411   if test "x$OPENJDK_$1_OS_TYPE" = xunix; then
 412     HOTSPOT_$1_OS_TYPE=posix
 413   fi
 414   AC_SUBST(HOTSPOT_$1_OS_TYPE)
 415 
 416   HOTSPOT_$1_CPU=${OPENJDK_$1_CPU}
 417   if test "x$OPENJDK_$1_CPU" = xx86; then
 418     HOTSPOT_$1_CPU=x86_32
 419   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
 420     HOTSPOT_$1_CPU=sparc
 421   elif test "x$OPENJDK_$1_CPU" = xppc64; then
 422     HOTSPOT_$1_CPU=ppc_64
 423   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
 424     HOTSPOT_$1_CPU=ppc_64
 425   fi
 426   AC_SUBST(HOTSPOT_$1_CPU)
 427 
 428   # This is identical with OPENJDK_*, but define anyway for consistency.
 429   HOTSPOT_$1_CPU_ARCH=${OPENJDK_$1_CPU_ARCH}
 430   AC_SUBST(HOTSPOT_$1_CPU_ARCH)
 431 
 432   # Setup HOTSPOT_$1_CPU_DEFINE
 433   if test "x$OPENJDK_$1_CPU" = xx86; then
 434     HOTSPOT_$1_CPU_DEFINE=IA32
 435   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
 436     HOTSPOT_$1_CPU_DEFINE=AMD64
 437   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
 438     HOTSPOT_$1_CPU_DEFINE=SPARC
 439   elif test "x$OPENJDK_$1_CPU" = xaarch64; then
 440     HOTSPOT_$1_CPU_DEFINE=AARCH64
 441   elif test "x$OPENJDK_$1_CPU" = xppc64; then
 442     HOTSPOT_$1_CPU_DEFINE=PPC64
 443   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
 444     HOTSPOT_$1_CPU_DEFINE=PPC64
 445 
 446   # The cpu defines below are for zero, we don't support them directly.
 447   elif test "x$OPENJDK_$1_CPU" = xsparc; then
 448     HOTSPOT_$1_CPU_DEFINE=SPARC
 449   elif test "x$OPENJDK_$1_CPU" = xppc; then
 450     HOTSPOT_$1_CPU_DEFINE=PPC32
 451   elif test "x$OPENJDK_$1_CPU" = xs390; then
 452     HOTSPOT_$1_CPU_DEFINE=S390
 453   elif test "x$OPENJDK_$1_CPU" = xs390x; then
 454     HOTSPOT_$1_CPU_DEFINE=S390
 455   elif test "x$OPENJDK_$1_CPU" != x; then
 456     HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z)
 457   fi
 458   AC_SUBST(HOTSPOT_$1_CPU_DEFINE)
 459 
 460 ])
 461 
 462 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
 463 [
 464   if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
 465     REQUIRED_OS_NAME=SunOS
 466     REQUIRED_OS_VERSION=5.10
 467   fi
 468   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
 469     REQUIRED_OS_NAME=Linux
 470     REQUIRED_OS_VERSION=2.6
 471   fi
 472   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 473     REQUIRED_OS_NAME=Windows
 474     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 475       REQUIRED_OS_VERSION=5.2
 476     else
 477       REQUIRED_OS_VERSION=5.1
 478     fi
 479   fi
 480   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 481     REQUIRED_OS_NAME="Mac OS X"
 482     REQUIRED_OS_VERSION=11.2
 483   fi
 484   if test "x$OPENJDK_TARGET_OS" = "xaix"; then
 485     REQUIRED_OS_NAME=AIX
 486     REQUIRED_OS_VERSION=7.1
 487   fi
 488   REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU}
 489 
 490   AC_SUBST(REQUIRED_OS_NAME)
 491   AC_SUBST(REQUIRED_OS_ARCH)
 492   AC_SUBST(REQUIRED_OS_VERSION)
 493 ])
 494 
 495 #%%% Build and target systems %%%
 496 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
 497 [
 498   # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
 499   # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
 500   # product you're building. The target of this build is called "host". Since this is confusing to most people, we
 501   # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
 502   # to use the configure naming style.
 503   AC_CANONICAL_BUILD
 504   AC_CANONICAL_HOST
 505   AC_CANONICAL_TARGET
 506 
 507   PLATFORM_EXTRACT_TARGET_AND_BUILD
 508   PLATFORM_SETUP_TARGET_CPU_BITS
 509   PLATFORM_SET_RELEASE_FILE_OS_VALUES
 510   PLATFORM_SETUP_LEGACY_VARS
 511 ])
 512 
 513 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
 514 [
 515   ###############################################################################
 516 
 517   # Note that this is the build platform OS version!
 518 
 519   OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
 520   OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
 521   OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
 522   OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
 523   AC_SUBST(OS_VERSION_MAJOR)
 524   AC_SUBST(OS_VERSION_MINOR)
 525   AC_SUBST(OS_VERSION_MICRO)
 526 ])
 527 
 528 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
 529 # Add -mX to various FLAGS variables.
 530 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
 531 [
 532   # When we add flags to the "official" CFLAGS etc, we need to
 533   # keep track of these additions in ADDED_CFLAGS etc. These
 534   # will later be checked to make sure only controlled additions
 535   # have been made to CFLAGS etc.
 536   ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 537   ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 538   ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 539 
 540   CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
 541   CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
 542   LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
 543 
 544   CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
 545   CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
 546   LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
 547 
 548   JVM_CFLAGS="$JVM_CFLAGS $ADDED_CFLAGS"
 549   JVM_LDFLAGS="$JVM_LDFLAGS $ADDED_LDFLAGS"
 550   JVM_ASFLAGS="$JVM_ASFLAGS $ADDED_CFLAGS"
 551 ])
 552 
 553 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 554 [
 555   ###############################################################################
 556   #
 557   # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
 558   # (The JVM can use 32 or 64 bit Java pointers but that decision
 559   # is made at runtime.)
 560   #
 561 
 562   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
 563     # Always specify -m flag on Solaris
 564     # And -q on AIX because otherwise the compiler produces 32-bit objects by default
 565     PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 566   elif test "x$COMPILE_TYPE" = xreduced; then
 567     if test "x$OPENJDK_TARGET_OS_TYPE" = xunix; then
 568       # Specify -m if running reduced on unix platforms
 569       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 570     fi
 571   fi
 572   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 573     JVM_CFLAGS="$JVM_CFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 574     JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 575     JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 576   fi
 577 
 578   # Make compilation sanity check
 579   AC_CHECK_HEADERS([stdio.h], , [
 580     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
 581     if test "x$COMPILE_TYPE" = xreduced; then
 582       HELP_MSG_MISSING_DEPENDENCY([reduced])
 583       AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 584     elif test "x$COMPILE_TYPE" = xcross; then
 585       AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 586     fi
 587     AC_MSG_ERROR([Cannot continue.])
 588   ])
 589 
 590   AC_CHECK_SIZEOF([int *], [1111])
 591 
 592   # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
 593   if test "x$ac_cv_sizeof_int_p" = x; then
 594     # The test failed, lets stick to the assumed value.
 595     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
 596   else
 597     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 598 
 599     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 600       # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
 601       # Let's try to implicitely set the compilers target architecture and retry the test
 602       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).])
 603       AC_MSG_NOTICE([Retrying with platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
 604       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 605 
 606       # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
 607       unset ac_cv_sizeof_int_p
 608       # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
 609       cat >>confdefs.h <<_ACEOF
 610 #undef SIZEOF_INT_P
 611 _ACEOF
 612 
 613       AC_CHECK_SIZEOF([int *], [1111])
 614 
 615       TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 616 
 617       if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 618         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)])
 619         if test "x$COMPILE_TYPE" = xreduced; then
 620           HELP_MSG_MISSING_DEPENDENCY([reduced])
 621           AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 622         elif test "x$COMPILE_TYPE" = xcross; then
 623           AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 624         fi
 625         AC_MSG_ERROR([Cannot continue.])
 626       fi
 627     fi
 628   fi
 629 
 630   AC_MSG_CHECKING([for target address size])
 631   AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
 632 ])
 633 
 634 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
 635 [
 636   ###############################################################################
 637   #
 638   # Is the target little of big endian?
 639   #
 640   AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
 641 
 642   if test "x$ENDIAN" = xuniversal_endianness; then
 643     AC_MSG_ERROR([Building with both big and little endianness is not supported])
 644   fi
 645   if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
 646     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)])
 647   fi
 648 ])