summaryrefslogtreecommitdiff
path: root/util/autoconf/autoconf.info-2
blob: ae8fc7b9cb16a778eebe0ba52463160bb8262fa4 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
This is Info file autoconf.info, produced by Makeinfo-1.55 from the
input file ./autoconf.texi.

START-INFO-DIR-ENTRY
* Autoconf: (autoconf).         Create source code configuration scripts.
END-INFO-DIR-ENTRY

   This file documents the GNU Autoconf package for creating scripts to
configure source code packages using templates and an `m4' macro
package.

   Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.


File: autoconf.info,  Node: Versions,  Prev: Default Prefix,  Up: Setup

Version Numbers in `configure'
==============================

   The following macros manage version numbers for `configure' scripts.
Using them is optional.

 - Macro: AC_PREREQ (VERSION)
     Ensure that a recent enough version of Autoconf is being used.  If
     the version of Autoconf being used to create `configure' is earlier
     than VERSION, print an error message on the standard error output
     and do not create `configure'.  For example:

          AC_PREREQ(1.8)

     This macro is useful if your `configure.in' relies on non-obvious
     behavior that changed between Autoconf releases.  If it merely
     needs recently added macros, then `AC_PREREQ' is less useful,
     because the `autoconf' program already tells the user which macros
     are not found.  The same thing happens if `configure.in' is
     processed by a version of Autoconf older than when `AC_PREREQ' was
     added.

 - Macro: AC_REVISION (REVISION-INFO)
     Copy revision stamp REVISION-INFO into the `configure' script,
     with any dollar signs or double-quotes removed.  This macro lets
     you put a revision stamp from `configure.in' into `configure'
     without RCS or CVS changing it when you check in `configure'.  That
     way, you can determine easily which revision of `configure.in' a
     particular `configure' corresponds to.

     It is a good idea to call this macro before `AC_INIT' so that the
     revision number is near the top of both `configure.in' and
     `configure'.  To support doing that, the `AC_REVISION' output
     begins with `#!/bin/sh', like the normal start of a `configure'
     script does.

     For example, this line in `configure.in':

          AC_REVISION($Revision$)dnl

     produces this in `configure':

          #!/bin/sh
          # From configure.in Revision: 1.30


File: autoconf.info,  Node: Existing Tests,  Next: Writing Tests,  Prev: Setup,  Up: Top

Existing Tests
**************

   These macros test for particular system features that packages might
need or want to use.  If you need to test for a kind of feature that
none of these macros check for, you can probably do it by calling
primitive test macros with appropriate arguments (*note Writing
Tests::.).

   These tests print messages telling the user which feature they're
checking for, and what they find.  They cache their results for future
`configure' runs (*note Caching Results::.).

   Some of these macros set output variables.  *Note Makefile
Substitutions::, for how to get their values.  The phrase "define NAME"
is used below as a shorthand to mean "define C preprocessor symbol NAME
to the value 1".  *Note Defining Symbols::, for how to get those symbol
definitions into your program.

* Menu:

* Alternative Programs::	Selecting between alternative programs.
* Libraries::                   Library archives that might be missing.
* Library Functions::		C library functions that might be missing.
* Header Files::		Header files that might be missing.
* Structures::			Structures or members that might be missing.
* Typedefs::			`typedef's that might be missing.
* Compiler Characteristics::	C compiler or machine architecture features.
* System Services::		Operating system services.
* UNIX Variants::		Special kludges for specific UNIX variants.


File: autoconf.info,  Node: Alternative Programs,  Next: Libraries,  Up: Existing Tests

Alternative Programs
====================

   These macros check for the presence or behavior of particular
programs.  They are used to choose between several alternative programs
and to decide what to do once one has been chosen.  If there is no
macro specifically defined to check for a program you need, and you
don't need to check for any special properties of it, then you can use
one of the general program check macros.

* Menu:

* Particular Programs::         Special handling to find certain programs.
* Generic Programs::            How to find other programs.


File: autoconf.info,  Node: Particular Programs,  Next: Generic Programs,  Up: Alternative Programs

Particular Program Checks
-------------------------

   These macros check for particular programs--whether they exist, and
in some cases whether they support certain features.

 - Macro: AC_DECL_YYTEXT
     Define `YYTEXT_POINTER' if `yytext' is a `char *' instead of a
     `char []'.  Also set output variable `LEX_OUTPUT_ROOT' to the base
     of the file name that the lexer generates; usually `lex.yy', but
     sometimes something else.  These results vary according to whether
     `lex' or `flex' is being used.

 - Macro: AC_PROG_AWK
     Check for `mawk', `gawk', `nawk', and `awk', in that order, and
     set output variable `AWK' to the first one that it finds.  It
     tries `mawk' first because that is reported to be the fastest
     implementation.

 - Macro: AC_PROG_CC
     Determine a C compiler to use.  If `CC' is not already set in the
     environment, check for `gcc', and use `cc' if it's not found.  Set
     output variable `CC' to the name of the compiler found.

     If using the GNU C compiler, set shell variable `GCC' to `yes',
     empty otherwise.  If output variable `CFLAGS' was not already set,
     set it to `-g -O' for the GNU C compiler (`-O' on systems where
     GCC does not accept `-g'), or `-g' for other compilers.

 - Macro: AC_PROG_CC_C_O
     If the C compiler does not accept the `-c' and `-o' options
     simultaneously, define `NO_MINUS_C_MINUS_O'.

 - Macro: AC_PROG_CPP
     Set output variable `CPP' to a command that runs the C
     preprocessor.  If `$CC -E' doesn't work, it uses `/lib/cpp'.  It
     is only portable to run `CPP' on files with a `.c' extension.

     If the current language is C (*note Language Choice::.), many of
     the specific test macros use the value of `CPP' indirectly by
     calling `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or
     `AC_EGREP_CPP'.

 - Macro: AC_PROG_CXX
     Determine a C++ compiler to use.  Check if the environment variable
     `CXX' or `CCC' (in that order) is set; if so, set output variable
     `CXX' to its value.  Otherwise search for a C++ compiler under
     likely names (`c++', `g++', `gcc', `CC', and `cxx').  If none of
     those checks succeed, as a last resort set `CXX' to `gcc'.

     If using the GNU C++ compiler, set shell variable `GXX' to `yes',
     empty otherwise.  If output variable `CXXFLAGS' was not already
     set, set it to `-g -O' for the GNU C++ compiler (`-O' on systems
     where G++ does not accept `-g'), or `-g' for other compilers.

 - Macro: AC_PROG_CXXCPP
     Set output variable `CXXCPP' to a command that runs the C++
     preprocessor.  If `$CXX -E' doesn't work, it uses `/lib/cpp'.  It
     is only portable to run `CXXCPP' on files with a `.c', `.C', or
     `.cc' extension.

     If the current language is C++ (*note Language Choice::.), many of
     the specific test macros use the value of `CXXCPP' indirectly by
     calling `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or
     `AC_EGREP_CPP'.

 - Macro: AC_PROG_GCC_TRADITIONAL
     Add `-traditional' to output variable `CC' if using the GNU C
     compiler and `ioctl' does not work properly without
     `-traditional'.  That usually happens when the fixed header files
     have not been installed on an old system.  Since recent versions
     of the GNU C compiler fix the header files automatically when
     installed, this is becoming a less prevalent problem.

 - Macro: AC_PROG_INSTALL
     Set output variable `INSTALL' to the path of a BSD compatible
     `install' program, if one is found in the current `PATH'.
     Otherwise, set `INSTALL' to `DIR/install-sh -c', checking the
     directories specified to `AC_CONFIG_AUX_DIR' (or its default
     directories) to determine DIR (*note Output::.).  Also set the
     variable `INSTALL_PROGRAM' to `${INSTALL}' and `INSTALL_DATA' to
     `${INSTALL} -m 644'.

     This macro screens out various instances of `install' known to not
     work.  It prefers to find a C program rather than a shell script,
     for speed.  Instead of `install-sh', it can also use `install.sh',
     but that name is obsolete because some `make' programs have a rule
     that creates `install' from it if there is no `Makefile'.

     A copy of `install-sh' which you may use comes with Autoconf.  If
     you use `AC_PROG_INSTALL', you must include either `install-sh' or
     `install.sh' in your distribution, or `configure' will produce an
     error message saying it can't find them--even if the system you're
     on has a good `install' program.  This check is a safety measure
     to prevent you from accidentally leaving that file out, which
     would prevent your package from installing on systems that don't
     have a BSD-compatible `install' program.

     If you need to use your own installation program because it has
     features not found in standard `install' programs, there is no
     reason to use `AC_PROG_INSTALL'; just put the pathname of your
     program into your `Makefile.in' files.

 - Macro: AC_PROG_LEX
     If `flex' is found, set output variable `LEX' to `flex' and
     `LEXLIB' to `-lfl', if that library is in a standard place.
     Otherwise set `LEX' to `lex' and `LEXLIB' to `-ll'.

 - Macro: AC_PROG_LN_S
     If `ln -s' works on the current filesystem (the operating system
     and filesystem support symbolic links), set output variable `LN_S'
     to `ln -s', otherwise set it to `ln'.

 - Macro: AC_PROG_RANLIB
     Set output variable `RANLIB' to `ranlib' if `ranlib' is found,
     otherwise to `:' (do nothing).

 - Macro: AC_PROG_YACC
     If `bison' is found, set output variable `YACC' to `bison -y'.
     Otherwise, if `byacc' is found, set `YACC' to `byacc'.  Otherwise
     set `YACC' to `yacc'.


File: autoconf.info,  Node: Generic Programs,  Prev: Particular Programs,  Up: Alternative Programs

Generic Program Checks
----------------------

   These macros are used to find programs not covered by the particular
test macros.  If you need to check the behavior of a program as well as
find out whether it is present, you have to write your own test for it
(*note Writing Tests::.).

 - Macro: AC_CHECK_PROG (VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND [,
          VALUE-IF-NOT-FOUND])
     Check whether program PROG-TO-CHECK-FOR exists in `PATH'.  If it
     is found, set VARIABLE to VALUE-IF-FOUND, otherwise to
     VALUE-IF-NOT-FOUND, if given.  If VARIABLE was already set, do
     nothing.  Calls `AC_SUBST' for VARIABLE.

 - Macro: AC_CHECK_PROGS (VARIABLE, PROGS-TO-CHECK-FOR [,
          VALUE-IF-NOT-FOUND])
     Check for each program in the whitespace-separated list
     PROGS-TO-CHECK-FOR exists in `PATH'.  If it is found, set VARIABLE
     to the name of that program.  Otherwise, continue checking the
     next program in the list.  If none of the programs in the list are
     found, set VARIABLE to VALUE-IF-NOT-FOUND; if VALUE-IF-NOT-FOUND
     is not specified, the value of VARIABLE is not changed.  Calls
     `AC_SUBST' for VARIABLE.

 - Macro: AC_PATH_PROG (VARIABLE, PROG-TO-CHECK-FOR [,
          VALUE-IF-NOT-FOUND])
     Like `AC_CHECK_PROG', but set VARIABLE to the entire path of
     PROG-TO-CHECK-FOR if found.

 - Macro: AC_PATH_PROGS (VARIABLE, PROGS-TO-CHECK-FOR [,
          VALUE-IF-NOT-FOUND])
     Like `AC_CHECK_PROGS', but if any of PROGS-TO-CHECK-FOR are found,
     set VARIABLE to the entire path of the program found.


File: autoconf.info,  Node: Libraries,  Next: Library Functions,  Prev: Alternative Programs,  Up: Existing Tests

Library Files
=============

   The following macros check for the presence of certain C library
archive files.

 - Macro: AC_CHECK_LIB (LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
     Try to ensure that C function FUNCTION is available by checking
     whether a test C program can be linked with the library LIBRARY to
     get the function.  LIBRARY is the base name of the library; e.g.,
     to check for `-lmp', use `mp' as the LIBRARY argument.

     ACTION-IF-FOUND is a list of shell commands to run if the link
     with the library succeeds; ACTION-IF-NOT-FOUND is a list of shell
     commands to run if the link fails.  If ACTION-IF-FOUND and
     ACTION-IF-NOT-FOUND are not specified, the default action is to
     add `-lLIBRARY' to `LIBS' and define `HAVE_LIBLIBRARY' (in all
     capitals).

     If linking with LIBRARY results in unresolved symbols, which would
     be resolved by linking with additional libraries, give those
     libraries as the OTHER-LIBRARIES argument, separated by spaces:
     `-lX11 -lXt'.  Otherwise this macro will fail to detect that
     LIBRARY is present, because linking the test program will always
     fail with unresolved symbols.

 - Macro: AC_HAVE_LIBRARY (LIBRARY, [, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
     This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION
     argument of `main'.  In addition, LIBRARY can be written as any of
     `foo', `-lfoo', or `libfoo.a'.  In all of those cases, the
     compiler is passed `-lfoo'.  However, LIBRARY can not be a shell
     variable; it must be a literal name.  This macro is considered
     obsolete.


File: autoconf.info,  Node: Library Functions,  Next: Header Files,  Prev: Libraries,  Up: Existing Tests

Library Functions
=================

   The following macros check for particular C library functions.  If
there is no macro specifically defined to check for a function you need,
and you don't need to check for any special properties of it, then you
can use one of the general function check macros.

* Menu:

* Particular Functions::        Special handling to find certain functions.
* Generic Functions::           How to find other functions.


File: autoconf.info,  Node: Particular Functions,  Next: Generic Functions,  Up: Library Functions

Particular Function Checks
--------------------------

   These macros check for particular C functions--whether they exist,
and in some cases how they respond when given certain arguments.

 - Macro: AC_FUNC_ALLOCA
     Check how to get `alloca'.  Tries to get a builtin version by
     checking for `alloca.h' or the predefined C preprocessor macros
     `__GNUC__' and `_AIX'.  If this macro finds `alloca.h', it defines
     `HAVE_ALLOCA_H'.

     If those attempts fail, it looks for the function in the standard C
     library.  If any of those methods succeed, it defines
     `HAVE_ALLOCA'.  Otherwise, it sets the output variable `ALLOCA' to
     `alloca.o' and defines `C_ALLOCA' (so programs can periodically
     call `alloca(0)' to garbage collect).  This variable is separate
     from `LIBOBJS' so multiple programs can share the value of
     `ALLOCA' without needing to create an actual library, in case only
     some of them use the code in `LIBOBJS'.

     This macro does not try to get `alloca' from the System V R3
     `libPW' or the System V R4 `libucb' because those libraries
     contain some incompatible functions that cause trouble.  Some
     versions do not even contain `alloca' or contain a buggy version.
     If you still want to use their `alloca', use `ar' to extract
     `alloca.o' from them instead of compiling `alloca.c'.

     Source files that use `alloca' should start with a piece of code
     like the following, to declare it properly.  In some versions of
     AIX, the declaration of `alloca' must precede everything else
     except for comments and preprocessor directives.  The `#pragma'
     directive is indented so that pre-ANSI C compilers will ignore it,
     rather than choke on it.

          /* AIX requires this to be the first thing in the file.  */
          #ifdef __GNUC__
          # define alloca __builtin_alloca
          #else
          # if HAVE_ALLOCA_H
          #  include <alloca.h>
          # else
          #  ifdef _AIX
           #pragma alloca
          #  else
          #   ifndef alloca /* predefined by HP cc +Olibcalls */
          char *alloca ();
          #   endif
          #  endif
          # endif
          #endif

 - Macro: AC_FUNC_CLOSEDIR_VOID
     If the `closedir' function does not return a meaningful value,
     define `CLOSEDIR_VOID'.  Otherwise, callers ought to check its
     return value for an error indicator.

 - Macro: AC_FUNC_GETLOADAVG
     Check how to get the system load averages.  If the system has the
     `getloadavg' function, this macro defines `HAVE_GETLOADAVG', and
     adds to `LIBS' any libraries needed to get that function.

     Otherwise, it adds `getloadavg.o' to the output variable
     `LIBOBJS', and possibly defines several other C preprocessor
     macros and output variables:

       1. It defines `SVR4', `DGUX', `UMAX', or `UMAX4_3' if on those
          systems.

       2. If it finds `nlist.h', it defines `NLIST_STRUCT'.

       3. If `struct nlist' has an `n_un' member, it defines
          `NLIST_NAME_UNION'.

       4. If compiling `getloadavg.c' defines `LDAV_PRIVILEGED',
          programs need to be installed specially on this system for
          `getloadavg' to work, and this macro defines
          `GETLOADAVG_PRIVILEGED'.

       5. This macro sets the output variable `NEED_SETGID'.  The value
          is `true' if special installation is required, `false' if not.
          If `NEED_SETGID' is `true', this macro sets `KMEM_GROUP' to
          the name of the group that should own the installed program.

 - Macro: AC_FUNC_GETMNTENT
     Check for the `getmntent' in the `sun' and `seq' libraries, for
     Irix 4 and PTX, respectively.  Then, if `getmntent' is available,
     define `HAVE_GETMNTENT'.

 - Macro: AC_FUNC_MEMCMP
     If the `memcmp' function is not available, or does not work on
     8-bit data (like the one on SunOS 4.1.3), add `memcmp.o' to output
     variable `LIBOBJS'.

 - Macro: AC_FUNC_MMAP
     If the `mmap' function exists and works correctly on memory mapped
     files, define `HAVE_MMAP'.

 - Macro: AC_FUNC_SETVBUF_REVERSED
     If `setvbuf' takes the buffering type as its second argument and
     the buffer pointer as the third, instead of the other way around,
     define `SETVBUF_REVERSED'.  This is the case on System V before
     release 3.

 - Macro: AC_FUNC_STRCOLL
     If the `strcoll' function exists and works correctly, define
     `HAVE_STRCOLL'.  This does a bit more than
     `AC_CHECK_FUNCS(strcoll)', because some systems have incorrect
     definitions of `strcoll', which should not be used.

 - Macro: AC_FUNC_STRFTIME
     Check for `strftime' in the `intl' library, for SCO UNIX.  Then,
     if `strftime' is available, define `HAVE_STRFTIME'.

 - Macro: AC_FUNC_UTIME_NULL
     If `utime(FILE, NULL)' sets FILE's timestamp to the present,
     define `HAVE_UTIME_NULL'.

 - Macro: AC_FUNC_VFORK
     If `vfork.h' is found, define `HAVE_VFORK_H'.  If a working
     `vfork' is not found, define `vfork' to be `fork'.  This macro
     checks for several known errors in implementations of `vfork' and
     considers the system to not have a working `vfork' if it detects
     any of them.

 - Macro: AC_FUNC_VPRINTF
     If `vprintf' is found, define `HAVE_VPRINTF'.  Otherwise, if
     `_doprnt' is found, define `HAVE_DOPRNT'.  (If `vprintf' is
     available, you may assume that `vfprintf' and `vsprintf' are also
     available.)

 - Macro: AC_FUNC_WAIT3
     If `wait3' is found and fills in the contents of its third argument
     (a `struct rusage *'), which HP-UX does not do, define
     `HAVE_WAIT3'.


File: autoconf.info,  Node: Generic Functions,  Prev: Particular Functions,  Up: Library Functions

Generic Function Checks
-----------------------

   These macros are used to find functions not covered by the particular
test macros.  If the functions might be in libraries other than the
default C library, first call `AC_CHECK_LIB' for those libraries.  If
you need to check the behavior of a function as well as find out
whether it is present, you have to write your own test for it (*note
Writing Tests::.).

 - Macro: AC_CHECK_FUNC (FUNCTION, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     If C function FUNCTION is available, run shell commands
     ACTION-IF-FOUND, otherwise ACTION-IF-NOT-FOUND.  If you just want
     to define a symbol if the function is available, consider using
     `AC_CHECK_FUNCS' instead.  This macro checks for functions with C
     linkage even when `AC_LANG_CPLUSPLUS' has been called, since C++ is
     more standardized than C is.  (*note Language Choice::., for more
     information about selecting the language for checks.)

 - Macro: AC_CHECK_FUNCS (FUNCTION... [, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND]])
     For each given FUNCTION in the whitespace-separated argument list
     that is available, define `HAVE_FUNCTION' (in all capitals).  If
     ACTION-IF-FOUND is given, it is additional shell code to execute
     when one of the functions is found.  You can give it a value of
     `break' to break out of the loop on the first match.  If
     ACTION-IF-NOT-FOUND is given, it is executed when one of the
     functions is not found.

 - Macro: AC_REPLACE_FUNCS (FUNCTION-NAME...)
     For each given FUNCTION-NAME in the whitespace-separated argument
     list that is not in the C library, add `FUNCTION-NAME.o' to the
     value of the output variable `LIBOBJS'.


File: autoconf.info,  Node: Header Files,  Next: Structures,  Prev: Library Functions,  Up: Existing Tests

Header Files
============

   The following macros check for the presence of certain C header
files.  If there is no macro specifically defined to check for a header
file you need, and you don't need to check for any special properties of
it, then you can use one of the general header file check macros.

* Menu:

* Particular Headers::          Special handling to find certain headers.
* Generic Headers::             How to find other headers.


File: autoconf.info,  Node: Particular Headers,  Next: Generic Headers,  Up: Header Files

Particular Header Checks
------------------------

   These macros check for particular system header files--whether they
exist, and in some cases whether they declare certain symbols.

 - Macro: AC_DECL_SYS_SIGLIST
     Define `SYS_SIGLIST_DECLARED' if the variable `sys_siglist' is
     declared in a system header file, either `signal.h' or `unistd.h'.

 - Macro: AC_DIR_HEADER
     Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
     defines a different set of C preprocessor macros to indicate which
     header file is found.  This macro and the names it defines are
     considered obsolete.  The names it defines are:

    `dirent.h'
          `DIRENT'

    `sys/ndir.h'
          `SYSNDIR'

    `sys/dir.h'
          `SYSDIR'

    `ndir.h'
          `NDIR'

     In addition, if the `closedir' function does not return a
     meaningful value, define `VOID_CLOSEDIR'.

 - Macro: AC_HEADER_DIRENT
     Check for the following header files, and for the first one that is
     found and defines `DIR', define the listed C preprocessor macro:

    `dirent.h'
          `HAVE_DIRENT_H'

    `sys/ndir.h'
          `HAVE_SYS_NDIR_H'

    `sys/dir.h'
          `HAVE_SYS_DIR_H'

    `ndir.h'
          `HAVE_NDIR_H'

     The directory library declarations in the source code should look
     something like the following:

          #if HAVE_DIRENT_H
          # include <dirent.h>
          # define NAMLEN(dirent) strlen((dirent)->d_name)
          #else
          # define dirent direct
          # define NAMLEN(dirent) (dirent)->d_namlen
          # if HAVE_SYS_NDIR_H
          #  include <sys/ndir.h>
          # endif
          # if HAVE_SYS_DIR_H
          #  include <sys/dir.h>
          # endif
          # if HAVE_NDIR_H
          #  include <ndir.h>
          # endif
          #endif

     Using the above declarations, the program would declare variables
     to be type `struct dirent', not `struct direct', and would access
     the length of a directory entry name by passing a pointer to a
     `struct dirent' to the `NAMLEN' macro.

     This macro also checks for the SCO Xenix `dir' and `x' libraries.

 - Macro: AC_HEADER_MAJOR
     If `sys/types.h' does not define `major', `minor', and `makedev',
     but `sys/mkdev.h' does, define `MAJOR_IN_MKDEV'; otherwise, if
     `sys/sysmacros.h' does, define `MAJOR_IN_SYSMACROS'.

 - Macro: AC_HEADER_STDC
     Define `STDC_HEADERS' if the system has ANSI C header files.
     Specifically, this macro checks for `stdlib.h', `stdarg.h',
     `string.h', and `float.h'; if the system has those, it probably
     has the rest of the ANSI C header files.  This macro also checks
     whether `string.h' declares `memchr' (and thus presumably the
     other `mem' functions), whether `stdlib.h' declare `free' (and
     thus presumably `malloc' and other related functions), and whether
     the `ctype.h' macros work on characters with the high bit set, as
     ANSI C requires.

     Use `STDC_HEADERS' instead of `__STDC__' to determine whether the
     system has ANSI-compliant header files (and probably C library
     functions) because many systems that have GCC do not have ANSI C
     header files.

     On systems without ANSI C headers, there is so much variation that
     it is probably easier to declare the functions you use than to
     figure out exactly what the system header files declare.  Some
     systems contain a mix of functions ANSI and BSD; some are mostly
     ANSI but lack `memmove'; some define the BSD functions as macros in
     `string.h' or `strings.h'; some have only the BSD functions but
     `string.h'; some declare the memory functions in `memory.h', some
     in `string.h'; etc.  It is probably sufficient to check for one
     string function and one memory function; if the library has the
     ANSI versions of those then it probably has most of the others.
     If you put the following in `configure.in':

          AC_HEADER_STDC
          AC_CHECK_FUNCS(strchr memcpy)

     then, in your code, you can put declarations like this:

          #if STDC_HEADERS
          # include <string.h>
          #else
          # ifndef HAVE_STRCHR
          #  define strchr index
          #  define strrchr rindex
          # endif
          char *strchr (), *strrchr ();
          # ifndef HAVE_MEMCPY
          #  define memcpy(d, s, n) bcopy ((s), (d), (n))
          #  define memmove(d, s, n) bcopy ((s), (d), (n))
          # endif
          #endif

     If you use a function like `memchr', `memset', `strtok', or
     `strspn', which have no BSD equivalent, then macros won't suffice;
     you must provide an implementation of each function.  An easy way
     to incorporate your implementations only when needed (since the
     ones in system C libraries may be hand optimized) is to, taking
     `memchr' for example, put it in `memchr.c' and use
     `AC_REPLACE_FUNCS(memchr)'.

 - Macro: AC_HEADER_SYS_WAIT
     If `sys/wait.h' exists and is compatible with POSIX.1, define
     `HAVE_SYS_WAIT_H'.  Incompatibility can occur if `sys/wait.h' does
     not exist, or if it uses the old BSD `union wait' instead of `int'
     to store a status value.  If `sys/wait.h' is not POSIX.1
     compatible, then instead of including it, define the POSIX.1
     macros with their usual interpretations.  Here is an example:

          #include <sys/types.h>
          #if HAVE_SYS_WAIT_H
          # include <sys/wait.h>
          #endif
          #ifndef WEXITSTATUS
          # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
          #endif
          #ifndef WIFEXITED
          # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
          #endif

 - Macro: AC_MEMORY_H
     Define `NEED_MEMORY_H' if `memcpy', `memcmp', etc. are not
     declared in `string.h' and `memory.h' exists.  This macro is
     obsolete; instead, use `AC_CHECK_HEADERS(memory.h)'.  See the
     example for `AC_HEADER_STDC'.

 - Macro: AC_UNISTD_H
     Define `HAVE_UNISTD_H' if the system has `unistd.h'.  This macro
     is obsolete; instead, use `AC_CHECK_HEADERS(unistd.h)'.

     The way to check if the system supports POSIX.1 is:

          #if HAVE_UNISTD_H
          # include <sys/types.h>
          # include <unistd.h>
          #endif
          
          #ifdef _POSIX_VERSION
          /* Code for POSIX.1 systems.  */
          #endif

     `_POSIX_VERSION' is defined when `unistd.h' is included on POSIX.1
     systems.  If there is no `unistd.h', it is definitely not a
     POSIX.1 system.  However, some non-POSIX.1 systems do have
     `unistd.h'.

 - Macro: AC_USG
     Define `USG' if the system does not have `strings.h', `rindex',
     `bzero', etc.  This implies that it has `string.h', `strrchr',
     `memset', etc.

     The symbol `USG' is obsolete.  Instead of this macro, see the
     example for `AC_HEADER_STDC'.


File: autoconf.info,  Node: Generic Headers,  Prev: Particular Headers,  Up: Header Files

Generic Header Checks
---------------------

   These macros are used to find system header files not covered by the
particular test macros.  If you need to check the contents of a header
as well as find out whether it is present, you have to write your own
test for it (*note Writing Tests::.).

 - Macro: AC_CHECK_HEADER (HEADER-FILE, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     If the system header file HEADER-FILE exists, execute shell
     commands ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.
     If you just want to define a symbol if the header file is
     available, consider using `AC_CHECK_HEADERS' instead.

 - Macro: AC_CHECK_HEADERS (HEADER-FILE... [, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND]])
     For each given system header file HEADER-FILE in the
     whitespace-separated argument list that exists, define
     `HAVE_HEADER-FILE' (in all capitals).  If ACTION-IF-FOUND is
     given, it is additional shell code to execute when one of the
     header files is found.  You can give it a value of `break' to
     break out of the loop on the first match.  If ACTION-IF-NOT-FOUND
     is given, it is executed when one of the header files is not found.


File: autoconf.info,  Node: Structures,  Next: Typedefs,  Prev: Header Files,  Up: Existing Tests

Structures
==========

   The following macros check for certain structures or structure
members.  To check structures not listed here, use `AC_EGREP_CPP'
(*note Examining Declarations::.) or `AC_TRY_COMPILE' (*note Examining
Syntax::.).

 - Macro: AC_HEADER_STAT
     If the macros `S_ISDIR', `S_ISREG' et al. defined in `sys/stat.h'
     do not work properly (returning false positives), define
     `STAT_MACROS_BROKEN'.  This is the case on Tektronix UTekV, Amdahl
     UTS and Motorola System V/88.

 - Macro: AC_HEADER_TIME
     If a program may include both `time.h' and `sys/time.h', define
     `TIME_WITH_SYS_TIME'.  On some older systems, `sys/time.h'
     includes `time.h', but `time.h' is not protected against multiple
     inclusion, so programs should not explicitly include both files.
     This macro is useful in programs that use, for example, `struct
     timeval' or `struct timezone' as well as `struct tm'.  It is best
     used in conjunction with `HAVE_SYS_TIME_H', which can be checked
     for using `AC_CHECK_HEADERS(sys/time.h)'.

          #if TIME_WITH_SYS_TIME
          # include <sys/time.h>
          # include <time.h>
          #else
          # if HAVE_SYS_TIME_H
          #  include <sys/time.h>
          # else
          #  include <time.h>
          # endif
          #endif

 - Macro: AC_STRUCT_ST_BLKSIZE
     If `struct stat' contains an `st_blksize' member, define
     `HAVE_ST_BLKSIZE'.

 - Macro: AC_STRUCT_ST_BLOCKS
     If `struct stat' contains an `st_blocks' member, define
     `HAVE_ST_BLOCKS'.  Otherwise, add `fileblocks.o' to the output
     variable `LIBOBJS'.

 - Macro: AC_STRUCT_ST_RDEV
     If `struct stat' contains an `st_rdev' member, define
     `HAVE_ST_RDEV'.

 - Macro: AC_STRUCT_TM
     If `time.h' does not define `struct tm', define `TM_IN_SYS_TIME',
     which means that including `sys/time.h' had better define `struct
     tm'.

 - Macro: AC_STRUCT_TIMEZONE
     Figure out how to get the current timezone.  If `struct tm' has a
     `tm_zone' member, define `HAVE_TM_ZONE'.  Otherwise, if the
     external array `tzname' is found, define `HAVE_TZNAME'.


File: autoconf.info,  Node: Typedefs,  Next: Compiler Characteristics,  Prev: Structures,  Up: Existing Tests

Typedefs
========

   The following macros check for C typedefs.  If there is no macro
specifically defined to check for a typedef you need, and you don't need
to check for any special properties of it, then you can use a general
typedef check macro.

* Menu:

* Particular Typedefs::         Special handling to find certain types.
* Generic Typedefs::            How to find other types.


File: autoconf.info,  Node: Particular Typedefs,  Next: Generic Typedefs,  Up: Typedefs

Particular Typedef Checks
-------------------------

   These macros check for particular C typedefs in `sys/types.h' and
`stdlib.h' (if it exists).

 - Macro: AC_TYPE_GETGROUPS
     Define `GETGROUPS_T' to be whichever of `gid_t' or `int' is the
     base type of the array argument to `getgroups'.

 - Macro: AC_TYPE_MODE_T
     If `mode_t' is not defined, define `mode_t' to be `int'.

 - Macro: AC_TYPE_OFF_T
     If `off_t' is not defined, define `off_t' to be `long'.

 - Macro: AC_TYPE_PID_T
     If `pid_t' is not defined, define `pid_t' to be `int'.

 - Macro: AC_TYPE_SIGNAL
     If `signal.h' declares `signal' as returning a pointer to a
     function returning `void', define `RETSIGTYPE' to be `void';
     otherwise, define it to be `int'.

     Define signal handlers as returning type `RETSIGTYPE':

          RETSIGTYPE
          hup_handler ()
          {
          ...
          }

 - Macro: AC_TYPE_SIZE_T
     If `size_t' is not defined, define `size_t' to be `unsigned'.

 - Macro: AC_TYPE_UID_T
     If `uid_t' is not defined, define `uid_t' to be `int' and `gid_t'
     to be `int'.


File: autoconf.info,  Node: Generic Typedefs,  Prev: Particular Typedefs,  Up: Typedefs

Generic Typedef Checks
----------------------

   This macro is used to check for typedefs not covered by the
particular test macros.

 - Macro: AC_CHECK_TYPE (TYPE, DEFAULT)
     If the type TYPE is not defined in `sys/types.h' or `stdlib.h' (if
     it exists), define it to be the C (or C++) builtin type DEFAULT;
     e.g., `short' or `unsigned'.


File: autoconf.info,  Node: Compiler Characteristics,  Next: System Services,  Prev: Typedefs,  Up: Existing Tests

Compiler Characteristics
========================

   The following macros check for C compiler or machine architecture
features.  To check for characteristics not listed here, use
`AC_TRY_COMPILE' (*note Examining Syntax::.) or `AC_TRY_RUN' (*note Run
Time::.)

 - Macro: AC_C_BIGENDIAN
     If words are stored with the most significant byte first (like
     Motorola and SPARC, but not Intel and VAX, CPUs), define
     `WORDS_BIGENDIAN'.

 - Macro: AC_C_CONST
     If the C compiler does not fully support the keyword `const',
     define `const' to be empty.  Some C compilers that do not define
     `__STDC__' do support `const'; some compilers that define
     `__STDC__' do not completely support `const'.  Programs can simply
     use `const' as if every C compiler supported it; for those that
     don't, the `Makefile' or configuration header file will define it
     as empty.

 - Macro: AC_C_INLINE
     If the C compiler is a version of GCC that supports the keyword
     `__inline' but not `inline' (such as some NeXT versions), define
     `inline' to be `__inline'.

 - Macro: AC_C_CHAR_UNSIGNED
     If the C type `char' is unsigned, define `__CHAR_UNSIGNED__',
     unless the C compiler predefines it.

 - Macro: AC_C_LONG_DOUBLE
     If the C compiler supports the `long double' type, define
     `HAVE_LONG_DOUBLE'.  Some C compilers that do not define
     `__STDC__' do support the `long double' type; some compilers that
     define `__STDC__' do not support `long double'.

 - Macro: AC_CHECK_SIZEOF (TYPE)
     Define `SIZEOF_UCTYPE' to be the size in bytes of the C (or C++)
     builtin type TYPE, e.g. `int' or `char *'.  If `type' is unknown
     to the compiler, it gets a size of 0.  UCTYPE is TYPE, with
     lowercase converted to uppercase, spaces changed to underscores,
     and asterisks changed to `P'.  For example, the call
          AC_CHECK_SIZEOF(int *)

     defines `SIZEOF_INT_P' to be 8 on DEC Alpha AXP systems.

 - Macro: AC_INT_16_BITS
     If the C type `int' is 16 bits wide, define `INT_16_BITS'.  This
     macro is obsolete; it is more general to use
     `AC_CHECK_SIZEOF(int)' instead.

 - Macro: AC_LONG_64_BITS
     If the C type `long int' is 64 bits wide, define `LONG_64_BITS'.
     This macro is obsolete; it is more general to use
     `AC_CHECK_SIZEOF(long)' instead.


File: autoconf.info,  Node: System Services,  Next: UNIX Variants,  Prev: Compiler Characteristics,  Up: Existing Tests

System Services
===============

   The following macros check for operating system services or
capabilities.

 - Macro: AC_SYS_INTERPRETER
     Check whether the system supports starting scripts with a line of
     the form `#!/bin/csh' to select the interpreter to use for the
     script.  After running this macro, shell code in `configure.in'
     can check the variable `ac_cv_sys_interpreter'; it will be set to
     `yes' if the system supports `#!', `no' if not.

 - Macro: AC_PATH_X
     Try to locate the X Window System include files and libraries.  If
     the user gave the command line options `--x-includes=DIR' and
     `--x-libraries=DIR', use those directories.  If either or both
     were not given, get the missing values by running `xmkmf' on a
     trivial `Imakefile' and examining the `Makefile' that it produces.
     If that fails (such as if `xmkmf' is not present), look for them
     in several directories where they often reside.  If either method
     is successful, set the shell variables `x_includes' and
     `x_libraries' to their locations, unless they are in directories
     the compiler searches by default.

     If both methods fail, or the user gave the command line option
     `--without-x', set the shell variable `no_x' to `yes'; otherwise
     set it to the empty string.

 - Macro: AC_PATH_XTRA
     An enhanced version of `AC_PATH_X'.  Add the C compiler flags that
     X needs to output variable `X_CFLAGS', and the X linker flags to
     `X_LIBS'.  If X is not available, add `-DX_DISPLAY_MISSING' to
     `X_CFLAGS'.

     Also check for special libraries that some systems need in order to
     compile X programs.  Add any that the system needs to output
     variable `X_EXTRA_LIBS'.  And check for special X11R6 libraries
     that need to be linked with before `-lX11', and add any found to
     the output variable `X_PRE_LIBS'.

 - Macro: AC_SYS_LONG_FILE_NAMES
     If the system supports file names longer than 14 characters, define
     `HAVE_LONG_FILE_NAMES'.

 - Macro: AC_SYS_RESTARTABLE_SYSCALLS
     If the system automatically restarts a system call that is
     interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.


File: autoconf.info,  Node: UNIX Variants,  Prev: System Services,  Up: Existing Tests

UNIX Variants
=============

   The following macros check for certain operating systems that need
special treatment for some programs, due to exceptional oddities in
their header files or libraries.  These macros are warts; they will be
replaced by a more systematic approach, based on the functions they make
available or the environments they provide.

 - Macro: AC_AIX
     If on AIX, define `_ALL_SOURCE'.  Allows the use of some BSD
     functions.  Should be called before any macros that run the C
     compiler.

 - Macro: AC_DYNIX_SEQ
     If on Dynix/PTX (Sequent UNIX), add `-lseq' to output variable
     `LIBS'.  This macro is obsolete; instead, use `AC_FUNC_GETMNTENT'.

 - Macro: AC_IRIX_SUN
     If on IRIX (Silicon Graphics UNIX), add `-lsun' to output variable
     `LIBS'.  This macro is obsolete.  If you were using it to get
     `getmntent', use `AC_FUNC_GETMNTENT' instead.  If you used it for
     the NIS versions of the password and group functions, use
     `AC_CHECK_LIB(sun, getpwnam)'.

 - Macro: AC_ISC_POSIX
     If on a POSIXized ISC UNIX, define `_POSIX_SOURCE' and add
     `-posix' (for the GNU C compiler) or `-Xp' (for other C compilers)
     to output variable `CC'.  This allows the use of POSIX facilities.
     Must be called after `AC_PROG_CC' and before any other macros
     that run the C compiler.

 - Macro: AC_MINIX
     If on Minix, define `_MINIX' and `_POSIX_SOURCE' and define
     `_POSIX_1_SOURCE' to be 2.  This allows the use of POSIX
     facilities.  Should be called before any macros that run the C
     compiler.

 - Macro: AC_SCO_INTL
     If on SCO UNIX, add `-lintl' to output variable `LIBS'.  This
     macro is obsolete; instead, use `AC_FUNC_STRFTIME'.

 - Macro: AC_XENIX_DIR
     If on Xenix, add `-lx' to output variable `LIBS'.  Also, if
     `dirent.h' is being used, add `-ldir' to `LIBS'.  This macro is
     obsolete; use `AC_HEADER_DIRENT' instead.


File: autoconf.info,  Node: Writing Tests,  Next: Results,  Prev: Existing Tests,  Up: Top

Writing Tests
*************

   If the existing feature tests don't do something you need, you have
to write new ones.  These macros are the building blocks.  They provide
ways for other macros to check whether various kinds of features are
available and report the results.

   This chapter contains some suggestions and some of the reasons why
the existing tests are written the way they are.  You can also learn a
lot about how to write Autoconf tests by looking at the existing ones.
If something goes wrong in one or more of the Autoconf tests, this
information can help you understand the assumptions behind them, which
might help you figure out how to best solve the problem.

   These macros check the output of the C compiler system.  They do not
cache the results of their tests for future use (*note Caching
Results::.), because they don't know enough about the information they
are checking for to generate a cache variable name.  They also do not
print any messages, for the same reason.  The checks for particular
kinds of C features call these macros and do cache their results and
print messages about what they're checking for.

* Menu:

* Examining Declarations::	Detecting header files and declarations.
* Examining Syntax::            Detecting language syntax features.
* Examining Libraries::         Detecting functions and global variables.
* Run Time::		        Testing for run-time features.
* Portable Shell::              Shell script portability pitfalls.
* Testing Values and Files::    Checking strings and files.
* Multiple Cases::		Tests for several possible values.
* Language Choice::             Selecting which language to use for testing.


File: autoconf.info,  Node: Examining Declarations,  Next: Examining Syntax,  Up: Writing Tests

Examining Declarations
======================

   The macro `AC_TRY_CPP' is used to check whether particular header
files exist.  You can check for one at a time, or more than one if you
need several header files to all exist for some purpose.

 - Macro: AC_TRY_CPP (INCLUDES, ACTION-IF-TRUE [, ACTION-IF-FALSE])
     INCLUDES is C or C++ `#include' statements and declarations, on
     which shell variable, backquote, and backslash substitutions are
     performed.  (Actually, it can be any C program, but other
     statements are probably not useful.)  If the preprocessor produces
     no error messages while processing it, run shell commands
     ACTION-IF-TRUE.  Otherwise run shell commands ACTION-IF-FALSE.

     This macro uses `CPPFLAGS', but not `CFLAGS', because `-g', `-O',
     etc. are not valid options to many C preprocessors.

   Here is now to find out whether a header file contains a particular
declaration, such as a typedef, a structure, a structure member, or a
function.  Use `AC_EGREP_HEADER' instead of running `grep' directly on
the header file; on some systems the symbol might be defined in another
header file that the file you are checking `#include's.

 - Macro: AC_EGREP_HEADER (PATTERN, HEADER-FILE, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     If the output of running the preprocessor on the system header file
     HEADER-FILE matches the `egrep' regular expression PATTERN,
     execute shell commands ACTION-IF-FOUND, otherwise execute
     ACTION-IF-NOT-FOUND.

   To check for C preprocessor symbols, either defined by header files
or predefined by the C preprocessor, use `AC_EGREP_CPP'.  Here is an
example of the latter:

     AC_EGREP_CPP(yes,
     [#ifdef _AIX
       yes
     #endif
     ], is_aix=yes, is_aix=no)

 - Macro: AC_EGREP_CPP (PATTERN, PROGRAM, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     PROGRAM is the text of a C or C++ program, on which shell
     variable, backquote, and backslash substitutions are performed.
     If the output of running the preprocessor on PROGRAM matches the
     `egrep' regular expression PATTERN, execute shell commands
     ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.

     This macro calls `AC_PROG_CPP' or `AC_PROG_CXXCPP' (depending on
     which language is current, *note Language Choice::.), if it hasn't
     been called already.


File: autoconf.info,  Node: Examining Syntax,  Next: Examining Libraries,  Prev: Examining Declarations,  Up: Writing Tests

Examining Syntax
================

   To check for a syntax feature of the C or C++ compiler, such as
whether it recognizes a certain keyword, use `AC_TRY_COMPILE' to try to
compile a small program that uses that feature.  You can also use it to
check for structures and structure members that are not present on all
systems.

 - Macro: AC_TRY_COMPILE (INCLUDES, FUNCTION-BODY, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     Create a test C program to see whether a function whose body
     consists of FUNCTION-BODY can be compiled; INCLUDES is any
     `#include' statements needed by the code in FUNCTION-BODY.  If the
     file compiles successfully, run shell commands ACTION-IF-FOUND,
     otherwise run ACTION-IF-NOT-FOUND.  This macro uses `CFLAGS' or
     `CXXFLAGS', and `CPPFLAGS', when compiling.  It does not try to
     link; use `AC_TRY_LINK' if you need to do that (*note Examining
     Libraries::.).


File: autoconf.info,  Node: Examining Libraries,  Next: Run Time,  Prev: Examining Syntax,  Up: Writing Tests

Examining Libraries
===================

   To check for a library, a function, or a global variable, Autoconf
`configure' scripts try to compile and link a small program that uses
it.  This is unlike Metaconfig, which by default uses `nm' or `ar' on
the C library to try to figure out which functions are available.
Trying to link with the function is usually a more reliable approach
because it avoids dealing with the variations in the options and output
formats of `nm' and `ar' and in the location of the standard libraries.
It also allows configuring for cross-compilation or checking a
function's runtime behavior if needed.  On the other hand, it can be
slower than scanning the libraries once.

   A few systems have linkers that do not return a failure exit status
when there are unresolved functions in the link.  This bug makes the
configuration scripts produced by Autoconf unusable on those systems.
However, some of them can be given options that make the exit status
correct.  This is a problem that Autoconf does not currently handle
automatically.

   `AC_TRY_LINK' is used to compile test programs to test for functions
and global variables.  It is also used (by `AC_CHECK_LIB') to check for
libraries, by adding the library being checked for to `LIBS'
temporarily and trying to link a small program.

 - Macro: AC_TRY_LINK (INCLUDES, FUNCTION-BODY, ACTION-IF-FOUND [,
          ACTION-IF-NOT-FOUND])
     Create a test C program to see whether a function whose body
     consists of FUNCTION-BODY can be compiled and linked; INCLUDES is
     any `#include' statements needed by the code in FUNCTION-BODY.  If
     the file compiles and links successfully, run shell commands
     ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.  This macro
     uses `CFLAGS' or `CXXFLAGS', `CPPFLAGS', `LDFLAGS', and `LIBS'
     when compiling.

 - Macro: AC_COMPILE_CHECK (ECHO-TEXT, INCLUDES, FUNCTION-BODY,
          ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
     This is an obsolete version of `AC_TRY_LINK', with the addition
     that it prints `checking for ECHO-TEXT' to the standard output
     first, if ECHO-TEXT is non-empty.  Use `AC_MSG_CHECKING' and
     `AC_MSG_RESULT' instead to print messages (*note Printing
     Messages::.).