aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/cfitsio/configure.in
blob: 5bbd92dc700a25675f468d661e791de2e01d4127 (plain) (blame)
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
#
# configure.in for cfitsio
#
# /redshift/sgi6/lheavc/ftools/cfitsio/configure.in,v 3.4 1996/07/26 20:27:53 pence Exp
#
#  copied from host and modified
#

dnl Process this file with autoconf to produce a configure script.
AC_INIT(fitscore.c)

#--------------------------------------------------------------------
# Check "uname" to determine system type
#--------------------------------------------------------------------
AC_PROGRAM_CHECK(uname_found, uname, 1, 0)
if test $uname_found -eq 0 ; then
    echo "cfitsio: No uname found; setting system type to unknown."
    system="unknown"
else
    system=`uname -s`-`uname -r`
fi


dnl Checks for programs.
AC_PROG_CC

AC_CHECK_PROGS(FC, f77 xlf cf77 gf77 g77 af77 ncf f2c , nope)
if test $FC = 'nope' ; then
   AC_MSG_WARN(cfitsio: == No acceptable f77 found in \$PATH)
   AC_MSG_WARN(cfitsio: == Cfitsio will be built without Fortran wrapper support)
   FC=
   F77_WRAPPERS=
else
  CFORTRANFLAGS=
  F77_WRAPPERS="\${FITSIO_SRC}"
  echo $ac_n "checking whether we are using GNU Fortran""... $ac_c" 1>&6
  if test `$FC --version -c < /dev/null 2> /dev/null | grep -c GNU` -gt 0 -o \
          `$FC --version -c < /dev/null 2> /dev/null | grep -ic egcs` -gt 0
  then
    echo "$ac_t""yes" 1>&6
    echo $ac_n "cfitsio: == Adding wrapper support for GNU Fortran""... $ac_c" 1>&6
    CFORTRANFLAGS="-Dg77Fortran"
    echo "$ac_t"" done" 1>&6
  else
    echo "$ac_t""no" 1>&6
    if test $FC = 'f2c' ; then
      echo $ac_n "cfitsio: == Adding wrapper support for f2c""... $ac_c" 1>&6
      CFORTRANFLAGS="-Df2cFortran"
      echo "$ac_t"" done" 1>&6
    fi
  fi
fi

AC_PROG_RANLIB

dnl Checks for ANSI stdlib.h.
AC_CHECK_HEADERS(stdlib.h string.h math.h limits.h ,ANSI_HEADER=yes,ANSI_HEADER=no)dnl

dnl Check if prototyping is allowed.
AC_TRY_COMPILE( , void d( int , double) , PROTO=yes, PROTO=no)dnl

if test $ANSI_HEADER = no -o $PROTO = no; then
     echo "   *********** WARNING: CFITSIO CONFIGURE FAILURE ************  "
     echo "cfitsio: ANSI C environment NOT found. Aborting cfitsio configure."
     if test $ANSI_HEADER = no; then 
        echo "cfitsio: You're missing a needed ANSI header file."
     fi
     if test $PROTO = no; then
        echo "cfitsio: Your compiler can't do ANSI function prototypes."
     fi
     echo "cfitsio: You need an ANSI C compiler and all ANSI trappings"
     echo "cfitsio: to build cfitsio.   "
     echo "     *******************************************************  "
     exit 0;
fi

CFLAGS="$CFLAGS"
LIBPRE=""

case $system in
    Darwin-*)
	# Darwin can be powerpc or i386
	ARCH=`uname -p`
	EXT="darwin"
	CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
	;;
    SunOS-4*)
	ARCH="sun"
	EXT="sun"
	;;
    HP-UX-*)
	ARCH="hp"
	EXT="hpu"
	if test "x$CFORTRANFLAGS" = x ; then
		CFORTRANFLAGS="-Dappendus"
	fi
	CFLAGS="$CFLAGS -DPG_PPU" 
	LIBPRE="-Wl,"
	;;
    SunOS-5*)
	ARCH="solaris"
	EXT="sol"
	if test "x$CFORTRANFLAGS" = x ; then
		CFORTRANFLAGS="-Dsolaris"
	fi
	;;
    OSF1*)
	ARCH="alpha"
	EXT="osf"
	;;
    IRIX*)
	ARCH="sgi"
	EXT="sgi"
	CFLAGS="$CFLAGS -DHAVE_POSIX_SIGNALS"
	RANLIB="touch"
	;;
    ULTRIX*)
	ARCH="dec"
	EXT="dec"
	;;
    Linux*)
	ARCH="linux"
	EXT="lnx"
	;;
    FREEBSD*|FreeBSD*)
	ARCH="linux"
	EXT="lnx"
	;;
    CYGWIN*)
	ARCH="cygwin"
	EXT="cygwin"
	CFLAGS="$CFLAGS -DHAVE_POSIX_SIGNALS"
	;;
    *)
		echo "cfitsio: == Don't know what do do with $system"
	;;
esac

CFLAGS="$CFLAGS $CFORTRANFLAGS"

case $CC in
	gcc)
		GCCVERSION="`gcc -v 2>&1 | grep version`"
		echo "cfitsio: == Using $GCCVERSION"
		AC_SUBST(GCCVERSION)
                changequote(,)
		if test `echo $GCCVERSION | grep -c 'version 2\.[45678]\.'` -gt 0
		then
		    CFLAGS=`echo $CFLAGS | sed 's:-O[^ ]* *::'`
		    AC_MSG_WARN(This gcc is pretty old. Disabling optimization to be safe.)
		fi
                changequote([,])
		;;
	cc)
		echo "cfitsio: Old CFLAGS is $CFLAGS"
		CFLAGS=`echo $CFLAGS | sed -e "s/-g/-O/"`
		case $system in
		    SunOS-5*)
         		CFLAGS="$CFLAGS -DHAVE_ALLOCA_H -DHAVE_POSIX_SIGNALS"
			;;
		    *)
			echo "== No special changes for $system"
			;;
		esac
		echo "New CFLAGS is $CFLAGS"
		;;
	*)
		# Don't do anything now
		;;
esac
		
# Shared library section
#-------------------------------------------------------------------------------
SHLIB_LD=:
SHLIB_SUFFIX=".so"
lhea_shlib_cflags=
case $EXT in
  darwin)
    SHLIB_LD="cc -dynamiclib"
    SHLIB_SUFFIX=".dylib"
    lhea_shlib_cflags="-fPIC -fno-common"
    ;;
  hpu)
    SHLIB_LD="ld -b" 
    SHLIB_SUFFIX=".sl"
    ;;
  lnx|cygwin)
    SHLIB_LD=":"
    ;;
  osf)
    SHLIB_LD="ld -shared -expect_unresolved '*'"
    LD_FLAGS="-taso"
    ;;
  sol)
    SHLIB_LD="/usr/ccs/bin/ld -G"
    lhea_shlib_cflags="-KPIC"
    ;;
  sgi)
    SHLIB_LD="ld -shared -rdata_shared"
    ;;
  *)
    AC_MSG_WARN(Unable to determine how to make a shared library)
    ;;
esac
# Darwin uses gcc (=cc), but needs different flags (see above)
# if test "x$GCC" = xyes; then
if test "x$GCC" = xyes && test "x$EXT" != xdarwin; then
  SHLIB_LD="$CC -shared"
  lhea_shlib_cflags='-fPIC'
fi
if test "x$lhea_shlib_cflags" != x; then
  CFLAGS="$CFLAGS $lhea_shlib_cflags"
fi

AC_SUBST(ARCH)dnl
AC_SUBST(CFLAGS)dnl
AC_SUBST(CC)dnl
AC_SUBST(FC)dnl
AC_SUBST(LIBPRE)dnl
AC_SUBST(SHLIB_LD)dnl
AC_SUBST(SHLIB_SUFFIX)dnl
AC_SUBST(F77_WRAPPERS)

# ================= test for the unix ftruncate function ================

AC_MSG_CHECKING("whether ftruncate works")
AC_TRY_LINK([#include <unistd.h>
], [
ftruncate(0, 0);
], [
AC_DEFINE(HAVE_FTRUNCATE)
AC_MSG_RESULT("yes")
], AC_MSG_RESULT("no") )

# ---------------------------------------------------------
# some systems define long long for 64-bit ints
# ---------------------------------------------------------
 
AC_MSG_CHECKING("whether long long is defined")
AC_TRY_COMPILE([#include <stdlib.h>
], [
long long filler;
], [
AC_DEFINE(HAVE_LONGLONG)
AC_MSG_RESULT("yes")
], AC_MSG_RESULT("no") )

# ==================== SHARED MEMORY DRIVER SECTION =======================
#
# 09-Mar-98 : modified by JB/ISDC
# 3 checks added to support autoconfiguration of shared memory
# driver. First generic check is made whether shared memory is supported
# at all, then 2 more specific checks are made (architecture dependent).
# Currently tested on : sparc-solaris, intel-linux, sgi-irix, dec-alpha-osf

# -------------------------------------------------------------------------
# check is System V IPC is supported on this machine
# -------------------------------------------------------------------------

AC_MSG_CHECKING("whether system V style IPC services are supported")
AC_TRY_LINK([#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
], [
shmat(0, 0, 0);
shmdt(0);
shmget(0, 0, 0);
semget(0, 0, 0);
], [
AC_DEFINE(HAVE_SHMEM_SERVICES)
my_shmem=\${SOURCES_SHMEM}
AC_MSG_RESULT("yes")
], AC_MSG_RESULT("no") )

AC_SUBST(my_shmem)

# -------------------------------------------------------------------------
# some systems define flock_t, for others we have to define it ourselves
# -------------------------------------------------------------------------

AC_MSG_CHECKING("do we have flock_t defined")
AC_TRY_COMPILE([#include <sys/fcntl.h>
], [
flock_t filler;
], [
AC_DEFINE(HAVE_FLOCK_T)
AC_MSG_RESULT("yes") 
], AC_MSG_RESULT("no") )


# -------------------------------------------------------------------------
# there are some idiosyncrasies with semun defs (used in semxxx). Solaris
# does not define it at all
# -------------------------------------------------------------------------

AC_MSG_CHECKING("do we have union semun defined")
AC_TRY_COMPILE(
[#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
], [
union semun filler;
], [
AC_DEFINE(HAVE_UNION_SEMUN)   
AC_MSG_RESULT("yes")
], AC_MSG_RESULT("no") )

# ==================== END OF SHARED MEMORY DRIVER SECTION ================
# ================= test for the unix networking functions ================

#--------------------------------------------------------------------
#	Check for the existence of the -lsocket and -lnsl libraries.
#	The order here is important, so that they end up in the right
#	order in the command line generated by make.  Here are some
#	special considerations:
#	1. Use "connect" and "accept" to check for -lsocket, and
#	   "gethostbyname" to check for -lnsl.
#	2. Use each function name only once:  can't redo a check because
#	   autoconf caches the results of the last check and won't redo it.
#	3. Use -lnsl and -lsocket only if they supply procedures that
#	   aren't already present in the normal libraries.  This is because
#	   IRIX 5.2 has libraries, but they aren't needed and they're
#	   bogus:  they goof up name resolution if used.
#	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
#	   To get around this problem, check for both libraries together
#	   if -lsocket doesn't work by itself.
#--------------------------------------------------------------------
cfitsio_checkBoth=0
AC_CHECK_FUNC(connect, cfitsio_checkSocket=0, cfitsio_checkSocket=1)
if test "$cfitsio_checkSocket" = 1; then
    AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", cfitsio_checkBoth=1)
fi
if test "$cfitsio_checkBoth" = 1; then
    tk_oldLibs=$LIBS
    LIBS="$LIBS -lsocket -lnsl"
    AC_CHECK_FUNC(accept, cfitsio_checkNsl=0, [LIBS=$tk_oldLibs])
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))

AC_DEFINE(HAVE_NET_SERVICES)

# ==================== END OF unix networking SECTION ================


AC_OUTPUT(Makefile)dnl


AC_MSG_RESULT([])
AC_MSG_RESULT([    Congratulations, Makefile update was successful.])
AC_MSG_RESULT([    You may want to run \"make\" now.])
AC_MSG_RESULT([])