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 # 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-elf.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 cups is needed
  52   if test "x$OPENJDK_TARGET_OS" = xwindows; then
  53     # Windows have a separate print system
  54     NEEDS_LIB_CUPS=false
  55   else
  56     NEEDS_LIB_CUPS=true
  57   fi
  58 
  59   # A custom hook may have set this already
  60   if test "x$NEEDS_LIB_FREETYPE" = "x"; then
  61     NEEDS_LIB_FREETYPE=true
  62   fi
  63 
  64   # Check if alsa is needed
  65   if test "x$OPENJDK_TARGET_OS" = xlinux; then
  66     NEEDS_LIB_ALSA=true
  67   else
  68     NEEDS_LIB_ALSA=false
  69   fi
  70 
  71   # Check if ffi is needed
  72   if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
  73     NEEDS_LIB_FFI=true
  74   else
  75     NEEDS_LIB_FFI=false
  76   fi
  77 ])
  78 
  79 ################################################################################
  80 # Parse library options, and setup needed libraries
  81 ################################################################################
  82 AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
  83 [
  84   LIB_SETUP_STD_LIBS
  85   LIB_SETUP_X11
  86   LIB_SETUP_CUPS
  87   LIB_SETUP_FREETYPE
  88   LIB_SETUP_ALSA
  89   LIB_SETUP_LIBFFI
  90   LIB_SETUP_LLVM
  91   LIB_SETUP_BUNDLED_LIBS
  92   LIB_SETUP_MISC_LIBS
  93   LIB_SETUP_SOLARIS_STLPORT
  94   LIB_SETUP_LIBELF
  95 ])
  96 
  97 ################################################################################
  98 # Setup llvm (Low-Level VM)
  99 ################################################################################
 100 AC_DEFUN_ONCE([LIB_SETUP_LLVM],
 101 [
 102   if HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
 103     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 104 
 105     if test "x$LLVM_CONFIG" != xllvm-config; then
 106       AC_MSG_ERROR([llvm-config not found in $PATH.])
 107     fi
 108 
 109     llvm_components="jit mcjit engine nativecodegen native"
 110     unset LLVM_CFLAGS
 111     for flag in $("$LLVM_CONFIG" --cxxflags); do
 112       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 113         if test "${flag}" != "-D_DEBUG" ; then
 114           if test "${LLVM_CFLAGS}" != "" ; then
 115             LLVM_CFLAGS="${LLVM_CFLAGS} "
 116           fi
 117           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 118         fi
 119       fi
 120     done
 121     llvm_version=$("${LLVM_CONFIG}" --version | $SED 's/\.//; s/svn.*//')
 122     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 123 
 124     unset LLVM_LDFLAGS
 125     for flag in $("${LLVM_CONFIG}" --ldflags); do
 126       if echo "${flag}" | grep -q '^-L'; then
 127         if test "${LLVM_LDFLAGS}" != ""; then
 128           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 129         fi
 130         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 131       fi
 132     done
 133 
 134     unset LLVM_LIBS
 135     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 136       if echo "${flag}" | grep -q '^-l'; then
 137         if test "${LLVM_LIBS}" != ""; then
 138           LLVM_LIBS="${LLVM_LIBS} "
 139         fi
 140         LLVM_LIBS="${LLVM_LIBS}${flag}"
 141       fi
 142     done
 143 
 144     # Due to https://llvm.org/bugs/show_bug.cgi?id=16902, llvm does not
 145     # always properly detect -ltinfo
 146     LLVM_LIBS="${LLVM_LIBS} -ltinfo"
 147 
 148     AC_SUBST(LLVM_CFLAGS)
 149     AC_SUBST(LLVM_LDFLAGS)
 150     AC_SUBST(LLVM_LIBS)
 151   fi
 152 ])
 153 
 154 ################################################################################
 155 # Setup various libraries, typically small system libraries
 156 ################################################################################
 157 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 158 [
 159   # Setup libm (the maths library)
 160   if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
 161     AC_CHECK_LIB(m, cos, [], [
 162         AC_MSG_NOTICE([Maths library was not found])
 163     ])
 164     LIBM="-lm"
 165   else
 166     LIBM=""
 167   fi
 168   AC_SUBST(LIBM)
 169 
 170   # Setup libdl (for dynamic library loading)
 171   save_LIBS="$LIBS"
 172   LIBS=""
 173   AC_CHECK_LIB(dl, dlopen)
 174   LIBDL="$LIBS"
 175   AC_SUBST(LIBDL)
 176   LIBS="$save_LIBS"
 177 
 178   # Deprecated libraries, keep the flags for backwards compatibility
 179   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 180     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 181     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 182     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 183   fi
 184 
 185   # Control if libzip can use mmap. Available for purposes of overriding.
 186   LIBZIP_CAN_USE_MMAP=true
 187   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 188 ])
 189 
 190 ################################################################################
 191 # libstlport.so.1 is needed for running gtest on Solaris. Find it to
 192 # redistribute it in the test image.
 193 ################################################################################
 194 AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
 195 [
 196   if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
 197     # Find the root of the Solaris Studio installation from the compiler path
 198     SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
 199     STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
 200     AC_MSG_CHECKING([for libstlport.so.1])
 201     if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
 202       # SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
 203       STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
 204     fi
 205     if test -f "$STLPORT_LIB"; then
 206       AC_MSG_RESULT([yes, $STLPORT_LIB])
 207       BASIC_FIXUP_PATH([STLPORT_LIB])
 208     else
 209       AC_MSG_RESULT([no, not found at $STLPORT_LIB])
 210       AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
 211     fi
 212     AC_SUBST(STLPORT_LIB)
 213   fi
 214 ])
 215