1 #
   2 # Copyright (c) 2011, 2017, 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 
  35 ################################################################################
  36 # Determine which libraries are needed for this configuration
  37 ################################################################################
  38 AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
  39 [
  40   # Check if X11 is needed
  41   if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
  42     # No X11 support on windows or macosx
  43     NEEDS_LIB_X11=false
  44   else
  45     # All other instances need X11, even if building headless only, libawt still
  46     # needs X11 headers.
  47     NEEDS_LIB_X11=true
  48   fi
  49 
  50   # Check if cups is needed
  51   if test "x$OPENJDK_TARGET_OS" = xwindows; then
  52     # Windows have a separate print system
  53     NEEDS_LIB_CUPS=false
  54   else
  55     NEEDS_LIB_CUPS=true
  56   fi
  57 
  58   # A custom hook may have set this already
  59   if test "x$NEEDS_LIB_FREETYPE" = "x"; then
  60     NEEDS_LIB_FREETYPE=true
  61   fi
  62 
  63   # Check if alsa is needed
  64   if test "x$OPENJDK_TARGET_OS" = xlinux; then
  65     NEEDS_LIB_ALSA=true
  66   else
  67     NEEDS_LIB_ALSA=false
  68   fi
  69 
  70   # Check if ffi is needed
  71   if HOTSPOT_CHECK_JVM_VARIANT(zero); then
  72     NEEDS_LIB_FFI=true
  73   else
  74     NEEDS_LIB_FFI=false
  75   fi
  76 ])
  77 
  78 ################################################################################
  79 # Parse library options, and setup needed libraries
  80 ################################################################################
  81 AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
  82 [
  83   LIB_SETUP_STD_LIBS
  84   LIB_SETUP_X11
  85   LIB_SETUP_CUPS
  86   LIB_SETUP_FREETYPE
  87   LIB_SETUP_ALSA
  88   LIB_SETUP_LIBFFI
  89   LIB_SETUP_BUNDLED_LIBS
  90   LIB_SETUP_MISC_LIBS
  91   LIB_SETUP_SOLARIS_STLPORT
  92 ])
  93 
  94 ################################################################################
  95 # Setup various libraries, typically small system libraries
  96 ################################################################################
  97 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
  98 [
  99   # Setup libm (the maths library)
 100   if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
 101     AC_CHECK_LIB(m, cos, [], [
 102         AC_MSG_NOTICE([Maths library was not found])
 103     ])
 104     LIBM="-lm"
 105   else
 106     LIBM=""
 107   fi
 108   AC_SUBST(LIBM)
 109 
 110   # Setup libdl (for dynamic library loading)
 111   save_LIBS="$LIBS"
 112   LIBS=""
 113   AC_CHECK_LIB(dl, dlopen)
 114   LIBDL="$LIBS"
 115   AC_SUBST(LIBDL)
 116   LIBS="$save_LIBS"
 117 
 118   # Deprecated libraries, keep the flags for backwards compatibility
 119   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 120     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 121     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 122     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 123   fi
 124 
 125   # Control if libzip can use mmap. Available for purposes of overriding.
 126   LIBZIP_CAN_USE_MMAP=true
 127   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 128 ])
 129 
 130 ################################################################################
 131 # libstlport.so.1 is needed for running gtest on Solaris. Find it to
 132 # redistribute it in the test image.
 133 ################################################################################
 134 AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
 135 [
 136   if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
 137     # Find the root of the Solaris Studio installation from the compiler path
 138     SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
 139     STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
 140     AC_MSG_CHECKING([for libstlport.so.1])
 141     if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
 142       # SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
 143       STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
 144     fi
 145     if test -f "$STLPORT_LIB"; then
 146       AC_MSG_RESULT([yes, $STLPORT_LIB])
 147       BASIC_FIXUP_PATH([STLPORT_LIB])
 148     else
 149       AC_MSG_RESULT([no, not found at $STLPORT_LIB])
 150       AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
 151     fi
 152     AC_SUBST(STLPORT_LIB)
 153   fi
 154 ])
 155