source: tags/release-1.6.1/configure.ac

Last change on this file was 1391, checked in by MatthewWhiting, 10 years ago

Changing the version number to 1.6.1 in preparation for patch release #228

File size: 13.6 KB
Line 
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.57)
5AC_INIT([Duchamp], [1.6.1], [Matthew.Whiting@csiro.au])
6AC_CONFIG_SRCDIR([src/duchamp.hh])
7AC_CONFIG_HEADER([src/config.h])
8AC_PREFIX_DEFAULT(/usr/local)
9
10AC_CONFIG_AUX_DIR([config])
11
12# Get the system type.
13AC_CANONICAL_BUILD
14ARCH="${build_cpu}-$build_os"
15AC_SUBST([ARCH])
16
17# Checks for programs.
18AC_PROG_CXX
19AC_PROG_CC
20AC_PROG_CPP
21AC_PROG_F77
22AC_PROG_LN_S
23AC_CHECK_PROGS(INSTALL, install)
24LINKER=$CXX
25
26# Check for maths library -- will add -lm to $LIBS
27AC_CHECK_LIB([m], [log])
28
29# Checks for header files.
30AC_HEADER_STDC
31AC_CHECK_HEADERS([unistd.h time.h math.h values.h iostream fstream sstream iomanip vector string algorithm functional])
32if test "x$ac_cv_header_stdc" = xno; then
33  AC_MSG_ERROR([
34    -------------------------------------------------------------------
35    An ANSI standard C library is required to build Duchamp. 
36    One of the ANSI C header files it requires is missing or unusable.
37
38    ERROR: Duchamp configuration failure.
39    -------------------------------------------------------------------], [1])
40fi
41
42# Checks for typedefs, structures, and compiler characteristics.
43AC_HEADER_STDBOOL
44AC_C_CONST
45AC_C_INLINE
46
47# Library and installation utilities.
48#------------------------------------
49#     (Taken from Mark Calabretta's wcslib package)
50# Static library generation.
51AC_PROG_RANLIB
52# Installation utilities.
53#AC_PROG_LN_S
54#AC_PROG_INSTALL
55
56
57# Shared library generation.
58if test "x$ac_cv_c_compiler_gnu" = xyes ; then
59  # Note that -fPIC is on by default for Macs, this just makes it obvious.
60  SHRFLAGS="-fPIC"
61  SHRLD="\$(LINK) $SHRFLAGS"
62
63  case "$build_os" in
64  darwin*)
65    AC_MSG_NOTICE([ Using darwin build option])
66    SHRLIB="libduchamp.$PACKAGE_VERSION.dylib"
67    SHRLD="$SHRLD -dynamiclib -single_module"
68    SHRLD="$SHRLD -compatibility_version $PACKAGE_VERSION -current_version $PACKAGE_VERSION"
69    SHRLN="libduchamp.dylib"
70
71    case "$build_cpu" in
72    powerpc*)
73      AC_MSG_NOTICE([ Using darwin build option with powerpc subcase])         
74      # Switch off -fPIC (not applicable for Intel Macs).
75      CFLAGS="$CFLAGS -mdynamic-no-pic"
76      ;;
77    esac
78    ;;
79  *)
80    # Covers Linux and Solaris at least.
81    AC_MSG_NOTICE([ Using alternative (linux) build option])
82    SHRLIB="libduchamp.so.$PACKAGE_VERSION"
83    SHRLD="$SHRLD -shared -Wl,-soname,$SHRLIB"
84    SHRLN="libduchamp.so"
85    ;;
86  esac
87
88else
89    AC_MSG_NOTICE([ Not setting shared library options])
90  SHRLIB=
91  SHRFLAGS=
92  SHRLD=
93  SHRSFX=
94  SHRLN=
95fi
96
97AC_SUBST([SHRLIB])
98AC_SUBST([SHRFLAGS])
99AC_SUBST([SHRLD])
100AC_SUBST([SHRSFX])
101AC_SUBST([SHRLN])
102
103# Checks for library functions.
104AC_FUNC_STRTOD
105AC_CHECK_FUNCS([floor pow sqrt strtol log atan fabs])
106
107# Extra places to look for third-party include files and libraries.
108INCDIRS="$INCDIRS           \
109         /usr/include       \
110         /usr/local/include \
111         /usr/local/pgplot  \
112         /usr/local/cfitsio \
113         /usr/local/wcslib  \
114         /local/pgplot      \
115         /local/cfitsio     \
116         /opt/local/include"
117
118LIBDIRS="$LIBDIRS           \
119         /usr/lib           \
120         /usr/local/lib     \
121         /usr/local/pgplot  \
122         /usr/local/cfitsio \
123         /usr/local/wcslib  \
124         /local/lib         \
125         /local/pgplot      \
126         /local/cfitsio     \
127         /opt/SUNWspro/lib  \
128         /opt/local/lib"
129
130AC_MSG_NOTICE(LIBDIRS)
131
132for LIBDIR in $LIBDIRS ; do
133  AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
134done
135
136##########################################################################
137# Search for PGPLOT
138# use --with-pgplot=directory to specify a particular PGPLOT directory.
139# or  --without-pgplot or --with-pgplot=no to do without it
140# else do the normal searching for libraries.
141
142AC_MSG_NOTICE([  -- PGPLOT -- ])
143AC_ARG_WITH(pgplot,
144[
145AC_HELP_STRING([--with-pgplot=no],
146               [Compile without PGPLOT graphics capabilities.])
147AC_HELP_STRING([--without-pgplot],
148               [Compile without PGPLOT graphics capabilities.])
149AC_HELP_STRING([--with-pgplot=<dir>],
150               [Compile with PGPLOT graphics capabilities, using the directory <dir> to specify the PGPLOT library.]),
151],
152[
153if test "x$withval" != xno; then
154AC_MSG_NOTICE([Using directory "$withval"])
155PGPLOTINCDIRS=$withval
156PGPLOTLIBDIRS=$withval
157LDFLAGS="$LDFLAGS -L$withval"
158fi
159],
160[
161PGPLOTINCDIRS=$INCDIRS
162PGPLOTLIBDIRS=$LIBDIRS
163])
164
165if test "x$PGPLOTLIBDIRS" = x; then
166  #the argument to --with-pgplot was no, so we don't look for it.
167  AC_MSG_NOTICE([Not enabling PGPLOT use.])
168
169else
170
171  #Set up the PGPLOT-related libraries and includes.
172
173  for INCDIR in $PGPLOTINCDIRS ; do
174    AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
175    AC_CHECK_FILE([$INCDIR/pgplot/cpgplot.h], [PGPLOTINC=-I$INCDIR/pgplot; break])
176    AC_CHECK_FILE([$INCDIR/include/cpgplot.h], [PGPLOTINC=-I$INCDIR/include; break])
177  done
178 
179  # PGPLOT compiled with a SUN compiler but linked with something else.
180  AC_CHECK_LIB([sunmath], [cosd],      [EXTRAPGLIB="-lsunmath $EXTRAPGLIB"],
181               [], [$EXTRAPGLIB $LIBS])
182  AC_CHECK_LIB([M77],     [iand_],     [EXTRAPGLIB="-lM77 $EXTRAPGLIB"],
183               [], [$EXTRAPGLIB $LIBS])
184  AC_CHECK_LIB([F77],     [f77_init],  [EXTRAPGLIB="-lF77 $EXTRAPGLIB"],
185               [], [$EXTRAPGLIB $LIBS])
186 
187  # Search for X11 includes and libraries.
188  AC_PATH_XTRA()
189  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])
190  # returns C compiler flags needed for X to X_CFLAGS and the X linker flags to X_LIBS
191  if test "x$X_LIBS" != x; then
192    LDFLAGS="$LDFLAGS $X_LIBS"
193    EXTRAPGLIB="$X_LIBS $X_PRE_LIBS -lX11 $EXTRAPGLIB"
194  fi
195
196  # It is possible that other libraries may be required depending on what
197  # graphics drivers were installed with PGPLOT.
198  AC_CHECK_LIB([z],       [deflate],   [EXTRAPGLIB="$EXTRAPGLIB -lz"],
199               [], [$EXTRAPGLIB $LIBS])
200  AC_CHECK_LIB([png],     [png_error], [EXTRAPGLIB="$EXTRAPGLIB -lpng"],
201             [], [$EXTRAPGLIB $LIBS])
202
203  AC_LANG([Fortran 77])
204
205  AC_CHECK_LIB([pgplot],  [pgopen],    [PGPLOTLIB="-lpgplot"],
206               [], [$PGPLOTLIB $EXTRAPGLIB])
207  AC_LANG(C)
208  # Checks for extra libraries needed by PGPLOT -- will add -lg2c -lstdc++ to $LIBS
209  AC_CHECK_LIB([g2c], [gerror_])
210  AC_CHECK_LIB([stdc++], [main])
211  AC_CHECK_LIB([c++], [main])
212
213  # Need to link with libgfortran when we've used the gfortran
214  # compiler for pgplot
215  if test "x$F77" = xgfortran; then
216    AC_CHECK_LIB([gfortran], [_gfortran_getenv], [PGPLOTLIB="$PGPLOTLIB -lgfortran"], [], [])
217  fi
218
219    AC_CHECK_LIB([cpgplot], [cpgopen],   [PGPLOTLIB="-lcpgplot $PGPLOTLIB"], [], [$PGPLOTLIB $LIBS $EXTRAPGLIB])
220
221  # If PGPLOT is not present, we give a warning message but still continue.
222  # The compilation is able to work without the PGPLOT-dependent files.
223  if test "x$PGPLOTLIB" = x; then
224    AC_MSG_NOTICE([
225      -------------------------------------------------------
226      WARNING! PGPLOT could not be found.
227      Compiling Duchamp without graphics capabilities.               
228      -------------------------------------------------------])
229  else
230    PGPLOTLIB="$PGPLOTLIB $EXTRAPGLIB $LIBS"
231    AC_MSG_NOTICE([PGPLOT appears to be available.])
232    AC_DEFINE([HAVE_PGPLOT], [1], [Define to 1 if PGPLOT is available.])
233    for LIBDIR in $PGPLOTLIBDIRS ; do
234     AC_CHECK_FILE([$LIBDIR/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR $PGPLOTLIB"; break])
235     AC_CHECK_FILE([$LIBDIR/lib/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR/lib $PGPLOTLIB"; break])
236     AC_CHECK_FILE([$LIBDIR/pgplot/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR/pgplot $PGPLOTLIB"; break])
237    done
238   
239  fi
240
241fi
242
243
244AC_SUBST([LINKER])
245AC_SUBST([PGPLOTINC])
246AC_SUBST([PGPLOTLIB])
247##########################################################################
248
249##########################################################################
250# Search for CFITSIO.
251# use --with-cfitsio=directory to specify a particular CFITSIO directory.
252# else do the normal searching for libraries.
253
254AC_MSG_NOTICE([  -- CFITSIO -- ])
255AC_ARG_WITH(cfitsio,
256        AC_HELP_STRING([--with-cfitsio=<dir>],
257                       [The CFITSIO library and include files are in directory <dir>.]),
258[ #if we specify a directory...
259if test "x$withval" = xno; then
260  AC_MSG_NOTICE([
261    The CFITSIO library is required.
262    Ignoring the "--with-cfitsio=no" and searching for the library.], [1])
263  CFITSIOINCDIRS=$INCDIRS
264  CFITSIOLIBDIRS=$LIBDIRS
265else
266  AC_MSG_NOTICE([Using directory "$withval"])
267  CFITSIOINCDIRS="$withval \
268              $withval/include"
269  CFITSIOLIBDIRS="$withval \
270              $withval/lib"
271  for LIBDIR in $CFITSIOLIBDIRS ; do
272    AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
273  done
274  for INCDIR in $CFITSIOINCDIRS ; do
275    AC_CHECK_FILE([$INCDIR], [CPPFLAGS="$CPPFLAGS -I$INCDIR"], [continue])
276  done
277fi
278],
279[ # if directory not specified, go searching.
280CFITSIOINCDIRS=$INCDIRS
281CFITSIOLIBDIRS=$LIBDIRS
282])
283
284for INCDIR in $CFITSIOINCDIRS ; do
285  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
286  INCDIR=$INCDIR/cfitsio
287  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
288done
289
290AC_CHECK_LIB([socket],  [recv],   [CFITSIOLIB="$CFITSIOLIB -lsocket"], [], [$LIBS])
291AC_CHECK_LIB([cfitsio], [ffopen], [CFITSIOLIB="$CFITSIOLIB -lcfitsio"], [],
292             [$CFITSIOLIB $LIBS])
293
294# CFITSIO is essential for Duchamp, so exit with error message if it
295#   is not present.
296if test "x$CFITSIOINC" = x -o "x$CFITSIOLIB" = x; then
297  AC_MSG_ERROR([
298    -------------------------------------------------------
299    Could not find the CFITSIO library.
300
301    ERROR: Duchamp configuration failure.
302    -------------------------------------------------------], [1])
303else
304  AC_MSG_NOTICE([CFITSIO appears to be available.])
305  AC_DEFINE([HAVE_CFITSIO], [1], [Define to 1 if CFITSIO is available.])
306for LIBDIR in $CFITSIOLIBDIRS ; do
307  AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
308  LIBDIR=$LIBDIR/cfitsio
309  AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
310done
311
312fi
313
314AC_SUBST([CFITSIOINC])
315AC_SUBST([CFITSIOLIB])
316##########################################################################
317
318##########################################################################
319# Search for WCSLIB.
320# use --with-wcslib=directory to specify a particular WCSLIB directory.
321# else do the normal searching for libraries.
322
323AC_MSG_NOTICE([  -- WCSLIB -- ])
324WCSINCDIR=""
325AC_ARG_WITH(wcslib,
326        AC_HELP_STRING([--with-wcslib=<dir>],
327                       [The WCSLIB library and include files are in directory <dir>.]),
328[ #if we specify a directory...
329if test "x$withval" = xno; then
330  AC_MSG_NOTICE([
331    The WCSLIB library is required.
332    Ignoring the "--with-wcslib=no" and searching for the library.], [1])
333  WCSINCDIRS=$INCDIRS
334  WCSLIBDIRS=$LIBDIRS
335else
336  AC_MSG_NOTICE([Using directory "$withval"])
337  WCSINCDIRS="$withval \
338              $withval/include"
339  WCSLIBDIRS="$withval \
340              $withval/lib"
341  for LIBDIR in $WCSLIBDIRS ; do
342    AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
343  done
344  for INCDIR in $WCSINCDIRS ; do
345    AC_CHECK_FILE([$INCDIR/wcslib],
346                  [CPPFLAGS="$CPPFLAGS -I$INCDIR"; WCSINCDIR=$INCDIR; break],
347                  [continue])
348  done
349fi
350],
351[ # if directory not specified, go searching.
352WCSINCDIRS=$INCDIRS
353WCSLIBDIRS=$LIBDIRS
354])
355
356
357if test "x$WCSINCDIR" = x; then
358  for INCBASE in $WCSINCDIRS ; do
359    AC_CHECK_FILE([$INCBASE/wcslib/wcs.h], [WCSINC="-I$INCBASE -I$INCBASE/wcslib $WCSINC"; break])
360  done
361else
362  AC_CHECK_FILE([$WCSINCDIR/wcslib/wcs.h], [WCSINC="-I$WCSINCDIR -I$WCSINCDIR/wcslib $WCSINC"])
363fi
364
365
366# Look for libwcs.a, and libpgsbox.a
367AC_CHECK_LIB([wcs], [wcss2p], [WCSLIB="$WCSLIB -lwcs"], [],
368             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
369
370# Only use libpgsbox if we have pgplot enabled - determine this by testing the PGPLOTINCDIRS variable
371if test "x$PGPLOTINCDIRS" != x; then
372     AC_CHECK_LIB([pgsbox], [cpgsbox], [WCSLIB="$WCSLIB -lpgsbox"], [],
373                 [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
374fi
375
376# WCSLIB is essential for Duchamp, so exit with error message if it
377#   is not present. Need at least libwcs to be available -- libpgsbox will
378#   depend on PGPLOT being available, but is not critical.
379if test "x$WCSINC" = x -o "x$WCSLIB" = x; then
380  AC_MSG_ERROR([
381    -------------------------------------------------------
382    Could not find the WCSLIB library.
383
384    ERROR: Duchamp configuration failure.
385    -------------------------------------------------------], [1])
386else
387  AC_MSG_NOTICE([WCSLIB appears to be available.])
388  AC_DEFINE([HAVE_WCSLIB], [1], [Define to 1 if WCSLIB is available.])
389# Now add the -L statements to start of WCSLIB.
390# Search for libwcs.a, and, if we find it, search for libpgsbox in same directory and
391#   then in other directories, keeping the appropriate order of -L calls.
392
393  DIRLIST=". \
394           wcs \
395           wcslib"
396
397  for LIBBASE in $WCSLIBDIRS ; do
398    for DIR in $DIRLIST; do
399      if test "x$DIR" = x.; then
400       LIBDIR=$LIBBASE
401      else
402       LIBDIR="$LIBBASE/$DIR"
403      fi
404      AC_CHECK_FILE([$LIBDIR/libwcs.a],
405             [WCSLIBFRONT="-L$LIBDIR";
406             AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [], [
407               for LIBBASE2 in $WCSLIBDIRS ; do
408                for DIR2 in $DIRLIST; do
409                 if test "x$DIR" = x.; then
410                  LIBDIR=$LIBBASE
411                 else
412                  LIBDIR="$LIBBASE/$DIR"
413                 fi
414                 AC_CHECK_FILE([$LIBDIR2/libpgsbox.a],
415                               [WCSLIBFRONT="$WCSLIB -L$LIBDIR2"; break])
416                done
417               done])
418              break])
419    done
420  done
421  WCSLIB="$WCSLIBFRONT $WCSLIB"
422fi
423
424AC_SUBST([WCSINC])
425AC_SUBST([WCSLIB])
426##########################################################################
427
428AC_SUBST([LDFLAGS])
429
430AC_CONFIG_FILES([Makefile])
431AC_OUTPUT
Note: See TracBrowser for help on using the repository browser.