platform.m4 revision 693:1dfcc874461e
150276Speter#
2262685Sdelphij# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
350276Speter# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
450276Speter#
550276Speter# This code is free software; you can redistribute it and/or modify it
650276Speter# under the terms of the GNU General Public License version 2 only, as
750276Speter# published by the Free Software Foundation.  Oracle designates this
850276Speter# particular file as subject to the "Classpath" exception as provided
950276Speter# by Oracle in the LICENSE file that accompanied this code.
1050276Speter#
1150276Speter# This code is distributed in the hope that it will be useful, but WITHOUT
1250276Speter# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1350276Speter# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1450276Speter# version 2 for more details (a copy is included in the LICENSE file that
1550276Speter# accompanied this code).
1650276Speter#
1750276Speter# You should have received a copy of the GNU General Public License version
1850276Speter# 2 along with this work; if not, write to the Free Software Foundation,
1950276Speter# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2050276Speter#
2150276Speter# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2250276Speter# or visit www.oracle.com if you need additional information or have any
2350276Speter# questions.
2450276Speter#
2550276Speter
2650276Speter# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
2750276Speter# Converts autoconf style CPU name to OpenJDK style, into
2850276Speter# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
2950276SpeterAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
3050276Speter[
3150276Speter  # First argument is the cpu name from the trip/quad
32166124Srafan  case "$1" in
3350276Speter    x86_64)
3450276Speter      VAR_CPU=x86_64
3550276Speter      VAR_CPU_ARCH=x86
3650276Speter      VAR_CPU_BITS=64
3750276Speter      VAR_CPU_ENDIAN=little
3850276Speter      ;;
3950276Speter    i?86)
4050276Speter      VAR_CPU=x86
4150276Speter      VAR_CPU_ARCH=x86
4250276Speter      VAR_CPU_BITS=32
43166124Srafan      VAR_CPU_ENDIAN=little
4450276Speter      ;;
4550276Speter    arm*)
4650276Speter      VAR_CPU=arm
4750276Speter      VAR_CPU_ARCH=arm
4850276Speter      VAR_CPU_BITS=32
4950276Speter      VAR_CPU_ENDIAN=little
5050276Speter      ;;
5150276Speter    powerpc)
5250276Speter      VAR_CPU=ppc
5350276Speter      VAR_CPU_ARCH=ppc
5450276Speter      VAR_CPU_BITS=32
5550276Speter      VAR_CPU_ENDIAN=big
5650276Speter       ;;
5750276Speter    powerpc64)
5850276Speter      VAR_CPU=ppc64
5950276Speter      VAR_CPU_ARCH=ppc
6050276Speter      VAR_CPU_BITS=64
6150276Speter      VAR_CPU_ENDIAN=big
6250276Speter       ;;
6350276Speter    sparc)
6450276Speter      VAR_CPU=sparc
6550276Speter      VAR_CPU_ARCH=sparc
6650276Speter      VAR_CPU_BITS=32
6750276Speter      VAR_CPU_ENDIAN=big
6850276Speter       ;;
6950276Speter    sparcv9)
7050276Speter      VAR_CPU=sparcv9
7150276Speter      VAR_CPU_ARCH=sparc
7250276Speter      VAR_CPU_BITS=64
7350276Speter      VAR_CPU_ENDIAN=big
7450276Speter       ;;
7550276Speter    *)
7650276Speter      AC_MSG_ERROR([unsupported cpu $1])
7750276Speter      ;;
7850276Speter  esac
7950276Speter])
8050276Speter
8150276Speter# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
8250276Speter# Converts autoconf style OS name to OpenJDK style, into
8350276Speter# VAR_OS and VAR_OS_API.
8450276SpeterAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
8550276Speter[
8650276Speter  case "$1" in
8750276Speter    *linux*)
8850276Speter      VAR_OS=linux
8950276Speter      VAR_OS_API=posix
9050276Speter      VAR_OS_ENV=linux
9150276Speter      ;;
9250276Speter    *solaris*)
9350276Speter      VAR_OS=solaris
9450276Speter      VAR_OS_API=posix
9550276Speter      VAR_OS_ENV=solaris
96262685Sdelphij      ;;
9750276Speter    *darwin*)
9850276Speter      VAR_OS=macosx
9950276Speter      VAR_OS_API=posix
10050276Speter      VAR_OS_ENV=macosx
10150276Speter      ;;
10250276Speter    *bsd*)
10350276Speter      VAR_OS=bsd
10450276Speter      VAR_OS_API=posix
10550276Speter      VAR_OS_ENV=bsd
10650276Speter      ;;
10750276Speter    *cygwin*)
10850276Speter      VAR_OS=windows
10962449Speter      VAR_OS_API=winapi
11050276Speter      VAR_OS_ENV=windows.cygwin
11150276Speter      ;;
11262449Speter    *mingw*)
11362449Speter      VAR_OS=windows
11450276Speter      VAR_OS_API=winapi
11550276Speter      VAR_OS_ENV=windows.msys
11662449Speter      ;;
117262685Sdelphij    *)
11850276Speter      AC_MSG_ERROR([unsupported operating system $1])
11962449Speter      ;;
12062449Speter  esac
12150276Speter])
12250276Speter
12362449Speter# Expects $host_os $host_cpu $build_os and $build_cpu
12462449Speter# and $with_target_bits to have been setup!
12550276Speter#
126262629Sdelphij# Translate the standard triplet(quadruplet) definition
12762449Speter# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
12862449Speter# OPENJDK_BUILD_OS, etc.
129262629SdelphijAC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
13062449Speter[
131166124Srafan    # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
13262449Speter    # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
13362449Speter    # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
134262685Sdelphij    # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.     
13562449Speter    OPENJDK_TARGET_AUTOCONF_NAME="$host"
13650276Speter    OPENJDK_BUILD_AUTOCONF_NAME="$build"
13750276Speter    AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
138166124Srafan    AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
139166124Srafan
14050276Speter    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
14162449Speter    PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
142166124Srafan    PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
14362449Speter    # ..and setup our own variables. (Do this explicitely to facilitate searching)
14450276Speter    OPENJDK_BUILD_OS="$VAR_OS"
14550276Speter    OPENJDK_BUILD_OS_API="$VAR_OS_API"
14662449Speter    OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
14762449Speter    OPENJDK_BUILD_CPU="$VAR_CPU"
14850276Speter    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
14950276Speter    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
150184989Srafan    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
15150276Speter    AC_SUBST(OPENJDK_BUILD_OS)
15250276Speter    AC_SUBST(OPENJDK_BUILD_OS_API)
15350276Speter    AC_SUBST(OPENJDK_BUILD_CPU)
15450276Speter    AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
15550276Speter    AC_SUBST(OPENJDK_BUILD_CPU_BITS)
15662449Speter    AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
15762449Speter
15850276Speter    AC_MSG_CHECKING([openjdk-build os-cpu])
15950276Speter    AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
16050276Speter
16150276Speter    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
16250276Speter    PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
16350276Speter    PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
16450276Speter    # ... and setup our own variables. (Do this explicitely to facilitate searching)
16562449Speter    OPENJDK_TARGET_OS="$VAR_OS"
16650276Speter    OPENJDK_TARGET_OS_API="$VAR_OS_API"
16750276Speter    OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
16850276Speter    OPENJDK_TARGET_CPU="$VAR_CPU"
16950276Speter    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
17062449Speter    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
17162449Speter    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
17250276Speter    AC_SUBST(OPENJDK_TARGET_OS)
17350276Speter    AC_SUBST(OPENJDK_TARGET_OS_API)
17450276Speter    AC_SUBST(OPENJDK_TARGET_CPU)
17550276Speter    AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
17650276Speter    AC_SUBST(OPENJDK_TARGET_CPU_BITS)
17762449Speter    AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
17850276Speter
17962449Speter    AC_MSG_CHECKING([openjdk-target os-cpu])
18050276Speter    AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
18150276Speter])
18250276Speter
18350276Speter# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
184184989Srafan# accordingly. Must be done after setting up build and target system, but before
18550276Speter# doing anything else with these values.
18650276SpeterAC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
18750276Speter[
18850276Speter  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
18950276Speter     [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
19050276Speter
19150276Speter  # We have three types of compiles:
19250276Speter  # native  == normal compilation, target system == build system
19350276Speter  # cross   == traditional cross compilation, target system != build system; special toolchain needed
19450276Speter  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
19550276Speter  #
19697049Speter  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
197262629Sdelphij    # We're doing a proper cross-compilation
19850276Speter    COMPILE_TYPE="cross"
19950276Speter  else
20050276Speter    COMPILE_TYPE="native"
20150276Speter  fi
202184989Srafan
20350276Speter  if test "x$with_target_bits" != x; then
20450276Speter    if test "x$COMPILE_TYPE" = "xcross"; then
20550276Speter      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
20650276Speter    fi
20750276Speter
208262629Sdelphij    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
20950276Speter      # A reduced build is requested
21050276Speter      COMPILE_TYPE="reduced"
21150276Speter      OPENJDK_TARGET_CPU_BITS=32
212184989Srafan      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
21350276Speter        OPENJDK_TARGET_CPU=x86
21450276Speter      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
21550276Speter        OPENJDK_TARGET_CPU=sparc
21662449Speter      else
21762449Speter        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
21862449Speter      fi 
21950276Speter    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
22062449Speter      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
22150276Speter    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
22262449Speter      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
22350276Speter    else
22462449Speter      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
22562449Speter    fi
22662449Speter  fi
22750276Speter  AC_SUBST(COMPILE_TYPE)
22850276Speter
22950276SpeterAC_MSG_CHECKING([compilation type])
23050276SpeterAC_MSG_RESULT([$COMPILE_TYPE])
23162449Speter])
23262449Speter
23350276Speter    # Setup the legacy variables, for controlling the old makefiles.
23450276Speter    #
23562449SpeterAC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
23662449Speter[
23762449Speter    # Also store the legacy naming of the cpu.
23862449Speter    # Ie i586 and amd64 instead of x86 and x86_64
23962449Speter    OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
24062449Speter    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
241262685Sdelphij      OPENJDK_TARGET_CPU_LEGACY="i586"
242262685Sdelphij    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
243262685Sdelphij      # On all platforms except MacOSX replace x86_64 with amd64.
244262685Sdelphij      OPENJDK_TARGET_CPU_LEGACY="amd64"
245262685Sdelphij    fi
246262685Sdelphij    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
24762449Speter
24862449Speter    # And the second legacy naming of the cpu.
24962449Speter    # Ie i386 and amd64 instead of x86 and x86_64.
25062449Speter    OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
25162449Speter    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
25262449Speter      OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
25362449Speter    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
25450276Speter      OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
25562449Speter    fi
25662449Speter    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
25762449Speter
25862449Speter    # This is the name of the cpu (but using i386 and amd64 instead of
25950276Speter    # x86 and x86_64, respectively), preceeded by a /, to be used when
26062449Speter    # locating libraries. On macosx, it's empty, though.
26150276Speter    OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
26262449Speter    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
26362449Speter        OPENJDK_TARGET_CPU_LIBDIR=""
26462449Speter    fi
26550276Speter    AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
26662449Speter
26762449Speter    # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
26862449Speter    # /amd64 or /sparcv9. This string is appended to some library paths, like this:
26950276Speter    # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
27050276Speter    OPENJDK_TARGET_CPU_ISADIR=""
27176726Speter    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
27276726Speter      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
27376726Speter          OPENJDK_TARGET_CPU_ISADIR="/amd64"
27476726Speter      elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then 
275166124Srafan          OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
27676726Speter      fi
27776726Speter    fi
27876726Speter    AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
279166124Srafan
280166124Srafan    # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
28150276Speter    OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
28250276Speter    if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
28350276Speter      # On linux only, we replace x86 with i386.
28450276Speter      OPENJDK_TARGET_CPU_OSARCH="i386"
28550276Speter    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
28650276Speter      # On all platforms except macosx, we replace x86_64 with amd64.
28750276Speter      OPENJDK_TARGET_CPU_OSARCH="amd64"
28850276Speter    fi
28950276Speter    AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
29050276Speter
29162449Speter    OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
29250276Speter    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
29350276Speter      OPENJDK_TARGET_CPU_JLI="i386"
29450276Speter    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
29550276Speter      # On all platforms except macosx, we replace x86_64 with amd64.
29650276Speter      OPENJDK_TARGET_CPU_JLI="amd64"
297166124Srafan    fi
29862449Speter    # Now setup the -D flags for building libjli.
29997049Speter    OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
30050276Speter    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
30150276Speter      if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
30262449Speter        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
30362449Speter      elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 
30450276Speter        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
30550276Speter      fi
306166124Srafan    fi
30762449Speter    AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
30850276Speter
30950276Speter    # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
31062449Speter    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
31162449Speter        OPENJDK_TARGET_OS_API_DIR="solaris"
31262449Speter    fi
31362449Speter    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
31450276Speter        OPENJDK_TARGET_OS_API_DIR="windows"
31550276Speter    fi
31650276Speter    AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
31750276Speter
31850276Speter    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
31950276Speter        A_LP64="LP64:="
32050276Speter        # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in 
32150276Speter        # unpack200.exe
32250276Speter        if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
32350276Speter            ADD_LP64="-D_LP64=1"
32450276Speter        fi
32550276Speter    fi
32650276Speter    AC_SUBST(LP64,$A_LP64)
32750276Speter
32850276Speter    if test "x$COMPILE_TYPE" = "xcross"; then
32962449Speter      # FIXME: ... or should this include reduced builds..?
33062449Speter      DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
33162449Speter    else
33250276Speter      DEFINE_CROSS_COMPILE_ARCH=""
33350276Speter    fi
33462449Speter    AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
33562449Speter
33662449Speter    # Some Zero and Shark settings.
33762449Speter    # ZERO_ARCHFLAG tells the compiler which mode to build for
33850276Speter    case "${OPENJDK_TARGET_CPU}" in
33950276Speter      s390)
34050276Speter        ZERO_ARCHFLAG="-m31"
34150276Speter        ;;
34262449Speter      *)
34350276Speter        ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
34450276Speter    esac
34550276Speter    PLATFORM_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
34650276Speter    AC_SUBST(ZERO_ARCHFLAG)
34762449Speter
34850276Speter    # ZERO_ARCHDEF is used to enable architecture-specific code
34962449Speter    case "${OPENJDK_TARGET_CPU}" in
35050276Speter      ppc*)    ZERO_ARCHDEF=PPC   ;;
35162449Speter      s390*)   ZERO_ARCHDEF=S390  ;;
35250276Speter      sparc*)  ZERO_ARCHDEF=SPARC ;;
35350276Speter      x86_64*) ZERO_ARCHDEF=AMD64 ;;
35450276Speter      x86)     ZERO_ARCHDEF=IA32  ;;
35576726Speter      *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
35650276Speter    esac
35750276Speter    AC_SUBST(ZERO_ARCHDEF)
35850276Speter
35950276Speter])
36050276Speter
36150276SpeterAC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
36250276Speter[
36350276Speter    if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
36450276Speter       REQUIRED_OS_NAME=SunOS
36550276Speter       REQUIRED_OS_VERSION=5.10
36650276Speter    fi
36750276Speter    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
36850276Speter       REQUIRED_OS_NAME=Linux
36950276Speter       REQUIRED_OS_VERSION=2.6
37050276Speter    fi
37162449Speter    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
37250276Speter        REQUIRED_OS_NAME=Windows
37362449Speter        if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
37450276Speter            REQUIRED_OS_VERSION=5.2
37550276Speter        else
37662449Speter            REQUIRED_OS_VERSION=5.1
37750276Speter        fi
37850276Speter    fi
37962449Speter    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
38050276Speter        REQUIRED_OS_NAME=Darwin
38150276Speter        REQUIRED_OS_VERSION=11.2
38262449Speter    fi
38350276Speter
38450276Speter    AC_SUBST(REQUIRED_OS_NAME)
38550276Speter    AC_SUBST(REQUIRED_OS_VERSION)
38650276Speter])
38750276Speter
38850276Speter#%%% Build and target systems %%%
38950276SpeterAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
39050276Speter[
39150276Speter# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
39262449Speter# is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
39350276Speter# product you're building. The target of this build is called "host". Since this is confusing to most people, we
39450276Speter# have not adopted that system, but use "target" as the platform we are building for. In some places though we need
39550276Speter# to use the configure naming style.
39650276SpeterAC_CANONICAL_BUILD
39750276SpeterAC_CANONICAL_HOST
39850276SpeterAC_CANONICAL_TARGET
39950276Speter
40050276SpeterPLATFORM_EXTRACT_TARGET_AND_BUILD
40162449SpeterPLATFORM_SETUP_TARGET_CPU_BITS
40250276SpeterPLATFORM_SET_RELEASE_FILE_OS_VALUES
40350276SpeterPLATFORM_SETUP_LEGACY_VARS
40450276Speter])
40550276Speter
40662449SpeterAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
40750276Speter[
40850276Speter###############################################################################
40950276Speter
41050276Speter# Note that this is the build platform OS version!
41150276Speter
41250276SpeterOS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
41362449SpeterOS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
41450276SpeterOS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
41550276SpeterOS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
41662449SpeterAC_SUBST(OS_VERSION_MAJOR)
41750276SpeterAC_SUBST(OS_VERSION_MINOR)
41850276SpeterAC_SUBST(OS_VERSION_MICRO)
41950276Speter])
42050276Speter
42150276Speter# PLATFORM_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
42250276Speter#                                   [RUN-IF-FALSE])
42362449Speter# ------------------------------------------------------------
42450276Speter# Check that the c and c++ compilers support an argument
42550276SpeterAC_DEFUN([PLATFORM_COMPILER_CHECK_ARGUMENTS],
42650276Speter[
42750276Speter  AC_MSG_CHECKING([if compiler supports "$1"])
42862449Speter  supports=yes
42950276Speter
43050276Speter  saved_cflags="$CFLAGS"
43162449Speter  CFLAGS="$CFLAGS $1"
43250276Speter  AC_LANG_PUSH([C])
43350276Speter  AC_COMPILE_IFELSE([
43450276Speter    AC_LANG_SOURCE([[int i;]])
43550276Speter  ], [], [supports=no])
43650276Speter  AC_LANG_POP([C])
43750276Speter  CFLAGS="$saved_cflags"
43850276Speter
43962449Speter  saved_cxxflags="$CXXFLAGS"
44050276Speter  CXXFLAGS="$CXXFLAG $1"
44150276Speter  AC_LANG_PUSH([C++])
44262449Speter  AC_COMPILE_IFELSE([
44362449Speter    AC_LANG_SOURCE([[int i;]])
44450276Speter  ], [], [supports=no])
44562449Speter  AC_LANG_POP([C++])
44650276Speter  CXXFLAGS="$saved_cxxflags"
44750276Speter
44850276Speter  AC_MSG_RESULT([$supports])
44950276Speter  if test "x$supports" = "xyes" ; then
45062449Speter    m4_ifval([$2], [$2], [:])
45150276Speter  else
45250276Speter    m4_ifval([$3], [$3], [:])
45350276Speter  fi
45450276Speter])
45550276Speter
45650276Speter# Check that the compiler supports -mX flags
45750276Speter# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
45850276SpeterAC_DEFUN([PLATFORM_CHECK_COMPILER_TARGET_BITS_FLAGS],
45950276Speter[
46062449Speter  PLATFORM_COMPILER_CHECK_ARGUMENTS([-m${OPENJDK_TARGET_CPU_BITS}],
46150276Speter    [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
46262449Speter    [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
46362449Speter  AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
46462449Speter])
46550276Speter
46662449Speter# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
467166124Srafan# Add -mX to various FLAGS variables.
46850276SpeterAC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
46950276Speter[
47050276Speter  # keep track of c/cxx flags that we added outselves...
47150276Speter  #   to prevent emitting warning...
47262449Speter  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
47350276Speter  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
47450276Speter  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
47550276Speter
47650276Speter  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
47750276Speter  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
47850276Speter  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
47950276Speter
48050276Speter  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
48162449Speter  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
48262449Speter  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
48362449Speter])
48497049Speter
48562449SpeterAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
48650276Speter[
48750276Speter###############################################################################
48862449Speter#
48950276Speter# Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
49050276Speter# (The JVM can use 32 or 64 bit Java pointers but that decision
49162449Speter# is made at runtime.)
49262449Speter#
49350276Speter
49450276SpeterPLATFORM_CHECK_COMPILER_TARGET_BITS_FLAGS
49550276Speter
49662449Speterif test "x$OPENJDK_TARGET_OS" = xsolaris; then
49762449Speter  # Always specify -m flags on Solaris
49862449Speter  PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
49962449Speterelif test "x$COMPILE_TYPE" = xreduced; then
50062449Speter  if test "x$OPENJDK_TARGET_OS" != xwindows; then
50162449Speter    # Specify -m if running reduced on other Posix platforms
50262449Speter    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
50362449Speter  fi
50462449Speterfi
50562449Speter
50662449Speter# Make compilation sanity check
50762449SpeterAC_CHECK_HEADERS([stdio.h], , [
50897049Speter  AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
50997049Speter  if test "x$COMPILE_TYPE" = xreduced; then
51062449Speter    AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
51162449Speter  elif test "x$COMPILE_TYPE" = xcross; then
51262449Speter    AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
51362449Speter  fi
51462449Speter  AC_MSG_ERROR([Cannot continue.])
51562449Speter])
516262685Sdelphij
51762449SpeterAC_CHECK_SIZEOF([int *], [1111])
51862449Speter
51962449Speterif test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
52062449Speter  # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
52162449Speter  SIZEOF_INT_P="$ac_cv_sizeof_int_p"
52262449Speterfi
52362449Speter
52462449Speterif test "x$SIZEOF_INT_P" = x; then 
52562449Speter    # The test failed, lets stick to the assumed value.
52662449Speter    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
52762449Speterelse
52862449Speter    TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
52962449Speter
53062449Speter    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
53162449Speter        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)])
53262449Speter    fi
53362449Speterfi
53462449Speter
535262685SdelphijAC_MSG_CHECKING([for target address size])
536262685SdelphijAC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
537262685Sdelphij])
538262685Sdelphij
539262685SdelphijAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
540262685Sdelphij[
541262685Sdelphij###############################################################################
54262449Speter#
54362449Speter# Is the target little of big endian?
54462449Speter#
54562449SpeterAC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
54662449Speter
54762449Speterif test "x$ENDIAN" = xuniversal_endianness; then
54862449Speter    AC_MSG_ERROR([Building with both big and little endianness is not supported])
54962449Speterfi
55062449Speterif test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
55162449Speter    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)])
55262449Speterfi
55362449Speter])
55462449Speter