xref: /titanic_50/usr/src/lib/libpp/common/pp.probe (revision 9584cebb1c69707f4c67306b661c2ed47d8676f1)
1:
2# Glenn Fowler
3# AT&T Research
4#
5# @(#)pp.probe (AT&T Research) 2009-02-02
6#
7# C probe for libpp
8#
9# NOTE: C.probe must be included or .'d here
10#
11
12ppdef=$dir/pp.def
13ppkey=$dir/pp.key
14ppsym=$dir/ppsym
15for f in $ppdef $ppkey $ppsym
16do	test -f $f || { echo "$0: $f: not found" >&4; exit 1 ;}
17done
18
19sed -e "/^#/d" -e "s/[ 	].*//" < $ppdef > all.pp
20
21system=
22release=
23version=
24architecture=
25cpu=
26model=
27machine=
28undef_predef=
29
30#
31# path cleanup
32#
33
34for i in stdinclude usrinclude
35do	eval o='$'$i
36	v=$o
37	case $v in
38	*//*)	v=`echo $v | sed 's,///*,/,g'` ;;
39	esac
40	if	(test . -ef "`pwd`")
41	then	k=
42		for x in $v
43		do	case $x in
44			*/../*|*/..)
45				case $x in
46				/*)	a=/ ;;
47				*)	a= ;;
48				esac
49				IFS=/
50				set '' $x
51				IFS=$ifs
52				r=
53				for d
54				do	r="$d $r"
55				done
56				p=
57				g=
58				for d in $r
59				do	case $d in
60					..)	g="$g $d" ;;
61					*)	case $g in
62						'')	case $p in
63							'')	p=$d ;;
64							*)	p=$d/$p ;;
65							esac
66							;;
67						*)	set $g
68							shift
69							g=$*
70							;;
71						esac
72						;;
73					esac
74				done
75				case $a in
76				'')	for d in $g
77					do	p=$d/$p
78					done
79					;;
80				*)	p=$a$p
81					;;
82				esac
83				case $p in
84				/)	continue ;;
85				esac
86				test $x -ef $p && x=$p
87				;;
88			esac
89			k="$k $x"
90		done
91		set '' $k
92		shift
93		v=$1
94		case $# in
95		0)	;;
96		*)	shift
97			while	:
98			do	case $# in
99				0)	break ;;
100				esac
101				k=
102				for d
103				do	for j in $v
104					do	test $d -ef $j && continue 2
105					done
106					k="$k $d"
107				done
108				set '' $k
109				case $# in
110				1)	break ;;
111				esac
112				shift
113				v="$v $1"
114				shift
115			done
116			;;
117		esac
118	fi
119	case $v in
120	$o)	;;
121	*)	eval $i='$'v ;;
122	esac
123done
124
125id="::IDENT::`date`::IDENT::"
126echo '#assert test(ok)
127#if #test(ok)
128#else
129(
130#endif' > assert.$src
131echo '#ifdef __BASE_FILE__
132int ok;
133#else
134(
135#endif' > basefile.$src
136cat > catlit1.i <<'!'
137char test[] = "te"
138"st";
139!
140cat > catlit2.i <<'!'
141char test[] = "te\
142st";
143!
144echo '#define g(a,b) a ## b
145volatile int a;
146const int g(x,y)=1;
147extern int c(int);' > compat.$src
148echo > cpp.$src
149echo "#defincl <x.h>" > defincl.$src
150echo 'int a$b;' > dollar.$src
151echo "#eject" > eject.$src
152echo "#if 0
153(
154#else if 1
155int x;
156#else
157(
158#endif" > elseif.$src
159echo "#define _CAT(a,b,c) a##b##c
160#define hdra	hdrx
161#define hdr	_CAT(<,hdra,.h>)
162#include hdr" > hdra.$src
163echo "#define _XAT(a,b,c) a##b##c
164#define _CAT(a,b,c) _XAT(a,b,c)
165#define hdra	hdrx
166#define hdr	_CAT(<,hdra,.h>)
167#include hdr" > hdrx.$src
168echo "int f(){return 0;}" > hdrx.h
169echo "#ident \"$id\"" > ident.$src
170echo "#import \"import.h\"" > import.$src
171echo "int aaa;" > import.h
172echo "#include <inc_next.h>" > inc_next.$src
173mkdir inc0 inc1
174echo "#include_next <inc_next.h>" > inc0/inc_next.h
175echo 'char s[] = "INCLUDE_NEXT";' > inc1/inc_next.h
176echo '# 1 "linefile.i"
177
178# 1 "linefile.i"
179
180int i;' > linefile1.i
181echo '# 1 "linefile.i"
182
183# 1
184
185int i;' > linefile2.i
186echo "int i = 0;" > lineid1.i
187echo '# 1 "t.c"
188int i = 0;' > lineid2.i
189echo '# 1 "t.c"
190int i = 0;' > lineid3.$src
191echo "#include <stdio.h>" > linetype.$src
192echo '#include <sys/types.h>
193main()
194{
195	return sizeof(LONGLONG) != 8;
196}' > longlong.$src
197echo '#include "once.h"
198#include "once.h"' > once.$src
199echo '#ifdef once
200allmultiple
201#else
202#define once
203#endif' > once.h
204echo "extern int a,b;int f(){return a + = b;}" > opspace.$src
205echo "int f(){return(0);} // ((" > pluscom.$src
206echo "class x {int n;} m;" > plusplus.$src
207echo > preinc.$src
208echo '// splice \
209(
210int x = 1;' > plusspl.$src
211echo "int stdc_default_value = __STDC__ ;" > stdc.$src
212echo 'char xxx[] = "abc
213(";' > span.$src
214echo '#define g(a,b) a\
215b
216int ab,xy;
217#define xy XY
218char* g(x,y);' > splice.$src
219{
220echo 'int a\                        '
221echo 'b = 1;'
222} > splicesp.$src
223echo '#define g(a,b) a/**/b
224int g(x,y)=1;' > trans.$src
225echo '#define m 65
226#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 65
227#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 64
228#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 63
229#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62
230#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61
231#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 60
232#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 59
233#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 58
234#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 57
235#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 56
236#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 55
237#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 54
238#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 53
239#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 52
240#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 51
241#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
242#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 49
243#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 48
244#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 47
245#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 46
246#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 45
247#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 44
248#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 43
249#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42
250#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 41
251#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 40
252#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 39
253#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 38
254#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 37
255#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 36
256#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 35
257#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 34
258#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 33
259#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 32
260#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 31
261#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 30
262#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 29
263#define xxxxxxxxxxxxxxxxxxxxxxxxxxxx 28
264#define xxxxxxxxxxxxxxxxxxxxxxxxxxx 27
265#define xxxxxxxxxxxxxxxxxxxxxxxxxx 26
266#define xxxxxxxxxxxxxxxxxxxxxxxxx 25
267#define xxxxxxxxxxxxxxxxxxxxxxxx 24
268#define xxxxxxxxxxxxxxxxxxxxxxx 23
269#define xxxxxxxxxxxxxxxxxxxxxx 22
270#define xxxxxxxxxxxxxxxxxxxxx 21
271#define xxxxxxxxxxxxxxxxxxxx 20
272#define xxxxxxxxxxxxxxxxxxx 19
273#define xxxxxxxxxxxxxxxxxx 18
274#define xxxxxxxxxxxxxxxxx 17
275#define xxxxxxxxxxxxxxxx 16
276#define xxxxxxxxxxxxxxx 15
277#define xxxxxxxxxxxxxx 14
278#define xxxxxxxxxxxxx 13
279#define xxxxxxxxxxxx 12
280#define xxxxxxxxxxx 11
281#define xxxxxxxxxx 10
282#define xxxxxxxxx 9
283#define xxxxxxxx 8
284#define xxxxxxx 7
285#define xxxxxx 6
286#define xxxxx 5
287#define xxxx 4
288#define xxx 3
289#define xx 2
290#define x 1
291#if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx != m
292xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
293#endif' > truncate.$src
294cat > zeof.c <<'!'
295char* foo = "az";
296!
297
298allmultiple=
299assert=
300basefile=
301compatibility=1
302defincl=
303dollar=
304eject=
305elseif=
306headerexpand=
307headerexpandall=
308hostedtransition=
309ident=
310import=
311include_next=
312linefile=
313lineid=
314linetype=
315nocatliteral=
316opspace=
317pluscom=
318plusplus=
319plussplice=
320redef=
321reguard=
322reserved=
323spaceout=
324splicecat=
325splicespace=
326strict=
327stringspan=
328transition=
329truncate=
330zeof=
331
332$cc -c assert.$src && assert=1
333
334$cc -c basefile.$src && basefile=__BASE_FILE__
335
336if	$cc -E defincl.$src
337then	case "`$cc -E defincl.$src | grep -c 'defincl'`" in
338	0)	defincl=1 ;;
339	esac
340fi
341
342if	$cc -c catlit1.i 2>e
343then	if	$cc -c catlit2.i 2>f
344	then	if	test `wc -c < f` -gt `wc -c < e`
345		then	nocatliteral=1
346		fi
347	else	nocatliteral=1
348	fi
349fi
350
351$cc -c dollar.$src && dollar=1
352
353$cc -c elseif.$src && elseif=1
354
355if	$cc -I. -c hdra.$src
356then	headerexpandall=1
357elif	$cc -I. -c hdrx.$src
358then	headerexpand=1
359fi
360
361if	$cc -E eject.$src
362then	case "`$cc -E eject.$src | grep -c 'eject'`" in
363	0)	eject=1 ;;
364	esac
365fi
366
367$cc -S ident.$src && grep "$id" ident.s && ident=1
368
369{ $cc -E import.$src | grep aaa ;} && import=1
370
371{ $cc -E -Iinc0 -Iinc1 inc_next.$src | grep INCLUDE_NEXT ;} && include_next=1
372
373if	$cc -c linefile1.i
374then	$cc -c linefile2.i
375	case $? in
376	0)	;;
377	*)	linefile=1 ;;
378	esac
379fi
380
381if	$cc -c lineid1.i 2>b
382then	$cc -c lineid2.i 2>e
383	c=$?
384else	$cc -c lineid3.c 2>e
385	c=$?
386fi
387case $c in
3880)	case `wc -l < b` in
389	`wc -l < e`)	;;
390	*)		lineid=line ;;
391	esac
392	;;
393*)	lineid=line
394	;;
395esac
396
397if	$cc -E linetype.$src | grep '^[ 	]*#[ 	]*[0123456789]*[ 	]*".*"[ 	]*[12]' > linetype
398then	if	grep '^[ 	]*#[ 	]*[0123456789]*[ 	]*".*"[ 	]*[12][ 	][ 	]*3' linetype
399	then	linetype=2
400	else	linetype=1
401	fi
402fi
403
404{ $cc -E once.$src | grep allmultiple ;} && allmultiple=1
405
406$cc -c plusplus.$src && plusplus=1
407
408$cc -c span.$src && stringspan=1
409
410$cc -c splice.$src && splicecat=1
411
412$cc -c splicesp.$src && splicespace=1
413
414exec < $ppkey
415while	read keyword type alternate comment
416do	case $keyword in
417	.)	break ;;
418	""|"#")	continue ;;
419	esac
420	case $type in
421	""|".")	type= ;;
422	*)	type="=$type" ;;
423	esac
424	for pre in '' _ __
425	do	for suf in '' _ __
426		do	case $suf in
427			'')	sep= ;;
428			*)	sep=. ;;
429			esac
430			case ,,$alternate, in
431			*,$pre$sep$suf,*)
432				key=$pre$keyword$suf
433				undef="$undef $key"
434				echo "int f(){
435	int	$key = 0;
436	return $key;
437}
438#undef	$key
439int g(){
440	int	$key = 0;
441	return $key;
442}" > key.$src
443				$cc -c key.$src >/dev/null 2>&1 || reserved="$reserved $key$type"
444				;;
445			esac
446		done
447	done
448done
449
450$cc -c opspace.$src && opspace=1
451
452case $plusplus in
453"")	$cc -c compat.$src && compatibility=
454	$cc -c pluscom.$src && pluscom=1
455	;;
456esac
457case $plusplus$pluscom in
458?*)	$cc -c plusspl.$src || plussplice=1 ;;
459esac
460case $plusplus in
461?*)	mkdir reguard
462	cd reguard
463	echo '#include "ptrone.h"
464#include "ptrdef.h"
465int main () { return gt(2,1) + gt(2.0,1.0); }' > ptr.$src
466	echo '#include "ptrone.h"
467template<class T> int gt(T a, T b) { return a > b; }' > ptrdef.$src
468	echo 'template<class T> int gt(T a, T b);' > ptrdef.h
469	echo '/* empty */' > ptrone.h
470	if	$cc -E ptr.$src > x.i && $cc x.i
471	then	echo '#ifndef _PTRONE_H
472#define _PTRONE_H
473static int xxx;
474#endif' > ptrone.h
475		if	$cc -E ptr.$src > x.i && echo "#define _PTRONE_H" >> x.i && $cc x.i
476		then	reguard=1
477		fi
478	fi
479	cd ..
480	rm -rf reguard
481	;;
482esac
483
484stdc=`$cc -E stdc.$src | sed -e '/stdc_default_value/!d' -e 's/.*=[ 	]*//' -e 's/[ 	]*;.*//'`
485case $stdc in
4860)		$cc -c trans.$src && transition=1 ;;
487[0123456789]*)	;;
488*)		stdc= ;;
489esac
490
491truncate=`$cc -E truncate.$src | grep '^[ 	]*[0123456789]'`
492$cc -c zeof.c || zeof=1
493
494echo "$predef" >> all.pp
495{
496	case $ppopt$ppenv in
497	?*)	ppcmd=cpp
498		ppdir=.
499		eval $ppenv '$'cc -Dmycpp -E '$'ppopt cpp.$src
500		;;
501	esac
502	eval set x $probe_verbose
503	shift
504	x=
505	for o in "$@"
506	do	set x `$cc $o -c cpp.$src 2>&1`
507		while	:
508		do	shift
509			case $# in
510			0)	break ;;
511			esac
512			case $1 in
513			*[\\/]rm)
514				;;
515			[\\/]*)	case " $x " in
516				*" $1 "*)	;;
517				*)		test -x $1 && x="$x $1" ;;
518				esac
519				;;
520			esac
521		done
522		case $x in
523		?*)	for f in $x
524			do	cp $f x && chmod u+w x && strip x && f=x
525				$ppsym < $f
526			done
527			break
528			;;
529		esac
530	done
531} 3>&- 3>&1 >/dev/null |
532	sed -e '/^ppsymbol$/d' -e '/^.$/d' -e '/^..$/d' -e '/[ABCDEFGHIJKLMNOPQRSTUVWXYZ].*[abcdefghijklmnopqrstuvwxyz]/d' -e '/[abcdefghijklmnopqrstuvwxyz].*[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/d' |
533	cat - all.pp |
534	sort -u |
535	{
536	for i in 0 1 2 3 4 5
537	do	echo "struct { char* name; long value; } predef[] = {" > cpp$i.$src
538	done
539	while read sym junk
540	do	case $sym in
541		_*)	set 0 ${sym}
542			;;
543		*_)	continue
544			;;
545		[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
546			set 1 ${sym} 2 _${sym} 3 _${sym}_ 4 __${sym} 5 __${sym}__
547			;;
548		*)	continue
549			;;
550		esac
551		while	:
552		do	case $# in
553			0|1)	break ;;
554			esac
555			{
556			echo "#ifdef $2"
557			echo "\"$2\" , (long) $2 -1,"
558			echo "#endif"
559			} >> cpp$1.$src
560			shift
561			shift
562		done
563	done
564	for i in 0 1 2 3 4 5
565	do	echo "\"\", 0 };" >> cpp$i.$src
566	done
567	}
568preval="`for i in 0 1 2 3 4 5;do $cc -E cpp$i.$src;done | sed -e '/\".*\".*,.*,/!d' -e 's/[^\"]*\"\\([^\"]*\\)\"[ 	]*,[ 	]*([ 	]*long[ 	]*)[ 	]*\\(.*\\)[ 	]*-[ 	]*1[ 	]*,[ 	]*\$/\\1 \\2 =/g'` `$cc -dM -E stdc.$src | sed -e '/[ 	]*#[ 	]*define/!d' -e '/\"/d' -e 's/[ 	]*#[ 	]*define[ 	]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*\\)[ 	]*\\(.*\\)/\\1 \\2 =/'`"
569
570for i in bufld namei quota reboot utsname vfs
571do	echo "#include <sys/$i.h>" > t.$src
572	if	$cc -E t.$src
573	then	x=1
574	else	x=0
575	fi
576	eval sys_$i=$x
577done
578
579echo "char* fun() { return (char*)__FUNCTION__; }
580int main() { return !fun(); }" > fun.$src
581rm -f fun.exe
582if	$cc -o fun.exe fun.$src && test -x fun.exe
583then	undef_predef="$undef_predef __FUNCTION__"
584fi
585
586case "`grep -c '__STDC__[-0 	]*[=!]=[ 	]*0' $usrinclude/stdio.h 2>/dev/null`" in
5870)	;;
588*)	hostedtransition=1 ;;
589esac
590
591mapinclude=
592for i in builtins
593do	echo "#include <$i.h>" > t.$src
594	if	$cc -E t.$src
595	then	mapinclude="$mapinclude <$i.h>=\".\""
596	fi
597done
598
599#
600# the payoff
601#
602
603exec >&3
604
605case "$compatibility:$transition:$dollar" in
606::)	strict=1 ;;
607esac
608case $version_stamp in
609?*)	echo "/* $version_stamp" ;;
610*)	echo "/* $cc" ;;
611esac
612echo "*/"
613case $plusplus:$stdc in
6141:?*)	preval="$preval = __STDC__ $stdc ="
615	redef="$redef __STDC__"
616	;;
617esac
618ppbuiltin=0
619set x $preval
620shift
621case $# in
6220)	;;
623*)	echo
624	echo "#pragma pp:predefined"
625	predef=
626	while	:
627	do	case $# in
628		0)	break ;;
629		esac
630		m=$1
631		shift
632		case $m in
633		*'('*)	i=`echo "$m" | sed 's,(.*,,'` ;;
634		*)	i=$m ;;
635		esac
636		predef="$predef
637$i"
638		eval predef_$i=0
639		while	:
640		do	case $1 in
641			'=')	break ;;
642			*)	shift ;;
643			esac
644		done
645		while	:
646		do	case $1 in
647			'=')	shift ;;
648			*)	break ;;
649			esac
650		done
651	done
652	for i in $undef
653	do	case " $redef " in
654		*" $i "*)	;;
655		*)		eval predef_$i=3 ;;
656		esac
657	done
658	set $preval
659	while	:
660	do	case $# in
661		0)	break ;;
662		esac
663		m=$1
664		shift
665		case $m in
666		*'('*)	i=`echo "$m" | sed 's,(.*,,'` ;;
667		*)	i=$m ;;
668		esac
669		case $i in
670		'=')	continue ;;
671		esac
672		v=
673		while	:
674		do	case $1 in
675			'=')	break ;;
676			esac
677			v="$v $1"
678			shift
679		done
680		while	:
681		do	case $1 in
682			'=')	shift ;;
683			*)	break ;;
684			esac
685		done
686		case $i in
687		__LCC__)strict=2 ;;
688		_*)	;;
689		*)	eval j=\$predef_$i
690			case $j in
691			0)	eval predef_$i=1
692				echo "#define $m$v"
693				case $strict in
694				1)	strict= ;;
695				esac
696				;;
697			esac
698			;;
699		esac
700	done
701	nopredef=0
702	while	:
703	do	set $preval
704		while	:
705		do	case $# in
706			0)	break ;;
707			esac
708			m=$1
709			shift
710			case $m in
711			*'('*)	i=`echo "$m" | sed 's,(.*,,'` ;;
712			*)	i=$m ;;
713			esac
714			v=
715			while	:
716			do	case $1 in
717				'=')	break ;;
718				esac
719				v="$v $1"
720				shift
721			done
722			while	:
723			do	case $1 in
724				'=')	shift ;;
725				*)	break ;;
726				esac
727			done
728			case $nopredef in
729			2)	;;
730			*)	case $v in
731				' '*' '*)
732					nopredef=1
733					continue
734					;;
735				' '[0123456789]*|' '"'"*"'"*)
736					;;
737				*)	case $1 in
738					_*)	;;
739					*)	nopredef=1
740						continue
741						;;
742					esac
743					;;
744				esac
745				;;
746			esac
747			eval j=\$predef_$i
748			case $j in
749			0)	case $ppbuiltin in
750				2)	echo "#pragma pp:builtin"
751					ppbuiltin=1
752					;;
753				esac
754				eval predef_$i=2
755				echo "#define $m$v"
756				;;
757			1)	case $m in
758				$i)	eval predef_$i=2
759					eval j=\$predef___${i}__
760					case $j in
761					[12])	;;
762					*)	case $ppbuiltin in
763						2)	echo "#pragma pp:builtin"
764							ppbuiltin=1
765							;;
766						esac
767						eval predef___${i}__=2
768						echo "#define __${i}__$v"
769						;;
770					esac
771					;;
772				esac
773				;;
774			esac
775		done
776		case $nopredef in
777		2)	break ;;
778		esac
779		echo "#pragma pp:nopredefined"
780		case $nopredef in
781		0)	break ;;
782		esac
783		ppbuiltin=2
784		nopredef=2
785	done
786	;;
787esac
788case $basefile in
789?*)	case $ppbuiltin in
790	0|2)	ppbuiltin=1
791		echo "#pragma pp:builtin"
792		;;
793	esac
794	echo "#define $basefile	#(BASE)"
795	;;
796esac
797case $ppbuiltin in
7981)	echo "#pragma pp:nobuiltin" ;;
799esac
800
801eval set x $probe_longlong
802shift
803x=
804for o in "$@"
805do	rm -f longlong.$exe
806	if	$cc -DLONGLONG="$o" -o longlong.$exe longlong.$src &&
807		./longlong.$exe
808	then	x=1
809		break
810	fi
811done
812case $x in
813'')	eval set x $probe_longlong_t
814	shift
815	for o in "$@"
816	do	rm -f longlong.$exe
817		if	$cc -DLONGLONG="$o" -o longlong.$exe longlong.$src &&
818			./longlong.$exe
819		then	echo "#define <long long> $o"
820			break
821		fi
822	done
823	;;
824esac
825
826echo
827for i in `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*[0123456789][abcdefghijklmnopqrstuvwxyz0123456789]*\$/!d'` `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*\$/!d'`
828do	case $i in
829	*ix)	;;
830	*)	architecture=$i
831		break
832		;;
833	esac
834done
835for i in `sed -e '/^#/d' -e '/:architecture:/!d' -e 's/[ 	].*//' < $ppdef`
836do	eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \""
837	case $j in
838	*" 2 "*)architecture=$i
839		break
840		;;
841	esac
842done
843for i in `sed -e '/^#/d' -e '/:machine:/!d' -e 's/[ 	].*//' < $ppdef`
844do	eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \""
845	case $j in
846	*" 2 "*)machine="$machine $i" ;;
847	esac
848done
849case $sys_bufld$sys_reboot$sys_utsname in
8501??)	release=research
851	version=9
852	;;
85301?)	release=bsd
854	case $sys_quota in
855	0)	case $sys_vfs in
856		0)	version=4.1
857			;;
858		esac
859		;;
860	1)	case $sys_namei in
861		0)	version=4.2
862			;;
863		1)	version=4.3
864			;;
865		esac
866		;;
867	esac
868	;;
869001)	release=V
870	;;
871esac
872for i in `sed -e '/^#/d' -e '/:release:/!d' -e 's/[ 	].*//' < $ppdef`
873do	eval j=\$predef_$i
874	case $j in
875	2)	release="$release $i" ;;
876	esac
877done
878for i in `sed -e '/^#/d' -e '/:system:/!d' -e 's/[ 	].*//' < $ppdef`
879do	eval j=\$predef_$i
880	case $j in
881	2)	system="$system $i" ;;
882	esac
883done
884case $release in
885topix)	release="$release V"
886	;;
887esac
888case $assert in
889?*)	for i in $predef
890	do	case $i in
891		_*|*_)	;;
892		*)	for p in architecture cpu machine system
893			do	echo "#if #$p($i)
894eval \"case \\\" \$$p \\\" in *\\\" $i \\\"*) ;; *) $p=\\\"$i \$$p\\\" ;; esac\"
895: avoid string literal concatenation
896#endif"
897			done
898			;;
899		esac
900	done > t.$src
901	eval "`$cc -E t.$src`"
902	set x x $prepred
903	while	:
904	do	shift
905		shift
906		case $# in
907		[01])	break ;;
908		esac
909		eval "
910			case \" \$$1 \" in
911			*\" $2 \"*) ;;
912			*) $1=\"$2 \$$1\" ;;
913			esac
914		"
915	done
916	;;
917esac
918case $system in
919"")	system=unix ;;
920esac
921case $architecture in
922ibm|uts|u370)	model=370
923		architecture=ibm
924		;;
925m*68*)		architecture=m68000
926		for i in $predef
927		do	case $i in
928			m*68*[123456789][0123456789])
929				model=`echo $i | sed 's/.*\(..\)/\1/'`
930				break
931				;;
932			esac
933		done
934		;;
935u3b?*)		model=`echo $architecture | sed 's/u3b//'`
936		architecture=3b
937		;;
938u3b)		case $model in
939		"")	model=20 ;;
940		esac
941		architecture=3b
942		;;
943vax[0123456789]*)
944		model=`echo $architecture | sed 's/vax//'`
945		architecture=vax
946		;;
947hp[0123456789]*s[0123456789])
948		case $release in
949		[abcdefghijklmnopqrstuvwxyz]*.[abcdefghijklmnopqrstuvwxyz]*.*)
950			version=$release
951			release=V
952			;;
953		esac
954		architecture="$architecture `echo $architecture | sed 's/s.*//'`"
955		;;
956esac
957case $hosttype in
958*.*)	i=`echo $hosttype | sed -e 's,.*\.,,'` ;;
959*)	i=$hosttype ;;
960esac
961case $i in
962unknown);;
963?*)	case " $architecture " in
964	*" $i "*) ;;
965	*)	architecture="$architecture $i" ;;
966	esac
967	;;
968esac
969case $architecture in
970"")	echo "$cc: warning: architecture not determined" >&4
971	set x $machine
972	architecture=$2
973	;;
974esac
975echo "#define #hosttype($hosttype)"
976for i in $system
977do	echo "#define #system($i)"
978done
979case $release in
980"")	echo "#define #release()" ;;
981*)	for i in $release
982	do	echo "#define #release($i)"
983		case $i in
984		V)	echo "#define #release(system5)" ;; # compatibility
985		esac
986	done
987	;;
988esac
989echo "#define #version($version)"
990case $architecture in
991"")	echo "#define #architecture()" ;;
992*)	for i in `echo $architecture | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
993	do	echo "#define #architecture($i)"
994	done
995	;;
996esac
997echo "#define #model($model)"
998case $machine in
999"")	case $architecture:$model in
1000	?*:?*)	set x $architecture; machine="$2/$model $architecture" ;;
1001	*)	machine=$architecture ;;
1002	esac
1003	;;
1004*)	machine="$machine $architecture"
1005	;;
1006esac
1007case $machine in
1008"")	echo "#define #machine()" ;;
1009*)	j=
1010	for i in `echo $machine | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
1011	do	case " $i " in
1012		*" $j "*)
1013			;;
1014		*)	j="$j $i"
1015			echo "#define #machine($i)"
1016			;;
1017		esac
1018	done
1019	;;
1020esac
1021for i in $cpu
1022do	echo "#define #cpu($i)"
1023done
1024echo "#define #addressing()"
1025for i in $ATTRIBUTES
1026do	eval d=\$$i
1027	n=`echo $i | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
1028	echo "#define #$n($d)"
1029done
1030case $stdc in
1031?*)	echo "#define #dialect(ansi)" ;;
1032esac
1033case $plusplus in
1034?*)	echo "#define #dialect(C++)" ;;
1035esac
1036case $hosted in
1037"")	echo "#define #dialect(cross)" ;;
1038esac
1039case $so:$dynamic:$static in
1040::)	;;
1041*)	echo "#define #dialect(dynamic)" ;;
1042esac
1043echo
1044case $undef_predef in
1045?*)	for m in $undef_predef
1046	do	echo "#undef	$m"
1047	done
1048	echo
1049	;;
1050esac
1051case $plusplus in
1052?*)	echo "#pragma pp:plusplus" ;;
1053esac
1054case $reserved in
1055?*)	echo "#pragma pp:reserved" $reserved ;;
1056esac
1057case $nocatliteral in
1058?*)	echo "#pragma pp:nocatliteral" ;;
1059esac
1060case $opspace in
1061?*)	echo "#pragma pp:opspace" ;;
1062esac
1063case $pluscom in
1064?*)	echo "#pragma pp:pluscomment" ;;
1065esac
1066case $plussplice in
1067?*)	echo "#pragma pp:plussplice" ;;
1068esac
1069case $reguard in
1070?*)	echo "#pragma pp:reguard" ;;
1071esac
1072case $splicecat in
1073?*)	echo "#pragma pp:splicecat" ;;
1074esac
1075case $splicespace in
1076?*)	echo "#pragma pp:splicespace" ;;
1077esac
1078case $stringspan in
1079?*)	echo "#pragma pp:stringspan" ;;
1080esac
1081case $stdc in
1082"")	echo "#pragma pp:compatibility"
1083	;;
10840)	echo "#pragma pp:transition"
1085	;;
10861)	case $strict in
1087	?*)	echo "#pragma pp:strict" ;;
1088	esac
1089	;;
1090esac
1091case $hostedtransition in
10921)	echo "#pragma pp:hostedtransition" ;;
1093esac
1094case $stdc in
1095?*)	case $ppopt$ppenv in
1096	"")	spaceout=1
1097		echo "#pragma pp:spaceout"
1098		;;
1099	esac
1100	;;
1101esac
1102case $truncate in
1103?*)	echo "#pragma pp:truncate $truncate" ;;
1104esac
1105case $zeof in
1106?*)	echo "#pragma pp:zeof" ;;
1107esac
1108case $dollar in
11091)	echo '#pragma pp:id "$"' ;;
1110esac
1111cdir=-I+C
1112hdir=-I+H
1113set x $stdinclude
1114while	:
1115do	shift
1116	case $# in
1117	0)	break ;;
1118	esac
1119	case $1 in
1120	$cdir|$hdir)
1121		;;
1122	-I+C)	cdir=$1
1123		echo "#pragma pp:nocdir"
1124		;;
1125	-I-C)	cdir=$1
1126		echo "#pragma pp:cdir"
1127		;;
1128	-I+H)	hdir=$1
1129		echo "#pragma pp:nohostdir"
1130		;;
1131	-I-H)	hdir=$1
1132		echo "#pragma pp:hostdir"
1133		;;
1134	-I*)	;;
1135	*)	echo "#pragma pp:include \"$1\""
1136		;;
1137	esac
1138done
1139case $usrinclude in
1140/usr/include)
1141	;;
1142?*)	echo "#pragma pp:standard \"$usrinclude\""
1143	;;
1144esac
1145case $plusplus in
1146?*)	case $usrinclude in
1147	?*)	if	grep plusplus $usrinclude/ctype.h >/dev/null 2>&1
1148		then	echo '#pragma pp:nocdir "-"'
1149		fi
1150		;;
1151	esac
1152	;;
1153esac
1154case $mapinclude in
1155?*)	echo "#pragma pp:mapinclude hosted$mapinclude" ;;
1156esac
1157case $linefile in
1158?*)	echo "#pragma pp:linefile" ;;
1159esac
1160case $lineid in
1161?*)	echo "#pragma pp:lineid line" ;;
1162esac
1163case $linetype in
11641)	echo "#pragma pp:linetype" ;;
1165?*)	echo "#pragma pp:linetype $linetype" ;;
1166esac
1167case $allmultiple in
1168"")	echo "#pragma pp:noallmultiple" ;;
1169esac
1170case $defincl in
11711)	echo '#pragma pp:map "/#(pragma )?defincl>/"' ;;
1172esac
1173case $eject in
11741)	echo '#pragma pp:map "/#(pragma )?eject>/"' ;;
1175esac
1176case $elseif in
11771)	echo "#pragma pp:elseif" ;;
1178esac
1179case $headerexpand in
11801)	echo "#pragma pp:headerexpand" ;;
1181esac
1182case $headerexpandall in
11831)	echo "#pragma pp:headerexpandall" ;;
1184esac
1185case $ident in
11861)	echo '#pragma pp:map "/#(pragma )?ident>/" "/#(pragma )?/###/"' ;;
1187*)	echo '#pragma pp:map "/#(pragma )?ident>/"' ;;
1188esac
1189case $import in
11901)	echo '#pragma pp:map "/#(pragma )?import>/" "/#(pragma )?import(.*)/__STDPP__IMPORT__(\2)/"
1191#macdef __STDPP__IMPORT__(x)
1192#pragma pp:noallmultiple
1193#include x
1194#pragma pp:allmultiple
1195#endmac' ;;
1196esac
1197case $include_next in
11981)	echo '#pragma pp:map "/#include_next>/" ",[^\<]*\<,#include <.../,"' ;;
1199esac
1200echo '#pragma pp:map "/#pragma lint:/" ",#pragma lint:(.*),##/*\1*/,u"'
1201echo '#pragma pp:map "/#(pragma )?sccs>/"'
1202
1203case $stdc:$spaceout in
12041:)	case ' '$reserved' ' in
1205	*' 'asm' '*|*' 'asm=*)
1206		echo "#macdef asm"
1207		echo "#pragma pp:spaceout"
1208		echo "#undef asm"
1209		echo "asm"
1210		echo "#endmac"
1211		;;
1212	esac
1213	;;
1214esac
1215
1216if	$cc -E preinc.$src > preinc.out
1217then	for f in `sed -e 's,\\\\,/,g' -e 's,"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]:/,"/,g' -e '/^#[line 	]*[0123456789][0123456789]*[ 	][ 	]*"[\\/]/!d' -e 's/^#[line 	]*[0123456789][0123456789]*[ 	][ 	]*".*[\\/]\(.*\)".*/\1/' preinc.out | sort -u`
1218	do	case $f in
1219		*preinc.$src*)
1220			;;
1221		*)	echo "#include <$f>"
1222			;;
1223		esac
1224	done
1225fi
1226