This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add sin6_scope_id probe (LeoNerd)
[metaconfig.git] / U / modified / Cppsym.U
index 55fe4d3..6eed09b 100644 (file)
@@ -1,7 +1,7 @@
 ?RCS: $Id: Cppsym.U,v 3.0.1.5 1995/05/12 11:59:11 ram Exp $
 ?RCS:
 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
-?RCS: 
+?RCS:
 ?RCS: You may redistribute only under the terms of the Artistic Licence,
 ?RCS: as specified in the README file that comes with the distribution.
 ?RCS: You may reuse parts of this distribution only within the terms of
 ?RCS: Revision 3.0  1993/08/18  12:04:50  ram
 ?RCS: Baseline for dist 3.0 netwide release.
 ?RCS:
-?X: 
 ?X: This unit produces a shell script called Cppsym, which can be used to
 ?X: determine whether any in a list of symbols is defined by the C compilation
 ?X: chain (C preprocessor symbols plus C compiler native ones).
 ?X: It can determine the status of any symbol, though the symbols in $al
 ?X: are more easily determined.  If you want to add to $al you can do
 ?X: it in Myinit.U.
-?X: 
-?MAKE:Cppsym ccsymbols cppsymbols cppccsymbols: \
-       eunicefix Guess cppstdin awk cat tr sed sort grep rm startsh osname \
-       contains cppminus +cc +gccversion test comm uniq echo n c Options trnl
+?MAKE:Cppsym ccsymbols cppsymbols cppccsymbols: run \
+       eunicefix Guess awk cat tr sed sort rm rm_try startsh osname \
+       +cc +gccversion test comm uniq echo Options trnl \
+       optimize ccflags ldflags libs cpp_stuff cpp
 ?MAKE: -pick add $@ %<
-?F:./Cppsym
-?T:sym list unknown status also symbols i postprocess_cc_v
-?V:al
+?T:also symbols i postprocess_cc_v tHdrH
 ?X:
 ?X: The symbol list is in alpha order for ease of maintenance...
 ?X:
 ?X: Lots of new symbols (mostly rummaged from gcc), courtesy of
 ?X: Jarkko Hietaniemi <jhi@snakemail.hut.fi> -- RAM, 06/06/94
 ?X:
-?INIT:: list of known cpp symbols, sorted alphabetically
-?INIT:al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
-?INIT:al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
-?INIT:al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
-?INIT:al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
-?INIT:al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
-?INIT:al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
-?INIT:al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4 SVR5"
-?INIT:al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
-?INIT:al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
-?INIT:al="$al VMS Xenix286"
-?INIT:al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
-?INIT:al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
-?INIT:al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
-?INIT:al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
-?INIT:al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
-?INIT:al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
-?INIT:al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
-?INIT:al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
-?INIT:al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
-?INIT:al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
-?INIT:al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
-?INIT:al="$al __SVR4_2__ __UMAXV__"
-?INIT:al="$al ____386BSD____ __alpha __alpha__ __amiga"
-?INIT:al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
-?INIT:al="$al __host_mips__"
-?INIT:al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
-?INIT:al="$al __hp9000s500 __hp9000s700 __hp9000s800"
-?INIT:al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
-?INIT:al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
-?INIT:al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
-?INIT:al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
-?INIT:al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
-?INIT:al="$al __mc88100 __mc88100__ __mips __mips__"
-?INIT:al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
-?INIT:al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
-?INIT:al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
-?INIT:al="$al _host_mips _mips _unix"
-?INIT:al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
-?INIT:al="$al apollo ardent att386 att3b"
-?INIT:al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
-?INIT:al="$al cadmus clipper concurrent convex cray ctix"
-?INIT:al="$al dmert encore gcos gcx gimpel gould"
-?INIT:al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
-?INIT:al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
-?INIT:al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
-?INIT:al="$al i186 i286 i386 i486 i8086"
-?INIT:al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
-?INIT:al="$al ksr1 linux luna luna88k m68k m88100 m88k"
-?INIT:al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
-?INIT:al="$al mc68040 mc68060 mc68k mc68k32 mc700"
-?INIT:al="$al mc88000 mc88100 merlin mert mips mvs n16"
-?INIT:al="$al ncl_el ncl_mr"
-?INIT:al="$al news1500 news1700 news1800 news1900 news3700"
-?INIT:al="$al news700 news800 news900 ns16000 ns32000"
-?INIT:al="$al ns32016 ns32332 ns32k nsc32000 os osf"
-?INIT:al="$al parisc pc532 pdp11 plexus posix pyr"
-?INIT:al="$al riscix riscos scs sequent sgi sinix sony sony_news"
-?INIT:al="$al sonyrisc sparc sparclite spectrum stardent stratos"
-?INIT:al="$al sun sun3 sun386 svr4 sysV68 sysV88"
-?INIT:al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
-?INIT:al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
-?INIT:al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
-?INIT:al="$al xenix z8000"
-?INIT:
 ?S:ccsymbols:
 ?S:    The variable contains the symbols defined by the C compiler alone.
 ?S:    The symbols defined by cpp or by cc when it calls cpp are not in
 ?S:    The list is a space-separated list of symbol=value tokens.
 ?S:.
 ?S:cppccsymbols:
-?S:    The variable contains the symbols defined by the C compiler when
+?S:    The variable contains the symbols defined by the C compiler
 ?S:    when it calls cpp.  The symbols defined by the cc alone or cpp
 ?S:    alone are not in this list, see ccsymbols and cppsymbols.
 ?S:    The list is a space-separated list of symbol=value tokens.
 ?S:.
+?F:./Cppsym
+?F:./Cppsym.know
 ?F:!Cppsym.true
 ?F:!ccsym.com
 ?F:!ccsym.cpp
 ?F:!ccsym.own
-: get C preprocessor symbols handy
+?X: fake LINT hints
+?LINT:change ccflags
+?LINT:extern s
+?LINT:extern s__
+: Preprocessor symbols
 echo " "
-$echo $n "Hmm... $c"
-?X: The following used to be tr '[ - ]' ... but this was rejected by AIX 3.2
-?X: since the endpoints where the same (from patch 12u8 to patch).
-echo $al | $tr ' ' $trnl >Cppsym.know
-$cat <<EOSS >Cppsym
+$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
+?X: If your symbol is mixed case, just add it as-is.
+?X: All symbols will be transformed to both all-lower and all-upper.
+?X: Also drop any leading/trailing underscores, the scan will try all those.
+$cat <<'EOSH' > Cppsym.know
+a29k ABI64 aegis AES_SOURCE AIX AIX32 AIX370
+AIX41 AIX42 AIX43 AIX_SOURCE aixpc ALL_SOURCE
+alliant alpha am29000 AM29000 AMD64 amd64 amiga AMIGAOS AMIX
+ansi ANSI_C_SOURCE apollo ardent ARM32 atarist att386 att3b
+BeOS BIG_ENDIAN BIT_MSF bsd BSD bsd43 bsd4_2 bsd4_3 BSD4_3 bsd4_4
+BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES BSDCOMPAT bsdi
+bull c cadmus clipper CMU COFF COMPILER_VERSION
+concurrent convex cpu cray CRAY CRAYMPP ctix CX_UX
+CYGWIN DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO
+Dynix DynixPTX ELF encore EPI EXTENSIONS FAVOR_BSD
+FILE_OFFSET_BITS FreeBSD GCC_NEW_VARARGS gcos gcx gimpel
+GLIBC GLIBC_MINOR
+GNU_SOURCE GNUC GNUC_MINOR GNU_LIBRARY GO32 gould GOULD_PN
+H3050R H3050RX hbullx20 hcx host_mips
+hp200 hp300 hp700 HP700 hp800 hp9000
+hp9000s200 hp9000s300 hp9000s400 hp9000s500
+hp9000s700 hp9000s800 hp9k8 hp_osf hppa hpux HPUX_SOURCE
+i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960
+IA64 iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
+INLINE_INTRINSICS INTRINSICS INT64 interdata is68k ksr1
+LANGUAGE_C LARGE_FILE_API LARGEFILE64_SOURCE
+LARGEFILE_SOURCE LFS64_LARGEFILE LFS_LARGEFILE
+LIBCATAMOUNT Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG
+LONGDOUBLE LONGLONG LP64 luna luna88k Lynx
+M68000 m68k m88100 m88k M88KBCS_TARGET M_COFF
+M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM M_SYS3
+M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX MACH machine MachTen
+MATH_HAS_NO_SIDE_EFFECTS
+mc300 mc500 mc68000 mc68010 mc68020 mc68030 mc68040
+mc68060 mc68k mc68k32 mc700 mc88000 mc88100 merlin
+mert MiNT mips MIPS_FPSET MIPS_ISA MIPS_SIM MIPS_SZINT
+MIPS_SZLONG MIPS_SZPTR MIPSEB MIPSEL MODERN_C motorola
+mpeix MSDOS MTXINU MULTIMAX mvs MVS n16 ncl_el ncl_mr
+NetBSD news1500 news1700 news1800 news1900 news3700
+news700 news800 news900 NeXT NLS nonstopux ns16000 ns32000
+ns32016 ns32332 ns32k nsc32000
+OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
+pa_risc PA_RISC1_1 PA_RISC2_0 PARAGON parisc
+pc532 pdp11 PGC PIC plexus PORTAR posix
+POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
+POSIX_C_SOURCE POSIX_SOURCE POWER
+PROTOTYPES PWB pyr QNX QK_USER R3000 REENTRANT RES Rhapsody RISC6000
+riscix riscos RT S390 SA110 scs SCO sequent sgi SGI_SOURCE SH3 sinix
+SIZE_INT SIZE_LONG SIZE_PTR SOCKET_SOURCE SOCKETS_SOURCE
+sony sony_news sonyrisc sparc sparclite spectrum
+stardent stdc STDC_EXT stratos sun sun3 sun386
+Sun386i svr3 svr4 SVR4_2 SVR4_SOURCE svr5
+SX system SYSTYPE_BSD SYSTYPE_BSD43 SYSTYPE_BSD44
+SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3 SYSV4 SYSV5
+sysV68 sysV88 Tek4132 Tek4300 titan
+TM3200 TM5400 TM5600
+tower tower32 tower32_200 tower32_600 tower32_700
+tower32_800 tower32_850 tss
+u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5
+ultrix UMAXV UnicomPBB UnicomPBD UNICOS UNICOSMK
+unix UNIX95 UNIX99 unixpc unos
+USE_BSD USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE USE_LARGEFILE64
+USE_MISC USE_POSIX USE_POSIX199309 USE_POSIX199506 USE_POSIX2
+USE_REENTRANT USE_SVID USE_UNIX98 USE_XOPEN USE_XOPEN_EXTENDED
+USGr4 USGr4_2
+Utek UTek UTS UWIN uxpm uxps vax venix VMESA vms x86_64 xenix Xenix286
+XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2 XPG2_EXTENDED
+XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
+z8000
+EOSH
+# Maybe put other stuff here too.
+cat <<EOSH >>Cppsym.know
+$osname
+EOSH
+./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
+./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
+$cat Cppsym.know > Cppsym.c
+$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
+$rm -f Cppsym.a Cppsym.b Cppsym.c
+cat <<EOSH > Cppsym
 $startsh
-case "\$1" in
--l) list=true
-       shift
-       ;;
-esac
-unknown=''
-case "\$list\$#" in
-1|2)
-       for sym do
-               if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
-                       exit 0
-               elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
-                       :
-               else
-                       unknown="\$unknown \$sym"
-               fi
-       done
-       set X \$unknown
-       shift
-       ;;
-esac
-case \$# in
-0) exit 1;;
-esac
-echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
-#ifdef \1\\
-exit 0; _ _ _ _\1\\     \1\\
-#endif\\
-/' >Cppsym\$\$
-echo "exit 1; _ _ _" >>Cppsym\$\$
-$cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
-case "\$list" in
-true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
-*)
-       sh Cppsym2\$\$
-       status=\$?
-       ;;
-esac
-$rm -f Cppsym\$\$ Cppsym2\$\$
-exit \$status
-EOSS
+if $test \$# -gt 0; then
+    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
+    if $test -s Cppsym.got; then
+        $rm -f Cppsym.got
+        exit 0
+    fi
+    $rm -f Cppsym.got
+    exit 1
+else
+    $tr " " "$trnl" | ./Cppsym.try
+    exit 0
+fi
+EOSH
 chmod +x Cppsym
 $eunicefix Cppsym
-./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
-
+?X: The below awk script will die a horrible death if
+?X: some of the tested symbols are not long ints.
+?X: Also, we do not make difference between just defined and defined zero.
+cat <<EOSH > Cppsym.try
+$startsh
+cat <<'EOCP' > try.c
+#include <stdio.h>
+#if cpp_stuff == 1
+#define STRINGIFY(a)    "a"
+#endif
+#if cpp_stuff == 42
+#define StGiFy(a)  #a
+#define STRINGIFY(a)    StGiFy(a)
+#endif
+#if $cpp_stuff != 1 && $cpp_stuff != 42
+#   include "Bletch: How does this C preprocessor stringify macros?"
+#endif
+int main() {
+EOCP
+?X: The length($1) command guards against possible empty entries.
+?X: The awk snippet is know to give heartburn to UNICOS/mk awk.
+$awk \\
+EOSH
+cat <<'EOSH' >> Cppsym.try
+'length($1) > 0 {
+    printf "#ifdef %s\nprintf(\"%s=%%s\\n\", STRINGIFY(%s));\n#endif\n", $1, $1, $1
+    printf "#ifdef _%s\nprintf(\"_%s=%%s\\n\", STRINGIFY(_%s));\n#endif\n", $1, $1, $1
+    printf "#ifdef __%s\nprintf(\"__%s=%%s\\n\", STRINGIFY(__%s));\n#endif\n", $1, $1, $1
+    printf "#ifdef __%s__\nprintf(\"__%s__=%%s\\n\", STRINGIFY(__%s__));\n#endif\n", $1, $1, $1
+}'      >> try.c
+echo 'return 0;}' >> try.c
+EOSH
+cat <<EOSH >> Cppsym.try
+ccflags="$ccflags"
+case "$osname-$gccversion" in
+irix-) ccflags="\$ccflags -woff 1178" ;;
+os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
+esac
+$cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs && $run ./try | $sed 's/ /\\\\ /g'
+EOSH
+chmod +x Cppsym.try
+$eunicefix Cppsym.try
+./Cppsym < Cppsym.know > Cppsym.true
+: Add in any linux cpp "predefined macros":
+case "$osname::$gccversion" in
+  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
+    tHdrH=_tmpHdr
+    rm -f $tHdrH'.h' $tHdrH
+    touch $tHdrH'.h'
+    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
+       sed 's/#define[\ \  ]*//;s/[\ \     ].*$//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
+       if [ -s $tHdrH'_cppsym.real' ]; then
+         cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
+       fi
+    fi
+    rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real'
+  ;;
+esac
 : now check the C compiler for additional symbols
 ?X: suggested by Jarkko Hietaniemi <jhi@snakemail.hut.fi>, thanks!
 postprocess_cc_v=''
@@ -206,10 +247,10 @@ for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
 do
        case "\$i" in
        -D*) echo "\$i" | $sed 's/^-D//';;
-       -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
+       -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
        esac
 done
-$rm -f try.c
+$rm_try
 EOS
 postprocess_cc_v=''
 chmod +x ccsym
@@ -227,10 +268,9 @@ fi
 ?X: the awk script must be on two lines for older awk programs, sigh! -- ADO
 $awk '/\=/ { print $0; next }
        { print $0"=1" }' ccsym.raw >ccsym.list
-$awk '{ print $0"=1" }' Cppsym.true >ccsym.true
-$comm -13 ccsym.true ccsym.list >ccsym.own
-$comm -12 ccsym.true ccsym.list >ccsym.com
-$comm -23 ccsym.true ccsym.list >ccsym.cpp
+$comm -13 Cppsym.true ccsym.list >ccsym.own
+$comm -12 Cppsym.true ccsym.list >ccsym.com
+$comm -23 Cppsym.true ccsym.list >ccsym.cpp
 also=''
 if $test -z ccsym.raw; then
        echo "Your C compiler doesn't seem to define any symbols!" >&4
@@ -244,7 +284,7 @@ if $test -z ccsym.raw; then
 else
        if $test -s ccsym.com; then
                echo "Your C compiler and pre-processor define these symbols:"
-               $sed -e 's/\(.*\)=.*/\1/' ccsym.com
+               $sed -e 's/\(..*\)=.*/\1/' ccsym.com
                also='also '
                symbols='ones'
                cppccsymbols=`$cat ccsym.com`
@@ -254,7 +294,7 @@ else
        if $test -s ccsym.cpp; then
                $test "$also" && echo " "
                echo "Your C pre-processor ${also}defines the following symbols:"
-               $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
+               $sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
                also='further '
                cppsymbols=`$cat ccsym.cpp`
                cppsymbols=`echo $cppsymbols`
@@ -263,12 +303,11 @@ else
        if $test -s ccsym.own; then
                $test "$also" && echo " "
                echo "Your C compiler ${also}defines the following cpp symbols:"
-               $sed -e 's/\(.*\)=1/\1/' ccsym.own
-               $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
+               $sed -e 's/\(..*\)=1/\1/' ccsym.own
+               $sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
                ccsymbols=`$cat ccsym.own`
                ccsymbols=`echo $ccsymbols`
                $test "$silent" || sleep 1
        fi
 fi
-$rm -f ccsym*