1 | # -*- Autoconf -*- |
---|
2 | # Process this file with autoconf to produce a configure script. |
---|
3 | |
---|
4 | AC_PREREQ(2.57) |
---|
5 | AC_INIT([Duchamp], [1.1.1], [Matthew.Whiting@csiro.au]) |
---|
6 | AC_CONFIG_SRCDIR([src/duchamp.hh]) |
---|
7 | AC_CONFIG_HEADER([src/config.h]) |
---|
8 | AC_PREFIX_DEFAULT(/usr/local) |
---|
9 | |
---|
10 | # Checks for programs. |
---|
11 | AC_PROG_CXX |
---|
12 | AC_PROG_CC |
---|
13 | AC_PROG_CPP |
---|
14 | AC_PROG_LN_S |
---|
15 | AC_CHECK_PROGS(INSTALL, install) |
---|
16 | |
---|
17 | # Check for maths library -- will add -lm to $LIBS |
---|
18 | AC_CHECK_LIB([m], [log]) |
---|
19 | |
---|
20 | # Checks for header files. |
---|
21 | AC_HEADER_STDC |
---|
22 | AC_CHECK_HEADERS([unistd.h time.h math.h iostream fstream sstream iomanip vector string algorithm functional]) |
---|
23 | if test "x$ac_cv_header_stdc" = xno; then |
---|
24 | AC_MSG_ERROR([ |
---|
25 | ------------------------------------------------------------------- |
---|
26 | An ANSI standard C library is required to build Duchamp. |
---|
27 | One of the ANSI C header files it requires is missing or unusable. |
---|
28 | |
---|
29 | ERROR: Duchamp configuration failure. |
---|
30 | -------------------------------------------------------------------], [1]) |
---|
31 | fi |
---|
32 | |
---|
33 | # Checks for typedefs, structures, and compiler characteristics. |
---|
34 | AC_HEADER_STDBOOL |
---|
35 | AC_C_CONST |
---|
36 | AC_C_INLINE |
---|
37 | |
---|
38 | # Utilities. |
---|
39 | AC_PROG_RANLIB |
---|
40 | |
---|
41 | # Checks for library functions. |
---|
42 | AC_FUNC_STRTOD |
---|
43 | AC_CHECK_FUNCS([floor pow sqrt strtol log atan fabs]) |
---|
44 | |
---|
45 | # Extra places to look for third-party include files and libraries. |
---|
46 | INCDIRS="$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 | /opt/local/include" |
---|
55 | |
---|
56 | LIBDIRS="$LIBDIRS \ |
---|
57 | /usr/lib \ |
---|
58 | /usr/local/lib \ |
---|
59 | /usr/local/pgplot \ |
---|
60 | /usr/local/cfitsio \ |
---|
61 | /usr/local/wcslib \ |
---|
62 | /local/lib \ |
---|
63 | /local/pgplot \ |
---|
64 | /local/cfitsio \ |
---|
65 | /opt/SUNWspro/lib \ |
---|
66 | /opt/local/lib" |
---|
67 | |
---|
68 | AC_MSG_NOTICE(LIBDIRS) |
---|
69 | |
---|
70 | for LIBDIR in $LIBDIRS ; do |
---|
71 | AC_CHECK_FILE([$LIBDIR], [LDFLAGS="$LDFLAGS -L$LIBDIR"], [continue]) |
---|
72 | done |
---|
73 | |
---|
74 | ########################################################################## |
---|
75 | # Search for PGPLOT |
---|
76 | # use --with-cfitsio=directory to specify a particular PGPLOT directory. |
---|
77 | # or --without-pgplot or --with-pgplot=no to do without it |
---|
78 | # else do the normal searching for libraries. |
---|
79 | |
---|
80 | AC_MSG_NOTICE([ -- PGPLOT -- ]) |
---|
81 | AC_ARG_WITH(pgplot, |
---|
82 | [ |
---|
83 | AC_HELP_STRING([--with-pgplot=no], |
---|
84 | [Compile without PGPLOT graphics capabilities.]) |
---|
85 | AC_HELP_STRING([--without-pgplot], |
---|
86 | [Compile without PGPLOT graphics capabilities.]) |
---|
87 | AC_HELP_STRING([--with-pgplot=<dir>], |
---|
88 | [Compile with PGPLOT graphics capabilities, using the directory <dir> to specify the PGPLOT library.]), |
---|
89 | ], |
---|
90 | [ |
---|
91 | if test "x$withval" != xno; then |
---|
92 | AC_MSG_NOTICE([Using directory "$withval"]) |
---|
93 | PGPLOTINCDIRS=$withval |
---|
94 | PGPLOTLIBDIRS=$withval |
---|
95 | LDFLAGS="$LDFLAGS -L$withval" |
---|
96 | fi |
---|
97 | ], |
---|
98 | [ |
---|
99 | PGPLOTINCDIRS=$INCDIRS |
---|
100 | PGPLOTLIBDIRS=$LIBDIRS |
---|
101 | ]) |
---|
102 | |
---|
103 | if test "x$PGPLOTLIBDIRS" = x; then |
---|
104 | #the argument to --with-pgplot was no, so we don't look for it. |
---|
105 | AC_MSG_NOTICE([Not enabling PGPLOT use.]) |
---|
106 | else |
---|
107 | |
---|
108 | #Set up the PGPLOT-related libraries and includes. |
---|
109 | |
---|
110 | for INCDIR in $PGPLOTINCDIRS ; do |
---|
111 | AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break]) |
---|
112 | INCDIR=$INCDIR/pgplot |
---|
113 | AC_CHECK_FILE([$INCDIR/cpgplot.h], [PGPLOTINC=-I$INCDIR; break]) |
---|
114 | done |
---|
115 | |
---|
116 | # PGPLOT compiled with a SUN compiler but linked with something else. |
---|
117 | AC_CHECK_LIB([sunmath], [cosd], [PGPLOTLIB="-lsunmath $PGPLOTLIB"], |
---|
118 | [], [$PGPLOTLIB $LIBS]) |
---|
119 | AC_CHECK_LIB([M77], [iand_], [PGPLOTLIB="-lM77 $PGPLOTLIB"], |
---|
120 | [], [$PGPLOTLIB $LIBS]) |
---|
121 | AC_CHECK_LIB([F77], [f77_init], [PGPLOTLIB="-lF77 $PGPLOTLIB"], |
---|
122 | [], [$PGPLOTLIB $LIBS]) |
---|
123 | |
---|
124 | # Checks for extra libraries needed by PGPLOT -- will add -lg2c to $LIBS |
---|
125 | AC_CHECK_LIB([g2c], [gerror_]) |
---|
126 | |
---|
127 | # Search for X11 includes and libraries. |
---|
128 | AC_PATH_X |
---|
129 | if test "x$ac_x_libraries" != x; then |
---|
130 | LDFLAGS="$LDFLAGS -L$ac_x_libraries" |
---|
131 | PGPLOTLIB="-L$ac_x_libraries -lX11 $PGPLOTLIB" |
---|
132 | fi |
---|
133 | |
---|
134 | # It is possible that other libraries may be required depending on what |
---|
135 | # graphics drivers were installed with PGPLOT. |
---|
136 | AC_CHECK_LIB([z], [deflate], [PGPLOTLIB="-lz $PGPLOTLIB"], |
---|
137 | [], [$PGPLOTLIB $LIBS]) |
---|
138 | AC_CHECK_LIB([png], [png_error], [PGPLOTLIB="-lpng $PGPLOTLIB"], |
---|
139 | [], [$PGPLOTLIB $LIBS]) |
---|
140 | AC_CHECK_LIB([pgplot], [pgbeg_], [PGPLOTLIB="-lpgplot $PGPLOTLIB"], |
---|
141 | [], [$PGPLOTLIB $LIBS]) |
---|
142 | AC_CHECK_LIB([cpgplot], [cpgopen], [PGPLOTLIB="-lcpgplot $PGPLOTLIB"], |
---|
143 | [], [$PGPLOTLIB $LIBS]) |
---|
144 | |
---|
145 | PGPLOTLIB="$PGPLOTLIB $LIBS" |
---|
146 | |
---|
147 | # If PGPLOT is not present, we give a warning message but still continue. |
---|
148 | # The compilation is able to work without the PGPLOT-dependent files. |
---|
149 | if test "x$PGPLOTLIB" = x; then |
---|
150 | AC_MSG_NOTICE([ |
---|
151 | ------------------------------------------------------- |
---|
152 | WARNING! PGPLOT could not be found. |
---|
153 | Compiling Duchamp without graphics capabilities. |
---|
154 | -------------------------------------------------------]) |
---|
155 | else |
---|
156 | AC_MSG_NOTICE([PGPLOT appears to be available.]) |
---|
157 | AC_DEFINE([HAVE_PGPLOT], [1], [Define to 1 if PGPLOT is available.]) |
---|
158 | for LIBDIR in $PGPLOTLIBDIRS ; do |
---|
159 | AC_CHECK_FILE([$LIBDIR/libcpgplot.a], [PGPLOTLIB="-L$LIBDIR $PGPLOTLIB"; break]) |
---|
160 | done |
---|
161 | fi |
---|
162 | |
---|
163 | fi |
---|
164 | |
---|
165 | AC_SUBST([PGPLOTINC]) |
---|
166 | AC_SUBST([PGPLOTLIB]) |
---|
167 | ########################################################################## |
---|
168 | |
---|
169 | ########################################################################## |
---|
170 | # Search for CFITSIO. |
---|
171 | # use --with-cfitsio=directory to specify a particular CFITSIO directory. |
---|
172 | # else do the normal searching for libraries. |
---|
173 | |
---|
174 | AC_MSG_NOTICE([ -- CFITSIO -- ]) |
---|
175 | AC_ARG_WITH(cfitsio, |
---|
176 | AC_HELP_STRING([--with-cfitsio=<dir>], |
---|
177 | [The CFITSIO library and include files are in directory <dir>.]), |
---|
178 | [ #if we specify a directory... |
---|
179 | if test "x$withval" = xno; then |
---|
180 | AC_MSG_NOTICE([ |
---|
181 | The CFITSIO library is required. |
---|
182 | Ignoring the "--with-cfitsio=no" and searching for the library.], [1]) |
---|
183 | CFITSIOINCDIRS=$INCDIRS |
---|
184 | CFITSIOLIBDIRS=$LIBDIRS |
---|
185 | else |
---|
186 | AC_MSG_NOTICE([Using directory "$withval"]) |
---|
187 | CFITSIOINCDIRS="$withval \ |
---|
188 | $withval/include" |
---|
189 | CFITSIOLIBDIRS="$withval \ |
---|
190 | $withval/lib" |
---|
191 | fi |
---|
192 | ], |
---|
193 | [ # if directory not specified, go searching. |
---|
194 | CFITSIOINCDIRS=$INCDIRS |
---|
195 | CFITSIOLIBDIRS=$LIBDIRS |
---|
196 | ]) |
---|
197 | |
---|
198 | for INCDIR in $CFITSIOINCDIRS ; do |
---|
199 | AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break]) |
---|
200 | INCDIR=$INCDIR/cfitsio |
---|
201 | AC_CHECK_FILE([$INCDIR/fitsio.h], [CFITSIOINC=-I$INCDIR; break]) |
---|
202 | done |
---|
203 | |
---|
204 | AC_CHECK_LIB([socket], [recv], [CFITSIOLIB="-lsocket"], [], [$LIBS]) |
---|
205 | AC_CHECK_LIB([cfitsio], [ffopen], [CFITSIOLIB="-lcfitsio $CFITSIOLIB"], [], |
---|
206 | [$CFITSIOLIB $LIBS]) |
---|
207 | |
---|
208 | # CFITSIO is essential for Duchamp, so exit with error message if it |
---|
209 | # is not present. |
---|
210 | if test "x$CFITSIOINC" = x -o "x$CFITSIOLIB" = x; then |
---|
211 | AC_MSG_ERROR([ |
---|
212 | ------------------------------------------------------- |
---|
213 | Could not find the CFITSIO library. |
---|
214 | |
---|
215 | ERROR: Duchamp configuration failure. |
---|
216 | -------------------------------------------------------], [1]) |
---|
217 | else |
---|
218 | for LIBDIR in $CFITSIOLIBDIRS ; do |
---|
219 | AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break]) |
---|
220 | LIBDIR=$LIBDIR/cfitsio |
---|
221 | AC_CHECK_FILE([$LIBDIR/libcfitsio.a], [CFITSIOLIB="-L$LIBDIR $CFITSIOLIB"; break]) |
---|
222 | done |
---|
223 | AC_MSG_NOTICE([CFITSIO appears to be available.]) |
---|
224 | AC_DEFINE([HAVE_CFITSIO], [1], [Define to 1 if CFITSIO is available.]) |
---|
225 | fi |
---|
226 | |
---|
227 | AC_SUBST([CFITSIOINC]) |
---|
228 | AC_SUBST([CFITSIOLIB]) |
---|
229 | ########################################################################## |
---|
230 | |
---|
231 | ########################################################################## |
---|
232 | # Search for WCSLIB. |
---|
233 | # use --with-cfitsio=directory to specify a particular CFITSIO directory. |
---|
234 | # else do the normal searching for libraries. |
---|
235 | |
---|
236 | AC_MSG_NOTICE([ -- WCSLIB -- ]) |
---|
237 | AC_ARG_WITH(wcslib, |
---|
238 | AC_HELP_STRING([--with-wcslib=<dir>], |
---|
239 | [The WCSLIB library and include files are in directory <dir>.]), |
---|
240 | [ #if we specify a directory... |
---|
241 | if test "x$withval" = xno; then |
---|
242 | AC_MSG_NOTICE([ |
---|
243 | The WCSLIB library is required. |
---|
244 | Ignoring the "--with-wcslib=no" and searching for the library.], [1]) |
---|
245 | CFITSIOINCDIRS=$INCDIRS |
---|
246 | CFITSIOLIBDIRS=$LIBDIRS |
---|
247 | else |
---|
248 | AC_MSG_NOTICE([Using directory "$withval"]) |
---|
249 | WCSINCDIRS="$withval \ |
---|
250 | $withval/include" |
---|
251 | WCSLIBDIRS="$withval \ |
---|
252 | $withval/lib" |
---|
253 | fi |
---|
254 | ], |
---|
255 | [ # if directory not specified, go searching. |
---|
256 | WCSINCDIRS=$INCDIRS |
---|
257 | WCSLIBDIRS=$LIBDIRS |
---|
258 | ]) |
---|
259 | |
---|
260 | for INCDIR in $WCSINCDIRS ; do |
---|
261 | AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break]) |
---|
262 | INCDIR=$INCDIR/wcslib |
---|
263 | AC_CHECK_FILE([$INCDIR/cpgsbox.h], [WCSINC="-I$INCDIR $WCSINC"; break]) |
---|
264 | done |
---|
265 | for INCDIR in $WCSINCDIRS ; do |
---|
266 | AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break]) |
---|
267 | INCDIR=$INCDIR/wcslib |
---|
268 | AC_CHECK_FILE([$INCDIR/wcs.h], [WCSINC="-I$INCDIR $WCSINC"; break]) |
---|
269 | done |
---|
270 | |
---|
271 | AC_CHECK_LIB([pgsbox], [cpgsbox], [WCSLIB="-lpgsbox $WCSLIB"], [], |
---|
272 | [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB]) |
---|
273 | AC_CHECK_LIB([wcs], [wcss2p], [WCSLIB="-lwcs $WCSLIB"], [], |
---|
274 | [$WCSLIB $LIBS $CFITSIOLIB $PGPLOTLIB]) |
---|
275 | |
---|
276 | # WCSLIB is essential for Duchamp, so exit with error message if it |
---|
277 | # is not present. Need at least libwcs to be available -- libpgsbox will |
---|
278 | # depend on PGPLOT being available, but is not critical. |
---|
279 | if test "x$WCSINC" = x -o "x$WCSLIB" = x; then |
---|
280 | AC_MSG_ERROR([ |
---|
281 | ------------------------------------------------------- |
---|
282 | Could not find the WCSLIB library. |
---|
283 | |
---|
284 | ERROR: Duchamp configuration failure. |
---|
285 | -------------------------------------------------------], [1]) |
---|
286 | else |
---|
287 | for LIBDIR in $WCSLIBDIRS ; do |
---|
288 | AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break]) |
---|
289 | LIBDIR=$LIBDIR/wcs |
---|
290 | AC_CHECK_FILE([$LIBDIR/libpgsbox.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break]) |
---|
291 | done |
---|
292 | for LIBDIR in $WCSLIBDIRS ; do |
---|
293 | AC_CHECK_FILE([$LIBDIR/libwcs.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break]) |
---|
294 | LIBDIR=$LIBDIR/wcs |
---|
295 | AC_CHECK_FILE([$LIBDIR/libwcs.a], [WCSLIB="-L$LIBDIR $WCSLIB"; break]) |
---|
296 | done |
---|
297 | AC_MSG_NOTICE([WCSLIB appears to be available.]) |
---|
298 | AC_DEFINE([HAVE_WCSLIB], [1], [Define to 1 if WCSLIB is available.]) |
---|
299 | fi |
---|
300 | |
---|
301 | AC_SUBST([WCSINC]) |
---|
302 | AC_SUBST([WCSLIB]) |
---|
303 | ########################################################################## |
---|
304 | |
---|
305 | AC_SUBST([LDFLAGS]) |
---|
306 | |
---|
307 | AC_CONFIG_FILES([Makefile]) |
---|
308 | AC_OUTPUT |
---|