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