jdk-options.m4 revision 2017:9f1ecdfae7fb
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
86###############################################################################
87#
88# Should we build only OpenJDK even if closed sources are present?
89#
90AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM],
91[
92  AC_ARG_ENABLE([openjdk-only], [AS_HELP_STRING([--enable-openjdk-only],
93      [suppress building custom source even if present @<:@disabled@:>@])],,[enable_openjdk_only="no"])
94
95  AC_MSG_CHECKING([for presence of closed sources])
96  if test -d "$SRC_ROOT/jdk/src/closed"; then
97    CLOSED_SOURCE_PRESENT=yes
98  else
99    CLOSED_SOURCE_PRESENT=no
100  fi
101  AC_MSG_RESULT([$CLOSED_SOURCE_PRESENT])
102
103  AC_MSG_CHECKING([if closed source is suppressed (openjdk-only)])
104  SUPPRESS_CLOSED_SOURCE="$enable_openjdk_only"
105  AC_MSG_RESULT([$SUPPRESS_CLOSED_SOURCE])
106
107  if test "x$CLOSED_SOURCE_PRESENT" = xno; then
108    OPENJDK=true
109    if test "x$SUPPRESS_CLOSED_SOURCE" = "xyes"; then
110      AC_MSG_WARN([No closed source present, --enable-openjdk-only makes no sense])
111    fi
112  else
113    if test "x$SUPPRESS_CLOSED_SOURCE" = "xyes"; then
114      OPENJDK=true
115    else
116      OPENJDK=false
117    fi
118  fi
119
120  if test "x$OPENJDK" = "xtrue"; then
121    SET_OPENJDK="OPENJDK=true"
122  fi
123
124  AC_SUBST(SET_OPENJDK)
125
126  # custom-make-dir is deprecated. Please use your custom-hook.m4 to override
127  # the IncludeCustomExtension macro.
128  BASIC_DEPRECATED_ARG_WITH(custom-make-dir)
129])
130
131AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
132[
133  # Should we build a JDK/JVM with headful support (ie a graphical ui)?
134  # We always build headless support.
135  AC_MSG_CHECKING([headful support])
136  AC_ARG_ENABLE([headful], [AS_HELP_STRING([--disable-headful],
137      [disable building headful support (graphical UI support) @<:@enabled@:>@])],
138      [SUPPORT_HEADFUL=${enable_headful}], [SUPPORT_HEADFUL=yes])
139
140  SUPPORT_HEADLESS=yes
141  BUILD_HEADLESS="BUILD_HEADLESS:=true"
142
143  if test "x$SUPPORT_HEADFUL" = xyes; then
144    # We are building both headful and headless.
145    headful_msg="include support for both headful and headless"
146  fi
147
148  if test "x$SUPPORT_HEADFUL" = xno; then
149    # Thus we are building headless only.
150    BUILD_HEADLESS="BUILD_HEADLESS:=true"
151    headful_msg="headless only"
152  fi
153
154  AC_MSG_RESULT([$headful_msg])
155
156  AC_SUBST(SUPPORT_HEADLESS)
157  AC_SUBST(SUPPORT_HEADFUL)
158  AC_SUBST(BUILD_HEADLESS)
159
160  # Choose cacerts source file
161  AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file],
162      [specify alternative cacerts file])])
163  if test "x$with_cacerts_file" != x; then
164    CACERTS_FILE=$with_cacerts_file
165  fi
166  AC_SUBST(CACERTS_FILE)
167
168  # Enable or disable unlimited crypto
169  AC_ARG_ENABLE(unlimited-crypto, [AS_HELP_STRING([--enable-unlimited-crypto],
170      [Enable unlimited crypto policy @<:@disabled@:>@])],,
171      [enable_unlimited_crypto=no])
172  if test "x$enable_unlimited_crypto" = "xyes"; then
173    UNLIMITED_CRYPTO=true
174  else
175    UNLIMITED_CRYPTO=false
176  fi
177  AC_SUBST(UNLIMITED_CRYPTO)
178
179  # Should we build the serviceability agent (SA)?
180  INCLUDE_SA=true
181  if test "x$JVM_VARIANT_ZERO" = xtrue ; then
182    INCLUDE_SA=false
183  fi
184  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then
185    INCLUDE_SA=false
186  fi
187  if test "x$OPENJDK_TARGET_OS" = xaix ; then
188    INCLUDE_SA=false
189  fi
190  if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
191    INCLUDE_SA=false
192  fi
193  AC_SUBST(INCLUDE_SA)
194
195  # Compress jars
196  COMPRESS_JARS=false
197
198  AC_SUBST(COMPRESS_JARS)
199
200  # Setup default copyright year. Mostly overridden when building close to a new year.
201  AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year],
202      [Set copyright year value for build @<:@current year@:>@])])
203  if test "x$with_copyright_year" = xyes; then
204    AC_MSG_ERROR([Copyright year must have a value])
205  elif test "x$with_copyright_year" != x; then
206    COPYRIGHT_YEAR="$with_copyright_year"
207  else
208    COPYRIGHT_YEAR=`date +'%Y'`
209  fi
210  AC_SUBST(COPYRIGHT_YEAR)
211])
212
213###############################################################################
214#
215# Enable or disable the elliptic curve crypto implementation
216#
217AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
218[
219  AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
220
221  if test -d "${SRC_ROOT}/jdk/src/jdk.crypto.ec/share/native/libsunec/impl"; then
222    ENABLE_INTREE_EC=yes
223    AC_MSG_RESULT([yes])
224  else
225    ENABLE_INTREE_EC=no
226    AC_MSG_RESULT([no])
227  fi
228
229  AC_SUBST(ENABLE_INTREE_EC)
230])
231
232AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
233[
234  #
235  # NATIVE_DEBUG_SYMBOLS
236  # This must be done after the toolchain is setup, since we're looking at objcopy.
237  #
238  AC_MSG_CHECKING([what type of native debug symbols to use])
239  AC_ARG_WITH([native-debug-symbols],
240      [AS_HELP_STRING([--with-native-debug-symbols],
241      [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
242      [
243        if test "x$OPENJDK_TARGET_OS" = xaix; then
244          if test "x$withval" = xexternal || test "x$withval" = xzipped; then
245            AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols])
246          fi
247        fi
248      ],
249      [
250        if test "x$OPENJDK_TARGET_OS" = xaix; then
251          # AIX doesn't support 'zipped' so use 'internal' as default
252          with_native_debug_symbols="internal"
253        else
254          if test "x$STATIC_BUILD" = xtrue; then
255            with_native_debug_symbols="none"
256          else
257            with_native_debug_symbols="zipped"
258          fi
259        fi
260      ])
261  NATIVE_DEBUG_SYMBOLS=$with_native_debug_symbols
262  AC_MSG_RESULT([$NATIVE_DEBUG_SYMBOLS])
263
264  if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then
265
266    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
267      if test "x$OBJCOPY" = x; then
268        # enabling of enable-debug-symbols and can't find objcopy
269        # this is an error
270        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
271      fi
272    fi
273
274    COMPILE_WITH_DEBUG_SYMBOLS=true
275    COPY_DEBUG_SYMBOLS=true
276    ZIP_EXTERNAL_DEBUG_SYMBOLS=true
277
278    # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true
279    DEBUG_BINARIES=false
280    STRIP_POLICY=min_strip
281
282  elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then
283    COMPILE_WITH_DEBUG_SYMBOLS=false
284    COPY_DEBUG_SYMBOLS=false
285    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
286
287    DEBUG_BINARIES=false
288    STRIP_POLICY=no_strip
289  elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then
290    COMPILE_WITH_DEBUG_SYMBOLS=true
291    COPY_DEBUG_SYMBOLS=false
292    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
293
294    # Hotspot legacy support, will turn on -g when COPY_DEBUG_SYMBOLS=false
295    DEBUG_BINARIES=true
296    STRIP_POLICY=no_strip
297    STRIP=""
298
299  elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then
300
301    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
302      if test "x$OBJCOPY" = x; then
303        # enabling of enable-debug-symbols and can't find objcopy
304        # this is an error
305        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
306      fi
307    fi
308
309    COMPILE_WITH_DEBUG_SYMBOLS=true
310    COPY_DEBUG_SYMBOLS=true
311    ZIP_EXTERNAL_DEBUG_SYMBOLS=false
312
313    # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true
314    DEBUG_BINARIES=false
315    STRIP_POLICY=min_strip
316  else
317    AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
318  fi
319
320  # --enable-debug-symbols is deprecated.
321  # Please use --with-native-debug-symbols=[internal,external,zipped] .
322  BASIC_DEPRECATED_ARG_ENABLE(debug-symbols, debug_symbols,
323        [Please use --with-native-debug-symbols=[[internal,external,zipped]] .])
324
325  # --enable-zip-debug-info is deprecated.
326  # Please use --with-native-debug-symbols=zipped .
327  BASIC_DEPRECATED_ARG_ENABLE(zip-debug-info, zip_debug_info,
328                              [Please use --with-native-debug-symbols=zipped .])
329
330  AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
331  AC_SUBST(COPY_DEBUG_SYMBOLS)
332  AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
333
334  # Legacy values
335  AC_SUBST(DEBUG_BINARIES)
336  AC_SUBST(STRIP_POLICY)
337])
338
339################################################################################
340#
341# Gcov coverage data for hotspot
342#
343AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
344[
345  AC_ARG_ENABLE(native-coverage, [AS_HELP_STRING([--enable-native-coverage],
346      [enable native compilation with code coverage data@<:@disabled@:>@])])
347  GCOV_ENABLED="false"
348  if test "x$enable_native_coverage" = "xyes"; then
349    if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
350      AC_MSG_CHECKING([if native coverage is enabled])
351      AC_MSG_RESULT([yes])
352      GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline"
353      GCOV_LDFLAGS="-fprofile-arcs"
354      LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $GCOV_CFLAGS"
355      LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $GCOV_CFLAGS"
356      LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $GCOV_LDFLAGS"
357      CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS"
358      CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS"
359      CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS"
360      CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
361      LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
362      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
363      GCOV_ENABLED="true"
364    else
365      AC_MSG_ERROR([--enable-native-coverage only works with toolchain type gcc])
366    fi
367  elif test "x$enable_native_coverage" = "xno"; then
368    AC_MSG_CHECKING([if native coverage is enabled])
369    AC_MSG_RESULT([no])
370  elif test "x$enable_native_coverage" != "x"; then
371    AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"])
372  fi
373
374  AC_SUBST(GCOV_ENABLED)
375])
376
377################################################################################
378#
379# Static build support.  When enabled will generate static
380# libraries instead of shared libraries for all JDK libs.
381#
382AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
383[
384  AC_ARG_ENABLE([static-build], [AS_HELP_STRING([--enable-static-build],
385    [enable static library build @<:@disabled@:>@])])
386  STATIC_BUILD=false
387  if test "x$enable_static_build" = "xyes"; then
388    AC_MSG_CHECKING([if static build is enabled])
389    AC_MSG_RESULT([yes])
390    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
391      AC_MSG_ERROR([--enable-static-build is only supported for macosx builds])
392    fi
393    STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1"
394    LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $STATIC_BUILD_CFLAGS"
395    LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $STATIC_BUILD_CFLAGS"
396    CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
397    CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
398    STATIC_BUILD=true
399  elif test "x$enable_static_build" = "xno"; then
400    AC_MSG_CHECKING([if static build is enabled])
401    AC_MSG_RESULT([no])
402  elif test "x$enable_static_build" != "x"; then
403    AC_MSG_ERROR([--enable-static-build can only be assigned "yes" or "no"])
404  fi
405
406  AC_SUBST(STATIC_BUILD)
407])
408
409################################################################################
410#
411# jlink options.
412# We always keep packaged modules in JDK image.
413#
414AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
415[
416  AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules],
417    [Do not keep packaged modules in jdk image @<:@enable@:>@])])
418
419  if test "x$enable_keep_packaged_modules" = "xyes"; then
420    AC_MSG_CHECKING([if packaged modules are kept])
421    AC_MSG_RESULT([yes])
422    JLINK_KEEP_PACKAGED_MODULES=true
423  elif test "x$enable_keep_packaged_modules" = "xno"; then
424    AC_MSG_CHECKING([if packaged modules are kept])
425    AC_MSG_RESULT([no])
426    JLINK_KEEP_PACKAGED_MODULES=false
427  elif test "x$enable_keep_packaged_modules" = "x"; then
428    AC_MSG_RESULT([yes (default)])
429    JLINK_KEEP_PACKAGED_MODULES=true
430  else
431    AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument])
432  fi
433
434  AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
435])
436
437################################################################################
438#
439# Check if building of the jtreg failure handler should be enabled.
440#
441AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
442[
443  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
444    [forces build of the jtreg failure handler to be enabled, missing dependencies
445     become fatal errors. Default is auto, where the failure handler is built if all
446     dependencies are present and otherwise just disabled.])])
447
448  AC_MSG_CHECKING([if jtreg failure handler should be built])
449
450  if test "x$enable_jtreg_failure_handler" = "xyes"; then
451    if test "x$JT_HOME" = "x"; then
452      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
453    else
454      BUILD_FAILURE_HANDLER=true
455      AC_MSG_RESULT([yes, forced])
456    fi
457  elif test "x$enable_jtreg_failure_handler" = "xno"; then
458    BUILD_FAILURE_HANDLER=false
459    AC_MSG_RESULT([no, forced])
460  elif test "x$enable_jtreg_failure_handler" = "xauto" \
461      || test "x$enable_jtreg_failure_handler" = "x"; then
462    if test "x$JT_HOME" = "x"; then
463      BUILD_FAILURE_HANDLER=false
464      AC_MSG_RESULT([no, missing jtreg])
465    else
466      BUILD_FAILURE_HANDLER=true
467      AC_MSG_RESULT([yes, jtreg present])
468    fi
469  else
470    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
471  fi
472
473  AC_SUBST(BUILD_FAILURE_HANDLER)
474])
475