libraries.m4 revision 2400:5068c84c0844
186228Stmm#
286228Stmm# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
386228Stmm# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
486228Stmm#
586228Stmm# This code is free software; you can redistribute it and/or modify it
686228Stmm# under the terms of the GNU General Public License version 2 only, as
786228Stmm# published by the Free Software Foundation.  Oracle designates this
886228Stmm# particular file as subject to the "Classpath" exception as provided
986228Stmm# by Oracle in the LICENSE file that accompanied this code.
1086228Stmm#
1186228Stmm# This code is distributed in the hope that it will be useful, but WITHOUT
1286228Stmm# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1386228Stmm# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1486228Stmm# version 2 for more details (a copy is included in the LICENSE file that
1586228Stmm# accompanied this code).
1686228Stmm#
1786228Stmm# You should have received a copy of the GNU General Public License version
1886228Stmm# 2 along with this work; if not, write to the Free Software Foundation,
1986228Stmm# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2086228Stmm#
2186228Stmm# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2286228Stmm# or visit www.oracle.com if you need additional information or have any
2386228Stmm# questions.
2486228Stmm#
2586228Stmm
2686228Stmm# Major library component reside in separate files.
2786228Stmmm4_include([lib-alsa.m4])
2886228Stmmm4_include([lib-bundled.m4])
2986228Stmmm4_include([lib-cups.m4])
30139825Simpm4_include([lib-ffi.m4])
3186228Stmmm4_include([lib-freetype.m4])
3286228Stmmm4_include([lib-std.m4])
3386228Stmmm4_include([lib-x11.m4])
3486228Stmmm4_include([lib-elf.m4])
3586228Stmm
3686228Stmm################################################################################
3786228Stmm# Determine which libraries are needed for this configuration
3886228Stmm################################################################################
3986228StmmAC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
4086228Stmm[
4186228Stmm  # Check if X11 is needed
4286228Stmm  if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
4386228Stmm    # No X11 support on windows or macosx
4486228Stmm    NEEDS_LIB_X11=false
4586228Stmm  else
4686228Stmm    # All other instances need X11, even if building headless only, libawt still
4786228Stmm    # needs X11 headers.
4886228Stmm    NEEDS_LIB_X11=true
4986228Stmm  fi
5086228Stmm
5186228Stmm  # Check if cups is needed
5286228Stmm  if test "x$OPENJDK_TARGET_OS" = xwindows; then
5386228Stmm    # Windows have a separate print system
5486228Stmm    NEEDS_LIB_CUPS=false
5586228Stmm  else
5686228Stmm    NEEDS_LIB_CUPS=true
5786228Stmm  fi
5886228Stmm
5986228Stmm  # A custom hook may have set this already
6086228Stmm  if test "x$NEEDS_LIB_FREETYPE" = "x"; then
6186228Stmm    NEEDS_LIB_FREETYPE=true
62139825Simp  fi
6386228Stmm
6486228Stmm  # Check if alsa is needed
6586228Stmm  if test "x$OPENJDK_TARGET_OS" = xlinux; then
6686228Stmm    NEEDS_LIB_ALSA=true
6786228Stmm  else
6886228Stmm    NEEDS_LIB_ALSA=false
6986228Stmm  fi
7086228Stmm
7186228Stmm  # Check if ffi is needed
7286228Stmm  if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
7386228Stmm    NEEDS_LIB_FFI=true
7486228Stmm  else
7586228Stmm    NEEDS_LIB_FFI=false
7686228Stmm  fi
7786228Stmm])
7886228Stmm
7986228Stmm################################################################################
8086228Stmm# Parse library options, and setup needed libraries
8186228Stmm################################################################################
8286228StmmAC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
8386228Stmm[
8486228Stmm  LIB_SETUP_STD_LIBS
8586228Stmm  LIB_SETUP_X11
8686228Stmm  LIB_SETUP_CUPS
8786228Stmm  LIB_SETUP_FREETYPE
8886228Stmm  LIB_SETUP_ALSA
89219567Smarius  LIB_SETUP_LIBFFI
9086228Stmm  LIB_SETUP_LLVM
91177565Smarius  LIB_SETUP_BUNDLED_LIBS
9286228Stmm  LIB_SETUP_MISC_LIBS
9386228Stmm  LIB_SETUP_SOLARIS_STLPORT
94166096Smarius  LIB_SETUP_LIBELF
95166096Smarius])
96166096Smarius
9786228Stmm################################################################################
9886228Stmm# Setup llvm (Low-Level VM)
99112227Sjake################################################################################
10086228StmmAC_DEFUN_ONCE([LIB_SETUP_LLVM],
101112215Smux[
10286228Stmm  if HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
103225931Smarius    AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
10491783Sjake
10586228Stmm    if test "x$LLVM_CONFIG" != xllvm-config; then
10686228Stmm      AC_MSG_ERROR([llvm-config not found in $PATH.])
10786228Stmm    fi
10886228Stmm
10986228Stmm    llvm_components="jit mcjit engine nativecodegen native"
11086228Stmm    unset LLVM_CFLAGS
11186228Stmm    for flag in $("$LLVM_CONFIG" --cxxflags); do
112104486Ssam      if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
11386228Stmm        if test "${flag}" != "-D_DEBUG" ; then
11486228Stmm          if test "${LLVM_CFLAGS}" != "" ; then
115112436Smux            LLVM_CFLAGS="${LLVM_CFLAGS} "
11686228Stmm          fi
11793070Stmm          LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
11886228Stmm        fi
11991783Sjake      fi
12091177Sjake    done
12186228Stmm    llvm_version=$("${LLVM_CONFIG}" --version | $SED 's/\.//; s/svn.*//')
122119398Smarcel    LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
123119398Smarcel
124119398Smarcel    unset LLVM_LDFLAGS
125177565Smarius    for flag in $("${LLVM_CONFIG}" --ldflags); do
126177565Smarius      if echo "${flag}" | grep -q '^-L'; then
127166096Smarius        if test "${LLVM_LDFLAGS}" != ""; then
128166096Smarius          LLVM_LDFLAGS="${LLVM_LDFLAGS} "
12986228Stmm        fi
13086228Stmm        LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
13186228Stmm      fi
13286228Stmm    done
13386228Stmm
13486228Stmm    unset LLVM_LIBS
135177565Smarius    for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
136166096Smarius      if echo "${flag}" | grep -q '^-l'; then
137166096Smarius        if test "${LLVM_LIBS}" != ""; then
13886228Stmm          LLVM_LIBS="${LLVM_LIBS} "
13986228Stmm        fi
14086228Stmm        LLVM_LIBS="${LLVM_LIBS}${flag}"
14186228Stmm      fi
14286228Stmm    done
14386228Stmm
14486228Stmm    # Due to https://llvm.org/bugs/show_bug.cgi?id=16902, llvm does not
145117126Sscottl    # always properly detect -ltinfo
146117126Sscottl    LLVM_LIBS="${LLVM_LIBS} -ltinfo"
147117126Sscottl
148117126Sscottl    AC_SUBST(LLVM_CFLAGS)
149117126Sscottl    AC_SUBST(LLVM_LDFLAGS)
150117126Sscottl    AC_SUBST(LLVM_LIBS)
151117126Sscottl  fi
152117126Sscottl])
153117126Sscottl
154117126Sscottl################################################################################
155117126Sscottl# Setup various libraries, typically small system libraries
156117126Sscottl################################################################################
157117126SscottlAC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
158117126Sscottl[
159117126Sscottl  # Setup libm (the maths library)
160117126Sscottl  if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
161117126Sscottl    AC_CHECK_LIB(m, cos, [], [
162117126Sscottl        AC_MSG_NOTICE([Maths library was not found])
163117126Sscottl    ])
164117126Sscottl    LIBM="-lm"
165117126Sscottl  else
166117126Sscottl    LIBM=""
167117126Sscottl  fi
168117126Sscottl  AC_SUBST(LIBM)
169117126Sscottl
170117126Sscottl  # Setup libdl (for dynamic library loading)
171117126Sscottl  save_LIBS="$LIBS"
172117126Sscottl  LIBS=""
173117126Sscottl  AC_CHECK_LIB(dl, dlopen)
174117126Sscottl  LIBDL="$LIBS"
175117126Sscottl  AC_SUBST(LIBDL)
176117126Sscottl  LIBS="$save_LIBS"
177212676Smarius
178117126Sscottl  # Deprecated libraries, keep the flags for backwards compatibility
179117126Sscottl  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
180117126Sscottl    BASIC_DEPRECATED_ARG_WITH([dxsdk])
181117126Sscottl    BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
18286228Stmm    BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
18386228Stmm  fi
18486228Stmm
18586228Stmm  # Control if libzip can use mmap. Available for purposes of overriding.
186232356Sjhb  LIBZIP_CAN_USE_MMAP=true
18786228Stmm  AC_SUBST(LIBZIP_CAN_USE_MMAP)
188117126Sscottl])
189117126Sscottl
19086228Stmm################################################################################
19193070Stmm# libstlport.so.1 is needed for running gtest on Solaris. Find it to
19286228Stmm# redistribute it in the test image.
19386228Stmm################################################################################
19486228StmmAC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
19586228Stmm[
196167308Smarius  if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
197167308Smarius    # Find the root of the Solaris Studio installation from the compiler path
198167308Smarius    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
199167308Smarius    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
20086228Stmm    AC_MSG_CHECKING([for libstlport.so.1])
20186228Stmm    if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
20286228Stmm      # SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
20386228Stmm      STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
204116541Stmm    fi
205116541Stmm    if test -f "$STLPORT_LIB"; then
206167308Smarius      AC_MSG_RESULT([yes, $STLPORT_LIB])
207116541Stmm      BASIC_FIXUP_PATH([STLPORT_LIB])
208167308Smarius    else
209167308Smarius      AC_MSG_RESULT([no, not found at $STLPORT_LIB])
210116541Stmm      AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
211116541Stmm    fi
212108815Stmm    AC_SUBST(STLPORT_LIB)
213108815Stmm  fi
214108815Stmm])
215108815Stmm
216108815Stmm