source: trunk/configure.ac @ 1202

Last change on this file since 1202 was 1202, checked in by MatthewWhiting, 11 years ago

Updating the CHANGES for the upcoming 1.3.1 release, plus updating the version number everywhere.

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