1#
2# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# This code is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 2 only, as
7# published by the Free Software Foundation.  Oracle designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Oracle in the LICENSE file that accompanied this code.
10#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22# or visit www.oracle.com if you need additional information or have any
23# questions.
24#
25
26###############################################################################
27# Check which variant of the JDK that we want to build.
28# Currently we have:
29#    normal:   standard edition
30# but the custom make system may add other variants
31#
32# Effectively the JDK variant gives a name to a specific set of
33# modules to compile into the JDK.
34AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VARIANT],
35[
36  # Deprecated in JDK 12
37  BASIC_DEPRECATED_ARG_WITH([jdk-variant])
38])
39
40###############################################################################
41# Set the debug level
42#    release: no debug information, all optimizations, no asserts.
43#    optimized: no debug information, all optimizations, no asserts, HotSpot target is 'optimized'.
44#    fastdebug: debug information (-g), all optimizations, all asserts
45#    slowdebug: debug information (-g), no optimizations, all asserts
46AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_LEVEL],
47[
48  DEBUG_LEVEL="release"
49  AC_MSG_CHECKING([which debug level to use])
50  AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
51      [set the debug level to fastdebug (shorthand for --with-debug-level=fastdebug) @<:@disabled@:>@])],
52      [
53        ENABLE_DEBUG="${enableval}"
54        DEBUG_LEVEL="fastdebug"
55      ], [ENABLE_DEBUG="no"])
56
57  AC_ARG_WITH([debug-level], [AS_HELP_STRING([--with-debug-level],
58      [set the debug level (release, fastdebug, slowdebug, optimized) @<:@release@:>@])],
59      [
60        DEBUG_LEVEL="${withval}"
61        if test "x$ENABLE_DEBUG" = xyes; then
62          AC_MSG_ERROR([You cannot use both --enable-debug and --with-debug-level at the same time.])
63        fi
64      ])
65  AC_MSG_RESULT([$DEBUG_LEVEL])
66
67  if test "x$DEBUG_LEVEL" != xrelease && \
68      test "x$DEBUG_LEVEL" != xoptimized && \
69      test "x$DEBUG_LEVEL" != xfastdebug && \
70      test "x$DEBUG_LEVEL" != xslowdebug; then
71    AC_MSG_ERROR([Allowed debug levels are: release, fastdebug, slowdebug and optimized])
72  fi
73
74  # Translate DEBUG_LEVEL to debug level used by Hotspot
75  HOTSPOT_DEBUG_LEVEL="$DEBUG_LEVEL"
76  if test "x$DEBUG_LEVEL" = xrelease; then
77    HOTSPOT_DEBUG_LEVEL="product"
78  elif test "x$DEBUG_LEVEL" = xslowdebug; then
79    HOTSPOT_DEBUG_LEVEL="debug"
80  fi
81
82  if test "x$DEBUG_LEVEL" = xoptimized; then
83    # The debug level 'optimized' is a little special because it is currently only
84    # applicable to the HotSpot build where it means to build a completely
85    # optimized version of the VM without any debugging code (like for the
86    # 'release' debug level which is called 'product' in the HotSpot build) but
87    # with the exception that it can contain additional code which is otherwise
88    # protected by '#ifndef PRODUCT' macros. These 'optimized' builds are used to
89    # test new and/or experimental features which are not intended for customer
90    # shipment. Because these new features need to be tested and benchmarked in
91    # real world scenarios, we want to build the containing JDK at the 'release'
92    # debug level.
93    DEBUG_LEVEL="release"
94  fi
95
96  AC_SUBST(HOTSPOT_DEBUG_LEVEL)
97  AC_SUBST(DEBUG_LEVEL)
98])
99
100###############################################################################
101#
102# Should we build only OpenJDK even if closed sources are present?
103#
104AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM],
105[
106  AC_ARG_ENABLE([openjdk-only], [AS_HELP_STRING([--enable-openjdk-only],
107      [suppress building custom source even if present @<:@disabled@:>@])],,[enable_openjdk_only="no"])
108
109  AC_MSG_CHECKING([if custom source is suppressed (openjdk-only)])
110  AC_MSG_RESULT([$enable_openjdk_only])
111  if test "x$enable_openjdk_only" = "xyes"; then
112    SUPPRESS_CUSTOM_EXTENSIONS="true"
113  elif test "x$enable_openjdk_only" = "xno"; then
114    SUPPRESS_CUSTOM_EXTENSIONS="false"
115  else
116    AC_MSG_ERROR([Invalid value for --enable-openjdk-only: $enable_openjdk_only])
117  fi
118])
119
120AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
121[
122  # Should we build a JDK without a graphical UI?
123  AC_MSG_CHECKING([headless only])
124  AC_ARG_ENABLE([headless-only], [AS_HELP_STRING([--enable-headless-only],
125      [only build headless (no GUI) support @<:@disabled@:>@])])
126
127  if test "x$enable_headless_only" = "xyes"; then
128    ENABLE_HEADLESS_ONLY="true"
129    AC_MSG_RESULT([yes])
130  elif test "x$enable_headless_only" = "xno"; then
131    ENABLE_HEADLESS_ONLY="false"
132    AC_MSG_RESULT([no])
133  elif test "x$enable_headless_only" = "x"; then
134    ENABLE_HEADLESS_ONLY="false"
135    AC_MSG_RESULT([no])
136  else
137    AC_MSG_ERROR([--enable-headless-only can only take yes or no])
138  fi
139
140  AC_SUBST(ENABLE_HEADLESS_ONLY)
141
142  # Should we build the complete docs, or just a lightweight version?
143  AC_ARG_ENABLE([full-docs], [AS_HELP_STRING([--enable-full-docs],
144      [build complete documentation @<:@enabled if all tools found@:>@])])
145
146  # Verify dependencies
147  AC_MSG_CHECKING([for graphviz dot])
148  if test "x$DOT" != "x"; then
149    AC_MSG_RESULT([yes])
150  else
151    AC_MSG_RESULT([no, cannot generate full docs])
152    FULL_DOCS_DEP_MISSING=true
153  fi
154
155  AC_MSG_CHECKING([for pandoc])
156  if test "x$PANDOC" != "x"; then
157    AC_MSG_RESULT([yes])
158  else
159    AC_MSG_RESULT([no, cannot generate full docs])
160    FULL_DOCS_DEP_MISSING=true
161  fi
162
163  AC_MSG_CHECKING([full docs])
164  if test "x$enable_full_docs" = xyes; then
165    if test "x$FULL_DOCS_DEP_MISSING" = "xtrue"; then
166      AC_MSG_RESULT([no, missing dependencies])
167      HELP_MSG_MISSING_DEPENDENCY([dot])
168      AC_MSG_ERROR([Cannot enable full docs with missing dependencies. See above. $HELP_MSG])
169    else
170      ENABLE_FULL_DOCS=true
171      AC_MSG_RESULT([yes, forced])
172    fi
173  elif test "x$enable_full_docs" = xno; then
174    ENABLE_FULL_DOCS=false
175    AC_MSG_RESULT([no, forced])
176  elif test "x$enable_full_docs" = x; then
177    # Check for prerequisites
178    if test "x$FULL_DOCS_DEP_MISSING" = xtrue; then
179      ENABLE_FULL_DOCS=false
180      AC_MSG_RESULT([no, missing dependencies])
181    else
182      ENABLE_FULL_DOCS=true
183      AC_MSG_RESULT([yes, dependencies present])
184    fi
185  else
186    AC_MSG_ERROR([--enable-full-docs can only take yes or no])
187  fi
188
189  AC_SUBST(ENABLE_FULL_DOCS)
190
191  # Choose cacerts source file
192  AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file],
193      [specify alternative cacerts file])])
194  AC_MSG_CHECKING([for cacerts file])
195  if test "x$with_cacerts_file" == x; then
196    AC_MSG_RESULT([default])
197  else
198    CACERTS_FILE=$with_cacerts_file
199    if test ! -f "$CACERTS_FILE"; then
200      AC_MSG_RESULT([fail])
201      AC_MSG_ERROR([Specified cacerts file "$CACERTS_FILE" does not exist])
202    fi
203    AC_MSG_RESULT([$CACERTS_FILE])
204  fi
205  AC_SUBST(CACERTS_FILE)
206
207  # Enable or disable unlimited crypto
208  AC_ARG_ENABLE(unlimited-crypto, [AS_HELP_STRING([--disable-unlimited-crypto],
209      [Disable unlimited crypto policy @<:@enabled@:>@])],,
210      [enable_unlimited_crypto=yes])
211  if test "x$enable_unlimited_crypto" = "xyes"; then
212    UNLIMITED_CRYPTO=true
213  else
214    UNLIMITED_CRYPTO=false
215  fi
216  AC_SUBST(UNLIMITED_CRYPTO)
217
218  # Should we build the serviceability agent (SA)?
219  INCLUDE_SA=true
220  if HOTSPOT_CHECK_JVM_VARIANT(zero); then
221    INCLUDE_SA=false
222  fi
223  if test "x$OPENJDK_TARGET_OS" = xaix ; then
224    INCLUDE_SA=false
225  fi
226  if test "x$OPENJDK_TARGET_CPU" = xs390x ; then
227    INCLUDE_SA=false
228  fi
229  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.openbsd ; then
230    INCLUDE_SA=false
231  fi
232  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd ; then
233    INCLUDE_SA=false
234  fi
235  AC_SUBST(INCLUDE_SA)
236
237  # Compress jars
238  COMPRESS_JARS=false
239
240  AC_SUBST(COMPRESS_JARS)
241
242  # Setup default copyright year. Mostly overridden when building close to a new year.
243  AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year],
244      [Set copyright year value for build @<:@current year@:>@])])
245  if test "x$with_copyright_year" = xyes; then
246    AC_MSG_ERROR([Copyright year must have a value])
247  elif test "x$with_copyright_year" != x; then
248    COPYRIGHT_YEAR="$with_copyright_year"
249  else
250    COPYRIGHT_YEAR=`$DATE +'%Y'`
251  fi
252  AC_SUBST(COPYRIGHT_YEAR)
253
254  # Override default library path
255  AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath],
256      [override default JNI library search path])])
257  AC_MSG_CHECKING([for jni library path])
258  if test "x${with_jni_libpath}" = "x" || test "x${with_jni_libpath}" = "xno"; then
259    AC_MSG_RESULT([default])
260  elif test "x${with_jni_libpath}" = "xyes"; then
261    AC_MSG_RESULT([invalid])
262    AC_MSG_ERROR([The --with-jni-libpath option requires an argument.])
263  else
264    HOTSPOT_OVERRIDE_LIBPATH=${with_jni_libpath}
265    if test "x$OPENJDK_TARGET_OS" != "xlinux" &&
266         test "x$OPENJDK_TARGET_OS" != "xbsd" &&
267         test "x$OPENJDK_TARGET_OS" != "xaix"; then
268      AC_MSG_RESULT([fail])
269      AC_MSG_ERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.])
270    fi
271    AC_MSG_RESULT(${HOTSPOT_OVERRIDE_LIBPATH})
272  fi
273  AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH)
274
275])
276
277###############################################################################
278#
279# Enable or disable the elliptic curve crypto implementation
280#
281AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
282[
283  AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
284
285  if test -d "${TOPDIR}/src/jdk.crypto.ec/share/native/libsunec/impl"; then
286    ENABLE_INTREE_EC=true
287    AC_MSG_RESULT([yes])
288  else
289    ENABLE_INTREE_EC=false
290    AC_MSG_RESULT([no])
291  fi
292
293  AC_SUBST(ENABLE_INTREE_EC)
294])
295
296AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
297[
298  #
299  # Native debug symbols.
300  # This must be done after the toolchain is setup, since we're looking at objcopy.
301  #
302  AC_MSG_CHECKING([what type of native debug symbols to use])
303  AC_ARG_WITH([native-debug-symbols],
304      [AS_HELP_STRING([--with-native-debug-symbols],
305      [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
306      [
307        if test "x$OPENJDK_TARGET_OS" = xaix; then
308          if test "x$withval" = xexternal || test "x$withval" = xzipped; then
309            AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols])
310          fi
311        elif test "x$OPENJDK_TARGET_OS" = xwindows; then
312          if test "x$withval" = xinternal; then
313            AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols])
314          fi
315        fi
316      ],
317      [
318        if test "x$STATIC_BUILD" = xtrue; then
319          with_native_debug_symbols="none"
320        else
321          if test "x$OPENJDK_TARGET_OS" = xaix; then
322            # AIX doesn't support 'external' so use 'internal' as default
323            with_native_debug_symbols="internal"
324          else
325            with_native_debug_symbols="external"
326          fi
327        fi
328      ])
329  AC_MSG_RESULT([$with_native_debug_symbols])
330
331  if test "x$with_native_debug_symbols" = xnone; then
332    COMPILE_WITH_DEBUG_SYMBOLS=false
333    COPY_DEBUG_SYMBOLS=false
334    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
335  elif test "x$with_native_debug_symbols" = xinternal; then
336    COMPILE_WITH_DEBUG_SYMBOLS=true
337    COPY_DEBUG_SYMBOLS=false
338    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
339  elif test "x$with_native_debug_symbols" = xexternal; then
340
341    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
342      if test "x$OBJCOPY" = x; then
343        # enabling of enable-debug-symbols and can't find objcopy
344        # this is an error
345        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
346      fi
347    fi
348
349    COMPILE_WITH_DEBUG_SYMBOLS=true
350    COPY_DEBUG_SYMBOLS=true
351    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
352  elif test "x$with_native_debug_symbols" = xzipped; then
353
354    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
355      if test "x$OBJCOPY" = x; then
356        # enabling of enable-debug-symbols and can't find objcopy
357        # this is an error
358        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
359      fi
360    fi
361
362    COMPILE_WITH_DEBUG_SYMBOLS=true
363    COPY_DEBUG_SYMBOLS=true
364    ZIP_EXTERNAL_DEBUG_SYMBOLS=true
365  else
366    AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
367  fi
368
369  AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
370  AC_SUBST(COPY_DEBUG_SYMBOLS)
371  AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
372
373  # Should we add external native debug symbols to the shipped bundles?
374  AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles])
375  AC_ARG_WITH([external-symbols-in-bundles],
376      [AS_HELP_STRING([--with-external-symbols-in-bundles],
377      [which type of external native debug symbol information shall be shipped in product bundles (none, public, full)
378      (e.g. ship full/stripped pdbs on Windows) @<:@none@:>@])])
379
380  if test "x$with_external_symbols_in_bundles" = x || test "x$with_external_symbols_in_bundles" = xnone ; then
381    AC_MSG_RESULT([no])
382  elif test "x$with_external_symbols_in_bundles" = xfull || test "x$with_external_symbols_in_bundles" = xpublic ; then
383    if test "x$OPENJDK_TARGET_OS" != xwindows ; then
384      AC_MSG_ERROR([--with-external-symbols-in-bundles currently only works on windows!])
385    elif test "x$COPY_DEBUG_SYMBOLS" != xtrue ; then
386      AC_MSG_ERROR([--with-external-symbols-in-bundles only works when --with-native-debug-symbols=external is used!])
387    elif test "x$with_external_symbols_in_bundles" = xfull ; then
388      AC_MSG_RESULT([full])
389      SHIP_DEBUG_SYMBOLS=full
390    else
391      AC_MSG_RESULT([public])
392      SHIP_DEBUG_SYMBOLS=public
393    fi
394  else
395    AC_MSG_ERROR([$with_external_symbols_in_bundles is an unknown value for --with-external-symbols-in-bundles])
396  fi
397
398  AC_SUBST(SHIP_DEBUG_SYMBOLS)
399])
400
401################################################################################
402#
403# Native and Java code coverage
404#
405AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
406[
407  AC_ARG_ENABLE(native-coverage, [AS_HELP_STRING([--enable-native-coverage],
408      [enable native compilation with code coverage data@<:@disabled@:>@])])
409  GCOV_ENABLED="false"
410  if test "x$enable_native_coverage" = "xyes"; then
411    case $TOOLCHAIN_TYPE in
412      gcc | clang)
413        AC_MSG_CHECKING([if native coverage is enabled])
414        AC_MSG_RESULT([yes])
415        GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline"
416        GCOV_LDFLAGS="-fprofile-arcs"
417        JVM_CFLAGS="$JVM_CFLAGS $GCOV_CFLAGS"
418        JVM_LDFLAGS="$JVM_LDFLAGS $GCOV_LDFLAGS"
419        CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS"
420        CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS"
421        CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS"
422        CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
423        LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
424        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
425        GCOV_ENABLED="true"
426        ;;
427      *)
428        AC_MSG_ERROR([--enable-native-coverage only works with toolchain type gcc or clang])
429        ;;
430    esac
431  elif test "x$enable_native_coverage" = "xno"; then
432    AC_MSG_CHECKING([if native coverage is enabled])
433    AC_MSG_RESULT([no])
434  elif test "x$enable_native_coverage" != "x"; then
435    AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"])
436  fi
437  AC_SUBST(GCOV_ENABLED)
438
439  AC_ARG_WITH(jcov, [AS_HELP_STRING([--with-jcov],
440      [jcov library location])])
441  AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk],
442      [jdk image to instrument])])
443  AC_ARG_WITH(jcov-filters, [AS_HELP_STRING([--with-jcov-filters],
444      [filters to limit code for jcov instrumentation and report generation])])
445  JCOV_HOME=
446  JCOV_INPUT_JDK=
447  JCOV_ENABLED=
448  JCOV_FILTERS=
449  if test "x$with_jcov" = "x" ; then
450    JCOV_ENABLED="false"
451  else
452    JCOV_HOME="$with_jcov"
453    if test ! -f "$JCOV_HOME/lib/jcov.jar"; then
454      AC_MSG_RESULT([fail])
455      AC_MSG_ERROR([Invalid JCov bundle: "$JCOV_HOME/lib/jcov.jar" does not exist])
456    fi
457    JCOV_ENABLED="true"
458    BASIC_FIXUP_PATH(JCOV_HOME)
459    if test "x$with_jcov_input_jdk" != "x" ; then
460      JCOV_INPUT_JDK="$with_jcov_input_jdk"
461      if test ! -f "$JCOV_INPUT_JDK/bin/java$EXE_SUFFIX"; then
462        AC_MSG_RESULT([fail])
463        AC_MSG_ERROR([Invalid JDK bundle: "$JCOV_INPUT_JDK/bin/java$EXE_SUFFIX" does not exist])
464      fi
465      BASIC_FIXUP_PATH(JCOV_INPUT_JDK)
466    fi
467    if test "x$with_jcov_filters" != "x" ; then
468      JCOV_FILTERS="$with_jcov_filters"
469    fi
470  fi
471  AC_SUBST(JCOV_ENABLED)
472  AC_SUBST(JCOV_HOME)
473  AC_SUBST(JCOV_INPUT_JDK)
474  AC_SUBST(JCOV_FILTERS)
475])
476
477###############################################################################
478#
479# AddressSanitizer
480#
481AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
482[
483  AC_ARG_ENABLE(asan, [AS_HELP_STRING([--enable-asan],
484      [enable AddressSanitizer if possible @<:@disabled@:>@])])
485  ASAN_ENABLED="no"
486  if test "x$enable_asan" = "xyes"; then
487    case $TOOLCHAIN_TYPE in
488      gcc | clang)
489        AC_MSG_CHECKING([if asan is enabled])
490        AC_MSG_RESULT([yes])
491        ASAN_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
492        ASAN_LDFLAGS="-fsanitize=address"
493        JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
494        JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
495        CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
496        CFLAGS_JDKEXE="$CFLAGS_JDKEXE $ASAN_CFLAGS"
497        CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $ASAN_CFLAGS"
498        CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS"
499        LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS"
500        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS"
501        ASAN_ENABLED="yes"
502        ;;
503      *)
504        AC_MSG_ERROR([--enable-asan only works with toolchain type gcc or clang])
505        ;;
506    esac
507  elif test "x$enable_asan" = "xno"; then
508    AC_MSG_CHECKING([if asan is enabled])
509    AC_MSG_RESULT([no])
510  elif test "x$enable_asan" != "x"; then
511    AC_MSG_ERROR([--enable-asan can only be assigned "yes" or "no"])
512  fi
513
514  AC_SUBST(ASAN_ENABLED)
515])
516
517################################################################################
518#
519# Static build support.  When enabled will generate static
520# libraries instead of shared libraries for all JDK libs.
521#
522AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
523[
524  AC_ARG_ENABLE([static-build], [AS_HELP_STRING([--enable-static-build],
525    [enable static library build @<:@disabled@:>@])])
526  STATIC_BUILD=false
527  if test "x$enable_static_build" = "xyes"; then
528    AC_MSG_CHECKING([if static build is enabled])
529    AC_MSG_RESULT([yes])
530    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
531      AC_MSG_ERROR([--enable-static-build is only supported for macosx builds])
532    fi
533    STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1"
534    CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
535    CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
536    STATIC_BUILD=true
537  elif test "x$enable_static_build" = "xno"; then
538    AC_MSG_CHECKING([if static build is enabled])
539    AC_MSG_RESULT([no])
540  elif test "x$enable_static_build" != "x"; then
541    AC_MSG_ERROR([--enable-static-build can only be assigned "yes" or "no"])
542  fi
543
544  AC_SUBST(STATIC_BUILD)
545])
546
547################################################################################
548#
549# jlink options.
550# We always keep packaged modules in JDK image.
551#
552AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
553[
554  AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules],
555    [Do not keep packaged modules in jdk image @<:@enable@:>@])])
556
557  AC_MSG_CHECKING([if packaged modules are kept])
558  if test "x$enable_keep_packaged_modules" = "xyes"; then
559    AC_MSG_RESULT([yes])
560    JLINK_KEEP_PACKAGED_MODULES=true
561  elif test "x$enable_keep_packaged_modules" = "xno"; then
562    AC_MSG_RESULT([no])
563    JLINK_KEEP_PACKAGED_MODULES=false
564  elif test "x$enable_keep_packaged_modules" = "x"; then
565    AC_MSG_RESULT([yes (default)])
566    JLINK_KEEP_PACKAGED_MODULES=true
567  else
568    AC_MSG_RESULT([error])
569    AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument])
570  fi
571
572  AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
573])
574
575################################################################################
576#
577# Check if building of the jtreg failure handler should be enabled.
578#
579AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
580[
581  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
582    [forces build of the jtreg failure handler to be enabled, missing dependencies
583     become fatal errors. Default is auto, where the failure handler is built if all
584     dependencies are present and otherwise just disabled.])])
585
586  AC_MSG_CHECKING([if jtreg failure handler should be built])
587
588  if test "x$enable_jtreg_failure_handler" = "xyes"; then
589    if test "x$JT_HOME" = "x"; then
590      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
591    else
592      BUILD_FAILURE_HANDLER=true
593      AC_MSG_RESULT([yes, forced])
594    fi
595  elif test "x$enable_jtreg_failure_handler" = "xno"; then
596    BUILD_FAILURE_HANDLER=false
597    AC_MSG_RESULT([no, forced])
598  elif test "x$enable_jtreg_failure_handler" = "xauto" \
599      || test "x$enable_jtreg_failure_handler" = "x"; then
600    if test "x$JT_HOME" = "x"; then
601      BUILD_FAILURE_HANDLER=false
602      AC_MSG_RESULT([no, missing jtreg])
603    else
604      BUILD_FAILURE_HANDLER=true
605      AC_MSG_RESULT([yes, jtreg present])
606    fi
607  else
608    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
609  fi
610
611  AC_SUBST(BUILD_FAILURE_HANDLER)
612])
613
614################################################################################
615#
616# Enable or disable generation of the classlist at build time
617#
618AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST],
619[
620  AC_ARG_ENABLE([generate-classlist], [AS_HELP_STRING([--disable-generate-classlist],
621      [forces enabling or disabling of the generation of a CDS classlist at build time.
622      Default is to generate it when either the server or client JVMs are built and
623      enable-cds is true.])])
624
625  # Check if it's likely that it's possible to generate the classlist. Depending
626  # on exact jvm configuration it could be possible anyway.
627  if test "x$ENABLE_CDS" = "xtrue" && (HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) || HOTSPOT_CHECK_JVM_FEATURE(cds)); then
628    ENABLE_GENERATE_CLASSLIST_POSSIBLE="true"
629  else
630    ENABLE_GENERATE_CLASSLIST_POSSIBLE="false"
631  fi
632
633  AC_MSG_CHECKING([if the CDS classlist generation should be enabled])
634  if test "x$enable_generate_classlist" = "xyes"; then
635    AC_MSG_RESULT([yes, forced])
636    ENABLE_GENERATE_CLASSLIST="true"
637    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
638      if test "x$ENABLE_CDS" = "xfalse"; then
639        # In GenerateLinkOptData.gmk, DumpLoadedClassList is used to generate the
640        # classlist file. It never will work in this case since the VM will report
641        # an error for DumpLoadedClassList when CDS is disabled.
642        AC_MSG_ERROR([Generation of classlist is not possible with enable-cds=false])
643      else
644        AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS])
645      fi
646    fi
647  elif test "x$enable_generate_classlist" = "xno"; then
648    AC_MSG_RESULT([no, forced])
649    ENABLE_GENERATE_CLASSLIST="false"
650  elif test "x$enable_generate_classlist" = "x"; then
651    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xtrue"; then
652      AC_MSG_RESULT([yes])
653      ENABLE_GENERATE_CLASSLIST="true"
654    else
655      AC_MSG_RESULT([no])
656      ENABLE_GENERATE_CLASSLIST="false"
657    fi
658  else
659    AC_MSG_ERROR([Invalid value for --enable-generate-classlist: $enable_generate_classlist])
660  fi
661
662  AC_SUBST(ENABLE_GENERATE_CLASSLIST)
663])
664
665################################################################################
666#
667# Optionally filter resource translations
668#
669AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS],
670[
671  AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations],
672      [a comma separated list of locales to exclude translations for. Default is
673      to include all translations present in the source.])])
674
675  EXCLUDE_TRANSLATIONS=""
676  AC_MSG_CHECKING([if any translations should be excluded])
677  if test "x$with_exclude_translations" != "x"; then
678    EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }"
679    AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS])
680  else
681    AC_MSG_RESULT([no])
682  fi
683
684  AC_SUBST(EXCLUDE_TRANSLATIONS)
685])
686
687################################################################################
688#
689# Optionally disable man pages
690#
691AC_DEFUN([JDKOPT_ENABLE_DISABLE_MANPAGES],
692[
693  AC_ARG_ENABLE([manpages], [AS_HELP_STRING([--disable-manpages],
694      [Set to disable copy of static man pages @<:@enabled@:>@])])
695
696  BUILD_MANPAGES="true"
697  AC_MSG_CHECKING([if static man pages should be copied])
698  if test "x$enable_manpages" = "x"; then
699    AC_MSG_RESULT([yes])
700  elif test "x$enable_manpages" = "xyes"; then
701    AC_MSG_RESULT([yes, forced])
702  elif test "x$enable_manpages" = "xno"; then
703    AC_MSG_RESULT([no, forced])
704    BUILD_MANPAGES="false"
705  else
706    AC_MSG_RESULT([no])
707    AC_MSG_ERROR([--enable-manpages can only yes/no or empty])
708  fi
709
710  AC_SUBST(BUILD_MANPAGES)
711])
712
713################################################################################
714#
715# Disable the default CDS archive generation
716#   cross compilation - disabled
717#
718AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
719[
720  AC_ARG_ENABLE([cds-archive], [AS_HELP_STRING([--disable-cds-archive],
721      [Set to disable generation of a default CDS archive in the product image @<:@enabled@:>@])])
722
723  AC_MSG_CHECKING([if a default CDS archive should be generated])
724  if test "x$ENABLE_CDS" = "xfalse"; then
725    AC_MSG_RESULT([no, because CDS is disabled])
726    BUILD_CDS_ARCHIVE="false"
727  elif test "x$COMPILE_TYPE" = "xcross"; then
728    AC_MSG_RESULT([no, not possible with cross compilation])
729    BUILD_CDS_ARCHIVE="false"
730  elif test "x$enable_cds_archive" = "xyes"; then
731    AC_MSG_RESULT([yes, forced])
732    BUILD_CDS_ARCHIVE="true"
733  elif test "x$enable_cds_archive" = "x"; then
734    AC_MSG_RESULT([yes])
735    BUILD_CDS_ARCHIVE="true"
736  elif test "x$enable_cds_archive" = "xno"; then
737    AC_MSG_RESULT([no, forced])
738    BUILD_CDS_ARCHIVE="false"
739  else
740    AC_MSG_RESULT([no])
741    AC_MSG_ERROR([--enable-cds_archive can only be yes/no or empty])
742  fi
743
744  AC_SUBST(BUILD_CDS_ARCHIVE)
745])
746
747################################################################################
748#
749# Disallow any output from containing absolute paths from the build system.
750# This setting defaults to allowed on debug builds and not allowed on release
751# builds.
752#
753AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT],
754[
755  AC_ARG_ENABLE([absolute-paths-in-output],
756      [AS_HELP_STRING([--disable-absolute-paths-in-output],
757       [Set to disable to prevent any absolute paths from the build to end up in
758        any of the build output. @<:@disabled in release builds, otherwise enabled@:>@])
759      ])
760
761  AC_MSG_CHECKING([if absolute paths should be allowed in the build output])
762  if test "x$enable_absolute_paths_in_output" = "xno"; then
763    AC_MSG_RESULT([no, forced])
764    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
765  elif test "x$enable_absolute_paths_in_output" = "xyes"; then
766    AC_MSG_RESULT([yes, forced])
767    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
768  elif test "x$DEBUG_LEVEL" = "xrelease"; then
769    AC_MSG_RESULT([no, release build])
770    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
771  else
772    AC_MSG_RESULT([yes, debug build])
773    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
774  fi
775
776  AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)
777])
778