jdk-options.m4 revision 2257:c26f6c23f782
1#
2# Copyright (c) 2011, 2016, 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  # Choose cacerts source file
158  AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file],
159      [specify alternative cacerts file])])
160  if test "x$with_cacerts_file" != x; then
161    CACERTS_FILE=$with_cacerts_file
162  fi
163  AC_SUBST(CACERTS_FILE)
164
165  # Enable or disable unlimited crypto
166  AC_ARG_ENABLE(unlimited-crypto, [AS_HELP_STRING([--enable-unlimited-crypto],
167      [Enable unlimited crypto policy @<:@disabled@:>@])],,
168      [enable_unlimited_crypto=no])
169  if test "x$enable_unlimited_crypto" = "xyes"; then
170    UNLIMITED_CRYPTO=true
171  else
172    UNLIMITED_CRYPTO=false
173  fi
174  AC_SUBST(UNLIMITED_CRYPTO)
175
176  # Should we build the serviceability agent (SA)?
177  INCLUDE_SA=true
178  if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
179    INCLUDE_SA=false
180  fi
181  if test "x$OPENJDK_TARGET_OS" = xaix ; then
182    INCLUDE_SA=false
183  fi
184  AC_SUBST(INCLUDE_SA)
185
186  # Compress jars
187  COMPRESS_JARS=false
188
189  AC_SUBST(COMPRESS_JARS)
190
191  # Setup default copyright year. Mostly overridden when building close to a new year.
192  AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year],
193      [Set copyright year value for build @<:@current year@:>@])])
194  if test "x$with_copyright_year" = xyes; then
195    AC_MSG_ERROR([Copyright year must have a value])
196  elif test "x$with_copyright_year" != x; then
197    COPYRIGHT_YEAR="$with_copyright_year"
198  else
199    COPYRIGHT_YEAR=`$DATE +'%Y'`
200  fi
201  AC_SUBST(COPYRIGHT_YEAR)
202])
203
204###############################################################################
205#
206# Enable or disable the elliptic curve crypto implementation
207#
208AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
209[
210  AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
211
212  if test -d "${SRC_ROOT}/jdk/src/jdk.crypto.ec/share/native/libsunec/impl"; then
213    ENABLE_INTREE_EC=yes
214    AC_MSG_RESULT([yes])
215  else
216    ENABLE_INTREE_EC=no
217    AC_MSG_RESULT([no])
218  fi
219
220  AC_SUBST(ENABLE_INTREE_EC)
221])
222
223AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
224[
225  #
226  # NATIVE_DEBUG_SYMBOLS
227  # This must be done after the toolchain is setup, since we're looking at objcopy.
228  #
229  AC_MSG_CHECKING([what type of native debug symbols to use])
230  AC_ARG_WITH([native-debug-symbols],
231      [AS_HELP_STRING([--with-native-debug-symbols],
232      [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
233      [
234        if test "x$OPENJDK_TARGET_OS" = xaix; then
235          if test "x$withval" = xexternal || test "x$withval" = xzipped; then
236            AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols])
237          fi
238        fi
239      ],
240      [
241        if test "x$OPENJDK_TARGET_OS" = xaix; then
242          # AIX doesn't support 'zipped' so use 'internal' as default
243          with_native_debug_symbols="internal"
244        else
245          if test "x$STATIC_BUILD" = xtrue; then
246            with_native_debug_symbols="none"
247          else
248            with_native_debug_symbols="zipped"
249          fi
250        fi
251      ])
252  NATIVE_DEBUG_SYMBOLS=$with_native_debug_symbols
253  AC_MSG_RESULT([$NATIVE_DEBUG_SYMBOLS])
254
255  if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then
256
257    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
258      if test "x$OBJCOPY" = x; then
259        # enabling of enable-debug-symbols and can't find objcopy
260        # this is an error
261        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
262      fi
263    fi
264
265    COMPILE_WITH_DEBUG_SYMBOLS=true
266    COPY_DEBUG_SYMBOLS=true
267    ZIP_EXTERNAL_DEBUG_SYMBOLS=true
268
269    # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true
270    DEBUG_BINARIES=false
271    STRIP_POLICY=min_strip
272
273  elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then
274    COMPILE_WITH_DEBUG_SYMBOLS=false
275    COPY_DEBUG_SYMBOLS=false
276    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
277
278    DEBUG_BINARIES=false
279    STRIP_POLICY=no_strip
280  elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then
281    COMPILE_WITH_DEBUG_SYMBOLS=true
282    COPY_DEBUG_SYMBOLS=false
283    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
284
285    # Hotspot legacy support, will turn on -g when COPY_DEBUG_SYMBOLS=false
286    DEBUG_BINARIES=true
287    STRIP_POLICY=no_strip
288    STRIP=""
289
290  elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then
291
292    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
293      if test "x$OBJCOPY" = x; then
294        # enabling of enable-debug-symbols and can't find objcopy
295        # this is an error
296        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
297      fi
298    fi
299
300    COMPILE_WITH_DEBUG_SYMBOLS=true
301    COPY_DEBUG_SYMBOLS=true
302    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
303
304    # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true
305    DEBUG_BINARIES=false
306    STRIP_POLICY=min_strip
307  else
308    AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
309  fi
310
311  # --enable-debug-symbols is deprecated.
312  # Please use --with-native-debug-symbols=[internal,external,zipped] .
313  BASIC_DEPRECATED_ARG_ENABLE(debug-symbols, debug_symbols,
314        [Please use --with-native-debug-symbols=[[internal,external,zipped]] .])
315
316  # --enable-zip-debug-info is deprecated.
317  # Please use --with-native-debug-symbols=zipped .
318  BASIC_DEPRECATED_ARG_ENABLE(zip-debug-info, zip_debug_info,
319                              [Please use --with-native-debug-symbols=zipped .])
320
321  AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
322  AC_SUBST(COPY_DEBUG_SYMBOLS)
323  AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
324
325  # Legacy values
326  AC_SUBST(DEBUG_BINARIES)
327  AC_SUBST(STRIP_POLICY)
328])
329
330################################################################################
331#
332# Gcov coverage data for hotspot
333#
334AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
335[
336  AC_ARG_ENABLE(native-coverage, [AS_HELP_STRING([--enable-native-coverage],
337      [enable native compilation with code coverage data@<:@disabled@:>@])])
338  GCOV_ENABLED="false"
339  if test "x$enable_native_coverage" = "xyes"; then
340    if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
341      AC_MSG_CHECKING([if native coverage is enabled])
342      AC_MSG_RESULT([yes])
343      GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline"
344      GCOV_LDFLAGS="-fprofile-arcs"
345      LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $GCOV_CFLAGS"
346      LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $GCOV_CFLAGS"
347      LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $GCOV_LDFLAGS"
348      CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS"
349      CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS"
350      CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS"
351      CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
352      LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
353      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
354      GCOV_ENABLED="true"
355    else
356      AC_MSG_ERROR([--enable-native-coverage only works with toolchain type gcc])
357    fi
358  elif test "x$enable_native_coverage" = "xno"; then
359    AC_MSG_CHECKING([if native coverage is enabled])
360    AC_MSG_RESULT([no])
361  elif test "x$enable_native_coverage" != "x"; then
362    AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"])
363  fi
364
365  AC_SUBST(GCOV_ENABLED)
366])
367
368################################################################################
369#
370# Static build support.  When enabled will generate static
371# libraries instead of shared libraries for all JDK libs.
372#
373AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
374[
375  AC_ARG_ENABLE([static-build], [AS_HELP_STRING([--enable-static-build],
376    [enable static library build @<:@disabled@:>@])])
377  STATIC_BUILD=false
378  if test "x$enable_static_build" = "xyes"; then
379    AC_MSG_CHECKING([if static build is enabled])
380    AC_MSG_RESULT([yes])
381    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
382      AC_MSG_ERROR([--enable-static-build is only supported for macosx builds])
383    fi
384    STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1"
385    LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $STATIC_BUILD_CFLAGS"
386    LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $STATIC_BUILD_CFLAGS"
387    CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
388    CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
389    STATIC_BUILD=true
390  elif test "x$enable_static_build" = "xno"; then
391    AC_MSG_CHECKING([if static build is enabled])
392    AC_MSG_RESULT([no])
393  elif test "x$enable_static_build" != "x"; then
394    AC_MSG_ERROR([--enable-static-build can only be assigned "yes" or "no"])
395  fi
396
397  AC_SUBST(STATIC_BUILD)
398])
399
400################################################################################
401#
402# jlink options.
403# We always keep packaged modules in JDK image.
404#
405AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
406[
407  AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules],
408    [Do not keep packaged modules in jdk image @<:@enable@:>@])])
409
410  if test "x$enable_keep_packaged_modules" = "xyes"; then
411    AC_MSG_CHECKING([if packaged modules are kept])
412    AC_MSG_RESULT([yes])
413    JLINK_KEEP_PACKAGED_MODULES=true
414  elif test "x$enable_keep_packaged_modules" = "xno"; then
415    AC_MSG_CHECKING([if packaged modules are kept])
416    AC_MSG_RESULT([no])
417    JLINK_KEEP_PACKAGED_MODULES=false
418  elif test "x$enable_keep_packaged_modules" = "x"; then
419    AC_MSG_RESULT([yes (default)])
420    JLINK_KEEP_PACKAGED_MODULES=true
421  else
422    AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument])
423  fi
424
425  AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
426])
427
428################################################################################
429#
430# Check if building of the jtreg failure handler should be enabled.
431#
432AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
433[
434  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
435    [forces build of the jtreg failure handler to be enabled, missing dependencies
436     become fatal errors. Default is auto, where the failure handler is built if all
437     dependencies are present and otherwise just disabled.])])
438
439  AC_MSG_CHECKING([if jtreg failure handler should be built])
440
441  if test "x$enable_jtreg_failure_handler" = "xyes"; then
442    if test "x$JT_HOME" = "x"; then
443      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
444    else
445      BUILD_FAILURE_HANDLER=true
446      AC_MSG_RESULT([yes, forced])
447    fi
448  elif test "x$enable_jtreg_failure_handler" = "xno"; then
449    BUILD_FAILURE_HANDLER=false
450    AC_MSG_RESULT([no, forced])
451  elif test "x$enable_jtreg_failure_handler" = "xauto" \
452      || test "x$enable_jtreg_failure_handler" = "x"; then
453    if test "x$JT_HOME" = "x"; then
454      BUILD_FAILURE_HANDLER=false
455      AC_MSG_RESULT([no, missing jtreg])
456    else
457      BUILD_FAILURE_HANDLER=true
458      AC_MSG_RESULT([yes, jtreg present])
459    fi
460  else
461    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
462  fi
463
464  AC_SUBST(BUILD_FAILURE_HANDLER)
465])
466
467################################################################################
468#
469# Enable or disable generation of the classlist at build time
470#
471AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST],
472[
473  AC_ARG_ENABLE([generate-classlist], [AS_HELP_STRING([--disable-generate-classlist],
474      [forces enabling or disabling of the generation of a CDS classlist at build time.
475      Default is to generate it when either the server or client JVMs are built.])])
476
477  # Check if it's likely that it's possible to generate the classlist. Depending
478  # on exact jvm configuration it could be possible anyway.
479  if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client); then
480    ENABLE_GENERATE_CLASSLIST_POSSIBLE="true"
481  else
482    ENABLE_GENERATE_CLASSLIST_POSSIBLE="false"
483  fi
484
485  AC_MSG_CHECKING([if the CDS classlist generation should be enabled])
486  if test "x$enable_generate_classlist" = "xyes"; then
487    AC_MSG_RESULT([yes, forced])
488    ENABLE_GENERATE_CLASSLIST="true"
489    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
490      AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS])
491    fi
492  elif test "x$enable_generate_classlist" = "xno"; then
493    AC_MSG_RESULT([no, forced])
494    ENABLE_GENERATE_CLASSLIST="false"
495  elif test "x$enable_generate_classlist" = "x"; then
496    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xtrue"; then
497      AC_MSG_RESULT([yes])
498      ENABLE_GENERATE_CLASSLIST="true"
499    else
500      AC_MSG_RESULT([no])
501      ENABLE_GENERATE_CLASSLIST="false"
502    fi
503  else
504    AC_MSG_ERROR([Invalid value for --enable-generate-classlist: $enable_generate_classlist])
505  fi
506
507  AC_SUBST([ENABLE_GENERATE_CLASSLIST])
508])
509