forked from sit/dht
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acsfs.m4
2147 lines (2027 loc) · 55.9 KB
/
acsfs.m4
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
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl $Id: acinclude.m4 1754 2006-05-19 20:59:19Z max $
dnl
dnl Find full path to program
dnl
AC_DEFUN([SFS_PATH_PROG],
[AC_PATH_PROG(PATH_[]translit($1, [-a-z.], [_A-Z_]), $1,,
$2[]ifelse($2,,,:)/usr/bin:/bin:/sbin:/usr/sbin:/usr/etc:/usr/libexec:/usr/ucb:/usr/bsd:/usr/5bin:$PATH:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin)
if test "$PATH_[]translit($1, [-a-z.], [_A-Z_])"; then
AC_DEFINE_UNQUOTED(PATH_[]translit($1, [-a-z.], [_A-Z_]),
"$PATH_[]translit($1, [-a-z.], [_A-Z_])",
Full path of $1 command)
fi])
dnl
dnl File path to cpp
dnl
AC_DEFUN([SFS_PATH_CPP],
[AC_PATH_PROG(_PATH_CPP, cpp,,
/usr/ccs/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/etc:/usr/libexec:/lib:/usr/lib:/usr/ucb:/usr/bsd:/usr/5bin:$PATH:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin)
if test -z "$_PATH_CPP"; then
if test "$GCC" = yes; then
_PATH_CPP=`$CC -print-prog-name=cpp`
else
_PATH_CPP=`gcc -print-prog-name=cpp 2> /dev/null`
fi
fi
test -x "$_PATH_CPP" || unset _PATH_CPP
if test -z "$_PATH_CPP"; then
AC_MSG_ERROR(Cannot find path for cpp)
fi
AC_DEFINE_UNQUOTED(PATH_CPP, "$_PATH_CPP",
Path for the C preprocessor command)
])
dnl
dnl How to get BSD-like df output
dnl
AC_DEFUN([SFS_PATH_DF],
[SFS_PATH_PROG(df, /usr/ucb:/usr/bsd:/usr/local/bin)
AC_CACHE_CHECK(if [$PATH_DF] needs -k for BSD-formatted output,
sfs_cv_df_dash_k,
sfs_cv_df_dash_k=no
[test "`$PATH_DF . | sed -e '2,$d;/Mounted on/d'`" \
&& test "`$PATH_DF -k . | sed -ne '2,$d;/Mounted on/p'`" \
&& sfs_cv_df_dash_k=yes])
if test $sfs_cv_df_dash_k = yes; then
AC_DEFINE(DF_NEEDS_DASH_K, 1,
Define if you must run \"df -k\" to get BSD-formatted output)
fi])
dnl
dnl Check for declarations
dnl SFS_CHECK_DECL(symbol, headers-to-try, headers-to-include)
dnl
AC_DEFUN([SFS_CHECK_DECL],
[AC_CACHE_CHECK(for a declaration of $1, sfs_cv_$1_decl,
dnl for hdr in [patsubst(builtin(shift, $@), [,], [ ])]; do
for hdr in $2; do
if test -z "${sfs_cv_$1_decl}"; then
dnl AC_HEADER_EGREP($1, $hdr, sfs_cv_$1_decl=yes)
AC_TRY_COMPILE(
patsubst($3, [\([^ ]+\) *], [#include <\1>
])[#include <$hdr>], &$1;, sfs_cv_$1_decl=yes)
fi
done
test -z "${sfs_cv_$1_decl+set}" && sfs_cv_$1_decl=no)
if test "$sfs_cv_$1_decl" = no; then
AC_DEFINE_UNQUOTED(NEED_[]translit($1, [a-z], [A-Z])_DECL, 1,
Define if system headers do not declare $1.)
fi])
dnl
dnl Check if lsof keeps a device cache
dnl
AC_DEFUN([SFS_LSOF_DEVCACHE],
[if test "$PATH_LSOF"; then
AC_CACHE_CHECK(if lsof supports a device cache, sfs_cv_lsof_devcache,
if $PATH_LSOF -h 2>&1 | fgrep -e -D > /dev/null; then
sfs_cv_lsof_devcache=yes
else
sfs_cv_lsof_devcache=no
fi)
if test "$sfs_cv_lsof_devcache" = yes; then
AC_DEFINE(LSOF_DEVCACHE, 1,
Define is lsof supports the -D option)
fi
fi])
dnl
dnl Posix time subroutine
dnl
AC_DEFUN([SFS_TIME_CHECK],
[AC_CACHE_CHECK($3, sfs_cv_time_check_$1,
AC_TRY_COMPILE([
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#elif defined (HAVE_SYS_TIME_H)
# include <sys/time.h>
#else /* !TIME_WITH_SYS_TIME && !HAVE_SYS_TIME_H */
# include <time.h>
#endif /* !TIME_WITH_SYS_TIME && !HAVE_SYS_TIME_H */
], $2, sfs_cv_time_check_$1=yes, sfs_cv_time_check_$1=no))
if test "$sfs_cv_time_check_$1" = yes; then
AC_DEFINE($1, 1, $4)
fi])
dnl
dnl Posix time stuff
dnl
AC_DEFUN([SFS_TIMESPEC],
[AC_CHECK_HEADERS(sys/time.h)
AC_HEADER_TIME
AC_CHECK_FUNCS(clock_gettime)
SFS_TIME_CHECK(HAVE_CLOCK_GETTIME_DECL,
int (*x) () = &clock_gettime;,
for a declaration of clock_gettime,
Define if system headers declare clock_gettime.)
SFS_TIME_CHECK(HAVE_TIMESPEC,
int x = sizeof (struct timespec),
for struct timespec,
Define if sys/time.h defines a struct timespec.)
dnl AC_EGREP_HEADER(clock_gettime, sys/time.h,
dnl AC_DEFINE(HAVE_CLOCK_GETTIME_DECL, 1,
dnl Define if system header files declare clock_gettime.))
dnl AC_EGREP_HEADER(timespec, sys/time.h,
dnl AC_DEFINE(HAVE_TIMESPEC, 1,
dnl Define if sys/time.h defines a struct timespec.))
])
dnl
dnl Find the crypt function
dnl
AC_DEFUN([SFS_FIND_CRYPT],
[AC_SUBST(LIBCRYPT)
AC_CHECK_FUNC(crypt)
if test $ac_cv_func_crypt = no; then
AC_CHECK_LIB(crypt, crypt, LIBCRYPT="-lcrypt")
fi
])
dnl
dnl Find the setusercontext function
dnl
AC_DEFUN([SFS_CHECK_SETUSERCONTEXT],
[AC_SUBST(SETUSERCONTEXTLIB)
AC_CHECK_FUNC(setusercontext)
if test "$ac_cv_func_setusercontext" = no; then
AC_CHECK_LIB(setusercontext, util, SETUSERCONTEXTLIB="-lutil")
fi
if test "$ac_cv_func_setusercontext" = yes; then
AC_CHECK_HEADERS(login_cap.h)
AC_DEFINE(HAVE_SETUSERCONTEXT, 1,
Define if you have the setusercontext function)
fi
])
dnl
dnl Find pty functions
dnl
AC_DEFUN([SFS_PTYLIB],
[AC_SUBST(PTYLIB)
AC_CHECK_FUNCS(_getpty)
AC_CHECK_FUNCS(openpty)
if test $ac_cv_func_openpty = no; then
AC_CHECK_LIB(util, openpty, PTYLIB="-lutil"
AC_DEFINE(HAVE_OPENPTY, 1,
Define if you have the openpty function.))
fi
if test "$ac_cv_func_openpty" = yes -o "$ac_cv_lib_util_openpty" = yes; then
AC_CHECK_HEADERS(util.h libutil.h)
fi
AC_CHECK_HEADERS(pty.h)
AC_CACHE_CHECK(for BSD-style utmp slots, ac_cv_have_ttyent,
AC_EGREP_HEADER(getttyent, ttyent.h,
ac_cv_have_ttyent=yes, ac_cv_have_ttyent=no))
if test "$ac_cv_have_ttyent" = yes; then
AC_DEFINE(USE_TTYENT, 1,
Define if utmp must be managed with BSD-style ttyent functions)
fi
AC_MSG_CHECKING(for pseudo ttys)
if test -c /dev/ptmx && test -c /dev/pts/0
then
AC_DEFINE(HAVE_DEV_PTMX, 1,
Define if you have SYSV-style /dev/ptmx and /dev/pts/.)
AC_MSG_RESULT(streams ptys)
else
if test -c /dev/pts && test -c /dev/ptc
then
AC_DEFINE(HAVE_DEV_PTS_AND_PTC, 1,
Define if you have /dev/pts and /dev/ptc devices (as in AIX).)
AC_MSG_RESULT(/dev/pts and /dev/ptc)
else
AC_MSG_RESULT(bsd-style ptys)
fi
fi])
dnl
dnl SFS_TRY_RESOLV_LIB(library)
dnl see if -llibrary is needed to get res_mkquery
dnl
AC_DEFUN([SFS_TRY_RESOLV_LIB],
[reslib="$1"
if test -z "$reslib"; then
resdesc="standard C library"
else
resdesc="lib$reslib"
fi
AC_CACHE_CHECK(for resolver functions in [$resdesc],
sfs_cv_reslib_lib$1,
[sfs_try_resolv_lib_save_LIBS="$LIBS"
if test x"$reslib" != x; then
LIBS="$LIBS -l$reslib"
fi
AC_LINK_IFELSE([
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#if HAVE_ARPA_NAMESER_COMPAT_H
#include <arpa/nameser_compat.h>
#else /* !HAVE_ARPA_NAMESER_COMPAT_H */
#include <arpa/nameser.h>
#endif /* !HAVE_ARPA_NAMESER_COMPAT_H */
#include <resolv.h>
int
main (int argc, char **argv)
{
res_mkquery (0, 0, 0, 0, 0, 0, 0, 0, 0);
return 0;
}], sfs_cv_reslib_lib$1=yes, sfs_cv_reslib_lib$1=no)
LIBS="$sfs_try_resolv_lib_save_LIBS"])
if test "$sfs_cv_reslib_lib$1" = yes -a "$reslib"; then
LIBS="$LIBS -l$reslib"
fi
])
dnl
dnl Use -lresolv only if we need it
dnl
AC_DEFUN([SFS_FIND_RESOLV],
[AC_CHECK_HEADERS(arpa/nameser_compat.h)
if test "$ac_cv_header_arpa_nameser_compat_h" = yes; then
nameser_header=arpa/nameser_compat.h
else
nameser_header=arpa/nameser.h
fi
dnl AC_CHECK_FUNC(res_mkquery)
dnl if test "$ac_cv_func_res_mkquery" != yes; then
dnl AC_CHECK_LIB(resolv, res_mkquery)
dnl if test "$ac_cv_lib_resolv_res_mkquery" = no; then
dnl AC_CHECK_LIB(resolv, __res_mkquery)
dnl fi
dnl fi
SFS_TRY_RESOLV_LIB([])
if test "$sfs_cv_reslib_lib" = no; then
SFS_TRY_RESOLV_LIB(resolv)
fi
dnl See if the resolv functions are actually declared
SFS_CHECK_DECL(res_init, resolv.h,
sys/types.h sys/socket.h netinet/in.h $nameser_header)
SFS_CHECK_DECL(res_mkquery, resolv.h,
sys/types.h sys/socket.h netinet/in.h $nameser_header)
SFS_CHECK_DECL(dn_skipname, resolv.h,
sys/types.h sys/socket.h netinet/in.h $nameser_header)
SFS_CHECK_DECL(dn_expand, resolv.h,
sys/types.h sys/socket.h netinet/in.h $nameser_header)
])
dnl
dnl Check if first element in grouplist is egid
dnl
AC_DEFUN([SFS_CHECK_EGID_IN_GROUPLIST],
[AC_TYPE_GETGROUPS
AC_CACHE_CHECK(if egid is first element of grouplist, sfs_cv_egid_in_grouplist,
AC_TRY_RUN([changequote changequote([[,]])
#include <sys/types.h>
#include <unistd.h>
#include <netinet/in.h>
#include <rpc/rpc.h>
#include "confdefs.h"
static int
getint (void *_p)
{
unsigned char *p = _p;
return p[0]<<24 | p[1]<<16 | p[2]<<8 | p[3];
}
int
main (int argc, char **argv)
{
AUTH *a;
GETGROUPS_T gids[24];
int n, xn;
char buf[408];
char *p;
XDR x;
/* Must hard-code OSes with egid in grouplist *and* broken RPC lib */
#if __FreeBSD__ || __APPLE__
return 0;
#endif
n = getgroups (24, gids);
if (n <= 0)
return 1;
a = authunix_create_default ();
xdrmem_create (&x, buf, sizeof (buf), XDR_ENCODE);
if (!auth_marshall (a, &x))
return 1;
if (getint (buf) != AUTH_UNIX)
return 1;
p = buf + 12; /* Skip auth flavor, length, timestamp */
p += getint (p) + 7 & ~3; /* Skip machine name */
p += 8; /* Skip uid & gid */
xn = getint (p); /* Length of grouplist in auth_unix */
return n != xn + 1;
}
changequote([,])],
sfs_cv_egid_in_grouplist=yes, sfs_cv_egid_in_grouplist=no))
if test $sfs_cv_egid_in_grouplist = yes; then
AC_DEFINE(HAVE_EGID_IN_GROUPLIST, 1,
Define if the first element of a grouplist is the effective gid)
fi])
dnl
dnl Check for struct passwd fields
dnl
AC_DEFUN([SFS_PASSWD_FIELD],
[AC_CACHE_CHECK(for $1 in struct passwd, sfs_cv_passwd_$1,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <pwd.h>
], [
struct passwd *pw;
pw->$1;
], sfs_cv_passwd_$1=yes, sfs_cv_passwd_$1=no))
if test "$sfs_cv_passwd_$1" = yes; then
AC_DEFINE(HAVE_PASSWD_[]translit($1, [a-z ], [A-Z_]), 1,
Define if struct passwd has $1 field)
fi])
dnl
dnl Check if putenv copies arguments
dnl
AC_DEFUN([SFS_PUTENV_COPY],
[AC_CACHE_CHECK(if putenv() copies its argument, sfs_cv_putenv_copy,
AC_TRY_RUN([
changequote`'changequote([[,]])
#include <stdlib.h>
char var[] = "V=0";
int
main (int argc, char **argv)
{
char *v;
putenv (var);
var[2] = '1';
v = getenv (var);
return *v != '0';
}
changequote([,])],
sfs_cv_putenv_copy=yes, sfs_cv_putenv_copy=no,
sfs_cv_putenv_copy=no)
)
if test $sfs_cv_putenv_copy = yes; then
AC_DEFINE(PUTENV_COPIES_ARGUMENT, 1,
Define if putenv makes a copy of its argument)
fi])
dnl
dnl Check for wide select
dnl
AC_DEFUN([SFS_CHECK_WIDE_SELECT],
[AC_CACHE_CHECK(for wide select, sfs_cv_wideselect,
fdlim_h=${srcdir}/fdlim.h
test -f ${srcdir}/async/fdlim.h && fdlim_h=${srcdir}/async/fdlim.h
test -f ${srcdir}/libasync/fdlim.h && fdlim_h=${srcdir}/libasync/fdlim.h
AC_TRY_RUN([changequote changequote([[,]])
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include "${fdlim_h}"
struct timeval ztv;
int
main ()
{
int pfd[2];
int rfd, wfd;
int maxfd;
int i;
fd_set *rfdsp, *wfdsp;
maxfd = fdlim_get (1);
fdlim_set (maxfd, 1);
maxfd = fdlim_get (0);
if (maxfd <= FD_SETSIZE) {
printf ("[small fd limit anyway] ");
exit (1);
}
if (pipe (pfd) < 0)
exit (1);
#ifdef F_DUPFD
if ((rfd = fcntl (pfd[0], F_DUPFD, maxfd - 2)) < 0)
exit (1);
if ((wfd = fcntl (pfd[1], F_DUPFD, maxfd - 1)) < 0)
exit (1);
#else /* !F_DUPFD */
if ((rfd = dup2 (pfd[0], maxfd - 2)) < 0)
exit (1);
if ((wfd = dup2 (pfd[1], maxfd - 1)) < 0)
exit (1);
#endif /* !F_DUPFD */
rfdsp = malloc (1 + (maxfd/8));
for (i = 0; i < 1 + (maxfd/8); i++)
((char *) rfdsp)[i] = '\0';
wfdsp = malloc (1 + (maxfd/8));
for (i = 0; i < 1 + (maxfd/8); i++)
((char *) wfdsp)[i] = '\0';
FD_SET (rfd, rfdsp);
FD_SET (wfd, wfdsp);
if (select (maxfd, rfdsp, wfdsp, NULL, &ztv) < 0)
exit (1);
if (FD_ISSET (wfd, wfdsp) && !FD_ISSET (rfd, rfdsp))
exit (0);
else
exit (1);
}
changequote([,])],
sfs_cv_wideselect=yes, sfs_cv_wideselect=no, sfs_cv_wideselect=no))
if test $sfs_cv_wideselect = yes; then
AC_DEFINE(HAVE_WIDE_SELECT, 1,
Define if select can take file descriptors >= FD_SETSIZE)
fi])
dnl
dnl Check for 64-bit off_t
dnl
AC_DEFUN([SFS_CHECK_OFF_T_64],
[AC_CACHE_CHECK(for 64-bit off_t, sfs_cv_off_t_64,
AC_TRY_COMPILE([
#include <unistd.h>
#include <sys/types.h>
],[
switch (0) case 0: case (sizeof (off_t) <= 4):;
], sfs_cv_off_t_64=no, sfs_cv_off_t_64=yes))
if test $sfs_cv_off_t_64 = yes; then
AC_DEFINE(HAVE_OFF_T_64, 1, Define if off_t is 64 bits wide.)
fi])
dnl
dnl Check for type
dnl
AC_DEFUN([SFS_CHECK_TYPE],
[AC_CACHE_CHECK(for $1, sfs_cv_type_[]translit($1, [ ], [_]),
AC_TRY_COMPILE([
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_RPC_RPC_H
#include <rpc/rpc.h>
#endif
$2
],[
sizeof($1);
], sfs_cv_type_[]translit($1, [ ], [_])=yes, sfs_cv_type_[]translit($1, [ ], [_])=no))
if test $sfs_cv_type_[]translit($1, [ ], [_]) = yes; then
AC_DEFINE(HAVE_[]translit($1, [a-z ], [A-Z_]), 1,
Define if system headers declare a $1 type.)
fi])
dnl
dnl Check if system defines u_int64_t as an unsigned long long
dnl
AC_DEFUN([SFS_CHECK_U_INT64],
[AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 0)
SFS_CHECK_TYPE(u_int64_t)
AC_CACHE_CHECK(whether u_int64_t is an unsigned long long,
sfs_cv_u_int64_t_is_long_long,
if test 8 -gt "$ac_cv_sizeof_long"; then
sfs_cv_u_int64_t_is_long_long=yes
elif test yes != "$sfs_cv_type_u_int64_t"; then
sfs_cv_u_int64_t_is_long_long=yes
else
AC_COMPILE_IFELSE([
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_RPC_RPC_H
#include <rpc/rpc.h>
#endif
void f (u_int64_t val);
void
f (unsigned long long val)
{
}
], sfs_cv_u_int64_t_is_long_long=yes, sfs_cv_u_int64_t_is_long_long=no)
fi)
if test yes = "$sfs_cv_u_int64_t_is_long_long"; then
AC_DEFINE(U_INT64_T_IS_LONG_LONG, 1,
Define if system header files typedef u_int64_t as unsigned long long)
fi])
dnl
dnl Check for struct cmsghdr (for passing file descriptors)
dnl
AC_DEFUN([SFS_CHECK_FDPASS],
[
AC_CACHE_CHECK(for fd passing with msg_accrights in msghdr,
sfs_cv_accrights,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
struct msghdr mh;
mh.msg_accrights = 0;
], sfs_cv_accrights=yes, sfs_cv_accrights=no))
AC_CACHE_CHECK(for fd passing with struct cmsghdr, sfs_cv_cmsghdr,
if test "$sfs_cv_accrights" != "yes"; then
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
struct msghdr mh;
struct cmsghdr cmh;
mh.msg_control = (void *) &cmh;
], sfs_cv_cmsghdr=yes, sfs_cv_cmsghdr=no)
else
sfs_cv_cmsghdr=no
fi)
if test $sfs_cv_accrights = yes; then
AC_DEFINE(HAVE_ACCRIGHTS, 1,
Define if msghdr has msg_accrights field for passing file descriptors.)
fi
if test $sfs_cv_cmsghdr = yes; then
AC_DEFINE(HAVE_CMSGHDR, 1,
Define if system has cmsghdr structure for passing file descriptors.)
fi])
dnl
dnl Check for sa_len in struct sockaddrs
dnl
AC_DEFUN([SFS_CHECK_SA_LEN],
[AC_CACHE_CHECK(for sa_len in struct sockaddr, sfs_cv_sa_len,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
struct sockaddr sa;
sa.sa_len = 0;
], sfs_cv_sa_len=yes, sfs_cv_sa_len=no))
if test $sfs_cv_sa_len = yes; then
AC_DEFINE(HAVE_SA_LEN, 1,
Define if struct sockaddr has sa_len field.)
fi])
dnl
dnl Check for sockaddr_storage
dnl
AC_DEFUN([SFS_CHECK_SOCKADDR_STORAGE],
[SFS_CHECK_TYPE(struct sockaddr_storage)
AC_CACHE_CHECK(for __ss_len in sockaddr_storage, sfs_cv_ss_len_underscores,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
struct sockaddr_storage ss;
ss.__ss_len = 0;
], sfs_cv_ss_len_underscores=yes, sfs_cv_ss_len_underscores=no))
if test $sfs_cv_ss_len_underscores = yes; then
AC_DEFINE(HAVE_SS_LEN_UNDERSCORES, 1,
Define if struct sockaddr_storage has __ss_len field, not ss_len)
fi])
dnl
dnl Check something about the nfs_args field
dnl
AC_DEFUN([SFS_TRY_NFSARG_FIELD],
[AC_TRY_COMPILE([
#include "${srcdir}/nfsconf.h"
],[
struct nfs_args na;
$1;
], $2, $3)])
dnl
dnl Check a particular field in nfs_args
dnl
AC_DEFUN([SFS_CHECK_NFSMNT_FIELD],
[AC_CACHE_CHECK(for $1 in nfs_args structure, sfs_cv_nfsmnt_$1,
SFS_TRY_NFSARG_FIELD(na.$1, sfs_cv_nfsmnt_$1=yes, sfs_cv_nfsmnt_$1=no))
if test $sfs_cv_nfsmnt_$1 = yes; then
AC_DEFINE(HAVE_NFSMNT_[]translit($1, [a-z], [A-Z]), 1,
Define if the nfs_args structure has a $1 field.)
fi])
dnl
dnl Check if nfs_args hostname field is an array
dnl
AC_DEFUN([SFS_CHECK_NFSARG_HOSTNAME_ARRAY],
[AC_CACHE_CHECK(if nfs_args hostname field is an array, sfs_cv_nfs_hostarray,
SFS_TRY_NFSARG_FIELD(na.hostname = 0,
sfs_cv_nfs_hostarray=no, sfs_cv_nfs_hostarray=yes))
if test $sfs_cv_nfs_hostarray = yes; then
AC_DEFINE(HAVE_NFSARG_HOSTNAME_ARRAY, 1,
[The hostname field of nfs_arg is an array])
fi])
dnl
dnl Check if addr field is a pointer or not
dnl
AC_DEFUN([SFS_CHECK_NFSARG_ADDR_PTR],
[AC_CHECK_HEADERS(tiuser.h)
AC_CACHE_CHECK(if nfs_args addr field is a pointer, sfs_cv_nfsmnt_addr_ptr,
SFS_TRY_NFSARG_FIELD(na.addr = (void *) 0, sfs_cv_nfsmnt_addr_ptr=yes,
sfs_cv_nfsmnt_addr_ptr=no))
if test $sfs_cv_nfsmnt_addr_ptr = yes; then
AC_DEFINE(HAVE_NFSARG_ADDR_PTR, 1,
[The addr field of nfs_arg is a pointer])
AC_CACHE_CHECK(if nfs_args addr is a netbuf *, sfs_cv_nfsmnt_addr_netbuf,
SFS_TRY_NFSARG_FIELD(struct netbuf nb; *na.addr = nb,
sfs_cv_nfsmnt_addr_netbuf=yes, sfs_cv_nfsmnt_addr_netbuf=no))
if test $sfs_cv_nfsmnt_addr_netbuf = yes; then
AC_DEFINE(HAVE_NFSARG_ADDR_NETBUF, 1,
[If the nfs_arg addr field is a netbuf pointer])
fi
fi])
dnl
dnl Check for SVR4-like nfs_fh3 structure
dnl
AC_DEFUN([SFS_CHECK_FH3_SVR4],
[if test "$sfs_cv_nfsmnt_fhsize" != yes; then
AC_CACHE_CHECK(for SVR4-like struct nfs_fh3, sfs_cv_fh3_svr4,
AC_TRY_COMPILE([#include "${srcdir}/nfsconf.h"],
[ struct nfs_fh3 fh;
switch (0) case 0: case sizeof (fh.fh3_u.data) == 64:; ],
sfs_cv_fh3_svr4=yes, sfs_cv_fh3_svr4=no))
if test $sfs_cv_fh3_svr4 = yes; then
AC_DEFINE(HAVE_SVR4_FH3, 1,
[The the fh field of the nfs_arg structure points to an SVR4 nfs_fh3])
fi
fi])
dnl
dnl Check for 2 argument unmount
dnl
AC_DEFUN([SFS_CHECK_UNMOUNT_FLAGS],
[AC_CACHE_CHECK(for a 2 argument unmount, sfs_cv_umount_flags,
AC_TRY_COMPILE([
#include <sys/param.h>
#include <sys/mount.h>
],[
#ifdef HAVE_UNMOUNT
unmount
#else /* !HAVE_UNMOUNT */
umount
#endif /* !HAVE_UNMOUNT */
(0);
], sfs_cv_umount_flags=no, sfs_cv_umount_flags=yes))
if test $sfs_cv_umount_flags = yes; then
AC_DEFINE(UNMOUNT_FLAGS, 1,
Define if the unmount system call has 2 arguments.)
else
AC_CHECK_FUNCS(umount2)
fi])
dnl
dnl Check if we can find the nfs_args structure
dnl
AC_DEFUN([SFS_CHECK_NFSMNT],
[AC_CHECK_FUNCS(vfsmount unmount)
AC_CHECK_HEADERS(nfs/nfsproto.h, [], [],
[#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>])
need_nfs_nfs_h=no
AC_EGREP_HEADER(nfs_args, sys/mount.h,,
AC_EGREP_HEADER(nfs_args, nfs/mount.h,
AC_DEFINE(NEED_NFS_MOUNT_H, 1,
[The nfs_args structure is in <nfs/mount.h>]))
AC_EGREP_HEADER(nfs_args, nfs/nfsmount.h,
AC_DEFINE(NEED_NFS_NFSMOUNT_H, 1,
[The nfs_args structure is in <nfs/nfsmount.h]))
AC_EGREP_HEADER(nfs_args, nfsclient/nfs.h,
AC_DEFINE(NEED_NFSCLIENT_NFS_H, 1,
[The nfs_args structure is in <nfsclient/nfs.h>]))
AC_EGREP_HEADER(nfs_args, nfsclient/nfsargs.h,
AC_DEFINE(NEED_NFSCLIENT_NFSARGS_H, 1,
[The nfs_args structure is in <nfsclient/nfsargs.h>]))
AC_EGREP_HEADER(nfs_args, nfs/nfs.h,
AC_DEFINE(NEED_NFS_NFS_H, 1,
[The nfs_args structure is in <nfs/nfs.h>])
need_nfs_nfs_h=yes))
AC_CACHE_CHECK(for nfs_args mount structure, sfs_cv_nfsmnt_ok,
SFS_TRY_NFSARG_FIELD(, sfs_cv_nfsmnt_ok=yes, sfs_cv_nfsmnt_ok=no))
if test $sfs_cv_nfsmnt_ok = no; then
AC_MSG_ERROR([Could not find NFS mount argument structure!])
fi
if test "$need_nfs_nfs_h" = no; then
AC_EGREP_HEADER(nfs_fh3, nfs/nfs.h,
AC_DEFINE(NEED_NFS_NFS_H, 1,
[The nfs_args structure is in <nfs/nfs.h>])
need_nfs_nfs_h=yes)
fi
AC_CHECK_HEADERS(linux/nfs2.h)
SFS_CHECK_NFSMNT_FIELD(addrlen)
SFS_CHECK_NFSMNT_FIELD(sotype)
SFS_CHECK_NFSMNT_FIELD(proto)
SFS_CHECK_NFSMNT_FIELD(fhsize)
SFS_CHECK_NFSMNT_FIELD(fd)
dnl Check whether we have Linux 2.2 NFS V3 mount structure
SFS_CHECK_NFSMNT_FIELD(old_root)
dnl Check whether file handle is named "root" or "fh"
SFS_CHECK_NFSMNT_FIELD(root)
SFS_CHECK_NFSMNT_FIELD(fh)
dnl ksh apparently cannot handle this as a compound test.
if test "$sfs_cv_nfsmnt_root" = "no"; then
if test "$sfs_cv_nfsmnt_fh" = "no"; then
AC_MSG_ERROR([Could not find the nfs_args file handle field!])
fi
fi
AC_CHECK_HEADERS(sys/mntent.h)
SFS_CHECK_FH3_SVR4
if test "$sfs_cv_nfsmnt_fh" = yes; then
if test "$sfs_cv_fh3_svr4" = yes -o "$sfs_cv_nfsmnt_fhsize" = yes; then
AC_DEFINE(HAVE_NFS_V3, 1, [If the system supports NFS 3])
fi
elif test "$sfs_cv_nfsmnt_old_root" = yes; then
AC_DEFINE(HAVE_NFS_V3, 1, [If the system supports NFS 3])
fi
SFS_CHECK_NFSARG_HOSTNAME_ARRAY
SFS_CHECK_NFSARG_ADDR_PTR
SFS_CHECK_UNMOUNT_FLAGS])
dnl
dnl Use -ldb only if we need it.
dnl
AC_DEFUN([SFS_FIND_DB],
[AC_CHECK_FUNC(dbopen)
if test $ac_cv_func_dbopen = no; then
AC_CHECK_LIB(db, dbopen)
if test $ac_cv_lib_db_dbopen = no; then
AC_MSG_ERROR([Could not find library for dbopen!])
fi
fi
])
dnl
dnl Check something about the stat structure
dnl
AC_DEFUN([SFS_TRY_STAT_FIELD],
[AC_TRY_COMPILE([
#include <sys/stat.h>
],[
struct stat s;
$1;
], $2, $3)])
dnl
dnl Check for a particular field in stat
dnl
AC_DEFUN([SFS_CHECK_STAT_FIELD],
[AC_CACHE_CHECK(for $1 in stat structure, sfs_cv_stat_$1,
SFS_TRY_STAT_FIELD(s.$1, sfs_cv_stat_$1=yes, sfs_cv_stat_$1=no))
if test $sfs_cv_stat_$1 = yes; then
AC_DEFINE(SFS_HAVE_STAT_[]translit($1, [a-z], [A-Z]), 1,
Define if the stat structure has a $1 field.)
fi])
dnl
dnl Check whether we can get away with large socket buffers.
dnl
AC_DEFUN([SFS_CHECK_SOCK_BUF],
[AC_CACHE_CHECK(whether socket buffers > 64k are allowed,
sfs_cv_large_sock_buf, AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
int
main()
{
int bigbuf = 0x11000;
int s = socket(AF_INET, SOCK_STREAM, 0);
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&bigbuf, sizeof(bigbuf))<0)
exit(1);
exit(0);
}
], sfs_cv_large_sock_buf=yes,
sfs_cv_large_sock_buf=no,
sfs_cv_large_sock_buf=no))
if test $sfs_cv_large_sock_buf = yes; then
AC_DEFINE(SFS_ALLOW_LARGE_BUFFER, 1,
Define if SO_SNDBUF/SO_RCVBUF can exceed 64K.)
fi])
dnl
dnl Test to see if we can bind a port with SO_REUSEADDR when
dnl there is a connected TCP socket using the same port number,
dnl but the connected socket does not have SO_REUSEADDR set.
dnl
AC_DEFUN([SFS_CHECK_BSD_REUSEADDR],
[AC_CACHE_CHECK(for BSD SO_REUSEADDR semantics, sfs_cv_bsd_reuseaddr,
[AC_RUN_IFELSE([changequote changequote([[,]])[[
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "confdefs.h"
#ifndef HAVE_SOCKLEN_T
# define socklen_t int
#endif /* !HAVE_SOCKLEN_T */
#ifndef bzero
# define bzero(a,b) memset((a), 0, (b))
#endif /* !bzero */
int
inetsocket (unsigned long addr, int port, int *portp)
{
int s;
struct sockaddr_in sin;
int n = 1;
bzero (&sin, sizeof (sin));
sin.sin_family = AF_INET;
sin.sin_port = htons (port);
sin.sin_addr.s_addr = htonl (addr);
s = socket (AF_INET, SOCK_STREAM, 0);
if (s < 0) {
perror ("socket");
exit (2);
}
if (port && setsockopt (s,SOL_SOCKET, SO_REUSEADDR, &n, sizeof n) < 0) {
perror ("SO_REUSEADDR");
exit (2);
}
if (bind (s, (struct sockaddr *) &sin, sizeof (sin)) < 0)
return -1;
if (portp) {
socklen_t sinlen = sizeof (sin);
getsockname (s, (struct sockaddr *) &sin, &sinlen);
*portp = ntohs (sin.sin_port);
}
return s;
}
int
connectlocal (int s, int dport)
{
struct sockaddr_in sin;
bzero (&sin, sizeof (sin));
sin.sin_family = AF_INET;
sin.sin_port = htons (dport);
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
return connect (s, (struct sockaddr *) &sin, sizeof (sin));
}
void
make_async (int s)
{
int n;
if ((n = fcntl (s, F_GETFL)) < 0
|| fcntl (s, F_SETFL, n | O_NONBLOCK) < 0) {
perror ("fcntl");
exit (2);
}
}
int
main (int argc, char **argv)
{
int s1, s1p;
int c1, c1p;
int c2;
s1 = inetsocket (INADDR_LOOPBACK, 0, &s1p);
listen (s1, 5);
c1 = inetsocket (INADDR_LOOPBACK, 0, &c1p);
make_async (c1);
if (connectlocal (c1, s1p) < 0) {
if (errno == EINPROGRESS) {
struct sockaddr_in sin;
socklen_t sinlen = sizeof (sin);
sin.sin_family = AF_INET;
accept (s1, (struct sockaddr *) &sin, &sinlen);
}
else {
perror ("connect");
exit (2);
}
}
c2 = inetsocket (INADDR_ANY, c1p, NULL);
exit (c2 < 0);
}
]]changequote([,])],
sfs_cv_bsd_reuseaddr=yes, sfs_cv_bsd_reuseaddr=no,
sfs_cv_bsd_reuseaddr=no)])
if test "$sfs_cv_bsd_reuseaddr" = yes; then
AC_DEFINE(HAVE_BSD_REUSEADDR, 1,
Define if SO_REUSEADDR allows same user to bind non-SO_REUSEADDR port)
fi])
dnl
dnl Find pthreads
dnl
AC_DEFUN([SFS_FIND_PTHREADS],
[AC_ARG_WITH(pthreads,
--with-pthreads=DIR Specify location of pthreads)
ac_save_CFLAGS=$CFLAGS
ac_save_LIBS=$LIBS
dirs="$with_pthreads ${prefix} ${prefix}/pthreads"
dirs="$dirs /usr/local /usr/local/pthreads"
AC_CACHE_CHECK(for pthread.h, sfs_cv_pthread_h,
[for dir in " " $dirs; do
iflags="-I${dir}/include"
CFLAGS="${ac_save_CFLAGS} $iflags"
AC_TRY_COMPILE([#include <pthread.h>], 0,
sfs_cv_pthread_h="${iflags}"; break)
done])
if test -z "${sfs_cv_pthread_h+set}"; then
AC_MSG_ERROR("Can\'t find pthread.h anywhere")
fi
AC_CACHE_CHECK(for libpthread, sfs_cv_libpthread,
[for dir in "" " " $dirs; do
case $dir in
"") lflags=" " ;;
" ") lflags="-lpthread" ;;
*) lflags="-L${dir}/lib -lpthread" ;;
esac
LIBS="$ac_save_LIBS $lflags"
AC_TRY_LINK([#include <pthread.h>],
pthread_create (0, 0, 0, 0);,
sfs_cv_libpthread=$lflags; break)
done])
if test -z ${sfs_cv_libpthread+set}; then
AC_MSG_ERROR("Can\'t find libpthread anywhere")
fi
CFLAGS=$ac_save_CFLAGS
CPPFLAGS="$CPPFLAGS $sfs_cv_pthread_h"
LIBS="$ac_save_LIBS $sfs_cv_libpthread"])
dnl
dnl Find GMP
dnl
AC_DEFUN([SFS_GMP],
[AC_ARG_WITH(gmp,
--with-gmp[[[=/usr/local]]] specify path for gmp)
AC_SUBST(GMP_DIR)
AC_SUBST(LIBGMP)
AC_MSG_CHECKING([for GMP library])
if test "$with_gmp" != "no"; then
ac_save_CPPFLAGS=$CPPFLAGS
ac_save_LIBS=$LIBS
cdirs="${with_gmp}/include ${prefix}/include"
dirs="$cdirs /usr/local/include /usr/include"
AC_CACHE_CHECK(for gmp.h, sfs_cv_gmp_h,
[for dir in " " $dirs; do
case $dir in
" ") iflags=" " ;;
*) iflags="-I${dir}" ;;
esac
CPPFLAGS="${ac_save_CPPFLAGS} $iflags"
AC_TRY_COMPILE([#include "gmp.h"], 0,
sfs_cv_gmp_h="${iflags}"; break)
done
if test "$sfs_cv_gmp_h" = " "; then
sfs_cv_gmp_h="yes"
fi
])
if test "$sfs_cv_gmp_h" = "yes"; then
sfs_cv_gmp_h=" "
fi
if test "${sfs_cv_gmp_h+set}"; then
cdirs="${with_gmp}/lib ${prefix}/lib"
dirs="$cdirs /usr/local/lib /usr/lib"
AC_CACHE_CHECK(for libgmp, sfs_cv_libgmp,
[for dir in "" " " $dirs; do
case $dir in
"") lflags=" "; Lflags="" ;;
" ") lflags="-lgmp"; Lflags="" ;;
*) Lflags="-L$dir"; lflags="-lgmp" ;;
esac
LIBS="$ac_save_LIBS $Lflags $lflags"
AC_TRY_LINK([#include "gmp.h"],
MP_INT i; mpz_init (&i);,
sfs_cv_libgmp=$lflags; \
LDFLAGS="$LDFLAGS $Lflags" ; \
LIBGMP="$lflags" ; break)
done
if test -z ${sfs_cv_libgmp+set}; then