1 #
   2 # Copyright (c) 2011, 2016, 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       case "$1" in
 127         *freebsd*)
 128           VAR_OS_ENV=bsd.freebsd ;;
 129         *openbsd*)
 130           VAR_OS_ENV=bsd.openbsd ;;
 131         *netbsd*)
 132           VAR_OS_ENV=bsd.netbsd ;;
 133       esac
 134       ;;
 135     *cygwin*)
 136       VAR_OS=windows
 137       VAR_OS_ENV=windows.cygwin
 138       ;;
 139     *mingw*)
 140       VAR_OS=windows
 141       VAR_OS_ENV=windows.msys
 142       ;;
 143     *aix*)
 144       VAR_OS=aix
 145       VAR_OS_TYPE=unix
 146       ;;
 147     *)
 148       AC_MSG_ERROR([unsupported operating system $1])
 149       ;;
 150   esac
 151 ])
 152 
 153 # Expects $host_os $host_cpu $build_os and $build_cpu
 154 # and $with_target_bits to have been setup!
 155 #
 156 # Translate the standard triplet(quadruplet) definition
 157 # of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
 158 # OPENJDK_BUILD_OS, etc.
 159 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
 160 [
 161   # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
 162   # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
 163   # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
 164   # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
 165   OPENJDK_TARGET_AUTOCONF_NAME="$host"
 166   OPENJDK_BUILD_AUTOCONF_NAME="$build"
 167   AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
 168   AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
 169 
 170   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
 171   PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
 172   PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
 173   # ..and setup our own variables. (Do this explicitely to facilitate searching)
 174   OPENJDK_BUILD_OS="$VAR_OS"
 175   if test "x$VAR_OS_TYPE" != x; then
 176     OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE"
 177   else
 178     OPENJDK_BUILD_OS_TYPE="$VAR_OS"
 179   fi
 180   if test "x$VAR_OS_ENV" != x; then
 181     OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
 182   else
 183     OPENJDK_BUILD_OS_ENV="$VAR_OS"
 184   fi
 185   OPENJDK_BUILD_CPU="$VAR_CPU"
 186   OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
 187   OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
 188   OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
 189   AC_SUBST(OPENJDK_BUILD_OS)
 190   AC_SUBST(OPENJDK_BUILD_OS_TYPE)
 191   AC_SUBST(OPENJDK_BUILD_OS_ENV)
 192   AC_SUBST(OPENJDK_BUILD_CPU)
 193   AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
 194   AC_SUBST(OPENJDK_BUILD_CPU_BITS)
 195   AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
 196 
 197   AC_MSG_CHECKING([openjdk-build os-cpu])
 198   AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
 199 
 200   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
 201   PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
 202   PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
 203   # ... and setup our own variables. (Do this explicitely to facilitate searching)
 204   OPENJDK_TARGET_OS="$VAR_OS"
 205   if test "x$VAR_OS_TYPE" != x; then
 206     OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE"
 207   else
 208     OPENJDK_TARGET_OS_TYPE="$VAR_OS"
 209   fi
 210   if test "x$VAR_OS_ENV" != x; then
 211     OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
 212   else
 213     OPENJDK_TARGET_OS_ENV="$VAR_OS"
 214   fi
 215   OPENJDK_TARGET_CPU="$VAR_CPU"
 216   OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
 217   OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
 218   OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
 219   AC_SUBST(OPENJDK_TARGET_OS)
 220   AC_SUBST(OPENJDK_TARGET_OS_TYPE)
 221   AC_SUBST(OPENJDK_TARGET_OS_ENV)
 222   AC_SUBST(OPENJDK_TARGET_CPU)
 223   AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
 224   AC_SUBST(OPENJDK_TARGET_CPU_BITS)
 225   AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
 226 
 227   AC_MSG_CHECKING([openjdk-target os-cpu])
 228   AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
 229 
 230   if test "x$OPENJDK_TARGET_OS_ENV" != "x$OPENJDK_TARGET_OS"; then
 231     AC_MSG_CHECKING([openjdk-target os-env])
 232     AC_MSG_RESULT([$OPENJDK_TARGET_OS_ENV])
 233   fi
 234 ])
 235 
 236 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
 237 # accordingly. Must be done after setting up build and target system, but before
 238 # doing anything else with these values.
 239 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
 240 [
 241   AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
 242        [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
 243 
 244   # We have three types of compiles:
 245   # native  == normal compilation, target system == build system
 246   # cross   == traditional cross compilation, target system != build system; special toolchain needed
 247   # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
 248   #
 249   if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
 250     # We're doing a proper cross-compilation
 251     COMPILE_TYPE="cross"
 252   else
 253     COMPILE_TYPE="native"
 254   fi
 255 
 256   if test "x$with_target_bits" != x; then
 257     if test "x$COMPILE_TYPE" = "xcross"; then
 258       AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
 259     fi
 260 
 261     if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 262       # A reduced build is requested
 263       COMPILE_TYPE="reduced"
 264       OPENJDK_TARGET_CPU_BITS=32
 265       if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 266         OPENJDK_TARGET_CPU=x86
 267       elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 268         OPENJDK_TARGET_CPU=sparc
 269       else
 270         AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
 271       fi
 272     elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 273       AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
 274     elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
 275       AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
 276     else
 277       AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
 278     fi
 279   fi
 280   AC_SUBST(COMPILE_TYPE)
 281 
 282   AC_MSG_CHECKING([compilation type])
 283   AC_MSG_RESULT([$COMPILE_TYPE])
 284 ])
 285 
 286 # Setup the legacy variables, for controlling the old makefiles.
 287 #
 288 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
 289 [
 290   # Also store the legacy naming of the cpu.
 291   # Ie i586 and amd64 instead of x86 and x86_64
 292   OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
 293   if test "x$OPENJDK_TARGET_CPU" = xx86; then
 294     OPENJDK_TARGET_CPU_LEGACY="i586"
 295   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 296     # On all platforms except MacOSX replace x86_64 with amd64.
 297     OPENJDK_TARGET_CPU_LEGACY="amd64"
 298   fi
 299   AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
 300 
 301   # And the second legacy naming of the cpu.
 302   # Ie i386 and amd64 instead of x86 and x86_64.
 303   OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
 304   if test "x$OPENJDK_TARGET_CPU" = xx86; then
 305     OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
 306   elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 307     OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
 308   fi
 309   AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
 310 
 311   # This is the name of the cpu (but using i386 and amd64 instead of
 312   # x86 and x86_64, respectively), preceeded by a /, to be used when
 313   # locating libraries. On macosx, it's empty, though.
 314   OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
 315   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 316     OPENJDK_TARGET_CPU_LIBDIR=""
 317   fi
 318   AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
 319 
 320   # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
 321   # /amd64 or /sparcv9. This string is appended to some library paths, like this:
 322   # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
 323   OPENJDK_TARGET_CPU_ISADIR=""
 324   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 325     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 326       OPENJDK_TARGET_CPU_ISADIR="/amd64"
 327     elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
 328       OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
 329     fi
 330   fi
 331   AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
 332 
 333   # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
 334   OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
 335   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
 336     # On linux only, we replace x86 with i386.
 337     OPENJDK_TARGET_CPU_OSARCH="i386"
 338   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 339     # On all platforms except macosx, we replace x86_64 with amd64.
 340     OPENJDK_TARGET_CPU_OSARCH="amd64"
 341   fi
 342   AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
 343 
 344   OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
 345   if test "x$OPENJDK_TARGET_CPU" = xx86; then
 346     OPENJDK_TARGET_CPU_JLI="i386"
 347   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 348     # On all platforms except macosx, we replace x86_64 with amd64.
 349     OPENJDK_TARGET_CPU_JLI="amd64"
 350   fi
 351   # Now setup the -D flags for building libjli.
 352   OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
 353   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 354     if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
 355       OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
 356     elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 357       OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
 358     fi
 359   fi
 360   AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
 361 
 362   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 363       OPENJDK_TARGET_OS_EXPORT_DIR=macosx
 364   else
 365       OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_TYPE}
 366   fi
 367   AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR)
 368 
 369   if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 370     A_LP64="LP64:="
 371     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
 372     # unpack200.exe
 373     if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
 374       ADD_LP64="-D_LP64=1"
 375     fi
 376   fi
 377   AC_SUBST(LP64,$A_LP64)
 378 
 379   if test "x$COMPILE_TYPE" = "xcross"; then
 380     # FIXME: ... or should this include reduced builds..?
 381     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
 382   else
 383     DEFINE_CROSS_COMPILE_ARCH=""
 384   fi
 385   AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
 386 
 387   # ZERO_ARCHDEF is used to enable architecture-specific code
 388   case "${OPENJDK_TARGET_CPU}" in
 389     ppc)     ZERO_ARCHDEF=PPC32 ;;
 390     ppc64)   ZERO_ARCHDEF=PPC64 ;;
 391     s390*)   ZERO_ARCHDEF=S390  ;;
 392     sparc*)  ZERO_ARCHDEF=SPARC ;;
 393     x86_64*) ZERO_ARCHDEF=AMD64 ;;
 394     x86)     ZERO_ARCHDEF=IA32  ;;
 395     *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
 396   esac
 397   AC_SUBST(ZERO_ARCHDEF)
 398 ])
 399 
 400 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
 401 [
 402   if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
 403     REQUIRED_OS_NAME=SunOS
 404     REQUIRED_OS_VERSION=5.10
 405   fi
 406   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
 407     REQUIRED_OS_NAME=Linux
 408     REQUIRED_OS_VERSION=2.6
 409   fi
 410   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 411     REQUIRED_OS_NAME=Windows
 412     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 413       REQUIRED_OS_VERSION=5.2
 414     else
 415       REQUIRED_OS_VERSION=5.1
 416     fi
 417   fi
 418   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 419     REQUIRED_OS_NAME=Darwin
 420     REQUIRED_OS_VERSION=11.2
 421   fi
 422 
 423   AC_SUBST(REQUIRED_OS_NAME)
 424   AC_SUBST(REQUIRED_OS_VERSION)
 425 ])
 426 
 427 #%%% Build and target systems %%%
 428 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
 429 [
 430   # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
 431   # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
 432   # product you're building. The target of this build is called "host". Since this is confusing to most people, we
 433   # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
 434   # to use the configure naming style.
 435   AC_CANONICAL_BUILD
 436   AC_CANONICAL_HOST
 437   AC_CANONICAL_TARGET
 438 
 439   PLATFORM_EXTRACT_TARGET_AND_BUILD
 440   PLATFORM_SETUP_TARGET_CPU_BITS
 441   PLATFORM_SET_RELEASE_FILE_OS_VALUES
 442   PLATFORM_SETUP_LEGACY_VARS
 443 ])
 444 
 445 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
 446 [
 447   ###############################################################################
 448 
 449   # Note that this is the build platform OS version!
 450 
 451   OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
 452   OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
 453   OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
 454   OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
 455   AC_SUBST(OS_VERSION_MAJOR)
 456   AC_SUBST(OS_VERSION_MINOR)
 457   AC_SUBST(OS_VERSION_MICRO)
 458 ])
 459 
 460 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
 461 # Add -mX to various FLAGS variables.
 462 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
 463 [
 464   # When we add flags to the "official" CFLAGS etc, we need to
 465   # keep track of these additions in ADDED_CFLAGS etc. These
 466   # will later be checked to make sure only controlled additions
 467   # have been made to CFLAGS etc.
 468   ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 469   ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 470   ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 471 
 472   CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
 473   CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
 474   LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
 475 
 476   CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
 477   CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
 478   LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
 479 ])
 480 
 481 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 482 [
 483   ###############################################################################
 484   #
 485   # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
 486   # (The JVM can use 32 or 64 bit Java pointers but that decision
 487   # is made at runtime.)
 488   #
 489 
 490   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
 491     # Always specify -m flag on Solaris
 492     # And -q on AIX because otherwise the compiler produces 32-bit objects by default
 493     PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 494   elif test "x$COMPILE_TYPE" = xreduced; then
 495     if test "x$OPENJDK_TARGET_OS_TYPE" = xunix; then
 496       # Specify -m if running reduced on unix platforms
 497       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 498     fi
 499   fi
 500 
 501   # Make compilation sanity check
 502   AC_CHECK_HEADERS([stdio.h], , [
 503     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
 504     if test "x$COMPILE_TYPE" = xreduced; then
 505       HELP_MSG_MISSING_DEPENDENCY([reduced])
 506       AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 507     elif test "x$COMPILE_TYPE" = xcross; then
 508       AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 509     fi
 510     AC_MSG_ERROR([Cannot continue.])
 511   ])
 512 
 513   AC_CHECK_SIZEOF([int *], [1111])
 514 
 515   # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
 516   if test "x$ac_cv_sizeof_int_p" = x; then
 517     # The test failed, lets stick to the assumed value.
 518     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
 519   else
 520     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 521 
 522     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 523       # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
 524       # Let's try to implicitely set the compilers target architecture and retry the test
 525       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).])
 526       AC_MSG_NOTICE([Retrying with platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
 527       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
 528 
 529       # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
 530       unset ac_cv_sizeof_int_p
 531       # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
 532       cat >>confdefs.h <<_ACEOF
 533 #undef SIZEOF_INT_P
 534 _ACEOF
 535 
 536       AC_CHECK_SIZEOF([int *], [1111])
 537 
 538       TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 539 
 540       if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
 541         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)])
 542         if test "x$COMPILE_TYPE" = xreduced; then
 543           HELP_MSG_MISSING_DEPENDENCY([reduced])
 544           AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
 545         elif test "x$COMPILE_TYPE" = xcross; then
 546           AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
 547         fi
 548         AC_MSG_ERROR([Cannot continue.])
 549       fi
 550     fi
 551   fi
 552 
 553   AC_MSG_CHECKING([for target address size])
 554   AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
 555 ])
 556 
 557 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
 558 [
 559   ###############################################################################
 560   #
 561   # Is the target little of big endian?
 562   #
 563   AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
 564 
 565   if test "x$ENDIAN" = xuniversal_endianness; then
 566     AC_MSG_ERROR([Building with both big and little endianness is not supported])
 567   fi
 568   if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
 569     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)])
 570   fi
 571 ])