source: tags/release-1.1.1/configure.ac

Last change on this file was 345, checked in by MatthewWhiting, 17 years ago

Updating version 1.1.1 with the latest fixes for the configure/make scripts and their documentation.

File size: 10.2 KB
Line 
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.57)
5AC_INIT([Duchamp], [1.1.1], [Matthew.Whiting@csiro.au])
6AC_CONFIG_SRCDIR([src/duchamp.hh])
7AC_CONFIG_HEADER([src/config.h])
8AC_PREFIX_DEFAULT(/usr/local)
9
10# Checks for programs.
11AC_PROG_CXX
12AC_PROG_CC
13AC_PROG_CPP
14AC_PROG_LN_S
15AC_CHECK_PROGS(INSTALL, install)
16
17# Check for maths library -- will add -lm to $LIBS
18AC_CHECK_LIB([m], [log])
19
20# Checks for header files.
21AC_HEADER_STDC
22AC_CHECK_HEADERS([unistd.h time.h math.h iostream fstream sstream iomanip vector string algorithm functional])
23if test "x$ac_cv_header_stdc" = xno; then
24  AC_MSG_ERROR([
25    -------------------------------------------------------------------
26    An ANSI standard C library is required to build Duchamp. 
27    One of the ANSI C header files it requires is missing or unusable.
28
29    ERROR: Duchamp configuration failure.
30    -------------------------------------------------------------------], [1])
31fi
32
33# Checks for typedefs, structures, and compiler characteristics.
34AC_HEADER_STDBOOL
35AC_C_CONST
36AC_C_INLINE
37
38# Utilities.
39AC_PROG_RANLIB
40
41# Checks for library functions.
42AC_FUNC_STRTOD
43AC_CHECK_FUNCS([floor pow sqrt strtol log atan fabs])
44
45# Extra places to look for third-party include files and libraries.
46INCDIRS="$INCDIRS           \
47         /usr/include       \
48         /usr/local/include \
49         /usr/local/pgplot  \
50         /usr/local/cfitsio \
51         /usr/local/wcslib  \
52         /local/pgplot      \
53         /local/cfitsio     \
54         /opt/local/include"
55
56LIBDIRS="$LIBDIRS           \
57         /usr/lib           \
58         /usr/local/lib     \
59         /usr/local/pgplot  \
60         /usr/local/cfitsio \
61         /usr/local/wcslib  \
62         /local/lib         \
63         /local/pgplot      \
64         /local/cfitsio     \
65         /opt/SUNWspro/lib  \
66         /opt/local/lib"
67
68AC_MSG_NOTICE(LIBDIRS)
69
70for LIBDIR in $LIBDIRS ; do
71  AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
72done
73
74##########################################################################
75# Search for PGPLOT
76# use --with-cfitsio=directory to specify a particular PGPLOT directory.
77# or  --without-pgplot or --with-pgplot=no to do without it
78# else do the normal searching for libraries.
79
80AC_MSG_NOTICE([  -- PGPLOT -- ])
81AC_ARG_WITH(pgplot,
82[
83AC_HELP_STRING([--with-pgplot=no],
84               [Compile without PGPLOT graphics capabilities.])
85AC_HELP_STRING([--without-pgplot],
86               [Compile without PGPLOT graphics capabilities.])
87AC_HELP_STRING([--with-pgplot=<dir>],
88               [Compile with PGPLOT graphics capabilities, using the directory <dir> to specify the PGPLOT library.]),
89],
90[
91if test "x$withval" != xno; then
92AC_MSG_NOTICE([Using directory "$withval"])
93PGPLOTINCDIRS=$withval
94PGPLOTLIBDIRS=$withval
95LDFLAGS="$LDFLAGS -L$withval"
96fi
97],
98[
99PGPLOTINCDIRS=$INCDIRS
100PGPLOTLIBDIRS=$LIBDIRS
101])
102
103if test "x$PGPLOTLIBDIRS" = x; then
104  #the argument to --with-pgplot was no, so we don't look for it.
105  AC_MSG_NOTICE([Not enabling PGPLOT use.])
106else
107
108  #Set up the PGPLOT-related libraries and includes.
109
110  for INCDIR in $PGPLOTINCDIRS ; do
111    AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
112    INCDIR=$INCDIR/pgplot
113    AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
114  done
115 
116  # PGPLOT compiled with a SUN compiler but linked with something else.
117  AC_CHECK_LIB([sunmath], [cosd],      [PGPLOTLIB="-lsunmath $PGPLOTLIB"],
118               [], [$PGPLOTLIB $LIBS])
119  AC_CHECK_LIB([M77],     [iand_],     [PGPLOTLIB="-lM77 $PGPLOTLIB"],
120               [], [$PGPLOTLIB $LIBS])
121  AC_CHECK_LIB([F77],     [f77_init],  [PGPLOTLIB="-lF77 $PGPLOTLIB"],
122               [], [$PGPLOTLIB $LIBS])
123 
124  # Checks for extra libraries needed by PGPLOT -- will add -lg2c to $LIBS
125  AC_CHECK_LIB([g2c], [gerror_])
126
127  # Search for X11 includes and libraries.
128  AC_PATH_X
129  if test "x$ac_x_libraries" != x; then
130    LDFLAGS="$LDFLAGS -L$ac_x_libraries"
131    PGPLOTLIB="-L$ac_x_libraries -lX11 $PGPLOTLIB"
132  fi
133 
134  # It is possible that other libraries may be required depending on what
135  # graphics drivers were installed with PGPLOT.
136  AC_CHECK_LIB([z],       [deflate],   [PGPLOTLIB="-lz $PGPLOTLIB"],
137               [], [$PGPLOTLIB $LIBS])
138  AC_CHECK_LIB([png],     [png_error], [PGPLOTLIB="-lpng $PGPLOTLIB"],
139             [], [$PGPLOTLIB $LIBS])
140  AC_CHECK_LIB([pgplot],  [pgbeg_],    [PGPLOTLIB="-lpgplot $PGPLOTLIB"],
141               [], [$PGPLOTLIB $LIBS])
142  AC_CHECK_LIB([cpgplot], [cpgopen],   [PGPLOTLIB="-lcpgplot $PGPLOTLIB"],
143               [], [$PGPLOTLIB $LIBS])
144
145  PGPLOTLIB="$PGPLOTLIB $LIBS"
146 
147  # If PGPLOT is not present, we give a warning message but still continue.
148  # The compilation is able to work without the PGPLOT-dependent files.
149  if test "x$PGPLOTLIB" = x; then
150    AC_MSG_NOTICE([
151      -------------------------------------------------------
152      WARNING! PGPLOT could not be found.
153      Compiling Duchamp without graphics capabilities.               
154      -------------------------------------------------------])
155  else
156    AC_MSG_NOTICE([PGPLOT appears to be available.])
157    AC_DEFINE([HAVE_PGPLOT], [1], [Define to 1 if PGPLOT is available.])
158    for LIBDIR in $PGPLOTLIBDIRS ; do
159      AC_CHECK_FILE([$LIBDIR/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR $PGPLOTLIB"; break])
160    done
161  fi
162
163fi
164
165AC_SUBST([PGPLOTINC])
166AC_SUBST([PGPLOTLIB])
167##########################################################################
168
169##########################################################################
170# Search for CFITSIO.
171# use --with-cfitsio=directory to specify a particular CFITSIO directory.
172# else do the normal searching for libraries.
173
174AC_MSG_NOTICE([  -- CFITSIO -- ])
175AC_ARG_WITH(cfitsio,
176        AC_HELP_STRING([--with-cfitsio=<dir>],
177                       [The CFITSIO library and include files are in directory <dir>.]),
178[ #if we specify a directory...
179if test "x$withval" = xno; then
180  AC_MSG_NOTICE([
181    The CFITSIO library is required.
182    Ignoring the "--with-cfitsio=no" and searching for the library.], [1])
183  CFITSIOINCDIRS=$INCDIRS
184  CFITSIOLIBDIRS=$LIBDIRS
185else
186  AC_MSG_NOTICE([Using directory "$withval"])
187  CFITSIOINCDIRS="$withval \
188              $withval/include"
189  CFITSIOLIBDIRS="$withval \
190              $withval/lib"
191fi
192],
193[ # if directory not specified, go searching.
194CFITSIOINCDIRS=$INCDIRS
195CFITSIOLIBDIRS=$LIBDIRS
196])
197
198for INCDIR in $CFITSIOINCDIRS ; do
199  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
200  INCDIR=$INCDIR/cfitsio
201  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
202done
203
204AC_CHECK_LIB([socket],  [recv],   [CFITSIOLIB="-lsocket"], [], [$LIBS])
205AC_CHECK_LIB([cfitsio], [ffopen], [CFITSIOLIB="-lcfitsio $CFITSIOLIB"], [],
206             [$CFITSIOLIB $LIBS])
207
208# CFITSIO is essential for Duchamp, so exit with error message if it
209#   is not present.
210if test "x$CFITSIOINC" = x -o "x$CFITSIOLIB" = x; then
211  AC_MSG_ERROR([
212    -------------------------------------------------------
213    Could not find the CFITSIO library.
214
215    ERROR: Duchamp configuration failure.
216    -------------------------------------------------------], [1])
217else
218  for LIBDIR in $CFITSIOLIBDIRS ; do
219    AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
220    LIBDIR=$LIBDIR/cfitsio
221    AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
222  done
223  AC_MSG_NOTICE([CFITSIO appears to be available.])
224  AC_DEFINE([HAVE_CFITSIO], [1], [Define to 1 if CFITSIO is available.])
225fi
226
227AC_SUBST([CFITSIOINC])
228AC_SUBST([CFITSIOLIB])
229##########################################################################
230
231##########################################################################
232# Search for WCSLIB.
233# use --with-cfitsio=directory to specify a particular CFITSIO directory.
234# else do the normal searching for libraries.
235
236AC_MSG_NOTICE([  -- WCSLIB -- ])
237AC_ARG_WITH(wcslib,
238        AC_HELP_STRING([--with-wcslib=<dir>],
239                       [The WCSLIB library and include files are in directory <dir>.]),
240[ #if we specify a directory...
241if test "x$withval" = xno; then
242  AC_MSG_NOTICE([
243    The WCSLIB library is required.
244    Ignoring the "--with-wcslib=no" and searching for the library.], [1])
245  CFITSIOINCDIRS=$INCDIRS
246  CFITSIOLIBDIRS=$LIBDIRS
247else
248  AC_MSG_NOTICE([Using directory "$withval"])
249  WCSINCDIRS="$withval \
250              $withval/include"
251  WCSLIBDIRS="$withval \
252              $withval/lib"
253fi
254],
255[ # if directory not specified, go searching.
256WCSINCDIRS=$INCDIRS
257WCSLIBDIRS=$LIBDIRS
258])
259
260for INCDIR in $WCSINCDIRS ; do
261  AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break])
262  INCDIR=$INCDIR/wcslib
263  AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break])
264done
265for INCDIR in $WCSINCDIRS ; do
266  AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break])
267  INCDIR=$INCDIR/wcslib
268  AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break])
269done
270
271AC_CHECK_LIB([pgsbox], [cpgsbox], [WCSLIB="-lpgsbox $WCSLIB"], [],
272             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
273AC_CHECK_LIB([wcs], [wcss2p], [WCSLIB="-lwcs $WCSLIB"], [],
274             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
275
276# WCSLIB is essential for Duchamp, so exit with error message if it
277#   is not present. Need at least libwcs to be available -- libpgsbox will
278#   depend on PGPLOT being available, but is not critical.
279if test "x$WCSINC" = x -o "x$WCSLIB" = x; then
280  AC_MSG_ERROR([
281    -------------------------------------------------------
282    Could not find the WCSLIB library.
283
284    ERROR: Duchamp configuration failure.
285    -------------------------------------------------------], [1])
286else
287  for LIBDIR in $WCSLIBDIRS ; do
288    AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break])
289    LIBDIR=$LIBDIR/wcs
290    AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break])
291  done
292  for LIBDIR in $WCSLIBDIRS ; do
293    AC_CHECK_FILE([$LIBDIR/libwcs.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break])
294    LIBDIR=$LIBDIR/wcs
295    AC_CHECK_FILE([$LIBDIR/libwcs.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break])
296  done
297  AC_MSG_NOTICE([WCSLIB appears to be available.])
298  AC_DEFINE([HAVE_WCSLIB], [1], [Define to 1 if WCSLIB is available.])
299fi
300
301AC_SUBST([WCSINC])
302AC_SUBST([WCSLIB])
303##########################################################################
304
305AC_SUBST([LDFLAGS])
306
307AC_CONFIG_FILES([Makefile])
308AC_OUTPUT
Note: See TracBrowser for help on using the repository browser.