common/autoconf/platform.m4

Thu, 04 Apr 2019 17:59:06 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:59:06 +0800
changeset 2384
b45bf475c2ca
parent 2325
a5b23c21a665
parent 2316
64a3eeabf6e5
permissions
-rw-r--r--

Merge

     1 #
     2 # Copyright (c) 2011, 2015, 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 #
    26 #
    27 # This file has been modified by Loongson Technology in 2018. These
    28 # modifications are Copyright (c) 2018 Loongson Technology, and are made
    29 # available on the same license terms set forth above.
    30 #
    32 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
    33 # Converts autoconf style CPU name to OpenJDK style, into
    34 # VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
    35 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
    36 [
    37   # First argument is the cpu name from the trip/quad
    38   case "$1" in
    39     x86_64)
    40       VAR_CPU=x86_64
    41       VAR_CPU_ARCH=x86
    42       VAR_CPU_BITS=64
    43       VAR_CPU_ENDIAN=little
    44       ;;
    45     i?86)
    46       VAR_CPU=x86
    47       VAR_CPU_ARCH=x86
    48       VAR_CPU_BITS=32
    49       VAR_CPU_ENDIAN=little
    50       ;;
    51     arm*)
    52       VAR_CPU=arm
    53       VAR_CPU_ARCH=arm
    54       VAR_CPU_BITS=32
    55       VAR_CPU_ENDIAN=little
    56       ;;
    57     aarch64)
    58       VAR_CPU=aarch64
    59       VAR_CPU_ARCH=aarch64
    60       VAR_CPU_BITS=64
    61       VAR_CPU_ENDIAN=little
    62       ;;
    63     powerpc)
    64       VAR_CPU=ppc
    65       VAR_CPU_ARCH=ppc
    66       VAR_CPU_BITS=32
    67       VAR_CPU_ENDIAN=big
    68       ;;
    69     powerpc64)
    70       VAR_CPU=ppc64
    71       VAR_CPU_ARCH=ppc
    72       VAR_CPU_BITS=64
    73       VAR_CPU_ENDIAN=big
    74       ;;
    75     powerpc64le)
    76       VAR_CPU=ppc64le
    77       VAR_CPU_ARCH=ppc
    78       VAR_CPU_BITS=64
    79       VAR_CPU_ENDIAN=little
    80       ;;
    81     s390)
    82       VAR_CPU=s390
    83       VAR_CPU_ARCH=s390
    84       VAR_CPU_BITS=32
    85       VAR_CPU_ENDIAN=big
    86       ;;
    87     s390x)
    88       VAR_CPU=s390x
    89       VAR_CPU_ARCH=s390
    90       VAR_CPU_BITS=64
    91       VAR_CPU_ENDIAN=big
    92       ;;
    93     sparc)
    94       VAR_CPU=sparc
    95       VAR_CPU_ARCH=sparc
    96       VAR_CPU_BITS=32
    97       VAR_CPU_ENDIAN=big
    98       ;;
    99     sparcv9|sparc64)
   100       VAR_CPU=sparcv9
   101       VAR_CPU_ARCH=sparc
   102       VAR_CPU_BITS=64
   103       VAR_CPU_ENDIAN=big
   104       ;;
   105     mips64el)
   106       VAR_CPU=mips64
   107       VAR_CPU_ARCH=mips
   108       VAR_CPU_BITS=64
   109       VAR_CPU_ENDIAN=little
   110       ;;
   111     *)
   112       AC_MSG_ERROR([unsupported cpu $1])
   113       ;;
   114   esac
   115 ])
   117 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
   118 # Converts autoconf style OS name to OpenJDK style, into
   119 # VAR_OS and VAR_OS_API.
   120 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
   121 [
   122   case "$1" in
   123     *linux*)
   124       VAR_OS=linux
   125       VAR_OS_API=posix
   126       VAR_OS_ENV=linux
   127       ;;
   128     *solaris*)
   129       VAR_OS=solaris
   130       VAR_OS_API=posix
   131       VAR_OS_ENV=solaris
   132       ;;
   133     *darwin*)
   134       VAR_OS=macosx
   135       VAR_OS_API=posix
   136       VAR_OS_ENV=macosx
   137       ;;
   138     *bsd*)
   139       VAR_OS=bsd
   140       VAR_OS_API=posix
   141       VAR_OS_ENV=bsd
   142       ;;
   143     *cygwin*)
   144       VAR_OS=windows
   145       VAR_OS_API=winapi
   146       VAR_OS_ENV=windows.cygwin
   147       ;;
   148     *mingw*)
   149       VAR_OS=windows
   150       VAR_OS_API=winapi
   151       VAR_OS_ENV=windows.msys
   152       ;;
   153     *aix*)
   154       VAR_OS=aix
   155       VAR_OS_API=posix
   156       VAR_OS_ENV=aix
   157       ;;
   158     *)
   159       AC_MSG_ERROR([unsupported operating system $1])
   160       ;;
   161   esac
   162 ])
   164 # Expects $host_os $host_cpu $build_os and $build_cpu
   165 # and $with_target_bits to have been setup!
   166 #
   167 # Translate the standard triplet(quadruplet) definition
   168 # of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
   169 # OPENJDK_BUILD_OS, etc.
   170 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
   171 [
   172   # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
   173   # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
   174   # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
   175   # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
   176   OPENJDK_TARGET_AUTOCONF_NAME="$host"
   177   OPENJDK_BUILD_AUTOCONF_NAME="$build"
   178   AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
   179   AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
   181   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
   182   PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
   183   PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
   184   # ..and setup our own variables. (Do this explicitely to facilitate searching)
   185   OPENJDK_BUILD_OS="$VAR_OS"
   186   OPENJDK_BUILD_OS_API="$VAR_OS_API"
   187   OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
   188   OPENJDK_BUILD_CPU="$VAR_CPU"
   189   OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
   190   OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
   191   OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
   192   AC_SUBST(OPENJDK_BUILD_OS)
   193   AC_SUBST(OPENJDK_BUILD_OS_API)
   194   AC_SUBST(OPENJDK_BUILD_OS_ENV)
   195   AC_SUBST(OPENJDK_BUILD_CPU)
   196   AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
   197   AC_SUBST(OPENJDK_BUILD_CPU_BITS)
   198   AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
   200   AC_MSG_CHECKING([openjdk-build os-cpu])
   201   AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
   203   # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
   204   PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
   205   PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
   206   # ... and setup our own variables. (Do this explicitely to facilitate searching)
   207   OPENJDK_TARGET_OS="$VAR_OS"
   208   OPENJDK_TARGET_OS_API="$VAR_OS_API"
   209   OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
   210   OPENJDK_TARGET_CPU="$VAR_CPU"
   211   OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
   212   OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
   213   OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
   214   AC_SUBST(OPENJDK_TARGET_OS)
   215   AC_SUBST(OPENJDK_TARGET_OS_API)
   216   AC_SUBST(OPENJDK_TARGET_OS_ENV)
   217   AC_SUBST(OPENJDK_TARGET_CPU)
   218   AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
   219   AC_SUBST(OPENJDK_TARGET_CPU_BITS)
   220   AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
   222   AC_MSG_CHECKING([openjdk-target os-cpu])
   223   AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
   224 ])
   226 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
   227 # accordingly. Must be done after setting up build and target system, but before
   228 # doing anything else with these values.
   229 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
   230 [
   231   AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
   232        [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
   234   # We have three types of compiles:
   235   # native  == normal compilation, target system == build system
   236   # cross   == traditional cross compilation, target system != build system; special toolchain needed
   237   # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
   238   #
   239   if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
   240     # We're doing a proper cross-compilation
   241     COMPILE_TYPE="cross"
   242   else
   243     COMPILE_TYPE="native"
   244   fi
   246   if test "x$with_target_bits" != x; then
   247     if test "x$COMPILE_TYPE" = "xcross"; then
   248       AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
   249     fi
   251     if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   252       # A reduced build is requested
   253       COMPILE_TYPE="reduced"
   254       OPENJDK_TARGET_CPU_BITS=32
   255       if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
   256         OPENJDK_TARGET_CPU=x86
   257       elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
   258         OPENJDK_TARGET_CPU=sparc
   259       else
   260         AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
   261       fi
   262     elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
   263       AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
   264     elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
   265       AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
   266     else
   267       AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
   268     fi
   269   fi
   270   AC_SUBST(COMPILE_TYPE)
   272   AC_MSG_CHECKING([compilation type])
   273   AC_MSG_RESULT([$COMPILE_TYPE])
   274 ])
   276 # Setup the legacy variables, for controlling the old makefiles.
   277 #
   278 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
   279 [
   280   # Also store the legacy naming of the cpu.
   281   # Ie i586 and amd64 instead of x86 and x86_64
   282   OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
   283   if test "x$OPENJDK_TARGET_CPU" = xx86; then
   284     OPENJDK_TARGET_CPU_LEGACY="i586"
   285   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   286     # On all platforms except MacOSX replace x86_64 with amd64.
   287     OPENJDK_TARGET_CPU_LEGACY="amd64"
   288   fi
   289   AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
   291   # And the second legacy naming of the cpu.
   292   # Ie i386 and amd64 instead of x86 and x86_64.
   293   OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
   294   if test "x$OPENJDK_TARGET_CPU" = xx86; then
   295     OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
   296   elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   297     OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
   298   elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   299     OPENJDK_TARGET_CPU_LEGACY_LIB="mips64el"
   300   fi
   301   AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
   303   # This is the name of the cpu (but using i386 and amd64 instead of
   304   # x86 and x86_64, respectively), preceeded by a /, to be used when
   305   # locating libraries. On macosx, it's empty, though.
   306   OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
   307   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   308     OPENJDK_TARGET_CPU_LIBDIR=""
   309   fi
   310   AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
   312   # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
   313   # /amd64 or /sparcv9. This string is appended to some library paths, like this:
   314   # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
   315   OPENJDK_TARGET_CPU_ISADIR=""
   316   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   317     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   318       OPENJDK_TARGET_CPU_ISADIR="/amd64"
   319     elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
   320       OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
   321     fi
   322   fi
   323   AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
   325   # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
   326   OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
   327   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
   328     # On linux only, we replace x86 with i386.
   329     OPENJDK_TARGET_CPU_OSARCH="i386"
   330   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   331     # On all platforms except macosx, we replace x86_64 with amd64.
   332     OPENJDK_TARGET_CPU_OSARCH="amd64"
   333   elif test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   334     # Jin: to be exactly same with OpenJDK 6(mips64)
   335     # System.getProperty("os.arch"): mips64 -> mips64el
   336     OPENJDK_TARGET_CPU_OSARCH="mips64el"
   337   fi
   338   AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
   340   OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
   341   if test "x$OPENJDK_TARGET_CPU" = xx86; then
   342     OPENJDK_TARGET_CPU_JLI="i386"
   343   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
   344     # On all platforms except macosx, we replace x86_64 with amd64.
   345     OPENJDK_TARGET_CPU_JLI="amd64"
   346   elif test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   347     OPENJDK_TARGET_CPU_JLI="mips64el"
   348   fi
   349   # Now setup the -D flags for building libjli.
   350   OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
   351   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   352     if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
   353       OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
   354     elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
   355       OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
   356     fi
   357   fi
   358   if test "x$OPENJDK_TARGET_CPU" = xmips64 && test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   359     OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"mips32el\"' -DLIBARCH64NAME='\"mips64el\"'"
   360   fi
   361   AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
   363   # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
   364   if test "x$OPENJDK_TARGET_OS_API" = xposix; then
   365     OPENJDK_TARGET_OS_API_DIR="solaris"
   366   fi
   367   if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
   368     OPENJDK_TARGET_OS_API_DIR="windows"
   369   fi
   370   AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
   372   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   373       OPENJDK_TARGET_OS_EXPORT_DIR=macosx
   374   else
   375       OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_API_DIR}
   376   fi
   377   AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR)
   379   if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   380     A_LP64="LP64:="
   381     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
   382     # unpack200.exe
   383     if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
   384       ADD_LP64="-D_LP64=1"
   385     fi
   386   fi
   387   AC_SUBST(LP64,$A_LP64)
   389   if test "x$COMPILE_TYPE" = "xcross"; then
   390     # FIXME: ... or should this include reduced builds..?
   391     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
   392   else
   393     DEFINE_CROSS_COMPILE_ARCH=""
   394   fi
   395   AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
   397   # ZERO_ARCHDEF is used to enable architecture-specific code
   398   case "${OPENJDK_TARGET_CPU}" in
   399     ppc)     ZERO_ARCHDEF=PPC32 ;;
   400     ppc64)   ZERO_ARCHDEF=PPC64 ;;
   401     s390*)   ZERO_ARCHDEF=S390  ;;
   402     sparc*)  ZERO_ARCHDEF=SPARC ;;
   403     x86_64*) ZERO_ARCHDEF=AMD64 ;;
   404     x86)     ZERO_ARCHDEF=IA32  ;;
   405     *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
   406   esac
   407   AC_SUBST(ZERO_ARCHDEF)
   408 ])
   410 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
   411 [
   412   if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
   413     REQUIRED_OS_NAME=SunOS
   414     REQUIRED_OS_VERSION=5.10
   415   fi
   416   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
   417     REQUIRED_OS_NAME=Linux
   418     REQUIRED_OS_VERSION=2.6
   419   fi
   420   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   421     REQUIRED_OS_NAME=Windows
   422     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   423       REQUIRED_OS_VERSION=5.2
   424     else
   425       REQUIRED_OS_VERSION=5.1
   426     fi
   427   fi
   428   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   429     REQUIRED_OS_NAME=Darwin
   430     REQUIRED_OS_VERSION=11.2
   431   fi
   433   AC_SUBST(REQUIRED_OS_NAME)
   434   AC_SUBST(REQUIRED_OS_VERSION)
   435 ])
   437 #%%% Build and target systems %%%
   438 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
   439 [
   440   # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
   441   # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
   442   # product you're building. The target of this build is called "host". Since this is confusing to most people, we
   443   # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
   444   # to use the configure naming style.
   445   AC_CANONICAL_BUILD
   446   AC_CANONICAL_HOST
   447   AC_CANONICAL_TARGET
   449   PLATFORM_EXTRACT_TARGET_AND_BUILD
   450   PLATFORM_SETUP_TARGET_CPU_BITS
   451   PLATFORM_SET_RELEASE_FILE_OS_VALUES
   452   PLATFORM_SETUP_LEGACY_VARS
   453 ])
   455 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
   456 [
   457   ###############################################################################
   459   # Note that this is the build platform OS version!
   461   OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
   462   OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
   463   OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
   464   OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
   465   AC_SUBST(OS_VERSION_MAJOR)
   466   AC_SUBST(OS_VERSION_MINOR)
   467   AC_SUBST(OS_VERSION_MICRO)
   468 ])
   470 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
   471 # Add -mX to various FLAGS variables.
   472 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
   473 [
   474   # When we add flags to the "official" CFLAGS etc, we need to
   475   # keep track of these additions in ADDED_CFLAGS etc. These
   476   # will later be checked to make sure only controlled additions
   477   # have been made to CFLAGS etc.
   478   ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   479   ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   480   ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   482   CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
   483   CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
   484   LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
   486   CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
   487   CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
   488   LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
   489 ])
   491 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
   492 [
   493   ###############################################################################
   494   #
   495   # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
   496   # (The JVM can use 32 or 64 bit Java pointers but that decision
   497   # is made at runtime.)
   498   #
   500   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
   501     # Always specify -m flag on Solaris
   502     # And -q on AIX because otherwise the compiler produces 32-bit objects by default
   503     PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   504   elif test "x$COMPILE_TYPE" = xreduced; then
   505     if test "x$OPENJDK_TARGET_OS" != xwindows; then
   506       # Specify -m if running reduced on other Posix platforms
   507       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   508     fi
   509   fi
   511   # Make compilation sanity check
   512   AC_CHECK_HEADERS([stdio.h], , [
   513     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
   514     if test "x$COMPILE_TYPE" = xreduced; then
   515       AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
   516     elif test "x$COMPILE_TYPE" = xcross; then
   517       AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
   518     fi
   519     AC_MSG_ERROR([Cannot continue.])
   520   ])
   522   AC_CHECK_SIZEOF([int *], [1111])
   524   # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
   525   if test "x$ac_cv_sizeof_int_p" = x; then
   526     # The test failed, lets stick to the assumed value.
   527     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
   528   else
   529     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
   531     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
   532       # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
   533       # Let's try to implicitely set the compilers target architecture and retry the test
   534       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).])
   535       AC_MSG_NOTICE([I'll retry after setting the platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
   536       PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   538       # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
   539       unset ac_cv_sizeof_int_p
   540       # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
   541       cat >>confdefs.h <<_ACEOF
   542 #undef SIZEOF_INT_P
   543 _ACEOF
   545       AC_CHECK_SIZEOF([int *], [1111])
   547       TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
   549       if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
   550         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)])
   551       fi
   552     fi
   553   fi
   555   AC_MSG_CHECKING([for target address size])
   556   AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
   557 ])
   559 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
   560 [
   561   ###############################################################################
   562   #
   563   # Is the target little of big endian?
   564   #
   565   AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
   567   if test "x$ENDIAN" = xuniversal_endianness; then
   568     AC_MSG_ERROR([Building with both big and little endianness is not supported])
   569   fi
   570   if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
   571     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)])
   572   fi
   573 ])
   575 AC_DEFUN([GET_BUILDER_AND_HOST_DATA],
   576 [
   577 BUILDER_NAME="$build_os"
   578 BUILDER_ID="Custom build ($(date))"
   579 if test -f /etc/issue; then
   580   etc_issue_info=`cat /etc/issue`
   581   if test -n "$etc_issue_info"; then
   582     BUILDER_NAME=`cat /etc/issue | head -n 1 | cut -d " " -f 1`
   583   fi
   584 fi
   585 if test -f /etc/redhat-release; then
   586   etc_issue_info=`cat /etc/redhat-release`
   587   if test -n "$etc_issue_info"; then
   588     BUILDER_NAME=`cat /etc/redhat-release | head -n 1 | cut -d " " -f 1`
   589   fi
   590 fi
   591 if test -f /etc/neokylin-release; then
   592   etc_issue_info=`cat /etc/neokylin-release`
   593   if test -n "$etc_issue_info"; then
   594     BUILDER_NAME=`cat /etc/neokylin-release | head -n 1 | cut -d " " -f 1`
   595   fi
   596 fi
   597 if test -z "$BUILDER_NAME"; then
   598   BUILDER_NAME="unknown"
   599 fi
   600 if test -n "$OPENJDK_TARGET_CPU_OSARCH"; then
   601   HOST_NAME="$OPENJDK_TARGET_CPU_OSARCH"
   602 else
   603   HOST_NAME="unknown"
   604 fi
   605 if test -f "/usr/bin/cpp"; then
   606   # gcc_with_arch_info=`gcc -v 2>&1 | grep '\-\-with-arch=' | sed 's/.*--with-arch=//;s/ .*$//'`
   607   gcc_with_arch_info=`cpp -dM /dev/null | grep '\<_MIPS_ARCH\>' | sed 's/^#define _MIPS_ARCH "//;s/"$//'`
   608   if test -n "$gcc_with_arch_info"; then
   609     HOST_NAME="$gcc_with_arch_info"
   610   fi
   611 fi
   612 AC_SUBST(BUILDER_ID)
   613 AC_SUBST(BUILDER_NAME)
   614 AC_SUBST(HOST_NAME)
   615 ])

mercurial