common/autoconf/toolchain.m4
changeset 13697 5262b00bc10c
parent 13133 701e61c32ece
child 14111 2a82ecb35fc7
equal deleted inserted replaced
13694:ffe6bce5a521 13697:5262b00bc10c
    29 # Check if the VS env variables were setup prior to running configure.
    29 # Check if the VS env variables were setup prior to running configure.
    30 # If not, then find vcvarsall.bat and run it automatically, and integrate
    30 # If not, then find vcvarsall.bat and run it automatically, and integrate
    31 # the set env variables into the spec file.
    31 # the set env variables into the spec file.
    32 SETUPDEVENV="# No special vars"
    32 SETUPDEVENV="# No special vars"
    33 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
    33 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
       
    34     # Store path to cygwin link.exe to help excluding it when searching for 
       
    35     # VS linker.
       
    36     AC_PATH_PROG(CYGWIN_LINK, link)
       
    37     AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
       
    38     "$CYGWIN_LINK" --version > /dev/null
       
    39     if test $? -eq 0 ; then
       
    40       AC_MSG_RESULT([yes])
       
    41     else
       
    42       AC_MSG_RESULT([no])
       
    43       # This might be the VS linker. Don't exclude it later on.
       
    44       CYGWIN_LINK=""
       
    45     fi
       
    46     
    34     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
    47     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
    35     if test "x$VCINSTALLDIR" != x; then
    48     if test "x$VCINSTALLDIR" != x; then
    36         # No further setup is needed. The build will happen from this kind
    49         # No further setup is needed. The build will happen from this kind
    37         # of shell.
    50         # of shell.
    38         SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt."
    51         SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt."
    55 	if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then
    68 	if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then
    56             AC_MSG_CHECKING([if we can find the VS installation])
    69             AC_MSG_CHECKING([if we can find the VS installation])
    57             AC_MSG_RESULT([no])
    70             AC_MSG_RESULT([no])
    58             AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
    71             AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
    59         fi
    72         fi
    60         case "$LEGACY_OPENJDK_TARGET_CPU1" in
    73         case "$OPENJDK_TARGET_CPU" in
    61           i?86)
    74           x86)
    62             VARSBAT_ARCH=x86
    75             VARSBAT_ARCH=x86
    63             ;;
    76             ;;
    64           *)
    77           x86_64)
    65             VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1
    78             VARSBAT_ARCH=amd64
    66             ;;
    79             ;;
    67         esac
    80         esac
    68         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
    81         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
    69         cd $OUTPUT_ROOT
    82         cd $OUTPUT_ROOT
    70         bash $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH"
    83         bash $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH"
   120 ###############################################################################
   133 ###############################################################################
   121 #
   134 #
   122 # Configure the development tool paths and potential sysroot.
   135 # Configure the development tool paths and potential sysroot.
   123 #
   136 #
   124 AC_LANG(C++)
   137 AC_LANG(C++)
   125 DEVKIT=
       
   126 SYS_ROOT=/
       
   127 AC_SUBST(SYS_ROOT)
       
   128 
   138 
   129 # The option used to specify the target .o,.a or .so file.
   139 # The option used to specify the target .o,.a or .so file.
   130 # When compiling, how to specify the to be created object file.
   140 # When compiling, how to specify the to be created object file.
   131 CC_OUT_OPTION='-o$(SPACE)'
   141 CC_OUT_OPTION='-o$(SPACE)'
   132 # When linking, how to specify the to be created executable.
   142 # When linking, how to specify the to be created executable.
   151 # If neither of build and host is not set, then build=host and the
   161 # If neither of build and host is not set, then build=host and the
   152 # default compiler found in the path will be used.
   162 # default compiler found in the path will be used.
   153 # Setting only --host, does not seem to be really supported.
   163 # Setting only --host, does not seem to be really supported.
   154 # Please set both --build and --host if you want to cross compile.
   164 # Please set both --build and --host if you want to cross compile.
   155 
   165 
   156 DEFINE_CROSS_COMPILE_ARCH=""
   166 if test "x$COMPILE_TYPE" = "xcross"; then
   157 HOSTCC=""
       
   158 HOSTCXX=""
       
   159 HOSTLD=""
       
   160 AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
       
   161 AC_MSG_CHECKING([if this is a cross compile])
       
   162 if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then
       
   163     AC_MSG_RESULT([yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM])
       
   164     # We have detected a cross compile!
       
   165     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1"
       
   166     # Now we to find a C/C++ compiler that can build executables for the build
   167     # Now we to find a C/C++ compiler that can build executables for the build
   167     # platform. We can't use the AC_PROG_CC macro, since it can only be used
   168     # platform. We can't use the AC_PROG_CC macro, since it can only be used
   168     # once.
   169     # once. Also, we need to do this before adding a tools dir to the path,
   169     AC_PATH_PROGS(HOSTCC, [cl cc gcc])
   170     # otherwise we might pick up cross-compilers which don't use standard naming.
   170     WHICHCMD(HOSTCC)
   171     # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
   171     AC_PATH_PROGS(HOSTCXX, [cl CC g++])
   172     # to wait until they are properly discovered.
   172     WHICHCMD(HOSTCXX)
   173     AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
   173     AC_PATH_PROG(HOSTLD, ld)
   174     SET_FULL_PATH(BUILD_CC)
   174     WHICHCMD(HOSTLD)
   175     AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
   175     # Building for the build platform should be easy. Therefore
   176     SET_FULL_PATH(BUILD_CXX)
   176     # we do not need any linkers or assemblers etc.    
   177     AC_PATH_PROG(BUILD_LD, ld)
   177 else
   178     SET_FULL_PATH(BUILD_LD)
   178     AC_MSG_RESULT([no])
   179 fi
   179 fi
   180 AC_SUBST(BUILD_CC)
   180 
   181 AC_SUBST(BUILD_CXX)
   181 # You can force the sys-root if the sys-root encoded into the cross compiler tools
   182 AC_SUBST(BUILD_LD)
   182 # is not correct.
   183 
   183 AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
       
   184     [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
       
   185      the cross compiler tools is incorrect)])])
       
   186 
       
   187 if test "x$with_sys_root" != x; then
       
   188     SYS_ROOT=$with_sys_root
       
   189 fi
       
   190                      
       
   191 # If a devkit is found on the builddeps server, then prepend its path to the
   184 # If a devkit is found on the builddeps server, then prepend its path to the
   192 # PATH variable. If there are cross compilers available in the devkit, these
   185 # PATH variable. If there are cross compilers available in the devkit, these
   193 # will be found by AC_PROG_CC et al.
   186 # will be found by AC_PROG_CC et al.
       
   187 DEVKIT=
   194 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
   188 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
   195                     [# Found devkit
   189                     [# Found devkit
   196                      PATH="$DEVKIT/bin:$PATH"
   190                      PATH="$DEVKIT/bin:$PATH"
   197                      SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
   191                      SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
   198                      if test "x$x_includes" = "xNONE"; then
   192                      if test "x$x_includes" = "xNONE"; then
   216 # Store the CFLAGS etal passed to the configure script.
   210 # Store the CFLAGS etal passed to the configure script.
   217 ORG_CFLAGS="$CFLAGS"
   211 ORG_CFLAGS="$CFLAGS"
   218 ORG_CXXFLAGS="$CXXFLAGS"
   212 ORG_CXXFLAGS="$CXXFLAGS"
   219 ORG_OBJCFLAGS="$OBJCFLAGS"
   213 ORG_OBJCFLAGS="$OBJCFLAGS"
   220 
   214 
   221 AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
       
   222 	[search this directory for compilers and tools])], [TOOLS_DIR=$with_tools_dir])
       
   223 
       
   224 AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
       
   225 	[use this directory as base for tools-dir and sys-root])], [
       
   226     if test "x$with_sys_root" != x; then
       
   227       AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
       
   228     fi
       
   229     if test "x$with_tools_dir" != x; then
       
   230       AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
       
   231     fi
       
   232     TOOLS_DIR=$with_devkit/bin
       
   233     SYS_ROOT=$with_devkit/$host_alias/libc
       
   234     ])
       
   235 
       
   236 # autoconf magic only relies on PATH, so update it if tools dir is specified
   215 # autoconf magic only relies on PATH, so update it if tools dir is specified
   237 OLD_PATH="$PATH"
   216 OLD_PATH="$PATH"
   238 if test "x$TOOLS_DIR" != x; then
   217 if test "x$TOOLS_DIR" != x; then
   239   PATH=$TOOLS_DIR:$PATH
   218   PATH=$TOOLS_DIR:$PATH
   240 fi
   219 fi
   249 fi
   228 fi
   250 if test "x$CC" = xcc && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   229 if test "x$CC" = xcc && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   251     # Do not use cc on MacOSX use gcc instead.
   230     # Do not use cc on MacOSX use gcc instead.
   252     CC="gcc"
   231     CC="gcc"
   253 fi
   232 fi
   254 WHICHCMD(CC)
   233 SET_FULL_PATH(CC)
   255 
   234 
   256 AC_PROG_CXX([cl CC g++])
   235 AC_PROG_CXX([cl CC g++])
   257 if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   236 if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   258     # The found CC, even though it seems to be a g++ derivate, cannot compile
   237     # The found CC, even though it seems to be a g++ derivate, cannot compile
   259     # c++ code. Override.
   238     # c++ code. Override.
   260     CXX="g++"
   239     CXX="g++"
   261 fi
   240 fi
   262 WHICHCMD(CXX)
   241 SET_FULL_PATH(CXX)
   263 
   242 
   264 if test "x$CXX" = x || test "x$CC" = x; then
   243 if test "x$CXX" = x || test "x$CC" = x; then
   265     HELP_MSG_MISSING_DEPENDENCY([devkit])
   244     HELP_MSG_MISSING_DEPENDENCY([devkit])
   266     AC_MSG_ERROR([Could not find the needed compilers! $HELP_MSG ])
   245     AC_MSG_ERROR([Could not find the needed compilers! $HELP_MSG ])
   267 fi
   246 fi
   268 
   247 
   269 if test "x$OPENJDK_BUILD_OS" != xwindows; then
   248 if test "x$OPENJDK_BUILD_OS" != xwindows; then
   270     AC_PROG_OBJC
   249     AC_PROG_OBJC
   271     WHICHCMD(OBJC)
   250     SET_FULL_PATH(OBJC)
   272 else
   251 else
   273     OBJC=
   252     OBJC=
   274 fi
   253 fi
   275 
   254 
   276 # Restore the flags to the user specified values.
   255 # Restore the flags to the user specified values.
   277 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
   256 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
   278 CFLAGS="$ORG_CFLAGS"
   257 CFLAGS="$ORG_CFLAGS"
   279 CXXFLAGS="$ORG_CXXFLAGS"
   258 CXXFLAGS="$ORG_CXXFLAGS"
   280 OBJCFLAGS="$ORG_OBJCFLAGS"
   259 OBJCFLAGS="$ORG_OBJCFLAGS"
   281 
   260 
   282 # If we are not cross compiling, use the same compilers for
       
   283 # building the build platform executables.
       
   284 if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
       
   285     HOSTCC="$CC"
       
   286     HOSTCXX="$CXX"
       
   287 fi
       
   288 
       
   289 AC_CHECK_TOOL(LD, ld)
       
   290 WHICHCMD(LD)
       
   291 LD="$CC"
   261 LD="$CC"
   292 LDEXE="$CC"
   262 LDEXE="$CC"
   293 LDCXX="$CXX"
   263 LDCXX="$CXX"
   294 LDEXECXX="$CXX"
   264 LDEXECXX="$CXX"
       
   265 AC_SUBST(LD)
   295 # LDEXE is the linker to use, when creating executables.
   266 # LDEXE is the linker to use, when creating executables.
   296 AC_SUBST(LDEXE)
   267 AC_SUBST(LDEXE)
   297 # Linking C++ libraries.
   268 # Linking C++ libraries.
   298 AC_SUBST(LDCXX)
   269 AC_SUBST(LDCXX)
   299 # Linking C++ executables.
   270 # Linking C++ executables.
   300 AC_SUBST(LDEXECXX)
   271 AC_SUBST(LDEXECXX)
   301 
   272 
   302 AC_CHECK_TOOL(AR, ar)
   273 if test "x$OPENJDK_BUILD_OS" != xwindows; then
   303 WHICHCMD(AR)
   274     AC_CHECK_TOOL(AR, ar)
       
   275     SET_FULL_PATH(AR)
       
   276 fi
   304 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   277 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   305     ARFLAGS="-r"
   278     ARFLAGS="-r"
   306 else
   279 else
   307     ARFLAGS=""
   280     ARFLAGS=""
   308 fi
   281 fi
   314     # For now, assume that we are always compiling using cl.exe. 
   287     # For now, assume that we are always compiling using cl.exe. 
   315     CC_OUT_OPTION=-Fo
   288     CC_OUT_OPTION=-Fo
   316     EXE_OUT_OPTION=-out:
   289     EXE_OUT_OPTION=-out:
   317     LD_OUT_OPTION=-out:
   290     LD_OUT_OPTION=-out:
   318     AR_OUT_OPTION=-out:
   291     AR_OUT_OPTION=-out:
   319     # On Windows, reject /usr/bin/link, which is a cygwin
   292     # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
   320     # program for something completely different.
   293     # program for something completely different.
   321     AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link])
   294     AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
   322     # Since we must ignore the first found link, WINLD will contain
   295     # Since we must ignore the first found link, WINLD will contain
   323     # the full path to the link.exe program.
   296     # the full path to the link.exe program.
   324     WHICHCMD_SPACESAFE([WINLD])
   297     SET_FULL_PATH_SPACESAFE([WINLD])
       
   298     printf "Windows linker was found at $WINLD\n"
       
   299     AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
       
   300     "$WINLD" --version > /dev/null
       
   301     if test $? -eq 0 ; then
       
   302       AC_MSG_RESULT([no])
       
   303       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
       
   304     else
       
   305       AC_MSG_RESULT([yes])
       
   306     fi
   325     LD="$WINLD"
   307     LD="$WINLD"
   326     LDEXE="$WINLD"
   308     LDEXE="$WINLD"
   327     LDCXX="$WINLD"
   309     LDCXX="$WINLD"
   328     LDEXECXX="$WINLD"
   310     LDEXECXX="$WINLD"
   329     # Set HOSTLD to same as LD until we fully support cross compilation
       
   330     # on windows.
       
   331     HOSTLD="$WINLD"
       
   332 
   311 
   333     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
   312     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
   334     WHICHCMD_SPACESAFE([MT])
   313     SET_FULL_PATH_SPACESAFE([MT])
   335     # The resource compiler
   314     # The resource compiler
   336     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
   315     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
   337     WHICHCMD_SPACESAFE([RC])
   316     SET_FULL_PATH_SPACESAFE([RC])
   338 
   317 
   339     RC_FLAGS="-nologo /l 0x409 /r"
   318     RC_FLAGS="-nologo /l 0x409 /r"
   340     AS_IF([test "x$VARIANT" = xOPT], [
   319     AS_IF([test "x$VARIANT" = xOPT], [
   341         RC_FLAGS="$RC_FLAGS -d NDEBUG"
   320         RC_FLAGS="$RC_FLAGS -d NDEBUG"
   342     ])
   321     ])
   352     RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
   331     RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
   353     RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
   332     RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
   354 
   333 
   355     # lib.exe is used to create static libraries.
   334     # lib.exe is used to create static libraries.
   356     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
   335     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
   357     WHICHCMD_SPACESAFE([WINAR])
   336     SET_FULL_PATH_SPACESAFE([WINAR])
   358     AR="$WINAR"
   337     AR="$WINAR"
   359     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
   338     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
   360 
   339 
   361     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
   340     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
   362     WHICHCMD_SPACESAFE([DUMPBIN])
   341     SET_FULL_PATH_SPACESAFE([DUMPBIN])
   363 
   342 
   364     COMPILER_TYPE=CL
   343     COMPILER_TYPE=CL
   365     CCXXFLAGS="$CCXXFLAGS -nologo"
   344     CCXXFLAGS="$CCXXFLAGS -nologo"
   366 ])
   345 ])
   367 AC_SUBST(RC_FLAGS)
   346 AC_SUBST(RC_FLAGS)
   368 AC_SUBST(COMPILER_TYPE)
   347 AC_SUBST(COMPILER_TYPE)
   369 
   348 
   370 AC_PROG_CPP
   349 AC_PROG_CPP
   371 WHICHCMD(CPP)
   350 SET_FULL_PATH(CPP)
   372 
   351 
   373 AC_PROG_CXXCPP
   352 AC_PROG_CXXCPP
   374 WHICHCMD(CXXCPP)
   353 SET_FULL_PATH(CXXCPP)
       
   354 
       
   355 if test "x$COMPILE_TYPE" != "xcross"; then
       
   356     # If we are not cross compiling, use the same compilers for
       
   357     # building the build platform executables. The cross-compilation
       
   358     # case needed to be done earlier, but this can only be done after
       
   359     # the native tools have been localized.
       
   360     BUILD_CC="$CC"
       
   361     BUILD_CXX="$CXX"
       
   362     BUILD_LD="$LD"
       
   363 fi
   375 
   364 
   376 # for solaris we really need solaris tools, and not gnu equivalent
   365 # for solaris we really need solaris tools, and not gnu equivalent
   377 #   these seems to normally reside in /usr/ccs/bin so add that to path before
   366 #   these seems to normally reside in /usr/ccs/bin so add that to path before
   378 #   starting to probe
   367 #   starting to probe
   379 #
   368 #
   384 fi
   373 fi
   385 
   374 
   386 # Find the right assembler.
   375 # Find the right assembler.
   387 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   376 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   388     AC_PATH_PROG(AS, as)
   377     AC_PATH_PROG(AS, as)
   389     WHICHCMD(AS)
   378     SET_FULL_PATH(AS)
   390     ASFLAGS=" "
       
   391 else
   379 else
   392     AS="$CC -c"
   380     AS="$CC -c"
   393     ASFLAGS=" "
       
   394 fi
   381 fi
   395 AC_SUBST(AS)
   382 AC_SUBST(AS)
   396 AC_SUBST(ASFLAGS)
       
   397 
   383 
   398 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   384 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   399     AC_PATH_PROG(NM, nm)
   385     AC_PATH_PROGS(NM, [gnm nm])
   400     WHICHCMD(NM)
   386     SET_FULL_PATH(NM)
   401     AC_PATH_PROG(STRIP, strip)
   387     AC_PATH_PROG(STRIP, strip)
   402     WHICHCMD(STRIP)
   388     SET_FULL_PATH(STRIP)
   403     AC_PATH_PROG(MCS, mcs)
   389     AC_PATH_PROG(MCS, mcs)
   404     WHICHCMD(MCS)
   390     SET_FULL_PATH(MCS)
   405 else
   391 elif test "x$OPENJDK_BUILD_OS" != xwindows; then
   406     AC_CHECK_TOOL(NM, nm)
   392     AC_CHECK_TOOL(NM, nm)
   407     WHICHCMD(NM)
   393     SET_FULL_PATH(NM)
   408     AC_CHECK_TOOL(STRIP, strip)
   394     AC_CHECK_TOOL(STRIP, strip)
   409     WHICHCMD(STRIP)
   395     SET_FULL_PATH(STRIP)
   410 fi
   396 fi
   411 
   397 
   412 ###
   398 ###
   413 #
   399 #
   414 # Check for objcopy
   400 # Check for objcopy
   417 #   since I on solaris found a broken objcopy...buhh
   403 #   since I on solaris found a broken objcopy...buhh
   418 #
   404 #
   419 AC_PATH_TOOL(OBJCOPY, gobjcopy)
   405 AC_PATH_TOOL(OBJCOPY, gobjcopy)
   420 if test "x$OBJCOPY" = x; then
   406 if test "x$OBJCOPY" = x; then
   421    AC_PATH_TOOL(OBJCOPY, objcopy)
   407    AC_PATH_TOOL(OBJCOPY, objcopy)
       
   408 fi
       
   409 
       
   410 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
       
   411    AC_PATH_PROG(LIPO, lipo)
       
   412    SET_FULL_PATH(LIPO)
   422 fi
   413 fi
   423 
   414 
   424 # Restore old path without tools dir
   415 # Restore old path without tools dir
   425 PATH="$OLD_PATH"
   416 PATH="$OLD_PATH"
   426 ])
   417 ])
   447     EXE_SUFFIX=''
   438     EXE_SUFFIX=''
   448     SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   439     SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   449     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   440     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   450     C_FLAG_REORDER=''
   441     C_FLAG_REORDER=''
   451     CXX_FLAG_REORDER=''
   442     CXX_FLAG_REORDER=''
   452     SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/[$]1'
   443     SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
       
   444     SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
   453     LD="$CC"
   445     LD="$CC"
   454     LDEXE="$CC"
   446     LDEXE="$CC"
   455     LDCXX="$CXX"
   447     LDCXX="$CXX"
   456     LDEXECXX="$CXX"
   448     LDEXECXX="$CXX"
   457     POST_STRIP_CMD="$STRIP -g"
   449     POST_STRIP_CMD="$STRIP -g"
   458     if test "x$JDK_VARIANT" = xembedded; then
       
   459         POST_STRIP_CMD="$STRIP --strip-unneeded"
       
   460     fi
       
   461 
   450 
   462     # Linking is different on MacOSX
   451     # Linking is different on MacOSX
   463     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   452     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   464         # Might change in the future to clang.
   453         # Might change in the future to clang.
   465         COMPILER_NAME=gcc
   454         COMPILER_NAME=gcc
   468         SHARED_LIBRARY_SUFFIX='.dylib'
   457         SHARED_LIBRARY_SUFFIX='.dylib'
   469         EXE_SUFFIX=''
   458         EXE_SUFFIX=''
   470         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
   459         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
   471         SET_SHARED_LIBRARY_MAPFILE=''
   460         SET_SHARED_LIBRARY_MAPFILE=''
   472         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   461         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
       
   462         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   473         POST_STRIP_CMD="$STRIP -S"
   463         POST_STRIP_CMD="$STRIP -S"
   474     fi
   464     fi
   475 else
   465 else
   476     if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   466     if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   477         # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
   467         # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
   478         COMPILER_NAME=ossc
   468         COMPILER_NAME=ossc
   479         PICFLAG="-KPIC"
   469         PICFLAG="-KPIC"
   480         LIBRARY_PREFIX=lib
   470         LIBRARY_PREFIX=lib
   481         SHARED_LIBRARY='lib[$]1.so'
   471         SHARED_LIBRARY='lib[$]1.so'
   482         STATIC_LIBRARY='lib[$]1.a'
   472         STATIC_LIBRARY='lib[$]1.a'
   483         SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G"
   473         SHARED_LIBRARY_FLAGS="-G"
   484         SHARED_LIBRARY_SUFFIX='.so'
   474         SHARED_LIBRARY_SUFFIX='.so'
   485         STATIC_LIBRARY_SUFFIX='.a'
   475         STATIC_LIBRARY_SUFFIX='.a'
   486         OBJ_SUFFIX='.o'
   476         OBJ_SUFFIX='.o'
   487         EXE_SUFFIX=''
   477         EXE_SUFFIX=''
   488         SET_SHARED_LIBRARY_NAME=''
   478         SET_SHARED_LIBRARY_NAME=''
   489         SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   479         SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   490 	C_FLAG_REORDER='-xF'
   480 	C_FLAG_REORDER='-xF'
   491 	CXX_FLAG_REORDER='-xF'
   481 	CXX_FLAG_REORDER='-xF'
   492         SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/[$]1'
   482         SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
       
   483         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   493         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   484         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   494         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   485         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   495         CFLAGS_JDKLIB_EXTRA='-xstrconst'
   486         CFLAGS_JDKLIB_EXTRA='-xstrconst'
   496         POST_STRIP_CMD="$STRIP -x"
   487         POST_STRIP_CMD="$STRIP -x"
   497         POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
   488         POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
   509         OBJ_SUFFIX='.obj'
   500         OBJ_SUFFIX='.obj'
   510         EXE_SUFFIX='.exe'
   501         EXE_SUFFIX='.exe'
   511         SET_SHARED_LIBRARY_NAME=''
   502         SET_SHARED_LIBRARY_NAME=''
   512         SET_SHARED_LIBRARY_MAPFILE=''
   503         SET_SHARED_LIBRARY_MAPFILE=''
   513         SET_SHARED_LIBRARY_ORIGIN=''
   504         SET_SHARED_LIBRARY_ORIGIN=''
       
   505         SET_EXECUTABLE_ORIGIN=''
   514     fi
   506     fi
   515 fi
   507 fi
   516 
   508 
   517 AC_SUBST(OBJ_SUFFIX)
   509 AC_SUBST(OBJ_SUFFIX)
   518 AC_SUBST(SHARED_LIBRARY)
   510 AC_SUBST(SHARED_LIBRARY)
   525 AC_SUBST(SET_SHARED_LIBRARY_NAME)
   517 AC_SUBST(SET_SHARED_LIBRARY_NAME)
   526 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   518 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   527 AC_SUBST(C_FLAG_REORDER)
   519 AC_SUBST(C_FLAG_REORDER)
   528 AC_SUBST(CXX_FLAG_REORDER)
   520 AC_SUBST(CXX_FLAG_REORDER)
   529 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   521 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
       
   522 AC_SUBST(SET_EXECUTABLE_ORIGIN)
   530 AC_SUBST(POST_STRIP_CMD)
   523 AC_SUBST(POST_STRIP_CMD)
   531 AC_SUBST(POST_MCS_CMD)
   524 AC_SUBST(POST_MCS_CMD)
   532 
   525 
   533 # The (cross) compiler is now configured, we can now test capabilities
   526 # The (cross) compiler is now configured, we can now test capabilities
   534 # of the target platform.
   527 # of the target platform.
   540 ###############################################################################
   533 ###############################################################################
   541 #
   534 #
   542 # Setup the opt flags for different compilers
   535 # Setup the opt flags for different compilers
   543 # and different operating systems.
   536 # and different operating systems.
   544 #
   537 #
       
   538 
       
   539 #
       
   540 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
       
   541 #
       
   542 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   543     # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
       
   544     # While waiting for a better solution, the current workaround is to use -mstackrealign.
       
   545     CFLAGS="$CFLAGS -mstackrealign"
       
   546     AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
       
   547     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
       
   548                    [
       
   549 		        AC_MSG_RESULT([yes])
       
   550                    ],
       
   551 	           [
       
   552 		        AC_MSG_RESULT([no])
       
   553 	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
       
   554 	           ])
       
   555 fi
       
   556 
   545 C_FLAG_DEPS="-MMD -MF"
   557 C_FLAG_DEPS="-MMD -MF"
   546 CXX_FLAG_DEPS="-MMD -MF"
   558 CXX_FLAG_DEPS="-MMD -MF"
   547 
   559 
   548 case $COMPILER_TYPE in
   560 case $COMPILER_TYPE in
   549   CC )
   561   CC )
   564 	    C_O_FLAG_NONE="-O0"
   576 	    C_O_FLAG_NONE="-O0"
   565 	    CFLAGS_DEBUG_SYMBOLS="-g"
   577 	    CFLAGS_DEBUG_SYMBOLS="-g"
   566 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
   578 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
   567 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   579 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   568 	       CFLAGS_DEBUG_SYMBOLS="-g1"
   580 	       CFLAGS_DEBUG_SYMBOLS="-g1"
   569 	       CXXFLAGS_DEBUG_SYMBOLSG="-g1"
   581 	       CXXFLAGS_DEBUG_SYMBOLS="-g1"
   570 	    fi
   582 	    fi
   571 	    ;;
   583 	    ;;
   572 	esac
   584 	esac
   573         CXX_O_FLAG_HI="$C_O_FLAG_HI"
   585         CXX_O_FLAG_HI="$C_O_FLAG_HI"
   574         CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   586         CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   576         ;;
   588         ;;
   577       ossc )
   589       ossc )
   578         #
   590         #
   579         # Forte has different names for this with their C++ compiler...
   591         # Forte has different names for this with their C++ compiler...
   580         #
   592         #
   581 	C_FLAG_DEPS="-xMMD -xMF"
   593         C_FLAG_DEPS="-xMMD -xMF"
   582 	CXX_FLAG_DEPS="-xMMD -xMF"
   594         CXX_FLAG_DEPS="-xMMD -xMF"
   583 
   595 
   584 # Extra options used with HIGHEST
   596         # Extra options used with HIGHEST
   585 #
   597         #
   586 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   598         # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   587 #          done with care, there are some assumptions below that need to
   599         #          done with care, there are some assumptions below that need to
   588 #          be understood about the use of pointers, and IEEE behavior.
   600         #          be understood about the use of pointers, and IEEE behavior.
   589 #
   601         #
   590 # Use non-standard floating point mode (not IEEE 754)
   602         # Use non-standard floating point mode (not IEEE 754)
   591 CC_HIGHEST="$CC_HIGHEST -fns"
   603         CC_HIGHEST="$CC_HIGHEST -fns"
   592 # Do some simplification of floating point arithmetic (not IEEE 754)
   604         # Do some simplification of floating point arithmetic (not IEEE 754)
   593 CC_HIGHEST="$CC_HIGHEST -fsimple"
   605         CC_HIGHEST="$CC_HIGHEST -fsimple"
   594 # Use single precision floating point with 'float'
   606         # Use single precision floating point with 'float'
   595 CC_HIGHEST="$CC_HIGHEST -fsingle"
   607         CC_HIGHEST="$CC_HIGHEST -fsingle"
   596 # Assume memory references via basic pointer types do not alias
   608         # Assume memory references via basic pointer types do not alias
   597 #   (Source with excessing pointer casting and data access with mixed 
   609         #   (Source with excessing pointer casting and data access with mixed 
   598 #    pointer types are not recommended)
   610         #    pointer types are not recommended)
   599 CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   611         CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   600 # Use intrinsic or inline versions for math/std functions
   612         # Use intrinsic or inline versions for math/std functions
   601 #   (If you expect perfect errno behavior, do not use this)
   613         #   (If you expect perfect errno behavior, do not use this)
   602 CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   614         CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   603 # Loop data dependency optimizations (need -xO3 or higher)
   615         # Loop data dependency optimizations (need -xO3 or higher)
   604 CC_HIGHEST="$CC_HIGHEST -xdepend"
   616         CC_HIGHEST="$CC_HIGHEST -xdepend"
   605 # Pointer parameters to functions do not overlap
   617         # Pointer parameters to functions do not overlap
   606 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   618         #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   607 #    If you pass in multiple pointers to the same data, do not use this)
   619         #    If you pass in multiple pointers to the same data, do not use this)
   608 CC_HIGHEST="$CC_HIGHEST -xrestrict"
   620         CC_HIGHEST="$CC_HIGHEST -xrestrict"
   609 # Inline some library routines
   621         # Inline some library routines
   610 #   (If you expect perfect errno behavior, do not use this)
   622         #   (If you expect perfect errno behavior, do not use this)
   611 CC_HIGHEST="$CC_HIGHEST -xlibmil"
   623         CC_HIGHEST="$CC_HIGHEST -xlibmil"
   612 # Use optimized math routines
   624         # Use optimized math routines
   613 #   (If you expect perfect errno behavior, do not use this)
   625         #   (If you expect perfect errno behavior, do not use this)
   614 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   626         #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   615 #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
   627         #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
   616 
   628 
   617         case $LEGACY_OPENJDK_TARGET_CPU1 in
   629         case $OPENJDK_TARGET_CPU_ARCH in
   618           i586)
   630           x86)
   619             C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium"
   631             C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
   620             C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
   632             C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
   621             C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
   633             C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
   622             C_O_FLAG_NONE=""
   634             C_O_FLAG_NONE="-xregs=no%frameptr"
   623             CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium"
   635             CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
   624             CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
   636             CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
   625             CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
   637             CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
   626             CXX_O_FLAG_NONE=""
   638             CXX_O_FLAG_NONE="-xregs=no%frameptr"
       
   639             if test "x$OPENJDK_TARGET_CPU" = xx86; then
       
   640                C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
       
   641                CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
       
   642             fi
   627             ;;
   643             ;;
   628           sparc)
   644           sparc)
   629             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   645             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   630             CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   646             CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   631             CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   647             CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   645     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   661     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   646     esac
   662     esac
   647     ;;
   663     ;;
   648   CL )
   664   CL )
   649     D_FLAG=
   665     D_FLAG=
   650     C_O_FLAG_HI="-O2"
   666     C_O_FLAG_HIGHEST="-O2"
       
   667     C_O_FLAG_HI="-O1"
   651     C_O_FLAG_NORM="-O1"
   668     C_O_FLAG_NORM="-O1"
   652     C_O_FLAG_NONE="-Od"
   669     C_O_FLAG_NONE="-Od"
       
   670     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
   653     CXX_O_FLAG_HI="$C_O_FLAG_HI"
   671     CXX_O_FLAG_HI="$C_O_FLAG_HI"
   654     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   672     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   655     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   673     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   656     ;;
   674     ;;
   657 esac
   675 esac
   678 
   696 
   679 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
   697 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
   680 [
   698 [
   681 
   699 
   682 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   700 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   683    AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags"])
   701    AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
   684 fi
   702 fi
   685 
   703 
   686 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   704 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   687    AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags"])
   705    AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
   688 fi
   706 fi
   689 
   707 
   690 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   708 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   691    AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags"])
   709    AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
   692 fi
   710 fi
   693 
   711 
   694 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   712 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   695     [extra flags to be used when compiling jdk c-files])])
   713     [extra flags to be used when compiling jdk c-files])])
   696 
   714 
   701     [extra flags to be used when linking jdk])])
   719     [extra flags to be used when linking jdk])])
   702 
   720 
   703 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   721 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   704 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   722 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   705 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
   723 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
       
   724 
       
   725 # Hotspot needs these set in their legacy form
       
   726 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
       
   727 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
       
   728 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
       
   729 
       
   730 AC_SUBST(LEGACY_EXTRA_CFLAGS)
       
   731 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
       
   732 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
   706 
   733 
   707 ###############################################################################
   734 ###############################################################################
   708 #
   735 #
   709 # Now setup the CFLAGS and LDFLAGS for the JDK build.
   736 # Now setup the CFLAGS and LDFLAGS for the JDK build.
   710 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   737 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   727 	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   754 	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   728           ;;
   755           ;;
   729 	  esac
   756 	  esac
   730           ;;
   757           ;;
   731       ossc )
   758       ossc )
   732       	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib"
   759           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
   733       	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX"
   760           case $OPENJDK_TARGET_CPU_ARCH in
       
   761           x86 )
       
   762             CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -Di386"
       
   763        	    CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
       
   764           ;;
       
   765           esac
       
   766 
       
   767       	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
       
   768       	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
       
   769 
       
   770           LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
       
   771           LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
   734           ;;
   772           ;;
   735       cl )
   773       cl )
   736           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   774           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   737                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
   775                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
   738 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   776 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   739 	       -DWIN32 -DIAL"
   777 	       -DWIN32 -DIAL"
   740           case $LEGACY_OPENJDK_TARGET_CPU1 in
   778           case $OPENJDK_TARGET_CPU in
   741               i?86 )
   779               x86 )
   742                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   780                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   743                   ;;
   781                   ;;
   744               amd64 )
   782               x86_64 )
   745                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   783                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   746                   ;;
   784                   ;;
   747           esac
   785           esac
   748           ;;
   786           ;;
   749 esac
   787 esac
   750 
   788 
   751 ###############################################################################
   789 ###############################################################################
   752 #
       
   753 # Cross-compile arch specific flags
       
   754 
       
   755 #
       
   756 if test "x$JDK_VARIANT" = "xembedded"; then
       
   757    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED"
       
   758 fi
       
   759 
       
   760 case $OPENJDK_TARGET_CPU_ARCH in
       
   761 arm )
       
   762     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
       
   763     ;;
       
   764 ppc )
       
   765     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
       
   766     ;;
       
   767 esac
       
   768 
       
   769 ###############################################################################
       
   770 
   790 
   771 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   791 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   772 
   792 
   773 # The package path is used only on macosx?
   793 # The package path is used only on macosx?
   774 PACKAGE_PATH=/opt/local
   794 PACKAGE_PATH=/opt/local
   775 AC_SUBST(PACKAGE_PATH)
   795 AC_SUBST(PACKAGE_PATH)
   776 
   796 
   777 # Sometimes we use a cpu dir (.../lib/amd64/server) 
   797 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   778 # Sometimes not (.../lib/server) 
   798     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
   779 LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/"
   799     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
   780 if test "x$ENDIAN" = xlittle; then
   800     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
   781     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
   801     #   Note: -Dmacro         is the same as    #define macro 1
       
   802     #         -Dmacro=	    is the same as    #define macro
       
   803     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   804         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
       
   805     else
       
   806         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
       
   807     fi
   782 else
   808 else
   783     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   809     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   784 fi
   810 fi
   785 if test "x$OPENJDK_TARGET_OS" = xlinux; then
   811 if test "x$OPENJDK_TARGET_OS" = xlinux; then
   786     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
   812     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
   791 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   817 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   792     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   818     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   793 fi
   819 fi
   794 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   820 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   795     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   821     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   796     LIBARCHDIR=""
       
   797 fi
   822 fi
   798 if test "x$OPENJDK_TARGET_OS" = xbsd; then
   823 if test "x$OPENJDK_TARGET_OS" = xbsd; then
   799     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
   824     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
   800 fi
   825 fi
   801 if test "x$DEBUG_LEVEL" = xrelease; then
   826 if test "x$DEBUG_LEVEL" = xrelease; then
   802     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
   827     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
       
   828     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   829         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
       
   830     fi
   803 else
   831 else
   804     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   832     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   805 fi
   833 fi
   806 
   834 
   807 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1"
   835 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
   808 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
   836 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
   809 
   837 
   810 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   838 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   811         -I${JDK_OUTPUTDIR}/include \
   839         -I${JDK_OUTPUTDIR}/include \
   812         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   840         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   813         -I${JDK_TOPDIR}/src/share/javavm/export \
   841         -I${JDK_TOPDIR}/src/share/javavm/export \
   814         -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \
   842         -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
   815         -I${JDK_TOPDIR}/src/share/native/common \
   843         -I${JDK_TOPDIR}/src/share/native/common \
   816         -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common"
   844         -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
   817 
   845 
   818 # The shared libraries are compiled using the picflag.
   846 # The shared libraries are compiled using the picflag.
   819 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   847 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   820 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   848 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   821 
   849 
   831 # libraries will link to whatever is in memory. Yuck. 
   859 # libraries will link to whatever is in memory. Yuck. 
   832 #
   860 #
   833 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   861 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   834 if test "x$COMPILER_TYPE" = xCL; then
   862 if test "x$COMPILER_TYPE" = xCL; then
   835     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   863     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   836     if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then 
   864     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
   837         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   865         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   838     fi
   866     fi
   839     # TODO: make -debug optional "--disable-full-debug-symbols"
   867     # TODO: make -debug optional "--disable-full-debug-symbols"
   840     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   868     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   841     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   869     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   859             LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   887             LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   860         fi
   888         fi
   861     fi
   889     fi
   862 
   890 
   863     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   891     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   864                     -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
   892                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \
   865                     -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
   893                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \
   866   	            -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}"
   894                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
   867     LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
   895 
       
   896     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
   868     if test "x$COMPILER_NAME" = xossc; then
   897     if test "x$COMPILER_NAME" = xossc; then
   869         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   898         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   870     fi
   899     fi
   871 
   900 
   872     # Only the jli library is explicitly linked when the launchers are built.
       
   873     # The libjvm is then dynamically loaded/linked by the launcher.
       
   874     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   901     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   875     if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
   902     if test "x$OPENJDK_TARGET_OS" = xlinux; then
   876        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
   903         LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
   877        LDFLAGS_JDKEXE_SUFFIX="-ljli"
       
   878     fi
   904     fi
   879 fi
   905 fi
   880 
   906 
   881 # Adjust flags according to debug level.
   907 # Adjust flags according to debug level.
   882 case $DEBUG_LEVEL in
   908 case $DEBUG_LEVEL in
   903 
   929 
   904 AC_SUBST(LDFLAGS_JDKLIB)
   930 AC_SUBST(LDFLAGS_JDKLIB)
   905 AC_SUBST(LDFLAGS_JDKEXE)
   931 AC_SUBST(LDFLAGS_JDKEXE)
   906 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   932 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   907 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
   933 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
       
   934 AC_SUBST(LDFLAGS_CXX_JDK)
   908 ])
   935 ])