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