common/autoconf/platform.m4

changeset 0
75a576e87639
child 1133
50aaf272884f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/autoconf/platform.m4	Wed Apr 27 01:39:08 2016 +0800
     1.3 @@ -0,0 +1,541 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
    1.30 +# Converts autoconf style CPU name to OpenJDK style, into
    1.31 +# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
    1.32 +AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
    1.33 +[
    1.34 +  # First argument is the cpu name from the trip/quad
    1.35 +  case "$1" in
    1.36 +    x86_64)
    1.37 +      VAR_CPU=x86_64
    1.38 +      VAR_CPU_ARCH=x86
    1.39 +      VAR_CPU_BITS=64
    1.40 +      VAR_CPU_ENDIAN=little
    1.41 +      ;;
    1.42 +    i?86)
    1.43 +      VAR_CPU=x86
    1.44 +      VAR_CPU_ARCH=x86
    1.45 +      VAR_CPU_BITS=32
    1.46 +      VAR_CPU_ENDIAN=little
    1.47 +      ;;
    1.48 +    arm*)
    1.49 +      VAR_CPU=arm
    1.50 +      VAR_CPU_ARCH=arm
    1.51 +      VAR_CPU_BITS=32
    1.52 +      VAR_CPU_ENDIAN=little
    1.53 +      ;;
    1.54 +    powerpc)
    1.55 +      VAR_CPU=ppc
    1.56 +      VAR_CPU_ARCH=ppc
    1.57 +      VAR_CPU_BITS=32
    1.58 +      VAR_CPU_ENDIAN=big
    1.59 +      ;;
    1.60 +    powerpc64)
    1.61 +      VAR_CPU=ppc64
    1.62 +      VAR_CPU_ARCH=ppc
    1.63 +      VAR_CPU_BITS=64
    1.64 +      VAR_CPU_ENDIAN=big
    1.65 +      ;;
    1.66 +    powerpc64le)
    1.67 +      VAR_CPU=ppc64
    1.68 +      VAR_CPU_ARCH=ppc
    1.69 +      VAR_CPU_BITS=64
    1.70 +      VAR_CPU_ENDIAN=little
    1.71 +      ;;
    1.72 +    s390)
    1.73 +      VAR_CPU=s390
    1.74 +      VAR_CPU_ARCH=s390
    1.75 +      VAR_CPU_BITS=32
    1.76 +      VAR_CPU_ENDIAN=big
    1.77 +      ;;
    1.78 +    s390x)
    1.79 +      VAR_CPU=s390x
    1.80 +      VAR_CPU_ARCH=s390
    1.81 +      VAR_CPU_BITS=64
    1.82 +      VAR_CPU_ENDIAN=big
    1.83 +      ;;
    1.84 +    sparc)
    1.85 +      VAR_CPU=sparc
    1.86 +      VAR_CPU_ARCH=sparc
    1.87 +      VAR_CPU_BITS=32
    1.88 +      VAR_CPU_ENDIAN=big
    1.89 +      ;;
    1.90 +    sparcv9)
    1.91 +      VAR_CPU=sparcv9
    1.92 +      VAR_CPU_ARCH=sparc
    1.93 +      VAR_CPU_BITS=64
    1.94 +      VAR_CPU_ENDIAN=big
    1.95 +      ;;
    1.96 +    *)
    1.97 +      AC_MSG_ERROR([unsupported cpu $1])
    1.98 +      ;;
    1.99 +  esac
   1.100 +])
   1.101 +
   1.102 +# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
   1.103 +# Converts autoconf style OS name to OpenJDK style, into
   1.104 +# VAR_OS and VAR_OS_API.
   1.105 +AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
   1.106 +[
   1.107 +  case "$1" in
   1.108 +    *linux*)
   1.109 +      VAR_OS=linux
   1.110 +      VAR_OS_API=posix
   1.111 +      VAR_OS_ENV=linux
   1.112 +      ;;
   1.113 +    *solaris*)
   1.114 +      VAR_OS=solaris
   1.115 +      VAR_OS_API=posix
   1.116 +      VAR_OS_ENV=solaris
   1.117 +      ;;
   1.118 +    *darwin*)
   1.119 +      VAR_OS=macosx
   1.120 +      VAR_OS_API=posix
   1.121 +      VAR_OS_ENV=macosx
   1.122 +      ;;
   1.123 +    *bsd*)
   1.124 +      VAR_OS=bsd
   1.125 +      VAR_OS_API=posix
   1.126 +      VAR_OS_ENV=bsd
   1.127 +      ;;
   1.128 +    *cygwin*)
   1.129 +      VAR_OS=windows
   1.130 +      VAR_OS_API=winapi
   1.131 +      VAR_OS_ENV=windows.cygwin
   1.132 +      ;;
   1.133 +    *mingw*)
   1.134 +      VAR_OS=windows
   1.135 +      VAR_OS_API=winapi
   1.136 +      VAR_OS_ENV=windows.msys
   1.137 +      ;;
   1.138 +    *aix*)
   1.139 +      VAR_OS=aix
   1.140 +      VAR_OS_API=posix
   1.141 +      VAR_OS_ENV=aix
   1.142 +      ;;
   1.143 +    *)
   1.144 +      AC_MSG_ERROR([unsupported operating system $1])
   1.145 +      ;;
   1.146 +  esac
   1.147 +])
   1.148 +
   1.149 +# Expects $host_os $host_cpu $build_os and $build_cpu
   1.150 +# and $with_target_bits to have been setup!
   1.151 +#
   1.152 +# Translate the standard triplet(quadruplet) definition
   1.153 +# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
   1.154 +# OPENJDK_BUILD_OS, etc.
   1.155 +AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
   1.156 +[
   1.157 +  # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
   1.158 +  # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
   1.159 +  # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
   1.160 +  # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
   1.161 +  OPENJDK_TARGET_AUTOCONF_NAME="$host"
   1.162 +  OPENJDK_BUILD_AUTOCONF_NAME="$build"
   1.163 +  AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
   1.164 +  AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
   1.165 +
   1.166 +  # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
   1.167 +  PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
   1.168 +  PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
   1.169 +  # ..and setup our own variables. (Do this explicitely to facilitate searching)
   1.170 +  OPENJDK_BUILD_OS="$VAR_OS"
   1.171 +  OPENJDK_BUILD_OS_API="$VAR_OS_API"
   1.172 +  OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
   1.173 +  OPENJDK_BUILD_CPU="$VAR_CPU"
   1.174 +  OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
   1.175 +  OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
   1.176 +  OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
   1.177 +  AC_SUBST(OPENJDK_BUILD_OS)
   1.178 +  AC_SUBST(OPENJDK_BUILD_OS_API)
   1.179 +  AC_SUBST(OPENJDK_BUILD_CPU)
   1.180 +  AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
   1.181 +  AC_SUBST(OPENJDK_BUILD_CPU_BITS)
   1.182 +  AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
   1.183 +
   1.184 +  AC_MSG_CHECKING([openjdk-build os-cpu])
   1.185 +  AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
   1.186 +
   1.187 +  # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
   1.188 +  PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
   1.189 +  PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
   1.190 +  # ... and setup our own variables. (Do this explicitely to facilitate searching)
   1.191 +  OPENJDK_TARGET_OS="$VAR_OS"
   1.192 +  OPENJDK_TARGET_OS_API="$VAR_OS_API"
   1.193 +  OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
   1.194 +  OPENJDK_TARGET_CPU="$VAR_CPU"
   1.195 +  OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
   1.196 +  OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
   1.197 +  OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
   1.198 +  AC_SUBST(OPENJDK_TARGET_OS)
   1.199 +  AC_SUBST(OPENJDK_TARGET_OS_API)
   1.200 +  AC_SUBST(OPENJDK_TARGET_CPU)
   1.201 +  AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
   1.202 +  AC_SUBST(OPENJDK_TARGET_CPU_BITS)
   1.203 +  AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
   1.204 +
   1.205 +  AC_MSG_CHECKING([openjdk-target os-cpu])
   1.206 +  AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
   1.207 +])
   1.208 +
   1.209 +# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
   1.210 +# accordingly. Must be done after setting up build and target system, but before
   1.211 +# doing anything else with these values.
   1.212 +AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
   1.213 +[
   1.214 +  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
   1.215 +       [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
   1.216 +
   1.217 +  # We have three types of compiles:
   1.218 +  # native  == normal compilation, target system == build system
   1.219 +  # cross   == traditional cross compilation, target system != build system; special toolchain needed
   1.220 +  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
   1.221 +  #
   1.222 +  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
   1.223 +    # We're doing a proper cross-compilation
   1.224 +    COMPILE_TYPE="cross"
   1.225 +  else
   1.226 +    COMPILE_TYPE="native"
   1.227 +  fi
   1.228 +
   1.229 +  if test "x$with_target_bits" != x; then
   1.230 +    if test "x$COMPILE_TYPE" = "xcross"; then
   1.231 +      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
   1.232 +    fi
   1.233 +
   1.234 +    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   1.235 +      # A reduced build is requested
   1.236 +      COMPILE_TYPE="reduced"
   1.237 +      OPENJDK_TARGET_CPU_BITS=32
   1.238 +      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
   1.239 +        OPENJDK_TARGET_CPU=x86
   1.240 +      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   1.241 +        OPENJDK_TARGET_CPU=sparc
   1.242 +      else
   1.243 +        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
   1.244 +      fi
   1.245 +    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
   1.246 +      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
   1.247 +    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
   1.248 +      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
   1.249 +    else
   1.250 +      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
   1.251 +    fi
   1.252 +  fi
   1.253 +  AC_SUBST(COMPILE_TYPE)
   1.254 +
   1.255 +  AC_MSG_CHECKING([compilation type])
   1.256 +  AC_MSG_RESULT([$COMPILE_TYPE])
   1.257 +])
   1.258 +
   1.259 +# Setup the legacy variables, for controlling the old makefiles.
   1.260 +#
   1.261 +AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
   1.262 +[
   1.263 +  # Also store the legacy naming of the cpu.
   1.264 +  # Ie i586 and amd64 instead of x86 and x86_64
   1.265 +  OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
   1.266 +  if test "x$OPENJDK_TARGET_CPU" = xx86; then
   1.267 +    OPENJDK_TARGET_CPU_LEGACY="i586"
   1.268 +  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.269 +    # On all platforms except MacOSX replace x86_64 with amd64.
   1.270 +    OPENJDK_TARGET_CPU_LEGACY="amd64"
   1.271 +  fi
   1.272 +  AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
   1.273 +
   1.274 +  # And the second legacy naming of the cpu.
   1.275 +  # Ie i386 and amd64 instead of x86 and x86_64.
   1.276 +  OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
   1.277 +  if test "x$OPENJDK_TARGET_CPU" = xx86; then
   1.278 +    OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
   1.279 +  elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.280 +    OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
   1.281 +  fi
   1.282 +  AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
   1.283 +
   1.284 +  # This is the name of the cpu (but using i386 and amd64 instead of
   1.285 +  # x86 and x86_64, respectively), preceeded by a /, to be used when
   1.286 +  # locating libraries. On macosx, it's empty, though.
   1.287 +  OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
   1.288 +  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.289 +    OPENJDK_TARGET_CPU_LIBDIR=""
   1.290 +  fi
   1.291 +  AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
   1.292 +
   1.293 +  # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
   1.294 +  # /amd64 or /sparcv9. This string is appended to some library paths, like this:
   1.295 +  # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
   1.296 +  OPENJDK_TARGET_CPU_ISADIR=""
   1.297 +  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.298 +    if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.299 +      OPENJDK_TARGET_CPU_ISADIR="/amd64"
   1.300 +    elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
   1.301 +      OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
   1.302 +    fi
   1.303 +  fi
   1.304 +  AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
   1.305 +
   1.306 +  # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
   1.307 +  OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
   1.308 +  if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
   1.309 +    # On linux only, we replace x86 with i386.
   1.310 +    OPENJDK_TARGET_CPU_OSARCH="i386"
   1.311 +  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.312 +    # On all platforms except macosx, we replace x86_64 with amd64.
   1.313 +    OPENJDK_TARGET_CPU_OSARCH="amd64"
   1.314 +  fi
   1.315 +  AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
   1.316 +
   1.317 +  OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
   1.318 +  if test "x$OPENJDK_TARGET_CPU" = xx86; then
   1.319 +    OPENJDK_TARGET_CPU_JLI="i386"
   1.320 +  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   1.321 +    # On all platforms except macosx, we replace x86_64 with amd64.
   1.322 +    OPENJDK_TARGET_CPU_JLI="amd64"
   1.323 +  fi
   1.324 +  # Now setup the -D flags for building libjli.
   1.325 +  OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
   1.326 +  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.327 +    if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
   1.328 +      OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
   1.329 +    elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
   1.330 +      OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
   1.331 +    fi
   1.332 +  fi
   1.333 +  AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
   1.334 +
   1.335 +  # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
   1.336 +  if test "x$OPENJDK_TARGET_OS_API" = xposix; then
   1.337 +    OPENJDK_TARGET_OS_API_DIR="solaris"
   1.338 +  fi
   1.339 +  if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
   1.340 +    OPENJDK_TARGET_OS_API_DIR="windows"
   1.341 +  fi
   1.342 +  AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
   1.343 +
   1.344 +  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.345 +      OPENJDK_TARGET_OS_EXPORT_DIR=macosx
   1.346 +  else
   1.347 +      OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_API_DIR}
   1.348 +  fi
   1.349 +  AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR)
   1.350 +
   1.351 +  if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   1.352 +    A_LP64="LP64:="
   1.353 +    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
   1.354 +    # unpack200.exe
   1.355 +    if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.356 +      ADD_LP64="-D_LP64=1"
   1.357 +    fi
   1.358 +  fi
   1.359 +  AC_SUBST(LP64,$A_LP64)
   1.360 +
   1.361 +  if test "x$COMPILE_TYPE" = "xcross"; then
   1.362 +    # FIXME: ... or should this include reduced builds..?
   1.363 +    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
   1.364 +  else
   1.365 +    DEFINE_CROSS_COMPILE_ARCH=""
   1.366 +  fi
   1.367 +  AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
   1.368 +
   1.369 +  # ZERO_ARCHDEF is used to enable architecture-specific code
   1.370 +  case "${OPENJDK_TARGET_CPU}" in
   1.371 +    ppc*)    ZERO_ARCHDEF=PPC   ;;
   1.372 +    s390*)   ZERO_ARCHDEF=S390  ;;
   1.373 +    sparc*)  ZERO_ARCHDEF=SPARC ;;
   1.374 +    x86_64*) ZERO_ARCHDEF=AMD64 ;;
   1.375 +    x86)     ZERO_ARCHDEF=IA32  ;;
   1.376 +    *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
   1.377 +  esac
   1.378 +  AC_SUBST(ZERO_ARCHDEF)
   1.379 +])
   1.380 +
   1.381 +AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
   1.382 +[
   1.383 +  if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
   1.384 +    REQUIRED_OS_NAME=SunOS
   1.385 +    REQUIRED_OS_VERSION=5.10
   1.386 +  fi
   1.387 +  if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
   1.388 +    REQUIRED_OS_NAME=Linux
   1.389 +    REQUIRED_OS_VERSION=2.6
   1.390 +  fi
   1.391 +  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.392 +    REQUIRED_OS_NAME=Windows
   1.393 +    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   1.394 +      REQUIRED_OS_VERSION=5.2
   1.395 +    else
   1.396 +      REQUIRED_OS_VERSION=5.1
   1.397 +    fi
   1.398 +  fi
   1.399 +  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   1.400 +    REQUIRED_OS_NAME=Darwin
   1.401 +    REQUIRED_OS_VERSION=11.2
   1.402 +  fi
   1.403 +
   1.404 +  AC_SUBST(REQUIRED_OS_NAME)
   1.405 +  AC_SUBST(REQUIRED_OS_VERSION)
   1.406 +])
   1.407 +
   1.408 +#%%% Build and target systems %%%
   1.409 +AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
   1.410 +[
   1.411 +  # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
   1.412 +  # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
   1.413 +  # product you're building. The target of this build is called "host". Since this is confusing to most people, we
   1.414 +  # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
   1.415 +  # to use the configure naming style.
   1.416 +  AC_CANONICAL_BUILD
   1.417 +  AC_CANONICAL_HOST
   1.418 +  AC_CANONICAL_TARGET
   1.419 +
   1.420 +  PLATFORM_EXTRACT_TARGET_AND_BUILD
   1.421 +  PLATFORM_SETUP_TARGET_CPU_BITS
   1.422 +  PLATFORM_SET_RELEASE_FILE_OS_VALUES
   1.423 +  PLATFORM_SETUP_LEGACY_VARS
   1.424 +])
   1.425 +
   1.426 +AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
   1.427 +[
   1.428 +  ###############################################################################
   1.429 +
   1.430 +  # Note that this is the build platform OS version!
   1.431 +
   1.432 +  OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
   1.433 +  OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
   1.434 +  OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
   1.435 +  OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
   1.436 +  AC_SUBST(OS_VERSION_MAJOR)
   1.437 +  AC_SUBST(OS_VERSION_MINOR)
   1.438 +  AC_SUBST(OS_VERSION_MICRO)
   1.439 +])
   1.440 +
   1.441 +# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
   1.442 +# Add -mX to various FLAGS variables.
   1.443 +AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
   1.444 +[
   1.445 +  # When we add flags to the "official" CFLAGS etc, we need to
   1.446 +  # keep track of these additions in ADDED_CFLAGS etc. These
   1.447 +  # will later be checked to make sure only controlled additions
   1.448 +  # have been made to CFLAGS etc.
   1.449 +  ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   1.450 +  ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   1.451 +  ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   1.452 +
   1.453 +  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
   1.454 +  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
   1.455 +  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
   1.456 +
   1.457 +  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
   1.458 +  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
   1.459 +  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
   1.460 +])
   1.461 +
   1.462 +AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
   1.463 +[
   1.464 +  ###############################################################################
   1.465 +  #
   1.466 +  # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
   1.467 +  # (The JVM can use 32 or 64 bit Java pointers but that decision
   1.468 +  # is made at runtime.)
   1.469 +  #
   1.470 +
   1.471 +  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
   1.472 +    # Always specify -m flag on Solaris
   1.473 +    # And -q on AIX because otherwise the compiler produces 32-bit objects by default
   1.474 +    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   1.475 +  elif test "x$COMPILE_TYPE" = xreduced; then
   1.476 +    if test "x$OPENJDK_TARGET_OS" != xwindows; then
   1.477 +      # Specify -m if running reduced on other Posix platforms
   1.478 +      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   1.479 +    fi
   1.480 +  fi
   1.481 +
   1.482 +  # Make compilation sanity check
   1.483 +  AC_CHECK_HEADERS([stdio.h], , [
   1.484 +    AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
   1.485 +    if test "x$COMPILE_TYPE" = xreduced; then
   1.486 +      AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
   1.487 +    elif test "x$COMPILE_TYPE" = xcross; then
   1.488 +      AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
   1.489 +    fi
   1.490 +    AC_MSG_ERROR([Cannot continue.])
   1.491 +  ])
   1.492 +
   1.493 +  AC_CHECK_SIZEOF([int *], [1111])
   1.494 +
   1.495 +  # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
   1.496 +  if test "x$ac_cv_sizeof_int_p" = x; then
   1.497 +    # The test failed, lets stick to the assumed value.
   1.498 +    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
   1.499 +  else
   1.500 +    TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
   1.501 +
   1.502 +    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
   1.503 +      # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
   1.504 +      # Let's try to implicitely set the compilers target architecture and retry the test
   1.505 +      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).])
   1.506 +      AC_MSG_NOTICE([I'll retry after setting the platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
   1.507 +      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   1.508 +
   1.509 +      # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
   1.510 +      unset ac_cv_sizeof_int_p
   1.511 +      # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
   1.512 +      cat >>confdefs.h <<_ACEOF
   1.513 +#undef SIZEOF_INT_P
   1.514 +_ACEOF
   1.515 +
   1.516 +      AC_CHECK_SIZEOF([int *], [1111])
   1.517 +
   1.518 +      TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
   1.519 +
   1.520 +      if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
   1.521 +        AC_MSG_ERROR([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)])
   1.522 +      fi
   1.523 +    fi
   1.524 +  fi
   1.525 +
   1.526 +  AC_MSG_CHECKING([for target address size])
   1.527 +  AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
   1.528 +])
   1.529 +
   1.530 +AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
   1.531 +[
   1.532 +  ###############################################################################
   1.533 +  #
   1.534 +  # Is the target little of big endian?
   1.535 +  #
   1.536 +  AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
   1.537 +
   1.538 +  if test "x$ENDIAN" = xuniversal_endianness; then
   1.539 +    AC_MSG_ERROR([Building with both big and little endianness is not supported])
   1.540 +  fi
   1.541 +  if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
   1.542 +    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)])
   1.543 +  fi
   1.544 +])

mercurial