1 #
   2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 AC_PREREQ([2.61])
  27 AC_INIT(openjdk, version-0.1, build-infra-dev@openjdk.java.net)
  28 
  29 AC_CONFIG_AUX_DIR([build-aux])
  30 
  31 m4_include([build-aux/pkg.m4])
  32 m4_include([builddeps.m4])
  33 m4_include([platform.m4])
  34 m4_include([cores.m4])
  35 m4_include([help.m4])
  36 
  37 # Save the command line. Do this very early, before it is lost by calling autoconf macros.
  38 CONFIGURE_COMMAND_LINE="$@"
  39 AC_SUBST(CONFIGURE_COMMAND_LINE)
  40 
  41 # Locate the directory of this script.
  42 SCRIPT="[$]0"
  43 REMOVE_SYMBOLIC_LINKS(SCRIPT)        
  44 AUTOCONF_DIR=`dirname [$]0`
  45 
  46 # Start with tools that do not need have cross compilation support
  47 # and can be expected to be found in the default PATH. These tools are
  48 # used by configure. Nor are these tools expected to be found in the
  49 # devkit from the builddeps server either, since they are
  50 # needed to download the devkit. 
  51 AC_PROG_AWK
  52 CHECK_NONEMPTY(AWK)
  53 AC_PATH_PROG(CAT, cat)
  54 CHECK_NONEMPTY(CAT)
  55 AC_PATH_PROG(CHMOD, chmod)
  56 CHECK_NONEMPTY(CHMOD)
  57 AC_PATH_PROG(CP, cp)
  58 CHECK_NONEMPTY(CP)
  59 AC_PATH_PROG(CPIO, cpio)
  60 CHECK_NONEMPTY(CPIO)
  61 AC_PATH_PROG(CUT, cut)
  62 CHECK_NONEMPTY(CUT)
  63 AC_PATH_PROG(DATE, date)
  64 CHECK_NONEMPTY(DATE)
  65 AC_PATH_PROG(DF, df)
  66 CHECK_NONEMPTY(DF)
  67 AC_PATH_PROG(DIFF, diff)
  68 CHECK_NONEMPTY(DIFF)
  69 # Warning echo is really, really unportable!!!!! Different
  70 # behaviour in bash and dash and in a lot of other shells!
  71 # Use printf for serious work! 
  72 AC_PATH_PROG(ECHO, echo)
  73 CHECK_NONEMPTY(ECHO)
  74 AC_PROG_EGREP
  75 CHECK_NONEMPTY(EGREP)
  76 AC_PROG_FGREP
  77 CHECK_NONEMPTY(FGREP)
  78 
  79 AC_PATH_PROG(FIND, find)
  80 CHECK_NONEMPTY(FIND)
  81 CHECK_FIND_DELETE
  82 AC_SUBST(FIND_DELETE)
  83 
  84 AC_PROG_GREP
  85 CHECK_NONEMPTY(GREP)
  86 AC_PATH_PROG(HEAD, head)
  87 CHECK_NONEMPTY(HEAD)
  88 AC_PATH_PROG(LN, ln)
  89 CHECK_NONEMPTY(LN)
  90 AC_PATH_PROG(LS, ls)
  91 CHECK_NONEMPTY(LS)
  92 AC_PATH_PROGS(MAKE, [gmake make])
  93 CHECK_NONEMPTY(MAKE)
  94 MAKE_VERSION=`$MAKE --version | head -n 1 | grep '3.8[[12346789]]'`
  95 if test "x$MAKE_VERSION" = x; then
  96     AC_ERROR([You must use GNU make 3.81 or newer! Please put it in the path.])
  97 fi
  98 AC_PATH_PROG(MKDIR, mkdir)
  99 CHECK_NONEMPTY(MKDIR)
 100 AC_PATH_PROG(MV, mv)
 101 CHECK_NONEMPTY(MV)
 102 AC_PATH_PROGS(NAWK, [nawk gawk awk])
 103 CHECK_NONEMPTY(NAWK)
 104 AC_PATH_PROG(PRINTF, printf)
 105 CHECK_NONEMPTY(PRINTF)
 106 AC_PATH_PROG(THEPWDCMD, pwd)
 107 AC_PATH_PROG(RM, rm)
 108 CHECK_NONEMPTY(RM)
 109 RM="$RM -f"
 110 AC_PROG_SED
 111 CHECK_NONEMPTY(SED)
 112 AC_PATH_PROG(SH, sh)
 113 CHECK_NONEMPTY(SH)
 114 AC_PATH_PROG(SORT, sort)
 115 CHECK_NONEMPTY(SORT)
 116 AC_PATH_PROG(TAR, tar)
 117 CHECK_NONEMPTY(TAR)
 118 AC_PATH_PROG(TAIL, tail)
 119 CHECK_NONEMPTY(TAIL)
 120 AC_PATH_PROG(TEE, tee)
 121 CHECK_NONEMPTY(TEE)
 122 AC_PATH_PROG(TR, tr)
 123 CHECK_NONEMPTY(TR)
 124 AC_PATH_PROG(TOUCH, touch)
 125 CHECK_NONEMPTY(TOUCH)
 126 AC_PATH_PROG(WC, wc)
 127 CHECK_NONEMPTY(WC)
 128 AC_PATH_PROG(XARGS, xargs)
 129 CHECK_NONEMPTY(XARGS)
 130 AC_PATH_PROG(ZIP, zip)
 131 CHECK_NONEMPTY(ZIP)
 132 AC_PATH_PROG(UNZIP, unzip)
 133 CHECK_NONEMPTY(UNZIP)
 134 AC_PATH_PROG(LDD, ldd)
 135 if test "x$LDD" = "x"; then
 136     # List shared lib dependencies is used for
 137     # debug output and checking for forbidden dependencies.
 138     # We can build without it.
 139     LDD="true"
 140 fi
 141 AC_PATH_PROG(OTOOL, otool)
 142 if test "x$OTOOL" = "x"; then
 143    OTOOL="true"
 144 fi
 145 AC_PATH_PROG(READELF, readelf)
 146 AC_PATH_PROG(EXPR, expr)
 147 CHECK_NONEMPTY(EXPR)
 148 AC_PATH_PROG(FILE, file)
 149 CHECK_NONEMPTY(FILE)
 150 # Figure out the build and host system.
 151 AC_CANONICAL_BUILD
 152 AC_CANONICAL_HOST
 153 
 154 AC_ARG_WITH(data-model, [AS_HELP_STRING([--with-data-model],
 155    [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-data-model=32 @<:@guessed@:>@])])
 156 
 157 if test "x$with_data_model" != x && \
 158    test "x$with_data_model" != x32 && \
 159    test "x$with_data_model" != x64 ; then
 160     AC_ERROR([The data model can only be 32 or 64!])
 161 fi
 162 # Translate the standard cpu-vendor-kernel-os quadruplets into
 163 # the new HOST_.... and BUILD_... and the legacy names used by
 164 # the openjdk build.
 165 # It uses $host_os $host_cpu $build_os $build_cpu and $with_data_model
 166 EXTRACT_HOST_AND_BUILD_AND_LEGACY_VARS
 167 # Now the following vars are defined.
 168 # HOST_OS=aix,bsd,hpux,linux,macosx,solaris,windows
 169 # HOST_OS_FAMILY=bsd,gnu,sysv,win32,wince
 170 # HOST_OS_API=posix,winapi
 171 #
 172 # HOST_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
 173 # HOST_CPU_ARCH=x86,sparc,pcc,arm
 174 # HOST_CPU_BITS=32,64
 175 # HOST_CPU_ENDIAN=big,little
 176 #
 177 # There is also a:
 178 # LEGACY_HOST_CPU1=i586,amd64,....  # used to set the old var ARCH
 179 # LEGACY_HOST_CPU2=i386,amd64,.... # used to set the old var LIBARCH
 180 # LEGACY_HOST_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
 181 # There was also a BUILDARCH that had i486,amd64,... but we do not use that
 182 # in the new build.
 183 # LEGACY_HOST_OS_API=solaris,windows # used to select source roots
 184 
 185 DATE_WHEN_CONFIGURED=`LANG=C date`
 186 AC_SUBST(DATE_WHEN_CONFIGURED)
 187 
 188 # How many cores do we have on this build system?
 189 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
 190     [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
 191 if test "x$with_num_cores" = x; then
 192     # The number of cores were not specified, try to probe them.
 193     CHECK_CORES
 194 else
 195     NUM_CORES=$with_num_cores
 196     CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2`
 197 fi
 198 AC_SUBST(NUM_CORES)
 199 AC_SUBST(CONCURRENT_BUILD_JOBS)
 200 
 201 # How many cores do we have on this build system?
 202 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
 203     [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
 204 if test "x$with_memory_size" = x; then
 205     # The memory size was not specified, try to probe it.
 206     CHECK_MEMORY_SIZE
 207 else
 208     MEMORY_SIZE=$with_memory_size
 209 fi
 210 AC_SUBST(MEMORY_SIZE)
 211 
 212 # Where is the source? It is located two levels above the configure script.
 213 CURDIR="$PWD"
 214 cd "$AUTOCONF_DIR/../.."
 215 SRC_ROOT="`pwd`"
 216 AC_SUBST(SRC_ROOT)
 217 cd "$CURDIR"
 218 
 219 # For cygwin we need cygpath first, since it is used everywhere.
 220 AC_PATH_PROG(CYGPATH, cygpath)
 221 PATH_SEP=":"
 222 if test "x$BUILD_OS" = "xwindows"; then
 223     if test "x$CYGPATH" = x; then
 224         AC_ERROR([Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path])
 225     fi
 226     PATH_SEP=";"
 227 fi
 228 AC_SUBST(PATH_SEP)
 229 
 230 SPACESAFE(SRC_ROOT,[the path to the source root])
 231 SPACESAFE(CURDIR,[the path to the current directory])
 232 
 233 if test "x$BUILD_OS" = "xsolaris"; then
 234     # Also search in /usr/ccs/bin for utilities like ar and as.
 235     PATH="/usr/ccs/bin:$PATH"
 236 fi
 237 
 238 ###############################################################################
 239 #
 240 # OpenJDK or closed
 241 #
 242 AC_ARG_ENABLE([openjdk], [AS_HELP_STRING([--enable-openjdk],
 243     [build OpenJDK regardless of the presence of closed repositories @<:@disabled@:>@])],,)
 244 
 245 if test "x$enable_openjdk" = "xyes"; then
 246     OPENJDK=true
 247 elif test "x$enable_openjdk" = "xno"; then
 248     OPENJDK=false
 249 elif test -d "$SRC_ROOT/jdk/src/closed"; then
 250     OPENJDK=false
 251 else
 252     OPENJDK=true
 253 fi
 254 
 255 if test "x$OPENJDK" = "xtrue"; then
 256     SET_OPENJDK=OPENJDK=true
 257 fi
 258 
 259 AC_SUBST(SET_OPENJDK)
 260 
 261 ###############################################################################
 262 #
 263 # JIGSAW or not.  The JIGSAW variable is used during the intermediate
 264 # stage when we are building both the old style JDK and the new style modularized JDK.
 265 # When the modularized JDK is finalized, this option will go away.
 266 #
 267 AC_ARG_ENABLE([jigsaw], [AS_HELP_STRING([--enable-jigsaw],
 268     [build Jigsaw images (not yet available) @<:@disabled@:>@])],,)
 269 
 270 if test "x$enable_jigsaw" = "xyes"; then
 271     JIGSAW=true
 272 else
 273     JIGSAW=false
 274 fi
 275 AC_SUBST(JIGSAW)
 276 
 277 ###############################################################################
 278 #
 279 # Check which variant of the JDK that we want to build.
 280 # Currently we have:
 281 #    normal:   standard edition   
 282 #    embedded: cut down to a smaller footprint
 283 #
 284 # Effectively the JDK variant gives a name to a specific set of
 285 # modules to compile into the JDK. In the future, these modules
 286 # might even be Jigsaw modules.
 287 #
 288 AC_MSG_CHECKING([which variant of the JDK to build])
 289 AC_ARG_WITH([jdk-variant], [AS_HELP_STRING([--with-jdk-variant],
 290         [JDK variant to build (normal, embedded) @<:@normal@:>@])])
 291 
 292 if test "x$with_jdk_variant" = xnormal || test "x$with_jdk_variant" = x; then
 293     JAVASE_EMBEDDED=""
 294     MINIMIZE_RAM_USAGE=""
 295     JDK_VARIANT="normal"
 296 elif test "x$with_jdk_variant" = xembedded; then
 297     JAVASE_EMBEDDED="JAVASE_EMBEDDED:=true"
 298     MINIMIZE_RAM_USAGE="MINIMIZE_RAM_USAGE:=true"
 299     JDK_VARIANT="embedded"
 300 else
 301     AC_ERROR([The available JDK variants are: normal, embedded])
 302 fi
 303                               
 304 AC_SUBST(JAVASE_EMBEDDED)
 305 AC_SUBST(MINIMIZE_RAM_USAGE)
 306 AC_SUBST(JDK_VARIANT)
 307 
 308 AC_MSG_RESULT([$JDK_VARIANT])
 309 
 310 ###############################################################################
 311 #
 312 # Should we build a JDK/JVM with head support (ie a graphical ui)?
 313 # We always build headless support.
 314 #
 315 AC_MSG_CHECKING([headful support])
 316 AC_ARG_ENABLE([headful], [AS_HELP_STRING([--disable-headful],
 317         [build headful support (graphical UI support) @<:@enabled@:>@])],
 318     [SUPPORT_HEADFUL=${enable_headful}], [SUPPORT_HEADFUL=yes])
 319 
 320 SUPPORT_HEADLESS=yes
 321 BUILD_HEADLESS="BUILD_HEADLESS:=true"
 322 
 323 if test "x$SUPPORT_HEADFUL" = xyes; then
 324     # We are building both headful and headless.
 325     BUILD_HEADLESS_ONLY=""
 326     headful_msg="inlude support for both headful and headless"
 327 fi
 328 
 329 if test "x$SUPPORT_HEADFUL" = xno; then
 330     # Thus we are building headless only.
 331     BUILD_HEADLESS="BUILD_HEADLESS:=true"
 332     BUILD_HEADLESS_ONLY="BUILD_HEADLESS_ONLY:=true"
 333     headful_msg="headless only"
 334 fi
 335 
 336 AC_MSG_RESULT([$headful_msg])
 337 
 338 AC_SUBST(SUPPORT_HEADLESS)
 339 AC_SUBST(SUPPORT_HEADFUL)
 340 AC_SUBST(BUILD_HEADLESS)
 341 AC_SUBST(BUILD_HEADLESS_ONLY)
 342 
 343 ###############################################################################
 344 #
 345 # Check which variants of the JVM that we want to build.
 346 # Currently we have:
 347 #    server: normal interpreter and a tiered C1/C2 compiler
 348 #    client: normal interpreter and C1 (no C2 compiler) (only 32-bit platforms)
 349 #    kernel: kernel footprint JVM that passes the TCK without major performance problems,
 350 #             ie normal interpreter and C1, only the serial GC, kernel jvmti etc
 351 #    zero: no machine code interpreter, no compiler
 352 #    zeroshark: zero interpreter and shark/llvm compiler backend
 353 AC_MSG_CHECKING([which variants of the JVM that should be built])
 354 AC_ARG_WITH([jvm-variants], [AS_HELP_STRING([--with-jvm-variants],
 355         [JVM variants (separated by commas) to build (server, client, kernel, zero, zeroshark) @<:@server@:>@])])
 356 
 357 if test "x$with_jvm_variants" = x; then
 358     if test "x$JDK_VARIANT" = xembedded; then
 359         with_jvm_variants="kernel"
 360     elif test "x$HOST_CPU_BITS" = x64; then
 361         with_jvm_variants="server"
 362     else
 363         # Yes, on 32-bit machines, the same source (almost) is compiled twice
 364         # to generate two libjvm.so files. Fun, fun.
 365         with_jvm_variants="client,server"
 366     fi
 367 fi
 368 
 369 JVM_VARIANTS=",$with_jvm_variants,"
 370 TEST_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/server,//' -e 's/client,//' -e 's/kernel,//' -e 's/zero,//' -e 's/zeroshark,//'`
 371 
 372 if test "x$TEST_VARIANTS" != "x,"; then
 373    AC_ERROR([The available JVM variants are: server, client, kernel, zero, zeroshark])
 374 fi   
 375 AC_MSG_RESULT([$with_jvm_variants])
 376 
 377 JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
 378 JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'` 
 379 JVM_VARIANT_KERNEL=`$ECHO "$JVM_VARIANTS" | $SED -e '/,kernel,/!s/.*/false/g' -e '/,kernel,/s/.*/true/g'`
 380 JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
 381 JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
 382 
 383 if test "x$JVM_VARIANT_CLIENT" = xtrue; then
 384     if test "x$HOST_CPU_BITS" = x64; then
 385         AC_ERROR([You cannot build a client JVM for a 64-bit machine.])
 386     fi
 387 fi
 388 if test "x$JVM_VARIANT_KERNEL" = xtrue; then
 389     if test "x$HOST_CPU_BITS" = x64; then
 390         AC_ERROR([You cannot build a kernel JVM for a 64-bit machine.])
 391     fi
 392 fi
 393 
 394 COUNT_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/server,/1/' -e 's/client,/1/' -e 's/kernel,/1/' -e 's/zero,/1/' -e 's/zeroshark,/1/'`
 395 # Replace the commas with AND for use in the build directory name.
 396 ANDED_JVM_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/^,//' -e 's/,$//' -e 's/,/AND/'`
 397 if test "x$COUNT_VARIANTS" != "x,1"; then
 398     AC_MSG_NOTICE([NOTE! Longer build time since we are building more than one version of the libjvm! $with_jvm_variants])
 399 fi
 400 
 401 AC_SUBST(JVM_VARIANTS)
 402 AC_SUBST(JVM_VARIANT_SERVER)
 403 AC_SUBST(JVM_VARIANT_CLIENT)
 404 AC_SUBST(JVM_VARIANT_KERNEL)
 405 AC_SUBST(JVM_VARIANT_ZERO)
 406 AC_SUBST(JVM_VARIANT_ZEROSHARK)
 407 
 408 ###############################################################################
 409 #
 410 # Set the debug level
 411 #    release: no debug information, all optimizations, no asserts.
 412 #    fastdebug: debug information (-g), all optimizations, all asserts
 413 #    slowdebug: debug information (-g), no optimizations, all asserts
 414 #
 415 DEBUG_LEVEL="release"              
 416 AC_MSG_CHECKING([which debug level to use])
 417 AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
 418         [set the debug level to fastdebug (shorthand for --with-debug-level=fastdebug) @<:@disabled@:>@])],
 419         [
 420         ENABLE_DEBUG="${enableval}"
 421         DEBUG_LEVEL="fastdebug"
 422     ], [ENABLE_DEBUG="no"])
 423 
 424 AC_ARG_WITH([debug-level], [AS_HELP_STRING([--with-debug-level],
 425         [set the debug level (release, fastdebug, slowdebug) @<:@release@:>@])],
 426         [
 427         DEBUG_LEVEL="${withval}"
 428         if test "x$ENABLE_DEBUG" = xyes; then
 429                         AC_ERROR([You cannot use both --enable-debug and --with-debug-level at the same time.])
 430         fi
 431     ])
 432 AC_MSG_RESULT([$DEBUG_LEVEL])
 433 
 434 if test "x$DEBUG_LEVEL" != xrelease && \
 435    test "x$DEBUG_LEVEL" != xfastdebug && \
 436    test "x$DEBUG_LEVEL" != xslowdebug; then
 437    AC_ERROR([Allowed debug levels are: release, fastdebug and slowdebug])
 438 fi
 439 
 440 case $DEBUG_LEVEL in
 441       release )
 442           VARIANT="OPT"
 443           FASTDEBUG="false"
 444           DEBUG_CLASSFILES="false"            
 445           BUILD_VARIANT_RELEASE=""             
 446            ;;
 447       fastdebug )
 448           VARIANT="DBG"
 449           FASTDEBUG="true"
 450           DEBUG_CLASSFILES="true"            
 451           BUILD_VARIANT_RELEASE="-fastdebug"
 452            ;;
 453       slowdebug )
 454           VARIANT="DBG"
 455           FASTDEBUG="false"
 456           DEBUG_CLASSFILES="true"            
 457           BUILD_VARIANT_RELEASE="-debug"             
 458            ;;
 459 esac
 460 
 461 AC_SUBST(DEBUG_LEVEL)
 462 AC_SUBST(VARIANT)
 463 AC_SUBST(FASTDEBUG)
 464 AC_SUBST(DEBUG_CLASSFILES)
 465 AC_SUBST(BUILD_VARIANT_RELEASE)
 466 
 467 # Source the version numbers
 468 . $AUTOCONF_DIR/version.numbers
 469 if test "x$OPENJDK" = "xfalse"; then
 470     . $AUTOCONF_DIR/closed.version.numbers
 471 fi
 472 # Now set the JDK version, milestone, build number etc.
 473 AC_SUBST(JDK_MAJOR_VERSION)
 474 AC_SUBST(JDK_MINOR_VERSION)
 475 AC_SUBST(JDK_MICRO_VERSION)
 476 AC_SUBST(JDK_UPDATE_VERSION)
 477 AC_SUBST(JDK_BUILD_NUMBER)
 478 AC_SUBST(MILESTONE)
 479 AC_SUBST(LAUNCHER_NAME)
 480 AC_SUBST(PRODUCT_NAME)
 481 AC_SUBST(PRODUCT_SUFFIX)
 482 AC_SUBST(JDK_RC_PLATFORM_NAME)
 483 AC_SUBST(COMPANY_NAME)
 484 
 485 COPYRIGHT_YEAR=`date +'%Y'`
 486 AC_SUBST(COPYRIGHT_YEAR)
 487 
 488 RUNTIME_NAME="$PRODUCT_NAME $PRODUCT_SUFFIX"
 489 AC_SUBST(RUNTIME_NAME)
 490 
 491 if test "x$JDK_UPDATE_VERSION" != x; then
 492     JDK_VERSION="${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_MICRO_VERSION}_${JDK_UPDATE_VERSION}"
 493 else
 494     JDK_VERSION="${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_MICRO_VERSION}"
 495 fi
 496 AC_SUBST(JDK_VERSION)
 497 
 498 if test "x$MILESTONE" != x; then
 499     RELEASE="${JDK_VERSION}-${MILESTONE}${BUILD_VARIANT_RELEASE}"
 500 else
 501     RELEASE="${JDK_VERSION}${BUILD_VARIANT_RELEASE}"
 502 fi
 503 AC_SUBST(RELEASE)
 504 
 505 if test "x$JDK_BUILD_NUMBER" != x; then
 506     FULL_VERSION="${RELEASE}-${JDK_BUILD_NUMBER}"
 507 else
 508     JDK_BUILD_NUMBER=b00
 509     BUILD_DATE=`date '+%Y_%m_%d_%H_%M'`
 510     # Avoid [:alnum:] since it depends on the locale.
 511     CLEAN_USERNAME=`echo "$USER" | $TR -d -c 'abcdefghijklmnopqrstuvqxyz0123456789'`
 512     USER_RELEASE_SUFFIX=`echo "${CLEAN_USERNAME}_${BUILD_DATE}" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
 513     FULL_VERSION="${RELEASE}-${USER_RELEASE_SUFFIX}-${JDK_BUILD_NUMBER}"
 514 fi
 515 AC_SUBST(FULL_VERSION)
 516 COOKED_BUILD_NUMBER=`$ECHO $JDK_BUILD_NUMBER | $SED -e 's/^b//' -e 's/^0//'`
 517 AC_SUBST(COOKED_BUILD_NUMBER)
 518 
 519 # Test from where we are running configure, in or outside of src root.
 520 if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
 521     # We are running configure from the src root.
 522     # Create a default ./build/host-variant-debuglevel output root.
 523     OUTPUT_ROOT="$SRC_ROOT/build/${HOST_OS}-${HOST_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
 524     mkdir -p "$OUTPUT_ROOT"
 525     if test ! -d "$OUTPUT_ROOT"; then
 526         AC_ERROR([Could not create build directory $OUTPUT_ROOT])
 527     fi
 528 else
 529     # We are running configure from outside of the src dir.
 530     # Then use the current directory as output dir!
 531     OUTPUT_ROOT="$CURDIR"
 532 fi
 533 
 534 SPACESAFE(OUTPUT_ROOT,[the path to the output root])
 535 
 536 # Save the arguments given to us
 537 echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
 538 
 539 # Check if the VS env variables were setup prior to running configure.
 540 # If not, then find vcvarsall.bat and run it automatically, and integrate
 541 # the set env variables into the spec file.
 542 SETUPDEVENV="# No special vars"
 543 if test "x$BUILD_OS" = "xwindows"; then
 544     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
 545     if test "x$VCINSTALLDIR" != x; then
 546         # No further setup is needed. The build will happen from this kind
 547         # of shell.
 548         SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt."
 549         # Make sure to remind you, if you forget to run make from a cygwin bash shell
 550         # that is spawned "bash -l" from a VS command prompt.
 551         CHECK_FOR_VCINSTALLDIR=yes
 552         AC_MSG_CHECKING([if you are running from within a VS command prompt])
 553         AC_MSG_RESULT([yes])
 554     else
 555         # Ah, we have not yet run vcvarsall.bat/vsvars32.bat/vsvars64.bat. Lets do that. First find it.
 556         if test "x$VS100COMNTOOLS" != x; then
 557             VARSBAT=`find "$VS100COMNTOOLS/../.." -name vcvarsall.bat`
 558             SEARCH_ROOT="$VS100COMNTOOLS"
 559         else
 560             VARSBAT=`find "$PROGRAMFILES" -name vcvarsall.bat`
 561             SEARCH_ROOT="$PROGRAMFILES"
 562         fi
 563         VCPATH=`dirname "$VARSBAT"`
 564         VCPATH=`cygpath -w "$VCPATH"`
 565         if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then
 566             AC_MSG_CHECKING([if we can find the VS installation])
 567             AC_MSG_RESULT([no])
 568             AC_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.])
 569         fi
 570         case "$LEGACY_HOST_CPU1" in
 571           i?86)
 572             VARSBAT_ARCH=x86
 573             ;;
 574           *)
 575             VARSBAT_ARCH=$LEGACY_HOST_CPU1
 576             ;;
 577         esac
 578         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
 579         cd $OUTPUT_ROOT
 580         $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH"
 581         cd $CURDIR
 582         if test ! -s $OUTPUT_ROOT/localdevenv.sh || test ! -s $OUTPUT_ROOT/localdevenv.gmk; then
 583             AC_MSG_CHECKING([if we can extract the needed env variables])
 584             AC_MSG_RESULT([no])
 585             AC_ERROR([Could not succesfully extract the env variables needed for the VS setup. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
 586         fi 
 587         # Now set all paths and other env variables. This will allow the rest of 
 588         # the configure script to find and run the compiler in the proper way.
 589         . $OUTPUT_ROOT/localdevenv.sh
 590         AC_MSG_CHECKING([if we can find the VS installation])
 591         if test "x$VCINSTALLDIR" != x; then 
 592             AC_MSG_RESULT([$VCINSTALLDIR])
 593         else 
 594             AC_MSG_RESULT([no])
 595             AC_ERROR([Could not find VS installation. Please install. If you are sure you have installed VS, then please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
 596         fi
 597         CHECK_FOR_VCINSTALLDIR=no
 598         SETUPDEVENV="include $OUTPUT_ROOT/localdevenv.gmk"
 599 
 600         AC_MSG_CHECKING([for msvcr100.dll])
 601         AC_ARG_WITH(msvcr100dll, [AS_HELP_STRING([--with-msvcr100dll],
 602             [copy this msvcr100.dll into the built JDK])])
 603         if test "x$with_msvcr100dll" != x; then
 604             MSVCR100DLL="$with_msvcr100dll"
 605         else
 606             if test "x$HOST_CPU_BITS" = x64; then
 607                 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x64 | head --lines 1`
 608             else
 609                 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
 610                 if test "x$MSVCR100DLL" = x; then
 611                     MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | head --lines 1`
 612                 fi
 613             fi
 614         fi
 615         if test "x$MSVCR100DLL" = x; then
 616            AC_MSG_RESULT([no])
 617            AC_ERROR([Could not find msvcr100.dll !])
 618         fi
 619         AC_MSG_RESULT([$MSVCR100DLL])
 620         SPACESAFE(MSVCR100DLL,[the path to msvcr100.dll])
 621     fi
 622 fi
 623 AC_SUBST(SETUPDEVENV)
 624 AC_SUBST(CHECK_FOR_VCINSTALLDIR)
 625 AC_SUBST(MSVCR100DLL)
 626 
 627 # Most of the probed defines are put into config.h
 628 AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
 629 # The spec.gmk file contains all variables for the make system.
 630 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
 631 # The generated Makefile knows where the spec.gmk is and where the source is.
 632 # You can run make from the OUTPUT_ROOT. If you have only
 633 # one configured host, then you can also run make from the SRC_ROOT,
 634 # since it will go look for a single spec.gmk file. Or perhaps it
 635 # should instead make all configured hosts it can find?
 636 AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
 637 
 638 AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
 639 AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
 640 
 641 # Where are the sources. Any of these can be overridden
 642 # using --with-override-corba and the likes.
 643 LANGTOOLS_TOPDIR="$SRC_ROOT/langtools"
 644 CORBA_TOPDIR="$SRC_ROOT/corba"
 645 JAXP_TOPDIR="$SRC_ROOT/jaxp"
 646 JAXWS_TOPDIR="$SRC_ROOT/jaxws"
 647 HOTSPOT_TOPDIR="$SRC_ROOT/hotspot"
 648 JDK_TOPDIR="$SRC_ROOT/jdk"
 649 AC_SUBST(LANGTOOLS_TOPDIR)
 650 AC_SUBST(CORBA_TOPDIR)
 651 AC_SUBST(JAXP_TOPDIR)
 652 AC_SUBST(JAXWS_TOPDIR)
 653 AC_SUBST(HOTSPOT_TOPDIR)
 654 AC_SUBST(JDK_TOPDIR)
 655 
 656 # Check if pkg-config is available.
 657 PKG_PROG_PKG_CONFIG
 658 
 659 AC_ARG_WITH(builddeps-conf, [AS_HELP_STRING([--with-builddeps-conf],
 660     [use this configuration file for the builddeps])])
 661 
 662 AC_ARG_WITH(builddeps-server, [AS_HELP_STRING([--with-builddeps-server],
 663     [download and use build dependencies from this server url, e.g. --with-builddeps-server=ftp://example.com/dir])])
 664 
 665 AC_ARG_WITH(builddeps-dir, [AS_HELP_STRING([--with-builddeps-dir],
 666     [store downloaded build dependencies here @<:@d/localhome/builddeps@:>@])],
 667     [],
 668     [with_builddeps_dir=/localhome/builddeps])
 669 
 670 AC_ARG_WITH(builddeps-group, [AS_HELP_STRING([--with-builddeps-group],
 671     [chgrp the downloaded build dependencies to this group])])
 672 
 673 AC_ARG_ENABLE([list-builddeps], [AS_HELP_STRING([--enable-list-builddeps],
 674         [list all build dependencies known to the configure script])],
 675         [LIST_BUILDDEPS="${enableval}"], [LIST_BUILDDEPS='no'])
 676 
 677 if test "x$LIST_BUILDDEPS" = xyes; then
 678     echo
 679     echo List of build dependencies known to the configure script,
 680     echo that can be used in builddeps.conf files:
 681     cat $SRC_ROOT/configure.ac | grep BDEPS_CHECK_MODUL | grep -v configure.ac | cut -f 2 -d ',' | tr -d ' ' | sort
 682     echo
 683     exit 1
 684 fi
 685 
 686 # If builddeps server or conf file is given. Setup buildeps usage.
 687 BDEPS_SCAN_FOR_BUILDDEPS
 688 
 689 ###############################################################################
 690 #
 691 # Configure the development tool paths and potential sysroot.
 692 #
 693 AC_LANG(C++)
 694 DEVKIT=
 695 SYS_ROOT=/
 696 AC_SUBST(SYS_ROOT)
 697 
 698 # The option used to specify the target .o,.a or .so file.
 699 # When compiling, how to specify the to be created object file.
 700 CC_OUT_OPTION='-o$(SPACE)'
 701 # When linking, how to specify the to be created executable.
 702 EXE_OUT_OPTION='-o$(SPACE)'
 703 # When linking, how to specify the to be created dynamically linkable library.
 704 LD_OUT_OPTION='-o$(SPACE)'
 705 # When archiving, how to specify the to be create static archive for object files.
 706 AR_OUT_OPTION='rcs$(SPACE)'
 707 AC_SUBST(CC_OUT_OPTION)
 708 AC_SUBST(EXE_OUT_OPTION)
 709 AC_SUBST(LD_OUT_OPTION)
 710 AC_SUBST(AR_OUT_OPTION)
 711 
 712 # If --build AND --host is set, then the configure script will find any
 713 # cross compilation tools in the PATH. Cross compilation tools
 714 # follows the cross compilation standard where they are prefixed with ${host}.
 715 # For example the binary i686-sun-solaris2.10-gcc
 716 # will cross compile for i686-sun-solaris2.10
 717 # If neither of build and host is not set, then build=host and the
 718 # default compiler found in the path will be used.
 719 # Setting only --host, does not seem to be really supported.
 720 # Please set both --build and --host if you want to cross compile.
 721 
 722 DEFINE_CROSS_COMPILE_ARCH=""
 723 HOSTCC=""
 724 HOSTCXX=""
 725 AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
 726 AC_SUBST(HOST_CC)
 727 AC_SUBST(HOST_CXX)
 728 AC_MSG_CHECKING([if this is a cross compile])
 729 if test "x$build_var" != "x$host_var"; then
 730     AC_MSG_RESULT([yes, from $build_var to $host_var])   
 731     # We have detected a cross compile!
 732     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_HOST_CPU1"
 733     # Now we to find a C/C++ compiler that can build executables for the build
 734     # platform. We can't use the AC_PROG_CC macro, since it can only be used
 735     # once.
 736     AC_PATH_PROGS(HOSTCC, [cl cc gcc])
 737     WHICHCMD(HOSTCC)
 738     AC_PATH_PROGS(HOSTCXX, [cl CC g++])
 739     WHICHCMD(HOSTCXX)
 740     # Building for the build platform should be easy. Therefore
 741     # we do not need any linkers or assemblers etc.    
 742 else
 743     AC_MSG_RESULT([no])
 744 fi
 745 
 746 # You can force the sys-root if the sys-root encoded into the cross compiler tools
 747 # is not correct.
 748 AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
 749     [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
 750      the cross compiler tools is incorrect)])])
 751 
 752 if test "x$with_sys_root" != x; then
 753     SYS_ROOT=$with_sys_root
 754 fi
 755                      
 756 # If a devkit is found on the builddeps server, then prepend its path to the
 757 # PATH variable. If there are cross compilers available in the devkit, these
 758 # will be found by AC_PROG_CC et al.
 759 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
 760                     [# Found devkit
 761                      PATH="$DEVKIT/bin:$PATH"
 762                      SYS_ROOT="$DEVKIT/${rewritten_host}/sys-root"
 763                      if test "x$x_includes" = "xNONE"; then
 764                          x_includes="$SYS_ROOT/usr/include/X11"
 765                      fi
 766                      if test "x$x_libraries" = "xNONE"; then
 767                          x_libraries="$SYS_ROOT/usr/lib"
 768                      fi
 769                     ],
 770                     [])
 771 
 772 if test "x$SYS_ROOT" != "x/" ; then                    
 773     CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
 774     CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
 775     OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
 776     OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
 777     CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
 778     LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
 779 fi
 780 
 781 # Store the CFLAGS etal passed to the configure script.
 782 ORG_CFLAGS="$CFLAGS"
 783 ORG_CXXFLAGS="$CXXFLAGS"
 784 ORG_OBJCFLAGS="$OBJCFLAGS"
 785 
 786 # gcc is almost always present, but on Windows we
 787 # prefer cl.exe and on Solaris we prefer CC.
 788 # Thus test for them in this order.
 789 AC_PROG_CC([cl cc gcc])
 790 if test "x$CC" = x; then
 791     help_on_build_dependency devkit
 792     AC_ERROR([Could not find a compiler. $HELP_MSG])
 793 fi
 794 if test "x$CC" = xcc && test "x$BUILD_OS" = xmacosx; then
 795     # Do not use cc on MacOSX use gcc instead.
 796     CC="gcc"
 797 fi
 798 WHICHCMD(CC)
 799 
 800 AC_PROG_CXX([cl CC g++])
 801 if test "x$CXX" = xCC && test "x$BUILD_OS" = xmacosx; then
 802     # The found CC, even though it seems to be a g++ derivate, cannot compile
 803     # c++ code. Override.
 804     CXX="g++"
 805 fi
 806 WHICHCMD(CXX)
 807 
 808 if test "x$CXX" = x || test "x$CC" = x; then
 809     help_on_build_dependency devkit
 810     AC_ERROR([Could not find the needed compilers! $HELP_MSG ])
 811 fi
 812 
 813 if test "x$BUILD_OS" != xwindows; then
 814     AC_PROG_OBJC
 815     WHICHCMD(OBJC)
 816 else
 817     OBJC=
 818 fi
 819 
 820 # Restore the flags to the user specified values.
 821 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
 822 CFLAGS="$ORG_CFLAGS"
 823 CXXFLAGS="$ORG_CXXFLAGS"
 824 OBJCFLAGS="$ORG_OBJCFLAGS"
 825 
 826 # If we are not cross compiling, use the same compilers for
 827 # building the build platform executables.
 828 if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
 829     HOSTCC="$CC"
 830     HOSTCXX="$CXX"
 831 fi
 832 
 833 AC_CHECK_TOOL(LD, ld)
 834 WHICHCMD(LD)
 835 LDEXE="$LD"
 836 LDCXX="$LD"
 837 LDEXECXX="$LD"
 838 # LDEXE is the linker to use, when creating executables.
 839 AC_SUBST(LDEXE)
 840 # Linking C++ libraries.
 841 AC_SUBST(LDCXX)
 842 # Linking C++ executables.
 843 AC_SUBST(LDEXECXX)
 844 
 845 AC_CHECK_TOOL(AR, ar)
 846 WHICHCMD(AR)
 847 if test "x$BUILD_OS" = xmacosx; then
 848     ARFLAGS="-r"
 849 else
 850     ARFLAGS=""
 851 fi
 852 AC_SUBST(ARFLAGS)
 853 
 854 COMPILER_NAME=gcc
 855 COMPILER_TYPE=CC
 856 AS_IF([test "x$BUILD_OS" = xwindows], [
 857     # For now, assume that we are always compiling using cl.exe. 
 858     CC_OUT_OPTION=-Fo
 859     EXE_OUT_OPTION=-Fe
 860     LD_OUT_OPTION=-out:
 861     AR_OUT_OPTION=-out:
 862     # On Windows, reject /usr/bin/link, which is a cygwin
 863     # program for something completely different.
 864     AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link])
 865     # Since we must ignore the first found link, WINLD will contain
 866     # the full path to the link.exe program.
 867     WHICHCMD_SPACESAFE([WINLD])
 868     LD="$WINLD"
 869     # However creating executables can only be done with cl.exe. 
 870     LDEXE="$CC"
 871     LDCXX="$WINLD"
 872     LDEXECXX="$CC"
 873 
 874     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
 875     WHICHCMD_SPACESAFE([MT])
 876     # The resource compiler
 877     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
 878     WHICHCMD_SPACESAFE([RC])
 879 
 880     RC_FLAGS="/l 0x409 /r"
 881     AS_IF([test "x$VARIANT" = xOPT], [
 882         RC_FLAGS="$RC_FLAGS -d NDEBUG"
 883     ])
 884     JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION
 885     AS_IF([test "x$JDK_UPDATE_VERSION" = x], [
 886         JDK_UPDATE_VERSION_NOTNULL=0
 887     ])
 888     RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\""
 889     RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\""
 890     RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\""
 891     RC_FLAGS="$RC_FLAGS -d \"JDK_VER=$JDK_MINOR_VERSION.$JDK_MICRO_VERSION.$JDK_UPDATE_VERSION_NOTNULL.$COOKED_BUILD_NUMBER\""
 892     RC_FLAGS="$RC_FLAGS -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\""
 893     RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
 894     RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
 895 
 896     # lib.exe is used to create static libraries.
 897     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
 898     WHICHCMD_SPACESAFE([WINAR])
 899     AR="$WINAR"
 900     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
 901 
 902     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
 903     WHICHCMD_SPACESAFE([DUMPBIN])
 904 
 905     COMPILER_TYPE=CL
 906     CFLAGS="$CFLAGS -nologo"
 907     LDFLAGS="$LDFLAGS -nologo -dll -opt:ref -incremental:no "
 908     if test "x$LEGACY_HOST_CPU1" = xi586; then 
 909         LDFLAGS="$LDFLAGS -safeseh"
 910     fi
 911     if test "x$DEBUG_LEVEL" != xrelease; then
 912         LDFLAGS="$LDFLAGS -debug"
 913     fi
 914 ])
 915 AC_SUBST(RC_FLAGS)
 916 AC_SUBST(COMPILER_TYPE)
 917 
 918 AC_PROG_CPP
 919 WHICHCMD(CPP)
 920 
 921 AC_PROG_CXXCPP
 922 WHICHCMD(CXXCPP)
 923 
 924 # Find the right assembler.
 925 if test "x$BUILD_OS" = xsolaris; then
 926     AC_PATH_PROG(AS, as)
 927     WHICHCMD(AS)
 928     ASFLAGS=" "
 929 else
 930     AS="$CC -c"
 931     ASFLAGS=" "
 932 fi
 933 AC_SUBST(AS)
 934 AC_SUBST(ASFLAGS)
 935 
 936 if test "x$HOST_CPU_BITS" = x32 && test "x$HOST_OS" = macosx; then
 937     # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
 938     # While waiting for a better solution, the current workaround is to use -mstackrealign.
 939     CFLAGS="$CFLAGS -mstackrealign"
 940     AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
 941     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
 942                    [
 943                         AC_MSG_RESULT([yes])
 944                    ],
 945                    [
 946                         AC_MSG_RESULT([no])
 947                         AC_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
 948                    ])
 949 fi
 950 
 951 if test "x$BUILD_OS" = xsolaris; then
 952     AC_PATH_PROG(NM, nm)
 953     WHICHCMD(NM)
 954     AC_PATH_PROG(STRIP, strip)
 955     WHICHCMD(STRIP)
 956     AC_PATH_PROG(MCS, mcs)
 957     WHICHCMD(MCS)
 958 else
 959     AC_CHECK_TOOL(NM, nm)
 960     WHICHCMD(NM)
 961     AC_CHECK_TOOL(STRIP, strip)
 962     WHICHCMD(STRIP)
 963 fi
 964 
 965 # When using cygwin, we need a wrapper binary that renames
 966 # /cygdrive/c/ arguments into c:/ arguments and peeks into
 967 # @files and rewrites these too! This wrapper binary is
 968 # called uncygdrive.exe.
 969 UNCYGDRIVE=
 970 if test "x$BUILD_OS" = xwindows; then
 971     AC_MSG_CHECKING([if uncygdrive can be created])
 972     UNCYGDRIVE_SRC=`$CYGPATH -m $SRC_ROOT/common/src/uncygdrive.c`
 973     rm -f $OUTPUT_ROOT/uncygdrive*
 974     UNCYGDRIVE=`$CYGPATH -m $OUTPUT_ROOT/uncygdrive.exe`
 975     cd $OUTPUT_ROOT
 976     $CC $UNCYGDRIVE_SRC /Fe$UNCYGDRIVE > $OUTPUT_ROOT/uncygdrive1.log 2>&1
 977     cd $CURDIR
 978 
 979     if test ! -x $OUTPUT_ROOT/uncygdrive.exe; then 
 980         AC_MSG_RESULT([no])
 981         cat $OUTPUT_ROOT/uncygdrive1.log
 982         AC_ERROR([Could not create $OUTPUT_ROOT/uncygdrive.exe])
 983     fi
 984     AC_MSG_RESULT([$UNCYGDRIVE])
 985     AC_MSG_CHECKING([if uncygdrive.exe works])
 986     cd $OUTPUT_ROOT
 987     $UNCYGDRIVE $CC $SRC_ROOT/common/src/uncygdrive.c /Fe$OUTPUT_ROOT/uncygdrive2.exe > $OUTPUT_ROOT/uncygdrive2.log 2>&1 
 988     cd $CURDIR
 989     if test ! -x $OUTPUT_ROOT/uncygdrive2.exe; then 
 990         AC_MSG_RESULT([no])
 991         cat $OUTPUT_ROOT/uncygdrive2.log
 992         AC_ERROR([Uncygdrive did not work!])
 993     fi
 994     AC_MSG_RESULT([yes])
 995     rm -f $OUTPUT_ROOT/uncygdrive?.??? $OUTPUT_ROOT/uncygdrive.obj
 996 fi
 997 
 998 AC_SUBST(UNCYGDRIVE)
 999 
1000 TESTFOR_PROG_CCACHE
1001 
1002 # Used on GNU/Linux systems, can be empty...
1003 #AC_PATH_PROG(ELFDUMP, elfdump)
1004 
1005 # Setup default logging of stdout and stderr to build.log in the output root.
1006 BUILD_LOG='$(OUTPUT_ROOT)/build.log'
1007 BUILD_LOG_WRAPPER='$(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
1008 AC_SUBST(BUILD_LOG)
1009 AC_SUBST(BUILD_LOG_WRAPPER)
1010 
1011 ###############################################################################
1012 #
1013 # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
1014 # (The JVM can use 32 or 64 bit Java pointers but that decision
1015 # is made at runtime.)
1016 #
1017 AC_CHECK_SIZEOF([int *], [1111])
1018 if test "x$ac_cv_sizeof_int_p" = x0; then 
1019     # The test failed, lets pick the assumed value.
1020     ARCH_DATA_MODEL=$HOST_CPU_BITS
1021 else
1022     ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
1023 fi
1024 
1025 if test "x$ARCH_DATA_MODEL" = x64; then
1026     A_LP64="LP64:="
1027     ADD_LP64="-D_LP64=1"
1028 fi
1029 AC_MSG_CHECKING([for host address size])
1030 AC_MSG_RESULT([$ARCH_DATA_MODEL bits])
1031 AC_SUBST(LP64,$A_LP64)
1032 AC_SUBST(ARCH_DATA_MODEL)
1033 
1034 if test "x$ARCH_DATA_MODEL" != "x$HOST_CPU_BITS"; then
1035     AC_ERROR([The tested number of bits in the host ($ARCH_DATA_MODEL) differs from the number of bits expected to be found in the host ($HOST_CPU_BITS)])
1036 fi
1037 
1038 ###############################################################################
1039 #
1040 # Can the C/C++ compiler use precompiled headers?
1041 #
1042 AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers],
1043         [use precompiled headers when compiling C++ @<:@enabled@:>@])],
1044     [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes])
1045 
1046 USE_PRECOMPILED_HEADER=1
1047 if test "x$ENABLE_PRECOMPH" = xno; then
1048     USE_PRECOMPILED_HEADER=0
1049 fi
1050 
1051 if test "x$ENABLE_PRECOMPH" = xyes; then
1052     # Check that the compiler actually supports precomp headers.
1053     if test "x$GCC" = xyes; then
1054          AC_MSG_CHECKING([that precompiled headers work])         
1055          echo "int alfa();" > conftest.h
1056          $CXX -x c++-header conftest.h -o conftest.hpp.gch
1057          if test ! -f conftest.hpp.gch; then
1058              echo Precompiled header is not working!
1059              USE_PRECOMPILED_HEADER=0
1060              AC_MSG_RESULT([no])        
1061          else
1062              AC_MSG_RESULT([yes])
1063          fi
1064          rm -f conftest.h
1065     fi
1066 fi
1067 
1068 AC_SUBST(USE_PRECOMPILED_HEADER)
1069 
1070 ###############################################################################
1071 #
1072 # How to compile shared libraries. 
1073 #
1074 
1075 if test "x$GCC" = xyes; then
1076     COMPILER_NAME=gcc
1077     PICFLAG="-fPIC"
1078     LIBRARY_PREFIX=lib
1079     SHARED_LIBRARY='lib$1.so'
1080     STATIC_LIBRARY='lib$1.a'
1081     SHARED_LIBRARY_FLAGS="-shared"
1082     SHARED_LIBRARY_SUFFIX='.so'
1083     STATIC_LIBRARY_SUFFIX='.a'
1084     OBJ_SUFFIX='.o'
1085     EXE_SUFFIX=''
1086     SET_SHARED_LIBRARY_NAME='-Xlinker -soname=$1'
1087     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=$(JDK_TOPDIR)/$1'
1088     SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/$1'
1089     LD="$CC"
1090     LDEXE="$CC"
1091     LDCXX="$CXX"
1092     LDEXECXX="$CXX"
1093 
1094     # Linking is different on MacOSX
1095     if test "x$BUILD_OS" = xmacosx; then
1096         # Might change in the future to clang.
1097         COMPILER_NAME=gcc
1098         SHARED_LIBRARY='lib$1.dylib'
1099         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
1100         SHARED_LIBRARY_SUFFIX='.dylib'
1101         EXE_SUFFIX=''
1102         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/$1' 
1103         SET_SHARED_LIBRARY_MAPFILE=''
1104         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
1105     fi
1106 else
1107     if test "x$BUILD_OS" = xsolaris; then
1108         # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
1109         COMPILER_NAME=ossc
1110         PICFLAG="-KPIC"
1111         LIBRARY_PREFIX=lib
1112         SHARED_LIBRARY='lib$1.so'
1113         STATIC_LIBRARY='lib$1.a'
1114         SHARED_LIBRARY_FLAGS="-G"
1115         SHARED_LIBRARY_SUFFIX='.so'
1116         STATIC_LIBRARY_SUFFIX='.a'
1117         OBJ_SUFFIX='.o'
1118         EXE_SUFFIX=''
1119         SET_SHARED_LIBRARY_NAME=''
1120         SET_SHARED_LIBRARY_MAPFILE='-M $(JDK_TOPDIR)/$1'
1121         SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/$1'
1122         CFLAGS_JDKLIB_EXTRA='-xstrconst -D__solaris__'
1123     fi
1124     if test "x$BUILD_OS" = xwindows; then
1125         # If it is not gcc, then assume it is the MS Visual Studio compiler
1126         COMPILER_NAME=cl
1127         PICFLAG=""
1128         LIBRARY_PREFIX=
1129         SHARED_LIBRARY='$1.dll'
1130         STATIC_LIBRARY='$1.lib'
1131         SHARED_LIBRARY_FLAGS="-LD"
1132         SHARED_LIBRARY_SUFFIX='.dll'
1133         STATIC_LIBRARY_SUFFIX='.lib'
1134         OBJ_SUFFIX='.obj'
1135         EXE_SUFFIX='.exe'
1136         SET_SHARED_LIBRARY_NAME=''
1137         SET_SHARED_LIBRARY_MAPFILE=''
1138         SET_SHARED_LIBRARY_ORIGIN=''
1139     fi
1140 fi
1141 
1142 AC_SUBST(OBJ_SUFFIX)
1143 AC_SUBST(SHARED_LIBRARY)
1144 AC_SUBST(STATIC_LIBRARY)
1145 AC_SUBST(LIBRARY_PREFIX)
1146 AC_SUBST(SHARED_LIBRARY_SUFFIX)
1147 AC_SUBST(STATIC_LIBRARY_SUFFIX)
1148 AC_SUBST(EXE_SUFFIX)
1149 AC_SUBST(SHARED_LIBRARY_FLAGS)
1150 AC_SUBST(SET_SHARED_LIBRARY_NAME)
1151 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
1152 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
1153 
1154 # The (cross) compiler is now configured, we can now test capabilities
1155 # of the host platform.
1156 
1157 ###############################################################################
1158 #
1159 # Is the host little of big endian?
1160 #
1161 AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal"])
1162 
1163 if test "x$ENDIAN" = xuniversal; then
1164     AC_ERROR([It seems like someone needs to decide how we are to deal with universal binaries on the MacOSX?])
1165 fi
1166 if test "x$ENDIAN" = xunknown; then
1167     ENDIAN="$HOST_CPU_ENDIAN"
1168 fi
1169 if test "x$ENDIAN" != "x$HOST_CPU_ENDIAN"; then
1170     AC_WARN([The tested endian in the host ($ENDIAN) differs from the endian expected to be found in the host ($HOST_CPU_ENDIAN)])
1171     ENDIAN="$HOST_CPU_ENDIAN"
1172 fi
1173 AC_SUBST(ENDIAN)
1174 
1175 ###############################################################################
1176 #
1177 # We need a Boot JDK to bootstrap the build. 
1178 #
1179 BOOT_JDK_FOUND=no
1180 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
1181     [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
1182                     
1183 if test "x$with_boot_jdk" != x; then
1184     BOOT_JDK=$with_boot_jdk
1185     BOOT_JDK_FOUND=yes
1186 fi
1187 if test "x$BOOT_JDK_FOUND" = xno; then
1188     BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=yes], [BOOT_JDK_FOUND=no])
1189 fi
1190 
1191 if test "x$BOOT_JDK_FOUND" = xno; then
1192     if test "x$JAVA_HOME" != x; then
1193         if test ! -d "$JAVA_HOME"; then
1194             AC_ERROR([Your JAVA_HOME points to a non-existing directory!])
1195         fi
1196         # Aha, the user has set a JAVA_HOME
1197         # let us use that as the Boot JDK.
1198         BOOT_JDK=$JAVA_HOME
1199         BOOT_JDK_FOUND=yes
1200         # To be on the safe side, lets check that it is a JDK.
1201         if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
1202             JAVAC=$BOOT_JDK/bin/javac
1203             JAVA=$BOOT_JDK/bin/java
1204             BOOT_JDK_FOUND=yes
1205         else
1206             AC_ERROR([Your JAVA_HOME points to a JRE! The build needs a JDK! Please point JAVA_HOME to a JDK.])
1207         fi            
1208     fi
1209 fi
1210 
1211 if test "x$BOOT_JDK_FOUND" = xno; then
1212     AC_PATH_PROG(JAVAC_CHECK, javac)
1213     AC_PATH_PROG(JAVA_CHECK, java)
1214     BINARY="$JAVAC_CHECK"
1215     if test "x$JAVAC_CHECK" = x; then
1216         BINARY="$JAVA_CHECK"
1217     fi
1218     if test "x$BINARY" != x; then
1219         # So there is a java(c) binary, it might be part of a JDK.
1220         # Lets find the JDK/JRE directory by following symbolic links.
1221         # Linux/GNU systems often have links from /usr/bin/java to 
1222         # /etc/alternatives/java to the real JDK binary.
1223         WHICHCMD_SPACESAFE(BINARY,[path to javac])
1224         REMOVE_SYMBOLIC_LINKS(BINARY)
1225         BOOT_JDK=`dirname $BINARY`
1226         BOOT_JDK=`cd $BOOT_JDK/..; pwd`
1227         if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
1228             JAVAC=$BOOT_JDK/bin/javac
1229             JAVA=$BOOT_JDK/bin/java
1230             BOOT_JDK_FOUND=yes
1231         fi
1232     fi
1233 fi
1234 
1235 if test "x$BOOT_JDK_FOUND" = xno; then
1236     # Try the MacOSX way.
1237     if test -x /usr/libexec/java_home; then
1238         BOOT_JDK=`/usr/libexec/java_home`
1239         if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
1240             JAVAC=$BOOT_JDK/bin/javac
1241             JAVA=$BOOT_JDK/bin/java
1242             BOOT_JDK_FOUND=yes
1243         fi
1244     fi
1245 fi
1246 
1247 if test "x$BOOT_JDK_FOUND" = xno; then
1248     AC_PATH_PROG(JAVA_CHECK, java)
1249     if test "x$JAVA_CHECK" != x; then
1250         # There is a java in the path. But apparently we have not found a javac 
1251         # in the path, since that would have been tested earlier.
1252         if test "x$HOST_OS" = xwindows; then
1253             # Now if this is a windows platform. The default installation of a JDK
1254             # actually puts the JRE in the path and keeps the JDK out of the path!
1255             # Go look in the default installation location.
1256             BOOT_JDK=/cygdrive/c/Program\ Files/Java/`ls /cygdrive/c/Program\ Files/Java | grep jdk | sort -r | head --lines 1`
1257             if test -d "$BOOT_JDK"; then
1258                 BOOT_JDK_FOUND=yes
1259             fi
1260         fi
1261         if test "x$BOOT_JDK_FOUND" = xno; then
1262             help_on_build_dependency openjdk
1263             AC_ERROR([Found a JRE, not not a JDK! Please remove the JRE from your path and put a JDK there instead. $HELP_MSG])
1264         fi
1265     else
1266         help_on_build_dependency openjdk
1267         AC_ERROR([Could not find a JDK. $HELP_MSG])
1268     fi
1269 fi
1270 
1271 WIN_FIX_PATH(BOOT_JDK)
1272 
1273 # Now see if we can find the rt.jar, or its nearest equivalent.
1274 BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar"
1275 SPACESAFE(BOOT_RTJAR,[the path to the Boot JDK rt.jar (or nearest equivalent)])
1276 
1277 BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar"
1278 SPACESAFE(BOOT_TOOLSJAR,[the path to the Boot JDK tools.jar (or nearest equivalent)])
1279 
1280 if test ! -f $BOOT_RTJAR; then
1281     # On MacOSX it is called classes.jar
1282     BOOT_RTJAR=$BOOT_JDK/../Classes/classes.jar
1283     if test ! -f $BOOT_RTJAR; then
1284         AC_ERROR([Cannot find the rt.jar or its equivalent!])
1285     fi
1286     # Remove the .. 
1287     BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
1288     # The tools.jar is part of classes.jar
1289     BOOT_TOOLSJAR="$BOOT_RTJAR"
1290 fi
1291 
1292 AC_SUBST(BOOT_JDK)
1293 AC_SUBST(BOOT_RTJAR)
1294 AC_SUBST(BOOT_TOOLSJAR)
1295 AC_MSG_CHECKING([for Boot JDK])
1296 AC_MSG_RESULT([$BOOT_JDK])
1297 AC_MSG_CHECKING([for Boot rt.jar])
1298 AC_MSG_RESULT([$BOOT_RTJAR])
1299 AC_MSG_CHECKING([for Boot tools.jar])
1300 AC_MSG_RESULT([$BOOT_TOOLSJAR])
1301 
1302 # Use the java tool from the Boot JDK.
1303 AC_MSG_CHECKING([for java in Boot JDK])
1304 JAVA=$BOOT_JDK/bin/java
1305 if test ! -x $JAVA; then
1306     AC_ERROR([Could not find a working java])
1307 fi
1308 BOOT_JDK_VERSION=`$JAVA -version 2>&1 | head -n 1`
1309 AC_MSG_RESULT([yes $BOOT_JDK_VERSION])
1310 AC_SUBST(JAVA)
1311 
1312 # Extra M4 quote needed to protect [] in grep expression.
1313 [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`]
1314 if test "x$FOUND_VERSION_78" = x; then
1315     help_on_build_dependency openjdk
1316     AC_ERROR([Your bootjdk must be version 7 or 8. $HELP_MSG])
1317 fi
1318 
1319 # When compiling code to be executed by the Boot JDK, force jdk7 compatibility.
1320 BOOT_JDK_SOURCETARGET="-source 7 -target 7"
1321 AC_SUBST(BOOT_JDK_SOURCETARGET)
1322 
1323 # Use the javac tool from the Boot JDK.
1324 AC_MSG_CHECKING([for javac in Boot JDK])
1325 JAVAC=$BOOT_JDK/bin/javac
1326 if test ! -x $JAVAC; then
1327     AC_ERROR([Could not find a working javac])
1328 fi
1329 AC_MSG_RESULT(yes)
1330 AC_SUBST(JAVAC)
1331 AC_SUBST(JAVAC_FLAGS)
1332 
1333 # Use the javac tool from the Boot JDK.
1334 AC_MSG_CHECKING([for javah in Boot JDK])
1335 JAVAH=$BOOT_JDK/bin/javah
1336 if test ! -x $JAVAH; then
1337     AC_ERROR([Could not find a working javah])
1338 fi
1339 AC_MSG_RESULT(yes)
1340 AC_SUBST(JAVAH)
1341 
1342 # Use the jar tool from the Boot JDK.
1343 AC_MSG_CHECKING([for jar in Boot JDK])
1344 JAR=$BOOT_JDK/bin/jar
1345 if test ! -x $JAR; then
1346     AC_ERROR([Could not find a working jar])
1347 fi
1348 AC_SUBST(JAR)
1349 AC_MSG_RESULT(yes)
1350 
1351 # Use the rmic tool from the Boot JDK.
1352 AC_MSG_CHECKING([for rmic in Boot JDK])
1353 RMIC=$BOOT_JDK/bin/rmic
1354 if test ! -x $RMIC; then
1355     AC_ERROR([Could not find a working rmic])
1356 fi
1357 AC_SUBST(RMIC)
1358 AC_MSG_RESULT(yes)
1359 
1360 ###############################################################################
1361 #
1362 # Pickup additional source for a component from outside of the source root
1363 # or override source for a component. 
1364 #
1365 AC_ARG_WITH(add-source-root, [AS_HELP_STRING([--with-add-source-root],
1366     [for each and every source directory, look in this additional source root for
1367      the same directory; if it exists and have files in it, include it in the build])])                             
1368                              
1369 AC_ARG_WITH(override-source-root, [AS_HELP_STRING([--with-override-source-root],
1370     [for each and every source directory, look in this override source root for
1371      the same directory; if it exists, use that directory instead and
1372      ignore the directory in the original source root])])
1373 
1374 AC_ARG_WITH(adds-and-overrides, [AS_HELP_STRING([--with-adds-and-overrides],
1375     [use the subdirs 'adds' and 'overrides' in the specified directory as
1376      add-source-root and override-source-root])])
1377 
1378 if test "x$with_adds_and_overrides" != x; then
1379     with_add_source_root="$with_adds_and_overrides/adds"
1380     with_override_source_root="$with_adds_and_overrides/overrides"
1381 fi
1382 
1383 if test "x$with_add_source_root" != x; then
1384     if ! test -d $with_add_source_root; then
1385        AC_ERROR([Trying to use a non-existant add-source-root $with_add_source_root])
1386     fi
1387     CURDIR="$PWD"
1388     cd "$with_add_source_root"
1389     ADD_SRC_ROOT="`pwd`"
1390     cd "$CURDIR"
1391     # Verify that the addon source root does not have any root makefiles.
1392     # If it does, then it is usually an error, prevent this.
1393     if test -f $with_add_source_root/langtools/makefiles/Makefile || \
1394        test -f $with_add_source_root/langtools/make/Makefile; then
1395         AC_ERROR([Your add source root seems to contain a full langtools repo! An add source root should only contain additional sources.])
1396     fi
1397     if test -f $with_add_source_root/corba/makefiles/Makefile || \
1398        test -f $with_add_source_root/corba/make/Makefile; then
1399         AC_ERROR([Your add source root seems to contain a full corba repo! An add source root should only contain additional sources.])
1400     fi
1401     if test -f $with_add_source_root/jaxp/makefiles/Makefile || \
1402        test -f $with_add_source_root/jaxp/make/Makefile; then
1403         AC_ERROR([Your add source root seems to contain a full jaxp repo! An add source root should only contain additional sources.])
1404     fi
1405     if test -f $with_add_source_root/jaxws/makefiles/Makefile || \
1406        test -f $with_add_source_root/jaxws/make/Makefile; then
1407         AC_ERROR([Your add source root seems to contain a full jaxws repo! An add source root should only contain additional sources.])
1408     fi
1409     if test -f $with_add_source_root/hotspot/makefiles/Makefile || \
1410        test -f $with_add_source_root/hotspot/make/Makefile; then
1411         AC_ERROR([Your add source root seems to contain a full hotspot repo! An add source root should only contain additional sources.])
1412     fi
1413     if test -f $with_add_source_root/jdk/makefiles/Makefile || \
1414        test -f $with_add_source_root/jdk/make/Makefile; then
1415         AC_ERROR([Your add source root seems to contain a full JDK repo! An add source root should only contain additional sources.])
1416     fi
1417 fi
1418 AC_SUBST(ADD_SRC_ROOT)
1419 
1420 if test "x$with_override_source_root" != x; then
1421     if ! test -d $with_override_source_root; then
1422        AC_ERROR([Trying to use a non-existant override-source-root $with_override_source_root])
1423     fi
1424     CURDIR="$PWD"
1425     cd "$with_override_source_root"
1426     OVERRIDE_SRC_ROOT="`pwd`"
1427     cd "$CURDIR"
1428     if test -f $with_override_source_root/langtools/makefiles/Makefile || \
1429        test -f $with_override_source_root/langtools/make/Makefile; then
1430         AC_ERROR([Your override source root seems to contain a full langtools repo! An override source root should only contain sources that override.])
1431     fi
1432     if test -f $with_override_source_root/corba/makefiles/Makefile || \
1433        test -f $with_override_source_root/corba/make/Makefile; then
1434         AC_ERROR([Your override source root seems to contain a full corba repo! An override source root should only contain sources that override.])
1435     fi
1436     if test -f $with_override_source_root/jaxp/makefiles/Makefile || \
1437        test -f $with_override_source_root/jaxp/make/Makefile; then
1438         AC_ERROR([Your override source root seems to contain a full jaxp repo! An override source root should only contain sources that override.])
1439     fi
1440     if test -f $with_override_source_root/jaxws/makefiles/Makefile || \
1441        test -f $with_override_source_root/jaxws/make/Makefile; then
1442         AC_ERROR([Your override source root seems to contain a full jaxws repo! An override source root should only contain sources that override.])
1443     fi
1444     if test -f $with_override_source_root/hotspot/makefiles/Makefile || \
1445        test -f $with_override_source_root/hotspot/make/Makefile; then
1446         AC_ERROR([Your override source root seems to contain a full hotspot repo! An override source root should only contain sources that override.])
1447     fi
1448     if test -f $with_override_source_root/jdk/makefiles/Makefile || \
1449        test -f $with_override_source_root/jdk/make/Makefile; then
1450         AC_ERROR([Your override source root seems to contain a full JDK repo! An override source root should only contain sources that override.])
1451     fi
1452 fi
1453 AC_SUBST(OVERRIDE_SRC_ROOT)
1454 
1455 ###############################################################################
1456 #
1457 # Override a repo completely, this is used for example when you have 3 small
1458 # development sandboxes of the langtools sources and want to avoid having 3 full
1459 # OpenJDK sources checked out on disk.
1460 #
1461 # Assuming that the 3 langtools sandboxes are located here:
1462 # /home/fredrik/sandbox1/langtools
1463 # /home/fredrik/sandbox2/langtools
1464 # /home/fredrik/sandbox3/langtools
1465 #
1466 # From the source root you create build subdirs manually:
1467 #     mkdir -p build1 build2 build3 
1468 # in each build directory run:
1469 #     (cd build1 && ../configure --with-override-langtools=/home/fredrik/sandbox1 && make)
1470 #     (cd build2 && ../configure --with-override-langtools=/home/fredrik/sandbox2 && make)
1471 #     (cd build3 && ../configure --with-override-langtools=/home/fredrik/sandbox3 && make)
1472 #
1473 
1474 AC_ARG_WITH(override-langtools, [AS_HELP_STRING([--with-override-langtools],
1475     [use this langtools dir for the build])])
1476 
1477 AC_ARG_WITH(override-corba, [AS_HELP_STRING([--with-override-corba],
1478     [use this corba dir for the build])])
1479 
1480 AC_ARG_WITH(override-jaxp, [AS_HELP_STRING([--with-override-jaxp],
1481         [use this jaxp dir for the build])])
1482 
1483 AC_ARG_WITH(override-jaxws, [AS_HELP_STRING([--with-override-jaxws],
1484         [use this jaxws dir for the build])])
1485 
1486 AC_ARG_WITH(override-hotspot, [AS_HELP_STRING([--with-override-hotspot],
1487         [use this hotspot dir for the build])])
1488 
1489 AC_ARG_WITH(override-jdk, [AS_HELP_STRING([--with-override-jdk],
1490         [use this jdk dir for the build])])
1491 
1492 if test "x$with_override_langtools" != x; then
1493     CURDIR="$PWD"
1494     cd "$with_override_langtools"
1495     LANGTOOLS_TOPDIR="`pwd`"
1496     cd "$CURDIR"
1497     if ! test -f $LANGTOOLS_TOPDIR/makefiles/Makefile; then
1498         AC_ERROR([You have to override langtools with a full langtools repo!])
1499     fi
1500     AC_MSG_CHECKING([if langtools should be overridden])
1501     AC_MSG_RESULT([yes with $LANGTOOLS_TOPDIR])
1502 fi    
1503 if test "x$with_override_corba" != x; then
1504     CURDIR="$PWD"
1505     cd "$with_override_corba"
1506     CORBA_TOPDIR="`pwd`"
1507     cd "$CURDIR"
1508     if ! test -f $CORBA_TOPDIR/makefiles/Makefile; then
1509         AC_ERROR([You have to override corba with a full corba repo!])
1510     fi
1511     AC_MSG_CHECKING([if corba should be overridden])
1512     AC_MSG_RESULT([yes with $CORBA_TOPDIR])
1513 fi    
1514 if test "x$with_override_jaxp" != x; then
1515     CURDIR="$PWD"
1516     cd "$with_override_jaxp"
1517     JAXP_TOPDIR="`pwd`"
1518     cd "$CURDIR"
1519     if ! test -f $JAXP_TOPDIR/makefiles/Makefile; then
1520         AC_ERROR([You have to override jaxp with a full jaxp repo!])
1521     fi
1522     AC_MSG_CHECKING([if jaxp should be overridden])
1523     AC_MSG_RESULT([yes with $JAXP_TOPDIR])
1524 fi    
1525 if test "x$with_override_jaxws" != x; then
1526     CURDIR="$PWD"
1527     cd "$with_override_jaxws"
1528     JAXWS_TOPDIR="`pwd`"
1529     cd "$CURDIR"
1530     if ! test -f $JAXWS_TOPDIR/makefiles/Makefile; then
1531         AC_ERROR([You have to override jaxws with a full jaxws repo!])
1532     fi
1533     AC_MSG_CHECKING([if jaxws should be overridden])
1534     AC_MSG_RESULT([yes with $JAXWS_TOPDIR])
1535 fi    
1536 if test "x$with_override_hotspot" != x; then
1537     CURDIR="$PWD"
1538     cd "$with_override_hotspot"
1539     HOTSPOT_TOPDIR="`pwd`"
1540     cd "$CURDIR"
1541     if ! test -f $HOTSPOT_TOPDIR/make/Makefile && \
1542        ! test -f $HOTSPOT_TOPDIR/makefiles/Makefile; then
1543         AC_ERROR([You have to override hotspot with a full hotspot repo!])
1544     fi
1545     AC_MSG_CHECKING([if hotspot should be overridden])
1546     AC_MSG_RESULT([yes with $HOTSPOT_TOPDIR])
1547 fi    
1548 if test "x$with_override_jdk" != x; then
1549     CURDIR="$PWD"
1550     cd "$with_override_jdk"
1551     JDK_TOPDIR="`pwd`"
1552     cd "$CURDIR"
1553     if ! test -f $JDK_TOPDIR/makefiles/Makefile; then
1554         AC_ERROR([You have to override JDK with a full JDK repo!])
1555     fi
1556     AC_MSG_CHECKING([if JDK should be overridden])
1557     AC_MSG_RESULT([yes with $JDK_TOPDIR])
1558 fi    
1559 
1560 ###############################################################################
1561 #
1562 # Specify options for anything that is run with the Boot JDK.
1563 #
1564 AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
1565         [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values,
1566      e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])])
1567 
1568 if test "x$with_boot_jdk_jvmargs" = x; then
1569     # Not all JVM:s accept the same arguments on the command line.
1570     # OpenJDK specific increase in thread stack for JDK build,
1571     # well more specifically, when running javac.
1572     if test "x$BUILD_NUM_BITS" = x32; then
1573        STACK_SIZE=768
1574     else
1575        # Running Javac on a JVM on a 64-bit machine, the stack takes more space
1576        # since 64-bit pointers are pushed on the stach. Apparently, we need
1577        # to increase the stack space when javacing the JDK....
1578        STACK_SIZE=1536
1579     fi
1580 
1581     # Minimum amount of heap memory.
1582     ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA])
1583     if test "x$HOST_OS" = "xmacosx"; then
1584         # Why does macosx need more heap? Its the huge JDK batch.
1585         ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA])
1586     else
1587         ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA])
1588     fi
1589     # When is adding -client something that speeds up the JVM?
1590     # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA])
1591     ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA])
1592     ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA])
1593     ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA])
1594     # Disable special log output when a debug build is used as Boot JDK...
1595     ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA])
1596 fi
1597 
1598 AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs)
1599 
1600 AC_ARG_WITH(server-java, [AS_HELP_STRING([--with-server-java],
1601         [use this java binary for running the javac background server and other long running java tasks in the build process,
1602      e.g. ---with-server-java="/opt/jrockit/bin/java -server"])])
1603 
1604 if test "x$with_server_java" != x; then
1605     SERVER_JAVA="$with_server_java"
1606     FOUND_VERSION=`$SERVER_JAVA -version 2>&1 | grep " version \""`
1607     if test "x$FOUND_VERSION" = x; then
1608         AC_ERROR([Could not execute server java: $SERVER_JAVA])
1609     fi
1610 else
1611     SERVER_JAVA=""
1612     # Hotspot specific options.
1613     ADD_JVM_ARG_IF_OK([-XX:+UseParallelOldGC],SERVER_JAVA,[$JAVA])
1614     ADD_JVM_ARG_IF_OK([-verbosegc],SERVER_JAVA,[$JAVA])
1615     # JRockit specific options.
1616     ADD_JVM_ARG_IF_OK([-Xverbose:gc],SERVER_JAVA,[$JAVA])
1617     SERVER_JAVA="$JAVA $SERVER_JAVA"
1618 fi                    
1619 AC_SUBST(SERVER_JAVA)
1620 
1621 AC_MSG_CHECKING([whether to use shared server for javac])
1622 AC_ARG_ENABLE([javac-server], [AS_HELP_STRING([--enable-javac-server],
1623         [enable the shared javac server during the build process @<:@disabled@:>@])],
1624         [ENABLE_JAVAC_SERVER="${enableval}"], [ENABLE_JAVAC_SERVER='no'])
1625 AC_MSG_RESULT([$ENABLE_JAVAC_SERVER])
1626 if test "x$ENABLE_JAVAC_SERVER" = xyes; then
1627     JAVAC_USE_REMOTE=true
1628     JAVAC_SERVERS="$OUTPUT_ROOT/javacservers"
1629 else
1630     JAVAC_USE_REMOTE=false
1631     JAVAC_SERVERS=
1632 fi
1633 AC_SUBST(JAVAC_USE_REMOTE)
1634 AC_SUBST(JAVAC_SERVERS)
1635 
1636 AC_ARG_WITH(javac-server-cores, [AS_HELP_STRING([--with-javac-server-cores],
1637         [use at most this number of concurrent threads on the javac server @<:@probed@:>@])])
1638 if test "x$with_javac_server_cores" != x; then
1639     JAVAC_SERVER_CORES="$with_javac_server_cores"
1640 else
1641     if test "$NUM_CORES" -gt 16; then
1642         # We set this arbitrary limit because we want to limit the heap
1643         # size of the javac server.
1644         # In the future we will make the javac compilers in the server
1645         # share more and more state, thus enabling us to use more and
1646         # more concurrent threads in the server.
1647         JAVAC_SERVER_CORES="16"
1648     else
1649         JAVAC_SERVER_CORES="$NUM_CORES"
1650     fi
1651 
1652     if test "$MEMORY_SIZE" -gt "17000"; then
1653         MAX_HEAP_MEM=10000
1654         ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
1655         ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SERVER_JAVA,[$SERVER_JAVA])
1656         ADD_JVM_ARG_IF_OK([-Xmn2G],SERVER_JAVA,[$SERVER_JAVA])
1657     elif test "$MEMORY_SIZE" -gt "10000"; then
1658         MAX_HEAP_MEM=6000
1659         ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
1660         ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SERVER_JAVA,[$SERVER_JAVA])
1661         ADD_JVM_ARG_IF_OK([-Xmn1G],SERVER_JAVA,[$SERVER_JAVA])
1662     elif test "$MEMORY_SIZE" -gt "5000"; then
1663         MAX_HEAP_MEM=3000
1664         ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
1665         ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SERVER_JAVA,[$SERVER_JAVA])
1666         ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
1667     elif test "$MEMORY_SIZE" -gt "3800"; then
1668         MAX_HEAP_MEM=2500
1669         ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SERVER_JAVA,[$SERVER_JAVA])
1670         ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
1671     elif test "$MEMORY_SIZE" -gt "1900"; then
1672         MAX_HEAP_MEM=1200
1673         ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1200M],SERVER_JAVA,[$SERVER_JAVA])
1674         ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
1675     elif test "$MEMORY_SIZE" -gt "1000"; then
1676         MAX_HEAP_MEM=900
1677         ADD_JVM_ARG_IF_OK([-Xms400M -Xmx900M],SERVER_JAVA,[$SERVER_JAVA])
1678         ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA])
1679     else
1680         MAX_HEAP_MEM=512
1681         ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SERVER_JAVA,[$SERVER_JAVA])
1682         ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA])
1683     fi
1684 
1685     MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501`
1686     if test "$JAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
1687         AC_MSG_CHECKING([if number of server cores must be reduced])
1688         JAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
1689         AC_MSG_RESULT([yes, to $JAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB])
1690     fi
1691 fi                    
1692 AC_SUBST(JAVAC_SERVER_CORES)
1693 
1694 AC_MSG_CHECKING([whether to track dependencies between Java packages])
1695 AC_ARG_ENABLE([javac-deps], [AS_HELP_STRING([--enable-javac-deps],
1696         [enable the dependency tracking between Java packages @<:@disabled@:>@])],
1697         [ENABLE_JAVAC_DEPS="${enableval}"], [ENABLE_JAVAC_DEPS='no'])
1698 AC_MSG_RESULT([$ENABLE_JAVAC_DEPS])
1699 if test "x$ENABLE_JAVAC_DEPS" = xyes; then
1700     JAVAC_USE_DEPS=true
1701 else
1702     JAVAC_USE_DEPS=false
1703 fi
1704 AC_SUBST(JAVAC_USE_DEPS)
1705 
1706 AC_MSG_CHECKING([whether to use multiple cores for javac compilation])
1707 AC_ARG_ENABLE([javac-multi-core], [AS_HELP_STRING([--enable-javac-multi-core],
1708         [compile Java packages concurrently @<:@disabled@:>@])],
1709         [ENABLE_JAVAC_MULTICORE="${enableval}"], [ENABLE_JAVAC_MULTICORE='no'])
1710 AC_MSG_RESULT([$ENABLE_JAVAC_MULTICORE])
1711 if test "x$ENABLE_JAVAC_MULTICORE" = xyes; then
1712     JAVAC_USE_MODE=MULTI_CORE_CONCURRENT
1713 else
1714     JAVAC_USE_MODE=SINGLE_THREADED_BATCH
1715     if test "x$ENABLE_JAVAC_DEPS" = xyes; then
1716         AC_MSG_WARN([Dependency tracking is not supported with single threaded batch compiles of Java source roots. Please add --disable-javac-deps to your configure options.])
1717         AC_MSG_WARN([Disabling dependency tracking for you now.])
1718         JAVAC_USE_DEPS=false
1719     fi
1720     if test "x$ENABLE_JAVAC_SERVER" = xyes; then
1721         AC_MSG_WARN([The javac server will not be used since single threaded batch compiles are run within their own JVM. Please add --disable-javac-server to your configure options.])
1722         AC_MSG_WARN([Disabling javac server for you now.])
1723         JAVAC_USE_REMOTE=false
1724     fi
1725 fi
1726 AC_SUBST(JAVAC_USE_MODE)
1727 
1728 ###############################################################################
1729 #
1730 # OS specific settings that we never will need to probe.
1731 #
1732 if test "x$HOST_OS" = xlinux; then
1733     AC_MSG_CHECKING([what is not needed on Linux?])
1734     PULSE_NOT_NEEDED=yes
1735     AC_MSG_RESULT([pulse])
1736 fi
1737 
1738 if test "x$HOST_OS" = xsolaris; then
1739     AC_MSG_CHECKING([what is not needed on Solaris?])
1740     ALSA_NOT_NEEDED=yes
1741     PULSE_NOT_NEEDED=yes
1742     AC_MSG_RESULT([alsa pulse])
1743 fi
1744 
1745 if test "x$HOST_OS" = xwindows; then
1746     AC_MSG_CHECKING([what is not needed on Windows?])
1747     CUPS_NOT_NEEDED=yes    
1748     ALSA_NOT_NEEDED=yes
1749     PULSE_NOT_NEEDED=yes
1750     X11_NOT_NEEDED=yes
1751     AC_MSG_RESULT([alsa cups pulse x11])
1752 fi
1753 
1754 if test "x$HOST_OS" = xmacosx; then
1755     AC_MSG_CHECKING([what is not needed on MacOSX?])
1756     ALSA_NOT_NEEDED=yes
1757     PULSE_NOT_NEEDED=yes
1758     X11_NOT_NEEDED=yes
1759     FREETYPE2_NOT_NEEDED=yes    
1760     # If the java runtime framework is disabled, then we need X11.
1761     # This will be adjusted below.
1762     AC_MSG_RESULT([alsa pulse x11])
1763 fi
1764 
1765 if test "x$HOST_OS" = xbsd; then
1766     AC_MSG_CHECKING([what is not needed on bsd?])
1767     ALSA_NOT_NEEDED=yes
1768     AC_MSG_RESULT([alsa])    
1769 fi
1770 
1771 ###############################################################################
1772 #
1773 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
1774 # that uses this API. 
1775 #
1776 AC_ARG_ENABLE([macosx-runtime-support], [AS_HELP_STRING([--disable-macosx-runtime-support],
1777         [disable the use of MacOSX Java runtime support framework @<:@enabled@:>@])],
1778         [MACOSX_RUNTIME_SUPPORT="${enableval}"],[MACOSX_RUNTIME_SUPPORT="no"])
1779 
1780 USE_MACOSX_RUNTIME_SUPPORT=no
1781 AC_MSG_CHECKING([for explicit Java runtime support in the OS])
1782 if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
1783     if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then
1784         MACOSX_RUNTIME_SUPPORT=yes
1785         USE_MACOSX_RUNTIME_SUPPORT=yes
1786         AC_MSG_RESULT([yes, does not need alsa freetype2 pulse and X11])
1787     else
1788         AC_MSG_RESULT([yes, but explicitly disabled.])
1789     fi
1790 else
1791     AC_MSG_RESULT([no])
1792 fi
1793 
1794 if test "x$HOST_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then
1795     AC_MSG_CHECKING([what is not needed on an X11 build on MacOSX?])
1796     X11_NOT_NEEDED=
1797     FREETYPE2_NOT_NEEDED=
1798     AC_MSG_RESULT([alsa pulse])
1799 fi
1800 
1801 ###############################################################################
1802 #
1803 # Check for X Windows
1804 #
1805 AC_PATH_XTRA
1806 
1807 if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 
1808     help_on_build_dependency x11
1809     AC_ERROR([Could not find X11 libraries. $HELP_MSG])
1810 fi
1811 
1812 AC_SUBST(X_CFLAGS)
1813 AC_SUBST(X_LIBS)
1814 
1815 # Some of the old makefiles require a setting of OPENWIN_HOME
1816 # Since the X11R6 directory has disappeared on later Linuxes,
1817 # we need to probe for it.
1818 if test "x$HOST_OS" = xlinux; then
1819     if test -d "$SYS_ROOT/usr/X11R6"; then
1820         OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
1821     fi
1822     if test -d "$SYS_ROOT/usr/include/X11"; then
1823         OPENWIN_HOME="$SYS_ROOT/usr"
1824     fi
1825 fi
1826 if test "x$HOST_OS" = xsolaris; then
1827     OPENWIN_HOME="/usr/openwin"
1828 fi
1829 AC_SUBST(OPENWIN_HOME)
1830 
1831 AC_LANG_PUSH(C)
1832 OLD_CFLAGS="$CFLAGS"
1833 CFLAGS="$CFLAGS $X_CFLAGS"
1834 AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
1835                 [X11_A_OK=yes],
1836                 [X11_A_OK=no])
1837 CFLAGS="$OLD_CFLAGS"
1838 AC_LANG_POP(C)
1839 
1840 if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 
1841     help_on_build_dependency x11
1842     AC_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG])
1843 fi
1844 
1845 ###############################################################################
1846 #
1847 # The common unix printing system cups is used to print from java.
1848 #
1849 AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
1850     [specify prefix directory for the cups package
1851          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
1852 AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
1853         [specify directory for the cups include files])])
1854 AC_ARG_WITH(cups-lib, [AS_HELP_STRING([--with-cups-lib],
1855         [specify directory for the cups library])])
1856 
1857 if test "x$CUPS_NOT_NEEDED" = xyes; then
1858         if test "x$with_cups" != x || test "x$with_cups-include" != x || test "x$with_cups-lib" != x; then
1859                 AC_MSG_WARN([cups not used, so --with-cups is ignored])
1860         fi
1861         CUPS_CFLAGS=
1862         CUPS_LIBS=
1863 else
1864         CUPS_FOUND=no
1865 
1866         if test "x$with_cups" = xno || test "x$with_cups-include" = xno || test "x$with_cups-lib" = xno; then
1867             AC_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
1868         fi
1869 
1870         if test "x$with_cups" != x; then
1871             CUPS_LIBS="-L$with_cups/lib -lcups"
1872             CUPS_CFLAGS="-I$with_cups/include"
1873             CUPS_FOUND=yes
1874         fi
1875         if test "x$with_cups-include" != x; then
1876             CUPS_CFLAGS="-I$with_cups-include"
1877             CUPS_FOUND=yes
1878         fi
1879         if test "x$with_cups-lib" != x; then
1880             CUPS_LIBS="-L$with_cups-lib -lcups"
1881             CUPS_FOUND=yes
1882         fi
1883         if test "x$CUPS_FOUND" = xno; then
1884             BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
1885         fi
1886         if test "x$CUPS_FOUND" = xno; then
1887             # Are the cups headers installed in the default /usr/include location?
1888             AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
1889                              [CUPS_FOUND=yes
1890                               CUPS_CFLAGS=
1891                               CUPS_LIBS="-lcups"
1892                               DEFAULT_CUPS=yes])
1893         fi
1894         if test "x$CUPS_FOUND" = xno; then
1895             # Getting nervous now? Lets poke around for standard Solaris third-party
1896             # package installation locations.
1897             AC_MSG_CHECKING([for cups headers and libs])
1898             if test -s /opt/sfw/cups/include/cups/cups.h; then
1899                # An SFW package seems to be installed!
1900                CUPS_FOUND=yes
1901                CUPS_CFLAGS="-I/opt/sfw/cups/include"
1902                CUPS_LIBS="-L/opt/sfw/cups/lib -lcups"
1903             elif test -s /opt/csw/include/cups/cups.h; then
1904                # A CSW package seems to be installed!
1905                CUPS_FOUND=yes
1906                CUPS_CFLAGS="-I/opt/csw/include"
1907                CUPS_LIBS="-L/opt/csw/lib -lcups"
1908             fi
1909             AC_MSG_RESULT([$CUPS_FOUND])
1910         fi
1911         if test "x$CUPS_FOUND" = xno; then 
1912             help_on_build_dependency cups
1913             AC_ERROR([Could not find cups! $HELP_MSG ])
1914         fi
1915 fi
1916 
1917 AC_SUBST(CUPS_CFLAGS)
1918 AC_SUBST(CUPS_LIBS)
1919 
1920 ###############################################################################
1921 #
1922 # The ubiquitous freetype2 library is used to render fonts.
1923 #
1924 AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
1925         [specify prefix directory for the freetype2 package
1926      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
1927 
1928 # If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
1929 USING_SYSTEM_FT_LIB=false
1930 
1931 if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
1932         if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
1933                 AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
1934         fi
1935         FREETYPE2_CFLAGS=
1936         FREETYPE2_LIBS=
1937         FREETYPE2_LIB_PATH=
1938 else
1939         FREETYPE2_FOUND=no
1940 
1941         if test "x$with_freetype" != x; then
1942             SPACESAFE(with_freetype,[the path to freetype])
1943             FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
1944             if test "x$HOST_OS" = xwindows; then
1945                 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
1946             fi
1947             FREETYPE2_LIB_PATH="$with_freetype/lib"
1948             FREETYPE2_CFLAGS="-I$with_freetype/include"
1949             if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
1950                 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
1951             fi
1952             FREETYPE2_FOUND=yes
1953             if test "x$FREETYPE2_FOUND" = xyes; then
1954                 # Verify that the directories exist 
1955                 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
1956                    AC_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
1957                 fi
1958                 # List the contents of the lib.
1959                 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
1960                 if test "x$FREETYPELIB" = x; then
1961                    AC_ERROR([Could not find libfreetype.se nor freetype.dll in $with_freetype/lib])
1962                 fi
1963                 # Check one h-file
1964                 if ! test -s "$with_freetype/include/ft2build.h"; then
1965                    AC_ERROR([Could not find $with_freetype/include/ft2build.h])
1966                 fi
1967             fi
1968         fi
1969         if test "x$FREETYPE2_FOUND" = xno; then
1970             BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
1971             USING_SYSTEM_FT_LIB=true
1972         fi
1973         if test "x$FREETYPE2_FOUND" = xno; then
1974             PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
1975             USING_SYSTEM_FT_LIB=true
1976         fi
1977         if test "x$FREETYPE2_FOUND" = xno; then
1978             AC_MSG_CHECKING([for freetype in some standard locations])
1979         
1980             if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then
1981                 DEFAULT_FREETYPE_CFLAGS="-I/usr/X11/include/freetype2 -I/usr/X11/include"
1982                 DEFAULT_FREETYPE_LIBS="-L/usr/X11/lib -lfreetype"
1983             fi
1984             if test -s /usr/include/ft2build.h && test -d /usr/include/freetype2/freetype; then
1985                 DEFAULT_FREETYPE_CFLAGS="-I/usr/include/freetype2"
1986                 DEFAULT_FREETYPE_LIBS="-lfreetype"
1987             fi
1988         
1989             PREV_CXXCFLAGS="$CXXFLAGS"
1990             PREV_LDFLAGS="$LDFLAGS"
1991             CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
1992             LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
1993             AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
1994                             #include FT_FREETYPE_H 
1995                            int main() { return 0; }
1996                           ]])],
1997                           [
1998                               # Yes, the default cflags and libs did the trick.
1999                               FREETYPE2_FOUND=yes
2000                               FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
2001                               FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
2002                           ],
2003                           [
2004                               FREETYPE2_FOUND=no
2005                           ])
2006             CXXCFLAGS="$PREV_CXXFLAGS"
2007             LDFLAGS="$PREV_LDFLAGS"
2008             AC_MSG_RESULT([$FREETYPE2_FOUND])
2009             USING_SYSTEM_FT_LIB=true
2010         fi
2011         if test "x$FREETYPE2_FOUND" = xno; then
2012                 help_on_build_dependency freetype2
2013                 AC_ERROR([Could not find freetype2! $HELP_MSG ])
2014         fi    
2015 fi
2016 
2017 AC_SUBST(USING_SYSTEM_FT_LIB)
2018 AC_SUBST(FREETYPE2_LIB_PATH)
2019 AC_SUBST(FREETYPE2_CFLAGS)
2020 AC_SUBST(FREETYPE2_LIBS)
2021 
2022 ###############################################################################
2023 #
2024 # Check for alsa headers and libraries. Used on Linux/GNU systems.
2025 #
2026 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
2027         [specify prefix directory for the alsa package
2028          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
2029 AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
2030         [specify directory for the alsa include files])])
2031 AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
2032         [specify directory for the alsa library])])
2033 
2034 if test "x$ALSA_NOT_NEEDED" = xyes; then
2035         if test "x$with_alsa" != x || test "x$with_alsa-include" != x || test "x$with_alsa-lib" != x; then
2036                 AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
2037         fi
2038         ALSA_CFLAGS=
2039         ALSA_LIBS=
2040 else
2041         ALSA_FOUND=no
2042 
2043         if test "x$with_alsa" = xno || test "x$with_alsa-include" = xno || test "x$with_alsa-lib" = xno; then
2044             AC_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
2045         fi
2046 
2047         if test "x$with_alsa" != x; then
2048             ALSA_LIBS="-L$with_alsa/lib -lalsa"
2049             ALSA_CFLAGS="-I$with_alsa/include"
2050             ALSA_FOUND=yes
2051         fi
2052         if test "x$with_alsa-include" != x; then
2053             ALSA_CFLAGS="-I$with_alsa/include"
2054             ALSA_FOUND=yes
2055         fi
2056         if test "x$with_alsa-lib" != x; then
2057             ALSA_LIBS="-L$with_alsa/lib -lalsa"
2058             ALSA_FOUND=yes
2059         fi
2060         if test "x$ALSA_FOUND" = xno; then
2061             BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
2062         fi
2063         if test "x$ALSA_FOUND" = xno; then
2064             PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
2065         fi
2066         if test "x$ALSA_FOUND" = xno; then
2067             AC_CHECK_HEADERS([alsa/asoundlib.h],
2068                              [ALSA_FOUND=yes
2069                               ALSA_CFLAGS=-Iignoreme
2070                               ALSA_LIBS=-lasound
2071                               DEFAULT_ALSA=yes],
2072                              [ALSA_FOUND=no])
2073         fi
2074         if test "x$ALSA_FOUND" = xno; then 
2075             help_on_build_dependency alsa
2076             AC_ERROR([Could not find alsa! $HELP_MSG ])
2077         fi    
2078 fi
2079 
2080 AC_SUBST(ALSA_CFLAGS)
2081 AC_SUBST(ALSA_LIBS)
2082 
2083 ###############################################################################
2084 #
2085 # Check for pulse audio headers and libraries.
2086 #
2087 PULSE_FOUND=no
2088 AC_ARG_WITH(pulse, [AS_HELP_STRING([--with-pulse],
2089         [specify prefix directory for the pulseaudio package
2090          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
2091 AC_ARG_WITH(pulse-include, [AS_HELP_STRING([--with-pulse-include],
2092         [specify directory for the pulseaudio include files])])
2093 AC_ARG_WITH(pulse-lib, [AS_HELP_STRING([--with-pulse-lib],
2094         [specify directory for the pulseaudio library])])
2095 
2096 if test "x$with_pulse" != x; then
2097     PULSE_LIBS="-L$with_pulse/lib -lfreetype"
2098     PULSE_CFLAGS="-I$with_pulse/include"
2099     PULSE_FOUND=yes
2100 fi
2101 if test "x$with_pulse-include" != x; then
2102     PULSE_CFLAGS="-I$with_pulse/include"
2103     PULSE_FOUND=yes
2104 fi
2105 if test "x$with_pulse-lib" != x; then
2106     PULSE_LIBS="-L$with_pulse/lib -lfreetype"
2107     PULSE_FOUND=yes
2108 fi
2109 if test "x$PULSE_FOUND" = xno; then
2110     BDEPS_CHECK_MODULE(PULSE, pulse, xxx, [PULSE_FOUND=yes], [PULSE_FOUND=no])
2111 fi
2112 if test "x$PULSE_FOUND" = xno; then
2113     PKG_CHECK_MODULES(LIBPULSE,[libpulse >= 0.9.11],[PULSE_FOUND=yes],[PULSE_FOUND=no])
2114 fi
2115 if test "x$PULSE_FOUND" = xno; then
2116     AC_CHECK_HEADERS([pulse/pulseaudio.h],
2117                      [PULSE_FOUND=yes
2118                       PULSE_CFLAGS=-Iignoreme
2119                       PULSE_LIBS=
2120                       DEFAULT_PULSE=yes],
2121                      [PULSE_FOUND=no])
2122 fi
2123 
2124 if test "x$PULSE_FOUND" = xno && test "x$PULSE_NOT_NEEDED" != xyes; then 
2125     help_on_build_dependency pulse
2126     AC_ERROR([Could not find pulse audio libraries. $HELP_MSG ])
2127 fi    
2128 
2129 AC_SUBST(PULSE_CFLAGS)
2130 AC_SUBST(PULSE_LIBS)
2131 
2132 ###############################################################################
2133 #
2134 # Check for the jpeg library
2135 #
2136 
2137 USE_EXTERNAL_LIBJPEG=true
2138 AC_CHECK_LIB(jpeg, main, [],
2139              [ USE_EXTERNAL_LIBJPEG=false
2140                AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
2141              ])
2142 AC_SUBST(USE_EXTERNAL_LIBJPEG)
2143         
2144 ###############################################################################
2145 #
2146 # Check for the gif library
2147 #
2148 
2149 USE_EXTERNAL_LIBJPEG=true
2150 AC_CHECK_LIB(gif, main, [],
2151              [ USE_EXTERNAL_LIBGIF=false
2152                AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source])
2153              ])
2154 AC_SUBST(USE_EXTERNAL_LIBGIF)
2155 
2156 ###############################################################################
2157 #
2158 # Check for the zlib library
2159 #
2160 
2161 USE_EXTERNAL_LIBZ=true
2162 AC_CHECK_LIB(z, main, [],
2163              [ USE_EXTERNAL_LIBZ=false
2164                AC_MSG_NOTICE([Will use zlib bundled with the OpenJDK source])
2165              ])
2166 AC_SUBST(USE_EXTERNAL_LIBZ)
2167 
2168 ###############################################################################
2169 #
2170 # Check if altzone exists in time.h
2171 #
2172 
2173 AC_TRY_LINK([#include <time.h>], [return (int)altzone;],
2174             has_altzone=yes,
2175             has_altzone=no)
2176 if test "x$has_altzone" = xyes; then
2177     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
2178 fi
2179 
2180 ###############################################################################
2181 #
2182 # Check the maths library
2183 #
2184 
2185 AC_CHECK_LIB(m, main, [],
2186              [ 
2187                   AC_MSG_NOTICE([Maths library was not found])
2188              ])
2189 AC_SUBST(LIBM)
2190 
2191 ###############################################################################
2192 #
2193 # Should we run the painfully slow javadoc tool?
2194 #
2195 AC_MSG_CHECKING([whether to build documentation])
2196 AC_ARG_ENABLE([docs], [AS_HELP_STRING([--enable-docs],
2197         [enable generation of Javadoc documentation @<:@disabled@:>@])],
2198         [ENABLE_DOCS="${enableval}"], [ENABLE_DOCS='no'])
2199 AC_MSG_RESULT([$ENABLE_DOCS])
2200 AC_SUBST(ENABLE_DOCS)
2201 GENERATE_DOCS=false
2202 if test "x$ENABLE_DOCS" = xyes; then
2203     GENERATE_DOCS=true
2204 fi
2205 AC_SUBST(GENERATE_DOCS)
2206 
2207 ###############################################################################
2208 #
2209 # Should we compile nimbus swing L&F? We can probably remove this option
2210 # since nimbus is officially part of javax now.
2211 #
2212 AC_MSG_CHECKING([whether to build nimbus L&F])
2213 AC_ARG_ENABLE([nimbus], [AS_HELP_STRING([--disable-nimbus],
2214         [disable Nimbus L&F @<:@enabled@:>@])],
2215         [ENABLE_NIMBUS="${enableval}"], [ENABLE_NIMBUS='yes'])
2216 AC_MSG_RESULT([$ENABLE_NIMBUS])
2217 DISABLE_NIMBUS=
2218 if test "x$ENABLE_NIMBUS" = xno; then
2219     DISABLE_NIMBUS=true
2220 fi
2221 AC_SUBST(DISABLE_NIMBUS)
2222 
2223 ###############################################################################
2224 #
2225 # Setup the opt flags for different compilers
2226 # and different operating systems.
2227 #
2228 case $COMPILER_TYPE in
2229   CC )
2230     D_FLAG="-g"
2231     case $COMPILER_NAME in
2232       gcc )
2233         case $PLATFORM in
2234           macosx )
2235             # On MacOSX we optimize for size, something
2236             # we should do for all platforms?
2237             C_O_FLAG_HI="-O3"
2238             C_O_FLAG_NORM="-Os"
2239             C_O_FLAG_NONE="-O0"
2240             ;;
2241           *)
2242             C_O_FLAG_HI="-O3"
2243             C_O_FLAG_NORM="-O2"
2244             C_O_FLAG_NONE="-O0"
2245             ;;
2246         esac
2247         CXX_O_FLAG_HI="$C_O_FLAG_HI"
2248         CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
2249         CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
2250         ;;
2251       ossc )
2252         case $LEGACY_HOST_CPU1 in
2253           i586)
2254             C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
2255             C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
2256             C_O_FLAG_NONE=""
2257             CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
2258             CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
2259             CXX_O_FLAG_NONE=""
2260             ;;
2261           sparc)
2262             C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
2263             C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
2264             C_O_FLAG_NONE=""
2265             CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
2266             CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
2267             CXX_O_FLAG_NONE=""
2268             ;;
2269         esac
2270     esac
2271     ;;
2272   CL )
2273     D_FLAG=
2274     C_O_FLAG_HI="-O2"
2275     C_O_FLAG_NORM="-O1"
2276     C_O_FLAG_NONE="-Od"
2277     CXX_O_FLAG_HI="$C_O_FLAG_HI"
2278     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
2279     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
2280     ;;
2281 esac
2282 
2283 AC_SUBST(C_O_FLAG_HI)
2284 AC_SUBST(C_O_FLAG_NORM)
2285 AC_SUBST(C_O_FLAG_NONE)
2286 AC_SUBST(CXX_O_FLAG_HI)
2287 AC_SUBST(CXX_O_FLAG_NORM)
2288 AC_SUBST(CXX_O_FLAG_NONE)
2289 
2290 ###############################################################################
2291 #
2292 # Setup legacy vars/targets and new vars to deal with different debug levels.
2293 #
2294 case $DEBUG_LEVEL in
2295       release )
2296               HOTSPOT_DEBUG_LEVEL="product"
2297               HOTSPOT_EXPORT="product"
2298               ;;
2299       fastdebug ) 
2300               HOTSPOT_DEBUG_LEVEL="fastdebug"   
2301               HOTSPOT_EXPORT="fastdebug"
2302               CFLAGS="$CFLAGS $D_FLAG"
2303               JAVAC_FLAGS="$JAVAC_FLAGS -g"
2304               ;;
2305       slowdebug )
2306               HOTSPOT_DEBUG_LEVEL="jvmg"
2307               HOTSPOT_EXPORT="debug"
2308               CFLAGS="$CFLAGS $D_FLAG"
2309               C_O_FLAG_HI="$C_O_FLAG_NONE"
2310               C_O_FLAG_NORM="$C_O_FLAG_NONE"
2311               CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
2312               CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
2313               JAVAC_FLAGS="$JAVAC_FLAGS -g"
2314               ;;
2315 esac              
2316 
2317 ###############################################################################
2318 #
2319 # Generate the legacy makefile targets for hotspot.
2320 # The hotspot api for selecting the build artifacts, really, needs to be improved.
2321 #
2322 HOTSPOT_TARGET=""
2323 
2324 if test "x$JVM_VARIANT_SERVER" = xtrue; then
2325     HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
2326 fi
2327 
2328 if test "x$JVM_VARIANT_CLIENT" = xtrue; then
2329     HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
2330 fi
2331 
2332 if test "x$JVM_VARIANT_KERNEL" = xtrue; then
2333     HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}kernel "
2334 fi
2335 
2336 if test "x$JVM_VARIANT_ZERO" = xtrue; then
2337     HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
2338 fi
2339 
2340 if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
2341     HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
2342 fi
2343 
2344 HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_EXPORT"
2345 
2346 ###############################################################################
2347 #
2348 # Setup all directories for the subrepoes and the arguments to the sub makes.
2349 #
2350 LANGTOOLS_OUTPUTDIR="$OUTPUT_ROOT/langtools"
2351 LANGTOOLS_DIST="$OUTPUT_ROOT/langtools/dist"
2352 LANGTOOLS_MAKE_ARGS=""
2353 AC_SUBST(LANGTOOLS_OUTPUTDIR)
2354 AC_SUBST(LANGTOOLS_DIST)
2355 AC_SUBST(LANGTOOLS_MAKE_ARGS)
2356 
2357 CORBA_OUTPUTDIR="$OUTPUT_ROOT/corba"
2358 CORBA_DIST="$OUTPUT_ROOT/corba/dist"
2359 CORBA_MAKE_ARGS=""
2360 AC_SUBST(CORBA_OUTPUTDIR)
2361 AC_SUBST(CORBA_DIST)
2362 AC_SUBST(CORBA_MAKE_ARGS)
2363 
2364 JAXP_OUTPUTDIR="$OUTPUT_ROOT/jaxp"
2365 JAXP_DIST="$OUTPUT_ROOT/jaxp/dist"
2366 JAXP_MAKE_ARGS=""
2367 AC_SUBST(JAXP_OUTPUTDIR)
2368 AC_SUBST(JAXP_DIST)
2369 AC_SUBST(JAXP_MAKE_ARGS)
2370 
2371 JAXWS_OUTPUTDIR="$OUTPUT_ROOT/jaxws"
2372 JAXWS_DIST="$OUTPUT_ROOT/jaxws/dist"
2373 JAXWS_MAKE_ARGS=""
2374 AC_SUBST(JAXWS_OUTPUTDIR)
2375 AC_SUBST(JAXWS_DIST)
2376 AC_SUBST(JAXWS_MAKE_ARGS)
2377 
2378 HOTSPOT_OUTPUTDIR="$OUTPUT_ROOT/hotspot"
2379 HOTSPOT_DIST="$OUTPUT_ROOT/hotspot/dist"
2380 HOTSPOT_MAKE_ARGS="ALT_OUTPUTDIR=$HOTSPOT_OUTPUTDIR ALT_EXPORT_PATH=$HOTSPOT_DIST $HOTSPOT_TARGET"
2381 AC_SUBST(HOTSPOT_OUTPUTDIR)
2382 AC_SUBST(HOTSPOT_DIST)
2383 AC_SUBST(HOTSPOT_MAKE_ARGS)
2384 
2385 JDK_OUTPUTDIR="$OUTPUT_ROOT/jdk"
2386 JDK_MAKE_ARGS="ALT_OUTPUTDIR=\"$OUTPUT_ROOT/jdk\""
2387 AC_SUBST(JDK_OUTPUTDIR)
2388 AC_SUBST(JDK_MAKE_ARGS)
2389 
2390 IMAGES_OUTPUTDIR=$OUTPUT_ROOT/images
2391 IMAGES_MAKE_ARGS="ALT_OUTPUTDIR=$OUTPUT_ROOT/jdk \
2392                   SHARE_SRC=$JDK_TOPDIR/src/share \
2393                   PLATFORM_SRC=$JDK_TOPDIR/src/$LEGACY_HOST_OS_API \
2394                   TEMPDIR=$IMAGES_OUTPUTDIR/tmp \
2395                   ABS_TEMPDIR=$IMAGES_OUTPUTDIR/tmp "
2396 AC_SUBST(IMAGES_OUTPUTDIR)
2397 AC_SUBST(IMAGES_MAKE_ARGS)
2398 
2399 ###############################################################################
2400 #
2401 # Now setup the CFLAGS and LDFLAGS for the JDK build.
2402 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
2403 #
2404 case $COMPILER_NAME in
2405       gcc )
2406           CCXXFLAGS_JDK="$CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses -pipe -fno-omit-frame-pointer \
2407                           -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
2408           CFLAGS_JDK="$CFLAGS_JDK -fno-strict-aliasing"
2409           ;;
2410       ossc )
2411           CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa REQUIRED -v -mt -norunpath -xnolib"
2412           CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt REQUIRED -features=no%except -DCC_NOEX"
2413           ;;
2414       cl )
2415           CCXXFLAGS_JDK="$CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
2416                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
2417                -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
2418                -DWIN32 -DIAL"
2419           case $LEGACY_HOST_CPU1 in
2420               i?86 )
2421                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
2422                   ;;
2423               amd64 )
2424                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
2425                   ;;
2426           esac
2427           ;;
2428 esac
2429 
2430 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
2431 
2432 # The package path is used only on macosx?
2433 PACKAGE_PATH=/opt/local
2434 AC_SUBST(PACKAGE_PATH)
2435 
2436 # Sometimes we use a cpu dir (.../lib/amd64/server) 
2437 # Sometimes not (.../lib/server) 
2438 LIBARCHDIR="$LEGACY_HOST_CPU2/"
2439 if test "x$ENDIAN" = xlittle; then
2440     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
2441 else
2442     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
2443 fi
2444 if test "x$HOST_OS" = xlinux; then
2445     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
2446 fi
2447 if test "x$HOST_OS" = xwindows; then
2448     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
2449 fi
2450 if test "x$HOST_OS" = xsolaris; then
2451     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
2452 fi
2453 if test "x$HOST_OS" = xmacosx; then
2454     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
2455     LIBARCHDIR=""
2456 fi
2457 if test "x$HOST_OS" = xbsd; then
2458     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
2459 fi
2460 if test "x$DEBUG_LEVEL" = xrelease; then
2461     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
2462 else
2463     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
2464 fi
2465 
2466 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_HOST_CPU1\"' -D$LEGACY_HOST_CPU1"
2467 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
2468 
2469 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
2470         -I${JDK_OUTPUTDIR}/include \
2471         -I${JDK_OUTPUTDIR}/include/$PLATFORM \
2472         -I${JDK_TOPDIR}/src/share/javavm/export \
2473         -I${JDK_TOPDIR}/src/$LEGACY_HOST_OS_API/javavm/export \
2474         -I${JDK_TOPDIR}/src/share/native/common \
2475         -I${JDK_TOPDIR}/src/$LEGACY_HOST_OS_API/native/common"
2476 
2477 # The shared libraries are compiled using the picflag.
2478 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
2479 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG"
2480 
2481 # Executable flags
2482 CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
2483 CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
2484 
2485 # Now this is odd. The JDK native libraries have to link against libjvm.so
2486 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
2487 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
2488 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
2489 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
2490 # libraries will link to whatever is in memory. Yuck. 
2491 #
2492 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
2493 if test "x$COMPILER_TYPE" = xCL; then
2494     LDFLAGS_JDKLIB="$LDFLAGS -libpath:${JDK_OUTPUTDIR}/lib jvm.lib java.lib"
2495     LDFLAGS_JDKLIB_SUFFIX=""
2496     if test "x$HOST_CPU_BITS" = "x64"; then
2497         LDFLAGS_JDKEXE="$CFLAGS ${JDK_OUTPUTDIR}/tmp/java/jli/obj64/jli.lib"
2498     else
2499         LDFLAGS_JDKEXE="$CFLAGS ${JDK_OUTPUTDIR}/tmp/java/jli/obj/jli.lib"
2500     fi
2501     LDFLAGS_JDKEXE_SUFFIX=""
2502 else
2503     # If this is a --hash-style=gnu system, use --hash-style=both, why?
2504     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
2505     if test -n "$HAS_GNU_HASH"; then
2506         # And since we now know that the linker is gnu, then add -z defs, to forbid
2507         # undefined symbols in object files.
2508         LDFLAGS="$LDFLAGS -Xlinker --hash-style=both -Xlinker -z -Xlinker defs"
2509         if test "x$DEBUG_LEVEL" == "xrelease"; then
2510             # When building release libraries, tell the linker optimize them.
2511             # Should this be supplied to the OSS linker as well?
2512             LDFLAGS="$LDFLAGS -Xlinker -O1"
2513         fi
2514     fi
2515 
2516     LDFLAGS_JDKLIB="$LDFLAGS $SHARED_LIBRARY_FLAGS -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
2517                     -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
2518                     -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}" 
2519     LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
2520     if test "x$COMPILER_NAME" = xossc; then
2521         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
2522     fi
2523 
2524     # Only the jli library is explicitly linked when the launchers are built.
2525     # The libjvm is then dynamically loaded/linked by the launcher.
2526     LDFLAGS_JDKEXE="$LDFLAGS -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
2527     LDFLAGS_JDKEXE_SUFFIX="-ljli"
2528 fi
2529 
2530                 
2531 AC_SUBST(CFLAGS_JDKLIB)
2532 AC_SUBST(CFLAGS_JDKEXE)
2533 
2534 AC_SUBST(CXXFLAGS_JDKLIB)
2535 AC_SUBST(CXXFLAGS_JDKEXE)
2536 
2537 AC_SUBST(LDFLAGS_JDKLIB)
2538 AC_SUBST(LDFLAGS_JDKEXE)
2539 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
2540 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
2541 
2542 
2543 ###############################################################################
2544 #
2545 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
2546 # dynamic build is configured on command line.
2547 #
2548 AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++],
2549         [disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],,
2550         [
2551                 enable_static_link_stdc__=yes
2552     ])
2553 
2554 if test "x$HOST_OS" = xlinux; then
2555     # Test if -lstdc++ works.
2556     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
2557     AC_LANG_PUSH(C++)
2558     OLD_CXXFLAGS="$CXXFLAGS"
2559     CXXFLAGS="$CXXFLAGS -lstdc++"
2560     AC_TRY_LINK([], [return 0;],
2561             has_dynamic_libstdcxx=yes,
2562             has_dynamic_libstdcxx=no)
2563     CXXFLAGS="$OLD_CXXFLAGS"
2564     AC_LANG_POP(C++)
2565     AC_MSG_RESULT([$has_dynamic_libstdcxx])
2566 
2567     # Test if stdc++ can be linked statically.
2568     AC_MSG_CHECKING([if static link of stdc++ is possible])
2569     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
2570     AC_LANG_PUSH(C++)
2571     OLD_LIBS="$LIBS"
2572     OLD_CXX="$CXX"
2573     LIBS="$STATIC_STDCXX_FLAGS"
2574     CXX="$CC"                       
2575     AC_TRY_LINK([], [return 0;],
2576             has_static_libstdcxx=yes,
2577             has_static_libstdcxx=no)
2578     LIBS="$OLD_LIBS"
2579     CXX="$OLD_CXX"
2580     AC_LANG_POP(C++)
2581     AC_MSG_RESULT([$has_static_libstdcxx])
2582 
2583     if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then
2584         AC_ERROR([I cannot link to stdc++! Neither dynamically nor statically.])
2585     fi
2586 
2587     if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then
2588         AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.])
2589         enable_static_link_stdc__=no
2590     fi
2591 
2592     if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then
2593         AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.])
2594         enable_static_link_stdc__=yes
2595     fi
2596 
2597     AC_MSG_CHECKING([how to link with libstdc++])
2598     if test "x$enable_static_link_stdc__" = xyes; then
2599         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
2600         LDCXX="$CC"
2601         AC_MSG_RESULT([static])
2602     else
2603         LIBCXX="$LIBCXX -lstdc++"
2604         LDCXX="$CXX"
2605         AC_MSG_RESULT([dynamic])
2606     fi
2607 fi
2608 
2609 ###############################################################################
2610 #
2611 # Could someone enlighten this configure script with a comment about libCrun?
2612 # The LEGACY_HOST_CPU3 is the setting for ISA_DIR.
2613 #
2614 if test "x$HOST_OS" = xsolaris; then
2615     LIBCXX="$LIBCXX /usr/lib${LEGACY_HOST_CPU3}/libCrun.so.1"
2616 fi
2617 
2618 AC_SUBST(LIBCXX)
2619 
2620 ###############################################################################
2621 #
2622 # Misc
2623 #
2624 
2625 # Control wether Hotspot runs Queens test after build.
2626 AC_ARG_ENABLE([hotspot-test-in-build], [AS_HELP_STRING([--enable-hotspot-test-in-build],
2627         [enable running of Queens test after Hotspot build (not yet available) @<:@disabled@:>@])],,
2628     [enable_hotspot_test_in_build=no])
2629 if test "x$enable_hotspot_test_in_build" = "xyes"; then
2630     TEST_IN_BUILD=true
2631 else
2632     TEST_IN_BUILD=false
2633 fi
2634 AC_SUBST(TEST_IN_BUILD)
2635 
2636 ###############################################################################
2637 #
2638 # A helpful message at the end of the configure run.
2639 #
2640 if test "x$CCACHE_FOUND" = x && test "x$GCC" = xyes; then
2641     help_on_build_dependency ccache
2642     
2643     printf "\nTip of the day:\nYou should really install ccache version 3.1.4 or newer.\n"
2644     printf "It gives a tremendous speedup for C++ recompilations with precompiled headers!\n"
2645 fi    
2646 
2647 if test "x$CCACHE_FOUND" != x && test "x$HAS_GOOD_CCACHE" = x; then
2648     printf "You have a ccache installed, but it is a version prior to 3.1.4. Try upgrading.\n"
2649 fi
2650 
2651 AC_OUTPUT