platform.m4 revision 693:1dfcc874461e
1158115Sume#
2158115Sume# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3158115Sume# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4158115Sume#
5158115Sume# This code is free software; you can redistribute it and/or modify it
6158115Sume# under the terms of the GNU General Public License version 2 only, as
7158115Sume# published by the Free Software Foundation.  Oracle designates this
8158115Sume# particular file as subject to the "Classpath" exception as provided
9158115Sume# by Oracle in the LICENSE file that accompanied this code.
10158115Sume#
11158115Sume# This code is distributed in the hope that it will be useful, but WITHOUT
12158115Sume# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13158115Sume# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14158115Sume# version 2 for more details (a copy is included in the LICENSE file that
15158115Sume# accompanied this code).
16158115Sume#
17158115Sume# You should have received a copy of the GNU General Public License version
18158115Sume# 2 along with this work; if not, write to the Free Software Foundation,
19158115Sume# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20158115Sume#
21158115Sume# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22158115Sume# or visit www.oracle.com if you need additional information or have any
23158115Sume# questions.
24158115Sume#
25158115Sume
26158115Sume# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
27158115Sume# Converts autoconf style CPU name to OpenJDK style, into
28158115Sume# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
29158115SumeAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
30158115Sume[
31194089Sdes  # First argument is the cpu name from the trip/quad
32158115Sume  case "$1" in
33158115Sume    x86_64)
34194089Sdes      VAR_CPU=x86_64
35158115Sume      VAR_CPU_ARCH=x86
36158115Sume      VAR_CPU_BITS=64
37194089Sdes      VAR_CPU_ENDIAN=little
38158115Sume      ;;
39158115Sume    i?86)
40158115Sume      VAR_CPU=x86
41158115Sume      VAR_CPU_ARCH=x86
42158115Sume      VAR_CPU_BITS=32
43158115Sume      VAR_CPU_ENDIAN=little
44158115Sume      ;;
45158115Sume    arm*)
46158115Sume      VAR_CPU=arm
47158115Sume      VAR_CPU_ARCH=arm
48158115Sume      VAR_CPU_BITS=32
49158115Sume      VAR_CPU_ENDIAN=little
50158115Sume      ;;
51158115Sume    powerpc)
52158115Sume      VAR_CPU=ppc
53158115Sume      VAR_CPU_ARCH=ppc
54158115Sume      VAR_CPU_BITS=32
55158115Sume      VAR_CPU_ENDIAN=big
56158115Sume       ;;
57171795Sbushman    powerpc64)
58158115Sume      VAR_CPU=ppc64
59158115Sume      VAR_CPU_ARCH=ppc
60158115Sume      VAR_CPU_BITS=64
61158115Sume      VAR_CPU_ENDIAN=big
62158115Sume       ;;
63171795Sbushman    sparc)
64158115Sume      VAR_CPU=sparc
65171795Sbushman      VAR_CPU_ARCH=sparc
66158115Sume      VAR_CPU_BITS=32
67158115Sume      VAR_CPU_ENDIAN=big
68158115Sume       ;;
69158115Sume    sparcv9)
70158115Sume      VAR_CPU=sparcv9
71158115Sume      VAR_CPU_ARCH=sparc
72158115Sume      VAR_CPU_BITS=64
73158115Sume      VAR_CPU_ENDIAN=big
74158115Sume       ;;
75158115Sume    *)
76158115Sume      AC_MSG_ERROR([unsupported cpu $1])
77158115Sume      ;;
78158115Sume  esac
79158115Sume])
80158115Sume
81158115Sume# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
82158115Sume# Converts autoconf style OS name to OpenJDK style, into
83158115Sume# VAR_OS and VAR_OS_API.
84158115SumeAC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
85158115Sume[
86158115Sume  case "$1" in
87158115Sume    *linux*)
88158115Sume      VAR_OS=linux
89158115Sume      VAR_OS_API=posix
90158115Sume      VAR_OS_ENV=linux
91158115Sume      ;;
92158115Sume    *solaris*)
93158115Sume      VAR_OS=solaris
94158115Sume      VAR_OS_API=posix
95162891Sru      VAR_OS_ENV=solaris
96171795Sbushman      ;;
97158115Sume    *darwin*)
98158115Sume      VAR_OS=macosx
99158115Sume      VAR_OS_API=posix
100158115Sume      VAR_OS_ENV=macosx
101158115Sume      ;;
102158115Sume    *bsd*)
103158115Sume      VAR_OS=bsd
104158115Sume      VAR_OS_API=posix
105158115Sume      VAR_OS_ENV=bsd
106158115Sume      ;;
107158115Sume    *cygwin*)
108158115Sume      VAR_OS=windows
109158115Sume      VAR_OS_API=winapi
110158115Sume      VAR_OS_ENV=windows.cygwin
111158115Sume      ;;
112158115Sume    *mingw*)
113158115Sume      VAR_OS=windows
114158115Sume      VAR_OS_API=winapi
115158115Sume      VAR_OS_ENV=windows.msys
116158115Sume      ;;
117158115Sume    *)
118158115Sume      AC_MSG_ERROR([unsupported operating system $1])
119158115Sume      ;;
120158115Sume  esac
121158115Sume])
122158115Sume
123158115Sume# Expects $host_os $host_cpu $build_os and $build_cpu
124158115Sume# and $with_target_bits to have been setup!
125158115Sume#
126194097Sdes# Translate the standard triplet(quadruplet) definition
127158115Sume# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
128158115Sume# OPENJDK_BUILD_OS, etc.
129158115SumeAC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
130158115Sume[
131158115Sume    # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
132158115Sume    # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
133194097Sdes    # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
134158115Sume    # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.     
135158115Sume    OPENJDK_TARGET_AUTOCONF_NAME="$host"
136158115Sume    OPENJDK_BUILD_AUTOCONF_NAME="$build"
137158115Sume    AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
138158115Sume    AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
139158115Sume
140158115Sume    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
141158115Sume    PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
142158115Sume    PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
143158115Sume    # ..and setup our own variables. (Do this explicitely to facilitate searching)
144158115Sume    OPENJDK_BUILD_OS="$VAR_OS"
145158115Sume    OPENJDK_BUILD_OS_API="$VAR_OS_API"
146158115Sume    OPENJDK_BUILD_OS_ENV="$VAR_OS_ENV"
147158115Sume    OPENJDK_BUILD_CPU="$VAR_CPU"
148158115Sume    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
149158115Sume    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
150158115Sume    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
151158115Sume    AC_SUBST(OPENJDK_BUILD_OS)
152158115Sume    AC_SUBST(OPENJDK_BUILD_OS_API)
153158115Sume    AC_SUBST(OPENJDK_BUILD_CPU)
154158115Sume    AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
155158115Sume    AC_SUBST(OPENJDK_BUILD_CPU_BITS)
156158115Sume    AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
157158115Sume
158158115Sume    AC_MSG_CHECKING([openjdk-build os-cpu])
159158115Sume    AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
160158115Sume
161158115Sume    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
162158115Sume    PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
163158115Sume    PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
164158115Sume    # ... and setup our own variables. (Do this explicitely to facilitate searching)
165158115Sume    OPENJDK_TARGET_OS="$VAR_OS"
166158115Sume    OPENJDK_TARGET_OS_API="$VAR_OS_API"
167194104Sdes    OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
168158115Sume    OPENJDK_TARGET_CPU="$VAR_CPU"
169158115Sume    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
170158115Sume    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
171158115Sume    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
172158115Sume    AC_SUBST(OPENJDK_TARGET_OS)
173158115Sume    AC_SUBST(OPENJDK_TARGET_OS_API)
174158115Sume    AC_SUBST(OPENJDK_TARGET_CPU)
175158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
176158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_BITS)
177184187Sdelphij    AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
178158115Sume
179158115Sume    AC_MSG_CHECKING([openjdk-target os-cpu])
180158115Sume    AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
181158115Sume])
182158115Sume
183158115Sume# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
184158115Sume# accordingly. Must be done after setting up build and target system, but before
185158115Sume# doing anything else with these values.
186158115SumeAC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
187158115Sume[
188158115Sume  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
189158115Sume     [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
190158115Sume
191158115Sume  # We have three types of compiles:
192158115Sume  # native  == normal compilation, target system == build system
193158115Sume  # cross   == traditional cross compilation, target system != build system; special toolchain needed
194158115Sume  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
195158115Sume  #
196158115Sume  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
197158115Sume    # We're doing a proper cross-compilation
198158115Sume    COMPILE_TYPE="cross"
199158115Sume  else
200158115Sume    COMPILE_TYPE="native"
201158115Sume  fi
202158115Sume
203158115Sume  if test "x$with_target_bits" != x; then
204158115Sume    if test "x$COMPILE_TYPE" = "xcross"; then
205158115Sume      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
206158115Sume    fi
207158115Sume
208158115Sume    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
209158115Sume      # A reduced build is requested
210158115Sume      COMPILE_TYPE="reduced"
211158115Sume      OPENJDK_TARGET_CPU_BITS=32
212158115Sume      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
213158115Sume        OPENJDK_TARGET_CPU=x86
214158115Sume      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
215158115Sume        OPENJDK_TARGET_CPU=sparc
216158115Sume      else
217158115Sume        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
218158115Sume      fi 
219158115Sume    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
220158115Sume      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
221158115Sume    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
222158115Sume      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
223158115Sume    else
224158115Sume      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
225158115Sume    fi
226158115Sume  fi
227158115Sume  AC_SUBST(COMPILE_TYPE)
228158115Sume
229158115SumeAC_MSG_CHECKING([compilation type])
230158115SumeAC_MSG_RESULT([$COMPILE_TYPE])
231158115Sume])
232158115Sume
233158115Sume    # Setup the legacy variables, for controlling the old makefiles.
234158115Sume    #
235158115SumeAC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
236158115Sume[
237158115Sume    # Also store the legacy naming of the cpu.
238158115Sume    # Ie i586 and amd64 instead of x86 and x86_64
239158115Sume    OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
240158115Sume    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
241158115Sume      OPENJDK_TARGET_CPU_LEGACY="i586"
242158115Sume    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
243158115Sume      # On all platforms except MacOSX replace x86_64 with amd64.
244158115Sume      OPENJDK_TARGET_CPU_LEGACY="amd64"
245158115Sume    fi
246158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
247158115Sume
248158115Sume    # And the second legacy naming of the cpu.
249158115Sume    # Ie i386 and amd64 instead of x86 and x86_64.
250158115Sume    OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
251158115Sume    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
252158115Sume      OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
253158115Sume    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
254158115Sume      OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
255158115Sume    fi
256158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
257158115Sume
258158115Sume    # This is the name of the cpu (but using i386 and amd64 instead of
259158115Sume    # x86 and x86_64, respectively), preceeded by a /, to be used when
260158115Sume    # locating libraries. On macosx, it's empty, though.
261158115Sume    OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
262158115Sume    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
263158115Sume        OPENJDK_TARGET_CPU_LIBDIR=""
264158115Sume    fi
265158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
266158115Sume
267158115Sume    # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
268158115Sume    # /amd64 or /sparcv9. This string is appended to some library paths, like this:
269158115Sume    # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
270158115Sume    OPENJDK_TARGET_CPU_ISADIR=""
271158115Sume    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
272158115Sume      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
273158115Sume          OPENJDK_TARGET_CPU_ISADIR="/amd64"
274158115Sume      elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then 
275158115Sume          OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
276158115Sume      fi
277158115Sume    fi
278158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
279158115Sume
280158115Sume    # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
281158115Sume    OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
282158115Sume    if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
283158115Sume      # On linux only, we replace x86 with i386.
284158115Sume      OPENJDK_TARGET_CPU_OSARCH="i386"
285158115Sume    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
286158115Sume      # On all platforms except macosx, we replace x86_64 with amd64.
287158115Sume      OPENJDK_TARGET_CPU_OSARCH="amd64"
288158115Sume    fi
289158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
290158115Sume
291158115Sume    OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
292158115Sume    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
293158115Sume      OPENJDK_TARGET_CPU_JLI="i386"
294158115Sume    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
295158115Sume      # On all platforms except macosx, we replace x86_64 with amd64.
296158115Sume      OPENJDK_TARGET_CPU_JLI="amd64"
297158115Sume    fi
298158115Sume    # Now setup the -D flags for building libjli.
299158115Sume    OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
300158115Sume    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
301158115Sume      if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
302158115Sume        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
303158115Sume      elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 
304158115Sume        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
305158115Sume      fi
306158115Sume    fi
307158115Sume    AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
308158115Sume
309158115Sume    # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
310158115Sume    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
311158115Sume        OPENJDK_TARGET_OS_API_DIR="solaris"
312158115Sume    fi
313158115Sume    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
314158115Sume        OPENJDK_TARGET_OS_API_DIR="windows"
315158115Sume    fi
316158115Sume    AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
317158115Sume
318158115Sume    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
319194096Sdes        A_LP64="LP64:="
320158115Sume        # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in 
321194096Sdes        # unpack200.exe
322158115Sume        if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
323158115Sume            ADD_LP64="-D_LP64=1"
324158115Sume        fi
325158115Sume    fi
326158115Sume    AC_SUBST(LP64,$A_LP64)
327158115Sume
328158115Sume    if test "x$COMPILE_TYPE" = "xcross"; then
329158115Sume      # FIXME: ... or should this include reduced builds..?
330158115Sume      DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
331158115Sume    else
332158115Sume      DEFINE_CROSS_COMPILE_ARCH=""
333158115Sume    fi
334158115Sume    AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
335158115Sume
336158115Sume    # Some Zero and Shark settings.
337158115Sume    # ZERO_ARCHFLAG tells the compiler which mode to build for
338158115Sume    case "${OPENJDK_TARGET_CPU}" in
339158115Sume      s390)
340158115Sume        ZERO_ARCHFLAG="-m31"
341158115Sume        ;;
342158115Sume      *)
343158115Sume        ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
344158115Sume    esac
345158115Sume    PLATFORM_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
346158115Sume    AC_SUBST(ZERO_ARCHFLAG)
347158115Sume
348158115Sume    # ZERO_ARCHDEF is used to enable architecture-specific code
349158115Sume    case "${OPENJDK_TARGET_CPU}" in
350158115Sume      ppc*)    ZERO_ARCHDEF=PPC   ;;
351158115Sume      s390*)   ZERO_ARCHDEF=S390  ;;
352158115Sume      sparc*)  ZERO_ARCHDEF=SPARC ;;
353158115Sume      x86_64*) ZERO_ARCHDEF=AMD64 ;;
354158115Sume      x86)     ZERO_ARCHDEF=IA32  ;;
355158115Sume      *)      ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
356158115Sume    esac
357158115Sume    AC_SUBST(ZERO_ARCHDEF)
358158115Sume
359158115Sume])
360158115Sume
361158115SumeAC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
362158115Sume[
363158115Sume    if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
364158115Sume       REQUIRED_OS_NAME=SunOS
365158115Sume       REQUIRED_OS_VERSION=5.10
366158115Sume    fi
367158115Sume    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
368158115Sume       REQUIRED_OS_NAME=Linux
369158115Sume       REQUIRED_OS_VERSION=2.6
370158115Sume    fi
371158115Sume    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
372158115Sume        REQUIRED_OS_NAME=Windows
373158115Sume        if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
374158115Sume            REQUIRED_OS_VERSION=5.2
375158115Sume        else
376158115Sume            REQUIRED_OS_VERSION=5.1
377158115Sume        fi
378158115Sume    fi
379158115Sume    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
380158115Sume        REQUIRED_OS_NAME=Darwin
381158115Sume        REQUIRED_OS_VERSION=11.2
382158115Sume    fi
383158115Sume
384158115Sume    AC_SUBST(REQUIRED_OS_NAME)
385158115Sume    AC_SUBST(REQUIRED_OS_VERSION)
386158115Sume])
387158115Sume
388158115Sume#%%% Build and target systems %%%
389158115SumeAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
390158115Sume[
391158115Sume# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
392158115Sume# is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
393158115Sume# product you're building. The target of this build is called "host". Since this is confusing to most people, we
394158115Sume# have not adopted that system, but use "target" as the platform we are building for. In some places though we need
395158115Sume# to use the configure naming style.
396158115SumeAC_CANONICAL_BUILD
397158115SumeAC_CANONICAL_HOST
398158115SumeAC_CANONICAL_TARGET
399158115Sume
400158115SumePLATFORM_EXTRACT_TARGET_AND_BUILD
401158115SumePLATFORM_SETUP_TARGET_CPU_BITS
402158115SumePLATFORM_SET_RELEASE_FILE_OS_VALUES
403158115SumePLATFORM_SETUP_LEGACY_VARS
404158115Sume])
405158115Sume
406158115SumeAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
407158115Sume[
408158115Sume###############################################################################
409158115Sume
410158115Sume# Note that this is the build platform OS version!
411194104Sdes
412158115SumeOS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
413158115SumeOS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
414158115SumeOS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
415158115SumeOS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
416158115SumeAC_SUBST(OS_VERSION_MAJOR)
417158115SumeAC_SUBST(OS_VERSION_MINOR)
418158115SumeAC_SUBST(OS_VERSION_MICRO)
419158115Sume])
420158115Sume
421158115Sume# PLATFORM_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
422158115Sume#                                   [RUN-IF-FALSE])
423158115Sume# ------------------------------------------------------------
424158115Sume# Check that the c and c++ compilers support an argument
425158115SumeAC_DEFUN([PLATFORM_COMPILER_CHECK_ARGUMENTS],
426158115Sume[
427158115Sume  AC_MSG_CHECKING([if compiler supports "$1"])
428158115Sume  supports=yes
429158115Sume
430158115Sume  saved_cflags="$CFLAGS"
431158115Sume  CFLAGS="$CFLAGS $1"
432158115Sume  AC_LANG_PUSH([C])
433158115Sume  AC_COMPILE_IFELSE([
434158115Sume    AC_LANG_SOURCE([[int i;]])
435158115Sume  ], [], [supports=no])
436158115Sume  AC_LANG_POP([C])
437158115Sume  CFLAGS="$saved_cflags"
438158115Sume
439158115Sume  saved_cxxflags="$CXXFLAGS"
440158115Sume  CXXFLAGS="$CXXFLAG $1"
441158115Sume  AC_LANG_PUSH([C++])
442158115Sume  AC_COMPILE_IFELSE([
443158115Sume    AC_LANG_SOURCE([[int i;]])
444158115Sume  ], [], [supports=no])
445158115Sume  AC_LANG_POP([C++])
446158115Sume  CXXFLAGS="$saved_cxxflags"
447158115Sume
448158115Sume  AC_MSG_RESULT([$supports])
449158115Sume  if test "x$supports" = "xyes" ; then
450158115Sume    m4_ifval([$2], [$2], [:])
451158115Sume  else
452158115Sume    m4_ifval([$3], [$3], [:])
453158115Sume  fi
454158115Sume])
455158115Sume
456158115Sume# Check that the compiler supports -mX flags
457158115Sume# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
458158115SumeAC_DEFUN([PLATFORM_CHECK_COMPILER_TARGET_BITS_FLAGS],
459158115Sume[
460158115Sume  PLATFORM_COMPILER_CHECK_ARGUMENTS([-m${OPENJDK_TARGET_CPU_BITS}],
461158115Sume    [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
462158115Sume    [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
463158115Sume  AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
464158115Sume])
465158115Sume
466158115Sume# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
467158115Sume# Add -mX to various FLAGS variables.
468158115SumeAC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
469158115Sume[
470158115Sume  # keep track of c/cxx flags that we added outselves...
471158115Sume  #   to prevent emitting warning...
472158115Sume  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
473158115Sume  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
474158115Sume  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
475158115Sume
476158115Sume  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
477158115Sume  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
478158115Sume  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
479158115Sume
480158115Sume  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
481158115Sume  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
482158115Sume  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
483158115Sume])
484158115Sume
485158115SumeAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
486158115Sume[
487158115Sume###############################################################################
488158115Sume#
489158115Sume# Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
490158115Sume# (The JVM can use 32 or 64 bit Java pointers but that decision
491158115Sume# is made at runtime.)
492158115Sume#
493158115Sume
494158115SumePLATFORM_CHECK_COMPILER_TARGET_BITS_FLAGS
495158115Sume
496158115Sumeif test "x$OPENJDK_TARGET_OS" = xsolaris; then
497158115Sume  # Always specify -m flags on Solaris
498158115Sume  PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
499158115Sumeelif test "x$COMPILE_TYPE" = xreduced; then
500158115Sume  if test "x$OPENJDK_TARGET_OS" != xwindows; then
501158115Sume    # Specify -m if running reduced on other Posix platforms
502158115Sume    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
503194096Sdes  fi
504158115Sumefi
505158115Sume
506158115Sume# Make compilation sanity check
507158115SumeAC_CHECK_HEADERS([stdio.h], , [
508158115Sume  AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
509158115Sume  if test "x$COMPILE_TYPE" = xreduced; then
510158115Sume    AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
511158115Sume  elif test "x$COMPILE_TYPE" = xcross; then
512158115Sume    AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
513158115Sume  fi
514158115Sume  AC_MSG_ERROR([Cannot continue.])
515158115Sume])
516158115Sume
517158115SumeAC_CHECK_SIZEOF([int *], [1111])
518158115Sume
519158115Sumeif test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
520158115Sume  # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
521158115Sume  SIZEOF_INT_P="$ac_cv_sizeof_int_p"
522158115Sumefi
523158115Sume
524158115Sumeif test "x$SIZEOF_INT_P" = x; then 
525158115Sume    # The test failed, lets stick to the assumed value.
526158115Sume    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
527158115Sumeelse
528158115Sume    TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
529158115Sume
530158115Sume    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
531158115Sume        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)])
532158115Sume    fi
533158115Sumefi
534158115Sume
535158115SumeAC_MSG_CHECKING([for target address size])
536158115SumeAC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
537158115Sume])
538158115Sume
539158115SumeAC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
540158115Sume[
541158115Sume###############################################################################
542158115Sume#
543158115Sume# Is the target little of big endian?
544158115Sume#
545158115SumeAC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
546158115Sume
547158115Sumeif test "x$ENDIAN" = xuniversal_endianness; then
548158115Sume    AC_MSG_ERROR([Building with both big and little endianness is not supported])
549158115Sumefi
550158115Sumeif test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
551158115Sume    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)])
552158115Sumefi
553158115Sume])
554158115Sume