1 # 2 # Copyright (c) 2011, 2019, 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 ################################################################################ 27 # Setup bundled libraries. 28 # 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") 34 # version by the user. 35 ################################################################################ 36 AC_DEFUN_ONCE([LIB_SETUP_BUNDLED_LIBS], 37 [ 38 LIB_SETUP_LIBJPEG 39 LIB_SETUP_GIFLIB 40 LIB_SETUP_LIBPNG 41 LIB_SETUP_ZLIB 42 LIB_SETUP_LCMS 43 LIB_SETUP_HARFBUZZ 44 ]) 45 46 ################################################################################ 47 # Setup libjpeg 48 ################################################################################ 49 AC_DEFUN_ONCE([LIB_SETUP_LIBJPEG], 50 [ 51 AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg], 52 [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 53 54 AC_MSG_CHECKING([for which libjpeg to use]) 55 # default is bundled 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} 60 fi 61 AC_MSG_RESULT(${with_libjpeg}) 62 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])]) 70 71 USE_EXTERNAL_LIBJPEG=true 72 else 73 AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled']) 74 fi 75 76 AC_SUBST(USE_EXTERNAL_LIBJPEG) 77 ]) 78 79 ################################################################################ 80 # Setup giflib 81 ################################################################################ 82 AC_DEFUN_ONCE([LIB_SETUP_GIFLIB], 83 [ 84 AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib], 85 [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 86 87 AC_MSG_CHECKING([for which giflib to use]) 88 # default is bundled 89 DEFAULT_GIFLIB=bundled 90 # if user didn't specify, use DEFAULT_GIFLIB 91 if test "x${with_giflib}" = "x"; then 92 with_giflib=${DEFAULT_GIFLIB} 93 fi 94 AC_MSG_RESULT(${with_giflib}) 95 96 if test "x${with_giflib}" = "xbundled"; then 97 USE_EXTERNAL_LIBGIF=false 98 elif test "x${with_giflib}" = "xsystem"; then 99 AC_CHECK_HEADER(gif_lib.h, [], 100 [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])]) 101 AC_CHECK_LIB(gif, DGifGetCode, [], 102 [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])]) 103 104 USE_EXTERNAL_LIBGIF=true 105 else 106 AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled']) 107 fi 108 109 AC_SUBST(USE_EXTERNAL_LIBGIF) 110 ]) 111 112 ################################################################################ 113 # Setup libpng 114 ################################################################################ 115 AC_DEFUN_ONCE([LIB_SETUP_LIBPNG], 116 [ 117 AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng], 118 [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 119 120 PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no]) 121 AC_MSG_CHECKING([for which libpng to use]) 122 123 # default is bundled 124 DEFAULT_LIBPNG=bundled 125 # if user didn't specify, use DEFAULT_LIBPNG 126 if test "x${with_libpng}" = "x"; then 127 with_libpng=${DEFAULT_LIBPNG} 128 fi 129 130 if test "x${with_libpng}" = "xbundled"; then 131 USE_EXTERNAL_LIBPNG=false 132 PNG_CFLAGS="" 133 PNG_LIBS="" 134 AC_MSG_RESULT([bundled]) 135 elif test "x${with_libpng}" = "xsystem"; then 136 if test "x${LIBPNG_FOUND}" = "xyes"; then 137 # PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS 138 USE_EXTERNAL_LIBPNG=true 139 AC_MSG_RESULT([system]) 140 else 141 AC_MSG_RESULT([system not found]) 142 AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!]) 143 fi 144 else 145 AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled']) 146 fi 147 148 AC_SUBST(USE_EXTERNAL_LIBPNG) 149 AC_SUBST(PNG_CFLAGS) 150 AC_SUBST(PNG_LIBS) 151 ]) 152 153 ################################################################################ 154 # Setup zlib 155 ################################################################################ 156 AC_DEFUN_ONCE([LIB_SETUP_ZLIB], 157 [ 158 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib], 159 [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 160 161 AC_CHECK_LIB(z, compress, 162 [ ZLIB_FOUND=yes ], 163 [ ZLIB_FOUND=no ]) 164 165 AC_MSG_CHECKING([for which zlib to use]) 166 167 DEFAULT_ZLIB=system 168 if test "x$OPENJDK_TARGET_OS" = xwindows -o "x$OPENJDK_TARGET_OS" = xaix; then 169 # On windows and aix default is bundled, on others default is system 170 DEFAULT_ZLIB=bundled 171 fi 172 173 if test "x${ZLIB_FOUND}" != "xyes"; then 174 # If we don't find any system...set default to bundled 175 DEFAULT_ZLIB=bundled 176 fi 177 178 # If user didn't specify, use DEFAULT_ZLIB 179 if test "x${with_zlib}" = "x"; then 180 with_zlib=${DEFAULT_ZLIB} 181 fi 182 183 if test "x${with_zlib}" = "xbundled"; then 184 USE_EXTERNAL_LIBZ=false 185 AC_MSG_RESULT([bundled]) 186 elif test "x${with_zlib}" = "xsystem"; then 187 if test "x${ZLIB_FOUND}" = "xyes"; then 188 USE_EXTERNAL_LIBZ=true 189 AC_MSG_RESULT([system]) 190 191 if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then 192 # If we use bundled libpng, we must verify that we have a proper zlib. 193 # For instance zlib-ng has had issues with inflateValidate(). 194 AC_MSG_CHECKING([for system zlib functionality]) 195 AC_COMPILE_IFELSE( 196 [AC_LANG_PROGRAM([#include "zlib.h"], [ 197 #if ZLIB_VERNUM >= 0x1281 198 inflateValidate(NULL, 0); 199 #endif 200 ])], 201 [AC_MSG_RESULT([ok])], 202 [ 203 AC_MSG_RESULT([not ok]) 204 AC_MSG_ERROR([System zlib not working correctly]) 205 ] 206 ) 207 fi 208 else 209 AC_MSG_RESULT([system not found]) 210 AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!]) 211 fi 212 else 213 AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled']) 214 fi 215 216 LIBZ_CFLAGS="" 217 LIBZ_LIBS="" 218 if test "x$USE_EXTERNAL_LIBZ" = "xfalse"; then 219 LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" 220 else 221 LIBZ_LIBS="-lz" 222 fi 223 224 AC_SUBST(USE_EXTERNAL_LIBZ) 225 AC_SUBST(LIBZ_CFLAGS) 226 AC_SUBST(LIBZ_LIBS) 227 ]) 228 229 ################################################################################ 230 # Setup lcms (Little CMS) 231 ################################################################################ 232 AC_DEFUN_ONCE([LIB_SETUP_LCMS], 233 [ 234 AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms], 235 [use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 236 237 AC_MSG_CHECKING([for which lcms to use]) 238 239 DEFAULT_LCMS=bundled 240 # If user didn't specify, use DEFAULT_LCMS 241 if test "x${with_lcms}" = "x"; then 242 with_lcms=${DEFAULT_LCMS} 243 fi 244 245 if test "x${with_lcms}" = "xbundled"; then 246 USE_EXTERNAL_LCMS=false 247 LCMS_CFLAGS="" 248 LCMS_LIBS="" 249 AC_MSG_RESULT([bundled]) 250 elif test "x${with_lcms}" = "xsystem"; then 251 AC_MSG_RESULT([system]) 252 PKG_CHECK_MODULES([LCMS], [lcms2], [LCMS_FOUND=yes], [LCMS_FOUND=no]) 253 if test "x${LCMS_FOUND}" = "xyes"; then 254 # PKG_CHECK_MODULES will set LCMS_CFLAGS and LCMS_LIBS 255 USE_EXTERNAL_LCMS=true 256 else 257 AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!]) 258 fi 259 else 260 AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled']) 261 fi 262 263 AC_SUBST(USE_EXTERNAL_LCMS) 264 AC_SUBST(LCMS_CFLAGS) 265 AC_SUBST(LCMS_LIBS) 266 ]) 267 268 ################################################################################ 269 # Setup harfbuzz 270 ################################################################################ 271 AC_DEFUN_ONCE([LIB_SETUP_HARFBUZZ], 272 [ 273 AC_ARG_WITH(harfbuzz, [AS_HELP_STRING([--with-harfbuzz], 274 [use harfbuzz from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 275 276 AC_MSG_CHECKING([for which harfbuzz to use]) 277 278 DEFAULT_HARFBUZZ=bundled 279 # If user didn't specify, use DEFAULT_HARFBUZZ 280 if test "x${with_harfbuzz}" = "x"; then 281 with_harfbuzz=${DEFAULT_HARFBUZZ} 282 fi 283 284 if test "x${with_harfbuzz}" = "xbundled"; then 285 USE_EXTERNAL_HARFBUZZ=false 286 HARFBUZZ_CFLAGS="" 287 HARFBUZZ_LIBS="" 288 AC_MSG_RESULT([bundled]) 289 elif test "x${with_harfbuzz}" = "xsystem"; then 290 AC_MSG_RESULT([system]) 291 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz], [HARFBUZZ_FOUND=yes], [HARFBUZZ_FOUND=no]) 292 if test "x${HARFBUZZ_FOUND}" = "xyes"; then 293 # PKG_CHECK_MODULES will set HARFBUZZ_CFLAGS and HARFBUZZ_LIBS 294 USE_EXTERNAL_HARFBUZZ=true 295 else 296 HELP_MSG_MISSING_DEPENDENCY([harfbuzz]) 297 AC_MSG_ERROR([--with-harfbuzz=system specified, but no harfbuzz found! $HELP_MSG]) 298 fi 299 else 300 AC_MSG_ERROR([Invalid value for --with-harfbuzz: ${with_harfbuzz}, use 'system' or 'bundled']) 301 fi 302 303 AC_SUBST(USE_EXTERNAL_HARFBUZZ) 304 AC_SUBST(HARFBUZZ_CFLAGS) 305 AC_SUBST(HARFBUZZ_LIBS) 306 ])