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   
 383   OPENJDK_$1_CLIB_BUNDLE="$OPENJDK_$1_CLIB"
 384 
 385   OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}-${OPENJDK_$1_CLIB_BUNDLE}"
 386   AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
 387 
 388   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
 389     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
 390     # unpack200.exe. This variable is used in
 391     # FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER.
 392     if test "x$OPENJDK_$1_OS" = xlinux || test "x$OPENJDK_$1_OS" = xmacosx; then
 393       OPENJDK_$1_ADD_LP64="-D_LP64=1"
 394     fi
 395   fi
 396 
 397   if test "x$COMPILE_TYPE" = "xcross"; then
 398     # FIXME: ... or should this include reduced builds..?
 399     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_$1_CPU_LEGACY"
 400   else
 401     DEFINE_CROSS_COMPILE_ARCH=""
 402   fi
 403   AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
 404 
 405   # Convert openjdk platform names to hotspot names
 406 
 407   HOTSPOT_$1_OS=${OPENJDK_$1_OS}
 408   if test "x$OPENJDK_$1_OS" = xmacosx; then
 409     HOTSPOT_$1_OS=bsd
 410   fi
 411   AC_SUBST(HOTSPOT_$1_OS)
 412 
 413   HOTSPOT_$1_OS_TYPE=${OPENJDK_$1_OS_TYPE}
 414   if test "x$OPENJDK_$1_OS_TYPE" = xunix; then
 415     HOTSPOT_$1_OS_TYPE=posix
 416   fi
 417   AC_SUBST(HOTSPOT_$1_OS_TYPE)
 418 
 419   HOTSPOT_$1_CPU=${OPENJDK_$1_CPU}
 420   if test "x$OPENJDK_$1_CPU" = xx86; then
 421     HOTSPOT_$1_CPU=x86_32
 422   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
 423     HOTSPOT_$1_CPU=sparc
 424   elif test "x$OPENJDK_$1_CPU" = xppc64; then
 425     HOTSPOT_$1_CPU=ppc_64
 426   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
 427     HOTSPOT_$1_CPU=ppc_64
 428   fi
 429   AC_SUBST(HOTSPOT_$1_CPU)
 430 
 431   # This is identical with OPENJDK_*, but define anyway for consistency.
 432   HOTSPOT_$1_CPU_ARCH=${OPENJDK_$1_CPU_ARCH}
 433   AC_SUBST(HOTSPOT_$1_CPU_ARCH)
 434 
 435   # Setup HOTSPOT_$1_CPU_DEFINE
 436   if test "x$OPENJDK_$1_CPU" = xx86; then
 437     HOTSPOT_$1_CPU_DEFINE=IA32
 438   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
 439     HOTSPOT_$1_CPU_DEFINE=AMD64
 440   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
 441     HOTSPOT_$1_CPU_DEFINE=SPARC
 442   elif test "x$OPENJDK_$1_CPU" = xaarch64; then
 443     HOTSPOT_$1_CPU_DEFINE=AARCH64
 444   elif test "x$OPENJDK_$1_CPU" = xppc64; then
 445     HOTSPOT_$1_CPU_DEFINE=PPC64
 446   elif test "x$OPENJDK_$1_CPU" = xppc64le; then
 447     HOTSPOT_$1_CPU_DEFINE=PPC64
 448 
 449   # The cpu defines below are for zero, we don't support them directly.
 450   elif test "x$OPENJDK_$1_CPU" = xsparc; then
 451     HOTSPOT_$1_CPU_DEFINE=SPARC
 452   elif test "x$OPENJDK_$1_CPU" = xppc; then
 453     HOTSPOT_$1_CPU_DEFINE=PPC32
 454   elif test "x$OPENJDK_$1_CPU" = xs390; then
 455     HOTSPOT_$1_CPU_DEFINE=S390
 456   elif test "x$OPENJDK_$1_CPU" = xs390x; then
 457     HOTSPOT_$1_CPU_DEFINE=S390
 458   elif test "x$OPENJDK_$1_CPU" != x; then
 459     HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z)
 460   fi
 461   AC_SUBST(HOTSPOT_$1_CPU_DEFINE)
 462 
 463   HOTSPOT_$1_CLIB=${OPENJDK_$1_CLIB}
 464   AC_SUBST(HOTSPOT_$1_CLIB)
 465 ])
 466 
 467 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
 468 [
 469   if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
 470     REQUIRED_OS_NAME=SunOS
 471     REQUIRED_OS_VERSION=5.10
 472   fi
 473   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
 474     REQUIRED_OS_NAME=Linux
 475     REQUIRED_OS_VERSION=2.6
 476   fi
 477   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 478     REQUIRED_OS_NAME=Windows
 479     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 480       REQUIRED_OS_VERSION=5.2
 481     else
 482       REQUIRED_OS_VERSION=5.1
 483     fi
 484   fi
 485   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 486     REQUIRED_OS_NAME="Mac OS X"
 487     REQUIRED_OS_VERSION=11.2
 488   fi
 489   if test "x$OPENJDK_TARGET_OS" = "xaix"; then
 490     REQUIRED_OS_NAME=AIX
 491     REQUIRED_OS_VERSION=7.1
 492   fi
 493   REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU}
 494 
 495   AC_SUBST(REQUIRED_OS_NAME)
 496   AC_SUBST(REQUIRED_OS_ARCH)
 497   AC_SUBST(REQUIRED_OS_VERSION)
 498 ])
 499 
 500 #%%% Build and target systems %%%
 501 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
 502 [
 503   # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
 504   # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
 505   # product you're building. The target of this build is called "host". Since this is confusing to most people, we
 506   # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
 507   # to use the configure naming style.
 508   AC_CANONICAL_BUILD
 509   AC_CANONICAL_HOST
 510   AC_CANONICAL_TARGET
 511 
 512   PLATFORM_EXTRACT_TARGET_AND_BUILD
 513   PLATFORM_SETUP_TARGET_CPU_BITS
 514   PLATFORM_SET_RELEASE_FILE_OS_VALUES
 515   PLATFORM_SETUP_LEGACY_VARS
 516 ])
 517 
 518 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
 519 [
 520   ###############################################################################
 521 
 522   # Note that this is the build platform OS version!
 523 
 524   OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
 525   OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
 526   OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
 527   OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
 528   AC_SUBST(OS_VERSION_MAJOR)
 529   AC_SUBST(OS_VERSION_MINOR)
 530   AC_SUBST(OS_VERSION_MICRO)
 531 ])
 532 
 533 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
 534 # Add -mX to various FLAGS variables.
 535 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
 536 [
 537   # When we add flags to the "official" CFLAGS etc, we need to
 538   # keep track of these additions in ADDED_CFLAGS etc. These
 539   # will later be checked to make sure only controlled additions
 540   # have been made to CFLAGS etc.
 541   ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 542   ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 543   ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 544 
 545   CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
 546   CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
 547   LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
 548 
 549   CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
 550   CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
 551   LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
 552 
 553   JVM_CFLAGS="$JVM_CFLAGS $ADDED_CFLAGS"
 554   JVM_LDFLAGS="$JVM_LDFLAGS $ADDED_LDFLAGS"
 555   JVM_ASFLAGS="$JVM_ASFLAGS $ADDED_CFLAGS"
 556 ])
 557 
 558 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 559 [
 560   ###############################################################################
 561   #
 562   # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
 563   # (The JVM can use 32 or 64 bit Java pointers but that decision
 564   # is made at runtime.)
 565   #
 566 
 567   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
 568     # Always specify -m flag on Solaris
 569     # And -q on AIX because otherwise the compiler produces 32-bit objects by default
 570     PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 571   elif test "x$COMPILE_TYPE" = xreduced; then
 572     if test "x$OPENJDK_TARGET_OS_TYPE" = xunix; then
 573       # Specify -m if running reduced on unix platforms
 574       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 575     fi
 576   fi
 577   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 578     JVM_CFLAGS="$JVM_CFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 579     JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 580     JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 581   fi
 582 
 583   # Make compilation sanity check
 584   AC_CHECK_HEADERS([stdio.h], , [
 585     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
 586     if test "x$COMPILE_TYPE" = xreduced; then
 587       HELP_MSG_MISSING_DEPENDENCY([reduced])
 588       AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 589     elif test "x$COMPILE_TYPE" = xcross; then
 590       AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 591     fi
 592     AC_MSG_ERROR([Cannot continue.])
 593   ])
 594 
 595   AC_CHECK_SIZEOF([int *], [1111])
 596 
 597   # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
 598   if test "x$ac_cv_sizeof_int_p" = x; then
 599     # The test failed, lets stick to the assumed value.
 600     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
 601   else
 602     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 603 
 604     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 605       # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
 606       # Let's try to implicitely set the compilers target architecture and retry the test
 607       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).])
 608       AC_MSG_NOTICE([Retrying with platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
 609       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 610 
 611       # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
 612       unset ac_cv_sizeof_int_p
 613       # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
 614       cat >>confdefs.h <<_ACEOF
 615 #undef SIZEOF_INT_P
 616 _ACEOF
 617 
 618       AC_CHECK_SIZEOF([int *], [1111])
 619 
 620       TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 621 
 622       if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 623         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)])
 624         if test "x$COMPILE_TYPE" = xreduced; then
 625           HELP_MSG_MISSING_DEPENDENCY([reduced])
 626           AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 627         elif test "x$COMPILE_TYPE" = xcross; then
 628           AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 629         fi
 630         AC_MSG_ERROR([Cannot continue.])
 631       fi
 632     fi
 633   fi
 634 
 635   AC_MSG_CHECKING([for target address size])
 636   AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
 637 ])
 638 
 639 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
 640 [
 641   ###############################################################################
 642   #
 643   # Is the target little of big endian?
 644   #
 645   AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
 646 
 647   if test "x$ENDIAN" = xuniversal_endianness; then
 648     AC_MSG_ERROR([Building with both big and little endianness is not supported])
 649   fi
 650   if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
 651     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)])
 652   fi
 653 ])