-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
467 lines (391 loc) · 14.2 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([scopedesign], [0.2.5], [[email protected]])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
# save LDFLAGS
XLDFLAGS="$LDFLAGS"
AC_EXEEXT
if test x"${EXEEXT}" = "xno"; then
EXEEXT=""
fi
# Check for required programs.
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB dnl Needed by ARGTABLE, XPA
PKG_CHECK_MODULES([GTK], [gtk+-3.0],
[AC_DEFINE([HAVE_GTK3], [1], [Use GTK3])],
[AC_DEFINE([HAVE_GTK3], [0], [Use GTK3])] )
# Checks for header files.
dnl ScopeDesign requirements
AC_HEADER_STDC dnl Standard Basic C Headers
AC_CHECK_HEADERS([getopt.h sys/ioctl.h])
dnl LIBARGTABLE requirements
AC_CHECK_HEADERS([libintl.h limits.h])
dnl LIBXPA requirements
AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h pwd.h setjmp.h sys/un.h sys/socket.h sys/time.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_STRUCT_TM
AC_CHECK_SIZEOF(long) dnl == Needed by XPA
SZ_LONG=$ac_cv_sizeof_long
AC_SUBST(SZ_LONG)
AC_CHECK_TYPES([socklen_t], [], [], [#include <sys/socket.h>])
# Checks for library functions.
dnl ScopeDesign requirements
AC_FUNC_MALLOC
AC_CHECK_FUNCS([sqrt strdup])
AC_CHECK_FUNCS([sysinfo sysctl])
dnl LIBARGTABLE requirements
AC_CHECK_FUNCS([bzero memset regcomp strchr strcspn strrchr strtol])
AC_CHECK_FUNC(getopt_long, SYS_GETOPTLONG=1, SYS_GETOPTLONG=0)
AC_FUNC_STRTOD
dnl LIBXPA requirements
AC_CHECK_FUNCS([alarm atexit dup2 getcwd gethostname inet_ntoa memmove putenv setenv strcasecmp strncasecmp strpbrk strstr])
AC_CHECK_FUNCS(gethostbyname)
if test $ac_cv_func_gethostbyname = no; then
AC_CHECK_LIB(nsl, gethostbyname, EXTRA_LIBS="$EXTRA_LIBS -lnsl")
fi
AC_FUNC_FORK
AC_FUNC_REALLOC
dnl === Checks of unknown origin or utility...
dnl AC_FUNC_STRFTIME
dnl AC_CHECK_FUNC(regcomp, SYS_REGEX=1, SYS_REGEX=0)
dnl AC_CHECK_FUNC(strptime, SYS_STRPTIME=1, SYS_STRPTIME=0)
dnl AC_CHECK_FUNCS(strchr memcpy snprintf atexit setenv)
dnl AC_CHECK_FUNCS(connect)
dnl if test $ac_cv_func_connect = no; then
dnl AC_CHECK_LIB(socket, connect, EXTRA_LIBS="$EXTRA_LIBS -lsocket")
dnl fi
# Define automake conditionals
AM_CONDITIONAL(USE_SYS_GETOPTLONG, test "$SYS_GETOPTLONG" = "1")
AM_CONDITIONAL(USE_ARGREX, test "$SYS_REGEX" = "1")
AM_CONDITIONAL(USE_ARGDATE, test "$SYS_STRPTIME" = "1")
# Checks for command line options
AC_ARG_ENABLE([async-exec],
[AS_HELP_STRING([--disable-async-exec],
[disable asynchronous execution @<:@default: no@:>@])],
[async_exec=${enableval}],
[async_exec=yes])
if test "x${async_exec}" = xyes; then
AC_MSG_RESULT( Checking PTHREADS Library ==============================)
have_pthreads=no
AC_SEARCH_LIBS([pthread_create], [pthread],
[have_pthreads=yes])
if test "x${have_pthreads}" = xyes; then
AC_CHECK_HEADERS([pthread.h], [],
[have_pthreads=no])
fi
if test "x${have_pthreads}" = xno; then
echo "---------------------------------------"
echo "Unable to find pthreads on this system."
echo "Building a single-threaded version. "
echo "---------------------------------------"
async_exec=no
fi
fi
if test "x${async_exec}" = xyes; then
AC_DEFINE([ASYNC_EXEC], 1, [async exec enabled])
fi
AC_ARG_ENABLE([need-fft],
[AS_HELP_STRING([--enable-fft],
[enable FFT libraries @<:@default: no@:>@])],
[need_fft=${enableval}],
[need_fft=no])
dnl =============================================================
# Check for GSL (code from the GSL manual)
AC_MSG_RESULT( Checking GSL Library ===================================)
AC_CHECK_LIB([m],[cos])
AC_CHECK_LIB([gslcblas],[cblas_dgemm])
AC_CHECK_LIB([gsl],[gsl_blas_dgemm])
dnl dnl =============================================================
dnl # Check for FREEGLUT
dnl AC_MSG_RESULT( Checking FREEGLUT Library ==============================)
dnl AC_CHECK_LIB( freeglut, main, ,
dnl AC_MSG_ERROR("freeglut not found; use --with-freeglutlib"), [-lfreeglut] )
dnl fi
dnl =============================================================
dnl Checking Code from Alex's pofd_fitter
dnl =============================================================
# Check for FFTW library and headers
if test "x${need_fft}" = xyes; then
AC_LANG_C
AC_ARG_WITH(fftwinc,
[ --with-fftwinc=VAL VAL=-IVAL, has fftw3 include files ],
[fftwinc="$withval/" CPPFLAGS="$CPPFLAGS -I$fftwinc"],
[fftwinc=] )
AC_ARG_WITH(fftwlib,
[ --with-fftwlib=DIR DIR=-LDIR, has libfftw3 ],
fftwlib="$withval/",fftwlib= )
AC_MSG_RESULT( Checking FFTW3 Library =================================)
# Check for FFTW library first
if test $fftwlib; then
AC_MSG_RESULT( Checking User specified FFTW3 ==========================)
if test $rpathset; then
LDFLAGS="$LDFLAGS -L$fftwlib -Wl,--rpath -Wl,$fftwlib"
else
LDFLAGS="$LDFLAGS -L$fftwlib"
fi
LIBS="$LIBS -lfftw3"
AC_TRY_LINK( [#include<fftw3.h>],
[fftw_plan plan;],
[echo "Found libFFTW3"],
[AC_MSG_ERROR("FFTW3 library not found in user specified location")])
else
AC_CHECK_LIB( fftw3, main, ,
AC_MSG_ERROR("libfftw3 not found; use --with-fftwlib"), [-lm -lfftw3] )
fi
# Check for FFTW header next
AC_CHECK_HEADERS([fftw3.h],,
[ if test $fftwinc; then
AC_MSG_ERROR("fftw3 headers not in location specified by --with-fftwinc")
elif test $fftwlib; then
AC_CHECK_HEADER($fftwlib/../include/fftw3.h,
[fftwinc="$fftwlib/../include/" CPPFLAGS="$CPPFLAGS -I$fftwinc"],
AC_MSG_ERROR("Can't find fftw3 includes in user specified location; use --
with-fftwinc"))
else
AC_MSG_ERROR("Can't find fftw3 includes; use --with-fftwinc")
fi ] )
fi
dnl =============================================================
# Check for CFITSIO library and headers
AC_LANG_C
AC_ARG_WITH( cfitsiolib,
[ --with-cfitsiolib=DIR DIR=-LDIR, has libcfitsio.a],
cfitsiolib="$withval/" , cfitsiolib= )
if test $cfitsiolib; then
if test $rpathset; then
LDFLAGS="$LDFLAGS -L$cfitsiolib -Wl,--rpath -Wl,$cfitsiolib"
else
LDFLAGS="$LDFLAGS -L$cfitsiolib"
fi
fi
AC_MSG_RESULT( Checking CFITSIO Library ===============================)
# Check for CFITSIO library first
AC_CHECK_LIB(cfitsio,main,,
[AC_MSG_ERROR("Can't find libcfitsio; use --with-cfitsiolib")],
[-lm "-L$cfitsiolib"])
# Check for CFITSIO header next
AC_ARG_WITH(cfitsioinc,
[ --with-cfitsioinc=VAL VAL=-IVAL, has cfitsio include files ],
[cfitsioinc="$withval/" CPPFLAGS="-I$cfitsioinc $CPPFLAGS"],
[cfitsioinc=] )
AC_CHECK_HEADER(fitsio.h,,
[ if test $cfitsioinc; then
AC_MSG_ERROR("cfitsio headers not in location specified by --with-cfitsioinc")
elif test $cfitsiolib; then
AC_CHECK_HEADER($cfitsiolib/../include/fitsio.h,
[cfitsioinc="$cfitsiolib/../include/" CPPFLAGS="$CPPFLAGS -I$cfitsioinc"],
AC_MSG_ERROR("Can't find cfitsio includes; use --with-cfitsioinc"))
else
AC_MSG_ERROR("Can't find cfitsio includes; use --with-cfitsioinc")
fi ] )
dnl =============================================================
AC_MSG_RESULT( Checking other libraries ===============================)
dnl ===============================================================
dnl BEGIN XPA-specific code
AC_MSG_CHECKING(for threaded xpans)
AC_ARG_ENABLE(threaded-xpans, [ --enable-threaded-xpans build threaded xpans],
[fun_ok=$enableval], [fun_ok=no])
if test "$fun_ok" = "yes"; then
AC_MSG_RESULT($fun_ok)
AC_CHECK_LIB(pthread, pthread_create, have_pthread=yes)
if test x"${have_pthread}" = x"yes"; then
AC_DEFINE([HAVE_LIBPTHREAD],[1],[libpthread])
AC_DEFINE([_REENTRANT],[1],[reentrant])
TLIB="-lpthread"
else
AC_MSG_ERROR([no threads found ... can't use enable-threaded-xpans], 1)
fi
else
AC_MSG_RESULT($fun_ok)
fi
AC_SUBST(TLIB)
AC_MSG_CHECKING(for shared library build)
AC_ARG_ENABLE(shared, [ --enable-shared build shared libraries],
[fun_ok=$enableval], [fun_ok=no])
if test "$fun_ok" != "no"; then
fpic="yes"
DOSHARED=shlib
AC_SUBST(DOSHARED)
if test "$fun_ok" = "link"; then
LLIB="-L. -l$PACKAGE_NAME"
else
LLIB='$(LIB)'
fi
else
DOSHARED=""
LLIB='$(LIB)'
fi
AC_SUBST(LLIB)
AC_MSG_RESULT($fun_ok)
AC_MSG_CHECKING(for request to use posix_spawn)
AC_ARG_ENABLE(posix_spawn, [ --enable-posix_spawn use posix_spawn() if available],
[fun_ok=$enableval], [fun_ok=no])
AC_MSG_RESULT($fun_ok)
if test "$fun_ok" = "yes"; then
AC_CHECK_FUNCS(posix_spawn _NSGetEnviron)
AC_CHECK_HEADERS(crt_externs.h)
fi
AC_PATH_XTRA
if test x"${have_x}" = "xyes"; then
AC_DEFINE([HAVE_XT],[1],[Define to 1 if the system has XT])
fi
SC_PATH_TCLCONFIG
if test x"${no_tcl}" = x ; then
SC_LOAD_TCLCONFIG
if test -r $TCL_PREFIX/include/tcl.h; then
TCL_CFLAGS="$TCL_INCLUDE_SPEC"
if test x"$DOSHARED" != x -a x"$TCL_SUPPORTS_STUBS" = x1; then
TCL_LIBS="$TCL_STUB_LIB_SPEC"
TCL_CFLAGS="$TCL_CFLAGS -DUSE_TCL_STUBS=1"
AC_MSG_RESULT([Tcl support will utilize stubs library: $TCL_LIBS])
else
TCL_LIBS="$TCL_LIB_SPEC"
AC_MSG_RESULT([Tcl support will utilize library: $TCL_LIBS])
fi
AC_DEFINE([HAVE_TCL],[1],[Define to 1 if the system has Tcl])
else
if test x"${with_tclconfig}" != x ; then
TCL_CFLAGS="$TCL_INCLUDE_SPEC"
TCL_LIBS="$TCL_LIB_SPEC"
AC_DEFINE([HAVE_TCL],[1],[Define to 1 if the system has Tcl])
AC_MSG_RESULT([warning: tcl.h not found with --with-tcl ... tcl build might fail])
else
AC_MSG_RESULT([$TCL_PREFIX/include/tcl.h not found ... use --with-tcl to build tcl explicitly])
fi
fi
fi
AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_LIBS)
AC_MSG_CHECKING(for incorporation of thread support)
AC_ARG_WITH(threads,
[ --with-threads build for use in threaded programs], thr=1, thr=0)
if test x"$thr" = x1 ; then
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -D_REENTRANT"
else
AC_MSG_RESULT(no)
fi
dnl AC_MSG_CHECKING(for gtk)
dnl AC_ARG_WITH(gtk,
dnl [ --with-gtk=<path> include directory for gtk e.g. /usr/include/gtk-1.2], havelib=1, havelib=0)
dnl if test x"$havelib" = x1 ; then
dnl AC_MSG_RESULT(yes ($withval))
dnl GTK_CFLAGS="`pkg-config gtk+-2.0 --cflags` -DHAVE_GTK=1"
dnl GTK_LIBS="`pkg-config gtk+-2.0 --libs`"
dnl AC_DEFINE([HAVE_GTK],[1],[Define to 1 is the system has GTK])
dnl else
dnl GTK_CFLAGS=""
dnl GTK_LIBS=""
dnl AC_MSG_RESULT(no)
dnl fi
dnl AC_SUBST(GTK_CFLAGS)
dnl AC_SUBST(GTK_LIBS)
# restore LDFLAGS
LDFLAGS="$LDFLAGS $XLDFLAGS"
AC_MSG_CHECKING([$host_os configuration])
case $host_os in
*cygwin*|*Cygwin* )
AC_DEFINE([HAVE_CYGWIN],[1],[Define to 1 is the system IS cygwin])
AC_MSG_RESULT([flagging Cygwin])
;;
*mingw32*|*Mingw32*)
CFLAGS="$CFLAGS -mconsole"
EXTRA_LIBS="$EXTRA_LIBS -lwsock32"
AC_DEFINE([HAVE_MINGW32],[1],[Define to 1 if the system IS mingw32])
AC_MSG_RESULT([flagging MinGW])
;;
*darwin*|*Darwin*)
LDFLAGS="$LDFLAGS $CFLAGS"
G=`$CC -v 2>&1 | grep version | awk '{print $3}' | awk -F. '{print $1$2}'`
if test x"$G" != x -a "$G" -lt 42; then
CFLAGS="$CFLAGS -no-cpp-precomp"
fi
if test x"$TCL_PREFIX" = x"/usr/local"; then
TCL_CFLAGS=""
AC_MSG_RESULT([removing -I/usr/local/include])
fi
;;
*osf*|*Osf*)
AC_CHECK_LIB(db, snprintf, EXTRA_LIBS="$EXTRA_LIBS -ldb")
;;
* )
if test x"$fpic" = x"yes" ; then
if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
CFLAGS="$CFLAGS -fPIC"
AC_MSG_RESULT([adding -fPIC to gcc])
else
AC_MSG_RESULT(none)
fi
else
AC_MSG_RESULT(none)
fi
;;
esac
AC_SUBST(EXTRA_LIBS)
dnl END XPA-specific code
dnl ===============================================================
# Check for installed DS9 for display of FITS images produced by the program
# If no DS9 found, then exit configuration
AC_MSG_RESULT( Checking for a FITS display utility ====================)
AC_PATH_PROG([ds9_path],[ds9],[no])
if test "x${ds9_path}" = xno; then
echo \
"----------------------------------------------------------
The FITS viewer DS9 could not be found in the system path!
Please install DS9 from http://ds9.si.edu/site/Home.html
Re-run the configuration for ${PACKAGE}.
----------------------------------------------------------"
AC_MSG_ERROR("Exiting configuration.")
else
AC_DEFINE_UNQUOTED([DS9_PATH],["$ds9_path"],[Callable ds9 Path])
fi
dnl === Lifted from the nightfall OSS package
# Make sure data directory is included in the config.h file!
mydataroot="${datadir}/${PACKAGE}"
AC_SUBST(mydataroot)
my_save_prefix="${prefix}"
if test "X$prefix" = "XNONE"; then
prefix="$ac_default_prefix"
else
prefix="$prefix"
fi
PREFIX=`eval echo ${prefix}` ; PREFIX=`eval echo ${PREFIX}`
AC_DEFINE_UNQUOTED([PREFIX], ["$PREFIX"], [Installation prefix])
DATADIR=`eval echo ${mydataroot}` ; DATADIR=`eval echo ${DATADIR}`
AC_DEFINE_UNQUOTED([DATADIR], ["$DATADIR"], [Installation datadir])
prefix="${my_save_prefix}"
dnl === Lifted from the nightfall OSS package
# These are the Makefiles that need to be built!
AC_CONFIG_FILES([Makefile
src/Makefile
libargtable/Makefile
libxpa/Makefile
cexamples/Makefile
data/Makefile])
AC_OUTPUT
echo \
"-------------------------------------------------
${PACKAGE_NAME} Version ${PACKAGE_VERSION}
Prefix: '${prefix}'.
Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}'
Package features:
Async Execution: ${async_exec}
Use of FFT Libraries: ${need_fft}
Now type 'make @<:@<target>@:>@'
where the optional <target> is:
all - build all binaries
install - install everything
--------------------------------------------------"