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