common/autoconf/toolchain.m4

Thu, 19 Mar 2015 12:46:21 +0100

author
erikj
date
Thu, 19 Mar 2015 12:46:21 +0100
changeset 1328
0785e45b19c8
parent 1304
c27cb0ab944f
child 1404
17e06bbf496e
permissions
-rw-r--r--

8075495: Update jtreg bin location in configure
Reviewed-by: alanb

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

mercurial