source: trunk/configure.ac @ 338

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

Getting the trunk up to date with the improvements to the configure/make setup, plus the documentation, that was done for v1.1.1.

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