source: trunk/configure.ac @ 1088

Last change on this file since 1088 was 1088, checked in by MatthewWhiting, 12 years ago

Updating the version number in configure, a few updates to CHANGES, and a cleanest target in Makefile to remove the configure-generated content

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