-
Notifications
You must be signed in to change notification settings - Fork 154
/
acsite.m4
executable file
·1658 lines (1545 loc) · 45 KB
/
acsite.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
#######################################################################
# autoconf support macros
#######################################################################
dnl
dnl SNERT_JOIN_UNIQ(var, word_list)
dnl
AC_DEFUN([SNERT_JOIN_UNIQ],[
list=`eval echo \"\$$1\"`
for w in $2; do
AS_IF([expr "$list" : ".*$w" >/dev/null],[],[list="${list:+$list }$w"])
done
eval $1="\"$list\""
])
dnl
dnl SNERT_CHECK_DEFINE(symbol[, header_file])
dnl
dnl Without a header_file, check for a predefined macro.
dnl
AC_DEFUN([SNERT_CHECK_DEFINE],[
AC_LANG_PUSH([C])
AC_CACHE_CHECK([for $1],ac_cv_define_$1,[
AS_IF([test -z "$2"],[
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
int main()
{
#ifdef $1
return 0;
#else
return 1;
#endif
}
]])
],[
ac_cv_define_$1=yes
],[
ac_cv_define_$1=no
])
],[
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <$2>
int main()
{
#ifdef $1
return 0;
#else
return 1;
#endif
}
]])
],[
ac_cv_define_$1=yes
],[
ac_cv_define_$1=no
])
])
])
AC_LANG_POP([C])
AS_IF([test $ac_cv_define_$1 = 'yes'],[
AC_DEFINE_UNQUOTED([HAVE_MACRO_]translit($1, [a-z], [A-Z]))
AH_TEMPLATE([HAVE_MACRO_]translit($1, [a-z], [A-Z]))
])
])
dnl
dnl SNERT_CHECK_PREDEFINE(symbol)
dnl
AC_DEFUN(SNERT_CHECK_PREDEFINE,[
SNERT_CHECK_DEFINE($1)
])
dnl
dnl SNERT_IF_SYSTEM_DIR(word, if-system, not-system)
dnl
m4_define([SNERT_IF_SYSTEM_DIR],[
AS_CASE([$1],[/usr/include|/usr/lib64|/usr/lib],[$2],[$3])
])
dnl
dnl SNERT_FIND_FILE(wild_file, directories, if-found, not-found)
dnl if-found can reference the found $dir_val
dnl
AC_DEFUN([SNERT_FIND_FILE],[
AS_VAR_PUSHDEF([snert_dir], [snert_find_file_$1])
AS_VAR_SET([snert_dir],'no')
AC_MSG_CHECKING([for location of $1])
dnl File to find specifies an extension?
AS_IF([expr "$1" : '.*\.[[0-9a-zA-Z]]' >/dev/null],[
dnl Has an extension.
pattern="$1"
],[
dnl No extension, so look for any extension (.a and .so variants).
dnl Without the dot (.) to mark the end of the name prefix
dnl we can inadvertantly match libraries with similar prefixes,
dnl ie. libz and libzephyr
pattern="$1.*"
])
for d in $2; do
AS_IF([ls -1 $d/$pattern >/dev/null 2>&1],[
AS_VAR_SET([snert_dir],[$d])
break
])
done
AS_VAR_COPY([dir_val],[snert_dir])
dnl AS_IF([test "$dir_val" = 'no'],AC_MSG_RESULT(no),AC_MSG_RESULT(yes))
AC_MSG_RESULT($dir_val)
AS_VAR_IF([snert_dir],[no],[$4],[$3])
AS_VAR_POPDEF([snert_dir])
])
dnl
dnl SNERT_CHECK_PACKAGE_HEADER(header, if-found, not-found[, extra_dirs])
dnl
AC_DEFUN([SNERT_CHECK_PACKAGE_HEADER],[
SNERT_FIND_FILE([$1],[$4 /usr/pkg/include /usr/local/include /usr/include],[$2],[$3])
])
dnl
dnl SNERT_CHECK_PACKAGE_LIB(library, if-found, not-found[, extra_dirs])
dnl
AC_DEFUN([SNERT_CHECK_PACKAGE_LIB],[
SNERT_FIND_FILE([$1],[$4 /usr/pkg/lib /usr/local/lib /usr/lib64 /usr/lib],[$2],[$3])
])
dnl
dnl SNERT_DEFINE(name[, value])
dnl
AC_DEFUN([SNERT_DEFINE],[
name=AS_TR_CPP($1)
AS_IF([test -n "$2"],[value="$2"],[eval value="\$$name"])
AC_DEFINE_UNQUOTED($name,["$value"])
])
dnl
dnl SNERT_CHECK_PACKAGE(name, headers, libs, funcs, with_base, with_inc, with_lib, extra_includes)
dnl
AC_DEFUN([SNERT_CHECK_PACKAGE],[
AS_ECHO()
AS_ECHO("Checking for $1 package...")
AS_ECHO()
dnl Watch out for leading and trailing whitespace with m4 macros;
dnl everything delimited by open/close paren and/or commas is
dnl part of the argument, so pretty formatting for readability
dnl can screw with string compares. Use echo to trim whitespace.
with_base=`AS_ECHO([$5])`
AS_IF([test "$with_base" != 'no'],[
dnl Careful with --with options as they can be specified,
dnl without a base directory path, in which case ignore it.
AS_IF([test "$with_base" = 'yes'],[
with_base=''
])
for f in $2; do
SNERT_CHECK_PACKAGE_HEADER([$f],[
have=AS_TR_CPP(HAVE_$f)
AC_DEFINE_UNQUOTED($have,[1])
cache_id=AS_TR_SH(ac_cv_header_$f)
AC_CACHE_VAL($cache_id, eval $cache_id='yes')
SNERT_IF_SYSTEM_DIR([$dir_val],[
dnl Ignore system directories.
],[
dnl Add only one -Idir instance.
AS_IF([eval expr "\"\$CPPFLAGS_$1\"" : "\".*\\(-I$dir_val\\)\"" >/dev/null],[
dnl
],[
eval CPPFLAGS_$1=\"\${CPPFLAGS_$1:+\$CPPFLAGS_$1 }-I$dir_val\"
])
])
],[],[${with_base:+$with_base/include} $6])
done
SNERT_DEFINE(CPPFLAGS_[$1])
AC_SUBST(CPPFLAGS_[$1])
for f in $3; do
SNERT_CHECK_PACKAGE_LIB([$f],[
have=AS_TR_CPP(HAVE_$f)
AC_DEFINE_UNQUOTED($have,[1])
SNERT_IF_SYSTEM_DIR([$dir_val],[
lib=`basename -- $f | sed -e's/^lib//'`
eval LIBS_$1=\"\${LIBS_$1:+\$LIBS_$1 }-l\"$lib
],[
dnl Add only one -Ldir instance.
AS_IF([eval expr "\"\$LDFLAGS_$1\"" : "\".*\\(-L$dir_val\\)\"" >/dev/null],[
dnl
],[
eval LDFLAGS_$1=\"\${LDFLAGS_$1:+\$LDFLAGS_$1 }-L$dir_val\"
])
AS_IF([expr "$f" : '.*\.a$' >/dev/null],[
dnl Explicit static library.
eval LIBS_$1=\"\${LIBS_$1:+\$LIBS_$1 }$dir_val/$f\"
],[
lib=`basename -- $f | sed -e's/^lib//'`
eval LIBS_$1=\"\${LIBS_$1:+\$LIBS_$1 }-l\"$lib
])
])
],[],[${with_base:+$with_base/lib} $7])
done
SNERT_DEFINE(LDFLAGS_[$1])
SNERT_DEFINE(LIBS_[$1])
AC_SUBST(LDFLAGS_[$1])
AC_SUBST(LIBS_[$1])
AS_IF([test -n "$4"],[
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
eval LIBS=\"\$LIBS_$1 $LIBS\"
eval LDFLAGS=\"\$LDFLAGS_$1 $LDFLAGS\"
eval CPPFLAGS=\"\$CPPFLAGS_$1 $CPPFLAGS\"
AC_CHECK_FUNCS([$4],[],[],[$8])
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
])
],[
AC_MSG_NOTICE([Package $1 has been explicitly disabled.])
])
])
dnl
dnl SNERT_OPTION_ENABLE_DEBUG
dnl
AC_DEFUN(SNERT_OPTION_ENABLE_DEBUG,[
dnl Assert that CFLAGS is defined. When AC_PROC_CC is called to
dnl check the compiler and CC == gcc is found and CFLAGS is
dnl undefined, then it gets assigned "-g -O2", which is just
dnl annoying when you want the default to no debugging.
CPPFLAGS="${CPPFLAGS}"
CFLAGS="${CFLAGS}"
AC_ARG_ENABLE(debug,[AC_HELP_STRING([--enable-debug],[enable compiler debug option])],[
],[
AC_DEFINE(NDEBUG,[1],[Disable debug code])
])
])
AC_DEFUN([SNERT_CC_INFO],[
AC_REQUIRE([AC_PROG_CC])
AC_USE_SYSTEM_EXTENSIONS
AC_LANG([C])
AS_IF([test "$GCC" = 'yes'],[
GCC_MAJOR=`$CC -dM -E -xc /dev/null | sed -n -e 's/.*__GNUC__ \(.*\)/\1/p'`
GCC_MINOR=`$CC -dM -E -xc /dev/null | sed -n -e 's/.*__GNUC_MINOR__ \(.*\)/\1/p'`
GCC_PATCH=`$CC -dM -E -xc /dev/null | sed -n -e 's/.*__GNUC_PATCHLEVEL__ \(.*\)/\1/p'`
dnl Nothing wrong using a char for a subscript.
AS_IF([test $GCC_MAJOR -ge 3],[CFLAGS="-Wno-char-subscripts $CFLAGS"])
dnl Option to ignore extra support functions.
AS_IF([test $GCC_MAJOR -ge 4 -a $GCC_MINOR -ge 3 ],[CFLAGS="-Wno-unused-function $CFLAGS"])
dnl Option to silience Valgrind and ProtoThread macro warnings.
AS_IF([test $GCC_MAJOR -ge 4 -a $GCC_MINOR -ge 6 ],[CFLAGS="-Wno-unused-but-set-variable $CFLAGS"])
CFLAGS="-Wall $CFLAGS"
])
AS_IF([test ${enable_debug:-no} = 'no'],[
CFLAGS="-O2 ${CFLAGS}"
LDFLAGS="${LDFLAGS}"
],[
CFLAGS="-O0 -g ${CFLAGS}"
])
dnl Tradional cc options.
dnl NOTE SunOS as(1) _wants_ a space between -o and its argument.
CC_E='-o'
CC_E_NAME='-o $@'
CC_O='-o'
CC_O_NAME='-o $''*$O'
LD=$CC
AC_SUBST(CC_E)
AC_SUBST(CC_E_NAME)
AC_SUBST(CC_O)
AC_SUBST(CC_O_NAME)
dnl Check for recent ANSI C additions that HAVE_HEADER_STDC check
dnl doesn't distinguish between C89 and C99.
AC_CHECK_HEADERS([stdarg.h])
SNERT_CHECK_DEFINE([va_copy], [stdarg.h])
])
AC_DEFUN([SNERT_TAR_SETTINGS],[
AC_MSG_CHECKING(for tar file list option to use)
AS_IF([tar --version 2>&1 | grep '(GNU tar)' >/dev/null],[
TAR_I='-T'
],[
TAR_I='-I'
])
AC_SUBST(TAR_I)
AC_MSG_RESULT($TAR_I)
])
#######################################################################
# API Families
#######################################################################
dnl
dnl SNERT_ANSI_STRING
dnl
AC_DEFUN(SNERT_ANSI_STRING,[
AS_ECHO()
AS_ECHO("Check for ANSI string functions...")
AS_ECHO()
AC_CHECK_FUNCS([ dnl
memchr memcmp memcpy memmove memset dnl
strcat strncat strcpy strncpy strcmp strncmp strxfrm dnl
strchr strcspn strerror strlen strpbrk strrchr strspn strstr strtok dnl
sys_errlist dnl
])
AC_FUNC_STRCOLL
AC_FUNC_STRERROR_R
])
dnl
dnl SNERT_EXTRA_STRING
dnl
AC_DEFUN(SNERT_EXTRA_STRING,[
AS_ECHO()
AS_ECHO("Check for supplemental string support...")
AS_ECHO()
AC_CHECK_FUNCS([ dnl
strdup strtol strlcpy strlcat strcasecmp strncasecmp dnl
snprintf vsnprintf setproctitle dnl
])
])
AC_DEFUN(SNERT_FILE_LOCKS,[
AS_ECHO()
AS_ECHO("Check for file locking...")
AS_ECHO()
AC_CHECK_HEADERS([fcntl.h],[
AC_CHECK_FUNCS(flock fcntl lockf locking)
SNERT_CHECK_DEFINE(O_BINARY, fcntl.h)
SNERT_CHECK_DEFINE(LOCK_SH, fcntl.h)
dnl Discontinue used of old flags, switch to O_NONBLOCK.
SNERT_CHECK_DEFINE(O_NDELAY, fcntl.h)
SNERT_CHECK_DEFINE(FNDELAY, fcntl.h)
])
AH_VERBATIM(HAVE_LOCK_SH,[
/*
* Define the flock() constants separately, since some systems
* have flock(), but fail to define the constants in a header.
* These values were taken from FreeBSD.
*/
#ifndef HAVE_MACRO_LOCK_SH
# define LOCK_SH 0x01 /* shared file lock */
# define LOCK_EX 0x02 /* exclusive file lock */
# define LOCK_NB 0x04 /* don't block when locking */
# define LOCK_UN 0x08 /* unlock file */
#endif
])
])
dnl
dnl SNERT_POSIX_IO
dnl
AC_DEFUN(SNERT_POSIX_IO,[
AS_ECHO()
AS_ECHO("Check for POSIX File & Directory I/O support...")
AS_ECHO()
AC_HEADER_DIRENT
dnl autoconf says the following should be included:
dnl
dnl #if HAVE_DIRENT_H
dnl # include <dirent.h>
dnl # define NAMLEN(dirent) strlen((dirent)->d_name)
dnl #else
dnl # define dirent direct
dnl # define NAMLEN(dirent) (dirent)->d_namlen
dnl # if HAVE_SYS_NDIR_H
dnl # include <sys/ndir.h>
dnl # endif
dnl # if HAVE_SYS_DIR_H
dnl # include <sys/dir.h>
dnl # endif
dnl # if HAVE_NDIR_H
dnl # include <ndir.h>
dnl # endif
dnl #endif
AC_CHECK_HEADERS([unistd.h fcntl.h sys/stat.h utime.h])
AC_CHECK_FUNCS([ dnl
chdir getcwd mkdir rmdir closedir opendir readdir dnl
chmod chown chroot fchmod stat fstat link rename symlink unlink umask utime dnl
close creat dup dup2 ftruncate chsize truncate lseek open pipe read write dnl
isatty getdtablesize dnl
])
AC_FUNC_CHOWN
])
dnl
dnl SNERT_SYS
dnl
AC_DEFUN([SNERT_SYS],[
AS_ECHO()
AS_ECHO("Check for system kernel support...")
AS_ECHO()
dnl Linux
AC_CHECK_HEADERS([sys/prctl.h],[
AC_CHECK_FUNCS(prctl)
])
AC_CHECK_HEADERS([sys/sysinfo.h],[
AC_CHECK_FUNCS(get_nprocs_conf get_nprocs)
])
dnl *BSD
AC_CHECK_HEADERS([sys/param.h sys/sysctl.h],[
AC_CHECK_FUNCS(sysctl)
])
AC_CHECK_HEADERS([stdlib.h],[
AC_CHECK_FUNCS(getloadavg)
])
dnl POSIX / generic
AC_CHECK_HEADERS([unistd.h],[
AC_CHECK_FUNCS(fpathconf pathconf sysconf)
])
])
dnl
dnl SNERT_PROCESS
dnl
AC_DEFUN(SNERT_PROCESS,[
AS_ECHO()
AS_ECHO("Check for process support...")
AS_ECHO()
AC_CHECK_HEADER([unistd.h],[
AC_DEFINE_UNQUOTED(HAVE_UNISTD_H)
AC_CHECK_FUNCS([ dnl
getopt getuid getgid setuid setgid dnl
geteuid getegid seteuid setegid getpgid setpgid dnl
getresuid getresgid setresuid setresgid dnl
setreuid getgroups setgroups initgroups dnl
_exit exit daemon fork execl execle execlp execv execve execvp setsid dnl
])
])
AC_CHECK_HEADER([sys/wait.h],[
AC_DEFINE(HAVE_SYS_WAIT_H,[],[Process Support])
AC_CHECK_FUNCS([wait wait3 wait4 waitpid])
])
AC_CHECK_HEADER([sys/resource.h],[
AC_DEFINE(HAVE_SYS_RESOURCE_H,[],[Process Resources])
AC_CHECK_TYPES([struct rlimit, rlim_t],[],[],[
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <sys/resource.h>
])
AC_CHECK_FUNCS([getrlimit setrlimit])
])
AC_CHECK_HEADERS([limits.h sysexits.h syslog.h])
])
dnl
dnl SNERT_NETWORK
dnl
AC_DEFUN(SNERT_NETWORK,[
AS_ECHO()
AS_ECHO("Check for Network services...")
AS_ECHO()
SNERT_CHECK_PREDEFINE(__WIN32__)
SNERT_CHECK_PREDEFINE(__CYGWIN__)
AS_IF([test "$ac_cv_define___WIN32__" = 'no'],[
AC_SEARCH_LIBS([socket], [socket nsl])
AC_SEARCH_LIBS([inet_aton], [socket nsl resolv])
AC_CHECK_HEADERS([ dnl
sys/socket.h netinet/in.h netinet/in6.h netinet6/in6.h dnl
netinet/tcp.h poll.h sys/poll.h sys/select.h sys/un.h dnl
arpa/inet.h dnl
])
dnl When using poll() use this block.
dnl
dnl #ifdef HAVE_POLL_H
dnl # include <poll.h>
dnl # ifndef INFTIM
dnl # define INFTIM (-1)
dnl # endif
dnl #endif
dnl When using kqueue() use this block.
dnl
dnl #ifdef HAVE_SYS_EVENT_H
dnl # include <sys/types.h>
dnl # include <sys/event.h>
dnl # include <sys/time.h>
dnl # ifndef INFTIM
dnl # define INFTIM (-1)
dnl # endif
dnl #endif
AC_CHECK_FUNCS([ dnl
inet_pton inet_aton inet_addr inet_ntoa inet_ntop dnl
accept bind connect listen poll select shutdown socket dnl
getpeereid getpeername getsockname getsockopt setsockopt dnl
recv recvfrom recvmsg send sendmsg sendto dnl
htonl htons ntohl ntohs dnl
])
AC_CHECK_HEADERS([sys/event.h],[AC_CHECK_FUNCS([kqueue kevent])])
AC_CHECK_HEADERS([sys/epoll.h],[AC_CHECK_FUNCS([epoll_create epoll_ctl epoll_wait epoll_pwait])])
AC_CHECK_HEADERS([netdb.h],[
AC_CHECK_FUNCS([ dnl
getaddrinfo freeaddrinfo getnameinfo dnl
gethostname gethostbyname gethostbyname2 gethostbyaddr dnl
gethostbyname_r gethostbyname2_r gethostbyaddr_r dnl
gethostent sethostent endhostent hstrerror herror dnl
getservent getservbyport getservbyname setservent endservent dnl
getprotoent getprotobynumber getprotobyname setprotoent endprotoent dnl
])
])
AC_CHECK_HEADERS([ifaddrs.h],[
AC_CHECK_FUNCS([getifaddrs freeifaddrs])
])
AC_CHECK_HEADERS([net/if.h],[
AC_CHECK_FUNCS([if_nameindex if_freenameindex if_nametoindex if_indextoname])
])
],[
AC_CHECK_HEADERS(windows.h)
AC_CHECK_HEADER(winsock2.h,[
AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]winsock2.h),[],[Windows BSD Socket API])
],[],[
#if defined(__WIN32__)
# if defined(HAVE_WINDOWS_H)
# include <windows.h>
# endif
#endif
])
AC_CHECK_HEADER(ws2tcpip.h,[
AC_SUBST(HAVE_LIB_WS2_32, '-lws2_32')
AC_DEFINE(AS_TR_CPP([HAVE_]ws2tcpip.h),[],[Windows TCP/IP API])
],[],[
#if defined(__WIN32__)
# if defined(HAVE_WINDOWS_H)
# include <windows.h>
# endif
# if defined(HAVE_WINSOCK2_H)
# include <winsock2.h>
# endif
#endif
])
AC_CHECK_HEADER(Iphlpapi.h,[
AC_SUBST(HAVE_LIB_IPHLPAPI, '-lIphlpapi')
AC_DEFINE(AS_TR_CPP([HAVE_]Iphlpapi.h),[],[Windows IP Helper library])
],[],[
#if defined(__WIN32__)
# if defined(HAVE_WINDOWS_H)
# include <windows.h>
# endif
#endif
])
for i in \
accept \
bind \
closesocket \
connect \
endservent \
getpeername \
getprotobyname \
getprotobynumber \
getservbyname \
getservbyport \
getservent \
getsockname \
getsockopt \
htonl \
htons \
inet_addr \
inet_ntoa \
listen \
ntohl \
ntohs \
recv \
recvfrom \
select \
send \
sendto \
setservent \
setsockopt \
shutdown \
socket \
getaddrinfo freeaddrinfo getnameinfo \
gethostname gethostbyname gethostbyaddr
do
AC_MSG_CHECKING([for $i])
AC_DEFINE(AS_TR_CPP([HAVE_]$i),[],[function $1])
AC_MSG_RESULT([assumed in winsock2.h & ws2tcpip.h])
done
])
AS_IF([test ${ac_cv_define___CYGWIN__:-no} != 'no' -o ${ac_cv_define___WIN32__:-no} != 'no'],[
NETWORK_LIBS="-lws2_32 -lIphlpapi $NETWORK_LIBS"
AC_SUBST(NETWORK_LIBS, ${NETWORK_LIBS})
])
AC_CHECK_TYPES([struct sockaddr_in6, struct in6_addr, struct sockaddr_un, socklen_t, struct sockaddr_storage],[],[],[
#if defined(__WIN32__)
# define WINVER 0x0501
# if defined(HAVE_WINDOWS_H)
# include <windows.h>
# endif
# if defined(HAVE_WINSOCK2_H)
# include <winsock2.h>
# endif
# if defined(HAVE_WS2TCPIP_H)
# include <ws2tcpip.h>
# endif
#else
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# endif
# ifdef HAVE_SYS_UN_H
# include <sys/un.h>
# endif
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_NETINET_IN6_H
# include <netinet/in6.h>
# endif
# ifdef HAVE_NETINET6_IN6_H
# include <netinet6/in6.h>
# endif
#endif
])
AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len, struct sockaddr_un.sun_len],[],[],[
#if defined(__WIN32__)
# define WINVER 0x0501
# if defined(HAVE_WINDOWS_H)
# include <windows.h>
# endif
# if defined(HAVE_WINSOCK2_H)
# include <winsock2.h>
# endif
# if defined(HAVE_WS2TCPIP_H)
# include <ws2tcpip.h>
# endif
#else
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# endif
# ifdef HAVE_SYS_UN_H
# include <sys/un.h>
# endif
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_NETINET_IN6_H
# include <netinet/in6.h>
# endif
# ifdef HAVE_NETINET6_IN6_H
# include <netinet6/in6.h>
# endif
#endif
])
])
dnl
dnl SNERT_ANSI_TIME
dnl
AC_DEFUN(SNERT_ANSI_TIME,[
AS_ECHO()
AS_ECHO("Check for ANSI & supplemental time support...")
AS_ECHO()
dnl saved_libs=$LIBS
AC_CHECK_HEADERS(time.h sys/time.h)
AC_HEADER_TIME
dnl autoconf says the following should be included:
dnl
dnl #ifdef TIME_WITH_SYS_TIME
dnl # include <sys/time.h>
dnl # include <time.h>
dnl #else
dnl # ifdef HAVE_SYS_TIME_H
dnl # include <sys/time.h>
dnl # else
dnl # include <time.h>
dnl # endif
dnl #endif
AC_SEARCH_LIBS([clock_gettime],[rt])
AS_IF([expr "$ac_cv_search_clock_gettime" : '-l' >/dev/null],[
LIBS_RT="$ac_cv_search_clock_gettime"
AC_DEFINE_UNQUOTED(LIBS_RT,"$LIBS_RT",[Realtime library])
AC_SUBST(LIBS_RT)
])
AC_CHECK_FUNCS([ dnl
clock difftime mktime time asctime ctime gmtime localtime tzset sleep usleep nanosleep dnl
asctime_r ctime_r gmtime_r localtime_r clock_gettime gettimeofday dnl
alarm getitimer setitimer dnl
])
dnl These are typically macros: timerclear timerisset timercmp timersub timeradd
AC_FUNC_STRFTIME
AC_CHECK_TYPES([struct timespec, struct timeval],[],[],[
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
])
AC_STRUCT_TM
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],[],[],[
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
])
AC_STRUCT_TIMEZONE
AC_CHECK_FUNCS(timegm)
dnl LIBS=$saved_libs
])
dnl
dnl SNERT_REGEX
dnl
AC_DEFUN([SNERT_REGEX],[
AS_ECHO()
AS_ECHO("Check for regex...")
AS_ECHO()
AC_CHECK_HEADERS([regex.h],[
AC_SEARCH_LIBS([regcomp], [regex])
dnl Redo function tests; see SNERT_PCRE.
AS_UNSET(ac_cv_func_regcomp)
AS_UNSET(ac_cv_func_regexec)
AS_UNSET(ac_cv_func_regerror)
AS_UNSET(ac_cv_func_regfree)
AC_CHECK_FUNCS(regcomp regexec regerror regfree)
])
])
AC_DEFUN(CYRUS_SIGVEC,[
AS_ECHO()
AS_ECHO("Check for sigvec...")
AS_ECHO()
AC_SEARCH_LIBS([sigvec],[BSD],[
AS_IF([test "$ac_cv_search_sigvec" = 'none required'],[
ac_cv_search_sigvec=''
])
],[
SAVE_LDFLAGS="$LDFLAGS"
dnl solaris flavor
LDFLAGS="-L/usr/ucblib -R/usr/ucblib $LDFLAGS"
AS_UNSET([ac_cv_search_sigvec])
AC_SEARCH_LIBS([sigvec],[ucb],[
dnl more solaris flavor
ac_cv_search_sigvec="-L/usr/ucblib -R/usr/ucblib -lucb"
])
LDFLAGS="$SAVE_LDFLAGS"
])
AC_SUBST(cyrus_cv_sigveclib, $ac_cv_search_sigvec)
])
dnl
dnl CYRUS_MMAP
dnl
AC_DEFUN(CYRUS_MMAP,[
AS_ECHO()
AS_ECHO("Check MMAP...")
AS_ECHO()
AC_CHECK_HEADERS([sys/mman.h],[
AC_CHECK_FUNCS([madvise mlock mmap mprotect msync munmap])
])
AC_CACHE_CHECK([for shared mmap],[cyrus_cv_func_mmap_shared],[
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_MMAN_H
# include <sys/mman.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
int
main(int argc, char **argv)
{
char *base;
int fd, mmapflags = MAP_SHARED;
/* Create a file. */
if ((fd = open("conftestmmap", O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
return 1;
(void) unlink("conftestmmap");
if (write(fd, "test", 4) != 4)
return 2;
(void) fsync(fd);
/* Map file into memory. */
#ifdef MAP_FILE
mmapflags |= MAP_FILE;
#endif
#ifdef MAP_VARIABLE
mmapflags |= MAP_VARIABLE;
#endif
base = mmap((caddr_t)0, 100, PROT_READ, mmapflags, fd, 0L);
if (base == (caddr_t)-1)
return 3;
/* Verify memory matches what was originally written. */
if (memcmp(base, "test", 4) != 0)
return 4;
/* Write / append to the file. */
if (write(fd, "more", 4) != 4)
return 5;
(void) fsync(fd);
/* Check if file write is seen by the memory map. */
if (memcmp(base+4, "more", 4) != 0)
return 6;
(void) close(fd);
return 0;
}
]])
],[
cyrus_cv_func_mmap_shared='yes'
],[
cyrus_cv_func_mmap_shared='no'
])
])
AC_CACHE_CHECK([for stupid shared mmap],[cyrus_cv_func_mmap_stupidshared],[
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_MMAN_H
# include <sys/mman.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
int
main(int argc, char **argv)
{
char *base;
int fd, mmapflags = MAP_SHARED;
/* Create a file. */
if ((fd = open("conftestmmap", O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
return 1;
(void) unlink("conftestmmap");
if (write(fd, "test", 4) != 4)
return 2;
(void) fsync(fd);
/* Map file into memory. */
#ifdef MAP_FILE
mmapflags |= MAP_FILE;
#endif
#ifdef MAP_VARIABLE
mmapflags |= MAP_VARIABLE;
#endif
base = mmap((caddr_t)0, 100, PROT_READ, mmapflags, fd, 0L);
if (base == (caddr_t)-1)
return 3;
/* Verify memory matches what was originally written. */
if (memcmp(base, "test", 4) != 0)
return 4;
/* Rewind to start of file. */
(void) lseek(fd, 0L, 0);
/* Overwrite start of file. */
if (write(fd, "over", 4) != 4)
return 5;
(void) fsync(fd);
/* Check if file seek and overwrite is seen by the memory map. */
if (memcmp(base, "over", 4) != 0)
return 6;
(void) close(fd);
return 0;
}
]])
],[
cyrus_cv_func_mmap_stupidshared='yes'
],[
cyrus_cv_func_mmap_stupidshared='no'
])
])
])
#######################################################################
# Packages
#######################################################################
dnl
dnl SNERT_SQLITE3
dnl
AC_DEFUN(SNERT_OPTION_WITH_SQLITE3,[
AC_ARG_WITH([sqlite3],[AS_HELP_STRING([--with-sqlite3=DIR],[SQLite3 package, optional base directory])])
AC_ARG_WITH([sqlite3-inc],[AS_HELP_STRING([--with-sqlite3-inc=DIR],[specific SQLite3 include directory])])
AC_ARG_WITH([sqlite3-lib],[AS_HELP_STRING([--with-sqlite3-lib=DIR],[specific SQLite3 library directory])])
])
AC_DEFUN(SNERT_SQLITE3,[
SNERT_CHECK_PACKAGE([SQLITE3],[sqlite3.h],[libsqlite3],[sqlite3_open], dnl
[$with_sqlite3],[$with_sqlite3_inc],[$with_sqlite3_lib] dnl
)
dnl AC_SUBST(LIBS_SQLITE3)
dnl AC_SUBST(CPPFLAGS_SQLITE3)
dnl AC_SUBST(LDFLAGS_SQLITE3)
AH_VERBATIM(LIBS_SQLITE3,[
#undef HAVE_LIBSQLITE3
#undef HAVE_SQLITE3_H
#undef HAVE_SQLITE3_OPEN
#undef CPPFLAGS_SQLITE3
#undef LDFLAGS_SQLITE3
#undef LIBS_SQLITE3
])
])
AC_DEFUN([SNERT_OPTION_WITH_SASL2],[
AC_ARG_WITH([sasl2],[AS_HELP_STRING([--with-sasl2=DIR],[SASL2 package, optional base directory])])
AC_ARG_WITH([sasl2-inc],[AS_HELP_STRING([--with-sasl2-inc=DIR],[specific SASL2 include directory])])
AC_ARG_WITH([sasl2-lib],[AS_HELP_STRING([--with-sasl2-lib=DIR],[specific SASL2 library directory])])
])
AC_DEFUN([SNERT_SASL2],[
AC_REQUIRE([SNERT_NETWORK])
SNERT_CHECK_PACKAGE([SASL2], dnl
[sasl/sasl.h sasl/saslutil.h],[libsasl2],[prop_get sasl_checkapop], dnl
[$with_sasl2],[$with_sasl2_inc],[$with_sasl2_lib] dnl
)
dnl AC_SUBST(LIBS_SASL2)
dnl AC_SUBST(CPPFLAGS_SASL2)
dnl AC_SUBST(LDFLAGS_SASL2)
AH_VERBATIM(LIBS_SASL2,[
#undef HAVE_LIBSASL2
#undef HAVE_SASL_SASL_H
#undef HAVE_SASL_SASLUTIL_H
#undef HAVE_SASL_CHECKAPOP
#undef HAVE_PROP_GET
#undef CPPFLAGS_SASL2
#undef LDFLAGS_SASL2
#undef LIBS_SASL2
])
])
AC_DEFUN([CYRUS_OPTION_WITH_KERBEROS],[
AC_ARG_WITH([krb],[AS_HELP_STRING([--with-krb=DIR],[Kerberos 4 package, optional base directory])])
AC_ARG_WITH([krb-inc],[AS_HELP_STRING([--with-krb-inc=DIR],[specific Kerberos 4 include directory])])
AC_ARG_WITH([krb-lib],[AS_HELP_STRING([--with-krb-lib=DIR],[specific Kerberos 4 library directory])])
AC_ARG_WITH([krb-des],[AS_HELP_STRING([--with-krb-des],[use Kerberos DES implementation])],[],[with_krb_des='yes'])
])
AC_DEFUN([CYRUS_KERBEROS],[
AC_REQUIRE([SNERT_NETWORK])
AC_REQUIRE([CYRUS_COM_ERR])