diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..1c311e0
--- /dev/null
@@ -0,0 +1,103 @@
+AC_PREREQ([2.68])
+AC_INIT([CADS_fits2jpeg], [1.0], [cads@iiap.res.in])
+AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE(CADS_fits2jpeg, 1.0)
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_CHECK_HEADERS([stdlib.h string.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+
+LIBS="$LIBS -lm -Wall -pedantic"
+
+LIBS="$LIBS -L/usr/lib64 -L/usr/lib -lm -ljpeg -lcfitsio"
+CFLAGS="-ansi $CFLAGS -I/usr/include -I/usr/include/cfitsio"
+#---------------------------------------------------------------------#
+#           Now we check for cfitsio headers and library              #
+#---------------------------------------------------------------------#
+fitserror="
+ +------------------------------------------------------------------+
+ | Unable to find cfitsio distribution. You may need to get it from |
+ |   http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html  |
+ +------------------------------------------------------------------+
+"
+AC_ARG_WITH(cfitsio,
+            [ --with-cfitsio[=DIR]     Location of the cfitsio distribution],
+            [CFITS=$with_cfitsio]
+)
+
+if test x"$CFITS" != 'x'; then
+        LIBS="-L$CFITS -L$CFITS/lib64 -L$CFITS/lib $LIBS"
+        CFLAGS="$CFLAGS -I$CFITS -I$CFITS/include -I$CFITS/include/cfitsio"
+fi
+
+AC_MSG_CHECKING(for cfitsio)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+            #include <stdio.h>
+            #include <stdlib.h>
+            #include <fitsio2.h>]],
+          [[    fitsfile *fptr]])],
+          [cfitsio=yes],[cfitsio=no])
+AC_MSG_RESULT([$cfitsio])
+
+if test "$cfitsio" != "yes"; then
+    AC_MSG_ERROR($fitserror)
+fi
+
+#---------------------------------------------------------------------#
+#                   And the jpeg headers and library                  #
+#---------------------------------------------------------------------#
+jpegerror="
+ +------------------------------------------------------------------+
+ |            Unable to find jpeg library and headers               |
+ +------------------------------------------------------------------+
+"
+AC_ARG_WITH(jpeglib,
+            [ --with-jpeglib[=DIR]     Location of the jpeg library],
+            [LJPG=$with_jpeglib]
+)
+
+if test x"$LJPG" != 'x'; then
+        LIBS="-L$LJPG -L$LJPG/lib64 -L$LJPG/lib $LIBS"
+        CFLAGS="$CFLAGS -I$LJPG -I$LJPG/include -I$LJPG/include/jpeglib"
+fi
+
+AC_MSG_CHECKING(for jpeglib)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+            #include <stdio.h>
+            #include <stdlib.h>
+            #include <jpeglib.h>]],
+          [[    FILE *jpeg_file]])],
+          [jpeg=yes],[jpeg=no])
+AC_MSG_RESULT([$jpeg])
+
+if test "$jpeg" != "yes"; then
+        AC_MSG_ERROR($jpegerror)
+fi
+
+AC_OUTPUT(Makefile src/Makefile)
+
+echo
+echo " +------------------------------------------------------------------+"
+echo " | Configuration complete                                           |"
+echo " | Type 'make' to compile the software, followed by 'make install'  |"
+echo " |                   All the very best! :-)                         |"
+echo " |                                             --CADS Software Team |"
+echo " +------------------------------------------------------------------+"
+echo
+