common/autoconf/platform.m4
changeset 13697 5262b00bc10c
parent 13132 bd88bb8dd3af
child 14111 2a82ecb35fc7
--- a/common/autoconf/platform.m4	Wed Jul 05 18:22:17 2017 +0200
+++ b/common/autoconf/platform.m4	Tue Sep 18 11:29:16 2012 -0700
@@ -23,279 +23,86 @@
 # questions.
 #
 
-AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS],
-[
-    # Expects $host_os $host_cpu $build_os and $build_cpu
-    # and $with_target_bits to have been setup!
-    #
-    # Translate the standard triplet(quadruplet) definition
-    # of the target/build system into
-    # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-    # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-    # OPENJDK_TARGET_OS_API=posix,winapi
-    # 
-    # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-    # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-    # OPENJDK_TARGET_CPU_BITS=32,64
-    # OPENJDK_TARGET_CPU_ENDIAN=big,little
-    #
-    # The same values are setup for BUILD_...
-    # 
-    # And the legacy variables, for controlling the old makefiles.
-    # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64/x86_64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU3=sparcv9,amd64 (but only on solaris)
-    # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows
-    #
-    # We also copy the autoconf trip/quadruplet
-    # verbatim to OPENJDK_TARGET_SYSTEM (from the autoconf "host") and OPENJDK_BUILD_SYSTEM
-    OPENJDK_TARGET_SYSTEM="$host"
-    OPENJDK_BUILD_SYSTEM="$build"
-    AC_SUBST(OPENJDK_TARGET_SYSTEM)
-    AC_SUBST(OPENJDK_BUILD_SYSTEM)
-    
-    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_TARGET,$host_os)
-    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_TARGET,$host_cpu)
-
-    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_BUILD,$build_os)
-    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_BUILD,$build_cpu)
-
-    if test "x$OPENJDK_TARGET_OS" != xsolaris; then
-        LEGACY_OPENJDK_TARGET_CPU3=""
-        LEGACY_OPENJDK_BUILD_CPU3=""
-    fi
-
-    # On MacOSX and MacOSX only, we have a different name for the x64 CPU in ARCH (LEGACY_OPENJDK_TARGET_CPU1) ...
-    if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$OPENJDK_TARGET_CPU" = xx64; then
-        LEGACY_OPENJDK_TARGET_CPU1="x86_64"
-    fi
-
-    PLATFORM_SET_RELEASE_FILE_OS_VALUES
-])
-
-AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS_TO],
-[
-    PLATFORM_EXTRACT_VARS_FROM_OS($2)
-    $1_OS="$VAR_OS"
-    $1_OS_FAMILY="$VAR_OS_FAMILY"
-    $1_OS_API="$VAR_OS_API"
-
-    AC_SUBST($1_OS)
-    AC_SUBST($1_OS_FAMILY)
-    AC_SUBST($1_OS_API)
-
-    if test "x$$1_OS_API" = xposix; then
-        LEGACY_$1_OS_API="solaris"
-    fi
-    if test "x$$1_OS_API" = xwinapi; then
-        LEGACY_$1_OS_API="windows"
-    fi
-    AC_SUBST(LEGACY_$1_OS_API)    
-])
-
-AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU_TO],
-[
-    PLATFORM_EXTRACT_VARS_FROM_CPU($2)
-    $1_CPU="$VAR_CPU"
-    $1_CPU_ARCH="$VAR_CPU_ARCH"
-    $1_CPU_BITS="$VAR_CPU_BITS"
-    $1_CPU_ENDIAN="$VAR_CPU_ENDIAN"
-
-    AC_SUBST($1_CPU)
-    AC_SUBST($1_CPU_ARCH)
-    AC_SUBST($1_CPU_BITS)
-    AC_SUBST($1_CPU_ENDIAN)
-    
-    # Also store the legacy naming of the cpu.
-    # Ie i586 and amd64 instead of ia32 and x64
-    LEGACY_$1_CPU1="$VAR_LEGACY_CPU"
-    AC_SUBST(LEGACY_$1_CPU1)
-
-    # And the second legacy naming of the cpu.
-    # Ie i386 and amd64 instead of ia32 and x64.
-    LEGACY_$1_CPU2="$LEGACY_$1_CPU1"
-    if test "x$LEGACY_$1_CPU1" = xi586; then 
-        LEGACY_$1_CPU2=i386
-    fi
-    AC_SUBST(LEGACY_$1_CPU2)
-
-    # And the third legacy naming of the cpu.
-    # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
-    LEGACY_$1_CPU3=""
-    if test "x$$1_CPU" = xx64; then 
-        LEGACY_$1_CPU3=amd64
-    fi
-    if test "x$$1_CPU" = xsparcv9; then 
-        LEGACY_$1_CPU3=sparcv9
-    fi
-    AC_SUBST(LEGACY_$1_CPU3)
-])
-
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style CPU name to OpenJDK style, into
+# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
 [
   # First argument is the cpu name from the trip/quad
   case "$1" in
     x86_64)
-      VAR_CPU=x64
+      VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=amd64
       ;;
     i?86)
-      VAR_CPU=ia32
+      VAR_CPU=x86
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=i586
-      ;;
-    alpha*)
-      VAR_CPU=alpha
-      VAR_CPU_ARCH=alpha
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=alpha
       ;;
     arm*)
       VAR_CPU=arm
       VAR_CPU_ARCH=arm
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=arm
       ;;
-    mips)
-      VAR_CPU=mips
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mips
-       ;;
-    mipsel)
-      VAR_CPU=mipsel
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mipsel
-       ;;
     powerpc)
       VAR_CPU=ppc
       VAR_CPU_ARCH=ppc
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc
        ;;
     powerpc64)
       VAR_CPU=ppc64
       VAR_CPU_ARCH=ppc
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc64
        ;;
     sparc)
       VAR_CPU=sparc
       VAR_CPU_ARCH=sparc
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparc
        ;;
-    sparc64)
+    sparcv9)
       VAR_CPU=sparcv9
       VAR_CPU_ARCH=sparc
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparcv9
-       ;;
-    s390)
-      VAR_CPU=s390
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390
-      VAR_LEGACY_CPU=s390
-       ;;
-    s390x)
-      VAR_CPU=s390x
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390x
        ;;
     *)
       AC_MSG_ERROR([unsupported cpu $1])
       ;;
   esac
-
-  # Workaround cygwin not knowing about 64 bit.
-  if test "x$VAR_OS" = "xwindows"; then
-      if test "x$PROCESSOR_IDENTIFIER" != "x"; then
-          PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
-          case "$PROC_ARCH" in
-            intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
-              VAR_CPU=x64
-              VAR_CPU_BITS=64
-              VAR_LEGACY_CPU=amd64
-              ;;
-          esac
-      fi
-  fi
-
-  # on solaris x86...default seems to be 32-bit
-  if test "x$VAR_OS" = "xsolaris" && \
-     test "x$with_target_bits" = "x" && \
-     test "x$VAR_CPU_ARCH" = "xx86"
-  then
-      with_target_bits=32
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xx86"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=x64
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=amd64
-      fi
-      if test "x$with_target_bits" = "x32"; then
-          VAR_CPU=ia32
-          VAR_CPU_BITS=32
-          VAR_LEGACY_CPU=i586
-      fi
-  fi 
-
-  if test "x$VAR_CPU_ARCH" = "xsparc"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=sparcv9
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=sparcv9
-      fi
-  fi 
 ])
 
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style OS name to OpenJDK style, into
+# VAR_OS and VAR_OS_API.
 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
 [
   case "$1" in
     *linux*)
       VAR_OS=linux
       VAR_OS_API=posix
-      VAR_OS_FAMILY=gnu
       ;;
     *solaris*)
       VAR_OS=solaris
       VAR_OS_API=posix
-      VAR_OS_FAMILY=sysv
       ;;
     *darwin*)
       VAR_OS=macosx
       VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
       ;;
     *bsd*)
       VAR_OS=bsd
       VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
       ;;
     *cygwin*|*windows*)
       VAR_OS=windows
       VAR_OS_API=winapi
-      VAR_OS_FAMILY=windows
       ;;
     *)
       AC_MSG_ERROR([unsupported operating system $1])
@@ -303,6 +110,208 @@
   esac
 ])
 
+# Expects $host_os $host_cpu $build_os and $build_cpu
+# and $with_target_bits to have been setup!
+#
+# Translate the standard triplet(quadruplet) definition
+# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
+# OPENJDK_BUILD_OS, etc.
+AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
+[
+    # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
+    # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
+    # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
+    # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.     
+    OPENJDK_TARGET_AUTOCONF_NAME="$host"
+    OPENJDK_BUILD_AUTOCONF_NAME="$build"
+    AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
+    AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+    PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
+    PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
+    # ... and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_TARGET_OS="$VAR_OS"
+    OPENJDK_TARGET_OS_API="$VAR_OS_API"
+    OPENJDK_TARGET_CPU="$VAR_CPU"
+    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+    AC_SUBST(OPENJDK_TARGET_OS)
+    AC_SUBST(OPENJDK_TARGET_OS_API)
+    AC_SUBST(OPENJDK_TARGET_CPU)
+    AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
+    AC_SUBST(OPENJDK_TARGET_CPU_BITS)
+    AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+    PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
+    PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
+    # ..and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_BUILD_OS="$VAR_OS"
+    OPENJDK_BUILD_OS_API="$VAR_OS_API"
+    OPENJDK_BUILD_CPU="$VAR_CPU"
+    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+    AC_SUBST(OPENJDK_BUILD_OS)
+    AC_SUBST(OPENJDK_BUILD_OS_API)
+    AC_SUBST(OPENJDK_BUILD_CPU)
+    AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
+    AC_SUBST(OPENJDK_BUILD_CPU_BITS)
+    AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
+])
+
+# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
+# accordingly. Must be done after setting up build and target system, but before
+# doing anything else with these values.
+AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
+[
+  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
+     [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
+
+  # We have three types of compiles:
+  # native  == normal compilation, target system == build system
+  # cross   == traditional cross compilation, target system != build system; special toolchain needed
+  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
+  #
+  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
+    # We're doing a proper cross-compilation
+    COMPILE_TYPE="cross"
+  else
+    COMPILE_TYPE="native"
+  fi
+
+  if test "x$with_target_bits" != x; then
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
+    fi
+
+    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+      # A reduced build is requested
+      COMPILE_TYPE="reduced"
+      OPENJDK_TARGET_CPU_BITS=32
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
+        OPENJDK_TARGET_CPU=x86
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
+        OPENJDK_TARGET_CPU=sparc
+      else
+        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
+      fi 
+    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
+    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
+      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
+    else
+      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
+    fi
+  fi
+  AC_SUBST(COMPILE_TYPE)
+
+AC_MSG_CHECKING([for compilation type])
+AC_MSG_RESULT([$COMPILE_TYPE])
+])
+
+    # Setup the legacy variables, for controlling the old makefiles.
+    #
+AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
+[
+    # Also store the legacy naming of the cpu.
+    # Ie i586 and amd64 instead of x86 and x86_64
+    OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_LEGACY="i586"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+      # On all platforms except MacOSX replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_LEGACY="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
+
+    # And the second legacy naming of the cpu.
+    # Ie i386 and amd64 instead of x86 and x86_64.
+    OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
+    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+      OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
+
+    # This is the name of the cpu (but using i386 and amd64 instead of
+    # x86 and x86_64, respectively), preceeded by a /, to be used when
+    # locating libraries. On macosx, it's empty, though.
+    OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+        OPENJDK_TARGET_CPU_LIBDIR=""
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
+
+    # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
+    # /amd64 or /sparcv9. This string is appended to some library paths, like this:
+    # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
+    OPENJDK_TARGET_CPU_ISADIR=""
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+          OPENJDK_TARGET_CPU_ISADIR="/amd64"
+      elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then 
+          OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
+      fi
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
+
+    # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
+    OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
+      # On linux only, we replace x86 with i386.
+      OPENJDK_TARGET_CPU_OSARCH="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_OSARCH="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
+
+    OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_JLI="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_JLI="amd64"
+    fi
+    # Now setup the -D flags for building libjli.
+    OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
+      fi
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
+
+    # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
+    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
+        OPENJDK_TARGET_OS_API_DIR="solaris"
+    fi
+    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
+        OPENJDK_TARGET_OS_API_DIR="windows"
+    fi
+    AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        A_LP64="LP64:="
+        ADD_LP64="-D_LP64=1"
+    fi
+    AC_SUBST(LP64,$A_LP64)
+
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      # FIXME: ... or should this include reduced builds..?
+      DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
+    else
+      DEFINE_CROSS_COMPILE_ARCH=""
+    fi
+    AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
+])
+
 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
 [
     if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
@@ -315,7 +324,11 @@
     fi
     if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
         REQUIRED_OS_NAME=Windows
-        REQUIRED_OS_VERSION=5.1
+        if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
+            REQUIRED_OS_VERSION=5.2
+        else
+            REQUIRED_OS_VERSION=5.1
+        fi
     fi
     if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
         REQUIRED_OS_NAME=Darwin
@@ -338,42 +351,10 @@
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
-AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
-   [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
-
-if test "x$with_target_bits" != x && \
-   test "x$with_target_bits" != x32 && \
-   test "x$with_target_bits" != x64 ; then
-    AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
-fi
-# Translate the standard cpu-vendor-kernel-os quadruplets into
-# the new TARGET_.... and BUILD_... and the legacy names used by
-# the openjdk build.
-# It uses $host_os $host_cpu $build_os $build_cpu and $with_target_bits
-PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS
-
-# The LEGACY_OPENJDK_TARGET_CPU3 is the setting for ISA_DIR.
-if test "x$LEGACY_OPENJDK_TARGET_CPU3" != x; then
-   LEGACY_OPENJDK_TARGET_CPU3="/${LEGACY_OPENJDK_TARGET_CPU3}"
-fi
-
-# Now the following vars are defined.
-# OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-# OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-# OPENJDK_TARGET_OS_API=posix,winapi
-#
-# OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-# OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-# OPENJDK_TARGET_CPU_BITS=32,64
-# OPENJDK_TARGET_CPU_ENDIAN=big,little
-#
-# There is also a:
-# LEGACY_OPENJDK_TARGET_CPU1=i586,amd64,....  # used to set the old var ARCH
-# LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,.... # used to set the old var LIBARCH
-# LEGACY_OPENJDK_TARGET_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
-# There was also a BUILDARCH that had i486,amd64,... but we do not use that
-# in the new build.
-# LEGACY_OPENJDK_TARGET_OS_API=solaris,windows # used to select source roots
+PLATFORM_EXTRACT_TARGET_AND_BUILD
+PLATFORM_SETUP_TARGET_CPU_BITS
+PLATFORM_SET_RELEASE_FILE_OS_VALUES
+PLATFORM_SETUP_LEGACY_VARS
 ])
 
 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
@@ -391,7 +372,26 @@
 AC_SUBST(OS_VERSION_MICRO)
 ])
 
-AC_DEFUN_ONCE([PLATFORM_TEST_OPENJDK_TARGET_BITS],
+# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
+# Add -mX to various FLAGS variables.
+AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
+[
+  # keep track of c/cxx flags that we added outselves...
+  #   to prevent emitting warning...
+  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+
+  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
+  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
+  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+
+  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
+  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
+  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+])
+
+AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 [
 ###############################################################################
 #
@@ -399,72 +399,47 @@
 # (The JVM can use 32 or 64 bit Java pointers but that decision
 # is made at runtime.)
 #
-AC_LANG_PUSH(C++)
-OLD_CXXFLAGS="$CXXFLAGS"
-if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-	CXXFLAGS="-m${with_target_bits} $CXXFLAGS"
+if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+  # Always specify -m flags on Solaris
+  PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
+elif test "x$COMPILE_TYPE" = xreduced; then
+  if test "x$OPENJDK_TARGET_OS" != xwindows; then
+    # Specify -m if running reduced on other Posix platforms
+    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
+  fi
 fi
-AC_CHECK_SIZEOF([int *], [1111])
-CXXFLAGS="$OLD_CXXFLAGS"
-AC_LANG_POP(C++)
-
-# keep track of c/cxx flags that we added outselves...
-#   to prevent emitting warning...
-ADDED_CFLAGS=
-ADDED_CXXFLAGS=
-ADDED_LDFLAGS=
 
-if test "x$ac_cv_sizeof_int_p" = x0; then 
-    # The test failed, lets pick the assumed value.
-    ARCH_DATA_MODEL=$OPENJDK_TARGET_CPU_BITS
-else
-    ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
+# Make compilation sanity check
+AC_CHECK_HEADERS([stdio.h], , [
+  AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
+  if test "x$COMPILE_TYPE" = xreduced; then
+    AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
+  elif test "x$COMPILE_TYPE" = xcross; then
+    AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
+  fi
+  AC_MSG_ERROR([Cannot continue.])
+])
+
+AC_CHECK_SIZEOF([int *], [1111])
 
-    if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-       ADDED_CFLAGS=" -m${with_target_bits}"
-       ADDED_CXXFLAGS=" -m${with_target_bits}"
-       ADDED_LDFLAGS=" -m${with_target_bits}"
+if test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
+  # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
+  SIZEOF_INT_P="$ac_cv_sizeof_int_p"
+fi
 
-       CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
-       CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
-       LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+if test "x$SIZEOF_INT_P" = x; then 
+    # The test failed, lets stick to the assumed value.
+    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
+else
+    TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
 
-       CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
-       CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
-       LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
+        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)])
     fi
 fi
 
-if test "x$ARCH_DATA_MODEL" = x64; then
-    A_LP64="LP64:="
-    ADD_LP64="-D_LP64=1"
-fi
 AC_MSG_CHECKING([for target address size])
-AC_MSG_RESULT([$ARCH_DATA_MODEL bits])
-AC_SUBST(LP64,$A_LP64)
-AC_SUBST(ARCH_DATA_MODEL)
-
-if test "x$ARCH_DATA_MODEL" != "x$OPENJDK_TARGET_CPU_BITS"; then
-    AC_MSG_ERROR([The tested number of bits in the target ($ARCH_DATA_MODEL) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
-fi
-
-#
-# NOTE: check for -mstackrealign needs to be below potential addition of -m32
-#
-if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
-    # While waiting for a better solution, the current workaround is to use -mstackrealign.
-    CFLAGS="$CFLAGS -mstackrealign"
-    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
-    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
-                   [
-		        AC_MSG_RESULT([yes])
-                   ],
-	           [
-		        AC_MSG_RESULT([no])
-	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
-	           ])
-fi
+AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
 ])
 
 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
@@ -478,21 +453,7 @@
 if test "x$ENDIAN" = xuniversal_endianness; then
     AC_MSG_ERROR([Building with both big and little endianness is not supported])
 fi
-if test "x$ENDIAN" = xunknown; then
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
+if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
+    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)])
 fi
-if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
-    AC_MSG_WARN([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
-fi
-AC_SUBST(ENDIAN)
 ])
-
-AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ISADIR],
-[
-###############################################################################
-#
-# Could someone enlighten this configure script with a comment about libCrun?
-#
-#
-])