source: trunk/configure.ac @ 1283

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

Final updates of version number to 1.5, and setting the release date in the User's guide

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