platform.m4 revision 1957:34c2b2497b60
119304Speter#
219304Speter# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
319304Speter# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
419304Speter#
519304Speter# This code is free software; you can redistribute it and/or modify it
619304Speter# under the terms of the GNU General Public License version 2 only, as
719304Speter# published by the Free Software Foundation.  Oracle designates this
819304Speter# particular file as subject to the "Classpath" exception as provided
919304Speter# by Oracle in the LICENSE file that accompanied this code.
1019304Speter#
1119304Speter# This code is distributed in the hope that it will be useful, but WITHOUT
1219304Speter# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13254225Speter# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1419304Speter# version 2 for more details (a copy is included in the LICENSE file that
1519304Speter# accompanied this code).
1619304Speter#
1719304Speter# You should have received a copy of the GNU General Public License version
1819304Speter# 2 along with this work; if not, write to the Free Software Foundation,
1919304Speter# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2019304Speter#
2119304Speter# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2219304Speter# or visit www.oracle.com if you need additional information or have any
2319304Speter# questions.
2419304Speter#
2519304Speter
2619304Speter# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
2719304Speter# Converts autoconf style CPU name to OpenJDK style, into
2819304Speter# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
2919304SpeterAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
3019304Speter[
3119304Speter  # First argument is the cpu name from the trip/quad
3219304Speter  case "$1" in
3319304Speter    x86_64)
3419304Speter      VAR_CPU=x86_64
35281373Sbapt      VAR_CPU_ARCH=x86
3619304Speter      VAR_CPU_BITS=64
3719304Speter      VAR_CPU_ENDIAN=little
38254225Speter      ;;
39254225Speter    i?86)
40254225Speter      VAR_CPU=x86
41254225Speter      VAR_CPU_ARCH=x86
4219304Speter      VAR_CPU_BITS=32
4319304Speter      VAR_CPU_ENDIAN=little
4419304Speter      ;;
4519304Speter    arm*)
4619304Speter      VAR_CPU=arm
4719304Speter      VAR_CPU_ARCH=arm
4819304Speter      VAR_CPU_BITS=32
4919304Speter      VAR_CPU_ENDIAN=little
5019304Speter      ;;
5119304Speter    aarch64)
5219304Speter      VAR_CPU=aarch64
5319304Speter      VAR_CPU_ARCH=aarch64
54254225Speter      VAR_CPU_BITS=64
5519304Speter      VAR_CPU_ENDIAN=little
56254225Speter      ;;
5719304Speter    powerpc)
5819304Speter      VAR_CPU=ppc
5919304Speter      VAR_CPU_ARCH=ppc
6019304Speter      VAR_CPU_BITS=32
6119304Speter      VAR_CPU_ENDIAN=big
6219304Speter      ;;
6319304Speter    powerpc64)
64254225Speter      VAR_CPU=ppc64
6519304Speter      VAR_CPU_ARCH=ppc
6619304Speter      VAR_CPU_BITS=64
6719304Speter      VAR_CPU_ENDIAN=big
6819304Speter      ;;
6919304Speter    powerpc64le)
7019304Speter      VAR_CPU=ppc64le
7119304Speter      VAR_CPU_ARCH=ppc
7219304Speter      VAR_CPU_BITS=64
7319304Speter      VAR_CPU_ENDIAN=little
7419304Speter      ;;
7519304Speter    s390)
7619304Speter      VAR_CPU=s390
7719304Speter      VAR_CPU_ARCH=s390
7819304Speter      VAR_CPU_BITS=32
7919304Speter      VAR_CPU_ENDIAN=big
8019304Speter      ;;
8119304Speter    s390x)
8219304Speter      VAR_CPU=s390x
8319304Speter      VAR_CPU_ARCH=s390
84254225Speter      VAR_CPU_BITS=64
8519304Speter      VAR_CPU_ENDIAN=big
8619304Speter      ;;
8719304Speter    sparc)
88254225Speter      VAR_CPU=sparc
8919304Speter      VAR_CPU_ARCH=sparc
9019304Speter      VAR_CPU_BITS=32
9119304Speter      VAR_CPU_ENDIAN=big
92254225Speter      ;;
9319304Speter    sparcv9|sparc64)
9419304Speter      VAR_CPU=sparcv9
9519304Speter      VAR_CPU_ARCH=sparc
9619304Speter      VAR_CPU_BITS=64
9719304Speter      VAR_CPU_ENDIAN=big
9819304Speter      ;;
9919304Speter    *)
10019304Speter      AC_MSG_ERROR([unsupported cpu $1])
10119304Speter      ;;
10219304Speter  esac
10319304Speter])
10419304Speter
10519304Speter# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
10619304Speter# Converts autoconf style OS name to OpenJDK style, into
10719304Speter# VAR_OS, VAR_OS_TYPE and VAR_OS_ENV.
10819304SpeterAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
10919304Speter[
11019304Speter  case "$1" in
11119304Speter    *linux*)
11219304Speter      VAR_OS=linux
11319304Speter      VAR_OS_TYPE=unix
11419304Speter      ;;
11519304Speter    *solaris*)
11619304Speter      VAR_OS=solaris
117254225Speter      VAR_OS_TYPE=unix
118254225Speter      ;;
11919304Speter    *darwin*)
12019304Speter      VAR_OS=macosx
12119304Speter      VAR_OS_TYPE=unix
12219304Speter      ;;
12319304Speter    *bsd*)
12419304Speter      VAR_OS=bsd
12519304Speter      VAR_OS_TYPE=unix
12619304Speter      ;;
12719304Speter    *cygwin*)
12819304Speter      VAR_OS=windows
12919304Speter      VAR_OS_ENV=windows.cygwin
13019304Speter      ;;
13119304Speter    *mingw*)
132281373Sbapt      VAR_OS=windows
13319304Speter      VAR_OS_ENV=windows.msys
13419304Speter      ;;
135254225Speter    *aix*)
13619304Speter      VAR_OS=aix
13719304Speter      VAR_OS_TYPE=unix
13819304Speter      ;;
13919304Speter    *)
14019304Speter      AC_MSG_ERROR([unsupported operating system $1])
14119304Speter      ;;
14219304Speter  esac
14319304Speter])
14419304Speter
14519304Speter# Expects $host_os $host_cpu $build_os and $build_cpu
14619304Speter# and $with_target_bits to have been setup!
14719304Speter#
14819304Speter# Translate the standard triplet(quadruplet) definition
149254225Speter# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
150254225Speter# OPENJDK_BUILD_OS, etc.
15119304SpeterAC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
15219304Speter[
15319304Speter  # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
15419304Speter  # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
15519304Speter  # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
15619304Speter  # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
15719304Speter  OPENJDK_TARGET_AUTOCONF_NAME="$host"
15819304Speter  OPENJDK_BUILD_AUTOCONF_NAME="$build"
15919304Speter  AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
16019304Speter  AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
16119304Speter
16219304Speter  # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
16319304Speter  PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
16419304Speter  PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
16519304Speter  # ..and setup our own variables. (Do this explicitely to facilitate searching)
16619304Speter  OPENJDK_BUILD_OS="$VAR_OS"
16719304Speter  if test "x$VAR_OS_TYPE" != x; then
16819304Speter    OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE"
16919304Speter  else
17019304Speter    OPENJDK_BUILD_OS_TYPE="$VAR_OS"
171254225Speter  fi
172254225Speter  if test "x$VAR_OS_ENV" != x; then
17319304Speter    OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
17419304Speter  else
17519304Speter    OPENJDK_BUILD_OS_ENV="$VAR_OS"
17619304Speter  fi
17719304Speter  OPENJDK_BUILD_CPU="$VAR_CPU"
17819304Speter  OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
17919304Speter  OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
18019304Speter  OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
18119304Speter  AC_SUBST(OPENJDK_BUILD_OS)
18219304Speter  AC_SUBST(OPENJDK_BUILD_OS_TYPE)
18319304Speter  AC_SUBST(OPENJDK_BUILD_OS_ENV)
18419304Speter  AC_SUBST(OPENJDK_BUILD_CPU)
18519304Speter  AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
18619304Speter  AC_SUBST(OPENJDK_BUILD_CPU_BITS)
18719304Speter  AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
18819304Speter
18919304Speter  AC_MSG_CHECKING([openjdk-build os-cpu])
19019304Speter  AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
19119304Speter
192254225Speter  # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
193254225Speter  PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
194254225Speter  PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
19519304Speter  # ... and setup our own variables. (Do this explicitely to facilitate searching)
19619304Speter  OPENJDK_TARGET_OS="$VAR_OS"
19719304Speter  if test "x$VAR_OS_TYPE" != x; then
19819304Speter    OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE"
19919304Speter  else
20019304Speter    OPENJDK_TARGET_OS_TYPE="$VAR_OS"
20119304Speter  fi
20219304Speter  if test "x$VAR_OS_ENV" != x; then
20319304Speter    OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
20419304Speter  else
20519304Speter    OPENJDK_TARGET_OS_ENV="$VAR_OS"
20619304Speter  fi
20719304Speter  OPENJDK_TARGET_CPU="$VAR_CPU"
208281373Sbapt  OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
20919304Speter  OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
21019304Speter  OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
211254225Speter  AC_SUBST(OPENJDK_TARGET_OS)
21219304Speter  AC_SUBST(OPENJDK_TARGET_OS_TYPE)
21319304Speter  AC_SUBST(OPENJDK_TARGET_OS_ENV)
21419304Speter  AC_SUBST(OPENJDK_TARGET_CPU)
21519304Speter  AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
21619304Speter  AC_SUBST(OPENJDK_TARGET_CPU_BITS)
21719304Speter  AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
218254225Speter
21919304Speter  AC_MSG_CHECKING([openjdk-target os-cpu])
22019304Speter  AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
221254225Speter])
22219304Speter
22319304Speter# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
22419304Speter# accordingly. Must be done after setting up build and target system, but before
225254225Speter# doing anything else with these values.
226254225SpeterAC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
227254225Speter[
228254225Speter  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
22919304Speter       [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
23019304Speter
23119304Speter  # We have three types of compiles:
23219304Speter  # native  == normal compilation, target system == build system
233  # cross   == traditional cross compilation, target system != build system; special toolchain needed
234  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
235  #
236  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
237    # We're doing a proper cross-compilation
238    COMPILE_TYPE="cross"
239  else
240    COMPILE_TYPE="native"
241  fi
242
243  if test "x$with_target_bits" != x; then
244    if test "x$COMPILE_TYPE" = "xcross"; then
245      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
246    fi
247
248    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
249      # A reduced build is requested
250      COMPILE_TYPE="reduced"
251      OPENJDK_TARGET_CPU_BITS=32
252      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
253        OPENJDK_TARGET_CPU=x86
254      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
255        OPENJDK_TARGET_CPU=sparc
256      else
257        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
258      fi
259    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
260      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
261    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
262      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
263    else
264      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
265    fi
266  fi
267  AC_SUBST(COMPILE_TYPE)
268
269  AC_MSG_CHECKING([compilation type])
270  AC_MSG_RESULT([$COMPILE_TYPE])
271])
272
273# Setup the legacy variables, for controlling the old makefiles.
274#
275AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
276[
277  # Also store the legacy naming of the cpu.
278  # Ie i586 and amd64 instead of x86 and x86_64
279  OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
280  if test "x$OPENJDK_TARGET_CPU" = xx86; then
281    OPENJDK_TARGET_CPU_LEGACY="i586"
282  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
283    # On all platforms except MacOSX replace x86_64 with amd64.
284    OPENJDK_TARGET_CPU_LEGACY="amd64"
285  fi
286  AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
287
288  # And the second legacy naming of the cpu.
289  # Ie i386 and amd64 instead of x86 and x86_64.
290  OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
291  if test "x$OPENJDK_TARGET_CPU" = xx86; then
292    OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
293  elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
294    OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
295  fi
296  AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
297
298  # This is the name of the cpu (but using i386 and amd64 instead of
299  # x86 and x86_64, respectively), preceeded by a /, to be used when
300  # locating libraries. On macosx, it's empty, though.
301  OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
302  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
303    OPENJDK_TARGET_CPU_LIBDIR=""
304  fi
305  AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
306
307  # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
308  # /amd64 or /sparcv9. This string is appended to some library paths, like this:
309  # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
310  OPENJDK_TARGET_CPU_ISADIR=""
311  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
312    if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
313      OPENJDK_TARGET_CPU_ISADIR="/amd64"
314    elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
315      OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
316    fi
317  fi
318  AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
319
320  # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
321  OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
322  if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
323    # On linux only, we replace x86 with i386.
324    OPENJDK_TARGET_CPU_OSARCH="i386"
325  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
326    # On all platforms except macosx, we replace x86_64 with amd64.
327    OPENJDK_TARGET_CPU_OSARCH="amd64"
328  fi
329  AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
330
331  OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
332  if test "x$OPENJDK_TARGET_CPU" = xx86; then
333    OPENJDK_TARGET_CPU_JLI="i386"
334  elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
335    # On all platforms except macosx, we replace x86_64 with amd64.
336    OPENJDK_TARGET_CPU_JLI="amd64"
337  fi
338  # Now setup the -D flags for building libjli.
339  OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
340  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
341    if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
342      OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
343    elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
344      OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
345    fi
346  fi
347  AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
348
349  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
350      OPENJDK_TARGET_OS_EXPORT_DIR=macosx
351  else
352      OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_TYPE}
353  fi
354  AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR)
355
356  if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
357    A_LP64="LP64:="
358    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
359    # unpack200.exe
360    if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
361      ADD_LP64="-D_LP64=1"
362    fi
363  fi
364  AC_SUBST(LP64,$A_LP64)
365
366  if test "x$COMPILE_TYPE" = "xcross"; then
367    # FIXME: ... or should this include reduced builds..?
368    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
369  else
370    DEFINE_CROSS_COMPILE_ARCH=""
371  fi
372  AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
373
374  # ZERO_ARCHDEF is used to enable architecture-specific code
375  case "${OPENJDK_TARGET_CPU}" in
376    ppc)     ZERO_ARCHDEF=PPC32 ;;
377    ppc64)   ZERO_ARCHDEF=PPC64 ;;
378    s390*)   ZERO_ARCHDEF=S390  ;;
379    sparc*)  ZERO_ARCHDEF=SPARC ;;
380    x86_64*) ZERO_ARCHDEF=AMD64 ;;
381    x86)     ZERO_ARCHDEF=IA32  ;;
382    *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
383  esac
384  AC_SUBST(ZERO_ARCHDEF)
385])
386
387AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
388[
389  if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
390    REQUIRED_OS_NAME=SunOS
391    REQUIRED_OS_VERSION=5.10
392  fi
393  if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
394    REQUIRED_OS_NAME=Linux
395    REQUIRED_OS_VERSION=2.6
396  fi
397  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
398    REQUIRED_OS_NAME=Windows
399    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
400      REQUIRED_OS_VERSION=5.2
401    else
402      REQUIRED_OS_VERSION=5.1
403    fi
404  fi
405  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
406    REQUIRED_OS_NAME=Darwin
407    REQUIRED_OS_VERSION=11.2
408  fi
409  if test "x$OPENJDK_TARGET_OS" = "xaix"; then
410    REQUIRED_OS_NAME=AIX
411    REQUIRED_OS_VERSION=7.1
412  fi
413
414  AC_SUBST(REQUIRED_OS_NAME)
415  AC_SUBST(REQUIRED_OS_VERSION)
416])
417
418#%%% Build and target systems %%%
419AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
420[
421  # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
422  # is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
423  # product you're building. The target of this build is called "host". Since this is confusing to most people, we
424  # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
425  # to use the configure naming style.
426  AC_CANONICAL_BUILD
427  AC_CANONICAL_HOST
428  AC_CANONICAL_TARGET
429
430  PLATFORM_EXTRACT_TARGET_AND_BUILD
431  PLATFORM_SETUP_TARGET_CPU_BITS
432  PLATFORM_SET_RELEASE_FILE_OS_VALUES
433  PLATFORM_SETUP_LEGACY_VARS
434])
435
436AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
437[
438  ###############################################################################
439
440  # Note that this is the build platform OS version!
441
442  OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
443  OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
444  OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
445  OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
446  AC_SUBST(OS_VERSION_MAJOR)
447  AC_SUBST(OS_VERSION_MINOR)
448  AC_SUBST(OS_VERSION_MICRO)
449])
450
451# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
452# Add -mX to various FLAGS variables.
453AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
454[
455  # When we add flags to the "official" CFLAGS etc, we need to
456  # keep track of these additions in ADDED_CFLAGS etc. These
457  # will later be checked to make sure only controlled additions
458  # have been made to CFLAGS etc.
459  ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
460  ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
461  ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
462
463  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
464  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
465  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
466
467  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
468  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
469  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
470])
471
472AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
473[
474  ###############################################################################
475  #
476  # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
477  # (The JVM can use 32 or 64 bit Java pointers but that decision
478  # is made at runtime.)
479  #
480
481  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
482    # Always specify -m flag on Solaris
483    # And -q on AIX because otherwise the compiler produces 32-bit objects by default
484    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
485  elif test "x$COMPILE_TYPE" = xreduced; then
486    if test "x$OPENJDK_TARGET_OS_TYPE" = xunix; then
487      # Specify -m if running reduced on unix platforms
488      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
489    fi
490  fi
491
492  # Make compilation sanity check
493  AC_CHECK_HEADERS([stdio.h], , [
494    AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
495    if test "x$COMPILE_TYPE" = xreduced; then
496      HELP_MSG_MISSING_DEPENDENCY([reduced])
497      AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
498    elif test "x$COMPILE_TYPE" = xcross; then
499      AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
500    fi
501    AC_MSG_ERROR([Cannot continue.])
502  ])
503
504  AC_CHECK_SIZEOF([int *], [1111])
505
506  # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
507  if test "x$ac_cv_sizeof_int_p" = x; then
508    # The test failed, lets stick to the assumed value.
509    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
510  else
511    TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
512
513    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
514      # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
515      # Let's try to implicitely set the compilers target architecture and retry the test
516      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).])
517      AC_MSG_NOTICE([Retrying with platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
518      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
519
520      # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
521      unset ac_cv_sizeof_int_p
522      # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
523      cat >>confdefs.h <<_ACEOF
524#undef SIZEOF_INT_P
525_ACEOF
526
527      AC_CHECK_SIZEOF([int *], [1111])
528
529      TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
530
531      if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
532        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)])
533        if test "x$COMPILE_TYPE" = xreduced; then
534          HELP_MSG_MISSING_DEPENDENCY([reduced])
535          AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
536        elif test "x$COMPILE_TYPE" = xcross; then
537          AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
538        fi
539        AC_MSG_ERROR([Cannot continue.])
540      fi
541    fi
542  fi
543
544  AC_MSG_CHECKING([for target address size])
545  AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
546])
547
548AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
549[
550  ###############################################################################
551  #
552  # Is the target little of big endian?
553  #
554  AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
555
556  if test "x$ENDIAN" = xuniversal_endianness; then
557    AC_MSG_ERROR([Building with both big and little endianness is not supported])
558  fi
559  if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
560    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)])
561  fi
562])
563