1 # 2 # Copyright (c) 2011, 2015, 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. Default is to use these libraries as bundled, but they 31 # might be replaced by en external version by the user. 32 ################################################################################ 33 AC_DEFUN_ONCE([LIB_SETUP_BUNDLED_LIBS], 34 [ 35 LIB_SETUP_LIBJPEG 36 LIB_SETUP_GIFLIB 37 LIB_SETUP_LIBPNG 38 LIB_SETUP_ZLIB 39 LIB_SETUP_LCMS 40 ]) 41 42 ################################################################################ 43 # Setup libjpeg 44 ################################################################################ 45 AC_DEFUN_ONCE([LIB_SETUP_LIBJPEG], 46 [ 47 AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg], 48 [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 49 50 AC_MSG_CHECKING([for which libjpeg to use]) 51 # default is bundled 52 DEFAULT_LIBJPEG=bundled 53 # if user didn't specify, use DEFAULT_LIBJPEG 54 if test "x${with_libjpeg}" = "x"; then 55 with_libjpeg=${DEFAULT_LIBJPEG} 56 fi 57 AC_MSG_RESULT(${with_libjpeg}) 58 59 if test "x${with_libjpeg}" = "xbundled"; then 60 USE_EXTERNAL_LIBJPEG=false 61 elif test "x${with_libjpeg}" = "xsystem"; then 62 AC_CHECK_HEADER(jpeglib.h, [], 63 [ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])]) 64 AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [], 65 [ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])]) 66 67 USE_EXTERNAL_LIBJPEG=true 68 else 69 AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled']) 70 fi 71 72 AC_SUBST(USE_EXTERNAL_LIBJPEG) 73 ]) 74 75 ################################################################################ 76 # Setup giflib 77 ################################################################################ 78 AC_DEFUN_ONCE([LIB_SETUP_GIFLIB], 79 [ 80 AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib], 81 [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 82 83 AC_MSG_CHECKING([for which giflib to use]) 84 # default is bundled 85 DEFAULT_GIFLIB=bundled 86 # if user didn't specify, use DEFAULT_GIFLIB 87 if test "x${with_giflib}" = "x"; then 88 with_giflib=${DEFAULT_GIFLIB} 89 fi 90 AC_MSG_RESULT(${with_giflib}) 91 92 if test "x${with_giflib}" = "xbundled"; then 93 USE_EXTERNAL_LIBGIF=false 94 elif test "x${with_giflib}" = "xsystem"; then 95 AC_CHECK_HEADER(gif_lib.h, [], 96 [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])]) 97 AC_CHECK_LIB(gif, DGifGetCode, [], 98 [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])]) 99 100 USE_EXTERNAL_LIBGIF=true 101 else 102 AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled']) 103 fi 104 105 AC_SUBST(USE_EXTERNAL_LIBGIF) 106 ]) 107 108 ################################################################################ 109 # Setup libpng 110 ################################################################################ 111 AC_DEFUN_ONCE([LIB_SETUP_LIBPNG], 112 [ 113 AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng], 114 [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 115 116 AC_MSG_CHECKING([for which libpng to use]) 117 118 # default is bundled 119 DEFAULT_LIBPNG=bundled 120 # if user didn't specify, use DEFAULT_LIBPNG 121 if test "x${with_libpng}" = "x"; then 122 with_libpng=${DEFAULT_LIBPNG} 123 fi 124 125 if test "x${with_libpng}" = "xbundled"; then 126 USE_EXTERNAL_LIBPNG=false 127 AC_MSG_RESULT([bundled]) 128 elif test "x${with_libpng}" = "xsystem"; then 129 PKG_CHECK_MODULES(PNG, libpng, 130 [ LIBPNG_FOUND=yes ], 131 [ LIBPNG_FOUND=no ]) 132 if test "x${LIBPNG_FOUND}" = "xyes"; then 133 USE_EXTERNAL_LIBPNG=true 134 AC_MSG_RESULT([system]) 135 else 136 AC_MSG_RESULT([system not found]) 137 AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!]) 138 fi 139 else 140 AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled']) 141 fi 142 143 AC_SUBST(USE_EXTERNAL_LIBPNG) 144 ]) 145 146 ################################################################################ 147 # Setup zlib 148 ################################################################################ 149 AC_DEFUN_ONCE([LIB_SETUP_ZLIB], 150 [ 151 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib], 152 [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 153 154 AC_CHECK_LIB(z, compress, 155 [ ZLIB_FOUND=yes ], 156 [ ZLIB_FOUND=no ]) 157 158 AC_MSG_CHECKING([for which zlib to use]) 159 160 DEFAULT_ZLIB=bundled 161 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 162 # On macosx default is system...on others default is bundled 163 DEFAULT_ZLIB=system 164 fi 165 166 if test "x${ZLIB_FOUND}" != "xyes"; then 167 # If we don't find any system...set default to bundled 168 DEFAULT_ZLIB=bundled 169 fi 170 171 # If user didn't specify, use DEFAULT_ZLIB 172 if test "x${with_zlib}" = "x"; then 173 with_zlib=${DEFAULT_ZLIB} 174 fi 175 176 if test "x${with_zlib}" = "xbundled"; then 177 USE_EXTERNAL_LIBZ=false 178 AC_MSG_RESULT([bundled]) 179 elif test "x${with_zlib}" = "xsystem"; then 180 if test "x${ZLIB_FOUND}" = "xyes"; then 181 USE_EXTERNAL_LIBZ=true 182 AC_MSG_RESULT([system]) 183 else 184 AC_MSG_RESULT([system not found]) 185 AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!]) 186 fi 187 else 188 AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled']) 189 fi 190 191 AC_SUBST(USE_EXTERNAL_LIBZ) 192 ]) 193 194 ################################################################################ 195 # Setup lcms (Little CMS) 196 ################################################################################ 197 AC_DEFUN_ONCE([LIB_SETUP_LCMS], 198 [ 199 AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms], 200 [use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 201 202 AC_MSG_CHECKING([for which lcms to use]) 203 204 DEFAULT_LCMS=bundled 205 # If user didn't specify, use DEFAULT_LCMS 206 if test "x${with_lcms}" = "x"; then 207 with_lcms=${DEFAULT_LCMS} 208 fi 209 210 if test "x${with_lcms}" = "xbundled"; then 211 USE_EXTERNAL_LCMS=false 212 AC_MSG_RESULT([bundled]) 213 elif test "x${with_lcms}" = "xsystem"; then 214 AC_MSG_RESULT([system]) 215 PKG_CHECK_MODULES([LCMS], [lcms2], [LCMS_FOUND=yes], [LCMS_FOUND=no]) 216 if test "x${LCMS_FOUND}" = "xyes"; then 217 USE_EXTERNAL_LCMS=true 218 else 219 AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!]) 220 fi 221 else 222 AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled']) 223 fi 224 225 AC_SUBST(USE_EXTERNAL_LCMS) 226 ])