📄 stupidh
字号:
#! /bin/sh#### Find stupid system include dependencies and account for them. Squirts## a sample .h file to stdout containing [too many of] the right things.## If you hose the output into "stupid.h", you will get MORE information.## This takes a while to run, because it checks so many things.#### IF YOU HAVE a system/arch/compiler/whatever that is NOT one of:## msdos-msc6.x ultrix-vax ultrix-mips sunos4.1.x-sparc solaris2.x-sparc## aix-rs6k linux1.[01].x-x86 freebsd-x86 netbsd-x86 hpux## [... hopefully this list will grow very large]## or even if you aren't sure, you would be doing me and the net in general## a wonderful service by running this and MAILING me the "full" output, e.g.#### chmod +x stupidh## ./stupidh > stupid.h## mail hobbit@avian.org < stupid.h#### WARNING: You may have to change "cc" to "gcc" below if you don't have## "cc" [e.g. solaris, thank you very fucking much, Sun].## Please note any errors this generates, too...#### *Hobbit*, 941122 and previous. VERSION: 1.3 951107#### edits: Use a consistent naming scheme, for easier identification and cleanup.## accomodate gcc's BOGUS assumptions based on input filename.## added a few more include-names and try-predefines; some swiped from autoconf.## added a couple of things commonly done as #defines so we can SEE 'em## Here is where to change "cc" to "gcc" if needed:CC=ccif test -z "${INCLUDE}" ; then INCLUDE=/usr/includefiecho '/* STUPIDH run:'uname -aecho '*/'echo ''echo "/* Includes, from ${INCLUDE} */"for xx in \assert ctype cdefs errno file fcntl ioctl malloc stdio stdlib stdarg iostdio \stddef dirent direct dir ndir utmp wtmp utmpx wtmpx lastlog login paths \getopt string strings signal setjmp io param stat types time timeb utime \dos msdos unistd socket netdb varargs sysinfo systeminfo resource ulimit \stream stropts pstat sysmacros termio termios sgtty tty ttyent lstat select \sockio wait vfork bsdtypes mkdev utsname sysexits \; do XX='' if test -f ${INCLUDE}/${xx}.h ; then echo "#include <${xx}.h>" XX=`echo $xx | tr '[a-z]' '[A-Z]'` fi if test -f ${INCLUDE}/sys/${xx}.h ; then echo "#include <sys/${xx}.h>" XX=`echo $xx | tr '[a-z]' '[A-Z]'` fi# everyone seems to have their own conventions; this may not be complete.# thats why this is so STUPID.# HAS_xx and USE_xx might indicate functions and available library calls,# not includes. Deal... if test "${XX}" ; then echo "#define USE_${XX}_H" echo "#define HAS_${XX}_H" echo "#define HAS_${XX}" echo "#define HAS${XX}" echo "#define HAVE_${XX}_H" echo "#define HAVE_${XX}" echo "#define HAVE${XX}H" echo "#define ${XX}H" echo '' fi# Stupid hack: "dir" and "dirent" might mutually exclusive, a la GNU# includes. This is to prevent it from biting us. if test "${xx}" = "dirent" ; then echo "#ifdef _SYS_DIRENT_H" echo "#undef _SYS_DIRENT_H" echo "#endif" fi### To make a DOS batchfile instead, do this [on a unix box!], xfer results,### and have "xxx.bat" that types out all the cruft for %INCLUDE%\%1.### WARNING: I might not have gotten the superquoting exactly right here...# echo "if exist %INCLUDE%\\${xx}.h call xxx ${xx}"# echo "if exist %INCLUDE%\\sys\\${xx}.h call xxx sys/${xx}"### You also need to save and manually run the CPP input file, below.### I've done this for msc6 and would appreciate results for other compilers.donesyncsleep 1### Note: if all the previous output went to "stupid.h", it will be### reincluded in the second part of this.sed -e '/^#/d' -e '/^[ ]*$/d' > st00pid.in << 'EOF'### More recently, some of this was swiped from the "gcc" doc. Autoconf is### worth a harder look for more ideas; havent gotten around to it yet.# architecturesalphadecibmi370i960i860ibm032a29kindigoirismipsmipselsparcsparclitencrshharrisapplevaxx86ix86i286i386i486i586pentiumintelsmpmpumpu8080mpu8086amigahphppahp400hp9000snakedecmipsmc68000mc68010mc68020mc68030m68000m68010m68020m68030m68km88ku3b15u3bu3b2u3b5u3b15u3b20dwe32kppcpowerpcarmaviionns32000iapx286# minor exception to lc-vs-uc thing?iAPX286rs6000rs6kriscsunsun3sun4sun4csun4msequentapollosolbournepyrpyramidinterdataintertecpdp11u370nextmacmacintosh# for completeness; ya never know ... yes, found it!! -- solaris inet/common.hbig_endianlittle_endianlsbfirstmsbfirst# vendors/OSesunixmunixm_unixgcososgssctssisc# *This* pair of imbeciles does *caseified defines*. Pinheads. One of# these might trigger before the "tr" step.NetBSDnetbsdfreebsdFreeBSD# cant do 386bsd, I dont think, but ..._386bsdbsd386bsdunixbsd_2bsd_20bsdbsdibsd4bsd42bsd43bsd44bsd4_2bsd4_3bsd4_4linuxminixultrixult3ult4bullconvexconvex_sourceresrtesixdgdguxencoreosfosf1osf2# oops:# osf/1machmach386mach_386nextsteptahoerenosunossunos3sunos4sunos5solarissun_src_compatsvr3svr4svr3_stylesvr4_stylesysvhpuxhp_uxirixsgisonynewsnewsosnews_oslunalynxosriscosmicroportewsuxews_uxmportdynixgenixunicosunixwaremsdosdosos2novellunivelplan9attatt_unixscoodtaixauxa_uxrsxvms# compiler cruft??ansiansi_sourceansicstdclintsccslibc_sccsmsmscmicrosoftgccgnugnucgnuccgnu_sourcesabresabercygnussourceall_sourcegprofprofposixposix_sourceposix_sourcesposix_c_sourcexopen_sourceargspprotono_protoprototypeprototypesreentrantkernelstrtraceasmlibcppathenaathena_compat# some preprocessors cant deal with this# c++cxxcplusplusborlandturboturboclatticehighc# various defines that pop out of other .h files that we need to know aboutindexstrchrrindexstrrchrbcopymemcpybzeromemsetpath_loginpath_lastlogpath_utmppath_utmpxEOF# FL must be named something.c, so STUPID gcc recognized it as a non-object!!( FL=st00pid.c if test -f stupid.h ; then cp stupid.h $FL sync echo '/* Re-including stupid.h */' sleep 1 else echo '/* Skipping stupid.h */' fi while read xx ; do XX=`echo $xx | tr '[a-z]' '[A-Z]'` echo "#ifdef ${xx}" >> $FL echo "\"${xx}\" = ${xx}" >> $FL echo "#endif" >> $FL echo "#ifdef _${xx}" >> $FL echo "\"_${xx}\" = _${xx}" >> $FL echo "#endif" >> $FL echo "#ifdef _${xx}_" >> $FL echo "\"_${xx}_\" = _${xx}_" >> $FL echo "#endif" >> $FL echo "#ifdef __${xx}" >> $FL echo "\"__${xx}\" = __${xx}" >> $FL echo "#endif" >> $FL echo "#ifdef __${xx}__" >> $FL echo "\"__${xx}__\" = __${xx}__" >> $FL echo "#endif" >> $FL echo "#ifdef ${XX}" >> $FL echo "\"${XX}\" = ${XX}" >> $FL echo "#endif" >> $FL echo "#ifdef _${XX}" >> $FL echo "\"_${XX}\" = _${XX}" >> $FL echo "#endif" >> $FL echo "#ifdef _${XX}_" >> $FL echo "\"_${XX}_\" = _${XX}_" >> $FL echo "#endif" >> $FL echo "#ifdef __${XX}" >> $FL echo "\"__${XX}\" = __${XX}" >> $FL echo "#endif" >> $FL echo "#ifdef __${XX}__" >> $FL echo "\"__${XX}__\" = __${XX}__" >> $FL echo "#endif" >> $FL done# and pick up a few specials echo "#ifdef major" >> $FL echo "\"major\" = major (x)" >> $FL echo "\"minor\" = minor (x)" >> $FL echo "#endif" >> $FL echo "#ifdef FD_SETSIZE" >> $FL echo "\"FD_SETSIZE\" = FD_SETSIZE" >> $FL echo "#endif" >> $FL) < st00pid.insyncecho '/* Compiler predefines:'${CC} -E st00pid.c | sed -e '/^#/d' -e '/^[ ]*$/d'echo '*/'synccat > st00pid.c << 'EOF'#include <stdio.h>main() {union { char *bletch; int *i;} yow;static char orig[16]; strcpy (orig, "ABCDEFGHIJK"); yow.bletch = orig; printf ("endian thing: %s = 0x%lx, addrbyte = %x -- ", yow.bletch, *yow.i, *yow.i & 0xFF); printf (((*yow.i & 0xff) == 0x41) ? "LITTLE\n" : "BIG\n"); printf ("short %d; int %d; long %d\n", sizeof (short), sizeof (int), sizeof (long));}EOF${CC} -o st00pid.x st00pid.cecho '/* Architecture:'./st00pid.xecho '*/'### dont nuke if generating DOS batchfilesrm -f st00pid.*syncexit 0### stuff remaining to deal with:# maybe take out the slew of HAS_* and HAS* excess predefines, and only use# our "standardized" scheme [like we were going to generate a real includible# file outa this??]# various POSIX_ME_HARDERisms:# vfork# lockf/flock/fcntl/euuugh# signal stuff# termio/termios/sgtty hair# strdup and related# ifdef HAVE_STD_LIB and such nonsense# auto-sniff cc-vs-gcc somehow? maybe a straight OR with exit statii..
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -