common/autoconf/toolchain.m4

Mon, 16 Oct 2017 15:57:35 +0800

author
aoqi
date
Mon, 16 Oct 2017 15:57:35 +0800
changeset 1482
8fb429038513
parent 1404
17e06bbf496e
parent 1133
50aaf272884f
child 2003
2224002fc647
permissions
-rw-r--r--

merge

aoqi@0 1 #
ddehaven@1304 2 # Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 # $1 = compiler to test (CC or CXX)
aoqi@0 27 # $2 = human readable name of compiler (C or C++)
aoqi@0 28 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
aoqi@0 29 [
aoqi@0 30 COMPILER=[$]$1
aoqi@0 31 COMPILER_NAME=$2
aoqi@0 32
aoqi@0 33 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 34 # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
aoqi@0 35 COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
aoqi@0 36 $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
aoqi@0 37 if test $? -ne 0; then
aoqi@0 38 GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
aoqi@0 39
aoqi@0 40 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
aoqi@0 41 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
aoqi@0 42 AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
aoqi@0 43 else
aoqi@0 44 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
aoqi@0 45 COMPILER_VENDOR="Sun Studio"
aoqi@0 46 fi
aoqi@0 47 elif test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 48 COMPILER_VERSION_TEST=`$COMPILER -qversion 2>&1 | $TAIL -n 1`
aoqi@0 49 $ECHO $COMPILER_VERSION_TEST | $GREP "^Version: " > /dev/null
aoqi@0 50 if test $? -ne 0; then
aoqi@0 51 AC_MSG_ERROR([Failed to detect the compiler version of $COMPILER ....])
aoqi@0 52 else
aoqi@0 53 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n 's/Version: \([0-9][0-9]\.[0-9][0-9]*\).*/\1/p'`
aoqi@0 54 COMPILER_VENDOR='IBM'
aoqi@0 55 fi
aoqi@0 56 elif test "x$OPENJDK_TARGET_OS" = xwindows; then
aoqi@0 57 # First line typically looks something like:
aoqi@0 58 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
aoqi@0 59 COMPILER_VERSION_TEST=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
aoqi@0 60 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*Version \(@<:@1-9@:>@@<:@0-9.@:>@*\) .*/\1/p"`
aoqi@0 61 COMPILER_VENDOR="Microsoft CL.EXE"
aoqi@0 62 COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"`
aoqi@0 63 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
aoqi@0 64 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
aoqi@0 65 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
aoqi@0 66 fi
aoqi@0 67 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
aoqi@0 68 if test "x$COMPILER_CPU_TEST" != "xx64"; then
aoqi@0 69 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
aoqi@0 70 fi
aoqi@0 71 fi
aoqi@0 72 else
aoqi@0 73 COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
aoqi@0 74 # Check that this is likely to be GCC.
aoqi@0 75 $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
aoqi@0 76 if test $? -ne 0; then
aoqi@0 77 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
aoqi@0 78 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
aoqi@0 79 AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
aoqi@0 80 fi
aoqi@0 81
aoqi@0 82 # First line typically looks something like:
aoqi@0 83 # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
aoqi@0 84 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
aoqi@0 85 COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
aoqi@0 86 fi
aoqi@0 87 # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
aoqi@0 88 $1_VERSION="$COMPILER_VERSION"
aoqi@0 89 # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker)
aoqi@0 90 $1_VENDOR="$COMPILER_VENDOR"
aoqi@0 91
aoqi@0 92 AC_MSG_NOTICE([Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)])
aoqi@0 93 ])
aoqi@0 94
aoqi@0 95
aoqi@0 96 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
aoqi@0 97 [
aoqi@0 98 ###############################################################################
aoqi@0 99 #
aoqi@0 100 # Configure the development tool paths and potential sysroot.
aoqi@0 101 #
aoqi@0 102 AC_LANG(C++)
aoqi@0 103
aoqi@0 104 # The option used to specify the target .o,.a or .so file.
aoqi@0 105 # When compiling, how to specify the to be created object file.
aoqi@0 106 CC_OUT_OPTION='-o$(SPACE)'
aoqi@0 107 # When linking, how to specify the to be created executable.
aoqi@0 108 EXE_OUT_OPTION='-o$(SPACE)'
aoqi@0 109 # When linking, how to specify the to be created dynamically linkable library.
aoqi@0 110 LD_OUT_OPTION='-o$(SPACE)'
aoqi@0 111 # When archiving, how to specify the to be create static archive for object files.
aoqi@0 112 AR_OUT_OPTION='rcs$(SPACE)'
aoqi@0 113 AC_SUBST(CC_OUT_OPTION)
aoqi@0 114 AC_SUBST(EXE_OUT_OPTION)
aoqi@0 115 AC_SUBST(LD_OUT_OPTION)
aoqi@0 116 AC_SUBST(AR_OUT_OPTION)
aoqi@0 117 ])
aoqi@0 118
aoqi@0 119 # $1 = compiler to test (CC or CXX)
aoqi@0 120 # $2 = human readable name of compiler (C or C++)
aoqi@0 121 # $3 = list of compiler names to search for
aoqi@0 122 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
aoqi@0 123 [
aoqi@0 124 COMPILER_NAME=$2
aoqi@0 125
aoqi@0 126 $1=
aoqi@0 127 # If TOOLS_DIR is set, check for all compiler names in there first
aoqi@0 128 # before checking the rest of the PATH.
aoqi@0 129 if test -n "$TOOLS_DIR"; then
aoqi@0 130 PATH_save="$PATH"
aoqi@0 131 PATH="$TOOLS_DIR"
aoqi@0 132 AC_PATH_PROGS(TOOLS_DIR_$1, $3)
aoqi@0 133 $1=$TOOLS_DIR_$1
aoqi@0 134 PATH="$PATH_save"
aoqi@0 135 fi
aoqi@0 136
aoqi@0 137 # AC_PATH_PROGS can't be run multiple times with the same variable,
aoqi@0 138 # so create a new name for this run.
aoqi@0 139 if test "x[$]$1" = x; then
aoqi@0 140 AC_PATH_PROGS(POTENTIAL_$1, $3)
aoqi@0 141 $1=$POTENTIAL_$1
aoqi@0 142 fi
aoqi@0 143
aoqi@0 144 if test "x[$]$1" = x; then
aoqi@0 145 HELP_MSG_MISSING_DEPENDENCY([devkit])
aoqi@0 146 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
aoqi@0 147 fi
aoqi@0 148 BASIC_FIXUP_EXECUTABLE($1)
aoqi@0 149 TEST_COMPILER="[$]$1"
aoqi@0 150 # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
aoqi@0 151 # to 'xlc' but it is crucial that we invoke the compiler with the right name!
aoqi@0 152 if test "x$OPENJDK_BUILD_OS" != xaix; then
aoqi@0 153 AC_MSG_CHECKING([resolved symbolic links for $1])
aoqi@0 154 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
aoqi@0 155 AC_MSG_RESULT([$TEST_COMPILER])
aoqi@0 156 fi
aoqi@0 157 AC_MSG_CHECKING([if $1 is disguised ccache])
aoqi@0 158
aoqi@0 159 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
aoqi@0 160 if test "x$COMPILER_BASENAME" = "xccache"; then
aoqi@0 161 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
aoqi@0 162 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
aoqi@0 163 # We want to control ccache invocation ourselves, so ignore this cc and try
aoqi@0 164 # searching again.
aoqi@0 165
aoqi@0 166 # Remove the path to the fake ccache cc from the PATH
aoqi@0 167 RETRY_COMPILER_SAVED_PATH="$PATH"
aoqi@0 168 COMPILER_DIRNAME=`$DIRNAME [$]$1`
aoqi@0 169 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
aoqi@0 170
aoqi@0 171 # Try again looking for our compiler
aoqi@0 172 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
aoqi@0 173 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
aoqi@0 174 PATH="$RETRY_COMPILER_SAVED_PATH"
aoqi@0 175
aoqi@0 176 AC_MSG_CHECKING([for resolved symbolic links for $1])
aoqi@0 177 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
aoqi@0 178 AC_MSG_RESULT([$PROPER_COMPILER_$1])
aoqi@0 179 $1="$PROPER_COMPILER_$1"
aoqi@0 180 else
aoqi@0 181 AC_MSG_RESULT([no, keeping $1])
aoqi@0 182 $1="$TEST_COMPILER"
aoqi@0 183 fi
aoqi@0 184 TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
aoqi@0 185 ])
aoqi@0 186
aoqi@0 187
aoqi@0 188 AC_DEFUN([TOOLCHAIN_SETUP_PATHS],
aoqi@0 189 [
aoqi@0 190 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 191 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
aoqi@0 192 TOOLCHAIN_SETUP_MSVCR_DLL
aoqi@0 193 BASIC_DEPRECATED_ARG_WITH([dxsdk])
aoqi@0 194 BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
aoqi@0 195 BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
aoqi@0 196 fi
aoqi@0 197
aoqi@0 198 AC_SUBST(MSVCR_DLL)
aoqi@0 199
aoqi@0 200 # If --build AND --host is set, then the configure script will find any
aoqi@0 201 # cross compilation tools in the PATH. Cross compilation tools
aoqi@0 202 # follows the cross compilation standard where they are prefixed with ${host}.
aoqi@0 203 # For example the binary i686-sun-solaris2.10-gcc
aoqi@0 204 # will cross compile for i686-sun-solaris2.10
aoqi@0 205 # If neither of build and host is not set, then build=host and the
aoqi@0 206 # default compiler found in the path will be used.
aoqi@0 207 # Setting only --host, does not seem to be really supported.
aoqi@0 208 # Please set both --build and --host if you want to cross compile.
aoqi@0 209
aoqi@0 210 if test "x$COMPILE_TYPE" = "xcross"; then
aoqi@0 211 # Now we to find a C/C++ compiler that can build executables for the build
aoqi@0 212 # platform. We can't use the AC_PROG_CC macro, since it can only be used
aoqi@0 213 # once. Also, we need to do this before adding a tools dir to the path,
aoqi@0 214 # otherwise we might pick up cross-compilers which don't use standard naming.
aoqi@0 215 # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
aoqi@0 216 # to wait until they are properly discovered.
aoqi@0 217 AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
aoqi@0 218 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
aoqi@0 219 AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
aoqi@0 220 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
aoqi@0 221 AC_PATH_PROG(BUILD_LD, ld)
aoqi@0 222 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
aoqi@0 223 fi
aoqi@0 224 AC_SUBST(BUILD_CC)
aoqi@0 225 AC_SUBST(BUILD_CXX)
aoqi@0 226 AC_SUBST(BUILD_LD)
aoqi@0 227
aoqi@0 228 # If a devkit is found on the builddeps server, then prepend its path to the
aoqi@0 229 # PATH variable. If there are cross compilers available in the devkit, these
aoqi@0 230 # will be found by AC_PROG_CC et al.
aoqi@0 231 DEVKIT=
aoqi@0 232 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
aoqi@0 233 [
aoqi@0 234 # Found devkit
aoqi@0 235 PATH="$DEVKIT/bin:$PATH"
aoqi@0 236 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
aoqi@0 237 if test "x$x_includes" = "xNONE"; then
aoqi@0 238 x_includes="$SYS_ROOT/usr/include/X11"
aoqi@0 239 fi
aoqi@0 240 if test "x$x_libraries" = "xNONE"; then
aoqi@0 241 x_libraries="$SYS_ROOT/usr/lib"
aoqi@0 242 fi
aoqi@0 243 ],
aoqi@0 244 [])
aoqi@0 245
aoqi@0 246 # Store the CFLAGS etal passed to the configure script.
aoqi@0 247 ORG_CFLAGS="$CFLAGS"
aoqi@0 248 ORG_CXXFLAGS="$CXXFLAGS"
aoqi@0 249 ORG_OBJCFLAGS="$OBJCFLAGS"
aoqi@0 250
aoqi@0 251 # autoconf magic only relies on PATH, so update it if tools dir is specified
aoqi@0 252 OLD_PATH="$PATH"
aoqi@0 253 if test "x$TOOLS_DIR" != x; then
aoqi@0 254 PATH=$TOOLS_DIR:$PATH
aoqi@0 255 fi
aoqi@0 256
ddehaven@1304 257 # Before we locate the compilers, we need to sanitize the Xcode build environment
ddehaven@1304 258 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
ddehaven@1304 259 # determine path to Xcode developer directory
ddehaven@1304 260 # can be empty in which case all the tools will rely on a sane Xcode 4 installation
ddehaven@1304 261 SET_DEVELOPER_DIR=
ddehaven@1304 262
ddehaven@1304 263 if test -n "$XCODE_PATH"; then
ddehaven@1304 264 DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
ddehaven@1304 265 fi
ddehaven@1304 266
ddehaven@1304 267 # DEVELOPER_DIR could also be provided directly
ddehaven@1304 268 AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
ddehaven@1304 269 if test -n "$DEVELOPER_DIR"; then
ddehaven@1304 270 if test ! -d "$DEVELOPER_DIR"; then
ddehaven@1304 271 AC_MSG_ERROR([Xcode Developer path does not exist: $DEVELOPER_DIR, please provide a path to the Xcode 4 application bundle using --with-xcode-path])
ddehaven@1304 272 fi
ddehaven@1304 273 if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
ddehaven@1304 274 AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
ddehaven@1304 275 fi
ddehaven@1304 276 # make it visible to all the tools immediately
ddehaven@1304 277 export DEVELOPER_DIR
ddehaven@1304 278 SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
ddehaven@1304 279 AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
ddehaven@1304 280 else
ddehaven@1304 281 AC_MSG_RESULT([no])
ddehaven@1304 282 fi
ddehaven@1304 283 AC_SUBST(SET_DEVELOPER_DIR)
ddehaven@1304 284
ddehaven@1304 285 AC_PATH_PROG(XCODEBUILD, xcodebuild)
ddehaven@1304 286 if test -z "$XCODEBUILD"; then
ddehaven@1304 287 AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
ddehaven@1304 288 fi
ddehaven@1304 289
ddehaven@1304 290 # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
ddehaven@1304 291 XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
ddehaven@1304 292 XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
ddehaven@1304 293 if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
ddehaven@1304 294 AC_MSG_ERROR([Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.])
ddehaven@1304 295 fi
ddehaven@1304 296
ddehaven@1304 297 # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
ddehaven@1304 298 # clang and clang++, which will break the build. So handle that here if we need to.
ddehaven@1304 299 if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
ddehaven@1304 300 # use xcrun to find the real gcc and add it's directory to PATH
ddehaven@1304 301 # then autoconf magic will find it
ddehaven@1304 302 AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
ddehaven@1304 303 XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
ddehaven@1304 304 PATH="$XCODE_BIN_PATH":$PATH
ddehaven@1304 305 fi
ddehaven@1304 306
ddehaven@1304 307 # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
ddehaven@1304 308 AC_MSG_CHECKING([Determining Xcode SDK path])
ddehaven@1304 309 # allow SDKNAME to be set to override the default SDK selection
ddehaven@1304 310 SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
ddehaven@1304 311 if test -n "$SDKPATH"; then
ddehaven@1304 312 AC_MSG_RESULT([$SDKPATH])
ddehaven@1304 313 else
ddehaven@1304 314 AC_MSG_RESULT([(none, will use system headers and frameworks)])
ddehaven@1304 315 fi
ddehaven@1304 316 AC_SUBST(SDKPATH)
ddehaven@1304 317
ddehaven@1304 318 # Perform a basic sanity test
ddehaven@1304 319 if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
ddehaven@1304 320 AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
ddehaven@1304 321 fi
ddehaven@1304 322
ddehaven@1304 323 # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
ddehaven@1304 324 if test -n "$SDKPATH"; then
ddehaven@1304 325 # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
ddehaven@1304 326 CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 327 CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 328 LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
ddehaven@1304 329 fi
ddehaven@1304 330
ddehaven@1304 331 # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
ddehaven@1304 332 # setting this here means it doesn't have to be peppered throughout the forest
ddehaven@1304 333 CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 334 CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 335 LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
ddehaven@1304 336 fi
aoqi@0 337
aoqi@0 338 ### Locate C compiler (CC)
aoqi@0 339
aoqi@0 340 # On windows, only cl.exe is supported.
aoqi@0 341 # On Solaris, cc is preferred to gcc.
aoqi@0 342 # Elsewhere, gcc is preferred to cc.
aoqi@0 343
aoqi@0 344 if test "x$CC" != x; then
aoqi@0 345 COMPILER_CHECK_LIST="$CC"
aoqi@0 346 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 347 COMPILER_CHECK_LIST="cl"
aoqi@0 348 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
aoqi@0 349 COMPILER_CHECK_LIST="cc gcc"
aoqi@0 350 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
aoqi@0 351 # Do not probe for cc on AIX.
aoqi@0 352 COMPILER_CHECK_LIST="xlc_r"
aoqi@0 353 else
aoqi@0 354 COMPILER_CHECK_LIST="gcc cc"
aoqi@0 355 fi
aoqi@0 356
aoqi@0 357 TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
aoqi@0 358 # Now that we have resolved CC ourself, let autoconf have its go at it
aoqi@0 359 AC_PROG_CC([$CC])
aoqi@0 360
aoqi@0 361 # Option used to tell the compiler whether to create 32- or 64-bit executables
aoqi@0 362 # Notice that CC contains the full compiler path at this point.
aoqi@0 363 case $CC in
aoqi@0 364 *xlc_r) COMPILER_TARGET_BITS_FLAG="-q";;
aoqi@0 365 *) COMPILER_TARGET_BITS_FLAG="-m";;
aoqi@0 366 esac
aoqi@0 367 AC_SUBST(COMPILER_TARGET_BITS_FLAG)
aoqi@0 368
aoqi@0 369 ### Locate C++ compiler (CXX)
aoqi@0 370
aoqi@0 371 if test "x$CXX" != x; then
aoqi@0 372 COMPILER_CHECK_LIST="$CXX"
aoqi@0 373 elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
aoqi@0 374 COMPILER_CHECK_LIST="cl"
aoqi@0 375 elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
aoqi@0 376 COMPILER_CHECK_LIST="CC g++"
aoqi@0 377 elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
aoqi@0 378 # Do not probe for CC on AIX .
aoqi@0 379 COMPILER_CHECK_LIST="xlC_r"
aoqi@0 380 else
aoqi@0 381 COMPILER_CHECK_LIST="g++ CC"
aoqi@0 382 fi
aoqi@0 383
aoqi@0 384 TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
aoqi@0 385 # Now that we have resolved CXX ourself, let autoconf have its go at it
aoqi@0 386 AC_PROG_CXX([$CXX])
aoqi@0 387
aoqi@0 388 ### Locate other tools
aoqi@0 389
aoqi@0 390 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 391 AC_PROG_OBJC
aoqi@0 392 BASIC_FIXUP_EXECUTABLE(OBJC)
aoqi@0 393 else
aoqi@0 394 OBJC=
aoqi@0 395 fi
aoqi@0 396
aoqi@0 397 # Restore the flags to the user specified values.
aoqi@0 398 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
aoqi@0 399 CFLAGS="$ORG_CFLAGS"
aoqi@0 400 CXXFLAGS="$ORG_CXXFLAGS"
aoqi@0 401 OBJCFLAGS="$ORG_OBJCFLAGS"
aoqi@0 402
aoqi@0 403 LD="$CC"
aoqi@0 404 LDEXE="$CC"
aoqi@0 405 LDCXX="$CXX"
aoqi@0 406 LDEXECXX="$CXX"
aoqi@0 407 AC_SUBST(LD)
aoqi@0 408 # LDEXE is the linker to use, when creating executables.
aoqi@0 409 AC_SUBST(LDEXE)
aoqi@0 410 # Linking C++ libraries.
aoqi@0 411 AC_SUBST(LDCXX)
aoqi@0 412 # Linking C++ executables.
aoqi@0 413 AC_SUBST(LDEXECXX)
aoqi@0 414
aoqi@0 415 if test "x$OPENJDK_TARGET_OS" != xwindows; then
aoqi@0 416 AC_CHECK_TOOL(AR, ar)
aoqi@0 417 BASIC_FIXUP_EXECUTABLE(AR)
aoqi@0 418 fi
aoqi@0 419 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 420 ARFLAGS="-r"
aoqi@0 421 elif test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 422 ARFLAGS="-X64"
aoqi@0 423 else
aoqi@0 424 ARFLAGS=""
aoqi@0 425 fi
aoqi@0 426 AC_SUBST(ARFLAGS)
aoqi@0 427
aoqi@0 428 # For hotspot, we need these in Windows mixed path; other platforms keep them the same
aoqi@0 429 HOTSPOT_CXX="$CXX"
aoqi@0 430 HOTSPOT_LD="$LD"
aoqi@0 431 AC_SUBST(HOTSPOT_CXX)
aoqi@0 432 AC_SUBST(HOTSPOT_LD)
aoqi@0 433
aoqi@0 434 COMPILER_NAME=gcc
aoqi@0 435 COMPILER_TYPE=CC
aoqi@0 436 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
aoqi@0 437 # For now, assume that we are always compiling using cl.exe.
aoqi@0 438 CC_OUT_OPTION=-Fo
aoqi@0 439 EXE_OUT_OPTION=-out:
aoqi@0 440 LD_OUT_OPTION=-out:
aoqi@0 441 AR_OUT_OPTION=-out:
aoqi@0 442 # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
aoqi@0 443 # program for something completely different.
aoqi@0 444 AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
aoqi@0 445 # Since we must ignore the first found link, WINLD will contain
aoqi@0 446 # the full path to the link.exe program.
aoqi@0 447 BASIC_FIXUP_EXECUTABLE(WINLD)
aoqi@0 448 printf "Windows linker was found at $WINLD\n"
aoqi@0 449 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
aoqi@0 450 "$WINLD" --version > /dev/null
aoqi@0 451 if test $? -eq 0 ; then
aoqi@0 452 AC_MSG_RESULT([no])
aoqi@0 453 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
aoqi@0 454 else
aoqi@0 455 AC_MSG_RESULT([yes])
aoqi@0 456 fi
aoqi@0 457 LD="$WINLD"
aoqi@0 458 LDEXE="$WINLD"
aoqi@0 459 LDCXX="$WINLD"
aoqi@0 460 LDEXECXX="$WINLD"
aoqi@0 461
aoqi@0 462 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
aoqi@0 463 BASIC_FIXUP_EXECUTABLE(MT)
aoqi@0 464 # The resource compiler
aoqi@0 465 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
aoqi@0 466 BASIC_FIXUP_EXECUTABLE(RC)
aoqi@0 467
aoqi@0 468 # For hotspot, we need these in Windows mixed path,
aoqi@0 469 # so rewrite them all. Need added .exe suffix.
aoqi@0 470 HOTSPOT_CXX="$CXX.exe"
aoqi@0 471 HOTSPOT_LD="$LD.exe"
aoqi@0 472 HOTSPOT_MT="$MT.exe"
aoqi@0 473 HOTSPOT_RC="$RC.exe"
aoqi@0 474 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
aoqi@0 475 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
aoqi@0 476 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
aoqi@0 477 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
aoqi@0 478 AC_SUBST(HOTSPOT_MT)
aoqi@0 479 AC_SUBST(HOTSPOT_RC)
aoqi@0 480
aoqi@0 481 RC_FLAGS="-nologo -l 0x409 -r"
aoqi@0 482 AS_IF([test "x$VARIANT" = xOPT], [
aoqi@0 483 RC_FLAGS="$RC_FLAGS -d NDEBUG"
aoqi@0 484 ])
aoqi@0 485
aoqi@0 486 # The version variables used to create RC_FLAGS may be overridden
aoqi@0 487 # in a custom configure script, or possibly the command line.
aoqi@0 488 # Let those variables be expanded at make time in spec.gmk.
aoqi@0 489 # The \$ are escaped to the shell, and the $(...) variables
aoqi@0 490 # are evaluated by make.
aoqi@0 491 RC_FLAGS="$RC_FLAGS \
aoqi@0 492 -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \
aoqi@0 493 -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \
aoqi@0 494 -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
erikj@1404 495 -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(COOKED_JDK_UPDATE_VERSION).\$(COOKED_BUILD_NUMBER)\" \
aoqi@0 496 -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
aoqi@0 497 -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
erikj@1404 498 -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(COOKED_JDK_UPDATE_VERSION),\$(COOKED_BUILD_NUMBER)\""
aoqi@0 499
aoqi@0 500 # lib.exe is used to create static libraries.
aoqi@0 501 AC_CHECK_PROG([WINAR], [lib],[lib],,,)
aoqi@0 502 BASIC_FIXUP_EXECUTABLE(WINAR)
aoqi@0 503 AR="$WINAR"
aoqi@0 504 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
aoqi@0 505
aoqi@0 506 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
aoqi@0 507 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
aoqi@0 508
aoqi@0 509 COMPILER_TYPE=CL
aoqi@0 510 CCXXFLAGS="$CCXXFLAGS -nologo"
aoqi@0 511 ])
aoqi@0 512 AC_SUBST(RC_FLAGS)
aoqi@0 513 AC_SUBST(COMPILER_TYPE)
aoqi@0 514
aoqi@0 515 AC_PROG_CPP
aoqi@0 516 BASIC_FIXUP_EXECUTABLE(CPP)
aoqi@0 517
aoqi@0 518 AC_PROG_CXXCPP
aoqi@0 519 BASIC_FIXUP_EXECUTABLE(CXXCPP)
aoqi@0 520
aoqi@0 521 if test "x$COMPILE_TYPE" != "xcross"; then
aoqi@0 522 # If we are not cross compiling, use the same compilers for
aoqi@0 523 # building the build platform executables. The cross-compilation
aoqi@0 524 # case needed to be done earlier, but this can only be done after
aoqi@0 525 # the native tools have been localized.
aoqi@0 526 BUILD_CC="$CC"
aoqi@0 527 BUILD_CXX="$CXX"
aoqi@0 528 BUILD_LD="$LD"
aoqi@0 529 fi
aoqi@0 530
aoqi@0 531 # for solaris we really need solaris tools, and not gnu equivalent
aoqi@0 532 # these seems to normally reside in /usr/ccs/bin so add that to path before
aoqi@0 533 # starting to probe
aoqi@0 534 #
aoqi@0 535 # NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
aoqi@0 536 # so that it can be overriden --with-tools-dir
aoqi@0 537 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
aoqi@0 538 PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
aoqi@0 539 fi
aoqi@0 540
aoqi@0 541 # Find the right assembler.
aoqi@0 542 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 543 AC_PATH_PROG(AS, as)
aoqi@0 544 BASIC_FIXUP_EXECUTABLE(AS)
aoqi@0 545 else
aoqi@0 546 AS="$CC -c"
aoqi@0 547 fi
aoqi@0 548 AC_SUBST(AS)
aoqi@0 549
aoqi@0 550 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 551 AC_PATH_PROG(NM, nm)
aoqi@0 552 BASIC_FIXUP_EXECUTABLE(NM)
aoqi@0 553 AC_PATH_PROG(GNM, gnm)
aoqi@0 554 BASIC_FIXUP_EXECUTABLE(GNM)
aoqi@0 555 AC_PATH_PROG(STRIP, strip)
aoqi@0 556 BASIC_FIXUP_EXECUTABLE(STRIP)
aoqi@0 557 AC_PATH_PROG(MCS, mcs)
aoqi@0 558 BASIC_FIXUP_EXECUTABLE(MCS)
aoqi@0 559 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
ddehaven@1304 560 AC_PATH_PROG(OTOOL, otool)
ddehaven@1304 561 if test "x$OTOOL" = "x"; then
ddehaven@1304 562 OTOOL="true"
ddehaven@1304 563 fi
aoqi@0 564 AC_CHECK_TOOL(NM, nm)
aoqi@0 565 BASIC_FIXUP_EXECUTABLE(NM)
aoqi@0 566 GNM="$NM"
aoqi@0 567 AC_SUBST(GNM)
aoqi@0 568 AC_CHECK_TOOL(STRIP, strip)
aoqi@0 569 BASIC_FIXUP_EXECUTABLE(STRIP)
aoqi@0 570 fi
aoqi@0 571
aoqi@0 572 # objcopy is used for moving debug symbols to separate files when
aoqi@0 573 # full debug symbols are enabled.
aoqi@0 574 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 575 AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
aoqi@0 576 # Only call fixup if objcopy was found.
aoqi@0 577 if test -n "$OBJCOPY"; then
aoqi@0 578 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
aoqi@0 579 fi
aoqi@0 580 fi
aoqi@0 581
aoqi@0 582 AC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
aoqi@0 583 if test "x$OBJDUMP" != x; then
aoqi@0 584 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE bails if argument is missing.
aoqi@0 585 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
aoqi@0 586 fi
aoqi@0 587
aoqi@0 588 TOOLCHAIN_SETUP_JTREG
aoqi@0 589
aoqi@0 590 # Restore old path without tools dir
aoqi@0 591 PATH="$OLD_PATH"
aoqi@0 592 ])
aoqi@0 593
aoqi@0 594
aoqi@0 595 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
aoqi@0 596 [
aoqi@0 597
aoqi@0 598 ###############################################################################
aoqi@0 599 #
aoqi@0 600 # How to compile shared libraries.
aoqi@0 601 #
aoqi@0 602
aoqi@0 603 if test "x$GCC" = xyes; then
aoqi@0 604 COMPILER_NAME=gcc
aoqi@0 605 PICFLAG="-fPIC"
aoqi@0 606 LIBRARY_PREFIX=lib
aoqi@0 607 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 608 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 609 SHARED_LIBRARY_FLAGS="-shared"
aoqi@0 610 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 611 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 612 OBJ_SUFFIX='.o'
aoqi@0 613 EXE_SUFFIX=''
aoqi@0 614 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
aoqi@0 615 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
aoqi@0 616 C_FLAG_REORDER=''
aoqi@0 617 CXX_FLAG_REORDER=''
aoqi@0 618 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
aoqi@0 619 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
aoqi@0 620 LD="$CC"
aoqi@0 621 LDEXE="$CC"
aoqi@0 622 LDCXX="$CXX"
aoqi@0 623 LDEXECXX="$CXX"
aoqi@0 624 POST_STRIP_CMD="$STRIP -g"
aoqi@0 625
aoqi@0 626 # Linking is different on MacOSX
aoqi@0 627 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 628 # Might change in the future to clang.
aoqi@0 629 COMPILER_NAME=gcc
aoqi@0 630 SHARED_LIBRARY='lib[$]1.dylib'
aoqi@0 631 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
aoqi@0 632 SHARED_LIBRARY_SUFFIX='.dylib'
aoqi@0 633 EXE_SUFFIX=''
aoqi@0 634 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
aoqi@0 635 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 636 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
aoqi@0 637 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
aoqi@0 638 POST_STRIP_CMD="$STRIP -S"
aoqi@0 639 fi
aoqi@0 640 else
aoqi@0 641 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 642 # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
aoqi@0 643 COMPILER_NAME=ossc
aoqi@0 644 PICFLAG="-KPIC"
aoqi@0 645 LIBRARY_PREFIX=lib
aoqi@0 646 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 647 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 648 SHARED_LIBRARY_FLAGS="-G"
aoqi@0 649 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 650 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 651 OBJ_SUFFIX='.o'
aoqi@0 652 EXE_SUFFIX=''
aoqi@0 653 SET_SHARED_LIBRARY_NAME=''
aoqi@0 654 SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
aoqi@0 655 C_FLAG_REORDER='-xF'
aoqi@0 656 CXX_FLAG_REORDER='-xF'
aoqi@0 657 SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
aoqi@0 658 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
aoqi@0 659 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
aoqi@0 660 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
aoqi@0 661 CFLAGS_JDKLIB_EXTRA='-xstrconst'
aoqi@0 662 POST_STRIP_CMD="$STRIP -x"
aoqi@0 663 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
aoqi@0 664 fi
aoqi@0 665 if test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 666 COMPILER_NAME=xlc
aoqi@0 667 PICFLAG="-qpic=large"
aoqi@0 668 LIBRARY_PREFIX=lib
aoqi@0 669 SHARED_LIBRARY='lib[$]1.so'
aoqi@0 670 STATIC_LIBRARY='lib[$]1.a'
aoqi@0 671 SHARED_LIBRARY_FLAGS="-qmkshrobj"
aoqi@0 672 SHARED_LIBRARY_SUFFIX='.so'
aoqi@0 673 STATIC_LIBRARY_SUFFIX='.a'
aoqi@0 674 OBJ_SUFFIX='.o'
aoqi@0 675 EXE_SUFFIX=''
aoqi@0 676 SET_SHARED_LIBRARY_NAME=''
aoqi@0 677 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 678 C_FLAG_REORDER=''
aoqi@0 679 CXX_FLAG_REORDER=''
aoqi@0 680 SET_SHARED_LIBRARY_ORIGIN=''
aoqi@0 681 SET_EXECUTABLE_ORIGIN=""
aoqi@0 682 CFLAGS_JDK=""
aoqi@0 683 CXXFLAGS_JDK=""
aoqi@0 684 CFLAGS_JDKLIB_EXTRA=''
aoqi@0 685 POST_STRIP_CMD="$STRIP -X32_64"
aoqi@0 686 POST_MCS_CMD=""
aoqi@0 687 fi
aoqi@0 688 if test "x$OPENJDK_TARGET_OS" = xwindows; then
aoqi@0 689 # If it is not gcc, then assume it is the MS Visual Studio compiler
aoqi@0 690 COMPILER_NAME=cl
aoqi@0 691 PICFLAG=""
aoqi@0 692 LIBRARY_PREFIX=
aoqi@0 693 SHARED_LIBRARY='[$]1.dll'
aoqi@0 694 STATIC_LIBRARY='[$]1.lib'
aoqi@0 695 SHARED_LIBRARY_FLAGS="-LD"
aoqi@0 696 SHARED_LIBRARY_SUFFIX='.dll'
aoqi@0 697 STATIC_LIBRARY_SUFFIX='.lib'
aoqi@0 698 OBJ_SUFFIX='.obj'
aoqi@0 699 EXE_SUFFIX='.exe'
aoqi@0 700 SET_SHARED_LIBRARY_NAME=''
aoqi@0 701 SET_SHARED_LIBRARY_MAPFILE=''
aoqi@0 702 SET_SHARED_LIBRARY_ORIGIN=''
aoqi@0 703 SET_EXECUTABLE_ORIGIN=''
aoqi@0 704 fi
aoqi@0 705 fi
aoqi@0 706
aoqi@0 707 AC_SUBST(COMPILER_NAME)
aoqi@0 708 AC_SUBST(OBJ_SUFFIX)
aoqi@0 709 AC_SUBST(SHARED_LIBRARY)
aoqi@0 710 AC_SUBST(STATIC_LIBRARY)
aoqi@0 711 AC_SUBST(LIBRARY_PREFIX)
aoqi@0 712 AC_SUBST(SHARED_LIBRARY_SUFFIX)
aoqi@0 713 AC_SUBST(STATIC_LIBRARY_SUFFIX)
aoqi@0 714 AC_SUBST(EXE_SUFFIX)
aoqi@0 715 AC_SUBST(SHARED_LIBRARY_FLAGS)
aoqi@0 716 AC_SUBST(SET_SHARED_LIBRARY_NAME)
aoqi@0 717 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
aoqi@0 718 AC_SUBST(C_FLAG_REORDER)
aoqi@0 719 AC_SUBST(CXX_FLAG_REORDER)
aoqi@0 720 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
aoqi@0 721 AC_SUBST(SET_EXECUTABLE_ORIGIN)
aoqi@0 722 AC_SUBST(POST_STRIP_CMD)
aoqi@0 723 AC_SUBST(POST_MCS_CMD)
aoqi@0 724
aoqi@0 725 # The (cross) compiler is now configured, we can now test capabilities
aoqi@0 726 # of the target platform.
aoqi@0 727 ])
aoqi@0 728
aoqi@0 729 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
aoqi@0 730 [
aoqi@0 731
aoqi@0 732 ###############################################################################
aoqi@0 733 #
aoqi@0 734 # Setup the opt flags for different compilers
aoqi@0 735 # and different operating systems.
aoqi@0 736 #
aoqi@0 737
aoqi@0 738 #
aoqi@0 739 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
aoqi@0 740 #
aoqi@0 741 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 742 # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
aoqi@0 743 # While waiting for a better solution, the current workaround is to use -mstackrealign.
aoqi@0 744 CFLAGS="$CFLAGS -mstackrealign"
aoqi@0 745 AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
aoqi@0 746 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
aoqi@0 747 [
aoqi@0 748 AC_MSG_RESULT([yes])
aoqi@0 749 ],
aoqi@0 750 [
aoqi@0 751 AC_MSG_RESULT([no])
aoqi@0 752 AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
aoqi@0 753 ]
aoqi@0 754 )
aoqi@0 755 fi
aoqi@0 756
aoqi@0 757 C_FLAG_DEPS="-MMD -MF"
aoqi@0 758 CXX_FLAG_DEPS="-MMD -MF"
aoqi@0 759
aoqi@0 760 case $COMPILER_TYPE in
aoqi@0 761 CC )
aoqi@0 762 case $COMPILER_NAME in
aoqi@0 763 gcc )
aoqi@0 764 case $OPENJDK_TARGET_OS in
aoqi@0 765 macosx )
aoqi@0 766 # On MacOSX we optimize for size, something
aoqi@0 767 # we should do for all platforms?
aoqi@0 768 C_O_FLAG_HI="-Os"
aoqi@0 769 C_O_FLAG_NORM="-Os"
aoqi@0 770 C_O_FLAG_NONE=""
aoqi@0 771 ;;
aoqi@0 772 *)
aoqi@0 773 C_O_FLAG_HI="-O3"
aoqi@0 774 C_O_FLAG_NORM="-O2"
aoqi@0 775 C_O_FLAG_NONE="-O0"
aoqi@0 776 ;;
aoqi@0 777 esac
aoqi@0 778 CXX_O_FLAG_HI="$C_O_FLAG_HI"
aoqi@0 779 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 780 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
aoqi@0 781 CFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 782 CXXFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 783 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
aoqi@0 784 CFLAGS_DEBUG_SYMBOLS="-g1"
aoqi@0 785 CXXFLAGS_DEBUG_SYMBOLS="-g1"
aoqi@0 786 fi
aoqi@0 787 ;;
aoqi@0 788 ossc )
aoqi@0 789 #
aoqi@0 790 # Forte has different names for this with their C++ compiler...
aoqi@0 791 #
aoqi@0 792 C_FLAG_DEPS="-xMMD -xMF"
aoqi@0 793 CXX_FLAG_DEPS="-xMMD -xMF"
aoqi@0 794
aoqi@0 795 # Extra options used with HIGHEST
aoqi@0 796 #
aoqi@0 797 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
aoqi@0 798 # done with care, there are some assumptions below that need to
aoqi@0 799 # be understood about the use of pointers, and IEEE behavior.
aoqi@0 800 #
aoqi@0 801 # Use non-standard floating point mode (not IEEE 754)
aoqi@0 802 CC_HIGHEST="$CC_HIGHEST -fns"
aoqi@0 803 # Do some simplification of floating point arithmetic (not IEEE 754)
aoqi@0 804 CC_HIGHEST="$CC_HIGHEST -fsimple"
aoqi@0 805 # Use single precision floating point with 'float'
aoqi@0 806 CC_HIGHEST="$CC_HIGHEST -fsingle"
aoqi@0 807 # Assume memory references via basic pointer types do not alias
aoqi@0 808 # (Source with excessing pointer casting and data access with mixed
aoqi@0 809 # pointer types are not recommended)
aoqi@0 810 CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
aoqi@0 811 # Use intrinsic or inline versions for math/std functions
aoqi@0 812 # (If you expect perfect errno behavior, do not use this)
aoqi@0 813 CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
aoqi@0 814 # Loop data dependency optimizations (need -xO3 or higher)
aoqi@0 815 CC_HIGHEST="$CC_HIGHEST -xdepend"
aoqi@0 816 # Pointer parameters to functions do not overlap
aoqi@0 817 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
aoqi@0 818 # If you pass in multiple pointers to the same data, do not use this)
aoqi@0 819 CC_HIGHEST="$CC_HIGHEST -xrestrict"
aoqi@0 820 # Inline some library routines
aoqi@0 821 # (If you expect perfect errno behavior, do not use this)
aoqi@0 822 CC_HIGHEST="$CC_HIGHEST -xlibmil"
aoqi@0 823 # Use optimized math routines
aoqi@0 824 # (If you expect perfect errno behavior, do not use this)
aoqi@0 825 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
aoqi@0 826 #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
aoqi@0 827
aoqi@0 828 if test "x$OPENJDK_TARGET_CPU" = xsparc; then
aoqi@0 829 CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
aoqi@0 830 CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
aoqi@0 831 fi
aoqi@0 832
aoqi@0 833 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 834 x86)
aoqi@0 835 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
aoqi@0 836 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
aoqi@0 837 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
aoqi@0 838 C_O_FLAG_NONE="-xregs=no%frameptr"
aoqi@0 839 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
aoqi@0 840 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
aoqi@0 841 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
aoqi@0 842 CXX_O_FLAG_NONE="-xregs=no%frameptr"
aoqi@0 843 if test "x$OPENJDK_TARGET_CPU" = xx86; then
aoqi@0 844 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
aoqi@0 845 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
aoqi@0 846 fi
aoqi@0 847 ;;
aoqi@0 848 sparc)
aoqi@0 849 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
aoqi@0 850 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
aoqi@0 851 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
aoqi@0 852 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
aoqi@0 853 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
aoqi@0 854 C_O_FLAG_NONE=""
aoqi@0 855 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
aoqi@0 856 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
aoqi@0 857 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
aoqi@0 858 CXX_O_FLAG_NONE=""
aoqi@0 859 ;;
aoqi@0 860 esac
aoqi@0 861
aoqi@0 862 CFLAGS_DEBUG_SYMBOLS="-g -xs"
aoqi@0 863 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
aoqi@0 864 ;;
aoqi@0 865 xlc )
aoqi@0 866 C_FLAG_DEPS="-qmakedep=gcc -MF"
aoqi@0 867 CXX_FLAG_DEPS="-qmakedep=gcc -MF"
aoqi@0 868 C_O_FLAG_HIGHEST="-O3"
aoqi@0 869 C_O_FLAG_HI="-O3 -qstrict"
aoqi@0 870 C_O_FLAG_NORM="-O2"
aoqi@0 871 C_O_FLAG_NONE=""
aoqi@0 872 CXX_O_FLAG_HIGHEST="-O3"
aoqi@0 873 CXX_O_FLAG_HI="-O3 -qstrict"
aoqi@0 874 CXX_O_FLAG_NORM="-O2"
aoqi@0 875 CXX_O_FLAG_NONE=""
aoqi@0 876 CFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 877 CXXFLAGS_DEBUG_SYMBOLS="-g"
aoqi@0 878 LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
aoqi@0 879 CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
aoqi@0 880 CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
aoqi@0 881 ;;
aoqi@0 882 esac
aoqi@0 883 ;;
aoqi@0 884 CL )
aoqi@0 885 C_O_FLAG_HIGHEST="-O2"
aoqi@0 886 C_O_FLAG_HI="-O1"
aoqi@0 887 C_O_FLAG_NORM="-O1"
aoqi@0 888 C_O_FLAG_NONE="-Od"
aoqi@0 889 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
aoqi@0 890 CXX_O_FLAG_HI="$C_O_FLAG_HI"
aoqi@0 891 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 892 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
aoqi@0 893 ;;
aoqi@0 894 esac
aoqi@0 895
aoqi@0 896 if test -z "$C_O_FLAG_HIGHEST"; then
aoqi@0 897 C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
aoqi@0 898 fi
aoqi@0 899
aoqi@0 900 if test -z "$CXX_O_FLAG_HIGHEST"; then
aoqi@0 901 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
aoqi@0 902 fi
aoqi@0 903
aoqi@0 904 AC_SUBST(C_O_FLAG_HIGHEST)
aoqi@0 905 AC_SUBST(C_O_FLAG_HI)
aoqi@0 906 AC_SUBST(C_O_FLAG_NORM)
aoqi@0 907 AC_SUBST(C_O_FLAG_NONE)
aoqi@0 908 AC_SUBST(CXX_O_FLAG_HIGHEST)
aoqi@0 909 AC_SUBST(CXX_O_FLAG_HI)
aoqi@0 910 AC_SUBST(CXX_O_FLAG_NORM)
aoqi@0 911 AC_SUBST(CXX_O_FLAG_NONE)
aoqi@0 912 AC_SUBST(C_FLAG_DEPS)
aoqi@0 913 AC_SUBST(CXX_FLAG_DEPS)
aoqi@0 914 ])
aoqi@0 915
aoqi@0 916 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
aoqi@0 917 [
aoqi@0 918
aoqi@0 919 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
aoqi@0 920 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
aoqi@0 921 fi
aoqi@0 922
aoqi@0 923 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
aoqi@0 924 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
aoqi@0 925 fi
aoqi@0 926
aoqi@0 927 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
aoqi@0 928 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
aoqi@0 929 fi
aoqi@0 930
aoqi@0 931 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
aoqi@0 932 [extra flags to be used when compiling jdk c-files])])
aoqi@0 933
aoqi@0 934 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
aoqi@0 935 [extra flags to be used when compiling jdk c++-files])])
aoqi@0 936
aoqi@0 937 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
aoqi@0 938 [extra flags to be used when linking jdk])])
aoqi@0 939
aoqi@0 940 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
aoqi@0 941 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
aoqi@0 942 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
aoqi@0 943
aoqi@0 944 # Hotspot needs these set in their legacy form
aoqi@0 945 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
aoqi@0 946 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
aoqi@0 947 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
aoqi@0 948
aoqi@0 949 AC_SUBST(LEGACY_EXTRA_CFLAGS)
aoqi@0 950 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
aoqi@0 951 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
aoqi@0 952
aoqi@0 953 ###############################################################################
aoqi@0 954 #
aoqi@0 955 # Now setup the CFLAGS and LDFLAGS for the JDK build.
aoqi@0 956 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
aoqi@0 957 #
aoqi@0 958 case $COMPILER_NAME in
aoqi@0 959 gcc )
aoqi@0 960 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
aoqi@0 961 -pipe \
aoqi@0 962 -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
aoqi@0 963 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 964 arm )
aoqi@0 965 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
aoqi@0 966 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
aoqi@0 967 ;;
aoqi@0 968 ppc )
aoqi@0 969 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
aoqi@0 970 ;;
aoqi@0 971 * )
aoqi@0 972 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
aoqi@0 973 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
aoqi@0 974 ;;
aoqi@0 975 esac
aoqi@0 976 ;;
aoqi@0 977 ossc )
aoqi@0 978 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
aoqi@0 979 case $OPENJDK_TARGET_CPU_ARCH in
aoqi@0 980 x86 )
aoqi@0 981 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
aoqi@0 982 CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
aoqi@0 983 ;;
aoqi@0 984 esac
aoqi@0 985
aoqi@0 986 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
aoqi@0 987 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
aoqi@0 988
aoqi@0 989 LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
aoqi@0 990 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
aoqi@0 991 ;;
aoqi@0 992 xlc )
aoqi@0 993 CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
aoqi@0 994 CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
aoqi@0 995
aoqi@0 996 LDFLAGS_JDK="$LDFLAGS_JDK"
aoqi@0 997 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK"
aoqi@0 998 ;;
aoqi@0 999 cl )
aoqi@0 1000 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
aoqi@0 1001 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
aoqi@0 1002 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
aoqi@0 1003 -DWIN32 -DIAL"
aoqi@0 1004 case $OPENJDK_TARGET_CPU in
aoqi@0 1005 x86 )
aoqi@0 1006 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
aoqi@0 1007 ;;
aoqi@0 1008 x86_64 )
aoqi@0 1009 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
aoqi@0 1010 ;;
aoqi@0 1011 esac
aoqi@0 1012 ;;
aoqi@0 1013 esac
aoqi@0 1014
aoqi@0 1015 ###############################################################################
aoqi@0 1016
aoqi@0 1017 # Adjust flags according to debug level.
aoqi@0 1018 case $DEBUG_LEVEL in
aoqi@0 1019 fastdebug )
aoqi@0 1020 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
aoqi@0 1021 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
aoqi@0 1022 C_O_FLAG_HI="$C_O_FLAG_NORM"
aoqi@0 1023 C_O_FLAG_NORM="$C_O_FLAG_NORM"
aoqi@0 1024 CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
aoqi@0 1025 CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
aoqi@0 1026 JAVAC_FLAGS="$JAVAC_FLAGS -g"
aoqi@0 1027 ;;
aoqi@0 1028 slowdebug )
aoqi@0 1029 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
aoqi@0 1030 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
aoqi@0 1031 C_O_FLAG_HI="$C_O_FLAG_NONE"
aoqi@0 1032 C_O_FLAG_NORM="$C_O_FLAG_NONE"
aoqi@0 1033 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
aoqi@0 1034 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
aoqi@0 1035 JAVAC_FLAGS="$JAVAC_FLAGS -g"
aoqi@0 1036 ;;
aoqi@0 1037 esac
aoqi@0 1038
aoqi@0 1039 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
aoqi@0 1040
aoqi@0 1041 # The package path is used only on macosx?
aoqi@0 1042 PACKAGE_PATH=/opt/local
aoqi@0 1043 AC_SUBST(PACKAGE_PATH)
aoqi@0 1044
aoqi@0 1045 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
aoqi@0 1046 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
aoqi@0 1047 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
aoqi@0 1048 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
aoqi@0 1049 # Note: -Dmacro is the same as #define macro 1
aoqi@0 1050 # -Dmacro= is the same as #define macro
aoqi@0 1051 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 1052 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
aoqi@0 1053 else
aoqi@0 1054 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
aoqi@0 1055 fi
aoqi@0 1056 else
aoqi@0 1057 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
aoqi@0 1058 fi
aoqi@0 1059 if test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 1060 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
aoqi@0 1061 fi
aoqi@0 1062 if test "x$OPENJDK_TARGET_OS" = xwindows; then
aoqi@0 1063 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
aoqi@0 1064 fi
aoqi@0 1065 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 1066 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
aoqi@0 1067 fi
aoqi@0 1068 if test "x$OPENJDK_TARGET_OS" = xaix; then
aoqi@0 1069 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DAIX -DPPC64"
aoqi@0 1070 fi
aoqi@0 1071 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
aoqi@0 1072 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
aoqi@0 1073 # Setting these parameters makes it an error to link to macosx APIs that are
aoqi@0 1074 # newer than the given OS version and makes the linked binaries compatible even
aoqi@0 1075 # if built on a newer version of the OS.
aoqi@0 1076 # The expected format is X.Y.Z
aoqi@0 1077 MACOSX_VERSION_MIN=10.7.0
aoqi@0 1078 AC_SUBST(MACOSX_VERSION_MIN)
aoqi@0 1079 # The macro takes the version with no dots, ex: 1070
aoqi@0 1080 # Let the flags variables get resolved in make for easier override on make
aoqi@0 1081 # command line.
aoqi@0 1082 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
aoqi@0 1083 LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
aoqi@0 1084 fi
aoqi@0 1085 if test "x$OPENJDK_TARGET_OS" = xbsd; then
aoqi@0 1086 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
aoqi@0 1087 fi
aoqi@0 1088 if test "x$DEBUG_LEVEL" = xrelease; then
aoqi@0 1089 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
aoqi@0 1090 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
aoqi@0 1091 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
aoqi@0 1092 fi
aoqi@0 1093 else
aoqi@0 1094 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
aoqi@0 1095 fi
aoqi@0 1096
aoqi@0 1097 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
aoqi@0 1098 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
aoqi@0 1099
aoqi@0 1100 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
aoqi@0 1101 -I${JDK_OUTPUTDIR}/include \
aoqi@0 1102 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
aoqi@0 1103 -I${JDK_TOPDIR}/src/share/javavm/export \
aoqi@0 1104 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
aoqi@0 1105 -I${JDK_TOPDIR}/src/share/native/common \
aoqi@0 1106 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
aoqi@0 1107
aoqi@0 1108 # The shared libraries are compiled using the picflag.
aoqi@0 1109 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
aoqi@0 1110 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
aoqi@0 1111
aoqi@0 1112 # Executable flags
aoqi@0 1113 CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
aoqi@0 1114 CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
aoqi@0 1115
aoqi@0 1116 # Now this is odd. The JDK native libraries have to link against libjvm.so
aoqi@0 1117 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
aoqi@0 1118 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
aoqi@0 1119 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
aoqi@0 1120 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
aoqi@0 1121 # libraries will link to whatever is in memory. Yuck.
aoqi@0 1122 #
aoqi@0 1123 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
aoqi@0 1124 if test "x$COMPILER_NAME" = xcl; then
aoqi@0 1125 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
aoqi@0 1126 if test "x$OPENJDK_TARGET_CPU" = xx86; then
aoqi@0 1127 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
aoqi@0 1128 fi
aoqi@0 1129 # TODO: make -debug optional "--disable-full-debug-symbols"
aoqi@0 1130 LDFLAGS_JDK="$LDFLAGS_JDK -debug"
aoqi@0 1131 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
aoqi@0 1132 LDFLAGS_JDKLIB_SUFFIX=""
aoqi@0 1133 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
aoqi@0 1134 LDFLAGS_STACK_SIZE=1048576
aoqi@0 1135 else
aoqi@0 1136 LDFLAGS_STACK_SIZE=327680
aoqi@0 1137 fi
aoqi@0 1138 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
aoqi@0 1139 else
aoqi@0 1140 if test "x$COMPILER_NAME" = xgcc; then
aoqi@0 1141 # If this is a --hash-style=gnu system, use --hash-style=both, why?
aoqi@0 1142 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
aoqi@0 1143 if test -n "$HAS_GNU_HASH"; then
aoqi@0 1144 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
aoqi@0 1145 fi
aoqi@0 1146 if test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 1147 # And since we now know that the linker is gnu, then add -z defs, to forbid
aoqi@0 1148 # undefined symbols in object files.
aoqi@0 1149 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
aoqi@0 1150 if test "x$DEBUG_LEVEL" = "xrelease"; then
aoqi@0 1151 # When building release libraries, tell the linker optimize them.
aoqi@0 1152 # Should this be supplied to the OSS linker as well?
aoqi@0 1153 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
aoqi@0 1154 fi
aoqi@0 1155 fi
aoqi@0 1156 fi
aoqi@0 1157 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
aoqi@0 1158 -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
aoqi@0 1159
aoqi@0 1160 # On some platforms (mac) the linker warns about non existing -L dirs.
aoqi@0 1161 # Add server first if available. Linking aginst client does not always produce the same results.
aoqi@0 1162 # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
aoqi@0 1163 # Default to server for other variants.
aoqi@0 1164 if test "x$JVM_VARIANT_SERVER" = xtrue; then
aoqi@0 1165 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
aoqi@0 1166 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
aoqi@0 1167 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
aoqi@0 1168 elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
aoqi@0 1169 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
aoqi@0 1170 else
aoqi@0 1171 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
aoqi@0 1172 fi
aoqi@0 1173
aoqi@0 1174 LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
aoqi@0 1175 if test "x$COMPILER_NAME" = xossc; then
aoqi@0 1176 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
aoqi@0 1177 fi
aoqi@0 1178
aoqi@0 1179 LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
aoqi@0 1180 if test "x$OPENJDK_TARGET_OS" = xlinux; then
aoqi@0 1181 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
aoqi@0 1182 fi
aoqi@0 1183 fi
aoqi@0 1184
aoqi@0 1185 AC_SUBST(CFLAGS_JDKLIB)
aoqi@0 1186 AC_SUBST(CFLAGS_JDKEXE)
aoqi@0 1187
aoqi@0 1188 AC_SUBST(CXXFLAGS_JDKLIB)
aoqi@0 1189 AC_SUBST(CXXFLAGS_JDKEXE)
aoqi@0 1190
aoqi@0 1191 AC_SUBST(LDFLAGS_JDKLIB)
aoqi@0 1192 AC_SUBST(LDFLAGS_JDKEXE)
aoqi@0 1193 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
aoqi@0 1194 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
aoqi@0 1195 AC_SUBST(LDFLAGS_CXX_JDK)
aoqi@0 1196 ])
aoqi@0 1197
aoqi@0 1198
aoqi@0 1199 # TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
aoqi@0 1200 # [RUN-IF-FALSE])
aoqi@0 1201 # ------------------------------------------------------------
aoqi@0 1202 # Check that the c and c++ compilers support an argument
aoqi@0 1203 AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
aoqi@0 1204 [
aoqi@0 1205 AC_MSG_CHECKING([if compiler supports "$1"])
aoqi@0 1206 supports=yes
aoqi@0 1207
aoqi@0 1208 saved_cflags="$CFLAGS"
aoqi@0 1209 CFLAGS="$CFLAGS $1"
aoqi@0 1210 AC_LANG_PUSH([C])
aoqi@0 1211 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
aoqi@0 1212 [supports=no])
aoqi@0 1213 AC_LANG_POP([C])
aoqi@0 1214 CFLAGS="$saved_cflags"
aoqi@0 1215
aoqi@0 1216 saved_cxxflags="$CXXFLAGS"
aoqi@0 1217 CXXFLAGS="$CXXFLAG $1"
aoqi@0 1218 AC_LANG_PUSH([C++])
aoqi@0 1219 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
aoqi@0 1220 [supports=no])
aoqi@0 1221 AC_LANG_POP([C++])
aoqi@0 1222 CXXFLAGS="$saved_cxxflags"
aoqi@0 1223
aoqi@0 1224 AC_MSG_RESULT([$supports])
aoqi@0 1225 if test "x$supports" = "xyes" ; then
aoqi@0 1226 m4_ifval([$2], [$2], [:])
aoqi@0 1227 else
aoqi@0 1228 m4_ifval([$3], [$3], [:])
aoqi@0 1229 fi
aoqi@0 1230 ])
aoqi@0 1231
aoqi@0 1232 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC],
aoqi@0 1233 [
aoqi@0 1234 # Some Zero and Shark settings.
aoqi@0 1235 # ZERO_ARCHFLAG tells the compiler which mode to build for
aoqi@0 1236 case "${OPENJDK_TARGET_CPU}" in
aoqi@0 1237 s390)
aoqi@0 1238 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
aoqi@0 1239 ;;
aoqi@0 1240 *)
aoqi@0 1241 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
aoqi@0 1242 esac
aoqi@0 1243 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
aoqi@0 1244 AC_SUBST(ZERO_ARCHFLAG)
aoqi@0 1245
aoqi@0 1246 # Check that the compiler supports -mX (or -qX on AIX) flags
aoqi@0 1247 # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
aoqi@0 1248 TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
aoqi@0 1249 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
aoqi@0 1250 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
aoqi@0 1251 AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
aoqi@0 1252
aoqi@0 1253
aoqi@0 1254 # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed in executable.'
aoqi@0 1255 USING_BROKEN_SUSE_LD=no
aoqi@0 1256 if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$GCC" = xyes; then
aoqi@0 1257 AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
aoqi@0 1258 echo "SUNWprivate_1.1 { local: *; };" > version-script.map
aoqi@0 1259 echo "int main() { }" > main.c
aoqi@0 1260 if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
aoqi@0 1261 AC_MSG_RESULT(no)
aoqi@0 1262 USING_BROKEN_SUSE_LD=no
aoqi@0 1263 else
aoqi@0 1264 AC_MSG_RESULT(yes)
aoqi@0 1265 USING_BROKEN_SUSE_LD=yes
aoqi@0 1266 fi
aoqi@0 1267 rm -rf version-script.map main.c
aoqi@0 1268 fi
aoqi@0 1269 AC_SUBST(USING_BROKEN_SUSE_LD)
aoqi@0 1270 ])
aoqi@0 1271
aoqi@0 1272 # Setup the JTREG paths
aoqi@0 1273 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
aoqi@0 1274 [
aoqi@0 1275 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
aoqi@0 1276 [Regression Test Harness @<:@probed@:>@])],
aoqi@0 1277 [],
aoqi@0 1278 [with_jtreg=no])
aoqi@0 1279
aoqi@0 1280 if test "x$with_jtreg" = xno; then
aoqi@0 1281 # jtreg disabled
aoqi@0 1282 AC_MSG_CHECKING([for jtreg])
aoqi@0 1283 AC_MSG_RESULT(no)
aoqi@0 1284 else
aoqi@0 1285 if test "x$with_jtreg" != xyes; then
aoqi@0 1286 # with path specified.
aoqi@0 1287 JT_HOME="$with_jtreg"
aoqi@0 1288 fi
aoqi@0 1289
aoqi@0 1290 if test "x$JT_HOME" != x; then
aoqi@0 1291 AC_MSG_CHECKING([for jtreg])
aoqi@0 1292
aoqi@0 1293 # use JT_HOME enviroment var.
aoqi@0 1294 BASIC_FIXUP_PATH([JT_HOME])
aoqi@0 1295
aoqi@0 1296 # jtreg win32 script works for everybody
erikj@1328 1297 JTREGEXE="$JT_HOME/bin/jtreg"
aoqi@0 1298
aoqi@0 1299 if test ! -f "$JTREGEXE"; then
aoqi@0 1300 AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
aoqi@0 1301 fi
aoqi@0 1302
aoqi@0 1303 AC_MSG_RESULT($JTREGEXE)
aoqi@0 1304 else
aoqi@0 1305 # try to find jtreg on path
aoqi@0 1306 BASIC_REQUIRE_PROG(JTREGEXE, jtreg)
aoqi@0 1307 JT_HOME="`$DIRNAME $JTREGEXE`"
aoqi@0 1308 fi
aoqi@0 1309 fi
aoqi@0 1310
aoqi@0 1311 AC_SUBST(JT_HOME)
aoqi@0 1312 AC_SUBST(JTREGEXE)
aoqi@0 1313 ])

mercurial