1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
# adhoc_libjpeg.m4 serial 1
dnl m4/adhoc_libjpeg.m4 -- M4 macro processor include script
dnl
dnl Copyright (C) 2015 Jerome Benoit <jgmbenoit@rezozer.net>
dnl
dnl Based on macros for the GNU GMP library by Owen Taylor, modified by:
dnl Hans Petter Jansson, 2001-04-09;
dnl Allin Cottrell, April 2003;
dnl and certainly others.
dnl
dnl Copying and distribution of this file, with or without modification, are
dnl permitted in any medium without royalty provided the copyright notice and
dnl this notice are preserved. This file is offered as-is, without any warranty.
dnl
dnl
dnl NOTE:
dnl The trick used to extract the library version number of the JPEG library
dnl itself was adapted from a comment by user2834915 user at stackoverflow.com,
dnl https://stackoverflow.com/questions/10332908/find-out-libjpeg-version-at-runtime-or-other-ways-to-prevent-aborts
dnl
dnl _adhoc_AC_PROG_PATH_LIBJPEG_CC_ARG_WITH
AC_DEFUN_ONCE([_adhoc_AC_PROG_PATH_LIBJPEG_CC_ARG_WITH],[dnl
AC_ARG_WITH([libjpeg-prefix],
[AS_HELP_STRING([--with-libjpeg-prefix=PREFIX],
[specify prefix for the installed JPEG library [standard search prefixes]])],
[libjpeg_config_prefix="$withval"],[libjpeg_config_prefix=""])
AC_ARG_WITH([libjpeg-include],
[AS_HELP_STRING([--with-libjpeg-include=PATH],
[specify directory for the installed JPEG library header file [standard search paths]])],
[libjpeg_config_include_prefix="$withval"],[libjpeg_config_include_prefix=""])
AC_ARG_WITH([libjpeg-lib],
[AS_HELP_STRING([--with-libjpeg-lib=PATH],
[specify directory for the installed JPEG library [standard search paths]])],
[libjpeg_config_lib_prefix="$withval"],[libjpeg_config_lib_prefix=""])
if test "x$libjpeg_config_include_prefix" = "x" ; then
if test "x$libjpeg_config_prefix" != "x" ; then
libjpeg_config_include_prefix="$libjpeg_config_prefix/include"
fi
fi
if test "x$libjpeg_config_lib_prefix" = "x" ; then
if test "x$libjpeg_config_prefix" != "x" ; then
libjpeg_config_lib_prefix="$libjpeg_config_prefix/lib"
fi
fi
LIBJPEG_CPPFLAGS=
if test "x$libjpeg_config_include_prefix" != "x" ; then
LIBJPEG_CPPFLAGS="-I$libjpeg_config_include_prefix"
fi
LIBJPEG_LDFLAGS=
if test "x$libjpeg_config_lib_prefix" != "x" ; then
LIBJPEG_LDFLAGS="-L$libjpeg_config_lib_prefix"
fi
AC_SUBST(LIBJPEG_CPPFLAGS)
AC_SUBST(LIBJPEG_LDFLAGS)
])
dnl adhoc_AM_PATH_LIBJPEG([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
AC_DEFUN([adhoc_AM_PATH_LIBJPEG],[dnl
AC_REQUIRE([AC_PROG_SED])dnl
AC_REQUIRE([_adhoc_AC_PROG_PATH_LIBJPEG_CC_ARG_WITH])dnl
min_libjpeg_version=m4_default([$1],[60])
min_libjpeg_version_0="$min_libjpeg_version.0"
min_libjpeg_version_number=`echo $min_libjpeg_version_0 | $SED 's/\([[0-9]]*\).\(.*\)/\1/'`
min_libjpeg_dotted_version="$min_libjpeg_version_number"
LIBJPEG_LIBS="-ljpeg"
AC_MSG_CHECKING([for JPEG library - version >= $min_libjpeg_version ])
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_CFLAGS="$CFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $LIBJPEG_CPPFLAGS"
CFLAGS="$CFLAGS $LIBJPEG_CFLAGS"
LDFLAGS="$LDFLAGS $LIBJPEG_LDFLAGS"
LIBS="$LIBS $LIBJPEG_LIBS"
rm -f conf.libjpegtest
AC_RUN_IFELSE([AC_LANG_SOURCE(
[[
#include <stdio.h>
#include <jpeglib.h>
#define PRINTF_MSG_ERROR_MISMATCH_HEADER_LIBRARY \
printf("*** This likely indicates either a bad configuration or some\n"); \
printf("*** other inconsistency in the development environment. If the\n"); \
printf("*** expected JPEG library cannot be found, it may be sufficient\n"); \
printf("*** either to set properly the LD_LIBRARY_PATH environment variable\n"); \
printf("*** or to configure ldconfig(8) to consider the installed location.\n"); \
printf("*** Otherwise a bad configuration or an inconsistency in the\n"); \
printf("*** include/library search paths may be investigated; adjustments\n"); \
printf("*** through the use of --with-libjpeg-(include|lib) configure option\n"); \
printf("*** may help.\n"); \
printf("***\n"); \
printf("*** If an old version is installed, it may be best to remove it and to\n"); \
printf("*** reinstall a more recent one; although modifying LD_LIBRARY_PATH\n"); \
printf("*** may also get things to work. Latest information on JPEG may be\n"); \
printf("*** available from <http://jpegclub.org/>.\n"); \
printf("***\n");
int adhoc_libjpeg_version(void);
int main ()
{
int libjpeg_hdr_version_number = 0;
int libjpeg_lib_version_number = 0;
fclose (fopen ("conf.libjpegtest", "w"));
#ifdef JPEG_LIB_VERSION
libjpeg_hdr_version_number = JPEG_LIB_VERSION;
#else
error JPEG_LIB_VERSION not defined
#endif
libjpeg_lib_version_number = adhoc_libjpeg_version();
if (libjpeg_lib_version_number != libjpeg_hdr_version_number) {
printf("\n***\n");
printf("*** JPEG header version number (%d) and\n",libjpeg_hdr_version_number);
printf("*** JPEG library version number (%d)\n",libjpeg_lib_version_number);
printf("*** do not match.\n");
printf("***\n");
PRINTF_MSG_ERROR_MISMATCH_HEADER_LIBRARY
}
else if ($min_libjpeg_version_number <= libjpeg_hdr_version_number) {
return (0);
}
else {
printf("\n***\n");
printf("*** JPEG version $min_libjpeg_dotted_version or higher is required:\n");
printf("*** an older version of JPEG (%d) was found.\n",libjpeg_hdr_version_number);
printf("*** Latest information on JPEG may be available from <http://jpegclub.org/>.\n");
printf("***\n");
}
return (1);
}
static
int ADHOC_LIBRARY_JPEG_LIB_VERSION=-1;
static
void adhoc_libjpeg_version_error_exit(j_common_ptr cinfo) {
ADHOC_LIBRARY_JPEG_LIB_VERSION=cinfo->err->msg_parm.i[0];
return ; }
int adhoc_libjpeg_version(void) {
if (ADHOC_LIBRARY_JPEG_LIB_VERSION < 0) {
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr error_mgr;
error_mgr.error_exit=&adhoc_libjpeg_version_error_exit;
cinfo.err=&error_mgr;
#undef JPEG_LIB_VERSION
#define JPEG_LIB_VERSION -1
jpeg_create_decompress(&cinfo);
#undef JPEG_LIB_VERSION
}
return (ADHOC_LIBRARY_JPEG_LIB_VERSION); }
]]
)],[],[no_libjpeg=yes],[AC_MSG_WARN([$ac_n "cross compiling; assumed OK... $ac_c])])
CPPFLAGS="$ac_save_CPPFLAGS"
CFLAGS="$ac_save_CFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
if test "x$no_libjpeg" = "x" ; then
AC_MSG_RESULT([yes])
$2
else
AC_MSG_RESULT([no])
if test -f conf.libjpegtest ; then
:
else
echo "***"
echo "*** Could not run JPEG test program, checking why..."
CPPFLAGS="$CPPFLAGS $LIBJPEG_CPPFLAGS"
CFLAGS="$CFLAGS $LIBJPEG_CFLAGS"
LDFLAGS="$CFLAGS $LIBJPEG_LDFLAGS"
LIBS="$LIBS $LIBJPEG_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <jpeg.h>
]],
[[ return (1); ]]
)],
[
echo "***"
echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding JPEG library or finding the wrong"
echo "*** version of JPEG. If it is not finding JPEG, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or configure ldconfig(8) to consider"
echo "*** the installed location."
echo "***"
echo "*** If you have an old version installed, it is best to remove it; although"
echo "*** modifying LD_LIBRARY_PATH may also get things to work. Latest information"
echo "*** on JPEG may be available from <http://jpegclub.org/>."
echo "***"
],
[
echo "***"
echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means JPEG was incorrectly installed"
echo "*** or that you have moved JPEG since it was installed."
echo "***"
])
CPPFLAGS="$ac_save_CPPFLAGS"
CFLAGS="$ac_save_CFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
fi
rm -f conf.libjpegtest
m4_default([$3],[AC_MSG_ERROR([no suitable JPEG library found])])
fi
rm -f conf.libjpegtest
AC_SUBST(LIBJPEG_LIBS)
])
dnl alias
AU_ALIAS([AM_PATH_LIBJPEG],[adhoc_AM_PATH_LIBJPEG])
dnl eof
|