platform.m4 revision 456:c8d320b48626
1#
2# Copyright (c) 2011, 2012, 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#
25
26AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS],
27[
28    # Expects $host_os $host_cpu $build_os and $build_cpu
29    # and $with_target_bits to have been setup!
30    #
31    # Translate the standard triplet(quadruplet) definition
32    # of the target/build system into
33    # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
34    # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
35    # OPENJDK_TARGET_OS_API=posix,winapi
36    # 
37    # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
38    # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
39    # OPENJDK_TARGET_CPU_BITS=32,64
40    # OPENJDK_TARGET_CPU_ENDIAN=big,little
41    #
42    # The same values are setup for BUILD_...
43    # 
44    # And the legacy variables, for controlling the old makefiles.
45    # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64/x86_64,sparc,sparcv9,arm,arm64...
46    # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,sparc,sparcv9,arm,arm64...
47    # LEGACY_OPENJDK_TARGET_CPU3=sparcv9,amd64 (but only on solaris)
48    # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows
49    #
50    # We also copy the autoconf trip/quadruplet
51    # verbatim to OPENJDK_TARGET_SYSTEM (from the autoconf "host") and OPENJDK_BUILD_SYSTEM
52    OPENJDK_TARGET_SYSTEM="$host"
53    OPENJDK_BUILD_SYSTEM="$build"
54    AC_SUBST(OPENJDK_TARGET_SYSTEM)
55    AC_SUBST(OPENJDK_BUILD_SYSTEM)
56    
57    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_TARGET,$host_os)
58    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_TARGET,$host_cpu)
59
60    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_BUILD,$build_os)
61    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_BUILD,$build_cpu)
62
63    if test "x$OPENJDK_TARGET_OS" != xsolaris; then
64        LEGACY_OPENJDK_TARGET_CPU3=""
65        LEGACY_OPENJDK_BUILD_CPU3=""
66    fi
67
68    # On MacOSX and MacOSX only, we have a different name for the x64 CPU in ARCH (LEGACY_OPENJDK_TARGET_CPU1) ...
69    if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$OPENJDK_TARGET_CPU" = xx64; then
70        LEGACY_OPENJDK_TARGET_CPU1="x86_64"
71    fi
72
73    PLATFORM_SET_RELEASE_FILE_OS_VALUES
74])
75
76AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS_TO],
77[
78    PLATFORM_EXTRACT_VARS_FROM_OS($2)
79    $1_OS="$VAR_OS"
80    $1_OS_FAMILY="$VAR_OS_FAMILY"
81    $1_OS_API="$VAR_OS_API"
82
83    AC_SUBST($1_OS)
84    AC_SUBST($1_OS_FAMILY)
85    AC_SUBST($1_OS_API)
86
87    if test "x$$1_OS_API" = xposix; then
88        LEGACY_$1_OS_API="solaris"
89    fi
90    if test "x$$1_OS_API" = xwinapi; then
91        LEGACY_$1_OS_API="windows"
92    fi
93    AC_SUBST(LEGACY_$1_OS_API)    
94])
95
96AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU_TO],
97[
98    PLATFORM_EXTRACT_VARS_FROM_CPU($2)
99    $1_CPU="$VAR_CPU"
100    $1_CPU_ARCH="$VAR_CPU_ARCH"
101    $1_CPU_BITS="$VAR_CPU_BITS"
102    $1_CPU_ENDIAN="$VAR_CPU_ENDIAN"
103
104    AC_SUBST($1_CPU)
105    AC_SUBST($1_CPU_ARCH)
106    AC_SUBST($1_CPU_BITS)
107    AC_SUBST($1_CPU_ENDIAN)
108    
109    # Also store the legacy naming of the cpu.
110    # Ie i586 and amd64 instead of ia32 and x64
111    LEGACY_$1_CPU1="$VAR_LEGACY_CPU"
112    AC_SUBST(LEGACY_$1_CPU1)
113
114    # And the second legacy naming of the cpu.
115    # Ie i386 and amd64 instead of ia32 and x64.
116    LEGACY_$1_CPU2="$LEGACY_$1_CPU1"
117    if test "x$LEGACY_$1_CPU1" = xi586; then 
118        LEGACY_$1_CPU2=i386
119    fi
120    AC_SUBST(LEGACY_$1_CPU2)
121
122    # And the third legacy naming of the cpu.
123    # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
124    LEGACY_$1_CPU3=""
125    if test "x$$1_CPU" = xx64; then 
126        LEGACY_$1_CPU3=amd64
127    fi
128    if test "x$$1_CPU" = xsparcv9; then 
129        LEGACY_$1_CPU3=sparcv9
130    fi
131    AC_SUBST(LEGACY_$1_CPU3)
132])
133
134AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
135[
136  # First argument is the cpu name from the trip/quad
137  case "$1" in
138    x86_64)
139      VAR_CPU=x64
140      VAR_CPU_ARCH=x86
141      VAR_CPU_BITS=64
142      VAR_CPU_ENDIAN=little
143      VAR_LEGACY_CPU=amd64
144      ;;
145    i?86)
146      VAR_CPU=ia32
147      VAR_CPU_ARCH=x86
148      VAR_CPU_BITS=32
149      VAR_CPU_ENDIAN=little
150      VAR_LEGACY_CPU=i586
151      ;;
152    alpha*)
153      VAR_CPU=alpha
154      VAR_CPU_ARCH=alpha
155      VAR_CPU_BITS=64
156      VAR_CPU_ENDIAN=big
157      VAR_LEGACY_CPU=alpha
158      ;;
159    arm*)
160      VAR_CPU=arm
161      VAR_CPU_ARCH=arm
162      VAR_CPU_BITS=32
163      VAR_CPU_ENDIAN=little
164      VAR_LEGACY_CPU=arm
165      ;;
166    mips)
167      VAR_CPU=mips
168      VAR_CPU_ARCH=mips
169      VAR_CPU_BITS=woot
170      VAR_CPU_ENDIAN=woot
171      VAR_LEGACY_CPU=mips
172       ;;
173    mipsel)
174      VAR_CPU=mipsel
175      VAR_CPU_ARCH=mips
176      VAR_CPU_BITS=woot
177      VAR_CPU_ENDIAN=woot
178      VAR_LEGACY_CPU=mipsel
179       ;;
180    powerpc)
181      VAR_CPU=ppc
182      VAR_CPU_ARCH=ppc
183      VAR_CPU_BITS=32
184      VAR_CPU_ENDIAN=big
185      VAR_LEGACY_CPU=ppc
186       ;;
187    powerpc64)
188      VAR_CPU=ppc64
189      VAR_CPU_ARCH=ppc
190      VAR_CPU_BITS=64
191      VAR_CPU_ENDIAN=big
192      VAR_LEGACY_CPU=ppc64
193       ;;
194    sparc)
195      VAR_CPU=sparc
196      VAR_CPU_ARCH=sparc
197      VAR_CPU_BITS=32
198      VAR_CPU_ENDIAN=big
199      VAR_LEGACY_CPU=sparc
200       ;;
201    sparc64)
202      VAR_CPU=sparcv9
203      VAR_CPU_ARCH=sparc
204      VAR_CPU_BITS=64
205      VAR_CPU_ENDIAN=big
206      VAR_LEGACY_CPU=sparcv9
207       ;;
208    s390)
209      VAR_CPU=s390
210      VAR_CPU_ARCH=s390
211      VAR_CPU_BITS=32
212      VAR_CPU_ENDIAN=woot
213      VAR_LEGACY_CPU=s390
214      VAR_LEGACY_CPU=s390
215       ;;
216    s390x)
217      VAR_CPU=s390x
218      VAR_CPU_ARCH=s390
219      VAR_CPU_BITS=64
220      VAR_CPU_ENDIAN=woot
221      VAR_LEGACY_CPU=s390x
222       ;;
223    *)
224      AC_MSG_ERROR([unsupported cpu $1])
225      ;;
226  esac
227
228  # Workaround cygwin not knowing about 64 bit.
229  if test "x$VAR_OS" = "xwindows"; then
230      if test "x$PROCESSOR_IDENTIFIER" != "x"; then
231          PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
232          case "$PROC_ARCH" in
233            intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
234              VAR_CPU=x64
235              VAR_CPU_BITS=64
236              VAR_LEGACY_CPU=amd64
237              ;;
238          esac
239      fi
240  fi
241
242  # on solaris x86...default seems to be 32-bit
243  if test "x$VAR_OS" = "xsolaris" && \
244     test "x$with_target_bits" = "x" && \
245     test "x$VAR_CPU_ARCH" = "xx86"
246  then
247      with_target_bits=32
248  fi
249
250  if test "x$VAR_CPU_ARCH" = "xx86"; then
251      if test "x$with_target_bits" = "x64"; then
252          VAR_CPU=x64
253          VAR_CPU_BITS=64
254          VAR_LEGACY_CPU=amd64
255      fi
256      if test "x$with_target_bits" = "x32"; then
257          VAR_CPU=ia32
258          VAR_CPU_BITS=32
259          VAR_LEGACY_CPU=i586
260      fi
261  fi 
262
263  if test "x$VAR_CPU_ARCH" = "xsparc"; then
264      if test "x$with_target_bits" = "x64"; then
265          VAR_CPU=sparcv9
266          VAR_CPU_BITS=64
267          VAR_LEGACY_CPU=sparcv9
268      fi
269  fi 
270])
271
272AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
273[
274  case "$1" in
275    *linux*)
276      VAR_OS=linux
277      VAR_OS_API=posix
278      VAR_OS_FAMILY=gnu
279      ;;
280    *solaris*)
281      VAR_OS=solaris
282      VAR_OS_API=posix
283      VAR_OS_FAMILY=sysv
284      ;;
285    *darwin*)
286      VAR_OS=macosx
287      VAR_OS_API=posix
288      VAR_OS_FAMILY=bsd
289      ;;
290    *bsd*)
291      VAR_OS=bsd
292      VAR_OS_API=posix
293      VAR_OS_FAMILY=bsd
294      ;;
295    *cygwin*|*windows*)
296      VAR_OS=windows
297      VAR_OS_API=winapi
298      VAR_OS_FAMILY=windows
299      ;;
300    *)
301      AC_MSG_ERROR([unsupported operating system $1])
302      ;;
303  esac
304])
305
306AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
307[
308    if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
309       REQUIRED_OS_NAME=SunOS
310       REQUIRED_OS_VERSION=5.10
311    fi
312    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
313       REQUIRED_OS_NAME=Linux
314       REQUIRED_OS_VERSION=2.6
315    fi
316    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
317        REQUIRED_OS_NAME=Windows
318        REQUIRED_OS_VERSION=5.1
319    fi
320    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
321        REQUIRED_OS_NAME=Darwin
322        REQUIRED_OS_VERSION=11.2
323    fi
324
325    AC_SUBST(REQUIRED_OS_NAME)
326    AC_SUBST(REQUIRED_OS_VERSION)
327])
328
329#%%% Build and target systems %%%
330AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
331[
332# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
333# is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
334# product you're building. The target of this build is called "host". Since this is confusing to most people, we
335# have not adopted that system, but use "target" as the platform we are building for. In some places though we need
336# to use the configure naming style.
337AC_CANONICAL_BUILD
338AC_CANONICAL_HOST
339AC_CANONICAL_TARGET
340
341AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
342   [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
343
344if test "x$with_target_bits" != x && \
345   test "x$with_target_bits" != x32 && \
346   test "x$with_target_bits" != x64 ; then
347    AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
348fi
349# Translate the standard cpu-vendor-kernel-os quadruplets into
350# the new TARGET_.... and BUILD_... and the legacy names used by
351# the openjdk build.
352# It uses $host_os $host_cpu $build_os $build_cpu and $with_target_bits
353PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS
354
355# The LEGACY_OPENJDK_TARGET_CPU3 is the setting for ISA_DIR.
356if test "x$LEGACY_OPENJDK_TARGET_CPU3" != x; then
357   LEGACY_OPENJDK_TARGET_CPU3="/${LEGACY_OPENJDK_TARGET_CPU3}"
358fi
359
360# Now the following vars are defined.
361# OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
362# OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
363# OPENJDK_TARGET_OS_API=posix,winapi
364#
365# OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
366# OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
367# OPENJDK_TARGET_CPU_BITS=32,64
368# OPENJDK_TARGET_CPU_ENDIAN=big,little
369#
370# There is also a:
371# LEGACY_OPENJDK_TARGET_CPU1=i586,amd64,....  # used to set the old var ARCH
372# LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,.... # used to set the old var LIBARCH
373# LEGACY_OPENJDK_TARGET_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
374# There was also a BUILDARCH that had i486,amd64,... but we do not use that
375# in the new build.
376# LEGACY_OPENJDK_TARGET_OS_API=solaris,windows # used to select source roots
377])
378
379AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
380[
381###############################################################################
382
383# Note that this is the build platform OS version!
384
385OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
386OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
387OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
388OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
389AC_SUBST(OS_VERSION_MAJOR)
390AC_SUBST(OS_VERSION_MINOR)
391AC_SUBST(OS_VERSION_MICRO)
392])
393
394AC_DEFUN_ONCE([PLATFORM_TEST_OPENJDK_TARGET_BITS],
395[
396###############################################################################
397#
398# Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
399# (The JVM can use 32 or 64 bit Java pointers but that decision
400# is made at runtime.)
401#
402AC_LANG_PUSH(C++)
403OLD_CXXFLAGS="$CXXFLAGS"
404if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
405	CXXFLAGS="-m${with_target_bits} $CXXFLAGS"
406fi
407AC_CHECK_SIZEOF([int *], [1111])
408CXXFLAGS="$OLD_CXXFLAGS"
409AC_LANG_POP(C++)
410
411# keep track of c/cxx flags that we added outselves...
412#   to prevent emitting warning...
413ADDED_CFLAGS=
414ADDED_CXXFLAGS=
415ADDED_LDFLAGS=
416
417if test "x$ac_cv_sizeof_int_p" = x0; then 
418    # The test failed, lets pick the assumed value.
419    ARCH_DATA_MODEL=$OPENJDK_TARGET_CPU_BITS
420else
421    ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
422
423    if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
424       ADDED_CFLAGS=" -m${with_target_bits}"
425       ADDED_CXXFLAGS=" -m${with_target_bits}"
426       ADDED_LDFLAGS=" -m${with_target_bits}"
427
428       CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
429       CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
430       LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
431
432       CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
433       CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
434       LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
435    fi
436fi
437
438if test "x$ARCH_DATA_MODEL" = x64; then
439    A_LP64="LP64:="
440    ADD_LP64="-D_LP64=1"
441fi
442AC_MSG_CHECKING([for target address size])
443AC_MSG_RESULT([$ARCH_DATA_MODEL bits])
444AC_SUBST(LP64,$A_LP64)
445AC_SUBST(ARCH_DATA_MODEL)
446
447if test "x$ARCH_DATA_MODEL" != "x$OPENJDK_TARGET_CPU_BITS"; then
448    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)])
449fi
450
451#
452# NOTE: check for -mstackrealign needs to be below potential addition of -m32
453#
454if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
455    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
456    # While waiting for a better solution, the current workaround is to use -mstackrealign.
457    CFLAGS="$CFLAGS -mstackrealign"
458    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
459    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
460                   [
461		        AC_MSG_RESULT([yes])
462                   ],
463	           [
464		        AC_MSG_RESULT([no])
465	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
466	           ])
467fi
468])
469
470AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
471[
472###############################################################################
473#
474# Is the target little of big endian?
475#
476AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
477
478if test "x$ENDIAN" = xuniversal_endianness; then
479    AC_MSG_ERROR([Building with both big and little endianness is not supported])
480fi
481if test "x$ENDIAN" = xunknown; then
482    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
483fi
484if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
485    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)])
486    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
487fi
488AC_SUBST(ENDIAN)
489])
490
491AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ISADIR],
492[
493###############################################################################
494#
495# Could someone enlighten this configure script with a comment about libCrun?
496#
497#
498])
499