File: configure.in

package info (click to toggle)
spread 3.17.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,684 kB
  • ctags: 2,272
  • sloc: ansic: 15,165; sh: 2,563; java: 2,291; perl: 556; yacc: 523; makefile: 235; lex: 204; xml: 77
file content (735 lines) | stat: -rw-r--r-- 18,041 bytes parent folder | download | duplicates (3)
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
AC_INIT(spread.c)

AC_CONFIG_AUX_DIR(buildtools)
AC_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST

case "$host" in
mips-sgi-irix* ) 
	CC=cc 
	CFLAGS="-n32 -signed"
	;;
esac

AC_PROG_CC
AC_C_BIGENDIAN

# Checks for programs.
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_YACC
AC_PATH_PROG(LEX, flex)
AC_SUBST(LEX)
AC_PATH_PROG(AR, ar)
AC_PATH_PROGS(PERL, perl5 perl)
AC_SUBST(PERL)

if test -z "$AR" ; then
	AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
fi

if test -z "$LD" ; then
	LD=$CC
fi
AC_SUBST(LD)
	
# C Compiler features
AC_C_INLINE
if test "$GCC" = "yes"; then 
	CFLAGS="$CFLAGS -Wall"
fi

# Allow user to specify flags
AC_ARG_WITH(cflags,
	[  --with-cflags           Specify additional flags to pass to compiler],
	[
		if test "x$withval" != "xno" ; then
			CFLAGS="$CFLAGS $withval"
		fi
	]	
)
AC_ARG_WITH(cppflags,
	[  --with-cppflags         Specify additional flags to pass to preprocessor] ,
	[
		if test "x$withval" != "xno"; then
			CPPFLAGS="$CPPFLAGS $withval"
		fi
	]
)
AC_ARG_WITH(ldflags,
	[  --with-ldflags          Specify additional flags to pass to linker],
	[
		if test "x$withval" != "xno" ; then
			LDFLAGS="$LDFLAGS $withval"
		fi
	]	
)
AC_ARG_WITH(libs,
	[  --with-libs             Specify additional libraries to link with],
	[
		if test "x$withval" != "xno" ; then
			LIBS="$LIBS $withval"
		fi
	]	
)

# Checks for libraries.
 OLDLDFLAGS=$LDFLAGS
 LDFLAGS=
AC_PTHREAD_FREEBSD
 THLDFLAGS=$LDFLAGS
AC_SUBST(THLDFLAGS)
 LDFLAGS=$OLDLDFLAGS

 OLDLIBS=$LIBS
 LIBS=
AC_CHECK_LIB(pthread, pthread_create, , )
AC_CHECK_LIB(thread, thr_create, , )
AC_CHECK_LIB(posix4, sem_wait, , )
 THLIBS=$LIBS
AC_SUBST(THLIBS)
 LIBS=$OLDLIBS

AC_CHECK_LIB(nsl, gethostbyaddr, , )
AC_CHECK_LIB(socket, socket, , )

AC_FUNC_STRFTIME

# Checks for header files.
AC_CHECK_HEADERS(arpa/inet.h assert.h errno.h grp.h limits.h netdb.h netinet/in.h netinet/tcp.h process.h pthread.h pwd.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/inttypes.h sys/ioctl.h sys/param.h sys/socket.h sys/stat.h sys/time.h sys/timeb.h sys/types.h sys/uio.h sys/un.h sys/filio.h time.h unistd.h windows.h winsock.h)

dnl    Checks for library functions.
AC_CHECK_FUNCS(bcopy inet_aton inet_ntoa inet_ntop memmove setsid snprintf strerror lrand48)
dnl    Checks for time functions
AC_CHECK_FUNCS(gettimeofday time)

# Check for broken snprintf
if test "x$ac_cv_func_snprintf" = "xyes" ; then
	AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
	AC_TRY_RUN(
		[
#include <stdio.h>
int main(void){char b[5];snprintf(b,5,"123456789");return(b[4]!='\0');}
		],
		[AC_MSG_RESULT(yes)], 
		[
			AC_MSG_RESULT(no)
			AC_DEFINE(BROKEN_SNPRINTF)
			AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
		]
	)
fi

# Cheap hack to ensure NEWS-OS libraries are arranged right.
if test ! -z "$SONY" ; then
  LIBS="$LIBS -liberty";
fi

# Checks for data types
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short int, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long int, 4)
AC_CHECK_SIZEOF(long long int, 8)

# More checks for data types
AC_CACHE_CHECK([for windows arch], ac_cv_arch_win, [
	AC_TRY_COMPILE(
		[ #include <process.h> ],
		[ CRITICAL_SECTION mutex; InitializeCriticalSection(mutex); ],
		[ ac_cv_arch_win="yes" ],
		[ ac_cv_arch_win="no" ]
	)
])
if test "x$ac_cv_arch_win" = "xyes" ; then
	AC_DEFINE(ARCH_PC_WIN95)
fi

AC_CACHE_CHECK([for struct timezone type], ac_cv_have_struct_timezone, [
	AC_TRY_COMPILE(
		[ #include <time.h>
		  #include <sys/types.h> ], 
		[ struct timezone opt; ],
		[ ac_cv_have_struct_timezone="yes" ],
		[ ac_cv_have_struct_timezone="no" ]
	)
])
if test "x$ac_cv_have_struct_timezone" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_TIMEZONE)
fi

AC_CACHE_CHECK([for struct sockopt_len_t type], ac_cv_have_sockopt_len_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h>
		  #include <sys/socket.h> ], 
		[ static sockopt_len_t opt; opt=0; ],
		[ ac_cv_have_sockopt_len_t="yes" ],
		[ ac_cv_have_sockopt_len_t="no" ]
	)
])
if test "x$ac_cv_have_sockopt_len_t" = "xyes" ; then
	AC_DEFINE(HAVE_SOCKOPT_LEN_T)
fi

AC_CACHE_CHECK([for struct msghdr type], ac_cv_have_struct_msghdr, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h>
		  #include <sys/socket.h> ], 
		[ static  struct  msghdr msg; msg.msg_namelen = 1; ], 
		[ ac_cv_have_struct_msghdr="yes" ],
		[ ac_cv_have_struct_msghdr="no" ]
	)
])
if test "x$ac_cv_have_struct_msghdr" = "xno" ; then
	AC_DEFINE(ARCH_SCATTER_NONE)
else
  have_scatter="no"
  AC_CACHE_CHECK([for struct msghdr accrights], ac_cv_have_struct_msghdr_acc, [
        AC_TRY_COMPILE(
                [ #include <sys/types.h>
		  #include <sys/socket.h> ],
                [ static  struct  msghdr msg; msg.msg_accrightslen = 0; ],
                [ ac_cv_have_struct_msghdr_acc="yes" ],
                [ ac_cv_have_struct_msghdr_acc="no" ]
        )
  ])
  if test "x$ac_cv_have_struct_msghdr_acc" = "xyes" ; then
	AC_DEFINE(ARCH_SCATTER_ACCRIGHTS)
	have_scatter="yes"
  fi
  if test "x$have_scatter" = "xno" ; then
	AC_CACHE_CHECK([for struct msghdr control], ac_cv_have_struct_msghdr_ctl, [
	    AC_TRY_COMPILE(
            [ #include <sys/types.h>
	      #include <sys/socket.h> ],
            [ static  struct  msghdr msg; msg.msg_controllen = 0; ],
            [ ac_cv_have_struct_msghdr_ctl="yes" ],
            [ ac_cv_have_struct_msghdr_ctl="no" ]
            )
     	])
	if test "x$ac_cv_have_struct_msghdr_ctl" = "xyes" ; then
	    AC_DEFINE(ARCH_SCATTER_CONTROL)
            have_scatter="yes"
	fi
  fi
  if test "x$have_scatter" = "xno" ; then
        AC_MSG_ERROR([*** cannot determine which scatter type to use ***])
  fi
fi

AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ u_int a; a = 1;], 
		[ ac_cv_have_u_int="yes" ],
		[ ac_cv_have_u_int="no" ]
	)
])
if test "x$ac_cv_have_u_int" = "xyes" ; then
	AC_DEFINE(HAVE_U_INT)
	have_u_int=1
fi

AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
		[ ac_cv_have_intxx_t="yes" ],
		[ ac_cv_have_intxx_t="no" ]
	)
])
if test "x$ac_cv_have_intxx_t" = "xyes" ; then
	AC_DEFINE(HAVE_INTXX_T)
	have_intxx_t=1
fi
	
AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ int64_t a; a = 1;], 
		[ ac_cv_have_int64_t="yes" ],
		[ ac_cv_have_int64_t="no" ]
	)
])
if test "x$ac_cv_have_int64_t" = "xyes" ; then
	AC_DEFINE(HAVE_INT64_T)
	have_int64_t=1
fi
	
AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
		[ ac_cv_have_u_intxx_t="yes" ],
		[ ac_cv_have_u_intxx_t="no" ]
	)
])
if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
	AC_DEFINE(HAVE_U_INTXX_T)
	have_u_intxx_t=1
fi

AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
	AC_TRY_COMPILE(
		[ #include <sys/types.h> ], 
		[ u_int64_t a; a = 1;], 
		[ ac_cv_have_u_int64_t="yes" ],
		[ ac_cv_have_u_int64_t="no" ]
	)
])
if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
	AC_DEFINE(HAVE_U_INT64_T)
	have_u_int64_t=1
fi

if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
then
	AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
	AC_TRY_COMPILE(
		[
#include <sys/bitypes.h>
		], 
		[
			int8_t a; int16_t b; int32_t c;
			u_int8_t e; u_int16_t f; u_int32_t g;
			a = b = c = e = f = g = 1;
		], 
		[
			AC_DEFINE(HAVE_U_INTXX_T)
			AC_DEFINE(HAVE_INTXX_T)
			AC_MSG_RESULT(yes)
		],
		[AC_MSG_RESULT(no)]
	) 
fi

if test -z "$have_u_intxx_t" ; then
	AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
		AC_TRY_COMPILE(
			[
#include <sys/types.h>
			], 
			[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ], 
			[ ac_cv_have_uintxx_t="yes" ],
			[ ac_cv_have_uintxx_t="no" ]
		)
	])
	if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
		AC_DEFINE(HAVE_UINTXX_T)
	fi
fi

AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[socklen_t foo; foo = 1235;],
		[ ac_cv_have_socklen_t="yes" ],
		[ ac_cv_have_socklen_t="no" ]
	)
])
if test "x$ac_cv_have_socklen_t" = "xyes" ; then
	AC_DEFINE(HAVE_SOCKLEN_T)
fi

AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
		],
		[ size_t foo; foo = 1235; ],
		[ ac_cv_have_size_t="yes" ],
		[ ac_cv_have_size_t="no" ]
	)
])
if test "x$ac_cv_have_size_t" = "xyes" ; then
	AC_DEFINE(HAVE_SIZE_T)
fi

AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
		],
		[ ssize_t foo; foo = 1235; ],
		[ ac_cv_have_ssize_t="yes" ],
		[ ac_cv_have_ssize_t="no" ]
	)
])
if test "x$ac_cv_have_ssize_t" = "xyes" ; then
	AC_DEFINE(HAVE_SSIZE_T)
fi

AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
	AC_TRY_COMPILE(
		[
#include <time.h>
		],
		[ clock_t foo; foo = 1235; ],
		[ ac_cv_have_clock_t="yes" ],
		[ ac_cv_have_clock_t="no" ]
	)
])
if test "x$ac_cv_have_clock_t" = "xyes" ; then
	AC_DEFINE(HAVE_CLOCK_T)
fi

AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ sa_family_t foo; foo = 1235; ],
		[ ac_cv_have_sa_family_t="yes" ],
		[ AC_TRY_COMPILE(
		  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
		],
		[ sa_family_t foo; foo = 1235; ],
		[ ac_cv_have_sa_family_t="yes" ],

		[ ac_cv_have_sa_family_t="no" ]
	)]
	)
])
if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
	AC_DEFINE(HAVE_SA_FAMILY_T)
fi


AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct sockaddr_storage s; ],
		[ ac_cv_have_struct_sockaddr_storage="yes" ],
		[ ac_cv_have_struct_sockaddr_storage="no" ]
	)
])
if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
fi

AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <netinet/in.h>
		],
		[ struct sockaddr_in6 s; s.sin6_family = 0; ],
		[ ac_cv_have_struct_sockaddr_in6="yes" ],
		[ ac_cv_have_struct_sockaddr_in6="no" ]
	)
])
if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
fi

AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <netinet/in.h>
		],
		[ struct in6_addr s; s.s6_addr[0] = 0; ],
		[ ac_cv_have_struct_in6_addr="yes" ],
		[ ac_cv_have_struct_in6_addr="no" ]
	)
])
if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
fi

AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
		],
		[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
		[ ac_cv_have_struct_addrinfo="yes" ],
		[ ac_cv_have_struct_addrinfo="no" ]
	)
])
if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_ADDRINFO)
fi

AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
	AC_TRY_COMPILE(
		[ #include <sys/time.h> ], 
		[ struct timeval tv; tv.tv_sec = 1;], 
		[ ac_cv_have_struct_timeval="yes" ],
		[ ac_cv_have_struct_timeval="no" ]
	)
])
if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_TIMEVAL)
	have_struct_timeval=1
fi

AC_CACHE_CHECK([for sun_len field in struct sockaddr_un],
		ac_cv_have_sun_len_in_struct_sockaddr_un, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct sockaddr_un s; s.sun_len = 1; ],
		[ ac_cv_have_sun_len_in_struct_sockaddr_un="yes" ],
		[ ac_cv_have_sun_len_in_struct_sockaddr_un="no" ],
	)
])
if test "x$ac_cv_have_sun_len_in_struct_sockaddr_un" = "xyes" ; then
	AC_DEFINE(HAVE_SUN_LEN_IN_SOCKADDR_UN)
fi

AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
		ac_cv_have_ss_family_in_struct_ss, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct sockaddr_storage s; s.ss_family = 1; ],
		[ ac_cv_have_ss_family_in_struct_ss="yes" ],
		[ ac_cv_have_ss_family_in_struct_ss="no" ],
	)
])
if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
	AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
fi

AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
		ac_cv_have___ss_family_in_struct_ss, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct sockaddr_storage s; s.__ss_family = 1; ],
		[ ac_cv_have___ss_family_in_struct_ss="yes" ],
		[ ac_cv_have___ss_family_in_struct_ss="no" ]
	)
])
if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
	AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
fi

AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
        AC_TRY_COMPILE(
                [
#include <sys/types.h>
                ],
                [ pid_t foo; foo = 1235; ],
                [ ac_cv_have_pid_t="yes" ],
                [ ac_cv_have_pid_t="no" ]
        )
])
if test "x$ac_cv_have_pid_t" = "xyes" ; then
        AC_DEFINE(HAVE_PID_T)
fi

AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
	AC_TRY_LINK([], 
		[ extern char *__progname; printf("%s", __progname); ], 
		[ ac_cv_libc_defines___progname="yes" ],
		[ ac_cv_libc_defines___progname="no" ]
	)
])
if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
	AC_DEFINE(HAVE___PROGNAME)
fi


AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
	AC_TRY_LINK([], 
		[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);], 
		[ ac_cv_libc_defines_sys_errlist="yes" ],
		[ ac_cv_libc_defines_sys_errlist="no" ]
	)
])
if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
	AC_DEFINE(HAVE_SYS_ERRLIST)
fi


AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
	AC_TRY_LINK([], 
		[ extern int sys_nerr; printf("%i", sys_nerr);], 
		[ ac_cv_libc_defines_sys_nerr="yes" ],
		[ ac_cv_libc_defines_sys_nerr="no" ]
	)
])
if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
	AC_DEFINE(HAVE_SYS_NERR)
fi

for i in `grep "SP_....._VERSION" ${srcdir}/spread_params.h | sed -e 's/#define//g' -e 's/[ 	]//g' -e 's/VERSION/VERSION=/g;'`
do
  eval $i
done
AC_MSG_CHECKING([Check Spread's major version])
AC_MSG_RESULT($SP_MAJOR_VERSION)
AC_SUBST(SP_MAJOR_VERSION)
AC_MSG_CHECKING([Check Spread's minor version])
AC_MSG_RESULT($SP_MINOR_VERSION)
AC_SUBST(SP_MINOR_VERSION)
AC_MSG_CHECKING([Check Spread's patch version])
AC_MSG_RESULT($SP_PATCH_VERSION)
AC_SUBST(SP_PATCH_VERSION)

# Options from here on. Some of these are preset by platform above

AC_ARG_WITH(catman,
	[  --with-mantype=man|cat|doc  Set man page type],
	[
		case "$withval" in
		man|cat|doc)
			MANTYPE=$withval
			;;
		*)
			AC_MSG_ERROR(invalid man type: $withval)
			;;
		esac
	]
)
if test -z "$MANTYPE"; then
	AC_PATH_PROGS(NROFF, nroff awf, /bin/false, /usr/bin:/usr/ucb)
	if ${NROFF} -mdoc ${srcdir}/docs/spread.1 >/dev/null 2>&1; then
		MANTYPE=doc
	elif ${NROFF} -man ${srcdir}/docs/spread.1 >/dev/null 2>&1; then
		MANTYPE=man
	else
		MANTYPE=cat
	fi
fi
AC_SUBST(MANTYPE)
if test "$MANTYPE" = "doc"; then
	mansubdir=man;
else
	mansubdir=$MANTYPE;
fi
AC_SUBST(mansubdir)

# Where to place spread.pid
piddir=/var/run
AC_ARG_WITH(pid-dir,
	[  --with-pid-dir=PATH     Specify location of spread.pid file],
	[
		if test "x$withval" != "xno" ; then	
			piddir=$withval
		fi
	]
)

# make sure the directory exists
if test ! -d $piddir ; then	
	piddir=`eval echo ${sysconfdir}`
	case $piddir in
 		NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
	esac
fi

AC_DEFINE_UNQUOTED(_PATH_SPREAD_PIDDIR, "$piddir")
AC_SUBST(piddir)

# Where to find spread.conf and other config files
etcdir=`eval echo ${sysconfdir}`
case $etcdir in
	NONE/*) etcdir=`echo $etcdir | sed "s~NONE~$ac_default_prefix~"` ;;
esac

AC_DEFINE_UNQUOTED(SPREAD_ETCDIR, "$etcdir")

AC_EXEEXT

LIBSPSO=none
LIBTSPSO=none
case "$host" in
*-*-darwin*)
	SHCC=$CC
	SHCFLAGS="$CFLAGS -fPIC"
	SHCPPFLAGS="$CPPFLAGS"
	SHLD="$CC -dynamiclib"
	SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
	SHLIBS=$LIBS	
	LIBSPSO="libspread.dylib"
	LIBTSPSO="libtspread.dylib"
        ;;
mips-sgi-irix*)
	LIBSPSO=none
	LIBTSPSO=none
	;;
*-*-*)
	SHCC=$CC
	SHCFLAGS="$CFLAGS -fPIC"
	SHCPPFLAGS="$CPPFLAGS"
	SHLD="$CC -shared"
	SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
	SHLIBS=$LIBS
	LIBSPSO="libspread.so"
	LIBTSPSO="libtspread.so"
	;;
esac

AC_SUBST(SHCC)
AC_SUBST(SHCFLAGS)
AC_SUBST(SHCPPFLAGS)
AC_SUBST(SHLD)
AC_SUBST(SHLDFLAGS)
AC_SUBST(SHLIBS)
AC_SUBST(LIBSPSO)
AC_SUBST(LIBTSPSO)

AC_OUTPUT(Makefile)

# Print summary of options

# Someone please show me a better way :)
A=`eval echo ${prefix}` ; A=`eval echo ${A}`
B=`eval echo ${bindir}` ; B=`eval echo ${B}`
C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
E=`eval echo ${libdir}` ; E=`eval echo ${E}`
F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
G=`eval echo ${piddir}` ; G=`eval echo ${G}`
H=`eval echo ${LIBSPSO}`; H=`eval echo ${H}`
I=`eval echo ${LIBTSPSO}`; I=`eval echo ${I}`
J=`eval echo ${includedir}`; J=`eval echo ${J}`

echo ""
echo "Spread has been configured with the following options:"
echo "                    User binaries: $B"
echo "                  System binaries: $C"
echo "              Configuration files: $D"
echo "                   User libraries: $E"
echo "            Shared Spread Library: $H"
echo "Shared Thread-safe Spread Library: $I"
echo "                     Header files: $J"
echo "                     Manual pages: $F"
echo "                         PID file: $G"
echo "                   Manpage format: $MANTYPE"

echo ""

echo "              Host: ${host}"
echo "          Compiler: ${CC}"
echo "    Compiler flags: ${CFLAGS}"
echo "Preprocessor flags: ${CPPFLAGS}"
echo "      Linker flags: ${LDFLAGS}"
echo "         Libraries: ${LIBS}"

echo ""