I found the script for checking libgcrypt in configure file. So we should use the same way for libjpeg , right? It seems no reason for another way...
libgcrypt is a special case: it uses a custom AM_PATH_LIBGCRYPT
macro. You can take a look to the code used for jbig2dec:
have_jbig2dec=no
AC_CHECK_LIB([jbig2dec],[jbig2_ctx_new],[have_jbig2dec=yes],,)
if test "x$have_jbig2dec" = "xyes"; then
LIBS="-ljbig2dec $LIBS"
AC_DEFINE([HAVE_JBIG2DEC], [1], [The jbig2dec library is available])
fi
