source: trunk/configure.ac @ 362

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

Updated the CHANGES and README for inclusion with the beta version.
Also updated the version number to 1.1.2.

File size: 12.3 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.2], [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_F77
15AC_PROG_LN_S
16AC_CHECK_PROGS(INSTALL, install)
17
18# Check for maths library -- will add -lm to $LIBS
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" = x; 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  #Set up the PGPLOT-related libraries and includes.
110
111  for INCDIR in $PGPLOTINCDIRS ; do
112    AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
113    INCDIR=$INCDIR/pgplot
114    AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
115  done
116 
117  # PGPLOT compiled with a SUN compiler but linked with something else.
118  AC_CHECK_LIB([sunmath], [cosd],      [EXTRAPGLIB="-lsunmath $EXTRAPGLIB"],
119               [], [$EXTRAPGLIB $LIBS])
120  AC_CHECK_LIB([M77],     [iand_],     [EXTRAPGLIB="-lM77 $EXTRAPGLIB"],
121               [], [$EXTRAPGLIB $LIBS])
122  AC_CHECK_LIB([F77],     [f77_init],  [EXTRAPGLIB="-lF77 $EXTRAPGLIB"],
123               [], [$EXTRAPGLIB $LIBS])
124 
125  # Search for X11 includes and libraries.
126  AC_PATH_X
127  if test "x$ac_x_libraries" != x; then
128    LDFLAGS="$LDFLAGS -L$ac_x_libraries"
129    EXTRAPGLIB="-L$ac_x_libraries -lX11 $EXTRAPGLIB"
130  fi
131
132#  # Add pgplot libraries, if they exist to the lib path
133#  for LIBDIR in $PGPLOTLIBDIRS ; do
134#    AC_CHECK_FILE([$LIBDIR/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR $PGPLOTLIB"; break])
135#  done
136 
137  # It is possible that other libraries may be required depending on what
138  # graphics drivers were installed with PGPLOT.
139  AC_CHECK_LIB([z],       [deflate],   [EXTRAPGLIB="$EXTRAPGLIB -lz"],
140               [], [$EXTRAPGLIB $LIBS])
141  AC_CHECK_LIB([png],     [png_error], [EXTRAPGLIB="$EXTRAPGLIB -lpng"],
142             [], [$EXTRAPGLIB $LIBS])
143
144  AC_LANG(Fortran 77)
145  AC_CHECK_LIB([pgplot],  [pgopen],    [PGPLOTLIB="-lpgplot"],
146               [], [$PGPLOTLIB $EXTRAPGLIB])
147  AC_LANG(C)
148  # Checks for extra libraries needed by PGPLOT -- will add -lg2c -lstdc++ to $LIBS
149  AC_CHECK_LIB([g2c], [gerror_])
150  AC_CHECK_LIB([stdc++], [main])
151  if test "x$F77" = xgfortran; then
152    PGPLOTLIB="-lcpgplot $PGPLOTLIB"
153    AC_MSG_NOTICE([ Using gfortran, so manually adding -lcpgplot to PGPLOTLIB string.])
154  else
155    AC_CHECK_LIB([cpgplot], [cpgopen],   [PGPLOTLIB="-lcpgplot $PGPLOTLIB"],
156                 [], [$PGPLOTLIB $LIBS $EXTRAPGLIB])
157  fi
158 
159  # If PGPLOT is not present, we give a warning message but still continue.
160  # The compilation is able to work without the PGPLOT-dependent files.
161  if test "x$PGPLOTLIB" = x; then
162    AC_MSG_NOTICE([
163      -------------------------------------------------------
164      WARNING! PGPLOT could not be found.
165      Compiling Duchamp without graphics capabilities.               
166      -------------------------------------------------------])
167  else
168    PGPLOTLIB="$PGPLOTLIB $EXTRAPGLIB $LIBS"
169    AC_MSG_NOTICE([PGPLOT appears to be available.])
170    AC_DEFINE([HAVE_PGPLOT], [1], [Define to 1 if PGPLOT is available.])
171    for LIBDIR in $PGPLOTLIBDIRS ; do
172     AC_CHECK_FILE([$LIBDIR/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR $PGPLOTLIB"; break])
173    done
174    if test "x$F77" = xgfortran; then
175      PGPLOTLIB="$PGPLOTLIB -bind_at_load"
176    fi
177  fi
178
179fi
180
181AC_SUBST([PGPLOTINC])
182AC_SUBST([PGPLOTLIB])
183##########################################################################
184
185##########################################################################
186# Search for CFITSIO.
187# use --with-cfitsio=directory to specify a particular CFITSIO directory.
188# else do the normal searching for libraries.
189
190AC_MSG_NOTICE([  -- CFITSIO -- ])
191AC_ARG_WITH(cfitsio,
192        AC_HELP_STRING([--with-cfitsio=<dir>],
193                       [The CFITSIO library and include files are in directory <dir>.]),
194[ #if we specify a directory...
195if test "x$withval" = xno; then
196  AC_MSG_NOTICE([
197    The CFITSIO library is required.
198    Ignoring the "--with-cfitsio=no" and searching for the library.], [1])
199  CFITSIOINCDIRS=$INCDIRS
200  CFITSIOLIBDIRS=$LIBDIRS
201else
202  AC_MSG_NOTICE([Using directory "$withval"])
203  CFITSIOINCDIRS="$withval \
204              $withval/include"
205  CFITSIOLIBDIRS="$withval \
206              $withval/lib"
207  for LIBDIR in $CFITSIOLIBDIRS ; do
208    AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
209  done
210  for INCDIR in $CFITSIOINCDIRS ; do
211    AC_CHECK_FILE([$INCDIR], [CPPFLAGS="$CPPFLAGS -I$INCDIR"], [continue])
212  done
213fi
214],
215[ # if directory not specified, go searching.
216CFITSIOINCDIRS=$INCDIRS
217CFITSIOLIBDIRS=$LIBDIRS
218])
219
220for INCDIR in $CFITSIOINCDIRS ; do
221  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
222  INCDIR=$INCDIR/cfitsio
223  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
224done
225
226AC_CHECK_LIB([socket],  [recv],   [CFITSIOLIB="$CFITSIOLIB -lsocket"], [], [$LIBS])
227AC_CHECK_LIB([cfitsio], [ffopen], [CFITSIOLIB="$CFITSIOLIB -lcfitsio"], [],
228             [$CFITSIOLIB $LIBS])
229
230# CFITSIO is essential for Duchamp, so exit with error message if it
231#   is not present.
232if test "x$CFITSIOINC" = x -o "x$CFITSIOLIB" = x; then
233  AC_MSG_ERROR([
234    -------------------------------------------------------
235    Could not find the CFITSIO library.
236
237    ERROR: Duchamp configuration failure.
238    -------------------------------------------------------], [1])
239else
240  AC_MSG_NOTICE([CFITSIO appears to be available.])
241  AC_DEFINE([HAVE_CFITSIO], [1], [Define to 1 if CFITSIO is available.])
242for LIBDIR in $CFITSIOLIBDIRS ; do
243  AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
244  LIBDIR=$LIBDIR/cfitsio
245  AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
246done
247
248fi
249
250AC_SUBST([CFITSIOINC])
251AC_SUBST([CFITSIOLIB])
252##########################################################################
253
254##########################################################################
255# Search for WCSLIB.
256# use --with-wcslib=directory to specify a particular WCSLIB directory.
257# else do the normal searching for libraries.
258
259AC_MSG_NOTICE([  -- WCSLIB -- ])
260AC_ARG_WITH(wcslib,
261        AC_HELP_STRING([--with-wcslib=<dir>],
262                       [The WCSLIB library and include files are in directory <dir>.]),
263[ #if we specify a directory...
264if test "x$withval" = xno; then
265  AC_MSG_NOTICE([
266    The WCSLIB library is required.
267    Ignoring the "--with-wcslib=no" and searching for the library.], [1])
268  WCSINCDIRS=$INCDIRS
269  WCSLIBDIRS=$LIBDIRS
270else
271  AC_MSG_NOTICE([Using directory "$withval"])
272  WCSINCDIRS="$withval \
273              $withval/include"
274  WCSLIBDIRS="$withval \
275              $withval/lib"
276  for LIBDIR in $WCSLIBDIRS ; do
277    AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
278  done
279  for INCDIR in $WCSINCDIRS ; do
280    AC_CHECK_FILE([$INCDIR], [CPPFLAGS="$CPPFLAGS -I$INCDIR"], [continue])
281  done
282fi
283],
284[ # if directory not specified, go searching.
285WCSINCDIRS=$INCDIRS
286WCSLIBDIRS=$LIBDIRS
287])
288
289DIRLIST=". \
290         wcs \
291         wcslib"
292
293for INCBASE in $WCSINCDIRS ; do
294  for DIR in $DIRLIST; do
295    if test "x$DIR" = x.; then
296     INCDIR=$INCBASE
297    else
298     INCDIR="$INCBASE/$DIR"
299    fi
300    AC_CHECK_FILE([$INCDIR/wcs.h],
301                  [WCSINC="-I$INCDIR $WCSINC";
302                  AC_CHECK_FILE([$INCDIR/cpgsbox.h], [], [
303                    for INCBASE2 in $WCSINCDIRS ; do
304                     for DIR2 in $DIRLIST; do
305                      if test "x$DIR" = x.; then
306                       INCDIR=$INCBASE
307                      else
308                       INCDIR="$INCBASE/$DIR"
309                      fi
310                      AC_CHECK_FILE([$INCDIR2/cpgsbox.h],
311                                    [WCSINC="-I$INCDIR $WCSINC"; break])
312                     done
313                    done])
314                  break])
315  done
316done
317
318# Look for libwcs.a, and libpgsbox.a
319AC_CHECK_LIB([wcs], [wcss2p], [WCSLIB="$WCSLIB -lwcs"], [],
320             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
321if test "x$F77" = xgfortran; then
322  WCSLIB="$WCSLIB -lpgsbox"
323  AC_MSG_NOTICE([ Using gfortran, so manually adding -lpgsbox to WCSLIB string.])
324else
325  AC_CHECK_LIB([pgsbox], [cpgsbox], [WCSLIB="$WCSLIB -lpgsbox"], [],
326               [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
327fi
328
329# WCSLIB is essential for Duchamp, so exit with error message if it
330#   is not present. Need at least libwcs to be available -- libpgsbox will
331#   depend on PGPLOT being available, but is not critical.
332if test "x$WCSINC" = x -o "x$WCSLIB" = x; then
333  AC_MSG_ERROR([
334    -------------------------------------------------------
335    Could not find the WCSLIB library.
336
337    ERROR: Duchamp configuration failure.
338    -------------------------------------------------------], [1])
339else
340  AC_MSG_NOTICE([WCSLIB appears to be available.])
341  AC_DEFINE([HAVE_WCSLIB], [1], [Define to 1 if WCSLIB is available.])
342# Now add the -L statements to start of WCSLIB.
343# Search for libwcs.a, and, if we find it, search for libpgsbox in same directory and
344#   then in other directories, keeping the appropriate order of -L calls.
345
346  for LIBBASE in $WCSLIBDIRS ; do
347    for DIR in $DIRLIST; do
348      if test "x$DIR" = x.; then
349       LIBDIR=$LIBBASE
350      else
351       LIBDIR="$LIBBASE/$DIR"
352      fi
353      AC_CHECK_FILE([$LIBDIR/libwcs.a],
354             [WCSLIBFRONT="-L$LIBDIR";
355             AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [], [
356               for LIBBASE2 in $WCSLIBDIRS ; do
357                for DIR2 in $DIRLIST; do
358                 if test "x$DIR" = x.; then
359                  LIBDIR=$LIBBASE
360                 else
361                  LIBDIR="$LIBBASE/$DIR"
362                 fi
363                 AC_CHECK_FILE([$LIBDIR2/libpgsbox.a],
364                               [WCSLIBFRONT="$WCSLIB -L$LIBDIR2"; break])
365                done
366               done])
367              break])
368    done
369  done
370  WCSLIB="$WCSLIBFRONT $WCSLIB"
371fi
372
373AC_SUBST([WCSINC])
374AC_SUBST([WCSLIB])
375##########################################################################
376
377AC_SUBST([LDFLAGS])
378
379AC_CONFIG_FILES([Makefile])
380AC_OUTPUT
Note: See TracBrowser for help on using the repository browser.