1 #
   2 # Copyright (c) 2011, 2017, 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     PNG_CFLAGS=""
 128     PNG_LIBS=""
 129     AC_MSG_RESULT([bundled])
 130   elif test "x${with_libpng}" = "xsystem"; then
 131     PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
 132     if test "x${LIBPNG_FOUND}" = "xyes"; then
 133       # PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
 134       USE_EXTERNAL_LIBPNG=true
 135       AC_MSG_RESULT([system])
 136     else
 137       AC_MSG_RESULT([system not found])
 138       AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
 139     fi
 140   else
 141     AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
 142   fi
 143 
 144   AC_SUBST(USE_EXTERNAL_LIBPNG)
 145   AC_SUBST(PNG_CFLAGS)
 146   AC_SUBST(PNG_LIBS)
 147 ])
 148 
 149 ################################################################################
 150 # Setup zlib
 151 ################################################################################
 152 AC_DEFUN_ONCE([LIB_SETUP_ZLIB],
 153 [
 154   AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 155       [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 156 
 157   AC_CHECK_LIB(z, compress,
 158       [ ZLIB_FOUND=yes ],
 159       [ ZLIB_FOUND=no ])
 160 
 161   AC_MSG_CHECKING([for which zlib to use])
 162 
 163   DEFAULT_ZLIB=system
 164   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 165     # On windows default is bundled...on others default is system
 166     DEFAULT_ZLIB=bundled
 167   fi
 168 
 169   if test "x${ZLIB_FOUND}" != "xyes"; then
 170     # If we don't find any system...set default to bundled
 171     DEFAULT_ZLIB=bundled
 172   fi
 173 
 174   # If user didn't specify, use DEFAULT_ZLIB
 175   if test "x${with_zlib}" = "x"; then
 176     with_zlib=${DEFAULT_ZLIB}
 177   fi
 178 
 179   if test "x${with_zlib}" = "xbundled"; then
 180     USE_EXTERNAL_LIBZ=false
 181     AC_MSG_RESULT([bundled])
 182   elif test "x${with_zlib}" = "xsystem"; then
 183     if test "x${ZLIB_FOUND}" = "xyes"; then
 184       USE_EXTERNAL_LIBZ=true
 185       AC_MSG_RESULT([system])
 186     else
 187       AC_MSG_RESULT([system not found])
 188       AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
 189     fi
 190   else
 191     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
 192   fi
 193 
 194   AC_SUBST(USE_EXTERNAL_LIBZ)
 195 ])
 196 
 197 ################################################################################
 198 # Setup lcms (Little CMS)
 199 ################################################################################
 200 AC_DEFUN_ONCE([LIB_SETUP_LCMS],
 201 [
 202   AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms],
 203       [use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 204 
 205   AC_MSG_CHECKING([for which lcms to use])
 206 
 207   DEFAULT_LCMS=bundled
 208   # If user didn't specify, use DEFAULT_LCMS
 209   if test "x${with_lcms}" = "x"; then
 210     with_lcms=${DEFAULT_LCMS}
 211   fi
 212 
 213   if test "x${with_lcms}" = "xbundled"; then
 214     USE_EXTERNAL_LCMS=false
 215     LCMS_CFLAGS=""
 216     LCMS_LIBS=""
 217     AC_MSG_RESULT([bundled])
 218   elif test "x${with_lcms}" = "xsystem"; then
 219     AC_MSG_RESULT([system])
 220     PKG_CHECK_MODULES([LCMS], [lcms2], [LCMS_FOUND=yes], [LCMS_FOUND=no])
 221     if test "x${LCMS_FOUND}" = "xyes"; then
 222       # PKG_CHECK_MODULES will set LCMS_CFLAGS and LCMS_LIBS
 223       USE_EXTERNAL_LCMS=true
 224     else
 225       AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!])
 226     fi
 227   else
 228     AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled'])
 229   fi
 230 
 231   AC_SUBST(USE_EXTERNAL_LCMS)
 232   AC_SUBST(LCMS_CFLAGS)
 233   AC_SUBST(LCMS_LIBS)
 234 ])