From 6c5bb6dfd5b52f11e0b1cd8cb0db5a232d1147d8 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 27 Mar 2023 08:54:45 -0400 Subject: [PATCH] find-systype.sh: remove unused "systype" mechanism The "systype" machanism is merely a system info gatherer, and the info it collects is (mostly) not used anywhere. The only seemingly important info is the kernel and kernel version (or the lack thereof), and has been moved to where it is used (print-ar.sh) This gets rid of two cross-incompatible buildtime programs. One tried to find if the build was happening on NeXT, but that's not an operating system that print-ar.sh cares about. The other tried to do cpuid on x86, which is useless to the build. This seems to implement what #11 started. --- src/Makefile | 13 ++-- src/TARGETS | 1 - src/find-systype.sh | 143 -------------------------------------------- src/print-ar.sh | 3 +- src/print-cc.sh | 1 - src/print-ld.sh | 1 - src/trycpp.c | 9 --- src/x86cpuid.c | 40 ------------- 8 files changed, 7 insertions(+), 204 deletions(-) delete mode 100644 src/find-systype.sh delete mode 100644 src/trycpp.c delete mode 100644 src/x86cpuid.c diff --git a/src/Makefile b/src/Makefile index 9834b3e..23d246b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -179,7 +179,7 @@ choose: choose.sh warn-auto.sh coe.o: coe.c coe.h compile ./compile coe.c -compile: conf-cc print-cc.sh systype warn-auto.sh +compile: conf-cc print-cc.sh warn-auto.sh rm -f compile sh print-cc.sh > compile chmod 555 compile @@ -235,7 +235,7 @@ iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h ./compile iopause.c -load: conf-ld print-ld.sh systype warn-auto.sh +load: conf-ld print-ld.sh warn-auto.sh rm -f load sh print-ld.sh > load chmod 555 load @@ -246,7 +246,7 @@ lock_ex.o: compile hasflock.h lock.h lock_ex.c lock_exnb.o: compile hasflock.h lock.h lock_exnb.c ./compile lock_exnb.c -makelib: print-ar.sh systype warn-auto.sh +makelib: print-ar.sh warn-auto.sh rm -f makelib sh print-ar.sh > makelib chmod 555 makelib @@ -358,10 +358,10 @@ subgetopt.o: compile subgetopt.c subgetopt.h ./compile subgetopt.c sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ -hassgprm.h haswaitp.h iopause.h load select.h systype \ +hassgprm.h haswaitp.h iopause.h load select.h \ uint64.h reboot_system.h uw_tmp.h socket.lib rm -f sysdeps - cat systype compile load socket.lib >>sysdeps + cat compile load socket.lib >>sysdeps grep sysdep direntry.h >>sysdeps grep sysdep haswaitp.h >>sysdeps grep sysdep hassgact.h >>sysdeps @@ -375,9 +375,6 @@ uint64.h reboot_system.h uw_tmp.h socket.lib grep sysdep uw_tmp.h >>sysdeps cat sysdeps -systype: find-systype.sh trycpp.c x86cpuid.c - sh find-systype.sh > systype - tai_now.o: compile tai.h tai_now.c uint64.h ./compile tai_now.c diff --git a/src/TARGETS b/src/TARGETS index 2a50be3..e78f783 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -106,7 +106,6 @@ strerr_die.o strerr_sys.o subgetopt.o sysdeps -systype tai_now.o tai_pack.o tai_sub.o diff --git a/src/find-systype.sh b/src/find-systype.sh deleted file mode 100644 index 9f6e565..0000000 --- a/src/find-systype.sh +++ /dev/null @@ -1,143 +0,0 @@ -# oper-:arch-:syst-:chip-:kern- -# oper = operating system type; e.g., sunos-4.1.4 -# arch = machine language; e.g., sparc -# syst = which binaries can run; e.g., sun4 -# chip = chip model; e.g., micro-2-80 -# kern = kernel version; e.g., sun4m -# dependence: arch --- chip -# \ \ -# oper --- syst --- kern -# so, for example, syst is interpreted in light of oper, but chip is not. -# anyway, no slashes, no extra colons, no uppercase letters. -# the point of the extra -'s is to ease parsing: can add hierarchies later. -# e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium, -# and i386-486 (486s do have more instructions, you know) as well as i386. -# the idea here is to include ALL useful available information. - -exec 2>/dev/null - -sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`" -if [ x"$sys" != x ] -then - unamer="`uname -r | tr /: ..`" - unamem="`uname -m | tr /: ..`" - unamev="`uname -v | tr /: ..`" - - case "$sys" in - bsd.os|freebsd|netbsd|openbsd) - # in bsd 4.4, uname -v does not have useful info. - # in bsd 4.4, uname -m is arch, not chip. - oper="$sys-$unamer" - arch="$unamem" - syst="" - chip="`sysctl -n hw.model`" # hopefully - kern="" - ;; - linux) - # as in bsd 4.4, uname -v does not have useful info. - oper="$sys-$unamer" - syst="" - chip="$unamem" - kern="" - case "$chip" in - i386|i486|i586|i686) - arch="i386" - ;; - alpha) - arch="alpha" - ;; - esac - ;; - aix) - # naturally IBM has to get uname -r and uname -v backwards. dorks. - oper="$sys-$unamev-$unamer" - arch="`arch | tr /: ..`" - syst="" - chip="$unamem" - kern="" - ;; - sunos) - oper="$sys-$unamer-$unamev" - arch="`(uname -p || mach) | tr /: ..`" - syst="`arch | tr /: ..`" - chip="$unamem" # this is wrong; is there any way to get the real info? - kern="`arch -k | tr /: ..`" - ;; - unix_sv) - oper="$sys-$unamer-$unamev" - arch="`uname -m`" - syst="" - chip="$unamem" - kern="" - ;; - *) - oper="$sys-$unamer-$unamev" - arch="`arch | tr /: ..`" - syst="" - chip="$unamem" - kern="" - ;; - esac -else - gcc -c trycpp.c - gcc -o trycpp trycpp.o - case `./trycpp` in - nextstep) - oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`" - arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`" - syst="" - chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`" - kern="" - ;; - *) - oper="unknown" - arch="" - syst="" - chip="" - kern="" - ;; - esac - rm -f trycpp.o trycpp -fi - -case "$chip" in -80486) - # let's try to be consistent here. (BSD/OS) - chip=i486 - ;; -i486DX) - # respect the hyphen hierarchy. (FreeBSD) - chip=i486-dx - ;; -i486.DX2) - # respect the hyphen hierarchy. (FreeBSD) - chip=i486-dx2 - ;; -Intel.586) - # no, you nitwits, there is no such chip. (NeXTStep) - chip=pentium - ;; -i586) - # no, you nitwits, there is no such chip. (Linux) - chip=pentium - ;; -i686) - # STOP SAYING THAT! (Linux) - chip=ppro -esac - -if gcc -c x86cpuid.c -then - if gcc -o x86cpuid x86cpuid.o - then - x86cpuid="`./x86cpuid | tr /: ..`" - case "$x86cpuid" in - ?*) - chip="$x86cpuid" - ;; - esac - fi -fi -rm -f x86cpuid x86cpuid.o - -echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]' diff --git a/src/print-ar.sh b/src/print-ar.sh index 99bc116..c31d937 100644 --- a/src/print-ar.sh +++ b/src/print-ar.sh @@ -2,7 +2,8 @@ cat warn-auto.sh echo 'main="$1"; shift' echo 'rm -f "$main"' echo 'ar cr "$main" ${1+"$@"}' -case "`cat systype`" in +kern="$(uname -s | tr '/:[A-Z]' '..[a-z])')-$(uname -r | tr /: ..)" || kern="unknown" +case $kern in sunos-5.*) ;; unix_sv*) ;; irix64-*) ;; diff --git a/src/print-cc.sh b/src/print-cc.sh index 31f4ed3..1bf3e3e 100644 --- a/src/print-cc.sh +++ b/src/print-cc.sh @@ -1,5 +1,4 @@ cc="`head -n1 conf-cc`" -systype="`cat systype`" cat warn-auto.sh echo exec "$cc" '-c ${1+"$@"}' diff --git a/src/print-ld.sh b/src/print-ld.sh index 59489a8..5f34bb8 100644 --- a/src/print-ld.sh +++ b/src/print-ld.sh @@ -1,5 +1,4 @@ ld="`head -n1 conf-ld`" -systype="`cat systype`" cat warn-auto.sh echo 'main="$1"; shift' diff --git a/src/trycpp.c b/src/trycpp.c deleted file mode 100644 index e4503d4..0000000 --- a/src/trycpp.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Public domain. */ - -int main() -{ -#ifdef NeXT - printf("nextstep\n"); exit(0); -#endif - printf("unknown\n"); exit(0); -} diff --git a/src/x86cpuid.c b/src/x86cpuid.c deleted file mode 100644 index f81c593..0000000 --- a/src/x86cpuid.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Public domain. */ - -#include - -void nope() -{ - exit(1); -} - -int main() -{ - unsigned long x[4]; - unsigned long y[4]; - int i; - int j; - char c; - - signal(SIGILL,nope); - - x[0] = 0; - x[1] = 0; - x[2] = 0; - x[3] = 0; - - asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); - if (!x[0]) return 0; - asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); - - for (i = 1;i < 4;++i) - for (j = 0;j < 4;++j) { - c = x[i] >> (8 * j); - if (c < 32) c = 32; - if (c > 126) c = 126; - putchar(c); - } - - printf("-%08x-%08x\n",y[0],y[3]); - - return 0; -}