source: tags/release-1.1.10/configure.ac

Last change on this file was 765, checked in by MatthewWhiting, 14 years ago

Small changes to configure script

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