libraries.m4 revision 2107:89769a2f1511
11541Srgrimes#
21541Srgrimes# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
31541Srgrimes# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41541Srgrimes#
51541Srgrimes# This code is free software; you can redistribute it and/or modify it
61541Srgrimes# under the terms of the GNU General Public License version 2 only, as
71541Srgrimes# published by the Free Software Foundation.  Oracle designates this
81541Srgrimes# particular file as subject to the "Classpath" exception as provided
91541Srgrimes# by Oracle in the LICENSE file that accompanied this code.
101541Srgrimes#
111541Srgrimes# This code is distributed in the hope that it will be useful, but WITHOUT
121541Srgrimes# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131541Srgrimes# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141541Srgrimes# version 2 for more details (a copy is included in the LICENSE file that
151541Srgrimes# accompanied this code).
161541Srgrimes#
171541Srgrimes# You should have received a copy of the GNU General Public License version
181541Srgrimes# 2 along with this work; if not, write to the Free Software Foundation,
191541Srgrimes# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201541Srgrimes#
211541Srgrimes# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221541Srgrimes# or visit www.oracle.com if you need additional information or have any
231541Srgrimes# questions.
241541Srgrimes#
251541Srgrimes
261541Srgrimes# Major library component reside in separate files.
271541Srgrimesm4_include([lib-alsa.m4])
281541Srgrimesm4_include([lib-bundled.m4])
291541Srgrimesm4_include([lib-cups.m4])
301541Srgrimesm4_include([lib-ffi.m4])
311541Srgrimesm4_include([lib-freetype.m4])
321541Srgrimesm4_include([lib-std.m4])
331541Srgrimesm4_include([lib-x11.m4])
342165Spaul
351541Srgrimes################################################################################
361541Srgrimes# Determine which libraries are needed for this configuration
372165Spaul################################################################################
382165SpaulAC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
392165Spaul[
401541Srgrimes  # Check if X11 is needed
411541Srgrimes  if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
421541Srgrimes    # No X11 support on windows or macosx
431541Srgrimes    NEEDS_LIB_X11=false
441541Srgrimes  else
451541Srgrimes    if test "x$SUPPORT_HEADFUL" = xno; then
461541Srgrimes      # No X11 support if building headless-only
471541Srgrimes      NEEDS_LIB_X11=false
481541Srgrimes    else
491541Srgrimes      # All other instances need X11
501541Srgrimes      NEEDS_LIB_X11=true
511541Srgrimes    fi
521541Srgrimes  fi
531541Srgrimes
541541Srgrimes  # Check if cups is needed
551541Srgrimes  if test "x$OPENJDK_TARGET_OS" = xwindows; then
561541Srgrimes    # Windows have a separate print system
571541Srgrimes    NEEDS_LIB_CUPS=false
581541Srgrimes  else
591541Srgrimes    NEEDS_LIB_CUPS=true
601541Srgrimes  fi
611541Srgrimes
621541Srgrimes  # Check if freetype is needed
631541Srgrimes  if test "x$OPENJDK" = "xtrue"; then
641541Srgrimes    NEEDS_LIB_FREETYPE=true
651541Srgrimes  else
661541Srgrimes    NEEDS_LIB_FREETYPE=false
671541Srgrimes  fi
681541Srgrimes
691541Srgrimes  # Check if alsa is needed
701541Srgrimes  if test "x$OPENJDK_TARGET_OS" = xlinux; then
711541Srgrimes    NEEDS_LIB_ALSA=true
721541Srgrimes  else
731541Srgrimes    NEEDS_LIB_ALSA=false
741541Srgrimes  fi
751541Srgrimes
761541Srgrimes  # Check if ffi is needed
771541Srgrimes  if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
781541Srgrimes    NEEDS_LIB_FFI=true
791541Srgrimes  else
801541Srgrimes    NEEDS_LIB_FFI=false
811541Srgrimes  fi
821541Srgrimes])
831541Srgrimes
841541Srgrimes################################################################################
851541Srgrimes# Parse library options, and setup needed libraries
861541Srgrimes################################################################################
871541SrgrimesAC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
881541Srgrimes[
891541Srgrimes  LIB_SETUP_STD_LIBS
901541Srgrimes  LIB_SETUP_X11
911541Srgrimes  LIB_SETUP_CUPS
921541Srgrimes  LIB_SETUP_FREETYPE
931541Srgrimes  LIB_SETUP_ALSA
941541Srgrimes  LIB_SETUP_LIBFFI
951541Srgrimes  LIB_SETUP_LLVM
961541Srgrimes  LIB_SETUP_BUNDLED_LIBS
971541Srgrimes  LIB_SETUP_MISC_LIBS
981541Srgrimes  LIB_SETUP_SOLARIS_STLPORT
991541Srgrimes])
1001541Srgrimes
1011541Srgrimes################################################################################
1021541Srgrimes# Setup llvm (Low-Level VM)
1031541Srgrimes################################################################################
1041541SrgrimesAC_DEFUN_ONCE([LIB_SETUP_LLVM],
1051541Srgrimes[
1061541Srgrimes  if HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
1071541Srgrimes    AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
1081541Srgrimes
1091541Srgrimes    if test "x$LLVM_CONFIG" != xllvm-config; then
1101541Srgrimes      AC_MSG_ERROR([llvm-config not found in $PATH.])
1111541Srgrimes    fi
1121541Srgrimes
1131541Srgrimes    llvm_components="jit mcjit engine nativecodegen native"
1141541Srgrimes    unset LLVM_CFLAGS
1151541Srgrimes    for flag in $("$LLVM_CONFIG" --cxxflags); do
1161541Srgrimes      if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
1171541Srgrimes        if test "${flag}" != "-D_DEBUG" ; then
1181541Srgrimes          if test "${LLVM_CFLAGS}" != "" ; then
1191541Srgrimes            LLVM_CFLAGS="${LLVM_CFLAGS} "
1201541Srgrimes          fi
1211541Srgrimes          LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
1221541Srgrimes        fi
1231541Srgrimes      fi
1241541Srgrimes    done
1251541Srgrimes    llvm_version=$("${LLVM_CONFIG}" --version | $SED 's/\.//; s/svn.*//')
1261541Srgrimes    LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
1271541Srgrimes
1281541Srgrimes    unset LLVM_LDFLAGS
1291541Srgrimes    for flag in $("${LLVM_CONFIG}" --ldflags); do
1301541Srgrimes      if echo "${flag}" | grep -q '^-L'; then
1311541Srgrimes        if test "${LLVM_LDFLAGS}" != ""; then
1321541Srgrimes          LLVM_LDFLAGS="${LLVM_LDFLAGS} "
1331541Srgrimes        fi
1341541Srgrimes        LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
1351541Srgrimes      fi
1361541Srgrimes    done
1371541Srgrimes
1381541Srgrimes    unset LLVM_LIBS
1391541Srgrimes    for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
1401541Srgrimes      if echo "${flag}" | grep -q '^-l'; then
1411541Srgrimes        if test "${LLVM_LIBS}" != ""; then
1421541Srgrimes          LLVM_LIBS="${LLVM_LIBS} "
1431541Srgrimes        fi
1441541Srgrimes        LLVM_LIBS="${LLVM_LIBS}${flag}"
1451541Srgrimes      fi
1461541Srgrimes    done
1471541Srgrimes
1481541Srgrimes    # Due to https://llvm.org/bugs/show_bug.cgi?id=16902, llvm does not
1491541Srgrimes    # always properly detect -ltinfo
1501541Srgrimes    LLVM_LIBS="${LLVM_LIBS} -ltinfo"
1511541Srgrimes
1521541Srgrimes    AC_SUBST(LLVM_CFLAGS)
1531541Srgrimes    AC_SUBST(LLVM_LDFLAGS)
1541541Srgrimes    AC_SUBST(LLVM_LIBS)
1551541Srgrimes  fi
1561541Srgrimes])
1571541Srgrimes
1581541Srgrimes################################################################################
1591541Srgrimes# Setup various libraries, typically small system libraries
1601541Srgrimes################################################################################
1611541SrgrimesAC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
1621541Srgrimes[
1631541Srgrimes  # Setup libm (the maths library)
1641541Srgrimes  if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
1651541Srgrimes    AC_CHECK_LIB(m, cos, [], [
1661541Srgrimes        AC_MSG_NOTICE([Maths library was not found])
1671541Srgrimes    ])
1681541Srgrimes    LIBM="-lm"
1691541Srgrimes  else
1701541Srgrimes    LIBM=""
1711541Srgrimes  fi
1721541Srgrimes  AC_SUBST(LIBM)
1731541Srgrimes
1741541Srgrimes  # Setup libdl (for dynamic library loading)
1751541Srgrimes  save_LIBS="$LIBS"
1761541Srgrimes  LIBS=""
1771541Srgrimes  AC_CHECK_LIB(dl, dlopen)
1781541Srgrimes  LIBDL="$LIBS"
1791541Srgrimes  AC_SUBST(LIBDL)
1801541Srgrimes  LIBS="$save_LIBS"
1811541Srgrimes
1821541Srgrimes  # Deprecated libraries, keep the flags for backwards compatibility
1831541Srgrimes  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
1841541Srgrimes    BASIC_DEPRECATED_ARG_WITH([dxsdk])
1851541Srgrimes    BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
1861541Srgrimes    BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
1871541Srgrimes  fi
1881541Srgrimes
1891541Srgrimes  # Control if libzip can use mmap. Available for purposes of overriding.
1901541Srgrimes  LIBZIP_CAN_USE_MMAP=true
1911541Srgrimes  AC_SUBST(LIBZIP_CAN_USE_MMAP)
1921541Srgrimes])
1931541Srgrimes
1941541Srgrimes################################################################################
1952112Swollman# libstlport.so.1 is needed for running gtest on Solaris. Find it to
1961541Srgrimes# redistribute it in the test image.
1971541Srgrimes################################################################################
1981541SrgrimesAC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
1991541Srgrimes[
2001541Srgrimes  if test "$OPENJDK_TARGET_OS" = "solaris"; then
2011541Srgrimes    # Find the root of the Solaris Studio installation from the compiler path
2021541Srgrimes    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
2031541Srgrimes    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
2041541Srgrimes    AC_MSG_CHECKING([for libstlport.so.1])
2051541Srgrimes    if test -f "$STLPORT_LIB"; then
2061541Srgrimes      AC_MSG_RESULT([yes, $STLPORT_LIB])
2071541Srgrimes      BASIC_FIXUP_PATH([STLPORT_LIB])
2081541Srgrimes    else
2091541Srgrimes      AC_MSG_RESULT([no, not found at $STLPORT_LIB])
2101541Srgrimes      AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
2111541Srgrimes    fi
2122165Spaul    AC_SUBST(STLPORT_LIB)
2132165Spaul  fi
214])
215
216