-
Notifications
You must be signed in to change notification settings - Fork 256
/
iffe
executable file
·3603 lines (3526 loc) · 78.5 KB
/
iffe
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
USAGE_LICENSE="[-author?Glenn Fowler <[email protected]>][-author?Phong Vo <[email protected]>][-copyright?Copyright (c) 1994-2004 AT&T Corp.][-license?http://www.research.att.com/sw/license/ast-open.html][--catalog?INIT]"
# Glenn Fowler & Phong Vo
# AT&T Labs Research
#
# test if feature exists
# this script is written to make it through all sh variants
#
# NOTE: .exe a.out suffix and [\\/] in path patterns for dos/nt
case $-:$BASH_VERSION in
*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
esac
command=iffe
version=2004-08-11 # update in USAGE too #
pkg() # package
{
case $1 in
'<') shift ;;
*) return ;;
esac
case $1 in
X|X11*) i="openwin"
case $1 in
X) set X11 ;;
esac
case $1 in
X11) case $# in
1) set $1 6 5 4 ;;
esac
;;
esac
;;
*) i=
;;
esac
pth="{ usr . - . contrib local $i - . share - . lib - $1"
i=$1
while :
do shift
case $# in
0) break ;;
esac
case $1 in
'>') shift; break ;;
esac
pth="$pth ${i}R$1 ${i}.$1"
done
pth="$pth . } $*"
}
is() # op name
{
case $verbose in
1) case $complete in
1) failure ;;
esac
oo=$1
shift
case $1 in
?*) yy=is
ii=$1
complete=1
case $oo in
cmd) mm="a command" ;;
dat) mm="a library data symbol" ;;
dfn) mm="a macro with extractable value" ;;
exp) mm="true" ;;
hdr) mm="a header" ;;
id) mm="an identifier" ;;
lcl) mm="a native header" ;;
key) mm="a reserved keyword" ;;
lib) mm="a library function" ;;
LIB) case $2 in
"") mm="a library" ;;
*) ii=$*; mm="a library group" ;;
esac
;;
mac) mm="a macro" ;;
mem) mm="a member of $2" ;;
mth) mm="a math library symbol" ;;
nos) mm="a non-opaque struct" ;;
npt) mm="a symbol that needs a prototype" ;;
num) mm="a numeric constant or enum" ;;
nxt) mm="an include path for the native header" ;;
pth) mm="a file" ;;
run) yy="capture output of" mm= ;;
siz) mm="a type with known size" ;;
sym) mm="a typed variable" ;;
sys) mm="a system header" ;;
typ) mm="a type or typedef" ;;
val) yy="determine" mm="value" ;;
*) yy= mm= ;;
esac
case $ii in
[abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;;
esac
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
complete=1
;;
esac
;;
esac
}
success()
{
case $1 in
-) shift
;;
*) case $result in
UNKNOWN) result=SUCCESS ;;
esac
;;
esac
case $complete:$verbose in
1:1) case $suspended in
1) suspended=0
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
;;
esac
complete=0
case $# in
0) mm="yes" ;;
*) mm="'$*'" ;;
esac
case $debug in
0) echo " $mm" >&$stderr ;;
*) echo "$command: ... $mm" >&$stderr ;;
esac
;;
esac
}
failure()
{
case $1 in
-) shift ;;
*) result=FAILURE ;;
esac
case $complete:$verbose in
1:1) case $suspended in
1) suspended=0
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
;;
esac
complete=0
case $# in
0) mm="no" ;;
*) mm=$* ;;
esac
case $debug in
0) echo " $mm" >&$stderr ;;
*) echo "$command: ... $mm" >&$stderr ;;
esac
;;
esac
}
# report
#
# - ignore global status
# -0 normal sense
# -1 inverted sense if ! def
# status test status 0:success *:failure
# success success comment
# failure failure comment
# default default setting comment
#
# globals
#
# $not invert test sense
# $M test variable
# $m test macro
# $v default macro
report() # [-] [-0] [-1] status value success failure default
{
case $1 in
-) _report_ignore=$1
shift
;;
*) _report_ignore=
;;
esac
_report_not=$not
case $1 in
-0) shift
;;
-1) shift
case $def in
''|-) case $_report_not in
1) _report_not= ;;
*) _report_not=1 ;;
esac
;;
esac
;;
esac
_report_status=$1
case $_report_ignore:$_report_status in
-:*) ;;
*:0) success $_report_ignore ;;
*) failure $_report_ignore ;;
esac
_report_value=$2
case $_report_not in
1) case $_report_status in
0) _report_status=1 ;;
*) _report_status=0 ;;
esac
_report_success=$4
_report_failure=$3
;;
*) _report_success=$3
_report_failure=$4
;;
esac
_report_default=$5
case $_report_status in
0) case $M in
*-*) ;;
*) usr="$usr$nl#define $m $_report_value"
case $_report_success in
''|-) ;;
*) echo "#define $m $_report_value /* $_report_success */" ;;
esac
eval $m=\'$_report_value\'
;;
esac
;;
*) case $M in
*-*) ;;
*) case $_report_failure in
''|-) ;;
*) case $define$all$config$undef in
1?1?|1??1)echo "#undef $m /* $_report_failure */" ;;
11??) echo "#define $m 0 /* $_report_failure */" ;;
esac
;;
esac
case $_report_default in
''|-) ;;
*) case $define$set in
1?*) echo "#define $v $set /* $_report_default */" ;;
esac
;;
esac
eval $m=0
;;
esac
;;
esac
}
noisy()
{
case $complete:$verbose in
1:1) suspended=1
echo >&$stderr
;;
esac
}
here_broken=0
copy() # output-file data
{
case $shell in
ksh) case $1 in
-) print -r - "$2" ;;
*) print -r - "$2" > "$1" ;;
esac
;;
*) case $1 in
-) if cat <<!
$2
!
then : old here doc botch not present
else case $here_broken in
0) here_broken=1
echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
;;
esac
sh -c "cat <<!
$2
!
"
fi
;;
*) if cat > "$1" <<!
$2
!
then : old here doc botch not present
else case $here_broken in
0) here_broken=1
echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
;;
esac
sh -c "cat > '$1' <<!
$2
!
"
fi
;;
esac
;;
esac
}
checkread()
{
posix_read=`(read -r _checkread_line; echo $_checkread_line) 2>/dev/null <<!
a z
!
`
case $posix_read in
"a z") posix_read=1
;;
*) copy ${tmp}r.c "
extern int read();
extern int write();
int main()
{
char c;
char r;
int k;
k = 1;
while (read(0, &c, 1) == 1)
{
if (k)
{
if (c == ' ' || c == '\\t')
continue;
k = 0;
}
if (c == '\\r')
{
r = c;
if (read(0, &c, 1) == 1 && c != '\n')
write(1, &r, 1);
}
write(1, &c, 1);
if (c == '\\n')
return 0;
}
return 1;
}"
if $cc -o ${tmp}r.exe ${tmp}r.c <&$nullin >&$nullout
then posix_read=${tmp}r.exe
else echo "$command: cannot compile read -r workaround" >&$stderr
exit 1
fi
;;
esac
case `(set -f && set x * && echo $# && set +f) 2>/dev/null` in
2) posix_noglob="set -f" posix_glob="set +f" ;;
*) case `(set -F && set x * && echo $# && set +F) 2>/dev/null` in
2) posix_noglob="set -F" posix_glob="set +F" ;;
*) posix_noglob=":" posix_glob=":" ;;
esac
;;
esac
}
execute()
{
if test "" != "$cross"
then crossexec $cross "$@"
_execute_=$?
elif test -d /NextDeveloper
then "$@" <&$nullin >&$nullout
_execute_=$?
"$@" <&$nullin | cat
else "$@"
_execute_=$?
fi
return $_execute_
}
exclude()
{
case $excludes in
'') return 0 ;;
esac
for _exclude_var
do eval _exclude_old=\$$_exclude_var
case $_exclude_old in
*" -I"*);;
*) continue ;;
esac
_exclude_new=
_exclude_sep=
for _exclude_arg in $_exclude_old
do
for _exclude_dir in $excludes
do case $_exclude_arg in
-I$_exclude_dir|-I*/$_exclude_dir)
;;
*) _exclude_new="$_exclude_new$_exclude_sep$_exclude_arg"
_exclude_sep=" "
;;
esac
done
done
eval $_exclude_var=\$_exclude_new
case $debug in
0) ;;
*) echo $command: exclude $_exclude_var: "$_exclude_old => $_exclude_new" >&$stderr
;;
esac
done
}
all=0
binding="-dy -dn -Bdynamic -Bstatic -Wl,-ashared -Wl,-aarchive -call_shared -non_shared '' -static"
complete=0
config=0
defhdr=
define=1
iff=
usr=
cross=
debug=0
deflib=
dir=FEATURE
excludes=
executable="test -x"
exists="test -e"
gothdr=
gotlib=
idno=
idyes=
ifs=$IFS
in=
includes=
intrinsic=
libpaths="LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH"
LD_LIBRARY_PATH_default=:/lib:/usr/lib
LD_LIBRARYN32_PATH_default=:/lib32:/usr/lib32
LD_LIBRARY64_PATH_default=:/lib64:/usr/lib64
LIBPATH_default=:/lib:/usr/lib
SHLIB_PATH_default=:/shlib:/usr/shlib:/lib:/usr/lib
nl="
"
occ=cc
one=
out=
posix_read=
protoflags=
puthdr=
putlib=
pragma=
case $RANDOM in
$RANDOM)shell=bsh
($executable .) 2>/dev/null || executable='test -r'
($exists .) 2>/dev/null || exists='test -r'
;;
*) case $BASH_VERSION in
?*) shell=bash ;;
*) shell=ksh ;;
esac
;;
esac
reallystatic=
reallystatictest=
regress=
static=.
statictest=
style=C
case $COTEMP in
"") case $HOSTNAME in
""|?|??|???|????|????)
tmp=${HOSTNAME}
;;
*) case $shell in
bsh) eval `echo $HOSTNAME | sed 's/\\(....\\).*/tmp=\\1/'` ;;
*) eval 'tmp=${HOSTNAME%${HOSTNAME#????}}' ;;
esac
;;
esac
tmp=${tmp}$$
;;
*) tmp=$COTEMP
;;
esac
case $tmp in
??????????*)
case $shell in
bsh) eval `echo $tmp | sed 's/\\(.........\\).*/tmp=\\1/'` ;;
*) eval 'tmp=${tmp%${tmp#?????????}}' ;;
esac
;;
?????????)
;;
????????)
tmp=F$tmp
;;
esac
tmp=./$tmp
undef=0
verbose=0
# options -- `-' for output to stdout otherwise usage
case $1 in
-) out=-; shift ;;
esac
set=
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
0123) USAGE=$'
[-?
@(#)$Id$
]
'$USAGE_LICENSE$'
[+NAME?iffe - C compilation environment feature probe]
[+DESCRIPTION?\biffe\b is a command interpreter that probes the C
compilation environment for features. A feature is any file, option
or symbol that controls or is controlled by the C compiler. \biffe\b
tests features by generating and compiling C programs and observing
the behavior of the C compiler and generated programs.]
[+?\biffe\b statements are line oriented. Statements may appear in the
operand list with the \b:\b operand or \bnewline\b as the line
delimiter. The standard input is read if there are no command
line statements or if \afile\a\b.iffe\b is omitted.]
[+?Though similar in concept to \bautoconf\b(1) and \bconfig\b(1), there
are fundamental differences. The latter tend to generate global
headers accessed by all components in a package, whereas \biffe\b is
aimed at localized, self contained feature testing.]
[+?Output is generated in \bFEATURE/\b\atest\a by default, where \atest\a is
the base name of \afile\a\b.iffe\b or the \biffe\b \brun\b
file operand. Output is first generated in a temporary file; the
output file is updated if it does not exist or if the temporary file
is different. If the first operand is \b-\b then the output is written
to the standard output and no update checks are done.]
[+?Files with suffixes \b.iffe\b and \b.iff\b are assumed to contain
\biffe\b statements.]
[a:all?Define failed test macros \b0\b. By default only successful test macros
are defined \b1\b.]
[c:cc?Sets the C compiler name and flags to be used in the feature
tests.]:[C-compiler-name [C-compiler-flags ...]]]
[C:config?Generate \bconfig\b(1) style \aHAVE_\a* macro names. This implies
\b--undef\b. Since \bconfig\b(1) has inconsistent naming conventions,
the \bexp\b op may be needed to translate from the (consistent)
\biffe\b names. Unless otherwise noted a \bconfig\b macro name
is the \biffe\b macro name prefixed with \bHAVE\b and converted to
upper case. \b--config\b is set by default if the command arguments
contain a \brun\b op on an input file with the base name \bconfig\b.]
[d:debug?Sets the debug level. Level 0 inhibits most
error messages, level 1 shows compiler messages, and
level 2 traces internal \biffe\b \bsh\b(1) actions and does
not remove core dumps on exit.]#[level]
[D:define?Successful test macro definitions are emitted. This is the default.]
[i:input?Sets the input file name to \afile\a, which
must contain \biffe\b statements.]:[file]
[I:include?Adds \b-I\b\adir\a to the C compiler flags.]:[dir]
[L:library?Adds \b-L\b\adir\a to the C compiler flags.]:[dir]
[o:output?Sets the output file name to \afile\a.]:[file]
[e:package?Sets the \bproto\b(1) package name to \aname\a.]:[name]
[p:prototyped?Emits \b#pragma prototyped\b at the top of the
output file. See \bproto\b(1).]
[P:pragma?Emits \b#pragma\b \atext\a at the top of the output file.]:[text]
[r:regress?Massage output for regression testing.]
[s:shell?Sets the internal shell name to \aname\a. Used for debugging
Bourne shell compatibility (otherwise \biffe\b uses \aksh\a constructs
if available). The supported names are \bksh\b, \bbsh\b, \bbash\b.
The default is determined by probing the shell at startup.]:[name]
[S:static?Sets the C compiler flags that force static linking. If not set
then \biffe\b probes the compiler to determine the flags. \biffe\b
must use static linking (no dlls) because on some systems missing
library symbols are only detected when referenced at runtime from
dynamically linked executables.]:[flags]
[u:undef?\b#undef\b failed test macros. By default only successful test macros
are defined \b1\b.]
[v:verbose?Produce a message line on the standard error for each test as
it is performed.]
[x:cross?Some tests compile an executable (\ba.out\b) and then run it.
If the C compiler is a cross compiler and the executable format is
incompatible with the execution environment then the generated
executables must be run in a different environment, possibly on
another host. \acrosstype\a is the HOSTTYPE for generated executables
(the \bpackage\b(1) command generates a consistent HOSTTYPE namespace).
Generated executables are run via \bcrossexec\b(1) with \acrosstype\a
as the first argument. \bcrossexec\b supports remote execution for
cross-compiled executables. See \bcrossexec\b(1) for
details.]:[crosstype]
[X:exclude?Removes \b-I\b\adir\a and \b-I\b*/\adir\a C compiler flags.]:[dir]
[ - ] [ file.iffe | statement [ : statement ... ] ]
[+SYNTAX?\biffe\b input consists of a sequence of statement lines. Statements
that span more than one line contain \abegin\a\b{\b as the last
operand (where \abegin\a is command specific) and zero
or more data lines terminated by a line containing
\b}end\b as the first operand. The statement syntax is:
[\aname\a \b=\b]] [\b!\b]] \atest\a[,\atest\a...]] [\b-\b]]
[\aarg\a[,\aarg\a...]]]] [\aprereq\a ...]]
[\abegin\a{ ... |\bend\b ...]] [= [\adefault\a]]]].
\atest\as and \aarg\as may be combined, separated by commas, to perform
a set of tests on a set of arguments. \aname\a \b=\b before \atest\a
overrides the default test variable and macro name, and \b-\b after
\atest\a performs the test but does not define the test variable and
macro values. \b!\b before \atest\a inverts the test sense for \bif\b,
\belif\b, and \byes{\b and \bno{\b blocks.]
[+?\aprereq\as are used when applying the features tests and may be
combinations of:]{
[+compiler options?\b-D\b*, \b-L\b*, etc.]
[+library references?\b-l\b*, *\b.a\b, etc. \b_LIB_\b\aname\a
is defined to be 1 if \b-l\b\aname\a is a library.]
[+header references?*\b.h\b. \a_dir_name\a is defined to be 1
if \adir/name\a\b.h\b is a header, or if \adir\a is
omitted, \b_hdr_\b\aname\a is defined to be 1 if
\aname\a\b.h\b is a header.]
[+-?Prereq grouping mark; prereqs before the first \b-\b are
passed to all feature tests. Subsequent groups
are attempted in left-to-right order until the first
successful group is found.]
}
[+?\abegin\a\b{\b ... \b}end\b delimit multiline code blocks that override
or augment the default code provided by \biffe\b. User supplied code
blocks should be compatible with the K&R, ANSI, and C++ C language
dialects for maximal portability. In addition to all macro definitions
generated by previous tests, all generated code contains the
following at the top to hide dialect differences:]{
[+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)?]
[+#define _STD_ 1?]
[+#define _VOID_ void?]
[+#else?]
[+#define _STD_ 0?]
[+#define _VOID_ char?]
[+#endif?]
[+#if defined(__cplusplus)?]
[+#define _BEGIN_EXTERNS_ extern "C" {?]
[+#define _END_EXTERNS_ }?]
[+#else?]
[+#define _BEGIN_EXTERNS_?]
[+#define _END_EXTERNS_?]
[+#endif?]
[+#define _NIL_(x) ((x)0)?]
}
[+?= \adefault\a may be specified for the \bkey\b, \blib\b, \bmac\b, \bmth\b
and \btyp\b tests. If the test fails for \aarg\a then
\b#define\b \aarg\a \adefault\a is emitted. \bkey\b accepts multiple
\b= \b\adefault\a values; the first valid one is used.]
[+?Each test statement generates a portion of a C language header that contains
macro defintions, comments, and other text corresponding to the feature
tests. \b#ifndef _def_\b\aname\a\b_\b\adirectory\a ...
\b#endif\b guards the generated header from multiple \b#include\bs,
where \aname\a is determined by either the \brun\b statement input file
name if any, or the first \atest\a in the first statement, and \adirectory\a
is the basename component of either the \brun\b statement file, if any,
or the current working directory. The output file name is determined
in this order:]{
[+-?If the first command line operand is \b-\b then the output
is written to the standard output.]
[+--output=\afile\a?Output is \afile\a.]
[+set out \afile\a?Output is \afile\a.]
[+[run]] [\adirectory\a/]]\abase\a[\a.suffix\a]]?Output is
\bFEATURE/\b\abase\a.]
}
[+?Generated \biffe\b headers are often referenced in C source as:
\b#include "FEATURE/\b\afile\a". The \bnmake\b(1) base rules contain
metarules for generating \bFEATURE/\b\afile\a from
\bfeatures/\b\afile\a[\asuffix\a]], where \asuffix\a may be omitted,
\b.c\b, or \b.sh\b (see the \brun\b test below). Because
\b#include\b prerequisites are automatically detected, \bnmake\b(1)
ensures that all prerequisite \biffe\b headers are generated before
compilation. Note that the directories are deliberately named
\bFEATURE\b and \bfeatures\b to keep case-ignorant file systems
happy.]
[+?The feature tests are:]{
[+# \acomment\a?Comment line - ignored.]
[+cmd \aname\a?Defines \b_cmd_\b\aname\a if \aname\a is an executable
in one of the standard system directories (\b/bin, /etc,
/usr/bin, /usr/etc, /usr/ucb\b).
\b_\b\adirectory\a\b_\b\aname\a is defined for \adirectory\a
in which \aname\a is found (with \b/\b translated to \b_\b).]
[+dat \aname\a?Defines \b_dat_\b\aname\a if \aname\a is a data symbol
in the default libraries.]
[+def \aname\a?Equivalent to \bcmd,dat,hdr,key,lib,mth,sys,typ\b
\aname\a.]
[+dfn \aname\a?If \aname\a is a macro in the candidate headers then
a \b#define\b \aname\a \avalue\a statement is output for the
\avalue\a defined in the headers. The definition is \b#ifndef\b
guarded.]
[+exp \aname\a \aexpression\a?If \aexpression\a is a \"...\" string
then \aname\a is defined to be the string, else if the
\bexpr\b(1) evaluation of \aexpression\a is not 0 then \aname\a
is defined to be 1, otherwise \aname\a is defined to be 0.
Identifiers in \aexpression\a may be previously defined names
from other \biffe\b tests; undefined names evaluate to 0.
If \aname\a was defined in a previous successful test then
the current and subsequent \bexp\b test on \aname\a are
skipped. If \aname\a is \b-\b then the \aexpression\a is
simply evaluated.]
[+hdr \aname\a?Defines \b_hdr_\b\aname\a if the header
\b<\b\aname\a\b.h>\b exists. The \b--config\b macro name is
\bHAVE_\b\aNAME\a\b_H\b.]
[+if \astatement\a ... | \belif\b \astatement\a ... | \belse\b
| \bendif\b?Nested if-else test control.]
[+iff \aname\a?The generated header \b#ifndef-#endif\b macro guard is
\b_\b\aname\a\b_H\b.]
[+key \aname\a?Defines \b_key_\b\aname\a if \aname\a is a reserved
word (keyword).]
[+lcl \aname\a?Generates a \b#include\b statement for the native version
of the header \b<\b\aname\a\b.h>\b if it exists. Defines
\b_lcl_\b\aname\a on success. The \b--config\b macro name is
\bHAVE_\b\aNAME\a\b_H\b.]
[+lib \aname\a?Defines \b_lib_\b\aname\a if \aname\a is an external
symbol in the default libraries.]
[+mac \aname\a?Defines \b_mac_\b\aname\a if \aname\a is a macro.]
[+mem \astruct.member\a?Defines \b_mem_\b\amember\a\b_\b\astruct\a
if \amember\a is a member of the structure \astruct\a.]
[+mth \aname\a?Defines \b_mth_\b\aname\a if \aname\a is an external
symbol in the math library.]
[+nop \aname\a?If this is the first test then \aname\a may be used
to name the output file and/or the output header guard macro.
Otherwise this test is ignored.]
[+npt \aname\a?Defines \b_npt_\b\aname\a if the \aname\a symbol
requires a prototype. The \b--config\b macro name is
\bHAVE_\aNAME\a\b_DECL\b with the opposite sense.]
[+num \aname\a?Defines \b_num_\b\aname\a if \aname\a is a numeric
constant \aenum\a or \amacro\a.]
[+nxt \aname\a?Defines a string macro \b_nxt_\b\aname\a suitable for
a \b#include\b statement to include the next (on the include
path) or native version of the header \b<\b\aname\a\b.h>\b
if it exists. Also defines the \"...\" form
\b_nxt_\b\aname\a\b_str\b. The \b--config\b macro name is
\bHAVE_\b\aNAME\a\b_NEXT\b.]
[+one \aheader\a ...?Generates a \b#include\b statement for the first
header found in the \aheader\a list.]
[+pth \afile\a [ \adir\a ... | { \ag1\a - ... - \agn\a } | < \apkg\a [\aver\a ...]] > ]]?Defines
\b_pth_\b\afile\a, with embedded \b/\b chars translated to
\b_\b, to the path of the first instance of \afile\a in the
\adir\a directories. \b{\b ... \b}\b forms a directory list
from the cross-product of \b-\b separated directory groups
\ag1\a ... \agn\a. < ... > forms a directory list for the
package \apkg\a with optional versions. The \b--config\b macro
name is \aNAME\a\b_PATH\b.]
[+run \afile\a?Runs the tests in \afile\a based on the \afile\a
suffix:]{
[+.c?\afile\a is compiled and executed and the output is copied
to the \biffe\b output file.]
[+.sh?\afile\a is executed as a shell script and the output is
copied to the \biffe\b output file.]
[+.iffe \bor no suffix?\afile\a contains \biffe\b
statements.]
}
[+set \aoption value\a?Sets option values. The options are described
above.]
[+siz \aname\a?Defines \b_siz_\b\aname\a to be \bsizeof\b(\aname\a) if
\aname\a is a type in any of \b<sys/types.h>, <times.h>,
<stddef.h>, <stdlib.h>\b. Any \b.\b characters in \aname\a are
translated to space before testing and are translated to \b_\b
in the output macro name.]
[+sym \aname\a?Defines \b_ary_\b\aname\a if \aname\a is an array,
\b_fun_\b\aname\a if \aname\a is a function pointer,
\b_ptr_\b\aname\a if \aname\a is a pointer, or
\b_reg_\b\aname\a if \aname\a is a scalar. In most cases
\aname\a is part of a macro expansion.]
[+sys \aname\a?Defines \b_sys_\b\aname\a if the header
\b<sys/\b\aname\a\b.h>\b exists. The \b--config\b macro name is
\bHAVE_SYS_\b\aNAME\a\b_H\b.]
[+tst \aname\a?A user defined test on name. A source block must be
supplied. Defines \b_\b\aname\a on success.]
[+typ \aname\a?Defines \b_typ_\b\aname\a if \aname\a is a type in any
of \b<sys/types.h>, <times.h>, <stddef.h>, <stdlib.h>\b. Any
\b.\b characters in \aname\a are translated to space before
testing and are translated to \b_\b in the output macro name.]
[+val \aname\a?The output of \becho\b \aname\a is written to the
output file.]
[+var \aname\a?A user defined test on name. A source block must be
supplied. Sets the \bexp\b variable \b_\b\aname\a on success
but does not define a macro.]
[+(\aexpression\a)?Equivalent to \bexp -\b \aexpression\a.]
}
[+?Code block names may be prefixed by \bno\b to invert the test sense. The
block names are:]{
[+cat?The block is copied to the output file.]
[+compile?The block is compiled (\bcc -c\b).]
[+cross?The block is executed as a shell script using \bcrossexec\b(1)
if \b--cross\b is on, or on the local host otherwise, and the
output is copied to the output file. Test macros are not
exported to the script.]
[+execute?The block is compiled, linked, and executed. \b0\b exit
status means success.]
[+fail?If the test fails then the block text is evaluated by
\bsh\b(1).]
[+link?The block is compiled and linked (\bcc -o\b).]
[+macro?The block is preprocessed (\bcc -E\b) and lines containing
text bracketed by \b<<"\b ... \b">>\b (\aless-than less-than
double-quote ... double-quote greater-than greater-than\a)
are copied to the output file with the brackets omitted.]
[+no?If the test fails then the block text is copied to the
output file. Deprecated: use { \bif\b \belif\b \belse\b
\bendif\b } with unnamed \b{\b ... \b}\b blocks.]
[+note?If the test succeeds then the block is copied to the output
as a \b/*\b ... \b*/\b comment.]
[+output?The block is compiled, linked, and executed, and the output
is copied to the output file.]
[+pass?If the test succeeds then the block text is evaluated by
\bsh\b(1).]
[+preprocess?The block is preprocessed (\bcc -E\b).]
[+run?The block is executed as a shell script and the output is
copied to the output file. Successful test macros are also
defined as shell variables with value \b1\b and are available
within the block. Likewise, failed test macros are defined
as shell variables with value \b0\b.]
[+yes?If the test succeeds then the block text is copied to the output
file. \byes{\b ... \b}end\b is equivalent to the unnamed block
\b{\b ... \b}\b. Deprecated: use { \bif\b \belif\b \belse\b
\bendif\b } with unnamed \b{\b ... \b}\b blocks.]
}
[+SEE ALSO?\bautoconf\b(1), \bconfig\b(1), \bcrossexec\b(1), \bnmake\b(1),
\bpackage\b(1), \bproto\b(1), \bsh\b(1)]
'
while getopts -a "$command" "$USAGE" OPT
do case $OPT in
a) set="$set set all :" ;;
c) set="$set set cc $OPTARG :" ;;
C) set="$set set config :" ;;
d) set="$set set debug $OPTARG :" ;;
D) set="$set set define :" ;;
i) set="$set set input $OPTARG :" ;;
I) set="$set set include $OPTARG :" ;;
L) set="$set set library $OPTARG :" ;;
o) set="$set set output $OPTARG :" ;;
e) set="$set set package $OPTARG :" ;;
p) set="$set set prototyped :" ;;
P) set="$set set pragma $OPTARG :" ;;
r) set="$set set regress :" ;;
s) set="$set set shell $OPTARG :" ;;
S) set="$set set static $OPTARG :" ;;
u) set="$set set undef :" ;;
v) set="$set set verbose :" ;;
x) set="$set set cross $OPTARG :" ;;
X) set="$set set exclude $OPTARG :" ;;
esac
done
shift `expr $OPTIND - 1`
;;
*) while :
do case $# in
0) break ;;
esac
case $1 in
-) break
;;
--) shift
break
;;
--a|--al|--all)
REM=a
;;
--cc=*) REM=c`echo $1 | sed -e 's,[^=]*=,,'`
;;
--co|--con|--conf|--confi|--config)
REM=C
;;
--cr=*|--cro=*|--cros=*|--cross=*)
REM=x`echo $1 | sed -e 's,[^=]*=,,'`
;;
--d=*|--de=*|--deb=*|--debu=*|--debug=*)
REM=d`echo $1 | sed -e 's,[^=]*=,,'`
;;
--def|--defi|--defin|--define)
REM=D
;;
--e=*|--ex=*|--exc=*|--excl=*|--exclu=*|--exclud=*|--exclude=*)
REM=X`echo $1 | sed -e 's,[^=]*=,,'`
;;
--inp=*|--inpu=*|--input=*)
REM=i`echo $1 | sed -e 's,[^=]*=,,'`
;;
--inc=*|--incl=*|--inclu=*|--includ=*|--include=*)
REM=I`echo $1 | sed -e 's,[^=]*=,,'`
;;
--l=*|--li=*|--lib=*|--libr=*|--libra=*|--librar=*|--library=*)
REM=L`echo $1 | sed -e 's,[^=]*=,,'`
;;
--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*)
REM=o`echo $1 | sed -e 's,[^=]*=,,'`
;;
--pa=*|--pac=*|--pack=*|--packa=*|--packag=*|--package=*)
REM=e`echo $1 | sed -e 's,[^=]*=,,'`
;;
--pro|--prot|--proto|--protot|--prototy|--prototyp|--prototype|--prototyped)
REM=p
;;
--pra=*|--prag=*|--pragma=*)
REM=P`echo $1 | sed -e 's,[^=]*=,,'`
;;
--r|--re|--reg|--regre|--regres|--regress)
REM=r
;;
--sh=*|--she=*|--shel=*|--shell=*)
REM=s`echo $1 | sed -e 's,[^=]*=,,'`
;;
--st=*|--sta=*|--stat=*|--stati=*|--static=*)
REM=S`echo $1 | sed -e 's,[^=]*=,,'`
;;
--u|--un|--und|--unde|--undef)
REM=u
;;
--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
REM=v
;;
--*) echo $command: $1: unknown option >&2
exit 2
;;
-*) REM=`echo $1 | sed -e 's,-,,'`
;;
*) break
;;
esac
shift
while :
do case $REM in
'') break ;;
esac
eval `echo $REM | sed -e "s,\(.\)\(.*\),OPT='\1' REM='\2',"`
case $OPT in
[cdiILoePsSxX])
case $REM in
'') case $# in
0) echo $command: -$OPT: option argument expected >&2
exit 1
;;
esac
OPTARG=$1
shift
;;
*) OPTARG=$REM
REM=''
;;
esac
esac
case $OPT in
a) set="$set set all :" ;;
c) set="$set set cc $OPTARG :" ;;
C) set="$set set config :" ;;
d) set="$set set debug $OPTARG :" ;;
D) set="$set set define :" ;;
i) set="$set set input $OPTARG :" ;;
I) set="$set set include $OPTARG :" ;;
L) set="$set set library $OPTARG :" ;;
o) set="$set set output $OPTARG :" ;;
e) set="$set set package $OPTARG :" ;;
p) set="$set set prototyped :" ;;
P) set="$set set pragma $OPTARG :" ;;
r) set="$set set regress :" ;;
s) set="$set set shell $OPTARG :" ;;
S) set="$set set static $OPTARG :" ;;
u) set="$set set undef :" ;;
v) set="$set set verbose :" ;;
x) set="$set set cross $OPTARG :" ;;
X) set="$set set exclude $OPTARG :" ;;
*) echo "Usage: $command [-aCDpruv] [-c C-compiler-name [C-compiler-flags ...]] [-d level]
[-i file] [-o file] [-e name] [-P text] [-s shell-path] [-S[flags]]
[-x cross-exec-prefix] [-I dir] [-L dir] [-X dir] [ - ]
[ file.iffe | statement [ : statement ... ] ]" >&2
exit 2
;;
esac
done
done
;;
esac
case $1 in
-) out=-; shift ;;
esac
case $# in
0) in=- ;;
esac
set -- $set "$@"
case " $* " in
*' set config '*|*' run config.'*|*' run '*' config.'*|*' run '*'/config.'*)
config=1
;;
esac
# standard error to /dev/null unless debugging
# standard output to the current output file
#
# stdout original standard output
# stderr original standard error
# nullin /dev/null input
# nullout /dev/null output
stdout=5 stderr=6 nullin=7 nullout=8
eval "exec $nullin</dev/null $nullout>/dev/null $stdout>&1 $stderr>&2"
case " $* " in
*" set debug "[3456789]*)
;;
*) eval "exec 2>&$nullout"
;;
esac