INIT.2014-12-24
[INIT.git] / src / cmd / INIT / iffe.sh
blobfc8e373708b311600cac6d6cb20a80ab90ef66b1
1 ########################################################################
2 # #
3 # This software is part of the ast package #
4 # Copyright (c) 1994-2016 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Eclipse Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
8 # #
9 # A copy of the License is available at #
10 # http://www.eclipse.org/org/documents/epl-v10.html #
11 # (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12 # #
13 # Information and Software Systems Research #
14 # AT&T Research #
15 # Florham Park NJ #
16 # #
17 # Glenn Fowler <glenn.s.fowler@gmail.com> #
18 # #
19 ########################################################################
20 ########################################################################
21 # #
22 # This software is part of the ast package #
23 # Copyright (c) 1994-2013 AT&T Intellectual Property #
24 # and is licensed under the #
25 # Eclipse Public License, Version 1.0 #
26 # by AT&T Intellectual Property #
27 # #
28 # A copy of the License is available at #
29 # http://www.eclipse.org/org/documents/epl-v10.html #
30 # (with md5 checksum b35adb5213ca9657e911e9befb180842) #
31 # #
32 # Information and Software Systems Research #
33 # AT&T Research #
34 # Florham Park NJ #
35 # #
36 # Glenn Fowler <glenn.s.fowler@gmail.com> #
37 # #
38 ########################################################################
39 # Glenn Fowler & Phong Vo
40 # AT&T Research
42 # test if feature exists
43 # this script is written to make it through all sh variants
45 # NOTE: .exe a.out suffix and [\\/] in path patterns for dos/nt
47 case $-:$BASH_VERSION in
48 *x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
49 esac
51 command=iffe
52 version=2013-11-14 # update in USAGE too #
54 compile() # $cc ...
56 "$@" 2>$tmp.err
57 _compile_status=$?
58 if test -s $tmp.err
59 then cat $tmp.err >&2
60 case $_compile_status in
61 [1-9]|[1-9][0-9]|1[01][0-9]|12[0-7])
62 if egrep -i -c 'terminated with signal|core dump|segmentation fault' $tmp.err >&$nullout
63 then _compile_status=139
66 esac
68 case $_compile_status in
69 ?|??|1[01]?|12[0-8]|25?)
71 *) echo "$command: $@" >&$stderr
72 cat $tmp.err >&$stderr
73 echo "$command: $1: core dump or fatal interruption -- results inconclusive" >&$stderr
74 exit $_compile_status
76 esac
77 return $_compile_status
80 is_hdr() # [ - ] [ file.c ] hdr
82 case $1 in
83 -) _is_hdr_flag=-; shift ;;
84 *) _is_hdr_flag= ;;
85 esac
86 case $1 in
87 *.c) _is_hdr_file=$1; shift ;;
88 *) _is_hdr_file=$tmp.c ;;
89 esac
90 is hdr $1
91 compile $cc -c $_is_hdr_file <&$nullin >&$nullout 2>$tmp.e
92 _is_hdr_status=$?
93 case $_is_hdr_status in
94 0) if test -s $tmp.e
95 then case `grep '#.*error' $tmp.e` in
96 ?*) _is_hdr_status=1 ;;
97 esac
100 esac
101 case $_is_hdr_status in
102 0) success $_is_hdr_flag
104 *) case $debug in
105 3) cat $tmp.e >&$stderr ;;
106 esac
107 failure $_is_hdr_flag
109 esac
110 return $_is_hdr_status
113 pkg() # package
115 case $1 in
116 '') pth=`getconf PATH 2>/dev/null`
117 case $pth in
118 '') pth="/bin /usr/bin" ;;
119 *:*) pth=`echo "$pth" | sed 's/:/ /g'` ;;
120 esac
121 return
123 '<') shift
125 *) return
127 esac
128 case $1 in
129 X|X11*) i="openwin"
130 case $1 in
131 X) set X11 ;;
132 esac
133 case $1 in
134 X11) case $# in
135 1) set $1 6 5 4 ;;
136 esac
138 esac
140 *) i=
142 esac
143 pth="{ usr . - . contrib local $i - . share - . lib - $1"
144 i=$1
145 while :
146 do shift
147 case $# in
148 0) break ;;
149 esac
150 case $1 in
151 '>') shift; break ;;
152 esac
153 pth="$pth ${i}R$1 ${i}.$1"
154 done
155 pth="$pth . } $*"
158 is() # op name
160 case $verbose in
161 1) case $complete in
162 1) failure ;;
163 esac
164 oo=$1
165 shift
166 case $1 in
167 ?*) yy=is
168 ii=$1
169 complete=1
170 case $oo in
171 cmd) mm="a command" ;;
172 dat) mm="a library data symbol" ;;
173 dfn) mm="a macro with extractable value" ;;
174 exp) mm="true" ;;
175 hdr) mm="a header" ;;
176 id) mm="an identifier" ;;
177 lcl) mm="a native header" ;;
178 key) mm="a reserved keyword" ;;
179 lib) mm="a library function" ;;
180 LIB) case $2 in
181 "") mm="a library" ;;
182 *) ii=$*; mm="a library group" ;;
183 esac
185 mac) mm="a macro" ;;
186 mem) mm="a member of $2" ;;
187 mth) mm="a math library symbol" ;;
188 nos) mm="a non-opaque struct" ;;
189 npt) mm="a symbol that needs a prototype" ;;
190 num) mm="a numeric constant or enum" ;;
191 nxt) mm="an include path for the native header" ;;
192 opt) mm="set in \$PACKAGE_OPTIONS" ;;
193 pth) mm="a file" ;;
194 run) yy="capture output of" mm= ;;
195 siz) mm="a type with known size" ;;
196 sym) mm="a typed variable" ;;
197 sys) mm="a system header" ;;
198 typ) mm="a type or typedef" ;;
199 val) yy="determine" mm="value" ;;
200 *) yy= mm= ;;
201 esac
202 case $ii in
203 [abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;;
204 esac
205 $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
206 complete=1
208 esac
210 esac
213 success()
215 case $1 in
216 -) shift
218 *) case $result in
219 UNKNOWN) result=SUCCESS ;;
220 esac
221 case $1 in
222 +) return ;;
223 esac
225 esac
226 case $complete:$verbose in
227 1:1) case $suspended in
228 1) suspended=0
229 $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
231 esac
232 complete=0
233 case $# in
234 0) mm="yes" ;;
235 *) mm="'$*'" ;;
236 esac
237 case $debug in
238 0) echo " $mm" >&$stderr ;;
239 *) echo "$command: ... $mm" >&$stderr ;;
240 esac
242 esac
245 failure()
247 case $1 in
248 -) shift ;;
249 *) result=FAILURE
250 case $1 in
251 +) return ;;
252 esac
254 esac
255 case $complete:$verbose in
256 1:1) case $suspended in
257 1) suspended=0
258 $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
260 esac
261 complete=0
262 case $group in
263 '') case $# in
264 0) mm="no" ;;
265 *) mm=$* ;;
266 esac
268 *) mm=
270 esac
271 case $debug in
272 0) echo " $mm" >&$stderr ;;
273 *) echo "$command: ... $mm" >&$stderr ;;
274 esac
276 esac
279 # report
281 # - ignore global status
282 # -0 normal sense
283 # -1 inverted sense if ! def
284 # status test status 0:success *:failure
285 # success success comment
286 # failure failure comment
287 # default default setting comment
289 # globals
291 # $not invert test sense
292 # $M test variable
293 # $m test macro
294 # $v default macro
296 report() # [-] [-0] [-1] status value success failure default
298 case $1 in
299 -) _report_ignore=$1
300 shift
302 *) _report_ignore=
304 esac
305 _report_not=$not
306 case $1 in
307 -0) shift
309 -1) shift
310 case $def in
311 ''|-) case $_report_not in
312 1) _report_not= ;;
313 *) _report_not=1 ;;
314 esac
316 esac
318 esac
319 _report_status=$1
320 case $_report_ignore:$_report_status in
321 -:*) ;;
322 *:0) success $_report_ignore
324 *) failure $_report_ignore
325 case $group in
326 ?*) return ;;
327 esac
329 esac
330 _report_value=$2
331 case $_report_not in
332 1) case $_report_status in
333 0) _report_status=1 ;;
334 *) _report_status=0 ;;
335 esac
336 _report_success=$4
337 _report_failure=$3
339 *) _report_success=$3
340 _report_failure=$4
342 esac
343 _report_default=$5
344 case $_report_status in
345 0) case $M in
346 *-*) ;;
347 *) usr="$usr$nl#define $m $_report_value"
348 case $_report_success in
349 ''|-) ;;
350 *) case $define in
351 1) echo "#define $m $_report_value /* $_report_success */" ;;
352 n) echo "$m=$_report_value"
353 esac
355 esac
356 eval $m=\'$_report_value\'
358 esac
360 *) case $M in
361 *-*) ;;
362 *) case $_report_failure in
363 ''|-) ;;
364 *) case $define$all$config$undef in
365 1?1?|1??1)echo "#undef $m /* $_report_failure */" ;;
366 11??) echo "#define $m 0 /* $_report_failure */" ;;
367 n1?1) echo "$m=" ;;
368 n1??) echo "$m=0" ;;
369 esac
371 esac
372 case $_report_default in
373 ''|-) ;;
374 *) case $define$set in
375 1?*) echo "#define $v $set /* $_report_default */" ;;
376 n?*) echo "$v=$set" ;;
377 esac
379 esac
380 eval $m=0
382 esac
384 esac
387 noisy()
389 case $complete:$verbose in
390 1:1) suspended=1
391 echo >&$stderr
393 esac
396 here_broken=0
398 literal() # line that echo might process
400 if cat <<!
403 then : old here doc botch not present
404 else case $here_broken in
405 0) here_broken=1
406 echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
408 esac
409 sh -c "cat <<!
416 copy() # "output-file" "data-that-must-not-be-processed-by-echo"
418 case $1 in
419 -) case $shell in
420 ksh) print -r - "$2"
422 *) if cat <<!
425 then : ancient here doc botch not present
426 else case $here_broken in
427 0) here_broken=1
428 echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
430 esac
431 sh -c "cat <<!
437 esac
439 *) case $shell in
440 ksh) print -r - "$2" > "$1"
442 *) if cat > "$1" <<!
445 then : ancient here doc botch not present
446 else case $here_broken in
447 0) here_broken=1
448 echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
450 esac
451 sh -c "cat > \"$1\" <<!
457 esac
459 esac
462 # verify that cc is a C compiler
464 checkcc()
466 # check for local package root directories
468 case $PACKAGE_PATH in
469 ?*) for i in `echo $PACKAGE_PATH | sed 's,:, ,g'`
470 do if test -d $i/include
471 then cc="$cc -I$i/include"
472 occ="$occ -I$i/include"
474 if test -d $i/lib
475 then cc="$cc -L$i/lib"
476 occ="$occ -L$i/lib"
477 for y in $libpaths
478 do eval $y=\"\$$y:\$i/lib\$${y}_default\"
479 eval export $y
480 done
482 done
484 esac
485 echo "int i = 1;" > $tmp.c
486 if compile $cc -c $tmp.c <&$nullin >&$nullout
487 then echo "(;" > $tmp.c
488 if compile $cc -c $tmp.c <&$nullin >&$nullout
489 then cctest="should not compile '(;'"
491 else cctest="should compile 'int i = 1;'"
493 case $cctest in
494 "") cctest=0
496 *) echo "$command: $cc: not a C compiler: $cctest" >&$stderr
497 exit 1
499 esac
502 checkread()
504 case $cctest in
505 "") checkcc ;;
506 esac
507 case $posix_read in
508 -no) ;;
509 *) posix_read=`(read -r _checkread_line; echo $_checkread_line) 2>/dev/null <<!
514 esac
515 case $posix_read in
516 "a z") posix_read=1
518 *) copy ${tmp}r.c "
519 extern int read();
520 extern int write();
521 int main()
523 char c;
524 char r;
525 int k;
526 char s[32];
527 k = 0;
528 while (read(0, &c, 1) == 1)
530 if (k >= 0)
532 if (c == ' ' || c == '\\t')
534 if (k < sizeof(s))
535 s[k++] = c;
536 continue;
538 if (k > 1 && c != '#' && c != '\\n' && c != '\\r')
539 write(1, s + 1, k - 1);
540 k = -1;
542 if (c == '\\r')
544 r = c;
545 if (read(0, &c, 1) == 1 && c != '\\n')
546 write(1, &r, 1);
548 write(1, &c, 1);
549 if (c == '\\n')
550 return 0;
552 return 1;
554 if compile $cc -o ${tmp}r.exe ${tmp}r.c >&$nullout
555 then posix_read=${tmp}r.exe
556 else echo "$command: cannot compile read -r workaround" >&$stderr
557 exit 1
560 esac
563 execute()
565 case $verbose in
566 0) noteout=$nullout ;;
567 *) noteout=$stderr ;;
568 esac
569 if test "" != "$cross"
570 then crossexec $cross "$@" $tmp.u 9>&$noteout
571 _execute_=$?
572 elif test -d /NextDeveloper
573 then "$@" $tmp.u <&$nullin >&$nullout 9>&$noteout
574 _execute_=$?
575 "$@" $tmp.u <&$nullin | cat
576 else "$@" $tmp.u 9>&$noteout
577 _execute_=$?
579 rm -rf $tmp.u* > /dev/null 2>&1
580 return $_execute_
583 exclude()
585 case $excludes in
586 '') return 0 ;;
587 esac
588 for _exclude_var
589 do eval _exclude_old=\$$_exclude_var
590 case $_exclude_old in
591 *" -I"*);;
592 *) continue ;;
593 esac
594 _exclude_new=
595 _exclude_sep=
596 for _exclude_arg in $_exclude_old
597 do _exclude_skip=
598 for _exclude_dir in $excludes
599 do case $_exclude_arg in
600 -I$_exclude_dir|-I*/$_exclude_dir)
601 _exclude_skip=1
602 break;
604 esac
605 done
606 case $_exclude_skip in
607 '') _exclude_new="$_exclude_new$_exclude_sep$_exclude_arg"
608 _exclude_sep=" "
610 esac
611 done
612 eval $_exclude_var=\$_exclude_new
613 case $debug in
614 0) ;;
615 *) echo $command: exclude $_exclude_var: "$_exclude_old => $_exclude_new" >&$stderr
617 esac
618 done
621 all=0
622 apis=
623 apisame=
624 binding="-dy -dn -Bdynamic -Bstatic -Wl,-ashared -Wl,-aarchive -call_shared -non_shared '' -static"
625 complete=0
626 config=0
627 defhdr=
628 define=1
629 explicit=0
630 iff=
631 usr=
632 cross=
633 debug=0
634 deflib=
635 dir=FEATURE
636 excludes=
637 executable="test -x"
638 exists="test -e"
639 gothdr=
640 gotlib=
641 idno=
642 idyes=
643 ifs=${IFS-'
646 includes=
647 intrinsic=
648 libpaths="LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH"
649 LD_LIBRARY_PATH_default=:/lib:/usr/lib
650 LD_LIBRARYN32_PATH_default=:/lib32:/usr/lib32
651 LD_LIBRARY64_PATH_default=:/lib64:/usr/lib64
652 LIBPATH_default=:/lib:/usr/lib
653 SHLIB_PATH_default=:/shlib:/usr/shlib:/lib:/usr/lib
654 nl="
656 optimize=1
657 occ=cc
658 one=
659 out=
660 posix_read=-check
661 case `(set -f && set x * && echo $# && set +f) 2>/dev/null` in
662 2) posix_noglob="set -f" posix_glob="set +f" ;;
663 *) case `(set -F && set x * && echo $# && set +F) 2>/dev/null` in
664 2) posix_noglob="set -F" posix_glob="set +F" ;;
665 *) posix_noglob=":" posix_glob=":" ;;
666 esac
668 esac
669 protoflags=
670 puthdr=
671 putlib=
672 pragma=
673 case $RANDOM in
674 $RANDOM)shell=bsh
675 ($executable .) 2>/dev/null || executable='test -r'
676 ($exists .) 2>/dev/null || exists='test -r'
678 *) case $BASH_VERSION in
679 ?*) shell=bash ;;
680 *) shell=ksh ;;
681 esac
683 esac
684 reallystatic=
685 reallystatictest=
686 regress=
687 static=.
688 statictest=
689 case $COTEMP in
690 "") case $HOSTNAME in
691 ""|?|??|???|????|????)
692 tmp=${HOSTNAME}
694 *) case $shell in
695 bsh) eval `echo $HOSTNAME | sed 's/\\(....\\).*/tmp=\\1/'` ;;
696 *) eval 'tmp=${HOSTNAME%${HOSTNAME#????}}' ;;
697 esac
699 esac
700 tmp=${tmp}$$
702 *) tmp=x${COTEMP}
704 esac
705 COTEMP=${tmp}
706 export COTEMP
707 case $tmp in
708 ./*) ;;
709 ??????????*)
710 case $shell in
711 bsh) eval `echo $tmp | sed 's/\\(.........\\).*/tmp=\\1/'` ;;
712 *) eval 'tmp=${tmp%${tmp#?????????}}' ;;
713 esac
715 ?????????)
717 ????????)
718 tmp=F$tmp
720 esac
721 case $tmp in
722 ./*) ;;
723 *) tmp=./$tmp ;;
724 esac
725 undef=0
726 verbose=0
727 vers=
729 # options -- `-' for output to stdout otherwise usage
731 case $1 in
732 -) out=-; shift ;;
733 esac
734 set=
736 case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
737 0123) USAGE=$'
739 @(#)$Id: iffe (AT&T Research) 2013-11-14 $
741 '$USAGE_LICENSE$'
742 [+NAME?iffe - C compilation environment feature probe]
743 [+DESCRIPTION?\biffe\b is a command interpreter that probes the C
744 compilation environment for features. A feature is any file, option
745 or symbol that controls or is controlled by the C compiler. \biffe\b
746 tests features by generating and compiling C programs and observing
747 the behavior of the C compiler and generated programs.]
748 [+?\biffe\b statements are line oriented. Statements may appear in the
749 operand list with the \b:\b operand or \bnewline\b as the line
750 delimiter. The standard input is read if there are no command
751 line statements or if \afile\a\b.iffe\b is omitted.]
752 [+?Though similar in concept to \bautoconf\b(1) and \bconfig\b(1), there
753 are fundamental differences. The latter tend to generate global
754 headers accessed by all components in a package, whereas \biffe\b is
755 aimed at localized, self contained feature testing.]
756 [+?Output is generated in \bFEATURE/\b\atest\a by default, where \atest\a is
757 the base name of \afile\a\b.iffe\b or the \biffe\b \brun\b
758 file operand. Output is first generated in a temporary file; the
759 output file is updated if it does not exist or if the temporary file
760 is different. If the first operand is \b-\b then the output is written
761 to the standard output and no update checks are done.]
762 [+?Files with suffixes \b.iffe\b and \b.iff\b are assumed to contain
763 \biffe\b statements.]
764 [a:all?Define failed test macros \b0\b. By default only successful test macros
765 are defined \b1\b.]
766 [c:cc?Sets the C compiler name and flags to be used in the feature
767 tests.]:[C-compiler-name [C-compiler-flags ...]]]
768 [C:config?Generate \bconfig\b(1) style \aHAVE_\a* macro names. This implies
769 \b--undef\b. Since \bconfig\b(1) has inconsistent naming conventions,
770 the \bexp\b op may be needed to translate from the (consistent)
771 \biffe\b names. Unless otherwise noted a \bconfig\b macro name
772 is the \biffe\b macro name prefixed with \bHAVE\b and converted to
773 upper case. \b--config\b is set by default if the command arguments
774 contain a \brun\b op on an input file with the base name \bconfig\b.]
775 [d:debug?Sets the debug level. Level 0 inhibits most
776 error messages, level 1 shows compiler messages, and
777 level 2 traces internal \biffe\b \bsh\b(1) actions and does
778 not remove core dumps on exit.]#[level]
779 [D:define?Successful test macro definitions are emitted. This is the default.]
780 [E:explicit?Disable implicit test output.]
781 [F:features?Sets the feature test header to \ahdr\a. This header typically
782 defines *_SOURCE feature test macros.]:[hdr:=NONE]
783 [i:input?Sets the input file name to \afile\a, which
784 must contain \biffe\b statements.]:[file]
785 [I:include?Adds \b-I\b\adir\a to the C compiler flags.]:[dir]
786 [L:library?Adds \b-L\b\adir\a to the C compiler flags.]:[dir]
787 [n:name-value?Output \aname\a=\avalue\a assignments only.]
788 [N!:optimize?\b--nooptimize\b disables compiler optimization options.]
789 [o:output?Sets the output file name to \afile\a.]:[file]
790 [O:stdio?Sets the standard io header to \ahdr\a.]:[hdr:=stdio.h]
791 [e:package?Sets the \bproto\b(1) package name to \aname\a.]:[name]
792 [p:prototyped?Emits \b#pragma prototyped\b at the top of the
793 output file. See \bproto\b(1).]
794 [P:pragma?Emits \b#pragma\b \atext\a at the top of the output file.]:[text]
795 [r:regress?Massage output for regression testing.]
796 [s:shell?Sets the internal shell name to \aname\a. Used for debugging
797 Bourne shell compatibility (otherwise \biffe\b uses \aksh\a constructs
798 if available). The supported names are \bksh\b, \bbsh\b, \bbash\b, and
799 \bosh\b. \bosh\b forces the \bread -r\b compatibility read command to
800 be compiled and used instead of \bread -r\b. The default is determined
801 by probing the shell at startup.]:[name]
802 [S:static?Sets the C compiler flags that force static linking. If not set
803 then \biffe\b probes the compiler to determine the flags. \biffe\b
804 must use static linking (no dlls) because on some systems missing
805 library symbols are only detected when referenced at runtime from
806 dynamically linked executables.]:[flags]
807 [u:undef?\b#undef\b failed test macros. By default only successful test macros
808 are defined \b1\b.]
809 [v:verbose?Produce a message line on the standard error for each test as
810 it is performed.]
811 [x:cross?Some tests compile an executable (\ba.out\b) and then run it.
812 If the C compiler is a cross compiler and the executable format is
813 incompatible with the execution environment then the generated
814 executables must be run in a different environment, possibly on
815 another host. \acrosstype\a is the HOSTTYPE for generated executables
816 (the \bpackage\b(1) command generates a consistent HOSTTYPE namespace).
817 Generated executables are run via \bcrossexec\b(1) with \acrosstype\a
818 as the first argument. \bcrossexec\b supports remote execution for
819 cross-compiled executables. See \bcrossexec\b(1) for
820 details.]:[crosstype]
821 [X:exclude?Removes \b-I\b\adir\a and \b-I\b*/\adir\a C compiler flags.]:[dir]
823 [ - ] [ file.iffe | statement [ : statement ... ] ]
825 [+SYNTAX?\biffe\b input consists of a sequence of statement lines. Statements
826 that span more than one line contain \abegin\a\b{\b as the last
827 operand (where \abegin\a is command specific) and zero
828 or more data lines terminated by a line containing
829 \b}end\b as the first operand. The statement syntax is:
830 [\aname\a \b=\b]] [\b!\b]] \atest\a[,\atest\a...]] [\b-\b]]
831 [\aarg\a[,\aarg\a...]]]] [\aprereq\a ...]]
832 [\abegin\a{ ... |\bend\b ...]] [= [\adefault\a]]]].
833 \atest\as and \aarg\as may be combined, separated by commas, to perform
834 a set of tests on a set of arguments. \aname\a \b=\b before \atest\a
835 overrides the default test variable and macro name, and \b-\b after
836 \atest\a performs the test but does not define the test variable and
837 macro values. \b!\b before \atest\a inverts the test sense for \bif\b,
838 \belif\b, and \byes{\b and \bno{\b blocks.]
839 [+?\aprereq\as are used when applying the features tests and may be
840 combinations of:]{
841 [+compiler options?\b-D\b*, \b-L\b*, etc.]
842 [+library references?\b-l\b*, *\b.a\b, etc. \b_LIB_\b\aname\a
843 is defined to be 1 if \b-l\b\aname\a is a library.]
844 [+header references?*\b.h\b. \a_dir_name\a is defined to be 1
845 if \adir/name\a\b.h\b is a header, or if \adir\a is
846 omitted, \b_hdr_\b\aname\a is defined to be 1 if
847 \aname\a\b.h\b is a header.]
848 [+-?Prereq grouping mark; prereqs before the first \b-\b are
849 passed to all feature tests. Subsequent groups
850 are attempted in left-to-right order until the first
851 successful group is found.]
853 [+?\abegin\a\b{\b ... \b}end\b delimit multiline code blocks that override
854 or augment the default code provided by \biffe\b. User supplied code
855 blocks should be compatible with the K&R, ANSI, and C++ C language
856 dialects for maximal portability. Test code may call the function
857 \bNOTE("...")\b to emit short text in \b--verbose\b output; only one
858 \bNOTE()\b should be called per test for readability. In addition to
859 all macro definitions generated by previous tests, all generated
860 code contains the following at the top to hide dialect differences:]{
861 [+ ?#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)]
862 [+ ?#define _STD_ 1]
863 [+ ?#define _ARG_(x) x]
864 [+ ?#define _VOID_ void]
865 [+ ?#else]
866 [+ ?#define _STD_ 0]
867 [+ ?#define _ARG_(x) ()]
868 [+ ?#define _VOID_ char]
869 [+ ?#endif]
870 [+ ?#if defined(__cplusplus)]
871 [+ ?#define _BEGIN_EXTERNS_ extern "C" {]
872 [+ ?#define _END_EXTERNS_ }]
873 [+ ?#else]
874 [+ ?#define _BEGIN_EXTERNS_]
875 [+ ?#define _END_EXTERNS_]
876 [+ ?#endif]
877 [+ ?#define _NIL_(x) ((x)0)]
878 [+ ?#include <stdio.h>]
880 [+?= \adefault\a may be specified for the \bkey\b, \blib\b, \bmac\b, \bmth\b
881 and \btyp\b tests. If the test fails for \aarg\a then
882 \b#define\b \aarg\a \adefault\a is emitted. \bkey\b accepts multiple
883 \b= \b\adefault\a values; the first valid one is used.]
884 [+?Each test statement generates a portion of a C language header that contains
885 macro defintions, comments, and other text corresponding to the feature
886 tests. \b#ifndef _def_\b\aname\a\b_\b\adirectory\a ...
887 \b#endif\b guards the generated header from multiple \b#include\bs,
888 where \aname\a is determined by either the \brun\b statement input file
889 name if any, or the first \atest\a in the first statement, and \adirectory\a
890 is the basename component of either the \brun\b statement file, if any,
891 or the current working directory. The output file name is determined
892 in this order:]{
893 [+-?If the first command line operand is \b-\b then the output
894 is written to the standard output.]
895 [+--output=\afile\a?Output is \afile\a.]
896 [+set out \afile\a?Output is \afile\a.]
897 [+[run]] [\adirectory\a/]]\abase\a[\a.suffix\a]]?Output is
898 \bFEATURE/\b\abase\a.]
900 [+?Generated \biffe\b headers are often referenced in C source as:
901 \b#include "FEATURE/\b\afile\a". The \bnmake\b(1) base rules contain
902 metarules for generating \bFEATURE/\b\afile\a from
903 \bfeatures/\b\afile\a[\asuffix\a]], where \asuffix\a may be omitted,
904 \b.c\b, or \b.sh\b (see the \brun\b test below). Because
905 \b#include\b prerequisites are automatically detected, \bnmake\b(1)
906 ensures that all prerequisite \biffe\b headers are generated before
907 compilation. Note that the directories are deliberately named
908 \bFEATURE\b and \bfeatures\b to keep case-ignorant file systems
909 happy.]
910 [+?The feature tests are:]{
911 [+# \acomment\a?Comment line - ignored.]
912 [+api \aname\a \aYYYYMMDD\a \asymbol ...\a?Emit api compatibility tests
913 for \aname\a and \b#define\b \asymbol\a \asymbol\a_\aYYYYMMDD\a
914 when \aNAME\a_API is >= \aYYYYMMDD\a (\aNAME\a is \aname\a
915 converted to upper case). If \aNAME\a_API is not defined
916 then \asymbol\a maps to the newest \aYYYYMMDD\a for \aname\a.]
917 [+api \aname1\a = \aname2\a?Set the default \aname1\a api version to
918 the \aname2\a api version.]
919 [+define \aname\a [ (\aarg,...\a) ]] [ \avalue\a ]]?Emit a macro
920 \b#define\b for \aname\a if it is not already defined. The
921 definition is passed to subsequent tests.]
922 [+extern \aname\a \atype\a [ (\aarg,...\a) | [\adimension\a]] ]]?Emit
923 an \bextern\b prototype for \aname\a if one is not already
924 defined. The prototype is passed to subsequent tests.]
925 [+header \aheader\a?Emit \b#include <\b\aheader\a\b>\b if \aheader\a
926 exists. The \b#include\b is passed to subsequent tests.]
927 [+print \atext\a?Copy \atext\a to the output file. \atext\a is passed
928 to subsequent tests.]
929 [+reference \aheader\a?If \aheader\a exists then add \b#include\b
930 \aheader\a to subsequent tests.]
931 [+ver \aname\a \aYYYYMMDD\a?\b#define\b \aNAME\a_VERSION \aYYYYMMDD\a
932 (\aNAME\a is \aname\a converted to upper case).]
933 [+cmd \aname\a?Defines \b_cmd_\b\aname\a if \aname\a is an executable
934 in one of the standard system directories (\b/bin, /etc,
935 /usr/bin, /usr/etc, /usr/ucb\b).
936 \b_\b\adirectory\a\b_\b\aname\a is defined for \adirectory\a
937 in which \aname\a is found (with \b/\b translated to \b_\b).]
938 [+dat \aname\a?Defines \b_dat_\b\aname\a if \aname\a is a data symbol
939 in the default libraries.]
940 [+def \aname\a?Equivalent to \bcmd,dat,hdr,key,lib,mth,sys,typ\b
941 \aname\a.]
942 [+dfn \aname\a?If \aname\a is a macro in the candidate headers then
943 a \b#define\b \aname\a \avalue\a statment is output for the
944 \avalue\a defined in the headers. The definition is \b#ifndef\b
945 guarded.]
946 [+exp \aname\a \aexpression\a?If \aexpression\a is a \"...\" string
947 then \aname\a is defined to be the string, else if the
948 \bexpr\b(1) evaluation of \aexpression\a is not 0 then \aname\a
949 is defined to be 1, otherwise \aname\a is defined to be 0.
950 Identifiers in \aexpression\a may be previously defined names
951 from other \biffe\b tests; undefined names evaluate to 0.
952 If \aname\a was defined in a previous successful test then
953 the current and subsequent \bexp\b test on \aname\a are
954 skipped. If \aname\a is \b-\b then the \aexpression\a is
955 simply evaluated.]
956 [+hdr \aname\a?Defines \b_hdr_\b\aname\a if the header
957 \b<\b\aname\a\b.h>\b exists. The \b--config\b macro name is
958 \bHAVE_\b\aNAME\a\b_H\b.]
959 [+if \astatement\a ... | \belif\b \astatement\a ... | \belse\b | \bendif\b?
960 Nested if-else test control.]
961 [+iff \aname\a?The generated header \b#ifndef-#endif\b macro guard is
962 \b_\b\aname\a\b_H\b.]
963 [+inc \afile\a [ re ]]?Read #define macro names from \afile\a
964 and arrange for those names to evaluate to 1 in \bexp\b
965 expressions. If \are\a is specified then macros not matching
966 \are\a are ignored.]
967 [+key \aname\a?Defines \b_key_\b\aname\a if \aname\a is a reserved
968 word (keyword).]
969 [+lcl \aname\a?Generates a \b#include\b statement for the native version
970 of the header \b<\b\aname\a\b.h>\b if it exists. Defines
971 \b_lcl_\b\aname\a on success. The \b--config\b macro name is
972 \bHAVE_\b\aNAME\a\b_H\b. The default \are\a is \b^HAVE_\b
973 for \b--config\b and \b^_\b otherwise.]
974 [+lib \aname\a?Defines \b_lib_\b\aname\a if \aname\a is an external
975 symbol in the default libraries.]
976 [+mac \aname\a?Defines \b_mac_\b\aname\a if \aname\a is a macro.]
977 [+mem \astruct.member\a?Defines \b_mem_\b\amember\a\b_\b\astruct\a
978 if \amember\a is a member of the structure \astruct\a.]
979 [+mth \aname\a?Defines \b_mth_\b\aname\a if \aname\a is an external
980 symbol in the math library.]
981 [+nop \aname\a?If this is the first test then \aname\a may be used
982 to name the output file and/or the output header guard macro.
983 Otherwise this test is ignored.]
984 [+npt \aname\a?Defines \b_npt_\b\aname\a if the \aname\a symbol
985 requires a prototype. The \b--config\b macro name is
986 \bHAVE_\aNAME\a\b_DECL\b with the opposite sense.]
987 [+num \aname\a?Defines \b_num_\b\aname\a if \aname\a is a numeric
988 constant \aenum\a or \amacro\a.]
989 [+nxt \aname\a?Defines a string macro \b_nxt_\b\aname\a suitable for
990 a \b#include\b statement to include the next (on the include
991 path) or native version of the header \b<\b\aname\a\b.h>\b
992 if it exists. Also defines the \"...\" form
993 \b_nxt_\b\aname\a\b_str\b. The \b--config\b macro name is
994 \bHAVE_\b\aNAME\a\b_NEXT\b.]
995 [+one \aheader\a ...?Generates a \b#include\b statement for the first
996 header found in the \aheader\a list.]
997 [+opt \aname\a?Defines \b_opt_\b\aname\a if \aname\a is a space-separated
998 token in the global environment variable \bPACKAGE_OPTIONS\b.
999 \bopt no\b\a-name\a defines \b_opt_\b\aname\a if \bno\b-\aname\a
1000 is not a space-separated token in the global environment variable
1001 \bPACKAGE_OPTIONS\b.]
1002 [+pth \afile\a [ \adir\a ... | { \ag1\a - ... - \agn\a } | < \apkg\a [\aver\a ...]] > ]]?Defines
1003 \b_pth_\b\afile\a, with embedded \b/\b chars translated to
1004 \b_\b, to the path of the first instance of \afile\a in the
1005 \adir\a directories. \b{\b ... \b}\b forms a directory list
1006 from the cross-product of \b-\b separated directory groups
1007 \ag1\a ... \agn\a. < ... > forms a directory list for the
1008 package \apkg\a with optional versions. If no operands are
1009 specified then the default PATH directories are used. The
1010 \b--config\b macro name is \aNAME\a\b_PATH\b.]
1011 [+run \afile\a?Runs the tests in \afile\a based on the \afile\a
1012 suffix:]{
1013 [+.c?\afile\a is compiled and executed and the output is copied
1014 to the \biffe\b output file. Macros and headers supplied
1015 to \bbegin{\b ... \b}end\b are also supplied to
1016 \afile\a.]
1017 [+.sh?\afile\a is executed as a shell script and the output is
1018 copied to the \biffe\b output file.]
1019 [+.iffe \bor no suffix?\afile\a contains \biffe\b
1020 statements.]
1022 [+set \aoption value\a?Sets option values. The options are described
1023 above.]
1024 [+siz \aname\a?Defines \b_siz_\b\aname\a to be \bsizeof\b(\aname\a) if
1025 \aname\a is a type in any of \b<sys/types.h>, <times.h>,
1026 <stddef.h>, <stdlib.h>\b. Any \b.\b characters in \aname\a are
1027 translated to space before testing and are translated to \b_\b
1028 in the output macro name.]
1029 [+sym \aname\a?Defines \b_ary_\b\aname\a if \aname\a is an array,
1030 \b_fun_\b\aname\a if \aname\a is a function pointer,
1031 \b_ptr_\b\aname\a if \aname\a is a pointer, or
1032 \b_reg_\b\aname\a if \aname\a is a scalar. In most cases
1033 \aname\a is part of a macro expansion.]
1034 [+sys \aname\a?Defines \b_sys_\b\aname\a if the header
1035 \b<sys/\b\aname\a\b.h>\b exists. The \b--config\b macro name is
1036 \bHAVE_SYS_\b\aNAME\a\b_H\b.]
1037 [+tst \aname\a?A user defined test on name. A source block must be
1038 supplied. Defines \b_\b\aname\a on success. \btst - ...\b is
1039 treated as \btst - - ...\b.]
1040 [+typ \aname\a?Defines \b_typ_\b\aname\a if \aname\a is a type in any
1041 of \b<sys/types.h>, <times.h>, <stddef.h>, <stdlib.h>\b. Any
1042 \b.\b characters in \aname\a are translated to space before
1043 testing and are translated to \b_\b in the output macro name.]
1044 [+val \aname\a?The output of \becho\b \aname\a is written to the
1045 output file.]
1046 [+var \aname\a?A user defined test on name. A source block must be
1047 supplied. Sets the \bexp\b variable \b_\b\aname\a on success
1048 but does not define a macro.]
1049 [+(\aexpression\a)?Equivalent to \bexp -\b \aexpression\a.]
1051 [+?Code block names may be prefixed by \bno\b to invert the test sense. Any
1052 block that is eventually executed as a command will have a single
1053 command argument set to a temp file prefix that may be used to
1054 generate temp files for the test. The temp files/dirs are removed
1055 after the block execution. The block names are:]{
1056 [+cat?The block is copied to the output file.]
1057 [+compile?The block is compiled (\bcc -c\b).]
1058 [+cross?The block is executed as a shell script using \bcrossexec\b(1)
1059 if \b--cross\b is on, or on the local host otherwise, and the
1060 output is copied to the output file. Test macros are not
1061 exported to the script.]
1062 [+execute?The block is compiled, linked, and executed. \b0\b exit
1063 status means success.]
1064 [+fail?If the test fails then the block text is evaluated by
1065 \bsh\b(1).]
1066 [+link?The block is compiled and linked (\bcc -o\b).]
1067 [+macro?The block is preprocessed (\bcc -E\b) and lines containing
1068 text bracketed by \b<<"\b ... \b">>\b (\aless-than less-than
1069 double-quote ... double-quote greater-than greater-than\a)
1070 are copied to the output file with the brackets omitted.]
1071 [+no?If the test fails then the block text is copied to the
1072 output file. Deprecated: use { \bif\b \belif\b \belse\b
1073 \bendif\b } with unnamed \b{\b ... \b}\b blocks.]
1074 [+note?If the test succeeds then the block is copied to the output
1075 as a \b/*\b ... \b*/\b comment.]
1076 [+output?The block is compiled, linked, and executed, and the output
1077 is copied to the output file.]
1078 [+pass?If the test succeeds then the block text is evaluated by
1079 \bsh\b(1).]
1080 [+preprocess?The block is preprocessed (\bcc -E\b).]
1081 [+run?The block is executed as a shell script and the output is
1082 copied to the output file. Succesful test macros are also
1083 defined as shell variables with value \b1\b and are available
1084 within the block. Likewise, failed test macros are defined
1085 as shell variables with value \b0\b.]
1086 [+status?The block is compiled, linked, and executed, and the exit
1087 status is the test outcome, 0 for \afailure\a, the value
1088 otherwise.]
1089 [+yes?If the test succeeds then the block text is copied to the output
1090 file. \byes{\b ... \b}end\b is equivalent to the unnamed block
1091 \b{\b ... \b}\b. Deprecated: use { \bif\b \belif\b \belse\b
1092 \bendif\b } with unnamed \b{\b ... \b}\b blocks.]
1094 [+SEE ALSO?\bautoconf\b(1), \bconfig\b(1), \bgetconf\b(1), \bcrossexec\b(1),
1095 \bnmake\b(1), \bpackage\b(1), \bproto\b(1), \bsh\b(1)]
1097 while getopts -a "$command" "$USAGE" OPT
1098 do case $OPT in
1099 a) set="$set set all :" ;;
1100 c) set="$set set cc $OPTARG :" ;;
1101 C) set="$set set config :" ;;
1102 d) set="$set set debug $OPTARG :" ;;
1103 D) set="$set set define :" ;;
1104 E) set="$set set explicit :" ;;
1105 F) set="$set set features $OPTARG :" ;;
1106 i) set="$set set input $OPTARG :" ;;
1107 I) set="$set set include $OPTARG :" ;;
1108 L) set="$set set library $OPTARG :" ;;
1109 n) set="$set set namval $OPTARG :" ;;
1110 N) set="$set set nooptimize $OPTARG :" ;;
1111 o) set="$set set output $OPTARG :" ;;
1112 e) set="$set set package $OPTARG :" ;;
1113 p) set="$set set prototyped :" ;;
1114 P) set="$set set pragma $OPTARG :" ;;
1115 r) set="$set set regress :" ;;
1116 s) set="$set set shell $OPTARG :" ;;
1117 S) set="$set set static $OPTARG :" ;;
1118 O) set="$set set stdio $OPTARG :" ;;
1119 u) set="$set set undef :" ;;
1120 v) set="$set set verbose :" ;;
1121 x) set="$set set cross $OPTARG :" ;;
1122 X) set="$set set exclude $OPTARG :" ;;
1123 esac
1124 done
1125 shift `expr $OPTIND - 1`
1127 *) while :
1128 do case $# in
1129 0) break ;;
1130 esac
1131 case $1 in
1132 -) break
1134 --) shift
1135 break
1137 --a|--al|--all)
1138 REM=a
1140 --cc=*) REM=c`echo X$1 | sed 's,[^=]*=,,'`
1142 --co|--con|--conf|--confi|--config)
1143 REM=C
1145 --cr=*|--cro=*|--cros=*|--cross=*)
1146 REM=x`echo X$1 | sed -e 's,[^=]*=,,'`
1148 --d=*|--de=*|--deb=*|--debu=*|--debug=*)
1149 REM=d`echo X$1 | sed 's,[^=]*=,,'`
1151 --def|--defi|--defin|--define)
1152 REM=D
1154 --e=*|--ex=*|--exc=*|--excl=*|--exclu=*|--exclud=*|--exclude=*)
1155 REM=X`echo X$1 | sed 's,[^=]*=,,'`
1157 --e|--ex|--exp|--expl|--expli|--explic|--explici|--explicit)
1158 REM=E
1160 --f=*|--fe=*|--fea=*|--feat=*|--featu=*|--featur=*|--feature=*|--features=*)
1161 REM=F`echo X$1 | sed 's,[^=]*=,,'`
1163 --inp=*|--inpu=*|--input=*)
1164 REM=i`echo X$1 | sed 's,[^=]*=,,'`
1166 --inc=*|--incl=*|--inclu=*|--includ=*|--include=*)
1167 REM=I`echo X$1 | sed 's,[^=]*=,,'`
1169 --l=*|--li=*|--lib=*|--libr=*|--libra=*|--librar=*|--library=*)
1170 REM=L`echo X$1 | sed 's,[^=]*=,,'`
1172 --n|--na|--nam|--name|--name-v|--name-va|--name-val|--name-valu|--name-value)
1173 REM=n
1175 --o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*)
1176 REM=o`echo X$1 | sed 's,[^=]*=,,'`
1178 --pa=*|--pac=*|--pack=*|--packa=*|--packag=*|--package=*)
1179 REM=e`echo X$1 | sed 's,[^=]*=,,'`
1181 --pro|--prot|--proto|--protot|--prototy|--prototyp|--prototype|--prototyped)
1182 REM=p
1184 --pra=*|--prag=*|--pragma=*)
1185 REM=P`echo X$1 | sed 's,[^=]*=,,'`
1187 --r|--re|--reg|--regre|--regres|--regress)
1188 REM=r
1190 --sh=*|--she=*|--shel=*|--shell=*)
1191 REM=s`echo X$1 | sed 's,[^=]*=,,'`
1193 --sta=*|--stat=*|--stati=*|--static=*)
1194 REM=S`echo X$1 | sed 's,[^=]*=,,'`
1196 --std=*|--stdi=*|--stdio=*)
1197 REM=O`echo X$1 | sed 's,[^=]*=,,'`
1199 --u|--un|--und|--unde|--undef)
1200 REM=u
1202 --v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
1203 REM=v
1205 --*) echo $command: $1: unknown option >&2
1206 exit 2
1208 -*) REM=`echo X$1 | sed 's,X-,,'`
1210 *) break
1212 esac
1213 shift
1214 while :
1215 do case $REM in
1216 '') break ;;
1217 esac
1218 eval `echo $REM | sed "s,\(.\)\(.*\),OPT='\1' REM='\2',"`
1219 case $OPT in
1220 [cdFiILoOePsSxX])
1221 case $REM in
1222 '') case $# in
1223 0) echo $command: -$OPT: option argument expected >&2
1224 exit 1
1226 esac
1227 OPTARG=$1
1228 shift
1230 *) OPTARG=$REM
1231 REM=''
1233 esac
1234 esac
1235 case $OPT in
1236 a) set="$set set all :" ;;
1237 c) set="$set set cc $OPTARG :" ;;
1238 C) set="$set set config :" ;;
1239 d) set="$set set debug $OPTARG :" ;;
1240 D) set="$set set define :" ;;
1241 E) set="$set set explicit :" ;;
1242 F) set="$set set features $OPTARG :" ;;
1243 i) set="$set set input $OPTARG :" ;;
1244 I) set="$set set include $OPTARG :" ;;
1245 L) set="$set set library $OPTARG :" ;;
1246 n) set="$set set namval $OPTARG :" ;;
1247 N) set="$set set nooptimize $OPTARG :" ;;
1248 o) set="$set set output $OPTARG :" ;;
1249 e) set="$set set package $OPTARG :" ;;
1250 p) set="$set set prototyped :" ;;
1251 P) set="$set set pragma $OPTARG :" ;;
1252 r) set="$set set regress :" ;;
1253 s) set="$set set shell $OPTARG :" ;;
1254 S) set="$set set static $OPTARG :" ;;
1255 O) set="$set set stdio $OPTARG :" ;;
1256 u) set="$set set undef :" ;;
1257 v) set="$set set verbose :" ;;
1258 x) set="$set set cross $OPTARG :" ;;
1259 X) set="$set set exclude $OPTARG :" ;;
1260 *) echo "Usage: $command [-aCDEnpruv] [-c C-compiler-name [C-compiler-flags ...]] [-d level]
1261 [-F features-header] [-i file] [-o file] [-O stdio-header] [-e name] [-P text]
1262 [-s shell-path] [-S[flags]] [-x cross-exec-prefix] [-I dir] [-L dir] [-X dir] [ - ]
1263 [ file.iffe | statement [ : statement ... ] ]" >&2
1264 exit 2
1266 esac
1267 done
1268 done
1270 esac
1271 case $1 in
1272 -) out=-; shift ;;
1273 esac
1274 case $# in
1275 0) in=- ;;
1276 esac
1277 set -- $set "$@"
1278 case " $* " in
1279 *' set config '*|*' run config.'*|*' run '*' config.'*|*' run '*'/config.'*)
1280 config=1
1282 esac
1284 # standard error to /dev/null unless debugging
1285 # standard output to the current output file
1287 # stdout original standard output
1288 # stderr original standard error
1289 # nullin /dev/null input
1290 # nullout /dev/null output
1292 stdout=5 stderr=6 nullin=7 nullout=8
1293 eval "exec $nullin</dev/null $nullout>/dev/null $stdout>&1 $stderr>&2"
1294 case " $* " in
1295 *" set debug "[3456789]*)
1297 *) eval "exec 2>&$nullout"
1299 esac
1301 # prompt complications
1303 case `print -n aha </dev/null 2>/dev/null` in
1304 aha) show='print -n' SHOW='' ;;
1305 *) case `echo -n aha 2>/dev/null` in
1306 -n*) show=echo SHOW='\c' ;;
1307 *) show='echo -n' SHOW='' ;;
1308 esac
1310 esac
1312 # tmp files cleaned up on exit
1313 # status: 0:success 1:failure 2:interrupt
1315 status=1
1316 case $debug in
1317 2) core=
1319 *) if (ulimit -c 0) >/dev/null 2>&1
1320 then ulimit -c 0
1321 core=
1322 else core="core core.??*"
1325 esac
1326 trap "rm -rf $core $tmp*" 0
1327 if (:>$tmp.c) 2>/dev/null
1328 then rm -f $tmp.c
1329 else echo "$command: cannot create tmp files in current dir" >&2
1330 exit 1
1332 status=2
1334 # standard header for c source
1336 std='#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
1337 #define _STD_ 1
1338 #define _ARG_(x) x
1339 #define _VOID_ void
1340 #else
1341 #define _STD_ 0
1342 #define _ARG_(x) ()
1343 #define _VOID_ char
1344 #endif
1345 #if defined(__cplusplus)
1346 #define _BEGIN_EXTERNS_ extern "C" {
1347 #define _END_EXTERNS_ }
1348 #else
1349 #define _BEGIN_EXTERNS_
1350 #define _END_EXTERNS_
1351 #endif
1352 #define _NIL_(x) ((x)0)'
1353 tst=
1354 ext="#include <stdio.h>"
1355 noext='*[<"][Ss][Tt][Dd][Ii][Oo].[Hh][">]*|*<ast.h>*|*<sfio.h>*|*/[*]<NOSTDIO>[*]/*'
1357 # loop on op [ arg [ ... ] ] [ : op [ arg [ ... ] ] ]
1359 argx=0
1360 cur=.
1361 can=
1362 cansep=
1363 cctest=
1364 file=
1365 hdrtest=
1366 ifelse=NONE
1367 ifstack=
1368 ini=
1369 init=1
1370 line=0
1371 nan=
1372 prototyped=
1373 while :
1374 do case $in in
1375 "") case $argx:$* in
1376 1:$argv);;
1377 1:*) argx=0
1378 set x $argv
1379 shift
1381 esac
1383 *) case $ini in
1384 '') if read lin
1385 then case $shell in
1386 ksh) let line=line+1 ;;
1387 *) line=`expr $line + 1` ;;
1388 esac
1389 $posix_noglob
1390 set x $lin
1391 $posix_glob
1392 case $# in
1393 1) continue ;;
1394 esac
1395 else set x
1398 *) $posix_noglob
1399 set x $ini
1400 $posix_glob
1401 ini=
1403 esac
1404 shift
1405 case $init in
1406 1) case $1 in
1407 iff) init=0
1409 print|ref|set)
1411 *) init=0
1412 ini=$*
1413 set ini
1415 esac
1416 esac
1418 esac
1419 case $# in
1420 0) case $ifstack in
1421 ?*) echo "$command: $file$line: missing endif" >&$stderr
1422 exit 1
1424 esac
1425 set set out +
1427 esac
1429 # if nesting
1431 while :
1432 do case $1 in
1433 "if") ifstack="$ifelse:$ifstack"
1434 case $ifelse in
1435 KEEP|NONE)
1436 ifelse=TEST
1438 TEST) ;;
1439 *) ifelse=DONE
1441 esac
1442 shift
1443 case $explicit in
1444 1) set '' - "$@"; shift ;;
1445 esac
1447 "elif") case $ifelse in
1448 SKIP) ifelse=TEST
1450 TEST) ;;
1451 *) ifelse=DONE
1453 NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
1454 exit 1
1456 esac
1457 shift
1458 case $explicit in
1459 1) set '' - "$@"; shift ;;
1460 esac
1462 "else") case $ifelse in
1463 KEEP) ifelse=DONE
1465 SKIP|TEST)
1466 ifelse=KEEP
1468 NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
1469 exit 1
1471 esac
1472 shift
1474 "endif")case $ifelse in
1475 NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
1476 exit 1
1478 esac
1479 case $shell in
1480 ksh) ifelse=${ifstack%%:*}
1481 ifstack=${ifstack#*:}
1483 *) eval `echo $ifstack | sed 's,\([^:]*\):\(.*\),ifelse=\1 ifstack=\2,'`
1485 esac
1486 shift
1488 *) break
1490 esac
1491 done
1493 # check if "run xxx" is equivalent to "set in xxx"
1495 case $1 in
1496 "("*) set exp - "$@" ;;
1497 *.iffe|*.iff) set run "$@" ;;
1498 esac
1499 case $1 in
1500 :) shift
1501 continue
1503 run) case $shell in
1504 bsh) case $2 in
1505 */*) x=`echo $2 | sed 's,.*[\\\\/],,'` ;;
1506 *) x=$2 ;;
1507 esac
1509 *) eval 'x=${2##*[\\/]}'
1511 esac
1512 case $x in
1513 *.iffe|*.iff)
1514 set set in $2 ;;
1515 *.*) ;;
1516 *) set set in $2 ;;
1517 esac
1519 esac
1521 # { inc set } drop out early
1523 case $1 in
1524 ""|"#"*)continue
1526 inc) case $ifelse in
1527 DONE|SKIP) set ''; shift; continue ;;
1528 esac
1529 shift
1530 case $# in
1531 0) echo "$command: $file$line: path expected" >&$stderr
1532 exit 1
1534 esac
1535 p=$1
1536 shift
1537 if test ! -f $p
1538 then echo "$command: $file$line: $p: file not found" >&$stderr
1539 exit 1
1541 case $# in
1542 0) case $config in
1543 1) e="^HAVE_" ;;
1544 *) e="^_" ;;
1545 esac
1547 1) e=$1
1549 *) shift
1550 echo "$command: $file$line: warning: $*: operands ignored" >&$stderr
1552 esac
1553 eval `sed -e '/^#define[ ]/!d' -e 's/#define[ ]//' -e 's/[ (].*//' ${e:+"-e/$e/!d"} -e 's/.*/&=1/' $p | LC_ALL=C sort -u`
1554 continue
1556 set) case $ifelse in
1557 DONE|SKIP) set ''; shift; continue ;;
1558 esac
1559 shift
1560 case $1 in
1561 ""|"#"*)op=
1563 *) arg=
1564 op=$1
1565 case $op in
1566 --*) case $shell in
1567 bsh) op=`echo X$op | sed 's/X--//'` ;;
1568 *) op=${op#--} ;;
1569 esac
1571 -*) case $op in
1572 -??*) case $shell in
1573 bsh) arg=`echo X$op | sed 's/X-.//'`
1574 op=`echo X$op | sed 's/X\\(-.\\).*/\\1/'`
1576 *) arg=${op#-?}
1577 op=${op%$arg}
1579 esac
1581 esac
1582 case $op in
1583 a) op=all ;;
1584 c) op=cc ;;
1585 C) op=config ;;
1586 d) op=debug ;;
1587 D) op=define ;;
1588 E) op=explicit ;;
1589 F) op=features ;;
1590 i) op=input ;;
1591 I) op=include ;;
1592 L) op=library ;;
1593 n) op=namval ;;
1594 N) op=nooptimize ;;
1595 o) op=output ;;
1596 e) op=package ;;
1597 p) op=prototyped ;;
1598 P) op=pragma ;;
1599 r) op=regress ;;
1600 s) op=shell ;;
1601 S) op=static ;;
1602 O) op=stdio ;;
1603 u) op=undef ;;
1604 v) op=verbose ;;
1605 x) op=cross ;;
1606 X) op=exclude ;;
1607 esac
1609 esac
1610 shift
1611 while :
1612 do case $# in
1613 0) break ;;
1614 esac
1615 case $1 in
1616 *" "*) shift
1617 continue
1619 ""|"#"*)break
1621 :) shift
1622 break
1624 esac
1625 case $arg in
1626 "") arg=$1 ;;
1627 *) arg="$arg $1" ;;
1628 esac
1629 shift
1630 done
1632 esac
1633 case $op in
1634 all) all=1
1635 continue
1637 cc) occ=
1638 for x in $arg
1639 do case $occ in
1640 "") case $x in
1641 *=*) case $shell in
1642 bsh) eval $x
1643 export `echo $x | sed 's/=.*//'`
1645 *) export $x
1647 esac
1649 -O*) case $optimize in
1650 1) occ=$x ;;
1651 esac
1653 *) occ=$x
1655 esac
1657 *) occ="$occ $x"
1659 esac
1660 done
1661 exclude occ
1662 continue
1664 config) config=1
1665 continue
1667 cross) case $arg in
1668 ""|-) cross= ;;
1669 *) cross="$arg" libpaths= ;;
1670 esac
1671 continue
1673 debug) debug=$arg
1674 case $arg in
1675 0) exec 2>&$nullout
1676 set -
1677 show=echo
1678 SHOW=
1680 ""|1) exec 2>&$stderr
1681 set -
1682 show=echo
1683 SHOW=
1685 2|3) exec 2>&$stderr
1686 case $shell in
1687 ksh) eval 'PS4="${PS4%+*([ ])}+\$LINENO+ "'
1688 esac
1689 show=echo
1690 SHOW=
1691 set -x
1693 *) echo "$command: $arg: debug levels are 0, 1, 2, 3" >&$stderr
1695 esac
1696 continue
1698 define) define=1
1699 continue
1701 exclude)case $arg in
1702 ""|-) excludes= ;;
1703 *) excludes="$excludes $arg" ;;
1704 esac
1705 exclude includes occ
1706 continue
1708 explicit)
1709 explicit=1
1710 continue
1712 features)case $arg in
1713 '') tst= ;;
1714 *) tst="#include \"$arg\"" ;;
1715 esac
1716 continue
1718 "in"|input)
1719 case $arg in
1720 "") in=-
1722 *) in=$arg
1723 if test ! -r $in
1724 then echo "$command: $in: not found" >&$stderr
1725 exit 1
1727 exec < $in
1728 file=$in:
1729 case $out in
1730 "") case $in in
1731 *[.\\/]*)
1732 case $shell in
1733 bsh) eval `echo $in | sed -e 's,.*[\\\\/],,' -e 's/\\.[^.]*//' -e 's/^/out=/'`
1735 *) eval 'out=${in##*[\\/]}'
1736 eval 'out=${out%.*}'
1738 esac
1740 *) out=$in
1742 esac
1744 esac
1746 esac
1747 continue
1749 include)case $arg in
1750 ""|-) includes= ;;
1751 *) includes="$includes -I$arg" ;;
1752 esac
1753 exclude includes
1754 continue
1756 library)for y in $libpaths
1757 do eval $y=\"\$$y:\$arg\$${y}_default\"
1758 eval export $y
1759 done
1760 continue
1762 namval) define=n
1763 continue
1765 nodebug)exec 2>&$nullout
1766 set -
1767 continue
1769 nodefine)
1770 define=0
1771 continue
1773 nooptimize)
1774 optimize=0
1775 case $occ in
1776 *" -O"*)occ=`echo $occ | sed 's/ -O[^ ]*//g'`
1777 cc=$occ
1779 esac
1781 optimize)
1782 optimize=1
1784 out|output)
1785 out=$arg
1786 defhdr=
1787 usr=
1788 deflib=
1789 one=
1790 puthdr=
1791 putlib=
1792 case $op in
1793 output) continue ;;
1794 esac
1795 def=
1796 test=
1798 package)protoflags="$protoflags -e $arg"
1799 continue
1801 prototyped|noprototyped)
1802 pragma="$pragma $op"
1803 case $op in
1804 prototyped) prototyped=1 ;;
1805 *) prototyped= ;;
1806 esac
1807 continue
1809 pragma) pragma="$pragma $arg"
1810 continue
1812 regress)regress=1
1813 version=1995-03-19
1814 continue
1816 shell) case $arg in
1817 osh) posix_read=-no
1818 shell=bsh
1820 esac
1821 shell=$arg
1822 continue
1824 static) static=$arg
1825 continue
1827 stdio) case $arg in
1828 '') ext=
1830 *) ext=
1831 sep=
1832 for i in $arg
1833 do case $i in
1834 -) case $ext in
1835 '') continue ;;
1836 *) break ;;
1837 esac
1839 esac
1840 echo "#include \"$i\"" > t.c
1841 if $cc -E t.c > /dev/null 2>&1
1842 then ext="$ext$sep#include \"$arg\""
1843 sep=$nl
1845 done
1847 esac
1848 continue
1850 undef) undef=1
1851 continue
1853 verbose)verbose=1
1854 continue
1856 *) echo "$command: $op: unknown option" >&$stderr
1857 exit 1
1859 esac
1861 api|define|extern|header|include|print|reference|ver)
1862 op=$1
1863 shift
1864 arg=
1866 *) case $2 in
1867 '=') def=$1
1868 shift
1869 shift
1871 *) case $1 in
1872 '-'|'?')def=-
1873 shift
1875 *) def=
1877 esac
1879 esac
1880 case $1 in
1881 '!') not=1
1882 shift
1884 *) not=
1886 esac
1887 case $1 in
1888 *'{') op=-
1890 '('*|'"'*'"'|'<'*'>')
1891 op=exp
1892 case $def in
1893 '') def=- ;;
1894 esac
1896 *) op=$1
1897 shift
1899 esac
1900 arg=
1901 cc="$occ $includes"
1902 group=
1903 groups=
1904 fail=
1905 hdr=
1906 lib=
1907 mac=
1909 note=
1910 opt=
1911 pass=
1912 pth=
1913 run=
1914 set=
1915 src=
1916 test=
1917 yes=
1918 case $# in
1919 0) ;;
1920 *) case $1 in
1921 "#"*) set x
1922 shift
1924 *) case $op in
1925 ref) ;;
1926 *) case $1 in
1927 '-') case $op:$2 in
1928 tst:*) arg=$1
1929 case $2 in
1930 -) shift ;;
1931 esac
1933 *:-*) arg=$1
1934 shift
1936 *) def=-
1937 shift
1938 case $1 in
1939 '('*|*'{'|'"'*'"'|'<'*'>')
1940 arg=-
1942 *) arg=$1
1943 case $# in
1944 0) ;;
1945 *) shift ;;
1946 esac
1948 esac
1950 esac
1952 -*|+*|'('*|*'{'|'"'*'"'|'<'*'>')
1953 arg=-
1955 *) arg=$1
1956 shift
1958 esac
1960 esac
1962 esac
1963 case $1 in
1964 '('*|'"'*'"'|'<'*'>')
1965 while :
1966 do case $# in
1967 0) break ;;
1968 esac
1969 case $1 in
1970 *[.{}]*)break ;;
1971 esac
1972 case $test in
1973 '') test=$1 ;;
1974 *) test="$test $1" ;;
1975 esac
1976 shift
1977 done
1978 case $arg in
1979 '') arg=- ;;
1980 esac
1981 case $op in
1982 exp) case $def in
1983 ''|'-') ;;
1984 *) arg=$def ;;
1985 esac
1987 esac
1989 esac
1990 sline=$line
1991 while :
1992 do case $# in
1993 0) break ;;
1994 esac
1995 case $1 in
1996 "") ;;
1997 "#"*) set x
1999 "=") shift
2000 set=$*
2001 case $set in
2002 "") set=" " ;;
2003 esac
2004 while :
2005 do case $# in
2006 0) break ;;
2007 esac
2008 shift
2009 done
2010 break
2012 [abcdefghijklmnopqrstuvwxyz]*'{'|'{')
2013 v=$1
2014 shift
2016 case $v in
2017 "note{")
2018 sep=" " ;;
2019 *) sep=$nl ;;
2020 esac
2021 case $v in
2022 '{') e='}' ;;
2023 *) e='}end' ;;
2024 esac
2026 SEP=
2027 while :
2028 do case $# in
2029 0) case $posix_read in
2030 -*) checkread ;;
2031 esac
2032 case $in in
2033 "") echo "$command: $file$line: missing }end" >&$stderr
2034 exit 1
2036 esac
2037 while :
2038 do case $posix_read in
2039 1) case $shell in
2040 ksh) IFS= read -r lin
2041 eof=$?
2042 while :
2043 do lin="${lin#[' ']}"
2044 case $lin in
2045 [' ']*'#'*);;
2046 *) break ;;
2047 esac
2048 done
2050 *) IFS=
2051 read -r lin
2052 eof=$?
2053 IFS=$ifs
2054 case $lin in
2055 [' ']*) lin=`sed -e 's,^[ ],,' -e 's,^[ ]*#,#,' <<!
2056 $lin
2060 esac
2062 esac
2064 *) lin=`$posix_read`
2065 eof=$?
2067 esac
2068 case $eof in
2069 0) case $shell in
2070 ksh) let line=line+1 ;;
2071 *) line=`expr $line + 1` ;;
2072 esac
2073 $posix_noglob
2074 set x $lin
2075 $posix_glob
2076 case $2 in
2077 $v) case $shell in
2078 ksh) let n=n+1 ;;
2079 *) n=`expr $n + 1` ;;
2080 esac
2082 $e|$e';')
2083 case $n in
2084 1) shift
2085 break 2
2087 esac
2088 case $shell in
2089 ksh) let n=n-1 ;;
2090 *) n=`expr $n - 1` ;;
2091 esac
2093 esac
2094 x="$x$SEP$lin"
2095 SEP=$sep
2097 *) echo "$command: $file$line: missing $e" >&$stderr
2098 exit 1
2100 esac
2101 done
2103 esac
2104 case $1 in
2105 $v) case $shell in
2106 ksh) let n=n+1 ;;
2107 *) n=`expr $n + 1` ;;
2108 esac
2110 $e|$e';')
2111 case $n in
2112 1) break ;;
2113 esac
2114 case $shell in
2115 ksh) let n=n-1 ;;
2116 *) n=`expr $n - 1` ;;
2117 esac
2119 esac
2120 x="$x$SEP$1"
2121 SEP=$sep
2122 shift
2123 done
2124 case $v in
2125 'note{');;
2126 *) x="$x$nl" # \r\n bash needs this barf # ;;
2127 esac
2128 case $v in
2129 'fail{') fail=$x ;;
2130 'nofail{') pass=$x v='pass{' ;;
2131 'nopass{') fail=$x v='fail{' ;;
2132 'no{') no=$x ;;
2133 'note{') note=$x ;;
2134 'pass{') pass=$x ;;
2135 'test{') test=$x ;;
2136 'yes{'|'{') yes=$x ;;
2137 *) src=$x run=$v ;;
2138 esac
2140 :) shift
2141 break
2143 *[\"\'\(\)\{\}\ \ ]*)
2144 case $op in
2145 pth) pth="$pth $1"
2147 *) case $test in
2148 '') test=$1 ;;
2149 *) test="$test $1" ;;
2150 esac
2152 esac
2154 -) group=$group$1
2155 case $group in
2156 -) com_hdr=$hdr
2157 com_lib=$lib
2158 com_mac=$mac
2159 com_opt=$opt
2160 com_pth=$pth
2161 com_test=$test
2163 *) groups="$groups $1"
2165 esac
2167 -l*) case $group in
2168 --*) groups="$groups $1" ;;
2169 *) lib="$lib $1" ;;
2170 esac
2172 +l*) case $shell in
2173 bsh) x=`echo X$1 | sed 's/X+/-/'` ;;
2174 *) eval 'x=-${1#+}' ;;
2175 esac
2176 case $group in
2177 --*) groups="$groups $x" ;;
2178 *) lib="$lib $x" ;;
2179 esac
2181 -*|+*) case $op in
2182 ref) cc="$cc $1"
2183 occ="$occ $1"
2184 case $1 in
2185 -L*) case $shell in
2186 ksh) x=${1#-L} ;;
2187 *) x=`echo x$1 | sed 's,^x-L,,'` ;;
2188 esac
2189 for y in $libpaths
2190 do eval $y=\"\$$y:\$x\$${y}_default\"
2191 eval export $y
2192 done
2194 esac
2196 *) case $group in
2197 --*) groups="$groups $1"
2199 *) case $op in
2200 run) opt="$opt $1"
2202 *) case $1 in
2203 -D*) mac="$mac $1" ;;
2204 *) cc="$cc $1" ;;
2205 esac
2207 esac
2209 esac
2211 esac
2213 *.[aAxX]|*.[dD][lL][lL]|*.[lL][iI][bB])
2214 case $group in
2215 --*) groups="$groups $1" ;;
2216 *) lib="$lib $1" ;;
2217 esac
2219 *[.\\/]*)
2220 case $group in
2221 --*) groups="$groups $1"
2223 *) case $op in
2224 pth) pth="$pth $1" ;;
2225 *) hdr="$hdr $1" ;;
2226 esac
2228 esac
2230 *) case $group in
2231 --*) groups="$groups $1"
2233 *) case $op in
2234 pth) pth="$pth $1"
2236 *) case $test in
2237 '') test=$1 ;;
2238 *) test="$test $1" ;;
2239 esac
2241 esac
2243 esac
2245 esac
2246 shift
2247 done
2248 case $group in
2249 -) group= ;;
2250 esac
2252 esac
2254 esac
2255 case $ifelse in
2256 DONE|SKIP) continue ;;
2257 esac
2259 # make sure $cc compiles C
2261 case $cc in
2262 "") cc="$occ $includes" ;;
2263 esac
2264 case $cctest in
2265 "") checkcc ;;
2266 esac
2268 # some ops allow no args
2270 case $arg in
2271 '') case $op in
2272 api) arg=-
2273 case $1:$2:$3 in
2274 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]:*)
2275 a=$1
2276 shift
2277 case " $apis " in
2278 *" $a "*)
2280 *) apis="$apis $a"
2281 eval api_sym_${a}= api_ver_${a}=
2283 esac
2284 rel=
2285 while :
2286 do case $# in
2287 0) break ;;
2288 esac
2289 case $1 in
2290 [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
2291 rel="$rel $1"
2293 *) break
2295 esac
2296 shift
2297 done
2298 while :
2299 do case $# in
2300 0) break ;;
2301 esac
2302 case $1 in
2303 :) break ;;
2304 esac
2305 eval syms='$'api_sym_${a}
2306 case $syms in
2307 '') sep='' ;;
2308 *) sep=$nl ;;
2309 esac
2310 for r in $rel
2311 do syms=$syms$sep${1}:${r}
2312 sep=$nl
2313 done
2314 eval api_sym_${a}='$'syms
2315 shift
2316 done
2318 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*:=:[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
2319 apisame="$apisame $1 $3"
2321 *) echo "$command: $op: expected: name YYYYMMDD symbol ..." >&$stderr
2323 esac
2324 while :
2325 do case $# in
2326 0) break ;;
2327 esac
2328 case $1 in
2329 :) break ;;
2330 esac
2331 shift
2332 done
2334 iff|ini)arg=-
2336 comment)copy - "/* $* */"
2337 continue
2339 define) x=$1
2340 shift
2341 case $1 in
2342 '('*')')
2343 arg=$1
2344 shift
2346 esac
2347 case $in in
2348 "") v=
2349 while :
2350 do case $# in
2351 0) break ;;
2352 esac
2353 t=$1
2354 shift
2355 case $t in
2356 ":") break ;;
2357 esac
2358 v="$v $t"
2359 done
2361 *) v=$*
2363 esac
2364 is mac $x
2365 copy $tmp.c "$std
2366 $usr
2367 #ifndef $x
2369 #endif
2370 int x;
2372 if compile $cc -c $tmp.c <&$nullin >&$nullout
2373 then success -
2374 else failure -
2375 copy - "#define $x$arg $v"
2376 usr="$usr${nl}#define $x$arg $v"
2378 continue
2380 extern) x=$1
2381 shift
2382 t=$1
2383 shift
2384 is npt $x
2385 copy $tmp.c "
2386 $std
2387 #include <sys/types.h>
2388 $usr
2389 _BEGIN_EXTERNS_
2390 struct _iffe_struct { int _iffe_member; };
2391 extern struct _iffe_struct* $x _ARG_((struct _iffe_struct*));
2392 _END_EXTERNS_
2394 # some compilers with -O only warn for invalid intrinsic prototypes
2395 case " $cc " in
2396 *" -O "*) xx=`echo $cc | sed 's/ -O / /g'` ;;
2397 *) xx=$cc ;;
2398 esac
2399 if compile $xx -c $tmp.c <&$nullin >&$nullout
2400 then success -
2401 while :
2402 do case $1 in
2403 ''|'('*|'['*)
2404 break
2406 esac
2407 t="$t $1"
2408 shift
2409 done
2410 case $in in
2411 "") v=
2412 while :
2413 do case $# in
2414 0) break ;;
2415 esac
2416 t=$1
2417 shift
2418 case $t in
2419 ":") break ;;
2420 esac
2421 v="$v $t"
2422 done
2424 *) v=$*
2426 esac
2427 copy - "extern $t $x$v;"
2428 # NOTE: technically if prototyped is on all tests should
2429 # be run through proto(1), but we'd like iffe to
2430 # work sans proto -- so we drop the extern's in
2431 # the test headers
2432 case $prototyped in
2433 '') usr="$usr${nl}extern $t $x$v;" ;;
2434 esac
2435 else failure -
2436 case $in in
2437 "") while :
2438 do case $# in
2439 0) break ;;
2440 esac
2441 case $1 in
2442 ":") break ;;
2443 esac
2444 done
2446 esac
2448 continue
2450 header|include|reference)
2451 while :
2452 do case $# in
2453 0) break ;;
2454 esac
2455 x=$1
2456 shift
2457 case $x in
2458 ":") break ;;
2459 esac
2460 case " $gothdr " in
2461 *" - $x "*)
2463 *" + $x "*)
2464 case $usr in
2465 *"# include <"$x">"*)
2467 *) case $op in
2468 reference)
2470 *) copy - "#include <$x>"
2472 esac
2473 usr="$usr${nl}#include <$x>"
2475 esac
2477 *) copy $tmp.c "$std
2478 $usr
2479 #include <$x>
2480 int x;
2482 if is_hdr - $x
2483 then gothdr="$gothdr + $x"
2484 case $op in
2485 reference)
2487 *) copy - "#include <$x>"
2489 esac
2490 usr="$usr${nl}#include <$x>"
2491 else gothdr="$gothdr - $x"
2494 esac
2495 done
2496 continue
2498 print) case $in in
2499 "") v=
2500 while :
2501 do case $# in
2502 0) break ;;
2503 esac
2504 t=$1
2505 shift
2506 case $t in
2507 ":") break ;;
2508 esac
2509 v="$v $t"
2510 done
2512 *) v=$*
2514 esac
2515 copy - "$*"
2516 usr="$usr${nl}$v"
2517 continue
2519 ver) arg=-
2520 case $1:$2 in
2521 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
2522 vers="$vers$nl$1"
2523 eval ver_$1=$2
2525 *) echo "$command: $op: expected: name YYYYMMDD" >&$stderr
2527 esac
2528 while :
2529 do case $# in
2530 0) break ;;
2531 esac
2532 case $1 in
2533 :) break ;;
2534 esac
2535 shift
2536 done
2538 esac
2540 esac
2542 # NOTE() support
2544 case $ext in
2545 *"<stdio.h>"*)
2546 case $ext in
2547 *"#define NOTE("*)
2549 *) ext="$ext
2550 #define NOTE(s) do{write(9,\" \",1);write(9,s,strlen(s));write(9,\" ...\",4);}while(0)"
2552 esac
2554 esac
2556 # save $* for ancient shells
2558 argx=1
2559 argv=$*
2561 # loop on all candidate groups
2563 while :
2565 # check the candidate macros
2567 cc="$cc $mac"
2569 # check for global default headers (some cc -E insist on compiling)
2571 case $hdrtest in
2572 '') hdrtest=1
2573 allinc=
2574 for x in types
2575 do case $config in
2576 0) c=_sys_${x}
2578 1) case $shell in
2579 ksh) typeset -u u=$x ;;
2580 *) u=`echo $x | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
2581 esac
2582 c=HAVE_SYS_${u}_H
2584 esac
2585 x=sys/$x.h
2586 echo "${allinc}#include <$x>" > $tmp.c
2587 if is_hdr $x
2588 then gothdr="$gothdr + $x"
2589 case $explicit in
2590 0) can="$can$cansep#define $c 1 /* #include <$x> ok */"
2591 nan="$nan$cansep$c=1"
2592 cansep=$nl
2594 esac
2595 eval $c=1
2596 allinc="${allinc}#include <$x>$nl"
2597 else gothdr="$gothdr - $x"
2598 case $explicit$all$config$undef in
2599 0?1?|0??1)
2600 can="$can$cansep#undef $c /* #include <$x> not ok */"
2601 nan="$nan$cansep$c="
2602 cansep=$nl
2604 01??) can="$can$cansep#define $c 0 /* #include <$x> not ok */"
2605 nan="$nan$cansep$c=0"
2606 cansep=$nl
2608 esac
2610 done
2612 esac
2614 # add implicit headers/libraries before the checks
2616 case $op in
2617 npt) hdr="sys/types.h stdlib.h unistd.h $hdr"
2619 siz|typ)hdr="sys/types.h time.h sys/time.h sys/times.h stddef.h stdlib.h $hdr"
2621 esac
2623 # check the candidate headers
2625 case $hdr in
2626 ?*) z=$hdr
2627 hdr=
2628 dis=0
2629 for x in $z
2630 do case $x in
2631 *.h) case " $gothdr " in
2632 *" - $x "*)
2633 continue
2635 *" + $x "*)
2637 *) case $shell in
2638 bsh) eval `echo $x | sed -e 's,^\\([^\\\\/]*\\).*[\\\\/]\\([^\\\\/]*\\)\$,\\1_\\2,' -e 's/\\..*//' -e 's/^/c=/'`
2640 *) eval 'c=${x##*[\\/]}'
2641 eval 'c=${c%%.*}'
2642 case $x in
2643 */*) eval 'c=${x%%[\\/]*}_${c}' ;;
2644 esac
2646 esac
2647 case $explicit in
2648 0) dis=0
2650 *) case $x in
2651 */*) dis=$c ;;
2652 *) dis=hdr ;;
2653 esac
2654 case ${dis}_ in
2655 ${op}_*)dis=0 ;;
2656 *) dis=1 ;;
2657 esac
2659 esac
2660 case $config in
2661 0) case $x in
2662 */*) c=_${c} ;;
2663 *) c=_hdr_${c} ;;
2664 esac
2666 1) case $shell in
2667 ksh) typeset -u u=$c ;;
2668 *) u=`echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
2669 esac
2670 c=HAVE_${u}_H
2672 esac
2673 echo "${allinc}#include <$x>" > $tmp.c
2674 if is_hdr $x
2675 then gothdr="$gothdr + $x"
2676 case $dis in
2677 0) can="$can$cansep#define $c 1 /* #include <$x> ok */"
2678 nan="$nan$cansep$c=1"
2679 cansep=$nl
2681 esac
2682 eval $c=1
2683 else gothdr="$gothdr - $x"
2684 case $dis$all$config$undef in
2685 0?1?|0??1)
2686 can="$can$cansep#undef $c /* #include <$x> not ok */"
2687 nan="$nan$cansep$c="
2688 cansep=$nl
2690 01??) can="$can$cansep#define $c 0 /* #include <$x> not ok */"
2691 nan="$nan$cansep$c=0"
2692 cansep=$nl
2694 esac
2695 continue
2698 esac
2700 *) test -r $x || continue
2702 esac
2703 hdr="$hdr $x"
2704 done
2706 esac
2708 # check the candidate libraries
2710 case $lib in
2711 ?*) z=
2712 for p in $lib
2713 do z="$p $z"
2714 done
2715 lib=
2717 hit=0
2718 echo "int main(){return(0);}" > $tmp.c
2719 for x in $z
2720 do p=$x
2721 case " $gotlib " in
2722 *"- $p "*)
2723 failure +
2726 *"+ $p "*)
2727 success +
2728 lib="$p $lib"
2730 *) rm -f $tmp.exe
2731 is LIB $p
2732 if compile $cc -o $tmp.exe $tmp.c $p $lib <&$nullin >&$nullout
2733 then success
2734 gotlib="$gotlib + $p"
2735 lib="$p $lib"
2737 else a=
2739 for l in $z
2740 do case $l in
2741 -) a=
2742 continue
2744 $p) a=$p
2745 continue
2747 *) case $gotlib in
2748 *" $l "*) continue ;;
2749 esac
2751 esac
2752 case $a in
2753 $p) a="$a $l"
2754 if compile $cc -o $tmp.exe $tmp.c $a <&$nullin >&$nullout
2755 then success
2756 gotlib="$gotlib + $p"
2757 lib="$p $lib"
2759 break
2762 esac
2763 done
2764 case $e in
2765 1) failure
2766 gotlib="$gotlib - $p"
2768 esac
2771 for x in $p
2772 do case $shell in
2773 bsh) c=`echo X$x | sed 's,X-l,,'` ;;
2774 *) eval 'c=${x#-l}' ;;
2775 esac
2776 case $c in
2777 *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
2778 c=`echo '' $c | sed -e 's,.*[\\\\/],,' -e 's,\.[^.]*$,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g' -e '/^lib./s,^lib,,'`
2780 esac
2781 case $config in
2782 0) case $e$p in
2783 0*' '*) case " $gotlib " in
2784 *[-+]" $x "*)
2786 *) can="$can$cansep#define _LIB_$c 1 /* $x is a library */"
2787 nan="$nan${cansep}_LIB_$c=1"
2788 cansep=$nl
2789 eval _LIB_$c=1
2791 esac
2793 esac
2795 1) case $shell in
2796 ksh) typeset -u u=$c ;;
2797 *) u=`echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
2798 esac
2799 c=$u
2800 case $e in
2801 0*' '*) case " $gotlib " in
2802 *[-+]" $x "*)
2804 *) can="$can$cansep#define HAVE_${c}_LIB 1 /* $x is a library */"
2805 nan="$nan${cansep}HAVE_${c}_LIB=1"
2806 cansep=$nl
2807 eval HAVE_${c}_LIB=1
2809 esac
2811 esac
2813 esac
2814 y=${y}_$c
2815 done
2816 case $config in
2817 0) c=_LIB${y} ;;
2818 1) c=HAVE${y}_LIB ;;
2819 esac
2820 case $p in
2821 *' '*) q="a library group" ;;
2822 *) q="a library" ;;
2823 esac
2824 case $e in
2825 0) can="$can$cansep#define $c 1 /* $p is $q */"
2826 nan="$nan$cansep$c=1"
2827 cansep=$nl
2828 eval $c=1
2829 case $hit in
2830 1) break ;;
2831 esac
2833 1) case $all$config$undef in
2834 ?1?|??1)can="$can$cansep#undef $c /* $p is not $q */"
2835 nan="$nan$cansep$c="
2836 cansep=$nl
2838 1??) can="$can$cansep#define $c 0 /* $p is not $q */"
2839 nan="$nan$cansep$c=0"
2840 cansep=$nl
2842 esac
2843 eval $c=0
2845 esac
2848 esac
2849 done
2851 esac
2853 # last op precheck
2855 case $op in
2856 ref) deflib="$deflib $lib"
2857 defhdr="$defhdr $hdr"
2858 break
2860 esac
2861 IFS=" ,"
2862 case $shell in
2863 bash) op=`echo $op`
2864 arg=`echo $arg`
2866 *) eval op=\"$op\"
2867 eval arg=\"$arg\"
2869 esac
2870 IFS=$ifs
2872 # check for op aliases
2875 for o in $op
2876 do case $o in
2877 def|default) x="$x cmd dat hdr key lib mth sys typ" ;;
2878 *) x="$x $o" ;;
2879 esac
2880 done
2882 # loop on the ops o and args a
2884 result=UNKNOWN
2885 for o in $x
2886 do for a in $arg
2887 do c=
2888 case $a in
2889 *[.\\/]*)
2890 case $o in
2891 hdr|lcl|nxt|pth|sys)
2892 x=$a
2893 case $x in
2894 *.lcl|*.nxt)
2895 case $o in
2896 sys) x=sys/$x ;;
2897 esac
2898 case $shell in
2899 bsh) eval `echo $x | sed 's,\\(.*\\)\.\\([^.]*\\),x=\\1 o=\\2,'`
2901 *) o=${x##*.}
2902 x=${x%.${o}}
2904 esac
2905 v=$x
2907 esac
2908 case $x in
2909 *[\\/]*)case $shell in
2910 bsh) eval `echo $x | sed 's,\\(.*\\)[\\\\//]\\(.*\\),p=\\1 v=\\2,'`
2912 *) eval 'p=${x%/*}'
2913 eval 'v=${x##*/}'
2915 esac
2917 *.*) case $shell in
2918 bsh) eval `echo $x | sed 's,\\(.*\\)\\.\\(.*\\),p=\\1 v=\\2,'`
2920 *) eval 'p=${x%.*}'
2921 eval 'v=${x##*.}'
2923 esac
2925 *) p=
2927 esac
2928 case $o in
2929 lcl|nxt) c=$v.$o ;;
2930 *) c=$v ;;
2931 esac
2933 *) case $shell in
2934 bsh) eval `echo $a | sed -e 's,.*[\\\\/],,' -e 's/\\(.*\\)\\.\\(.*\\)/p=\\1 v=\\2/'`
2936 *) eval 'p=${a%.*}'
2937 eval 'p=${p##*[\\/]}'
2938 eval 'v=${a##*.}'
2939 eval 'v=${v##*[\\/]}'
2941 esac
2943 esac
2944 case $p in
2945 '') f=${v} ;;
2946 *) f=${p}/${v} ;;
2947 esac
2948 case $o in
2949 run) v=$p
2951 m=_${v}
2953 mem) case $p in
2954 *.*) case $shell in
2955 bsh) eval `echo $p | sed 's/\\([^.]*\\)\\.\\(.*\\)/p=\\1 m=\\2/'`
2957 *) eval 'm=${p#*.}'
2958 eval 'p=${p%%.*}'
2960 esac
2961 v=${m}.${v}
2962 esac
2963 case $config in
2964 0) m=_${v}_${p} ;;
2965 1) m=_${v}_in_${p} ;;
2966 esac
2968 *) case $p in
2969 '') m=_${v} ;;
2970 *) m=_${p}_${v} ;;
2971 esac
2973 esac
2975 *) p=
2976 v=$a
2977 f=$a
2978 m=_${v}
2980 esac
2981 case $c in
2982 '') c=$v ;;
2983 esac
2984 M=$m
2985 case $o in
2986 out) case $a in
2987 -) a=-
2989 ?*) test="$a $test"
2992 esac
2994 *) case " $idyes " in
2995 *" $m "*)
2998 *) case " $idno " in
2999 *" $m "*)
3002 *) case $m in
3003 *'*') m=`echo "$m" | sed 's,\*,_ptr,g'` ;;
3004 esac
3005 case $m in
3006 *[-+/\\]*)
3009 *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
3010 is id $m
3011 copy $tmp.c "int $m = 0;"
3012 if compile $cc -c $tmp.c
3013 then success -
3014 idyes="$idyes $m"
3016 else failure -
3017 idno="$idno $m"
3021 *) i=1
3023 esac
3025 esac
3026 case $i in
3027 0) case $o in
3028 dat|dfn|key|lib|mac|mth|nos|npt|siz|sym|typ|val)
3029 continue
3031 esac
3033 esac
3035 esac
3037 esac
3038 case $m in
3039 *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
3040 m=`echo "X$m" | sed -e 's,^.,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g'`
3042 esac
3044 # check output redirection
3046 case $out in
3047 $cur) ;;
3048 *) case $cur in
3049 $a|$c) ;;
3050 *) case $cur in
3051 .) ;;
3052 *) case $vers in
3053 ?*) echo
3054 for api in $vers
3055 do API=`echo $api | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
3056 eval ver='${'ver_${api}'}'
3057 echo "#define ${API}_VERSION ${ver}"
3058 done
3059 esac
3060 set x x $apisame
3061 while :
3062 do case $# in
3063 [0123]) break ;;
3064 esac
3065 shift 2
3066 echo "#ifndef _API_${1}"
3067 echo "#define _API_${1} _API_${2}"
3068 echo "#endif"
3069 done
3070 case $apis in
3071 ?*) for api in $apis
3072 do API=`echo $api | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
3073 echo "#define ${API}API(rel) ( _BLD_${api} || !_API_${api} || _API_${api} >= rel )"
3074 echo
3075 echo "#ifndef _${API}_API_IMPLEMENT"
3076 echo "#define _${API}_API_IMPLEMENT 1"
3077 echo
3078 map=
3079 sep=
3080 eval syms='"${'api_sym_${api}'}"'
3081 # old solaris requires -k<space><junk> #
3082 set x x `echo "$syms" | sort -t: -u -k 1,1 -k 2,2nr 2>/dev/null | sed 's/:/ /'`
3083 case $# in
3084 2) # ancient sort doesn't have -k #
3085 set x x `echo "$syms" | sort -t: -u +0 -1 +1 -2nr 2>/dev/null | sed 's/:/ /'`
3087 esac
3088 sym=
3089 while :
3090 do shift 2
3091 case $# in
3092 [01]) break ;;
3093 esac
3094 prv=$sym
3095 sym=$1
3096 rel=$2
3097 case $prv in
3098 $sym) echo "#elif _API_${api} >= $rel"
3100 *) case $prv in
3101 '') echo
3102 echo "#if !defined(_API_${api}) && defined(_API_DEFAULT)"
3103 echo "#define _API_${api} _API_DEFAULT"
3104 echo "#endif"
3106 *) echo "#endif"
3108 esac
3109 echo
3110 echo "#if ${API}API($rel)"
3112 esac
3113 echo "#undef ${sym}"
3114 echo "#define ${sym} ${sym}_${rel}"
3115 map=$map$sep${sym}_${rel}
3116 sep=' '
3117 done
3118 echo "#endif"
3119 echo
3120 echo "#define _API_${api}_MAP \"$map\""
3121 echo
3122 echo "#endif"
3123 done
3124 echo
3126 esac
3127 case $iff in
3128 ?*) echo "#endif" ;;
3129 esac
3130 case $cur in
3131 -) ;;
3132 *) exec >/dev/null
3133 case $cur in
3134 *[\\/]*|*.h) x=$cur ;;
3135 *) x=$dir/$cur ;;
3136 esac
3137 case $define in
3138 n) sed '/^#/d' $tmp.h > $tmp.c
3139 sed '/^#/d' $x > $tmp.t
3141 *) (proto -r $protoflags $tmp.h) >/dev/null 2>&1
3142 sed 's,/\*[^/]*\*/, ,g' $tmp.h > $tmp.c
3143 sed 's,/\*[^/]*\*/, ,g' $x > $tmp.t
3145 esac
3146 if cmp -s $tmp.c $tmp.t
3147 then rm -f $tmp.h
3148 case $verbose in
3149 1) echo "$command: $x: unchanged" >&$stderr ;;
3150 esac
3151 else case $x in
3152 ${dir}[\\/]$cur) test -d $dir || mkdir $dir || exit 1 ;;
3153 esac
3154 mv $tmp.h $x
3157 esac
3159 esac
3160 case $out in
3161 +) case $status in
3162 1) ;;
3163 *) status=0 ;;
3164 esac
3165 exit $status
3167 -) eval "exec >&$stdout"
3169 *) exec >$tmp.h
3171 esac
3172 case $out in
3173 "") case $a in
3174 *[\\/]*|???????????????*) cur=$c ;;
3175 *) cur=$a ;;
3176 esac
3178 *) cur=$out
3180 esac
3181 case $in in
3182 ""|-|+) case $o in
3183 run) x=" from $a" ;;
3184 *) x= ;;
3185 esac
3187 *) x=" from $in"
3189 esac
3191 # output header comments
3193 case $define in
3194 n) ;;
3195 ?) echo "/* : : generated$x by $command version $version : : */"
3196 for x in $pragma
3197 do echo "#pragma $x"
3198 done
3199 case $out in
3200 ""|-|+) x=$m
3202 *.*) case $shell in
3203 bsh) eval `echo $in | sed -e 's,\\.,_,g' -e 's/^/x=/'`
3205 *) i=$out
3207 while :
3208 do case $i in
3209 *.*) eval 'x=$x${i%%.*}_'
3210 eval 'i=${i#*.}'
3212 *) x=$x$i
3213 break
3215 esac
3216 done
3218 esac
3220 *) x=_$out
3222 esac
3223 case $o in
3224 iff) case $M in
3225 ""|*-*) ;;
3226 *) iff=${m}_H ;;
3227 esac
3229 *) case $regress in
3230 '') case $x in
3231 *-*) ;;
3232 *) x=`pwd | sed -e 's,.*[\\\\/],,' -e 's,\\..*,,' -e 's,^lib,,' -e 's,^,'${x}_',' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g'`
3233 # ksh n+ bug workaround
3234 case $x in
3235 *[!_]*) ;;
3236 *) x=_$$ ;;
3237 esac
3238 iff=_def${x}
3240 esac
3242 *) case $x in
3243 *-*) ;;
3244 *) iff=_REGRESS
3246 esac
3248 esac
3250 esac
3251 case $iff in
3252 ?*) echo "#ifndef $iff"
3253 echo "#define $iff 1"
3255 esac
3257 esac
3259 esac
3261 esac
3262 case $can in
3263 ?*) case $define in
3264 1) echo "$can" ;;
3265 n) echo "$nan" ;;
3266 esac
3267 can=
3268 nan=
3269 cansep=
3271 esac
3273 # set up the candidate include list
3275 pre=
3276 inc=
3277 for x in $defhdr - $hdr
3278 do case $x in
3279 -) case $pre in
3280 ?*) continue ;;
3281 esac
3282 case $v in
3283 *.*) for x in `echo $v | sed 's,\\., ,g'`
3284 do pre="$pre
3285 #undef $x"
3286 done
3288 *) case $o in
3289 siz|typ)case $v in
3290 char|short|int|long)
3292 *) pre="#undef $v"
3294 esac
3296 *) pre="#undef $v"
3298 esac
3300 esac
3302 *.h) case $shell in
3303 bsh) eval `echo $x | sed -e 's,^\\([^\\\\/]*\\).*[\\\\/]\\([^\\\\/]*\\)\$,\\1_\\2,' -e 's/\\..*//' -e 's/^/c=/'`
3305 *) eval 'c=${x##*[\\/]}'
3306 eval 'c=${c%%.*}'
3307 case $x in
3308 */*) eval 'c=${x%%[\\/]*}_${c}' ;;
3309 esac
3311 esac
3312 case $config in
3313 0) case $x in
3314 */*) c=_${c} ;;
3315 *) c=_hdr_${c} ;;
3316 esac
3318 1) case $shell in
3319 ksh) typeset -u u=$c ;;
3320 *) u=`echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
3321 esac
3322 c=HAVE_${u}_H
3324 esac
3325 case " $puthdr " in
3326 *" $c "*)
3328 *) puthdr="$puthdr $c"
3329 usr="$usr$nl#define $c 1"
3331 esac
3332 inc="$inc
3333 #include <$x>"
3335 esac
3336 done
3338 # set up the candidate lib list
3340 for x in $lib $deflib
3341 do case $shell in
3342 ksh) eval 'c=${x#-l}' ;;
3343 *) c=`echo X$x | sed 's,X-l,,'` ;;
3344 esac
3345 case $c in
3346 *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
3347 c=`echo '' $c | sed -e 's,.*[\\\\/],,' -e 's,\.[^.]*$,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g' -e '/^lib./s,^lib,,'`
3349 esac
3350 case $config in
3351 0) c=_LIB_${c}
3353 1) case $shell in
3354 ksh) typeset -u u=$c ;;
3355 *) u=`echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
3356 esac
3357 c=HAVE_${u}_LIB
3359 esac
3360 case " $putlib " in
3361 *" $c "*)
3363 *) putlib="$putlib $c"
3364 usr="$usr$nl#define $c 1"
3366 esac
3367 done
3369 # src overrides builtin test
3371 case $config:$def in
3372 0:) case $o in
3373 tst|var);;
3374 *) m=_${o}${m} ;;
3375 esac
3377 1:) case $o in
3378 tst|var)m=${v} ;;
3379 esac
3380 case $shell in
3381 ksh) typeset -u u=$m ;;
3382 *) u=`echo $m | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
3383 esac
3384 case $o in
3385 tst|var)case $m in
3386 $u) ;;
3387 *) case $m in
3388 hdr_*|lib_*|sys_*)
3389 case $shell in
3390 ksh) u=${u#????} ;;
3391 *) u=`echo $u | sed 's/....//'` ;;
3392 esac
3394 esac
3395 m=HAVE_${u}
3397 esac
3399 dat) m=HAVE${u}_DATA ;;
3400 hdr|lcl)m=HAVE${u}_H ;;
3401 key) m=HAVE${u}_RESERVED ;;
3402 mth) m=HAVE${u}_MATH ;;
3403 npt) m=HAVE${u}_DECL ;;
3404 pth) m=${u}_PATH
3405 case $shell in
3406 ksh) m=${m#_} ;;
3407 *) m=`echo $m | sed 's,^_,,'` ;;
3408 esac
3410 nxt) m=HAVE${u}_NEXT ;;
3411 siz) m=SIZEOF${u} ;;
3412 sys) m=HAVE_SYS${u}_H ;;
3413 *) m=HAVE${u} ;;
3414 esac
3416 *) m=$def
3417 M=$m
3419 esac
3420 case $src in
3421 ?*) case $src in
3422 $noext) EXT= ;;
3423 *) EXT="$tst
3424 $ext"
3426 esac
3427 copy $tmp.c "$std
3428 $EXT
3429 $usr
3430 $inc
3431 $src
3435 is tst "${note:-$run}"
3436 case $run in
3437 cat*|nocat*)
3438 copy - "$src"
3440 cross*|nocross*)
3441 copy $tmp.sh "$src"
3442 chmod +x $tmp.sh
3443 execute $tmp.sh <&$nullin || e=1
3445 run*|norun*)
3446 (eval "$src") <&$nullin || e=1
3448 mac*|nomac*)
3449 if compile $cc -E $tmp.c <&$nullin >$tmp.i
3450 then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i
3451 else e=1
3454 p*|nop*)compile $cc -DTEST=$p -DID=$v -E $tmp.c <&$nullin >&$nullout || e=1
3456 c*|noc*)compile $cc -DTEST=$p -DID=$v -c $tmp.c <&$nullin >&$nullout || e=1
3458 *) case $run in
3459 status*)ccflags=
3461 s*|nos*)case $reallystatictest in
3462 '') #UNDENT...
3464 reallystatictest=.
3465 echo "$tst
3466 $ext
3467 int main(){printf("hello");return(0);}" > ${tmp}s.c
3468 rm -f ${tmp}s.exe
3469 if compile $cc -c ${tmp}s.c <&$nullin >&$nullout &&
3470 compile $cc -o ${tmp}s.exe ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e &&
3471 $executable ${tmp}s.exe
3472 then e=`wc -l ${tmp}s.e`
3473 eval set x x $binding
3474 while :
3475 do shift
3476 shift
3477 case $# in
3478 0) break ;;
3479 esac
3480 rm -f ${tmp}s.exe
3481 compile $cc -o ${tmp}s.exe $1 ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e && $executable ${tmp}s.exe || continue
3482 case `wc -l ${tmp}s.e` in
3483 $e) ;;
3484 *) continue ;;
3485 esac
3486 d=`ls -s ${tmp}s.exe`
3487 rm -f ${tmp}s.exe
3488 compile $cc -o ${tmp}s.exe $2 ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e && $executable ${tmp}s.exe || continue
3489 case `wc -l ${tmp}s.e` in
3490 $e) ;;
3491 *) continue ;;
3492 esac
3493 case `ls -s ${tmp}s.exe` in
3494 $d) ;;
3495 *) reallystatic=$2
3496 set x
3497 shift
3498 break
3500 esac
3501 done
3503 rm -f ${tmp}s.*
3504 #...INDENT
3506 esac
3507 ccflags=$reallystatic
3509 *) ccflags=
3511 esac
3512 set x $mac
3514 while :
3515 do o=
3516 shift
3517 while :
3518 do case $# in
3519 0) break ;;
3520 esac
3521 case $1 in
3522 -) break ;;
3523 esac
3524 o="$o $1"
3525 shift
3526 done
3527 rm -f $tmp.exe
3528 if compile $cc $ccflags $o -DTEST=$p -DID=$v -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout && $executable $tmp.exe
3529 then case $run in
3531 status*)execute $tmp.exe <&$nullin >&$nullout
3532 V=$?
3533 case $V in
3534 0) e=1 ;;
3535 *) e=0 ;;
3536 esac
3537 break
3539 no[ls]*);;
3540 [ls]*) e=0 && break ;;
3541 noo*) execute $tmp.exe <&$nullin >$tmp.out || break ;;
3542 o*) execute $tmp.exe <&$nullin >$tmp.out && e=0 && break ;;
3543 no*) execute $tmp.exe <&$nullin >&$nullout || break ;;
3544 *) execute $tmp.exe <&$nullin >&$nullout && e=0 && break ;;
3546 esac
3547 else case $run in
3548 no[els]*)e=1 && break ;;
3549 esac
3551 case $# in
3552 0) case $run in
3553 no*) e=0 ;;
3554 esac
3555 break
3557 esac
3558 done
3560 esac
3562 case $run in
3563 no*) case $e in
3564 0) e=1 ;;
3565 *) e=0 ;;
3566 esac
3568 esac
3569 case $run in
3570 o*|noo*)case $e in
3571 0) cat $tmp.out ;;
3572 esac
3573 rm -f $tmp.out
3575 esac
3576 report $e $V "${note:-$run\ passed}" "${note:-$run} failed"
3577 continue
3579 esac
3581 # initialize common builtin state
3583 case $o in
3584 dat|lib|mth|run)
3585 case $statictest in
3586 "") statictest=FoobaR
3587 copy $tmp.c "
3588 $tst
3589 $ext
3590 $std
3591 $usr
3592 _BEGIN_EXTERNS_
3593 extern int $statictest;
3594 _END_EXTERNS_
3595 int main(){char* i = (char*)&$statictest; return ((unsigned int)i)^0xaaaa;}
3597 rm -f $tmp.exe
3598 if compile $cc -o $tmp.exe $tmp.c <&$nullin >&$nullout && $executable $tmp.exe
3599 then case $static in
3600 .) static=
3601 copy $tmp.c "
3602 $tst
3603 $ext
3604 int main(){printf("hello");return(0);}
3606 rm -f $tmp.exe
3607 if compile $cc -c $tmp.c <&$nullin >&$nullout &&
3608 compile $cc -o $tmp.exe $tmp.o <&$nullin >&$nullout &&
3609 $executable $tmp.exe
3610 then e=`wc -l $tmp.e`
3611 eval set x x $binding
3612 while :
3613 do shift
3614 shift
3615 case $# in
3616 0) break ;;
3617 esac
3618 rm -f $tmp.exe
3619 compile $cc -o $tmp.exe $1 $tmp.o <&$nullin >&$nullout && $executable $tmp.exe || continue
3620 case `wc -l $tmp.e` in
3621 $e) ;;
3622 *) continue ;;
3623 esac
3624 d=`ls -s $tmp.exe`
3625 rm -f $tmp.exe
3626 compile $cc -o $tmp.exe $2 $tmp.o <&$nullin >&$nullout && $executable $tmp.exe || continue
3627 case `wc -l $tmp.e` in
3628 $e) ;;
3629 *) continue ;;
3630 esac
3631 case `ls -s $tmp.exe` in
3632 $d) ;;
3633 *) static=$2
3634 set x
3635 shift
3636 break
3638 esac
3639 done
3642 esac
3643 else static=
3646 esac
3648 esac
3650 # builtin tests
3652 case $o in
3653 api) ;;
3654 cmd) case $p in
3655 ?*) continue ;;
3656 esac
3657 is $o $a
3659 for j in "" usr
3660 do case $j in
3661 "") d= s= ;;
3662 *) d=/$j s=_$j ;;
3663 esac
3664 for i in bin etc ucb
3665 do if test -f $d/$i/$a
3666 then case $k in
3667 1) k=0
3668 case $M in
3669 *-*) ;;
3670 *) usr="$usr$nl#define $m 1"
3671 case $define in
3672 1) echo "#define $m 1 /* $a in ?(/usr)/(bin|etc|ucb) */" ;;
3673 n) echo "$m=1" ;;
3674 esac
3676 esac
3678 esac
3679 c=${s}_${i}_${v}
3680 usr="$usr$nl#define $c 1"
3681 case $define in
3682 1) echo "#define $c 1 /* $d/$i/$a found */" ;;
3683 n) echo "$c=1" ;;
3684 esac
3686 done
3687 done
3688 case $k in
3689 0) success ;;
3690 1) failure ;;
3691 esac
3693 dat) case $p in
3694 ?*) continue ;;
3695 esac
3697 copy - "
3698 $tst
3699 $ext
3700 $std
3701 $usr
3702 $pre
3704 case $inc in
3705 ?*) echo "$inc"
3707 *) echo "_BEGIN_EXTERNS_
3708 extern int $v;
3709 _END_EXTERNS_"
3711 esac
3712 echo "
3713 #ifdef _DLL
3714 #define _REF_
3715 #else
3716 #define _REF_ &
3717 #endif
3718 int main(){char* i = (char*) _REF_ $v; return ((unsigned int)i)^0xaaaa;}"
3719 } > $tmp.c
3720 is $o $v
3721 rm -f $tmp.exe
3722 compile $cc -c $tmp.c <&$nullin >&$nullout &&
3723 compile $cc $static -o $tmp.exe $tmp.o $lib $deflib <&$nullin >&$nullout &&
3724 $executable $tmp.exe
3725 report $? 1 "$v in default lib(s)" "$v not in default lib(s)"
3727 dfn) case $p in
3728 ?*) continue ;;
3729 esac
3730 is dfn $v
3731 echo "$pre
3732 $tst
3733 $ext
3734 $inc
3735 #ifdef $v
3736 <<\"#ifndef $v\">>
3737 <<\"#define $v\">> $v <<\"/* native $v */\">>
3738 <<\"#endif\">>
3739 #endif" > $tmp.c
3740 if compile $cc -E $tmp.c <&$nullin >$tmp.i
3741 then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i > $tmp.t
3742 if test -s $tmp.t
3743 then success
3744 cat $tmp.t
3745 else failure
3747 else failure
3750 exp) case $test in
3751 '') echo "$command: $file$sline: test expression expected for $o" >&$stderr
3752 exit 1
3754 esac
3755 case $a in
3756 -|'') ;;
3757 *) eval x='$'$a
3758 case $x in
3759 1) result=FAILURE
3760 continue
3762 esac
3764 esac
3765 case $test in
3766 [01]|'"'*'"'|'<'*'>')
3767 case $a in
3768 -|'') ;;
3769 *) case $define$note in
3770 1) echo "#define $a $test" ;;
3771 1*) echo "#define $a $test /* $note */" ;;
3772 n) echo "$a=$test" ;;
3773 esac
3774 eval $a='$test'
3776 esac
3778 *) case $note in
3779 '') note=$test ;;
3780 esac
3781 case $test in
3782 '') c=1
3784 *) is exp "$note"
3786 for i in `echo '' $test | sed 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], & ,g'`
3787 do case $i in
3788 [\ \ ])
3790 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]*)
3791 eval i='${'$i'}'
3792 case $i in
3793 '') i=0
3795 '"'*'"');;
3796 *[!-+0123456789]*)
3797 case $i in
3798 *'"'*) i=1 ;;
3799 *) i='"'$i'"' ;;
3800 esac
3802 esac
3803 x="$x $i"
3805 '!') x="$x 0 ="
3807 '&'|'|')case $x in
3808 *"$i") ;;
3809 *) x="$x \\$i" ;;
3810 esac
3812 *) x="$x \\$i"
3814 esac
3815 done
3816 c=`eval expr $x 2>&$stderr`
3818 esac
3819 case $c in
3820 0) c=1 ;;
3821 *) c=0 ;;
3822 esac
3823 M=$a
3824 m=$a
3825 report $c 1 "$note is true" "$note is false"
3827 esac
3829 hdr|lcl|nxt|sys)
3830 case $o in
3831 lcl|nxt)case $M in
3832 *-*) continue ;;
3833 esac
3834 eval x='$'_$m
3835 case $x in
3836 ?*) continue ;;
3837 esac
3838 eval _$m=1
3839 is $o $f
3840 echo "$pre
3841 $tst
3842 $ext
3843 $inc
3844 #include <$f.h>" > $tmp.c
3846 if compile $cc -E $tmp.c <&$nullin >$tmp.i
3847 then j=
3848 for i in `grep '^#.*".*'$f'\\.h"' $tmp.i | head -1 | sed -e 's;.*"\\(.*\\)[\\\\\/]'$f'\\.h".*;\\1;' -e 's;/; ;g' -e 's/^ *[^ ]*//'`
3849 do j="$i $j"
3850 done
3851 k=$f.h
3852 for i in $j
3853 do k=$i/$k
3854 echo "$pre
3855 $tst
3856 $ext
3857 $inc
3858 #include \"$k\"" > $tmp.c
3859 if compile $cc -E $tmp.c <&$nullin >$tmp.i
3860 then r=$k
3861 break
3863 done
3864 case $r in
3865 '') echo "$pre
3866 $tst
3867 $ext
3868 $inc
3869 #include \"/$k\"" > $tmp.c
3870 if compile $cc -E $tmp.c <&$nullin >&$nullout
3871 then r=$k
3872 else echo "$pre
3873 $tst
3874 $ext
3875 $inc
3876 #include \"../include/$f.h\"" > $tmp.c
3877 if compile $cc -E $tmp.c <&$nullin >&$nullout
3878 then r=../include/$f.h
3882 esac
3883 else r=
3885 case $r in
3886 '') failure
3887 case $o in
3888 lcl) case $all$config$undef in
3889 ?1?|??1)echo "#undef $m /* no native <$f.h> */" ;;
3890 1??) echo "#define $m 0 /* no native <$f.h> */" ;;
3891 esac
3892 eval $m=0
3894 nxt) case $all$config$undef in
3895 ?1?|??1)echo "#undef $m /* no include path for the native <$f.h> */" ;;
3896 esac
3898 esac
3900 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]:[\\/]*|[\\/]*)
3901 success
3902 case $o in
3903 lcl) echo "#if defined(__STDPP__directive)"
3904 echo "__STDPP__directive pragma pp:hosted"
3905 echo "#endif"
3906 echo "#include \"$r\" /* the native <$f.h> */"
3907 echo "#undef $m"
3908 usr="$usr$nl#define $m 1"
3909 echo "#define $m 1"
3911 nxt) echo "#define $m \"$r\" /* include path for the native <$f.h> */"
3912 echo "#define ${m}_str \"$r\" /* include string for the native <$f.h> */"
3913 usr="$usr$nl#define $m \"$r\"$nl#define ${m}_str \"$r\""
3914 eval $m=\\\<$r\\\>
3916 esac
3917 break
3919 *) success
3920 case $o in
3921 lcl) echo "#include \"$r\" /* the native <$f.h> */"
3922 echo "#undef $m"
3923 usr="$usr$nl#define $m 1"
3924 echo "#define $m 1"
3925 eval $m=1
3927 nxt) echo "#define $m \"$r\" /* include path for the native <$f.h> */"
3928 echo "#define ${m}_str \"$r\" /* include string for the native <$f.h> */"
3929 usr="$usr$nl#define $m \"$r\"$nl#define ${m}_str \"$r\""
3930 eval $m=\\\"$r\\\"
3932 esac
3933 break
3935 esac
3937 *) case $o in
3938 hdr) x=$f.h ;;
3939 sys) x=sys/$f.h ;;
3940 esac
3941 case " $gothdr " in
3942 *" - $x "*)
3943 failure +
3945 *" + $x "*)
3946 success +
3948 *) echo "
3949 $tst
3950 $ext
3951 $allinc
3952 $inc
3953 #include <$x>" > $tmp.c
3954 if is_hdr $x
3955 then gothdr="$gothdr + $x"
3956 case $M in
3957 *-*) ;;
3958 *) case " $puthdr " in
3959 *" $m "*)
3961 *) puthdr="$puthdr $m"
3962 usr="$usr$nl#define $m 1"
3964 esac
3965 case $define in
3966 1) echo "#define $m 1 /* #include <$x> ok */" ;;
3967 n) echo "$m=1" ;;
3968 esac
3969 eval $m=1
3971 esac
3972 else gothdr="$gothdr - $x"
3973 case $M in
3974 *-*) ;;
3975 *) case $define$all$config$undef in
3976 1?1?|1??1)echo "#undef $m /* #include <$x> not ok */" ;;
3977 11??) echo "#define $m 0 /* #include <$x> not ok */" ;;
3978 n1?1) echo "$m=" ;;
3979 n1??) echo "$m=0" ;;
3980 esac
3981 eval $m=0
3983 esac
3986 esac
3987 continue
3989 esac
3991 iff) ;;
3992 ini) ;;
3993 key) case $p in
3994 ?*) continue ;;
3995 esac
3996 w=$v
3997 while :
3998 do is $o $w
3999 echo "$pre
4000 $tst
4001 $ext
4002 int f(){int $w = 1;return($w);}" > $tmp.c
4003 if compile $cc -c $tmp.c <&$nullin >&$nullout
4004 then failure
4005 case $set in
4006 *" ="|*" = "*)
4007 set x $set
4008 shift
4010 while :
4011 do case $# in
4012 0) break ;;
4013 esac
4014 case $1 in
4015 =) break ;;
4016 esac
4017 case $w in
4018 '') w=$1 ;;
4019 *) w="$w $1" ;;
4020 esac
4021 shift
4022 done
4023 case $1 in
4024 =) shift
4025 case $# in
4026 0) set=" " ;;
4027 *) set=$* ;;
4028 esac
4030 *) set=
4032 esac
4033 case $shell in
4034 ksh) typeset -u u=$w ;;
4035 *) u=`echo $w | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` ;;
4036 esac
4037 u=_$u
4038 M=$w
4039 case $M in
4040 *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
4041 M=`echo "X$m" | sed -e 's,^.,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g'`
4043 esac
4044 case $config in
4045 1) m=HAVE${u}_RESERVED ;;
4046 *) m=_key_${w} ;;
4047 esac
4048 continue
4050 esac
4051 report - 1 - - "$w is not a reserved keyword" "default for reserved keyword $v"
4052 else report 0 1 "$w is a reserved keyword" -
4053 case $M in
4054 *-*) ;;
4055 *) case $define$w in
4056 1$v) ;;
4057 1*) echo "#define $v $w /* alternate for reserved keyword $v */" ;;
4058 n*) echo "$v=$w" ;;
4059 esac
4061 esac
4063 break
4064 done
4066 lib|mth)case $p in
4067 ?*) continue ;;
4068 esac
4069 case $v in
4070 -) continue ;;
4071 esac
4072 is $o $v
4073 copy $tmp.c "
4074 $tst
4075 $ext
4076 $std
4077 $usr
4078 $pre
4079 $inc
4080 #ifdef _IFFE_type
4081 $v i;
4082 #else
4083 typedef int (*_IFFE_fun)();
4084 #ifdef _IFFE_extern
4085 _BEGIN_EXTERNS_
4086 extern int $v();
4087 _END_EXTERNS_
4088 #endif
4089 static _IFFE_fun i=(_IFFE_fun)$v;int main(){return ((unsigned int)i)^0xaaaa;}
4090 #endif
4092 d=-D_IFFE_extern
4093 if compile $cc -c $tmp.c <&$nullin >&$nullout
4094 then d=
4095 elif compile $cc $d -c $tmp.c <&$nullin >&$nullout
4096 then :
4097 else d=error
4099 if test error != "$d"
4100 then rm -f $tmp.exe
4101 if compile $cc $d $static -o $tmp.exe $tmp.o $lib $deflib <&$nullin >&$nullout &&
4102 $executable $tmp.exe
4103 then case $o in
4104 lib) c=0 ;;
4105 *) c=1 ;;
4106 esac
4107 report $c 1 "$v() in default lib(s)" "$v() not in default lib(s)" "default for function $v()"
4108 else case $o in
4109 mth) rm -f $tmp.exe
4110 compile $cc $d $static -o $tmp.exe $tmp.o -lm <&$nullin >&$nullout &&
4111 $executable $tmp.exe
4112 report $? 1 "$v() in math lib" "$v() not in math lib" "default for function $v()"
4114 *) report 1 1 - "$v() not in default lib(s)" "default for function $v()"
4116 esac
4118 else if compile $cc -D_IFFE_type -c $tmp.c <&$nullin >&$nullout
4119 then c=1
4120 else case $intrinsic in
4121 '') copy $tmp.c "
4122 $tst
4123 $ext
4124 $std
4125 $usr
4126 $pre
4127 $inc
4128 _BEGIN_EXTERNS_
4129 extern int foo();
4130 _END_EXTERNS_
4131 static int ((*i)())=foo;int main(){return(i==0);}
4133 compile $cc -c $tmp.c <&$nullin >&$nullout
4134 intrinsic=$?
4136 esac
4137 c=$intrinsic
4139 case $o in
4140 mth) report $c 1 "$v() in math lib" "$v() not in math lib" "default for function $v()" ;;
4141 *) report $c 1 "$v() in default lib(s)" "$v() not in default lib(s)" "default for function $v()" ;;
4142 esac
4145 mac) case $p in
4146 ?*) continue ;;
4147 esac
4148 is mac $v
4149 echo "
4150 $tst
4151 $ext
4152 $pre
4153 $inc
4154 #ifdef $v
4155 '$m:$v'
4156 #endif" > $tmp.c
4157 compile $cc -E $tmp.c <&$nullin | grep -c "'$m:$v'" >&$nullout
4158 report $? 1 "$v is a macro" "$v is not a macro" "default for macro $v"
4160 mem) case $p in
4161 ?*) eval i='$'_iffe_typedef_$p
4162 case $i in
4163 0|1) ;;
4164 *) echo "$pre
4165 $tst
4166 $ext
4167 $inc
4168 static $p i;
4169 int n = sizeof(i);" > $tmp.c
4170 is typ $p
4171 if compile $cc -c $tmp.c <&$nullin >&$nullout
4172 then success -
4173 eval _iffe_typedef_$p=1
4175 else failure -
4176 eval _iffe_typedef_$p=0
4180 esac
4181 case $i in
4182 0) i="$v is not a member of $p" p="struct $p" ;;
4183 *) i=- ;;
4184 esac
4185 is mem $v "$p"
4186 echo "$pre
4187 $tst
4188 $ext
4189 $inc
4190 static $p i;
4191 int n = sizeof(i.$v);" > $tmp.c
4192 compile $cc -c $tmp.c <&$nullin >&$nullout
4193 report $? 1 "$v is a member of $p" "$i"
4195 *) p=$v
4196 eval i='$'_iffe_typedef_$p
4197 case $i in
4198 0|1) ;;
4199 *) echo "$pre
4200 $tst
4201 $ext
4202 $inc
4203 static $p i;
4204 int n = sizeof(i);" > $tmp.c
4205 is typ $p
4206 if compile $cc -c $tmp.c <&$nullin >&$nullout
4207 then success -
4208 eval _iffe_typedef_$p=1
4210 else failure -
4211 eval _iffe_typedef_$p=0
4215 esac
4216 case $i in
4217 0) i="$p is not a non-opaque struct" p="struct $p" ;;
4218 *) i=- ;;
4219 esac
4220 is nos "$p"
4221 echo "$pre
4222 $tst
4223 $ext
4224 $inc
4225 static $p i;
4226 int n = sizeof(i);" > $tmp.c
4227 if compile $cc -c $tmp.c <&$nullin >&$nullout
4228 then echo "$pre
4229 $tst
4230 $ext
4231 $inc
4232 static $p i;
4233 unsigned long f() { return (unsigned long)i; }" > $tmp.c
4234 if compile $cc -c $tmp.c <&$nullin >&$nullout
4235 then c=1
4236 else c=0
4238 else c=1
4240 report $c 1 "$p is a non-opaque struct" "$i"
4241 esac
4243 nop) ;;
4244 npt) is npt $v
4245 copy $tmp.c "
4246 $tst
4247 $ext
4248 $std
4249 $usr
4250 $pre
4251 $inc
4252 _BEGIN_EXTERNS_
4253 struct _iffe_struct { int _iffe_member; };
4254 #if _STD_
4255 extern struct _iffe_struct* $v(struct _iffe_struct*);
4256 #else
4257 extern struct _iffe_struct* $v();
4258 #endif
4259 _END_EXTERNS_
4261 # some compilers with -O only warn for invalid intrinsic prototypes
4262 case " $cc " in
4263 *" -O "*) xx=`echo $cc | sed 's/ -O / /g'` ;;
4264 *) xx=$cc ;;
4265 esac
4266 compile $xx -c $tmp.c <&$nullin >&$nullout
4267 report -$config $? 1 "$v() needs a prototype" "$v() does not need a prototype"
4269 num) is num $v
4270 copy $tmp.c "
4271 $tst
4272 $ext
4273 $std
4274 $usr
4275 $pre
4276 $inc
4277 _BEGIN_EXTERNS_
4278 int _iffe_int = $v / 2;
4279 _END_EXTERNS_
4281 compile $cc -c $tmp.c <&$nullin >&$nullout
4282 report $? 1 "$v is a numeric constant" "$v is not a numeric constant"
4284 one) for i in $a $hdr
4285 do x="#include <$i>"
4286 case " $gothdr " in
4287 *" - $i "*)
4288 continue
4290 *" + $i "*)
4292 *) echo "$x" > $tmp.c
4293 if is_hdr $x
4294 then gothdr="$gothdr + $x"
4295 else gothdr="$gothdr - $x"
4296 continue
4299 esac
4300 case $one in
4301 "") one=$x
4303 *"$x"*) break
4305 *) echo "$one" > $tmp.c
4306 if compile $cc -E $tmp.c <&$nullin >$tmp.i
4307 then c=$i
4308 case $c in
4309 *[\\/]*) c=`echo $c | sed 's,[\\\\/],[\\\\/],g'` ;;
4310 esac
4311 case `sed -e '/^#[line ]*1[ ][ ]*"[\\\\\/].*[\\\\\/]'$c'"/!d' $tmp.i` in
4312 ?*) break ;;
4313 esac
4315 one="$one$nl$x"
4317 esac
4318 echo "$x"
4319 break
4320 done
4322 opt) case $a in
4323 no-*) case $shell in
4324 ksh) m=_opt_${m#_opt_no_}
4325 a=${a#no-}
4327 *) eval m=`echo $m | sed 's/_opt_no_/_opt_/'`
4328 eval a=`echo $a | sed 's/^no-//'`
4330 esac
4331 case " $PACKAGE_OPTIONS " in
4332 *" no-$a "*) c=1 ;;
4333 *) c=0 ;;
4334 esac
4336 *) case " $PACKAGE_OPTIONS " in
4337 *" $a "*) c=0 ;;
4338 *) c=1 ;;
4339 esac
4341 esac
4342 M=$m
4343 is opt $a
4344 report $c 1 "$a is set in \$PACKAGE_OPTIONS" "$a is not set in \$PACKAGE_OPTIONS"
4346 out|output)
4348 pth) is pth $a
4349 pkg $pth
4350 tab=" "
4353 for i in $pth
4354 do case $i in
4355 '{') e="${nl}}"
4358 v="\$${x}"
4359 t=${nl}${tab}
4360 b="fnd()${nl}{${t}for ${x} in"
4362 '}') b="${b}${t}do${tab}if $exists ${v}/\${1}${t}${tab}${tab}then${tab}f=${v}/\${1}${t}${tab}${tab}${tab}return${t}${tab}${tab}fi"
4363 e="${t}done${e}"
4364 eval "${b}${e}"
4365 fnd $a
4366 case $f in
4367 ?*) break ;;
4368 esac
4370 -) b="${b}${t}do${tab}test \"${v}\" = '' -o -d \"${v}\" &&${t}${tab}${tab}"
4371 x=${x}i
4372 v="${v}\$${x}"
4373 b="${b}for ${x} in"
4374 e="${t}done${e}"
4375 t="${t}${tab}${tab}"
4377 *) case $e in
4378 '') if $exists ${i}/${a}
4379 then f=${i}/${a}
4380 break
4383 *) case $i in
4384 /|.) b="${b} ''" ;;
4385 *) b="${b} /${i}" ;;
4386 esac
4388 esac
4390 esac
4391 done
4392 case $f in
4393 '') case $set in
4394 ' ') f=$a ;;
4395 ?*) f=$set ;;
4396 esac
4398 esac
4399 case $f in
4400 '') c=1
4402 *) c=0
4403 f="\"$f\""
4405 esac
4406 report $c "$f" "${note:-$a path}" "$a path not found"
4408 run) is run $a
4409 if test ! -r $a
4410 then failure not found
4411 case $verbose in
4412 0) echo "$command: $file$line: $a: not found" >&$stderr ;;
4413 esac
4414 exit 1
4416 noisy
4417 case $a in
4418 *.c) rm -f $tmp.exe
4420 grep '^#include.*iffe --include-first' $a
4421 echo "$tst
4422 $ext
4423 $std
4424 $usr
4425 $inc"
4426 grep -v '^#include.*iffe --include-first' $a
4427 } > $tmp.c
4428 compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$stderr 2>&$stderr &&
4429 $executable $tmp.exe &&
4430 execute $tmp.exe $opt <&$nullin
4432 *.sh) {
4433 copy - ":
4434 set \"cc='$cc' executable='$executable' id='$m' static='$static' tmp='$tmp'\" $opt $hdr $test"
4435 cat $a
4436 } > $tmp.sh
4437 chmod +x $tmp.sh
4438 ( . $tmp.sh ) <&$nullin
4440 *) false
4442 esac
4443 case $? in
4444 0) success
4446 *) failure cannot run
4447 case $verbose in
4448 0) echo "$command: $file$line: $a: cannot run" >&$stderr ;;
4449 esac
4450 exit 1
4452 esac
4454 siz) case $p in
4455 "") x= ;;
4456 *) x="$p " ;;
4457 esac
4458 is siz "$x$v"
4460 case $p:$v in
4461 long:*|*:*[_0123456789]int[_0123456789]*)
4462 echo "$pre
4463 $tst
4464 $ext
4465 $inc
4466 static $x$v i;
4467 $x$v f() {
4468 $x$v v; i = 1; v = i;"
4469 echo "i = v * i; i = i / v; v = v + i; i = i - v;"
4470 case $v in
4471 float|double) ;;
4472 *) echo "v <<= 4; i = v >> 2; i = 10; i = v % i; i |= v; v ^= i; i = 123; v &= i;" ;;
4473 esac
4474 echo "return v; }"
4476 *) echo "$pre
4477 $inc
4478 struct xxx { $x$v mem; };
4479 static struct xxx v;
4480 struct xxx* f() { return &v; }"
4482 esac
4483 case $x in
4484 ""|"struct "|"union ")
4485 echo "int g() { return 0; }"
4487 *) echo "int g() { return sizeof($x$v)<=sizeof($v); }" ;;
4488 esac
4489 copy - "
4490 int main() {
4491 f();
4492 g();
4493 printf(\"%u\\n\", sizeof($x$v));
4494 return 0;
4496 } > $tmp.c
4497 rm -f $tmp.exe $tmp.dat
4498 if compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout &&
4499 $executable $tmp.exe &&
4500 execute $tmp.exe > $tmp.dat
4501 then z=`cat $tmp.dat`
4503 else z=0
4506 report $c "$z" "sizeof($x$v)" "$x$v not a type with known size"
4508 sym) case $test in
4509 "") x=$v ;;
4510 *) x=$test ;;
4511 esac
4512 echo "$pre
4513 $tst
4514 $ext
4515 $inc
4516 '=' $x '='" > $tmp.c
4517 compile $cc -E $tmp.c <&$nullin \
4518 | sed \
4519 -e "/'='/!d" \
4520 -e "s/'='//g" \
4521 -e 's/[ ]//g' \
4522 -e 's/((([^()]*)))->/->/g' \
4523 -e 's/(([^()]*))->/->/g' \
4524 -e 's/([^()]*)->/->/g' \
4525 -e 's/\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\)\[/\
4526 ary \1[/g' \
4527 -e 's/\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\)(/\
4528 fun \1[/g' \
4529 -e 's/\*->\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]\)/->\
4530 ptr \1/g' \
4531 -e 's/->\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]\)/->\
4532 reg \1/g' \
4533 -e "/^$v\$/d" \
4534 -e 's/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$/\
4535 nam &/g' \
4536 | sed \
4537 -e '/^... /!d' \
4538 | LC_ALL=C sort \
4539 -u \
4540 | sed \
4541 -e 's/\(...\) \([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\).*/#ifndef _\1_'$v'\
4542 #define _\1_'$v' \2\
4543 #define _\1_'$v'_str "\2"\
4544 #endif/'
4546 typ) case $p in
4547 "") x= r='*' ;;
4548 *) x="$p " r= ;;
4549 esac
4550 is typ "$x$v"
4552 case $p:$v in
4553 long:*|*:*[_0123456789]int[_0123456789]*)
4554 echo "$pre
4555 $tst
4556 $ext
4557 $inc
4558 static $x$v i;
4559 $x$v f() {
4560 $x$v v; i = 1; v = i;"
4561 echo "i = v * i; i = i / v; v = v + i; i = i - v;"
4562 case $v in
4563 float|double) ;;
4564 *) echo "v <<= 4; i = v >> 2; i = 10; i = v % i; i |= v; v ^= i; i = 123; v &= i;" ;;
4565 esac
4566 echo "return v; }"
4568 *) echo "$pre
4569 $tst
4570 $ext
4571 $inc
4572 struct xxx { $x$v$r mem; };
4573 static struct xxx v;
4574 struct xxx* f() { return &v; }"
4576 esac
4577 case $x in
4578 ""|"struct "|"union ")
4579 echo "int main() { f(); return 0; }" ;;
4580 *) echo "int main() { f(); return sizeof($x$v)<=sizeof($v); }" ;;
4581 esac
4582 } > $tmp.c
4583 rm -f $tmp.exe
4584 compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout &&
4585 $executable $tmp.exe &&
4586 execute $tmp.exe
4587 report $? 1 "$x$v is a type" "$x$v is not a type" "default for type $x$v"
4589 val) case $arg in
4590 '"'*'"')echo $arg=\'$val\' ;;
4591 *) echo $arg=\"$val\" ;;
4592 esac
4594 ver) ;;
4595 0) result=FAILURE
4597 1) result=SUCCESS
4599 :) ;;
4600 -) ;;
4601 *) echo "$command: $file$line: $o: unknown feature test" >&$stderr
4602 status=1
4604 esac
4605 done
4606 done
4607 case $not in
4608 1) case $result in
4609 FAILURE) result=SUCCESS ;;
4610 *) result=FAILURE ;;
4611 esac
4613 esac
4614 case $result in
4615 FAILURE) user_pf=$fail user_yn=$no ;;
4616 *) user_pf=$pass user_yn=$yes ;;
4617 esac
4618 case $user_pf in
4619 ?*) eval "$user_pf" <&$nullin ;;
4620 esac
4621 case $user_yn in
4622 ?*) case $def in
4623 -) ;;
4624 *) case $note in
4625 ?*) case $user_yn in
4626 *$nl*) user_yn="/* $note */$nl$user_yn" ;;
4627 *) user_yn="$user_yn /* $note */" ;;
4628 esac
4630 esac
4632 esac
4633 copy - "$user_yn"
4635 esac
4636 case $ifelse:$result in
4637 TEST:SUCCESS) ifelse=KEEP ;;
4638 TEST:*) ifelse=SKIP ;;
4639 esac
4640 case $group:$result in
4641 :*|*:SUCCESS) break ;;
4642 esac
4643 set '' $groups '' "$@"
4644 shift
4645 case $1 in
4646 '') shift; break ;;
4647 esac
4648 shift
4650 # set up and try the next group
4652 hdr=$com_hdr
4653 lib=$com_lib
4654 mac=$com_mac
4655 opt=$com_opt
4656 pth=$com_pth
4657 test=$com_test
4658 cc="$occ $includes"
4659 group=
4660 groups=
4661 while :
4662 do case $1 in
4663 '') shift; break ;;
4664 esac
4665 case $1 in
4666 *[\"\'\(\)\{\}\ \ ]*)
4667 case $op in
4668 pth) pth="$pth $1"
4670 *) case $test in
4671 '') test=$1 ;;
4672 *) test="$test $1" ;;
4673 esac
4675 esac
4677 -) group=$group$1
4678 groups="$groups $1"
4680 -l*) case $group in
4681 -*) groups="$groups $1" ;;
4682 *) lib="$lib $1" ;;
4683 esac
4685 +l*) case $shell in
4686 bsh) x=`echo X$1 | sed 's/X+/-/'` ;;
4687 *) eval 'x=-${1#+}' ;;
4688 esac
4689 case $group in
4690 -*) groups="$groups $x" ;;
4691 *) lib="$lib $x" ;;
4692 esac
4694 -*|+*) case $group in
4695 -*) groups="$groups $1"
4697 *) case $op in
4698 run) opt="$opt $1"
4700 *) case $1 in
4701 -D*) mac="$mac $1" ;;
4702 *) cc="$cc $1" ;;
4703 esac
4705 esac
4707 esac
4709 *.[aAxX]|*.[dD][lL][lL]|*.[lL][iI][bB])
4710 case $group in
4711 -*) groups="$groups $1" ;;
4712 *) lib="$lib $1" ;;
4713 esac
4715 *[.\\/]*)
4716 case $group in
4717 -*) groups="$groups $1"
4719 *) case $op in
4720 pth) pth="$pth $1" ;;
4721 *) hdr="$hdr $1" ;;
4722 esac
4724 esac
4726 *) case $group in
4727 -*) groups="$groups $1"
4729 *) case $op in
4730 pth) pth="$pth $1"
4732 *) case $test in
4733 '') test=$1 ;;
4734 *) test="$test $1" ;;
4735 esac
4737 esac
4739 esac
4741 esac
4742 shift
4743 done
4744 done
4745 done