1#
2# Copyright (c) 2011, 2021, 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  AC_MSG_CHECKING([which variant of the JDK to build])
37  AC_ARG_WITH([jdk-variant], [AS_HELP_STRING([--with-jdk-variant],
38      [JDK variant to build (normal) @<:@normal@:>@])])
39
40  if test "x$with_jdk_variant" = xnormal || test "x$with_jdk_variant" = x; then
41    JDK_VARIANT="normal"
42  else
43    AC_MSG_ERROR([The available JDK variants are: normal])
44  fi
45
46  AC_SUBST(JDK_VARIANT)
47
48  AC_MSG_RESULT([$JDK_VARIANT])
49])
50
51###############################################################################
52# Set the debug level
53#    release: no debug information, all optimizations, no asserts.
54#    optimized: no debug information, all optimizations, no asserts, HotSpot target is 'optimized'.
55#    fastdebug: debug information (-g), all optimizations, all asserts
56#    slowdebug: debug information (-g), no optimizations, all asserts
57AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_LEVEL],
58[
59  DEBUG_LEVEL="release"
60  AC_MSG_CHECKING([which debug level to use])
61  AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
62      [set the debug level to fastdebug (shorthand for --with-debug-level=fastdebug) @<:@disabled@:>@])],
63      [
64        ENABLE_DEBUG="${enableval}"
65        DEBUG_LEVEL="fastdebug"
66      ], [ENABLE_DEBUG="no"])
67
68  AC_ARG_WITH([debug-level], [AS_HELP_STRING([--with-debug-level],
69      [set the debug level (release, fastdebug, slowdebug, optimized) @<:@release@:>@])],
70      [
71        DEBUG_LEVEL="${withval}"
72        if test "x$ENABLE_DEBUG" = xyes; then
73          AC_MSG_ERROR([You cannot use both --enable-debug and --with-debug-level at the same time.])
74        fi
75      ])
76  AC_MSG_RESULT([$DEBUG_LEVEL])
77
78  if test "x$DEBUG_LEVEL" != xrelease && \
79      test "x$DEBUG_LEVEL" != xoptimized && \
80      test "x$DEBUG_LEVEL" != xfastdebug && \
81      test "x$DEBUG_LEVEL" != xslowdebug; then
82    AC_MSG_ERROR([Allowed debug levels are: release, fastdebug, slowdebug and optimized])
83  fi
84
85  # Translate DEBUG_LEVEL to debug level used by Hotspot
86  HOTSPOT_DEBUG_LEVEL="$DEBUG_LEVEL"
87  if test "x$DEBUG_LEVEL" = xrelease; then
88    HOTSPOT_DEBUG_LEVEL="product"
89  elif test "x$DEBUG_LEVEL" = xslowdebug; then
90    HOTSPOT_DEBUG_LEVEL="debug"
91  fi
92
93  if test "x$DEBUG_LEVEL" = xoptimized; then
94    # The debug level 'optimized' is a little special because it is currently only
95    # applicable to the HotSpot build where it means to build a completely
96    # optimized version of the VM without any debugging code (like for the
97    # 'release' debug level which is called 'product' in the HotSpot build) but
98    # with the exception that it can contain additional code which is otherwise
99    # protected by '#ifndef PRODUCT' macros. These 'optimized' builds are used to
100    # test new and/or experimental features which are not intended for customer
101    # shipment. Because these new features need to be tested and benchmarked in
102    # real world scenarios, we want to build the containing JDK at the 'release'
103    # debug level.
104    DEBUG_LEVEL="release"
105  fi
106
107  AC_SUBST(HOTSPOT_DEBUG_LEVEL)
108  AC_SUBST(DEBUG_LEVEL)
109])
110
111###############################################################################
112#
113# Should we build only OpenJDK even if closed sources are present?
114#
115AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM],
116[
117  AC_ARG_ENABLE([openjdk-only], [AS_HELP_STRING([--enable-openjdk-only],
118      [suppress building custom source even if present @<:@disabled@:>@])],,[enable_openjdk_only="no"])
119
120  AC_MSG_CHECKING([if custom source is suppressed (openjdk-only)])
121  AC_MSG_RESULT([$enable_openjdk_only])
122  if test "x$enable_openjdk_only" = "xyes"; then
123    SUPPRESS_CUSTOM_EXTENSIONS="true"
124  elif test "x$enable_openjdk_only" = "xno"; then
125    SUPPRESS_CUSTOM_EXTENSIONS="false"
126  else
127    AC_MSG_ERROR([Invalid value for --enable-openjdk-only: $enable_openjdk_only])
128  fi
129
130  # custom-make-dir is deprecated. Please use your custom-hook.m4 to override
131  # the IncludeCustomExtension macro.
132  BASIC_DEPRECATED_ARG_WITH(custom-make-dir)
133])
134
135AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
136[
137  # Should we build a JDK without a graphical UI?
138  AC_MSG_CHECKING([headless only])
139  AC_ARG_ENABLE([headless-only], [AS_HELP_STRING([--enable-headless-only],
140      [only build headless (no GUI) support @<:@disabled@:>@])])
141
142  if test "x$enable_headless_only" = "xyes"; then
143    ENABLE_HEADLESS_ONLY="true"
144    AC_MSG_RESULT([yes])
145  elif test "x$enable_headless_only" = "xno"; then
146    ENABLE_HEADLESS_ONLY="false"
147    AC_MSG_RESULT([no])
148  elif test "x$enable_headless_only" = "x"; then
149    ENABLE_HEADLESS_ONLY="false"
150    AC_MSG_RESULT([no])
151  else
152    AC_MSG_ERROR([--enable-headless-only can only take yes or no])
153  fi
154
155  AC_SUBST(ENABLE_HEADLESS_ONLY)
156
157  # Should we build the complete docs, or just a lightweight version?
158  AC_ARG_ENABLE([full-docs], [AS_HELP_STRING([--enable-full-docs],
159      [build complete documentation @<:@enabled if all tools found@:>@])])
160
161  # Verify dependencies
162  AC_MSG_CHECKING([for graphviz dot])
163  if test "x$DOT" != "x"; then
164    AC_MSG_RESULT([yes])
165  else
166    AC_MSG_RESULT([no, cannot generate full docs])
167    FULL_DOCS_DEP_MISSING=true
168  fi
169
170  AC_MSG_CHECKING([for pandoc])
171  if test "x$PANDOC" != "x"; then
172    AC_MSG_RESULT([yes])
173  else
174    AC_MSG_RESULT([no, cannot generate full docs])
175    FULL_DOCS_DEP_MISSING=true
176  fi
177
178  AC_MSG_CHECKING([full docs])
179  if test "x$enable_full_docs" = xyes; then
180    if test "x$FULL_DOCS_DEP_MISSING" = "xtrue"; then
181      AC_MSG_RESULT([no, missing dependencies])
182      HELP_MSG_MISSING_DEPENDENCY([dot])
183      AC_MSG_ERROR([Cannot enable full docs with missing dependencies. See above. $HELP_MSG])
184    else
185      ENABLE_FULL_DOCS=true
186      AC_MSG_RESULT([yes, forced])
187    fi
188  elif test "x$enable_full_docs" = xno; then
189    ENABLE_FULL_DOCS=false
190    AC_MSG_RESULT([no, forced])
191  elif test "x$enable_full_docs" = x; then
192    # Check for prerequisites
193    if test "x$FULL_DOCS_DEP_MISSING" = xtrue; then
194      ENABLE_FULL_DOCS=false
195      AC_MSG_RESULT([no, missing dependencies])
196    else
197      ENABLE_FULL_DOCS=true
198      AC_MSG_RESULT([yes, dependencies present])
199    fi
200  else
201    AC_MSG_ERROR([--enable-full-docs can only take yes or no])
202  fi
203
204  AC_SUBST(ENABLE_FULL_DOCS)
205
206  # Choose cacerts source file
207  AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file],
208      [specify alternative cacerts file])])
209  AC_MSG_CHECKING([for cacerts file])
210  if test "x$with_cacerts_file" == x; then
211    AC_MSG_RESULT([default])
212  else
213    CACERTS_FILE=$with_cacerts_file
214    if test ! -f "$CACERTS_FILE"; then
215      AC_MSG_RESULT([fail])
216      AC_MSG_ERROR([Specified cacerts file "$CACERTS_FILE" does not exist])
217    fi
218    AC_MSG_RESULT([$CACERTS_FILE])
219  fi
220  AC_SUBST(CACERTS_FILE)
221
222  # Enable or disable unlimited crypto
223  AC_ARG_ENABLE(unlimited-crypto, [AS_HELP_STRING([--disable-unlimited-crypto],
224      [Disable unlimited crypto policy @<:@enabled@:>@])],,
225      [enable_unlimited_crypto=yes])
226  if test "x$enable_unlimited_crypto" = "xyes"; then
227    UNLIMITED_CRYPTO=true
228  else
229    UNLIMITED_CRYPTO=false
230  fi
231  AC_SUBST(UNLIMITED_CRYPTO)
232
233  # Should we build the serviceability agent (SA)?
234  INCLUDE_SA=true
235  if HOTSPOT_CHECK_JVM_VARIANT(zero); then
236    INCLUDE_SA=false
237  fi
238  if test "x$OPENJDK_TARGET_OS" = xaix ; then
239    INCLUDE_SA=false
240  fi
241  if test "x$OPENJDK_TARGET_CPU" = xs390x ; then
242    INCLUDE_SA=false
243  fi
244  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.openbsd ; then
245    INCLUDE_SA=false
246  fi
247  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd ; then
248    INCLUDE_SA=false
249  fi
250  AC_SUBST(INCLUDE_SA)
251
252  # Compress jars
253  COMPRESS_JARS=false
254
255  AC_SUBST(COMPRESS_JARS)
256
257  # Setup default copyright year. Mostly overridden when building close to a new year.
258  AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year],
259      [Set copyright year value for build @<:@current year@:>@])])
260  if test "x$with_copyright_year" = xyes; then
261    AC_MSG_ERROR([Copyright year must have a value])
262  elif test "x$with_copyright_year" != x; then
263    COPYRIGHT_YEAR="$with_copyright_year"
264  else
265    COPYRIGHT_YEAR=`$DATE +'%Y'`
266  fi
267  AC_SUBST(COPYRIGHT_YEAR)
268])
269
270###############################################################################
271#
272# Enable or disable the elliptic curve crypto implementation
273#
274AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
275[
276  AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
277
278  if test -d "${TOPDIR}/src/jdk.crypto.ec/share/native/libsunec/impl"; then
279    ENABLE_INTREE_EC=true
280    AC_MSG_RESULT([yes])
281  else
282    ENABLE_INTREE_EC=false
283    AC_MSG_RESULT([no])
284  fi
285
286  AC_SUBST(ENABLE_INTREE_EC)
287])
288
289AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
290[
291  #
292  # Native debug symbols.
293  # This must be done after the toolchain is setup, since we're looking at objcopy.
294  #
295  AC_MSG_CHECKING([what type of native debug symbols to use])
296  AC_ARG_WITH([native-debug-symbols],
297      [AS_HELP_STRING([--with-native-debug-symbols],
298      [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
299      [
300        if test "x$OPENJDK_TARGET_OS" = xwindows; then
301          if test "x$withval" = xinternal; then
302            AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols])
303          fi
304        fi
305      ],
306      [
307        if test "x$STATIC_BUILD" = xtrue; then
308          with_native_debug_symbols="none"
309        else
310          with_native_debug_symbols="external"
311        fi
312      ])
313  AC_MSG_RESULT([$with_native_debug_symbols])
314
315  if test "x$with_native_debug_symbols" = xnone; then
316    COMPILE_WITH_DEBUG_SYMBOLS=false
317    COPY_DEBUG_SYMBOLS=false
318    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
319  elif test "x$with_native_debug_symbols" = xinternal; then
320    COMPILE_WITH_DEBUG_SYMBOLS=true
321    COPY_DEBUG_SYMBOLS=false
322    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
323  elif test "x$with_native_debug_symbols" = xexternal; then
324
325    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
326      if test "x$OBJCOPY" = x; then
327        # enabling of enable-debug-symbols and can't find objcopy
328        # this is an error
329        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
330      fi
331    fi
332
333    COMPILE_WITH_DEBUG_SYMBOLS=true
334    COPY_DEBUG_SYMBOLS=true
335    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
336  elif test "x$with_native_debug_symbols" = xzipped; then
337
338    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
339      if test "x$OBJCOPY" = x; then
340        # enabling of enable-debug-symbols and can't find objcopy
341        # this is an error
342        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
343      fi
344    fi
345
346    COMPILE_WITH_DEBUG_SYMBOLS=true
347    COPY_DEBUG_SYMBOLS=true
348    ZIP_EXTERNAL_DEBUG_SYMBOLS=true
349  else
350    AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
351  fi
352
353  # --enable-debug-symbols is deprecated.
354  # Please use --with-native-debug-symbols=[internal,external,zipped] .
355  BASIC_DEPRECATED_ARG_ENABLE(debug-symbols, debug_symbols,
356        [Please use --with-native-debug-symbols=[[internal,external,zipped]] .])
357
358  # --enable-zip-debug-info is deprecated.
359  # Please use --with-native-debug-symbols=zipped .
360  BASIC_DEPRECATED_ARG_ENABLE(zip-debug-info, zip_debug_info,
361                              [Please use --with-native-debug-symbols=zipped .])
362
363  AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
364  AC_SUBST(COPY_DEBUG_SYMBOLS)
365  AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
366
367  # Should we add external native debug symbols to the shipped bundles?
368  AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles])
369  AC_ARG_WITH([external-symbols-in-bundles],
370      [AS_HELP_STRING([--with-external-symbols-in-bundles],
371      [which type of external native debug symbol information shall be shipped in product bundles (none, public, full)
372      (e.g. ship full/stripped pdbs on Windows) @<:@none@:>@])])
373
374  if test "x$with_external_symbols_in_bundles" = x || test "x$with_external_symbols_in_bundles" = xnone ; then
375    AC_MSG_RESULT([no])
376  elif test "x$with_external_symbols_in_bundles" = xfull || test "x$with_external_symbols_in_bundles" = xpublic ; then
377    if test "x$OPENJDK_TARGET_OS" != xwindows ; then
378      AC_MSG_ERROR([--with-external-symbols-in-bundles currently only works on windows!])
379    elif test "x$COPY_DEBUG_SYMBOLS" != xtrue ; then
380      AC_MSG_ERROR([--with-external-symbols-in-bundles only works when --with-native-debug-symbols=external is used!])
381    elif test "x$with_external_symbols_in_bundles" = xfull ; then
382      AC_MSG_RESULT([full])
383      SHIP_DEBUG_SYMBOLS=full
384    else
385      AC_MSG_RESULT([public])
386      SHIP_DEBUG_SYMBOLS=public
387    fi
388  else
389    AC_MSG_ERROR([$with_external_symbols_in_bundles is an unknown value for --with-external-symbols-in-bundles])
390  fi
391
392  AC_SUBST(SHIP_DEBUG_SYMBOLS)
393])
394
395################################################################################
396#
397# Gcov coverage data for hotspot
398#
399AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
400[
401  AC_ARG_ENABLE(native-coverage, [AS_HELP_STRING([--enable-native-coverage],
402      [enable native compilation with code coverage data@<:@disabled@:>@])])
403  GCOV_ENABLED="false"
404  if test "x$enable_native_coverage" = "xyes"; then
405    if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
406      AC_MSG_CHECKING([if native coverage is enabled])
407      AC_MSG_RESULT([yes])
408      GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline"
409      GCOV_LDFLAGS="-fprofile-arcs"
410      JVM_CFLAGS="$JVM_CFLAGS $GCOV_CFLAGS"
411      JVM_LDFLAGS="$JVM_LDFLAGS $GCOV_LDFLAGS"
412      CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS"
413      CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS"
414      CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS"
415      CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
416      LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
417      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
418      GCOV_ENABLED="true"
419    else
420      AC_MSG_ERROR([--enable-native-coverage only works with toolchain type gcc])
421    fi
422  elif test "x$enable_native_coverage" = "xno"; then
423    AC_MSG_CHECKING([if native coverage is enabled])
424    AC_MSG_RESULT([no])
425  elif test "x$enable_native_coverage" != "x"; then
426    AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"])
427  fi
428
429  AC_SUBST(GCOV_ENABLED)
430])
431
432###############################################################################
433#
434# AddressSanitizer
435#
436AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
437[
438  AC_ARG_ENABLE(asan, [AS_HELP_STRING([--enable-asan],
439      [enable AddressSanitizer if possible @<:@disabled@:>@])])
440  ASAN_ENABLED="no"
441  if test "x$enable_asan" = "xyes"; then
442    case $TOOLCHAIN_TYPE in
443      gcc | clang)
444        AC_MSG_CHECKING([if asan is enabled])
445        AC_MSG_RESULT([yes])
446        ASAN_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
447        ASAN_LDFLAGS="-fsanitize=address"
448        JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
449        JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
450        CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
451        CFLAGS_JDKEXE="$CFLAGS_JDKEXE $ASAN_CFLAGS"
452        CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $ASAN_CFLAGS"
453        CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS"
454        LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS"
455        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS"
456        ASAN_ENABLED="yes"
457        ;;
458      *)
459        AC_MSG_ERROR([--enable-asan only works with toolchain type gcc or clang])
460        ;;
461    esac
462  elif test "x$enable_asan" = "xno"; then
463    AC_MSG_CHECKING([if asan is enabled])
464    AC_MSG_RESULT([no])
465  elif test "x$enable_asan" != "x"; then
466    AC_MSG_ERROR([--enable-asan can only be assigned "yes" or "no"])
467  fi
468
469  AC_SUBST(ASAN_ENABLED)
470])
471
472################################################################################
473#
474# Static build support.  When enabled will generate static
475# libraries instead of shared libraries for all JDK libs.
476#
477AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
478[
479  AC_ARG_ENABLE([static-build], [AS_HELP_STRING([--enable-static-build],
480    [enable static library build @<:@disabled@:>@])])
481  STATIC_BUILD=false
482  if test "x$enable_static_build" = "xyes"; then
483    AC_MSG_CHECKING([if static build is enabled])
484    AC_MSG_RESULT([yes])
485    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
486      AC_MSG_ERROR([--enable-static-build is only supported for macosx builds])
487    fi
488    STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1"
489    CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
490    CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
491    STATIC_BUILD=true
492  elif test "x$enable_static_build" = "xno"; then
493    AC_MSG_CHECKING([if static build is enabled])
494    AC_MSG_RESULT([no])
495  elif test "x$enable_static_build" != "x"; then
496    AC_MSG_ERROR([--enable-static-build can only be assigned "yes" or "no"])
497  fi
498
499  AC_SUBST(STATIC_BUILD)
500])
501
502################################################################################
503#
504# jlink options.
505# We always keep packaged modules in JDK image.
506#
507AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
508[
509  AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules],
510    [Do not keep packaged modules in jdk image @<:@enable@:>@])])
511
512  AC_MSG_CHECKING([if packaged modules are kept])
513  if test "x$enable_keep_packaged_modules" = "xyes"; then
514    AC_MSG_RESULT([yes])
515    JLINK_KEEP_PACKAGED_MODULES=true
516  elif test "x$enable_keep_packaged_modules" = "xno"; then
517    AC_MSG_RESULT([no])
518    JLINK_KEEP_PACKAGED_MODULES=false
519  elif test "x$enable_keep_packaged_modules" = "x"; then
520    AC_MSG_RESULT([yes (default)])
521    JLINK_KEEP_PACKAGED_MODULES=true
522  else
523    AC_MSG_RESULT([error])
524    AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument])
525  fi
526
527  AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
528])
529
530################################################################################
531#
532# Check if building of the jtreg failure handler should be enabled.
533#
534AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
535[
536  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
537    [forces build of the jtreg failure handler to be enabled, missing dependencies
538     become fatal errors. Default is auto, where the failure handler is built if all
539     dependencies are present and otherwise just disabled.])])
540
541  AC_MSG_CHECKING([if jtreg failure handler should be built])
542
543  if test "x$enable_jtreg_failure_handler" = "xyes"; then
544    if test "x$JT_HOME" = "x"; then
545      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
546    else
547      BUILD_FAILURE_HANDLER=true
548      AC_MSG_RESULT([yes, forced])
549    fi
550  elif test "x$enable_jtreg_failure_handler" = "xno"; then
551    BUILD_FAILURE_HANDLER=false
552    AC_MSG_RESULT([no, forced])
553  elif test "x$enable_jtreg_failure_handler" = "xauto" \
554      || test "x$enable_jtreg_failure_handler" = "x"; then
555    if test "x$JT_HOME" = "x"; then
556      BUILD_FAILURE_HANDLER=false
557      AC_MSG_RESULT([no, missing jtreg])
558    else
559      BUILD_FAILURE_HANDLER=true
560      AC_MSG_RESULT([yes, jtreg present])
561    fi
562  else
563    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
564  fi
565
566  AC_SUBST(BUILD_FAILURE_HANDLER)
567])
568
569################################################################################
570#
571# Enable or disable generation of the classlist at build time
572#
573AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST],
574[
575  AC_ARG_ENABLE([generate-classlist], [AS_HELP_STRING([--disable-generate-classlist],
576      [forces enabling or disabling of the generation of a CDS classlist at build time.
577      Default is to generate it when either the server or client JVMs are built and
578      enable-cds is true.])])
579
580  # Check if it's likely that it's possible to generate the classlist. Depending
581  # on exact jvm configuration it could be possible anyway.
582  if test "x$ENABLE_CDS" = "xtrue" && (HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client)); then
583    ENABLE_GENERATE_CLASSLIST_POSSIBLE="true"
584  else
585    ENABLE_GENERATE_CLASSLIST_POSSIBLE="false"
586  fi
587
588  AC_MSG_CHECKING([if the CDS classlist generation should be enabled])
589  if test "x$enable_generate_classlist" = "xyes"; then
590    AC_MSG_RESULT([yes, forced])
591    ENABLE_GENERATE_CLASSLIST="true"
592    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
593      AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS])
594    fi
595  elif test "x$enable_generate_classlist" = "xno"; then
596    AC_MSG_RESULT([no, forced])
597    ENABLE_GENERATE_CLASSLIST="false"
598  elif test "x$enable_generate_classlist" = "x"; then
599    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xtrue"; then
600      AC_MSG_RESULT([yes])
601      ENABLE_GENERATE_CLASSLIST="true"
602    else
603      AC_MSG_RESULT([no])
604      ENABLE_GENERATE_CLASSLIST="false"
605    fi
606  else
607    AC_MSG_ERROR([Invalid value for --enable-generate-classlist: $enable_generate_classlist])
608  fi
609
610  AC_SUBST(ENABLE_GENERATE_CLASSLIST)
611])
612
613################################################################################
614#
615# Optionally filter resource translations
616#
617AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS],
618[
619  AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations],
620      [a comma separated list of locales to exclude translations for. Default is
621      to include all translations present in the source.])])
622
623  EXCLUDE_TRANSLATIONS=""
624  AC_MSG_CHECKING([if any translations should be excluded])
625  if test "x$with_exclude_translations" != "x"; then
626    EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }"
627    AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS])
628  else
629    AC_MSG_RESULT([no])
630  fi
631
632  AC_SUBST(EXCLUDE_TRANSLATIONS)
633])
634
635################################################################################
636#
637# Optionally disable man pages
638#
639AC_DEFUN([JDKOPT_ENABLE_DISABLE_MANPAGES],
640[
641  AC_ARG_ENABLE([manpages], [AS_HELP_STRING([--disable-manpages],
642      [Set to disable building of man pages @<:@enabled@:>@])])
643
644  BUILD_MANPAGES="true"
645  AC_MSG_CHECKING([if man pages should be built])
646  if test "x$enable_manpages" = "x"; then
647    AC_MSG_RESULT([yes])
648  elif test "x$enable_manpages" = "xyes"; then
649    AC_MSG_RESULT([yes, forced])
650  elif test "x$enable_manpages" = "xno"; then
651    AC_MSG_RESULT([no, forced])
652    BUILD_MANPAGES="false"
653  else
654    AC_MSG_RESULT([no])
655    AC_MSG_ERROR([--enable-manpages can only yes/no or empty])
656  fi
657
658  AC_SUBST(BUILD_MANPAGES)
659])
660
661################################################################################
662#
663# Disallow any output from containing absolute paths from the build system.
664# This setting defaults to allowed on debug builds and not allowed on release
665# builds.
666#
667AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT],
668[
669  AC_ARG_ENABLE([absolute-paths-in-output],
670      [AS_HELP_STRING([--disable-absolute-paths-in-output],
671       [Set to disable to prevent any absolute paths from the build to end up in
672        any of the build output. @<:@disabled in release builds, otherwise enabled@:>@])
673      ])
674
675  AC_MSG_CHECKING([if absolute paths should be allowed in the build output])
676  if test "x$enable_absolute_paths_in_output" = "xno"; then
677    AC_MSG_RESULT([no, forced])
678    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
679  elif test "x$enable_absolute_paths_in_output" = "xyes"; then
680    AC_MSG_RESULT([yes, forced])
681    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
682  elif test "x$DEBUG_LEVEL" = "xrelease"; then
683    AC_MSG_RESULT([no, release build])
684    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
685  else
686    AC_MSG_RESULT([yes, debug build])
687    ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
688  fi
689
690  AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)
691])
692