1 #
  2 # Copyright (c) 2011, 2022, 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-fontconfig.m4])
 32 m4_include([lib-freetype.m4])
 33 m4_include([lib-hsdis.m4])
 34 m4_include([lib-std.m4])
 35 m4_include([lib-x11.m4])
 36 
 37 m4_include([lib-tests.m4])
 38 m4_include([lib-clang.m4])
 39 
 40 ################################################################################
 41 # Determine which libraries are needed for this configuration
 42 ################################################################################
 43 AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
 44 [
 45   # Check if X11 is needed
 46   if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
 47     # No X11 support on windows or macosx
 48     NEEDS_LIB_X11=false
 49   else
 50     # All other instances need X11, even if building headless only, libawt still
 51     # needs X11 headers.
 52     NEEDS_LIB_X11=true
 53   fi
 54 
 55   # Check if fontconfig is needed
 56   if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
 57     # No fontconfig support on windows or macosx
 58     NEEDS_LIB_FONTCONFIG=false
 59   else
 60     # All other instances need fontconfig, even if building headless only,
 61     # libawt still needs fontconfig headers.
 62     NEEDS_LIB_FONTCONFIG=true
 63   fi
 64 
 65   # Check if cups is needed
 66   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 67     # Windows have a separate print system
 68     NEEDS_LIB_CUPS=false
 69   else
 70     NEEDS_LIB_CUPS=true
 71   fi
 72 
 73   # A custom hook may have set this already
 74   if test "x$NEEDS_LIB_FREETYPE" = "x"; then
 75     NEEDS_LIB_FREETYPE=true
 76   fi
 77 
 78   # Check if alsa is needed
 79   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 80     NEEDS_LIB_ALSA=true
 81   else
 82     NEEDS_LIB_ALSA=false
 83   fi
 84 
 85   # Check if ffi is needed
 86   if HOTSPOT_CHECK_JVM_VARIANT(zero); then
 87     NEEDS_LIB_FFI=true
 88   else
 89     NEEDS_LIB_FFI=false
 90   fi
 91 ])
 92 
 93 ################################################################################
 94 # Parse library options, and setup needed libraries
 95 ################################################################################
 96 AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
 97 [
 98   LIB_SETUP_STD_LIBS
 99 
100   LIB_SETUP_ALSA
101   LIB_SETUP_BUNDLED_LIBS
102   LIB_SETUP_CUPS
103   LIB_SETUP_FONTCONFIG
104   LIB_SETUP_FREETYPE
105   LIB_SETUP_HSDIS
106   LIB_SETUP_LIBFFI
107   LIB_SETUP_MISC_LIBS
108   LIB_SETUP_X11
109 
110   LIB_TESTS_SETUP_GTEST
111   LIB_SETUP_LIBCLANG
112 
113   BASIC_JDKLIB_LIBS=""
114   if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
115     BASIC_JDKLIB_LIBS="-ljava -ljvm"
116   fi
117 
118   # Math library
119   BASIC_JVM_LIBS="$LIBM"
120 
121   # Dynamic loading library
122   if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
123     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBDL"
124   fi
125 
126   # Threading library
127   if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
128     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lpthread"
129   fi
130 
131   # librt for legacy clock_gettime
132   if test "x$OPENJDK_TARGET_OS" = xlinux; then
133     # Hotspot needs to link librt to get the clock_* functions.
134     # But once our supported minimum build and runtime platform
135     # has glibc 2.17, this can be removed as the functions are
136     # in libc.
137     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lrt"
138   fi
139 
140   # Atomic library
141   # 32-bit platforms needs fallback library for 8-byte atomic ops on Zero
142   if HOTSPOT_CHECK_JVM_VARIANT(zero); then
143     if test "x$OPENJDK_TARGET_OS" = xlinux &&
144         (test "x$OPENJDK_TARGET_CPU" = xarm ||
145          test "x$OPENJDK_TARGET_CPU" = xm68k ||
146          test "x$OPENJDK_TARGET_CPU" = xmips ||
147          test "x$OPENJDK_TARGET_CPU" = xmipsel ||
148          test "x$OPENJDK_TARGET_CPU" = xppc ||
149          test "x$OPENJDK_TARGET_CPU" = xsh ||
150          test "x$OPENJDK_TARGET_CPU" = xriscv32); then
151       BASIC_JVM_LIBS="$BASIC_JVM_LIBS -latomic"
152     fi
153   fi
154 
155   # Because RISC-V only has word-sized atomics, it requires libatomic where
156   # other common architectures do not.  So link libatomic by default.
157   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xriscv64; then
158     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -latomic"
159   fi
160 
161   # perfstat lib
162   if test "x$OPENJDK_TARGET_OS" = xaix; then
163     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat"
164   fi
165 
166   if test "x$OPENJDK_TARGET_OS" = xwindows; then
167     BASIC_JVM_LIBS="$BASIC_JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
168         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
169         wsock32.lib winmm.lib version.lib psapi.lib"
170   fi
171 
172   JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
173   JDKEXE_LIBS=""
174   JVM_LIBS="$BASIC_JVM_LIBS"
175   OPENJDK_BUILD_JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
176   OPENJDK_BUILD_JVM_LIBS="$BASIC_JVM_LIBS"
177 
178   AC_SUBST(JDKLIB_LIBS)
179   AC_SUBST(JDKEXE_LIBS)
180   AC_SUBST(JVM_LIBS)
181   AC_SUBST(OPENJDK_BUILD_JDKLIB_LIBS)
182   AC_SUBST(OPENJDK_BUILD_JVM_LIBS)
183 ])
184 
185 ################################################################################
186 # Setup various libraries, typically small system libraries
187 ################################################################################
188 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
189 [
190   # Setup libm (the maths library)
191   if test "x$OPENJDK_TARGET_OS" != "xwindows"; then
192     AC_CHECK_LIB(m, cos, [], [
193         AC_MSG_NOTICE([Maths library was not found])
194     ])
195     LIBM="-lm"
196   else
197     LIBM=""
198   fi
199   AC_SUBST(LIBM)
200 
201   # Setup libdl (for dynamic library loading)
202   save_LIBS="$LIBS"
203   LIBS=""
204   AC_CHECK_LIB(dl, dlopen)
205   LIBDL="$LIBS"
206   AC_SUBST(LIBDL)
207   LIBS="$save_LIBS"
208 
209   # Control if libzip can use mmap. Available for purposes of overriding.
210   LIBZIP_CAN_USE_MMAP=true
211   AC_SUBST(LIBZIP_CAN_USE_MMAP)
212 ])