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.
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.
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).
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.
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
26
################################################################################
27
# Setup bundled libraries.
29
# For libjpeg, giflib, libpng, lcms2 and zlib the source is present in the
30
# OpenJDK repository (referred to as "bundled"). Default is to use libjpeg,
31
# giflib, libpng and lcms2 libraries as "bundled". The default for zlib is
32
# to use the bundled zlib on Windows and AIX, otherwise the external ("system")
33
# zlib, if present. However the libs may be replaced by an external ("system")
35
################################################################################
36
AC_DEFUN_ONCE([LIB_SETUP_BUNDLED_LIBS],
46
################################################################################
48
################################################################################
49
AC_DEFUN_ONCE([LIB_SETUP_LIBJPEG],
51
AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg],
52
[use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
54
AC_MSG_CHECKING([for which libjpeg to use])
56
DEFAULT_LIBJPEG=bundled
57
# if user didn't specify, use DEFAULT_LIBJPEG
58
if test "x${with_libjpeg}" = "x"; then
59
with_libjpeg=${DEFAULT_LIBJPEG}
61
AC_MSG_RESULT(${with_libjpeg})
63
if test "x${with_libjpeg}" = "xbundled"; then
64
USE_EXTERNAL_LIBJPEG=false
65
elif test "x${with_libjpeg}" = "xsystem"; then
66
AC_CHECK_HEADER(jpeglib.h, [],
67
[ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])])
68
AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [],
69
[ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])])
71
USE_EXTERNAL_LIBJPEG=true
74
AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled'])
77
AC_SUBST(USE_EXTERNAL_LIBJPEG)
78
AC_SUBST(LIBJPEG_LIBS)
81
################################################################################
83
################################################################################
84
AC_DEFUN_ONCE([LIB_SETUP_GIFLIB],
86
AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
87
[use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
89
AC_MSG_CHECKING([for which giflib to use])
91
DEFAULT_GIFLIB=bundled
92
# if user didn't specify, use DEFAULT_GIFLIB
93
if test "x${with_giflib}" = "x"; then
94
with_giflib=${DEFAULT_GIFLIB}
96
AC_MSG_RESULT(${with_giflib})
98
if test "x${with_giflib}" = "xbundled"; then
99
USE_EXTERNAL_LIBGIF=false
100
elif test "x${with_giflib}" = "xsystem"; then
101
AC_CHECK_HEADER(gif_lib.h, [],
102
[ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
103
AC_CHECK_LIB(gif, DGifGetCode, [],
104
[ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
106
USE_EXTERNAL_LIBGIF=true
109
AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
112
AC_SUBST(USE_EXTERNAL_LIBGIF)
113
AC_SUBST(GIFLIB_LIBS)
116
################################################################################
118
################################################################################
119
AC_DEFUN_ONCE([LIB_SETUP_LIBPNG],
121
AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
122
[use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
124
PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
125
AC_MSG_CHECKING([for which libpng to use])
128
DEFAULT_LIBPNG=bundled
129
# if user didn't specify, use DEFAULT_LIBPNG
130
if test "x${with_libpng}" = "x"; then
131
with_libpng=${DEFAULT_LIBPNG}
134
if test "x${with_libpng}" = "xbundled"; then
135
USE_EXTERNAL_LIBPNG=false
138
AC_MSG_RESULT([bundled])
139
elif test "x${with_libpng}" = "xsystem"; then
140
if test "x${LIBPNG_FOUND}" = "xyes"; then
141
# PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
142
USE_EXTERNAL_LIBPNG=true
143
AC_MSG_RESULT([system])
145
AC_MSG_RESULT([system not found])
146
AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
149
AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
152
AC_SUBST(USE_EXTERNAL_LIBPNG)
157
################################################################################
159
################################################################################
160
AC_DEFUN_ONCE([LIB_SETUP_ZLIB],
162
AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
163
[use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
165
AC_CHECK_LIB(z, compress,
169
AC_MSG_CHECKING([for which zlib to use])
172
if test "x$OPENJDK_TARGET_OS" = xwindows -o "x$OPENJDK_TARGET_OS" = xaix; then
173
# On windows and aix default is bundled
175
elif test "x$OPENJDK_TARGET_OS" = xmacosx -a "x$OPENJDK_TARGET_CPU" = xaarch64; then
179
if test "x${ZLIB_FOUND}" != "xyes"; then
180
# If we don't find any system...set default to bundled
184
# If user didn't specify, use DEFAULT_ZLIB
185
if test "x${with_zlib}" = "x"; then
186
with_zlib=${DEFAULT_ZLIB}
189
if test "x${with_zlib}" = "xbundled"; then
190
USE_EXTERNAL_LIBZ=false
191
AC_MSG_RESULT([bundled])
192
elif test "x${with_zlib}" = "xsystem"; then
193
if test "x${ZLIB_FOUND}" = "xyes"; then
194
USE_EXTERNAL_LIBZ=true
195
AC_MSG_RESULT([system])
197
if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then
198
# If we use bundled libpng, we must verify that we have a proper zlib.
199
# For instance zlib-ng has had issues with inflateValidate().
200
AC_MSG_CHECKING([for system zlib functionality])
202
[AC_LANG_PROGRAM([#include "zlib.h"], [
203
#if ZLIB_VERNUM >= 0x1281
204
inflateValidate(NULL, 0);
207
[AC_MSG_RESULT([ok])],
209
AC_MSG_RESULT([not ok])
210
AC_MSG_ERROR([System zlib not working correctly])
215
AC_MSG_RESULT([system not found])
216
AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
219
AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
224
if test "x$USE_EXTERNAL_LIBZ" = "xfalse"; then
225
LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib"
226
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
227
LIBZ_CFLAGS="$LIBZ_CFLAGS -DHAVE_UNISTD_H"
233
AC_SUBST(USE_EXTERNAL_LIBZ)
234
AC_SUBST(LIBZ_CFLAGS)
238
################################################################################
239
# Setup lcms (Little CMS)
240
################################################################################
241
AC_DEFUN_ONCE([LIB_SETUP_LCMS],
243
AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms],
244
[use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
246
AC_MSG_CHECKING([for which lcms to use])
249
# If user didn't specify, use DEFAULT_LCMS
250
if test "x${with_lcms}" = "x"; then
251
with_lcms=${DEFAULT_LCMS}
254
if test "x${with_lcms}" = "xbundled"; then
255
USE_EXTERNAL_LCMS=false
258
AC_MSG_RESULT([bundled])
259
elif test "x${with_lcms}" = "xsystem"; then
260
AC_MSG_RESULT([system])
261
PKG_CHECK_MODULES([LCMS], [lcms2], [LCMS_FOUND=yes], [LCMS_FOUND=no])
262
if test "x${LCMS_FOUND}" = "xyes"; then
263
# PKG_CHECK_MODULES will set LCMS_CFLAGS and LCMS_LIBS
264
USE_EXTERNAL_LCMS=true
266
AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!])
269
AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled'])
272
AC_SUBST(USE_EXTERNAL_LCMS)
273
AC_SUBST(LCMS_CFLAGS)
277
################################################################################
279
################################################################################
280
AC_DEFUN_ONCE([LIB_SETUP_HARFBUZZ],
282
AC_ARG_WITH(harfbuzz, [AS_HELP_STRING([--with-harfbuzz],
283
[use harfbuzz from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
285
AC_MSG_CHECKING([for which harfbuzz to use])
287
DEFAULT_HARFBUZZ=bundled
288
# If user didn't specify, use DEFAULT_HARFBUZZ
289
if test "x${with_harfbuzz}" = "x"; then
290
with_harfbuzz=${DEFAULT_HARFBUZZ}
293
if test "x${with_harfbuzz}" = "xbundled"; then
294
USE_EXTERNAL_HARFBUZZ=false
297
AC_MSG_RESULT([bundled])
298
elif test "x${with_harfbuzz}" = "xsystem"; then
299
AC_MSG_RESULT([system])
300
PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz], [HARFBUZZ_FOUND=yes], [HARFBUZZ_FOUND=no])
301
if test "x${HARFBUZZ_FOUND}" = "xyes"; then
302
# PKG_CHECK_MODULES will set HARFBUZZ_CFLAGS and HARFBUZZ_LIBS
303
USE_EXTERNAL_HARFBUZZ=true
305
HELP_MSG_MISSING_DEPENDENCY([harfbuzz])
306
AC_MSG_ERROR([--with-harfbuzz=system specified, but no harfbuzz found! $HELP_MSG])
309
AC_MSG_ERROR([Invalid value for --with-harfbuzz: ${with_harfbuzz}, use 'system' or 'bundled'])
312
AC_SUBST(USE_EXTERNAL_HARFBUZZ)
313
AC_SUBST(HARFBUZZ_CFLAGS)
314
AC_SUBST(HARFBUZZ_LIBS)