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