source: trunk/configure.ac @ 383

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