pp.probe revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
12b2ae689353ecbaad720a9af9f9be01c1a3fe2dChristian Maeder# Glenn Fowler
e071fb22ea9923a2a4ff41184d80ca46b55ee932Till Mossakowski# AT&T Research
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu# @(#)pp.probe (AT&T Research) 2012-02-29
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett# C probe for libpp
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblett# NOTE: C.probe must be included or .'d here
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettfor f in $ppdef $ppkey $ppsym
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillydo test -f $f || { echo "$0: $f: not found" >&4; exit 1 ;}
020cdb5dad6b871aba61136a0e1567c00426de87Andy Gimblettsed -e "/^#/d" -e "s/[ ].*//" < $ppdef > all.pp
12b2ae689353ecbaad720a9af9f9be01c1a3fe2dChristian Maeder# path cleanup
8db2221917c1bc569614f3481bcdb3b988facaedChristian Maederfor i in stdinclude usrinclude
12b2ae689353ecbaad720a9af9f9be01c1a3fe2dChristian Maederdo eval o='$'$i
1c7c4d95775a8ad5f7373e5cf0bad86f8301c56cAndy Gimblett *//*) v=`echo $v | sed 's,///*,/,g'` ;;
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly if (test . -ef "`pwd`")
9f93b2a8b552789cd939d599504d39732672dc84Christian Maeder do case $x in
1c7c4d95775a8ad5f7373e5cf0bad86f8301c56cAndy Gimblett do case $d in
1c7c4d95775a8ad5f7373e5cf0bad86f8301c56cAndy Gimblett ..) g="$g $d" ;;
53f89daf88665d3ea96d871110a5c0d9d8326bd2Andy Gimblett *) case $g in
53f89daf88665d3ea96d871110a5c0d9d8326bd2Andy Gimblett '') case $p in
1c7c4d95775a8ad5f7373e5cf0bad86f8301c56cAndy Gimblett *) p=$d/$p ;;
a5f3a8cdc3ceb045c3c166ee840d3e59ec7efac6Christian Maeder '') for d in $g
61051521e4d82769a47f23aecb5fb477de47d534Andy Gimblett /) continue ;;
1c7c4d95775a8ad5f7373e5cf0bad86f8301c56cAndy Gimblett test $x -ef $p && x=$p
197888c54795ec1e79e77289b7e20436a6db74c0Andy Gimblett do case $# in
a1f6118e7ce7f8892fc4299e316630ec74083f0aAndy Gimblett do for j in $v
b25c72845890740c2f8a21214752574990b943cfChristian Maeder do test $d -ef $j && continue 2
b25c72845890740c2f8a21214752574990b943cfChristian Maeder *) eval $i='$'v ;;
afc52bfaabee38c4d55cee9f35b1a0028ba3854aAndy Gimblettid="::IDENT::`date`::IDENT::"
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#assert test(ok)
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#endif' > assert.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho '#ifdef __BASE_FILE__
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#endif' > basefile.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederchar test[] = "te"
2f35e5f6757968746dbab385be21fcae52378a3fLiam O'Reillychar test[] = "te\
23a073e0a3433ca80a286d46202841b569ec36fdChristian Maederecho '#define g(a,b) a ## b
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblettvolatile int a;
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reillyconst int g(x,y)=1;
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reillyextern int c(int);' > compat.$src
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reillyecho > cpp.$src
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reillyecho "#defincl <x.h>" > defincl.$src
afc52bfaabee38c4d55cee9f35b1a0028ba3854aAndy Gimblettecho 'int a$b;' > dollar.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#eject" > eject.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#endif" > elseif.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#define _CAT(a,b,c) a##b##c
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#define hdra hdrx
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#define hdr _CAT(<,hdra,.h>)
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#include hdr" > hdra.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#define _XAT(a,b,c) a##b##c
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#define _CAT(a,b,c) _XAT(a,b,c)
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#define hdra hdrx
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#define hdr _CAT(<,hdra,.h>)
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maeder#include hdr" > hdrx.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "int f(){return 0;}" > hdrx.h
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#ident \"$id\"" > ident.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#import \"import.h\"" > import.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "int aaa;" > import.h
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#include <inc_next.h>" > inc_next.$src
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maedermkdir inc0 inc1
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho "#include_next <inc_next.h>" > inc0/inc_next.h
4f4e94264f48e255d4125f47649f585d9d062fabChristian Maederecho 'char s[] = "INCLUDE_NEXT";' > inc1/inc_next.h
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillyecho "int i = 0;" > lineid1.i
2bb060537a37352251aa04d8dc09aa53aad5d4bfLiam O'Reillyint i = 0;' > lineid3.$src
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillyecho "#include <stdio.h>" > linetype.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#include <sys/types.h>
b25c72845890740c2f8a21214752574990b943cfChristian Maeder return sizeof(LONGLONG) != 8;
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly}' > longlong.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#include "once.h"
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#include "once.h"' > once.$src
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillyecho '#ifdef once
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho "extern int a,b;int f(){return a + = b;}" > opspace.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho "int f(){return(0);} // ((" > pluscom.$src
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maederecho "class x {int n;} m;" > plusplus.$src
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maederecho > preinc.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '// splice \
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillyint x = 1;' > plusspl.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho "int stdc_default_value = __STDC__ ;" > stdc.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho 'char xxx[] = "abc
b25c72845890740c2f8a21214752574990b943cfChristian Maeder(";' > span.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#define g(a,b) a\
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillychar* g(x,y);' > splice.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho 'int a\ '
b25c72845890740c2f8a21214752574990b943cfChristian Maeder} > splicesp.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#define g(a,b) a/**/b
576a4ca6de740c90afd448607c2323477139de24Liam O'Reillyint g(x,y)=1;' > trans.$src
b25c72845890740c2f8a21214752574990b943cfChristian Maederecho '#define m 65
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 65
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 64
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 63
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 60
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 59
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 58
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 57
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 56
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 55
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 54
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 53
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 52
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 51
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 49
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 48
576a4ca6de740c90afd448607c2323477139de24Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 47
b25c72845890740c2f8a21214752574990b943cfChristian Maeder#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 46
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblett#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 45
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblett#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 44
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblett#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 43
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblett#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42
7371f8fe3a9a286a74ea30a3cd18e7740f67d537Andy Gimblett#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 41
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 40
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 39
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 38
fd4ad12563262ebe380d810df8f7755cfab5fb42Liam O'Reilly#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 37
cat > zeof.c <<'!'
if $cc -c catlit1.i 2>e
then if $cc -c catlit2.i 2>f
$cc -S ident.$src && grep "$id" ident.s && ident=1
if $cc -c linefile1.i
then $cc -c linefile2.i
if $cc -c lineid1.i 2>b
then $cc -c lineid2.i 2>e
else $cc -c lineid3.c 2>e
$cc -c key.$src >/dev/null 2>&1 || reserved="$reserved $key$type"
echo '#include "ptrone.h"
#include "ptrdef.h"
echo '#include "ptrone.h"
echo 'template<class T> int gt(T a, T b);' > ptrdef.h
echo '/* empty */' > ptrone.h
#endif' > ptrone.h
$cc -c zeof.c || zeof=1
echo "$predef" >> all.pp
} 3>&- 3>&1 >/dev/null |
sed -e '/^ppsymbol$/d' -e '/^.$/d' -e '/^..$/d' -e '/[ABCDEFGHIJKLMNOPQRSTUVWXYZ].*[abcdefghijklmnopqrstuvwxyz]/d' -e '/[abcdefghijklmnopqrstuvwxyz].*[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/d' |
cat - all.pp |
preval="`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' -e '/\\(^[^ ]*\\) \1 *=$/d'` `$cc -dM -E stdc.$src | sed -e '/[ ]*#[ ]*define/!d' -e '/\"/d' -e 's/[ ]*#[ ]*define[ ]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*([^)]*)\\)[ ]*\\(.*\\)/\\1 \\2 =/' -e 's/[ ]*#[ ]*define[ ]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*\\)[ ]*\\(.*\\)/\\1 \\2 =/'`"
print -r "$preval" > /tmp/probe/preval
do echo "#include <sys/$i.h>" > t.$src
rm -f fun.exe
do echo "#include <$i.h>" > t.$src
then mapinclude="$mapinclude <$i.h>=\".\""
for i in `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*[0123456789][abcdefghijklmnopqrstuvwxyz0123456789]*\$/!d'` `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*\$/!d'`
u3b?*) model=`echo $architecture | sed 's/u3b//'`
model=`echo $architecture | sed 's/vax//'`
if $cc -E preinc.$src > preinc.out
then 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`