1 #
   2 # Copyright (c) 2011, 2018, 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 # Major library component reside in separate files.
  27 m4_include([lib-alsa.m4])
  28 m4_include([lib-bundled.m4])
  29 m4_include([lib-cups.m4])
  30 m4_include([lib-ffi.m4])
  31 m4_include([lib-freetype.m4])
  32 m4_include([lib-std.m4])
  33 m4_include([lib-x11.m4])
  34 m4_include([lib-fontconfig.m4])
  35 
  36 ################################################################################
  37 # Determine which libraries are needed for this configuration
  38 ################################################################################
  39 AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
  40 [
  41   # Check if X11 is needed
  42   if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
  43     # No X11 support on windows or macosx
  44     NEEDS_LIB_X11=false
  45   else
  46     # All other instances need X11, even if building headless only, libawt still
  47     # needs X11 headers.
  48     NEEDS_LIB_X11=true
  49   fi
  50 
  51   # Check if fontconfig is needed
  52   if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
  53     # No fontconfig support on windows or macosx
  54     NEEDS_LIB_FONTCONFIG=false
  55   else
  56     # All other instances need fontconfig, even if building headless only,
  57     # libawt still needs fontconfig headers.
  58     NEEDS_LIB_FONTCONFIG=true
  59   fi
  60 
  61   # Check if cups is needed
  62   if test "x$OPENJDK_TARGET_OS" = xwindows; then
  63     # Windows have a separate print system
  64     NEEDS_LIB_CUPS=false
  65   else
  66     NEEDS_LIB_CUPS=true
  67   fi
  68 
  69   # A custom hook may have set this already
  70   if test "x$NEEDS_LIB_FREETYPE" = "x"; then
  71     NEEDS_LIB_FREETYPE=true
  72   fi
  73 
  74   # Check if alsa is needed
  75   if test "x$OPENJDK_TARGET_OS" = xlinux; then
  76     NEEDS_LIB_ALSA=true
  77   else
  78     NEEDS_LIB_ALSA=false
  79   fi
  80 
  81   # Check if ffi is needed
  82   if HOTSPOT_CHECK_JVM_VARIANT(zero); then
  83     NEEDS_LIB_FFI=true
  84   else
  85     NEEDS_LIB_FFI=false
  86   fi
  87 ])
  88 
  89 ################################################################################
  90 # Parse library options, and setup needed libraries
  91 ################################################################################
  92 AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
  93 [
  94   LIB_SETUP_STD_LIBS
  95   LIB_SETUP_X11
  96   LIB_SETUP_CUPS
  97   LIB_SETUP_FONTCONFIG
  98   LIB_SETUP_FREETYPE
  99   LIB_SETUP_ALSA
 100   LIB_SETUP_LIBFFI
 101   LIB_SETUP_BUNDLED_LIBS
 102   LIB_SETUP_MISC_LIBS
 103   LIB_SETUP_SOLARIS_STLPORT
 104 
 105   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 106     GLOBAL_LIBS="-lc"
 107   else
 108     GLOBAL_LIBS=""
 109   fi
 110 
 111   BASIC_JDKLIB_LIBS=""
 112   if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
 113     BASIC_JDKLIB_LIBS="-ljava -ljvm"
 114   fi
 115 
 116   # Math library
 117   if test "x$OPENJDK_TARGET_OS" != xsolaris; then
 118     BASIC_JVM_LIBS="$LIBM"
 119   else
 120     # FIXME: This hard-coded path is not really proper.
 121     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 122       BASIC_SOLARIS_LIBM_LIBS="/usr/lib/amd64/libm.so.1"
 123     elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
 124       BASIC_SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
 125     fi
 126     BASIC_JVM_LIBS="$BASIC_SOLARIS_LIBM_LIBS"
 127   fi
 128 
 129   # Dynamic loading library
 130   if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
 131     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBDL"
 132   fi
 133 
 134   # Threading library
 135   if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
 136     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lpthread"
 137   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
 138     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread"
 139   fi
 140 
 141   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 142     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lsocket -lsched -ldoor -ldemangle -lnsl \
 143         -lrt"
 144     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBCXX_JVM"
 145   fi
 146 
 147   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 148     BASIC_JVM_LIBS="$BASIC_JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
 149         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
 150         wsock32.lib winmm.lib version.lib psapi.lib"
 151   fi
 152 
 153   JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
 154   JDKEXE_LIBS=""
 155   JVM_LIBS="$BASIC_JVM_LIBS"
 156   OPENJDK_BUILD_JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
 157   OPENJDK_BUILD_JVM_LIBS="$BASIC_JVM_LIBS"
 158 
 159   AC_SUBST(JDKLIB_LIBS)
 160   AC_SUBST(JDKEXE_LIBS)
 161   AC_SUBST(JVM_LIBS)
 162   AC_SUBST(OPENJDK_BUILD_JDKLIB_LIBS)
 163   AC_SUBST(OPENJDK_BUILD_JVM_LIBS)
 164   AC_SUBST(GLOBAL_LIBS)
 165 ])
 166 
 167 ################################################################################
 168 # Setup various libraries, typically small system libraries
 169 ################################################################################
 170 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 171 [
 172   # Setup libm (the maths library)
 173   if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
 174     AC_CHECK_LIB(m, cos, [], [
 175         AC_MSG_NOTICE([Maths library was not found])
 176     ])
 177     LIBM="-lm"
 178   else
 179     LIBM=""
 180   fi
 181   AC_SUBST(LIBM)
 182 
 183   # Setup libdl (for dynamic library loading)
 184   save_LIBS="$LIBS"
 185   LIBS=""
 186   AC_CHECK_LIB(dl, dlopen)
 187   LIBDL="$LIBS"
 188   AC_SUBST(LIBDL)
 189   LIBS="$save_LIBS"
 190 
 191   # Deprecated libraries, keep the flags for backwards compatibility
 192   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 193     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 194     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 195     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 196   fi
 197 
 198   # Control if libzip can use mmap. Available for purposes of overriding.
 199   LIBZIP_CAN_USE_MMAP=true
 200   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 201 ])
 202 
 203 ################################################################################
 204 # libstlport.so.1 is needed for running gtest on Solaris. Find it to
 205 # redistribute it in the test image.
 206 ################################################################################
 207 AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
 208 [
 209   if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
 210     # Find the root of the Solaris Studio installation from the compiler path
 211     SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
 212     STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
 213     AC_MSG_CHECKING([for libstlport.so.1])
 214     if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
 215       # SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
 216       STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
 217     fi
 218     if test -f "$STLPORT_LIB"; then
 219       AC_MSG_RESULT([yes, $STLPORT_LIB])
 220       BASIC_FIXUP_PATH([STLPORT_LIB])
 221     else
 222       AC_MSG_RESULT([no, not found at $STLPORT_LIB])
 223       AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
 224     fi
 225     AC_SUBST(STLPORT_LIB)
 226   fi
 227 ])
 228