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