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 ])
  99 
 100 ################################################################################
 101 # Setup llvm (Low-Level VM)
 102 ################################################################################
 103 AC_DEFUN_ONCE([LIB_SETUP_LLVM],
 104 [
 105   if HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
 106     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 107 
 108     if test "x$LLVM_CONFIG" != xllvm-config; then
 109       AC_MSG_ERROR([llvm-config not found in $PATH.])
 110     fi
 111 
 112     llvm_components="jit mcjit engine nativecodegen native"
 113     unset LLVM_CFLAGS
 114     for flag in $("$LLVM_CONFIG" --cxxflags); do
 115       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 116         if test "${flag}" != "-D_DEBUG" ; then
 117           if test "${LLVM_CFLAGS}" != "" ; then
 118             LLVM_CFLAGS="${LLVM_CFLAGS} "
 119           fi
 120           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 121         fi
 122       fi
 123     done
 124     llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
 125     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 126 
 127     unset LLVM_LDFLAGS
 128     for flag in $("${LLVM_CONFIG}" --ldflags); do
 129       if echo "${flag}" | grep -q '^-L'; then
 130         if test "${LLVM_LDFLAGS}" != ""; then
 131           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 132         fi
 133         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 134       fi
 135     done
 136 
 137     unset LLVM_LIBS
 138     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 139       if echo "${flag}" | grep -q '^-l'; then
 140         if test "${LLVM_LIBS}" != ""; then
 141           LLVM_LIBS="${LLVM_LIBS} "
 142         fi
 143         LLVM_LIBS="${LLVM_LIBS}${flag}"
 144       fi
 145     done
 146 
 147     # Due to https://llvm.org/bugs/show_bug.cgi?id=16902, llvm does not
 148     # always properly detect -ltinfo
 149     LLVM_LIBS="${LLVM_LIBS} -ltinfo"
 150 
 151     AC_SUBST(LLVM_CFLAGS)
 152     AC_SUBST(LLVM_LDFLAGS)
 153     AC_SUBST(LLVM_LIBS)
 154   fi
 155 ])
 156 
 157 ################################################################################
 158 # Setup various libraries, typically small system libraries
 159 ################################################################################
 160 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 161 [
 162   # Setup libm (the maths library)
 163   if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
 164     AC_CHECK_LIB(m, cos, [], [
 165         AC_MSG_NOTICE([Maths library was not found])
 166     ])
 167     LIBM="-lm"
 168   else
 169     LIBM=""
 170   fi
 171   AC_SUBST(LIBM)
 172 
 173   # Setup libdl (for dynamic library loading)
 174   save_LIBS="$LIBS"
 175   LIBS=""
 176   AC_CHECK_LIB(dl, dlopen)
 177   LIBDL="$LIBS"
 178   AC_SUBST(LIBDL)
 179   LIBS="$save_LIBS"
 180 
 181   # Deprecated libraries, keep the flags for backwards compatibility
 182   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 183     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 184     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 185     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 186   fi
 187 
 188   # Control if libzip can use mmap. Available for purposes of overriding.
 189   LIBZIP_CAN_USE_MMAP=true
 190   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 191 ])