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