Index: trunk/psLib/configure.ac
===================================================================
--- trunk/psLib/configure.ac	(revision 7404)
+++ trunk/psLib/configure.ac	(revision 7412)
@@ -169,5 +169,5 @@
 TMP_LIBS=${LIBS}
 AC_CHECK_LIB(cfitsio,ffopen,[],
-  [AC_MSG_ERROR([CFITSIO library not found.  Obtain it at  http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])]
+  [AC_MSG_ERROR([CFITSIO library not found.  Obtain it at  http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])],[-lm]
 )
 dnl Now check if CFITSIO supports fits_open_diskfile, i.e., is at least version 2.501
@@ -175,5 +175,5 @@
   [CFITSIO_DISKFILE=1],
   [AC_MSG_WARN([The CFITSIO library version is rather old.  Suggested version is 2.501 or greater.])
-   CFITSIO_DISKFILE=0]
+   CFITSIO_DISKFILE=0],[-lm]
 )
 LIBS=${TMP_LIBS}
@@ -207,8 +207,8 @@
 LDFLAGS="${TMP_LDFLAGS} ${PSLIB_LIBS}"
 AC_CHECK_HEADERS([fftw3.h],[],
-  [AC_MSG_ERROR([FFTW version 3 (--with-float) headers not found.  Obtain it at http://www.fftw.org/or use --with-fftw3 to specify location.])]
+  [AC_MSG_ERROR([FFTW version 3 (--enable-float) headers not found.  Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])]
 )
 AC_CHECK_LIB(fftw3f,fftwf_plan_dft_2d,[],
-  [AC_MSG_ERROR([FFTW version 3 (--with-float) library not found.  Obtain it at http://www.fftw.org/or use --with-fftw3 to specify location.])],[-lm]
+  [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found.  Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])],[-lm]
 )
 LIBS=${TMP_LIBS}
@@ -241,7 +241,37 @@
 AC_SUBST([GSL_CFLAGS])
 
-dnl libjpeg -------------------------------------------------------------------
-
-AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[],[AC_MSG_ERROR([jpeg library not found.])])
+dnl ------------------ libjpeg options ---------------------
+AC_ARG_WITH(jpeg,
+[AS_HELP_STRING(--with-jpeg=DIR,Specify location of libjpeg.)],
+[JPEG_CFLAGS="-I$withval/include"
+ JPEG_LDFLAGS="-L$withval/lib"])
+AC_ARG_WITH(jpeg-include,
+[AS_HELP_STRING(--with-jpeg-include=DIR,Specify libjpeg include directory.)],
+[FFTW3_CFLAGS="-I$withval"])
+AC_ARG_WITH(fftw3-lib,
+[AS_HELP_STRING(--with-jpeg-lib=DIR,Specify libjpeg library directory.)],
+[JPEG_LDFLAGS="-L$withval"])
+PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${JPEG_CFLAGS}"
+PSLIB_LIBS="${PSLIB_LIBS=} $JPEG_LDFLAGS -ljpeg"
+
+dnl Store off CFLAGS/LDFLAGS so that they can be restored after tests
+TMP_CFLAGS=${CFLAGS}
+TMP_LDFLAGS=${LDFLAGS}
+
+CFLAGS="${TMP_CFLAGS} ${PSLIB_CFLAGS}"
+LDFLAGS="${TMP_LDFLAGS} ${PSLIB_LIBS}"
+AC_CHECK_HEADERS([jpeglib.h],[],
+  [AC_MSG_ERROR([libjpeg headers not found.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
+)
+AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[],
+  [AC_MSG_ERROR([libjpeg library not found.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
+)
+LIBS=${TMP_LIBS}
+
+dnl restore the CFLAGS/LDFLAGS
+CFLAGS=${TMP_CFLAGS}
+LDFLAGS=${TMP_LDFLAGS}
+
+AC_SUBST([JPEG_CFLAGS])
 
 dnl ------------------- XML2 options ---------------------
