source: trunk/configure.ac @ 108

Last change on this file since 108 was 108, checked in by Matthew Whiting, 18 years ago

Changed source tree structure: added a src/ directory that contains all the
code. Makefile.in and configure.ac changed to match.

File size: 7.1 KB
Line 
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.57)
5AC_INIT([Duchamp], [1.0], [matthew.whiting@csiro.au])
6AC_CONFIG_SRCDIR([src/param.cc])
7AC_CONFIG_HEADER([config.h])
8
9# Checks for programs.
10AC_PROG_CXX
11AC_PROG_CC
12AC_PROG_CPP
13
14# Checks for libraries.
15# FIXME: Replace `main' with a function in `-lX11':
16#AC_CHECK_LIB([X11], [main])
17# FIXME: Replace `main' with a function in `-lcfitsio':
18#AC_CHECK_LIB([cfitsio], [main])
19# FIXME: Replace `main' with a function in `-lcpgplot':
20#AC_CHECK_LIB([cpgplot], [main])
21# FIXME: Replace `main' with a function in `-lg2c':
22AC_CHECK_LIB([g2c], [gerror_])
23# FIXME: Replace `main' with a function in `-lm':
24AC_CHECK_LIB([m], [log])
25# FIXME: Replace `main' with a function in `-lpgplot':
26#AC_CHECK_LIB([pgplot], [main])
27# FIXME: Replace `main' with a function in `-lpgsbox':
28#AC_CHECK_LIB([pgsbox], [main])
29# FIXME: Replace `main' with a function in `-lwcs':
30#AC_CHECK_LIB([wcs], [main])
31
32# Checks for header files.
33AC_HEADER_STDC
34AC_CHECK_HEADERS([stdlib.h string.h unistd.h time.h math.h])
35
36# Checks for typedefs, structures, and compiler characteristics.
37AC_HEADER_STDBOOL
38AC_C_CONST
39AC_C_INLINE
40
41# Checks for library functions.
42AC_FUNC_STRTOD
43AC_CHECK_FUNCS([floor pow sqrt strtol log atan fabs])
44
45# Extra places to look for third-party include files and libraries.
46INCDIRS="$INCDIRS           \
47         /usr/include       \
48         /usr/local/include \
49         /usr/local/pgplot  \
50         /usr/local/cfitsio \
51         /usr/local/wcslib  \
52         /local/pgplot      \
53         /local/cfitsio"
54
55LIBDIRS="$LIBDIRS           \
56         /usr/lib           \
57         /usr/local/lib     \
58         /usr/local/pgplot  \
59         /usr/local/cfitsio \
60         /usr/local/wcslib  \
61         /local/lib         \
62         /local/pgplot      \
63         /local/cfitsio     \
64         /u/whi550/CubeFinder\
65         /opt/SUNWspro/lib"
66
67AC_MSG_NOTICE(LIBDIRS)
68
69for LIBDIR in $LIBDIRS ; do
70  AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue])
71done
72
73##########################################################################
74# Search for PGPLOT
75
76for INCDIR in $INCDIRS ; do
77  AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
78  INCDIR=$INCDIR/pgplot
79  AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break])
80done
81
82# PGPLOT compiled with a SUN compiler but linked with something else.
83AC_CHECK_LIB([sunmath], [cosd],      [PGPLOTLIB="-lsunmath $PGPLOTLIB"],
84             [], [$PGPLOTLIB $LIBS])
85AC_CHECK_LIB([M77],     [iand_],     [PGPLOTLIB="-lM77 $PGPLOTLIB"],
86             [], [$PGPLOTLIB $LIBS])
87AC_CHECK_LIB([F77],     [f77_init],  [PGPLOTLIB="-lF77 $PGPLOTLIB"],
88             [], [$PGPLOTLIB $LIBS])
89# PGPLOT compiled with a GNU compiler but linked with something else.
90AC_CHECK_LIB([m],       [log],       [PGPLOTLIB="-lm $PGPLOTLIB"])
91AC_CHECK_LIB([g2c],     [gerror_],   [PGPLOTLIB="-lg2c $PGPLOTLIB"],
92             [], [$PGPLOTLIB $LIBS])
93
94# Search for X11 includes and libraries.
95AC_PATH_X
96if test "x$ac_x_libraries" != x; then
97  LDFLAGS="$LDFLAGS -L$ac_x_libraries"
98  PGPLOTLIB="-lX11 $PGPLOTLIB"
99fi
100
101# It is possible that other libraries may be required depending on what
102# graphics drivers were installed with PGPLOT.
103AC_CHECK_LIB([z],       [deflate],   [PGPLOTLIB="-lz $PGPLOTLIB"],
104             [], [$PGPLOTLIB $LIBS])
105AC_CHECK_LIB([png],     [png_error], [PGPLOTLIB="-lpng $PGPLOTLIB"],
106             [], [$PGPLOTLIB $LIBS])
107AC_CHECK_LIB([pgplot],  [pgbeg_],    [PGPLOTLIB="-lpgplot $PGPLOTLIB"],
108             [], [$PGPLOTLIB $LIBS])
109AC_CHECK_LIB([cpgplot], [cpgopen],   [PGPLOTLIB="-lcpgplot $PGPLOTLIB"],
110             [PGPLOTLIB=], [$PGPLOTLIB $LIBS])
111
112if test "x$PGPLOTLIB" = x; then
113  AC_MSG_ERROR([
114    -------------------------------------------------------
115    Could not find the PGPLOT library.
116
117    ERROR: Duchamp configuration failure.
118    -------------------------------------------------------], [1])
119else
120  AC_MSG_NOTICE([PGPLOT appears to be available.])
121  AC_DEFINE([HAVE_PGPLOT], [1], [Define to 1 if PGPLOT is available.])
122fi
123
124AC_SUBST([PGPLOTINC])
125AC_SUBST([PGPLOTLIB])
126##########################################################################
127
128##########################################################################
129# Search for CFITSIO.
130for INCDIR in $INCDIRS ; do
131  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
132  INCDIR=$INCDIR/cfitsio
133  AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break])
134done
135
136AC_CHECK_LIB([socket],  [recv],   [CFITSIOLIB="-lsocket"], [], [$LIBS])
137AC_CHECK_LIB([cfitsio], [ffopen], [CFITSIOLIB="-lcfitsio $CFITSIOLIB"], [],
138             [$CFITSIOLIB $LIBS])
139
140if test "x$CFITSIOINC" = x -o "x$CFITSIOLIB" = x; then
141  AC_MSG_ERROR([
142    -------------------------------------------------------
143    Could not find the CFITSIO library.
144
145    ERROR: Duchamp configuration failure.
146    -------------------------------------------------------], [1])
147else
148  for LIBDIR in $LIBDIRS ; do
149    AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
150    LIBDIR=$LIBDIR/cfitsio
151    AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break])
152  done
153  # Make sure that ffhdr2str is in the library -- exit if not
154#  AC_CHECK_LIB([cfitsio], [ffhdr2str], [CFITSIOLIB="$CFITSIOLIB"],
155#               [AC_MSG_ERROR([
156#    -------------------------------------------------------
157#    CFITSIO library does not have function ffhdr2str.
158#    Please upgrade your CFITSIO library.
159#
160#    ERROR: Duchamp configuration failure.
161#    -------------------------------------------------------])],
162#               [$CFITSIOLIB $LIBS])
163#
164  AC_MSG_NOTICE([CFITSIO appears to be available.])
165  AC_DEFINE([HAVE_CFITSIO], [1], [Define to 1 if CFITSIO is available.])
166fi
167
168AC_SUBST([CFITSIOINC])
169AC_SUBST([CFITSIOLIB])
170##########################################################################
171
172##########################################################################
173# Search for WCSLIB.
174for INCDIR in $INCDIRS ; do
175  AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break])
176  INCDIR=$INCDIR/wcslib
177  AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break])
178done
179for INCDIR in $INCDIRS ; do
180  AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break])
181  INCDIR=$INCDIR/wcslib
182  AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break])
183done
184
185AC_CHECK_LIB([wcs], [wcss2p], [WCSLIB="-lwcs $WCSLIB"], [],
186             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
187AC_CHECK_LIB([pgsbox], [cpgsbox], [WCSLIB="-lpgsbox $WCSLIB"], [],
188             [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB])
189
190if test "x$WCSINC" = x -o "x$WCSLIB" = x; then
191  AC_MSG_ERROR([
192    -------------------------------------------------------
193    Could not find the WCSLIB library.
194
195    ERROR: Duchamp configuration failure.
196    -------------------------------------------------------], [1])
197else
198  AC_MSG_NOTICE([WCSLIB appears to be available.])
199  AC_DEFINE([HAVE_WCSLIB], [1], [Define to 1 if WCSLIB is available.])
200fi
201
202AC_SUBST([WCSINC])
203AC_SUBST([WCSLIB])
204##########################################################################
205
206AC_SUBST([LDFLAGS])
207
208AC_CONFIG_FILES([Makefile])
209AC_OUTPUT
Note: See TracBrowser for help on using the repository browser.