Tue, 24 Jul 2018 13:19:47 +0800
#6580 added Loongson release info to java -version output
Summary: info includes Loongson OpenJDK version, host name and build OS name
Reviewed-by: zhaixiang
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=ppc64
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_CPU)
195 AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
196 AC_SUBST(OPENJDK_BUILD_CPU_BITS)
197 AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
199 AC_MSG_CHECKING([openjdk-build os-cpu])
200 AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])
202 # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
203 PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
204 PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
205 # ... and setup our own variables. (Do this explicitely to facilitate searching)
206 OPENJDK_TARGET_OS="$VAR_OS"
207 OPENJDK_TARGET_OS_API="$VAR_OS_API"
208 OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
209 OPENJDK_TARGET_CPU="$VAR_CPU"
210 OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
211 OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
212 OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
213 AC_SUBST(OPENJDK_TARGET_OS)
214 AC_SUBST(OPENJDK_TARGET_OS_API)
215 AC_SUBST(OPENJDK_TARGET_CPU)
216 AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
217 AC_SUBST(OPENJDK_TARGET_CPU_BITS)
218 AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
220 AC_MSG_CHECKING([openjdk-target os-cpu])
221 AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
222 ])
224 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
225 # accordingly. Must be done after setting up build and target system, but before
226 # doing anything else with these values.
227 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
228 [
229 AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
230 [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
232 # We have three types of compiles:
233 # native == normal compilation, target system == build system
234 # cross == traditional cross compilation, target system != build system; special toolchain needed
235 # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
236 #
237 if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
238 # We're doing a proper cross-compilation
239 COMPILE_TYPE="cross"
240 else
241 COMPILE_TYPE="native"
242 fi
244 if test "x$with_target_bits" != x; then
245 if test "x$COMPILE_TYPE" = "xcross"; then
246 AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
247 fi
249 if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
250 # A reduced build is requested
251 COMPILE_TYPE="reduced"
252 OPENJDK_TARGET_CPU_BITS=32
253 if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
254 OPENJDK_TARGET_CPU=x86
255 elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
256 OPENJDK_TARGET_CPU=sparc
257 else
258 AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
259 fi
260 elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
261 AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
262 elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
263 AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
264 else
265 AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
266 fi
267 fi
268 AC_SUBST(COMPILE_TYPE)
270 AC_MSG_CHECKING([compilation type])
271 AC_MSG_RESULT([$COMPILE_TYPE])
272 ])
274 # Setup the legacy variables, for controlling the old makefiles.
275 #
276 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
277 [
278 # Also store the legacy naming of the cpu.
279 # Ie i586 and amd64 instead of x86 and x86_64
280 OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
281 if test "x$OPENJDK_TARGET_CPU" = xx86; then
282 OPENJDK_TARGET_CPU_LEGACY="i586"
283 elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
284 # On all platforms except MacOSX replace x86_64 with amd64.
285 OPENJDK_TARGET_CPU_LEGACY="amd64"
286 fi
287 AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
289 # And the second legacy naming of the cpu.
290 # Ie i386 and amd64 instead of x86 and x86_64.
291 OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
292 if test "x$OPENJDK_TARGET_CPU" = xx86; then
293 OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
294 elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
295 OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
296 fi
297 AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
299 # This is the name of the cpu (but using i386 and amd64 instead of
300 # x86 and x86_64, respectively), preceeded by a /, to be used when
301 # locating libraries. On macosx, it's empty, though.
302 OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
303 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
304 OPENJDK_TARGET_CPU_LIBDIR=""
305 fi
306 AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
308 # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
309 # /amd64 or /sparcv9. This string is appended to some library paths, like this:
310 # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
311 OPENJDK_TARGET_CPU_ISADIR=""
312 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
313 if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
314 OPENJDK_TARGET_CPU_ISADIR="/amd64"
315 elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
316 OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
317 fi
318 fi
319 AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
321 # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
322 OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
323 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
324 # On linux only, we replace x86 with i386.
325 OPENJDK_TARGET_CPU_OSARCH="i386"
326 elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
327 # On all platforms except macosx, we replace x86_64 with amd64.
328 OPENJDK_TARGET_CPU_OSARCH="amd64"
329 elif test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xmips64; then
330 # Jin: to be exactly same with OpenJDK 6(mips64)
331 # System.getProperty("os.arch"): mips64 -> mips64el
332 OPENJDK_TARGET_CPU_OSARCH="mips64el"
333 fi
334 AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
336 OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
337 if test "x$OPENJDK_TARGET_CPU" = xx86; then
338 OPENJDK_TARGET_CPU_JLI="i386"
339 elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
340 # On all platforms except macosx, we replace x86_64 with amd64.
341 OPENJDK_TARGET_CPU_JLI="amd64"
342 fi
343 # Now setup the -D flags for building libjli.
344 OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
345 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
346 if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
347 OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
348 elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
349 OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
350 fi
351 fi
352 AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
354 # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
355 if test "x$OPENJDK_TARGET_OS_API" = xposix; then
356 OPENJDK_TARGET_OS_API_DIR="solaris"
357 fi
358 if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
359 OPENJDK_TARGET_OS_API_DIR="windows"
360 fi
361 AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
363 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
364 OPENJDK_TARGET_OS_EXPORT_DIR=macosx
365 else
366 OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_API_DIR}
367 fi
368 AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR)
370 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
371 A_LP64="LP64:="
372 # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
373 # unpack200.exe
374 if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xmacosx; then
375 ADD_LP64="-D_LP64=1"
376 fi
377 fi
378 AC_SUBST(LP64,$A_LP64)
380 if test "x$COMPILE_TYPE" = "xcross"; then
381 # FIXME: ... or should this include reduced builds..?
382 DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
383 else
384 DEFINE_CROSS_COMPILE_ARCH=""
385 fi
386 AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
388 # ZERO_ARCHDEF is used to enable architecture-specific code
389 case "${OPENJDK_TARGET_CPU}" in
390 ppc) ZERO_ARCHDEF=PPC32 ;;
391 ppc64) ZERO_ARCHDEF=PPC64 ;;
392 s390*) ZERO_ARCHDEF=S390 ;;
393 sparc*) ZERO_ARCHDEF=SPARC ;;
394 x86_64*) ZERO_ARCHDEF=AMD64 ;;
395 x86) ZERO_ARCHDEF=IA32 ;;
396 *) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
397 esac
398 AC_SUBST(ZERO_ARCHDEF)
399 ])
401 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
402 [
403 if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
404 REQUIRED_OS_NAME=SunOS
405 REQUIRED_OS_VERSION=5.10
406 fi
407 if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
408 REQUIRED_OS_NAME=Linux
409 REQUIRED_OS_VERSION=2.6
410 fi
411 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
412 REQUIRED_OS_NAME=Windows
413 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
414 REQUIRED_OS_VERSION=5.2
415 else
416 REQUIRED_OS_VERSION=5.1
417 fi
418 fi
419 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
420 REQUIRED_OS_NAME=Darwin
421 REQUIRED_OS_VERSION=11.2
422 fi
424 AC_SUBST(REQUIRED_OS_NAME)
425 AC_SUBST(REQUIRED_OS_VERSION)
426 ])
428 #%%% Build and target systems %%%
429 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET],
430 [
431 # Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
432 # is confusing; it assumes you are cross-compiling a cross-compiler (!) and "target" is thus the target of the
433 # product you're building. The target of this build is called "host". Since this is confusing to most people, we
434 # have not adopted that system, but use "target" as the platform we are building for. In some places though we need
435 # to use the configure naming style.
436 AC_CANONICAL_BUILD
437 AC_CANONICAL_HOST
438 AC_CANONICAL_TARGET
440 PLATFORM_EXTRACT_TARGET_AND_BUILD
441 PLATFORM_SETUP_TARGET_CPU_BITS
442 PLATFORM_SET_RELEASE_FILE_OS_VALUES
443 PLATFORM_SETUP_LEGACY_VARS
444 ])
446 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
447 [
448 ###############################################################################
450 # Note that this is the build platform OS version!
452 OS_VERSION="`uname -r | ${SED} 's!\.! !g' | ${SED} 's!-! !g'`"
453 OS_VERSION_MAJOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 1 -d ' '`"
454 OS_VERSION_MINOR="`${ECHO} ${OS_VERSION} | ${CUT} -f 2 -d ' '`"
455 OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`"
456 AC_SUBST(OS_VERSION_MAJOR)
457 AC_SUBST(OS_VERSION_MINOR)
458 AC_SUBST(OS_VERSION_MICRO)
459 ])
461 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
462 # Add -mX to various FLAGS variables.
463 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
464 [
465 # When we add flags to the "official" CFLAGS etc, we need to
466 # keep track of these additions in ADDED_CFLAGS etc. These
467 # will later be checked to make sure only controlled additions
468 # have been made to CFLAGS etc.
469 ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
470 ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
471 ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
473 CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
474 CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
475 LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
477 CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
478 CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
479 LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
480 ])
482 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
483 [
484 ###############################################################################
485 #
486 # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
487 # (The JVM can use 32 or 64 bit Java pointers but that decision
488 # is made at runtime.)
489 #
491 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
492 # Always specify -m flag on Solaris
493 # And -q on AIX because otherwise the compiler produces 32-bit objects by default
494 PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
495 elif test "x$COMPILE_TYPE" = xreduced; then
496 if test "x$OPENJDK_TARGET_OS" != xwindows; then
497 # Specify -m if running reduced on other Posix platforms
498 PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
499 fi
500 fi
502 # Make compilation sanity check
503 AC_CHECK_HEADERS([stdio.h], , [
504 AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
505 if test "x$COMPILE_TYPE" = xreduced; then
506 AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
507 elif test "x$COMPILE_TYPE" = xcross; then
508 AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
509 fi
510 AC_MSG_ERROR([Cannot continue.])
511 ])
513 AC_CHECK_SIZEOF([int *], [1111])
515 # AC_CHECK_SIZEOF defines 'ac_cv_sizeof_int_p' to hold the number of bytes used by an 'int*'
516 if test "x$ac_cv_sizeof_int_p" = x; then
517 # The test failed, lets stick to the assumed value.
518 AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
519 else
520 TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
522 if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
523 # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
524 # Let's try to implicitely set the compilers target architecture and retry the test
525 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).])
526 AC_MSG_NOTICE([I'll retry after setting the platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
527 PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
529 # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
530 unset ac_cv_sizeof_int_p
531 # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
532 cat >>confdefs.h <<_ACEOF
533 #undef SIZEOF_INT_P
534 _ACEOF
536 AC_CHECK_SIZEOF([int *], [1111])
538 TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
540 if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
541 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)])
542 fi
543 fi
544 fi
546 AC_MSG_CHECKING([for target address size])
547 AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
548 ])
550 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
551 [
552 ###############################################################################
553 #
554 # Is the target little of big endian?
555 #
556 AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
558 if test "x$ENDIAN" = xuniversal_endianness; then
559 AC_MSG_ERROR([Building with both big and little endianness is not supported])
560 fi
561 if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
562 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)])
563 fi
564 ])
566 AC_DEFUN([GET_BUILDER_AND_HOST_DATA],
567 [
568 BUILDER_NAME="$build_os"
569 BUILDER_ID="Custom build ($(date))"
570 if test -f /etc/issue; then
571 etc_issue_info=`cat /etc/issue`
572 if test -n "$etc_issue_info"; then
573 BUILDER_NAME=`cat /etc/issue | head -n 1 | cut -d " " -f 1`
574 fi
575 fi
576 if test -f /etc/neokylin-release; then
577 etc_issue_info=`cat /etc/neokylin-release`
578 if test -n "$etc_issue_info"; then
579 BUILDER_NAME=`cat /etc/neokylin-release | head -n 1 | cut -d " " -f 1`
580 fi
581 fi
582 if test -z "$BUILDER_NAME"; then
583 BUILDER_NAME="unknown"
584 fi
585 if test -n "$OPENJDK_TARGET_CPU_OSARCH"; then
586 HOST_NAME="$OPENJDK_TARGET_CPU_OSARCH"
587 else
588 HOST_NAME="unknown"
589 fi
590 if test -f "/usr/bin/cpp"; then
591 # gcc_with_arch_info=`gcc -v 2>&1 | grep '\-\-with-arch=' | sed 's/.*--with-arch=//;s/ .*$//'`
592 gcc_with_arch_info=`cpp -dM /dev/null | grep '\<_MIPS_ARCH\>' | sed 's/^#define _MIPS_ARCH "//;s/"$//'`
593 if test -n "$gcc_with_arch_info"; then
594 HOST_NAME="$gcc_with_arch_info"
595 fi
596 fi
597 AC_SUBST(BUILDER_ID)
598 AC_SUBST(BUILDER_NAME)
599 AC_SUBST(HOST_NAME)
600 ])