--- old/common/autoconf/libraries.m4 2014-05-20 12:39:15.136549562 -0400 +++ new/common/autoconf/libraries.m4 2014-05-20 12:39:14.994548641 -0400 @@ -620,11 +620,36 @@ # Check for the jpeg library # - USE_EXTERNAL_LIBJPEG=true - AC_CHECK_LIB(jpeg, main, [], - [ USE_EXTERNAL_LIBJPEG=false - AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source]) - ]) + AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg], + [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + + AC_MSG_CHECKING([for which libjpeg to use]) + + # default is bundled + DEFAULT_LIBJPEG=bundled + + # + # if user didn't specify, use DEFAULT_LIBJPEG + # + if test "x${with_libjpeg}" = "x"; then + with_libjpeg=${DEFAULT_LIBJPEG} + fi + + AC_MSG_RESULT(${with_libjpeg}) + + if test "x${with_libjpeg}" = "xbundled"; then + USE_EXTERNAL_LIBJPEG=false + elif test "x${with_libjpeg}" = "xsystem"; then + AC_CHECK_HEADER(jpeglib.h, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])]) + AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])]) + + USE_EXTERNAL_LIBJPEG=true + else + AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled']) + fi + AC_SUBST(USE_EXTERNAL_LIBJPEG) ###############################################################################