-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaclocal.m4
1513 lines (1480 loc) · 44.5 KB
/
aclocal.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 Macros for auto-configure script.
dnl by T.E.Dickey <dickey@clark.net>
dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
dnl and Philippe De Muyter <phdm@macqel.be>
dnl
dnl Created: 1997/1/28
dnl Updated: 1997/12/23
dnl
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
dnl but old versions (and some misinstalled ones) need that.
AC_DEFUN([CF_ADD_INCDIR],
[
for cf_add_incdir in $1
do
while true
do
case $cf_add_incdir in
/usr/include) # (vi
;;
*) # (vi
CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
;;
esac
cf_top_incdir=`echo $cf_add_incdir | sed -e 's:/include/.*$:/include:'`
test "$cf_top_incdir" = "$cf_add_incdir" && break
cf_add_incdir="$cf_top_incdir"
done
done
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for existence of alternate-character-set support in curses, so we
dnl can decide to use it for box characters.
dnl
AC_DEFUN([CF_ALT_CHAR_SET],
[
AC_MSG_CHECKING([if curses supports alternate-character set])
AC_CACHE_VAL(cf_cv_alt_char_set,[
AC_TRY_LINK([
#include <${cf_cv_ncurses_header-curses.h}>
],[chtype x = acs_map['l']; acs_map['m'] = 0],
[cf_cv_alt_char_set=yes],
[cf_cv_alt_char_set=no])])
AC_MSG_RESULT($cf_cv_alt_char_set)
test $cf_cv_alt_char_set = yes && AC_DEFINE(ALT_CHAR_SET)
])dnl
dnl ---------------------------------------------------------------------------
dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
dnl in the sharutils 4.2 distribution.
AC_DEFUN([CF_ANSI_CC_CHECK],
[
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
AC_CACHE_VAL(cf_cv_ansi_cc,[
cf_cv_ansi_cc=no
cf_save_CFLAGS="$CFLAGS"
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX -qlanglvl=ansi
# Ultrix and OSF/1 -std1
# HP-UX -Aa -D_HPUX_SOURCE
# SVR4 -Xc
# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
for cf_arg in "-DCC_HAS_PROTOS" "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc
do
CFLAGS="$cf_save_CFLAGS $cf_arg"
AC_TRY_COMPILE(
[
#ifndef CC_HAS_PROTOS
#if !defined(__STDC__) || __STDC__ != 1
choke me
#endif
#endif
],[
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};],
[cf_cv_ansi_cc="$cf_arg"; break])
done
CFLAGS="$cf_save_CFLAGS"
])
AC_MSG_RESULT($cf_cv_ansi_cc)
if test "$cf_cv_ansi_cc" != "no"; then
if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
CFLAGS="$CFLAGS $cf_cv_ansi_cc"
else
AC_DEFINE(CC_HAS_PROTOS)
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Allow user to disable a normally-on option.
AC_DEFUN([CF_ARG_DISABLE],
[CF_ARG_OPTION($1,[$2 (default: on)],[$3],[$4],yes)])dnl
dnl ---------------------------------------------------------------------------
dnl Allow user to enable a normally-off option.
AC_DEFUN([CF_ARG_ENABLE],
[CF_ARG_OPTION($1,[$2 (default: off)],[$3],[$4],no)])dnl
dnl ---------------------------------------------------------------------------
dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
dnl values.
dnl
dnl Parameters:
dnl $1 = option name
dnl $2 = help-string
dnl $3 = action to perform if option is not default
dnl $4 = action if perform if option is default
dnl $5 = default option value (either 'yes' or 'no')
AC_DEFUN([CF_ARG_OPTION],
[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
if test "$enableval" != "$5" ; then
ifelse($3,,[ :]dnl
,[ $3]) ifelse($4,,,[
else
$4])
fi],[enableval=$5 ifelse($4,,,[
$4
])dnl
])])dnl
dnl ---------------------------------------------------------------------------
dnl Check if curses.h defines TRUE/FALSE (it does under SVr4).
AC_DEFUN([CF_BOOL_DEFS],
[
AC_MSG_CHECKING(if TRUE/FALSE are defined)
AC_CACHE_VAL(cf_cv_bool_defs,[
AC_TRY_COMPILE([
#include <${cf_cv_ncurses_header-curses.h}>
#include <stdio.h>],[int x = TRUE, y = FALSE],
[cf_cv_bool_defs=yes],
[cf_cv_bool_defs=no])])
AC_MSG_RESULT($cf_cv_bool_defs)
if test "$cf_cv_bool_defs" = no ; then
AC_DEFINE(TRUE,(1))
AC_DEFINE(FALSE,(0))
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for data that is usually declared in <stdio.h> or <errno.h>
dnl $1 = the name to check
AC_DEFUN([CF_CHECK_ERRNO],
[
AC_MSG_CHECKING([declaration of $1])
AC_CACHE_VAL(cf_cv_dcl_$1,[
AC_TRY_COMPILE([
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <errno.h> ],
[long x = (long) $1],
[eval 'cf_cv_dcl_'$1'=yes'],
[eval 'cf_cv_dcl_'$1'=no]')])
eval 'cf_result=$cf_cv_dcl_'$1
AC_MSG_RESULT($cf_result)
# It's possible (for near-UNIX clones) that the data doesn't exist
AC_CACHE_VAL(cf_cv_have_$1,[
if test $cf_result = no ; then
eval 'cf_result=DECL_'$1
CF_UPPER(cf_result,$cf_result)
AC_DEFINE_UNQUOTED($cf_result)
AC_MSG_CHECKING([existence of $1])
AC_TRY_LINK([
#undef $1
extern long $1;
],
[$1 = 2],
[eval 'cf_cv_have_'$1'=yes'],
[eval 'cf_cv_have_'$1'=no'])
eval 'cf_result=$cf_cv_have_'$1
AC_MSG_RESULT($cf_result)
else
eval 'cf_cv_have_'$1'=yes'
fi
])
eval 'cf_result=HAVE_'$1
CF_UPPER(cf_result,$cf_result)
eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)'
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if a function is declared by including a set of include files.
dnl Invoke the corresponding actions according to whether it is found or not.
dnl
dnl Gcc (unlike other compilers) will only warn about the miscast assignment
dnl in the first test, but most compilers will oblige with an error in the
dnl second test.
dnl
dnl CF_CHECK_FUNCDECL(INCLUDES, FUNCTION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(CF_CHECK_FUNCDECL,
[
AC_MSG_CHECKING([for $2 declaration])
AC_CACHE_VAL(ac_cv_func_decl_$2,
[AC_TRY_COMPILE([$1],
[#ifndef ${ac_func}
extern int ${ac_func}();
#endif],[
AC_TRY_COMPILE([$1],
[#ifndef ${ac_func}
int (*p)() = ${ac_func};
#endif],[
eval "ac_cv_func_decl_$2=yes"],[
eval "ac_cv_func_decl_$2=no"])],[
eval "ac_cv_func_decl_$2=yes"])])
if eval "test \"`echo '$ac_cv_func_'decl_$2`\" = yes"; then
AC_MSG_RESULT(yes)
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if functions are declared by including a set of include files.
dnl and define DECL_XXX if not.
dnl
dnl CF_CHECK_FUNCDECLS(INCLUDES, FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(CF_CHECK_FUNCDECLS,
[for ac_func in $2
do
CF_CHECK_FUNCDECL([$1], $ac_func,
[$3],
[
CF_UPPER(ac_tr_func,DECL_$ac_func)
AC_DEFINE_UNQUOTED($ac_tr_func) $4])dnl
done
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if curses supports color. (Note that while SVr3 curses supports
dnl color, it does this differently from SVr4 curses; more work would be needed
dnl to accommodate SVr3).
dnl
AC_DEFUN([CF_COLOR_CURSES],
[
AC_MSG_CHECKING(if curses supports color attributes)
AC_CACHE_VAL(cf_cv_color_curses,[
AC_TRY_LINK([
#include <${cf_cv_ncurses_header-curses.h}>
],
[chtype x = COLOR_BLUE;
has_colors();
start_color();
#ifndef NCURSES_BROKEN
wbkgd(curscr, getbkgd(stdscr)); /* X/Open XPG4 aka SVr4 Curses */
#endif
],
[cf_cv_color_curses=yes],
[cf_cv_color_curses=no])
])
AC_MSG_RESULT($cf_cv_color_curses)
if test $cf_cv_color_curses = yes ; then
AC_DEFINE(COLOR_CURSES)
test ".$cf_cv_ncurses_broken" != .yes && AC_DEFINE(HAVE_GETBKGD)
fi
])
dnl ---------------------------------------------------------------------------
dnl Look for the curses libraries. Older curses implementations may require
dnl termcap/termlib to be linked as well.
AC_DEFUN([CF_CURSES_LIBS],[
AC_CHECK_FUNC(initscr,,[
case $host_os in #(vi
freebsd*) #(vi
AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
;;
hpux10.*)
AC_CHECK_LIB(cur_colr,initscr,[
LIBS="-lcur_colr $LIBS"
CFLAGS="-I/usr/include/curses_colr $CFLAGS"
ac_cv_func_initscr=yes
],[
AC_CHECK_LIB(Hcurses,initscr,[
# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
LIBS="-lHcurses $LIBS"
CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS"
ac_cv_func_initscr=yes
])])
;;
esac
if test ".$With5lib" != ".no" ; then
if test -d /usr/5lib ; then
# SunOS 3.x or 4.x
CPPFLAGS="$CPPFLAGS -I/usr/5include"
LIBS="$LIBS -L/usr/5lib"
fi
fi
if test ".$ac_cv_func_initscr" != .yes ; then
cf_save_LIBS="$LIBS"
cf_term_lib=""
cf_curs_lib=""
# Check for library containing tgoto. Do this before curses library
# because it may be needed to link the test-case for initscr.
AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
for cf_term_lib in termcap termlib unknown
do
AC_CHECK_LIB($cf_term_lib,tgoto,[break])
done
])
# Check for library containing initscr
test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
for cf_curs_lib in curses ncurses xcurses cursesX jcurses unknown
do
AC_CHECK_LIB($cf_curs_lib,initscr,[break])
done
test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
LIBS="-l$cf_curs_lib $cf_save_LIBS"
if test "$cf_term_lib" = unknown ; then
AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
[initscr()],
[cf_result=yes],
[cf_result=no])
AC_MSG_RESULT($cf_result)
test $cf_result = no && AC_ERROR(Cannot link curses library)
elif test "$cf_term_lib" != predefined ; then
AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
[initscr(); tgoto((char *)0, 0, 0);],
[cf_result=no],
[
LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
[initscr()],
[cf_result=yes],
[cf_result=error])
])
AC_MSG_RESULT($cf_result)
fi
fi
])])
dnl ---------------------------------------------------------------------------
dnl Solaris 2.x curses provides a "performance" tradeoff according to whether
dnl CURS_PERFORMANCE is defined. If defined, the implementation defines macros
dnl that access the WINDOW structure. Otherwise, function calls are used.
AC_DEFUN([CF_CURS_PERFORMANCE],
[
AC_MSG_CHECKING([for curses performance tradeoff])
AC_CACHE_VAL(cf_cv_curs_performance,[
cf_cv_curs_performance=no
AC_TRY_COMPILE([
#include <${cf_cv_ncurses_header-curses.h}>],[
#if defined(wbkgdset) && defined(clearok) && defined(getbkgd)
int x = ERR;
#else
int x = ; /* force an error */
#endif
],[
AC_TRY_COMPILE([
#define CURS_PERFORMANCE
#include <${cf_cv_ncurses_header-curses.h}>],[
#if defined(wbkgdset) && defined(clearok) && defined(getbkgd)
int x = ; /* force an error */
#else
int x = ERR;
#endif
],[cf_cv_curs_performance=yes])])])
AC_MSG_RESULT($cf_cv_curs_performance)
test $cf_cv_curs_performance = yes && AC_DEFINE(CURS_PERFORMANCE)
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for a program in the given list $3, defining the corresponding
dnl program variable $2.
dnl
AC_DEFUN([CF_DEFINE_PROG],[
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(cf_cv_$2,[
cf_cv_$2=unknown
for cv_path in $3
do
if test -f $cv_path ; then
cf_cv_$2=$cv_path
break
fi
done
])
AC_MSG_RESULT($cf_cv_$2)
AC_DEFINE_UNQUOTED($2,"$cf_cv_$2")
])
dnl ---------------------------------------------------------------------------
dnl You can always use "make -n" to see the actual options, but it's hard to
dnl pick out/analyze warning messages when the compile-line is long.
dnl
dnl Sets:
dnl ECHO_LD - symbol to prefix "cc -o" lines
dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
dnl SHOW_CC - symbol to put before explicit "cc -c" lines
dnl ECHO_CC - symbol to put before any "cc" line
dnl
AC_DEFUN([CF_DISABLE_ECHO],[
AC_MSG_CHECKING(if you want to see long compiling messages)
CF_ARG_DISABLE(echo,
[ --disable-echo test: display "compiling" commands],
[
ECHO_LD='@echo linking [$]@;'
RULE_CC=' @echo compiling [$]<'
SHOW_CC=' @echo compiling [$]@'
ECHO_CC='@'
],[
ECHO_LD=''
RULE_CC='# compiling'
SHOW_CC='# compiling'
ECHO_CC=''
])
AC_MSG_RESULT($enableval)
AC_SUBST(ECHO_LD)
AC_SUBST(RULE_CC)
AC_SUBST(SHOW_CC)
AC_SUBST(ECHO_CC)
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if 'errno' is declared in <errno.h>
AC_DEFUN([CF_ERRNO],
[
CF_CHECK_ERRNO(errno)
])dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([CF_FANCY_CURSES],
[
AC_MSG_CHECKING(if curses supports fancy attributes)
AC_CACHE_VAL(cf_cv_fancy_curses,[
AC_TRY_LINK([
#include <${cf_cv_ncurses_header-curses.h}>
],
[attrset(A_UNDERLINE|A_BOLD|A_REVERSE);
wattrset(stdscr, A_BLINK|A_DIM);
attroff(A_BOLD);
keypad(stdscr,TRUE);
],
[cf_cv_fancy_curses=yes],
[cf_cv_fancy_curses=no])
])
AC_MSG_RESULT($cf_cv_fancy_curses)
test $cf_cv_fancy_curses = yes && AC_DEFINE(FANCY_CURSES)
])
dnl ---------------------------------------------------------------------------
dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
dnl prefer a standard location, and use -L options only if we do not find the
dnl library in the standard library location(s).
dnl $1 = library name
dnl $2 = includes
dnl $3 = code fragment to compile/link
dnl $4 = corresponding function-name
dnl
dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
dnl to use a -L option.
AC_DEFUN([CF_FIND_LIBRARY],
[
cf_cv_have_lib_$1=no
cf_libdir=""
AC_CHECK_FUNC($4,cf_cv_have_lib_$1=yes,[
cf_save_LIBS="$LIBS"
AC_MSG_CHECKING(for $4 in -l$1)
LIBS="-l$1 $LIBS"
AC_TRY_LINK([$2],[$3],
[AC_MSG_RESULT(yes)
cf_cv_have_lib_$1=yes
],
[AC_MSG_RESULT(no)
CF_LIBRARY_PATH(cf_search,$1)
for cf_libdir in $cf_search
do
AC_MSG_CHECKING(for -l$1 in $cf_libdir)
LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
AC_TRY_LINK([$2],[$3],
[AC_MSG_RESULT(yes)
cf_cv_have_lib_$1=yes
break],
[AC_MSG_RESULT(no)
LIBS="$cf_save_LIBS"])
done
])
])
if test $cf_cv_have_lib_$1 = no ; then
AC_ERROR(Cannot link $1 library)
fi
case $host_os in #(vi
linux*) # Suse Linux does not follow /usr/lib convention
$1="[$]$1 /lib"
;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for availability of fcntl versus ioctl(,FIONBIO,). Lynx uses this
dnl for Sequent (ptx), and it is needed for OS/2 EMX.
AC_DEFUN([CF_FIONBIO],
[
AC_CACHE_CHECK(if we should use fcntl or ioctl,cf_cv_fionbio,[
AC_TRY_LINK([
#include <sys/types.h>
#include <sys/ioctl.h>
],[
int ret = ioctl(0, FIONBIO, (char *)0);
],[cf_cv_fionbio=ioctl],[
AC_TRY_LINK([
#include <sys/types.h>
#if HAVE_FCNTL_H
#include <fcntl.h>
#else
#if HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
#endif],[
int ret = fcntl(0, F_SETFL, O_NONBLOCK);
],
[cf_cv_fionbio=fcntl],
[cf_cv_fionbio=unknown])])
])
test "$cf_cv_fionbio" = "fcntl" && AC_DEFINE(USE_FCNTL)
])dnl
dnl ---------------------------------------------------------------------------
dnl A conventional existence-check for 'lstat' won't work with the Linux
dnl version of gcc 2.7.0, since the symbol is defined only within <sys/stat.h>
dnl as an inline function.
dnl
dnl So much for portability.
AC_DEFUN([CF_FUNC_LSTAT],
[
AC_MSG_CHECKING(for lstat)
AC_CACHE_VAL(ac_cv_func_lstat,[
AC_TRY_LINK([
#include <sys/types.h>
#include <sys/stat.h>],
[lstat(".", (struct stat *)0)],
[ac_cv_func_lstat=yes],
[ac_cv_func_lstat=no])
])
AC_MSG_RESULT($ac_cv_func_lstat )
if test $ac_cv_func_lstat = yes; then
AC_DEFINE(HAVE_LSTAT)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
dnl and/or 'waitpid()'.
dnl
dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
dnl because some Posix systems turn this on only when a BSD variable is
dnl defined.
dnl
dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
dnl would conflict with an attempt to test that header directly.
dnl
AC_DEFUN([CF_FUNC_WAIT],
[
AC_REQUIRE([CF_UNION_WAIT])
if test $cf_cv_type_unionwait = yes; then
AC_MSG_CHECKING(if union wait can be used as wait-arg)
AC_CACHE_VAL(cf_cv_arg_union_wait,[
AC_TRY_COMPILE($cf_wait_headers,
[union wait x; wait(&x)],
[cf_cv_arg_union_wait=yes],
[cf_cv_arg_union_wait=no])
])
AC_MSG_RESULT($cf_cv_arg_union_wait)
test $cf_cv_arg_union_wait = yes && AC_DEFINE(WAIT_USES_UNION)
AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
AC_TRY_COMPILE($cf_wait_headers,
[union wait x; waitpid(0, &x, 0)],
[cf_cv_arg_union_waitpid=yes],
[cf_cv_arg_union_waitpid=no])
])
AC_MSG_RESULT($cf_cv_arg_union_waitpid)
test $cf_cv_arg_union_waitpid = yes && AC_DEFINE(WAITPID_USES_UNION)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Test for availability of useful gcc __attribute__ directives to quiet
dnl compiler warnings. Though useful, not all are supported -- and contrary
dnl to documentation, unrecognized directives cause older compilers to barf.
AC_DEFUN([CF_GCC_ATTRIBUTES],
[
if test -n "$GCC"
then
cat > conftest.i <<EOF
#ifndef GCC_PRINTF
#define GCC_PRINTF 0
#endif
#ifndef GCC_SCANF
#define GCC_SCANF 0
#endif
#ifndef GCC_NORETURN
#define GCC_NORETURN /* nothing */
#endif
#ifndef GCC_UNUSED
#define GCC_UNUSED /* nothing */
#endif
EOF
if test -n "$GCC"
then
AC_CHECKING([for gcc __attribute__ directives])
changequote(,)dnl
cat > conftest.$ac_ext <<EOF
#line __oline__ "configure"
#include "confdefs.h"
#include "conftest.h"
#include "conftest.i"
#if GCC_PRINTF
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
#else
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
#if GCC_SCANF
#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
#else
#define GCC_SCANFLIKE(fmt,var) /*nothing*/
#endif
extern void wow(char *,...) GCC_SCANFLIKE(1,2);
extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern void foo(void) GCC_NORETURN;
int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
EOF
changequote([,])dnl
for cf_attribute in scanf printf unused noreturn
do
CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
cf_directive="__attribute__(($cf_attribute))"
echo "checking for gcc $cf_directive" 1>&AC_FD_CC
case $cf_attribute in
scanf|printf)
cat >conftest.h <<EOF
#define GCC_$CF_ATTRIBUTE 1
EOF
;;
*)
cat >conftest.h <<EOF
#define GCC_$CF_ATTRIBUTE $cf_directive
EOF
;;
esac
if AC_TRY_EVAL(ac_compile); then
test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
cat conftest.h >>confdefs.h
# else
# sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
fi
done
else
fgrep define conftest.i >>confdefs.h
fi
rm -rf conftest*
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if the compiler supports useful warning options. There's a few that
dnl we don't use, simply because they're too noisy:
dnl
dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
dnl -Wredundant-decls (system headers make this too noisy)
dnl -Wtraditional (combines too many unrelated messages, only a few useful)
dnl -Wwrite-strings (too noisy, but should review occasionally)
dnl -pedantic
dnl
AC_DEFUN([CF_GCC_WARNINGS],
[
if test -n "$GCC"
then
changequote(,)dnl
cat > conftest.$ac_ext <<EOF
#line __oline__ "configure"
int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
EOF
changequote([,])dnl
AC_CHECKING([for gcc warning options])
cf_save_CFLAGS="$CFLAGS"
EXTRA_CFLAGS="-W -Wall"
cf_warn_CONST=""
test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
for cf_opt in \
Wbad-function-cast \
Wcast-align \
Wcast-qual \
Winline \
Wmissing-declarations \
Wmissing-prototypes \
Wnested-externs \
Wpointer-arith \
Wshadow \
Wstrict-prototypes $cf_warn_CONST
do
CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
if AC_TRY_EVAL(ac_compile); then
test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
fi
done
rm -f conftest*
CFLAGS="$cf_save_CFLAGS"
fi
AC_SUBST(EXTRA_CFLAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl Construct a search-list for a nonstandard header-file
AC_DEFUN([CF_HEADER_PATH],
[$1=""
if test -d "$includedir" ; then
test "$includedir" != NONE && $1="[$]$1 $includedir $includedir/$2"
fi
if test -d "$oldincludedir" ; then
test "$oldincludedir" != NONE && $1="[$]$1 $oldincludedir $oldincludedir/$2"
fi
if test -d "$prefix"; then
test "$prefix" != NONE && $1="[$]$1 $prefix/include $prefix/include/$2"
fi
test "$prefix" != /usr/local && $1="[$]$1 /usr/local/include /usr/local/include/$2"
test "$prefix" != /usr && $1="[$]$1 /usr/include /usr/include/$2"
])dnl
dnl ---------------------------------------------------------------------------
dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
AC_DEFUN([CF_HELP_MESSAGE],
[AC_DIVERT_HELP([$1])dnl
])dnl
dnl ---------------------------------------------------------------------------
dnl Construct a search-list for a nonstandard library-file
AC_DEFUN([CF_LIBRARY_PATH],
[$1=""
if test -d "$libdir" ; then
test "$libdir" != NONE && $1="[$]$1 $libdir $libdir/$2"
fi
if test -d "$exec_prefix"; then
test "$exec_prefix" != NONE && $1="[$]$1 $exec_prefix/lib $exec_prefix/lib/$2"
fi
if test -d "$prefix"; then
test "$prefix" != NONE && \
test "$prefix" != "$exec_prefix" && $1="[$]$1 $prefix/lib $prefix/lib/$2"
fi
test "$prefix" != /usr/local && $1="[$]$1 /usr/local/lib /usr/local/lib/$2"
test "$prefix" != /usr && $1="[$]$1 /usr/lib /usr/lib/$2"
])dnl
dnl ---------------------------------------------------------------------------
dnl Check if we've got setlocale() and its header, <locale.h>
AC_DEFUN([CF_LOCALE],
[
AC_MSG_CHECKING(for setlocale())
AC_CACHE_VAL(cf_cv_locale,[
AC_TRY_LINK([#include <locale.h>],
[setlocale(LC_ALL, "")],
[cf_cv_locale=yes],
[cf_cv_locale=no])
])
AC_MSG_RESULT($cf_cv_locale)
test $cf_cv_locale = yes && AC_DEFINE(LOCALE)
])
dnl ---------------------------------------------------------------------------
dnl Check for the use of 'include' in 'make' (BSDI is a special case)
dnl The symbol $ac_make is set in AC_MAKE_SET, as a side-effect.
AC_DEFUN([CF_MAKE_INCLUDE],
[
AC_MSG_CHECKING(for style of include in makefiles)
make_include_left=""
make_include_right=""
make_include_quote="unknown"
cf_inc=head$$
cf_dir=subd$$
echo 'RESULT=OK' >$cf_inc
mkdir $cf_dir
for cf_include in "include" ".include" "!include"
do
for cf_quote in '' '"'
do
cat >$cf_dir/makefile <<CF_EOF
SHELL=/bin/sh
${cf_include} ${cf_quote}../$cf_inc${cf_quote}
all :
@echo 'cf_make_include=\$(RESULT)'
CF_EOF
cf_make_include=""
eval `cd $cf_dir && ${MAKE-make} 2>&AC_FD_CC | grep cf_make_include=OK`
if test -n "$cf_make_include"; then
make_include_left="$cf_include"
make_include_quote="$cf_quote"
break
else
echo Tried 1>&AC_FD_CC
cat $cf_dir/makefile 1>&AC_FD_CC
fi
done
test -n "$cf_make_include" && break
done
rm -rf $cf_inc $cf_dir
if test -z "$make_include_left" ; then
AC_ERROR(Your $ac_make program does not support includes)
fi
if test ".$make_include_quote" != .unknown ; then
make_include_left="$make_include_left $make_include_quote"
make_include_right="$make_include_quote"
fi
AC_MSG_RESULT(${make_include_left}file${make_include_right})
AC_SUBST(make_include_left)
AC_SUBST(make_include_right)
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for pre-1.9.9g ncurses (among other problems, the most obvious is
dnl that color combinations don't work).
AC_DEFUN([CF_NCURSES_BROKEN],
[
AC_REQUIRE([CF_NCURSES_VERSION])
if test "$cf_cv_ncurses_version" != no ; then
AC_MSG_CHECKING(for obsolete/broken version of ncurses)
AC_CACHE_VAL(cf_cv_ncurses_broken,[
AC_TRY_COMPILE([
#include <${cf_cv_ncurses_header-curses.h}>],[
#if defined(NCURSES_VERSION) && defined(wgetbkgd)
make an error
#else
int x = 1
#endif
],
[cf_cv_ncurses_broken=no],
[cf_cv_ncurses_broken=yes])
])
AC_MSG_RESULT($cf_cv_ncurses_broken)
if test "$cf_cv_ncurses_broken" = yes ; then
AC_MSG_WARN(hmm... you should get an up-to-date version of ncurses)
AC_DEFINE(NCURSES_BROKEN)
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
dnl the CPPFLAGS variable.
dnl
dnl The header files may be installed as either curses.h, or ncurses.h
dnl (obsolete). If not installed for overwrite, the curses.h file would be
dnl in an ncurses subdirectory (e.g., /usr/include/ncurses), but someone may
dnl have installed overwriting the vendor's curses. Only very old versions
dnl (pre-1.9.2d, the first autoconf'd version) of ncurses don't define
dnl either __NCURSES_H or NCURSES_VERSION in the header.
dnl
dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
dnl is already in the include-path, don't even bother with this, since we cannot
dnl easily determine which file it is. In this case, it has to be <curses.h>.
dnl
AC_DEFUN([CF_NCURSES_CPPFLAGS],
[
AC_MSG_CHECKING(for ncurses header file)
AC_CACHE_VAL(cf_cv_ncurses_header,[
AC_TRY_COMPILE([#include <curses.h>],[
#ifdef NCURSES_VERSION
printf("%s\n", NCURSES_VERSION);
#else
#ifdef __NCURSES_H
printf("old\n");
#else
make an error
#endif
#endif
],
[cf_cv_ncurses_header=predefined],[
CF_HEADER_PATH(cf_search,ncurses)
test -n "$verbose" && echo
for cf_incdir in $cf_search
do
for cf_header in \
curses.h \
ncurses.h
do
changequote(,)dnl
if egrep "NCURSES_[VH]" $cf_incdir/$cf_header 1>&AC_FD_CC 2>&1; then
changequote([,])dnl
cf_cv_ncurses_header=$cf_incdir/$cf_header
test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
break
fi
test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
done
test -n "$cf_cv_ncurses_header" && break
done
test -z "$cf_cv_ncurses_header" && AC_ERROR(not found)
])])
AC_MSG_RESULT($cf_cv_ncurses_header)
AC_DEFINE(NCURSES)
changequote(,)dnl
cf_incdir=`echo $cf_cv_ncurses_header | sed -e 's:/[^/]*$::'`
changequote([,])dnl
case $cf_cv_ncurses_header in # (vi
*/ncurses.h)
AC_DEFINE(HAVE_NCURSES_H)
;;
esac
case $cf_cv_ncurses_header in # (vi
predefined) # (vi
cf_cv_ncurses_header=curses.h
;;
*)
CF_ADD_INCDIR($cf_incdir)
;;
esac
CF_NCURSES_VERSION
])dnl
dnl ---------------------------------------------------------------------------
dnl Look for the ncurses library. This is a little complicated on Linux,
dnl because it may be linked with the gpm (general purpose mouse) library.
dnl Some distributions have gpm linked with (bsd) curses, which makes it
dnl unusable with ncurses. However, we don't want to link with gpm unless
dnl ncurses has a dependency, since gpm is normally set up as a shared library,
dnl and the linker will record a dependency.
AC_DEFUN([CF_NCURSES_LIBS],
[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
# This works, except for the special case where we find gpm, but
# ncurses is in a nonstandard location via $LIBS, and we really want
# to link gpm.
cf_ncurses_LIBS=""
cf_ncurses_SAVE="$LIBS"
AC_CHECK_LIB(gpm,Gpm_Open,
[AC_CHECK_LIB(gpm,initscr,
[LIBS="$cf_ncurses_SAVE"],
[cf_ncurses_LIBS="-lgpm"])])
case $host_os in #(vi
freebsd*)
# This is only necessary if you are linking against an obsolete
# version of ncurses (but it should do no harm, since it's static).
AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
;;
esac
LIBS="$cf_ncurses_LIBS $LIBS"
CF_FIND_LIBRARY(ncurses,
[#include <${cf_cv_ncurses_header-curses.h}>],
[initscr()],
initscr)
if test -n "$cf_ncurses_LIBS" ; then
AC_MSG_CHECKING(if we can link ncurses without $cf_ncurses_LIBS)
cf_ncurses_SAVE="$LIBS"
for p in $cf_ncurses_LIBS ; do
q=`echo $LIBS | sed -e 's/'$p' //' -e 's/'$p'$//'`
if test "$q" != "$LIBS" ; then
LIBS="$q"
fi
done
AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
LIBS="$cf_ncurses_SAVE"])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl Check for the version of ncurses, to aid in reporting bugs, etc.
AC_DEFUN([CF_NCURSES_VERSION],
[AC_MSG_CHECKING(for ncurses version)
AC_CACHE_VAL(cf_cv_ncurses_version,[
cf_cv_ncurses_version=no
cf_tempfile=out$$
AC_TRY_RUN([
#include <${cf_cv_ncurses_header-curses.h}>
int main()
{
FILE *fp = fopen("$cf_tempfile", "w");
#ifdef NCURSES_VERSION
# ifdef NCURSES_VERSION_PATCH
fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
# else
fprintf(fp, "%s\n", NCURSES_VERSION);
# endif
#else
# ifdef __NCURSES_H
fprintf(fp, "old\n");
# else
make an error
# endif
#endif
exit(0);
}],[
cf_cv_ncurses_version=`cat $cf_tempfile`
rm -f $cf_tempfile],,[
# This will not work if the preprocessor splits the line after the
# Autoconf token. The 'unproto' program does that.
cat > conftest.$ac_ext <<EOF
#include <${cf_cv_ncurses_header-curses.h}>
#undef Autoconf
#ifdef NCURSES_VERSION
Autoconf NCURSES_VERSION
#else