Get top level build script n.sh working again, improve path auto detect stuff
authorNick Downing <downing.nick@gmail.com>
Thu, 2 Feb 2017 10:17:05 +0000 (21:17 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 2 Feb 2017 10:17:05 +0000 (21:17 +1100)
79 files changed:
.gitignore
bin/cc.c
bin/ld.c
bin/passwd.c
env.sh
lib/libc/gen/getpwnamuid.c
lib/libc/linux/gen/abort.c
lib/libc/linux/gen/modf.c
lib/libc/linux/sys/_exit.c
lib/libc/linux/sys/brk.c
lib/libc/linux/sys/chdir.c
lib/libc/linux/sys/chmod.c
lib/libc/linux/sys/chown.c
lib/libc/linux/sys/chroot.c
lib/libc/linux/sys/close.c
lib/libc/linux/sys/dup.c
lib/libc/linux/sys/dup2.c
lib/libc/linux/sys/execve.c
lib/libc/linux/sys/fchmod.c
lib/libc/linux/sys/fchown.c
lib/libc/linux/sys/fork.c
lib/libc/linux/sys/fstat.c
lib/libc/linux/sys/ftruncate.c
lib/libc/linux/sys/getdtablesize.c
lib/libc/linux/sys/getegid.c
lib/libc/linux/sys/geteuid.c
lib/libc/linux/sys/getgid.c
lib/libc/linux/sys/getpagesize.c
lib/libc/linux/sys/getpgrp.c
lib/libc/linux/sys/getpid.c
lib/libc/linux/sys/getppid.c
lib/libc/linux/sys/getrusage.c
lib/libc/linux/sys/gettimeofday.c
lib/libc/linux/sys/getuid.c
lib/libc/linux/sys/ioctl.c
lib/libc/linux/sys/link.c
lib/libc/linux/sys/linux.c
lib/libc/linux/sys/linux.h
lib/libc/linux/sys/lseek.c
lib/libc/linux/sys/lstat.c
lib/libc/linux/sys/pipe.c
lib/libc/linux/sys/read.c
lib/libc/linux/sys/readlink.c
lib/libc/linux/sys/readv.c
lib/libc/linux/sys/sbrk.c
lib/libc/linux/sys/setpgrp.c
lib/libc/linux/sys/setregid.c
lib/libc/linux/sys/setreuid.c
lib/libc/linux/sys/settimeofday.c
lib/libc/linux/sys/sigblock.c
lib/libc/linux/sys/sigpause.c
lib/libc/linux/sys/sigsetmask.c
lib/libc/linux/sys/sigvec.c
lib/libc/linux/sys/stat.c
lib/libc/linux/sys/symlink.c
lib/libc/linux/sys/sync.c
lib/libc/linux/sys/truncate.c
lib/libc/linux/sys/umask.c
lib/libc/linux/sys/unlink.c
lib/libc/linux/sys/utimes.c
lib/libc/linux/sys/vopen.c
lib/libc/linux/sys/wait.c
lib/libc/linux/sys/wait3.c
lib/libc/linux/sys/write.c
lib/libc/linux/sys/writev.c
n.sh
scripts/make.sh [deleted file]
scripts/make0.sh [new file with mode: 0755]
usr.bin/yacc/dextern.h
usr.bin/yacc/files.h
usr.bin/yacc/uniqify.sed [new file with mode: 0644]
usr.bin/yacc/x_yaccpar [deleted file]
usr.bin/yacc/y1.c
xify/Makefile
xify/cc.sh
xify/hostcc.sh [deleted file]
xify/ld.sh [moved from xify/hostld.sh with 94% similarity]
xify/xify.sh
xify/xifyfilt.c

index ea18620..0b0f95a 100644 (file)
@@ -76,7 +76,8 @@ cproto-4.6/cproto
 cproto-4.6/lex.yy.c
 cproto-4.6/stamp-h
 cproto-4.6/y.tab.c
-cross
+stage0
+stage1
 lib/libc/compat-4.1/compat-4.1lib
 lib/libc/compat-4.1/compat-4.1lib_p
 lib/libc/compat-sys5/compat-sys5lib
index 1ea6cb4..c1fbc5a 100644 (file)
--- a/bin/cc.c
+++ b/bin/cc.c
@@ -8,6 +8,10 @@
 /*#include <sys/signal.h> gen.h*/
 #include <sys/wait.h>
 
+#ifdef X_
+#include <sys/stat.h>
+#endif
+
 #if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)cc.c 4.13 9/18/85";
 #endif
@@ -21,6 +25,7 @@ static        char sccsid[] = "@(#)cc.c 4.13 9/18/85";
 /*#include <sys/dir.h>*/
 
 #ifdef X_
+char   bin[MAXPATHLEN];
 char   *cpp;
 char   *ccom;
 char   *sccom;
@@ -75,26 +80,39 @@ char *savestr __P((register char *cp));
 char *strspl __P((char *left, char *right));
 
 void main(argc, argv) int argc; char **argv; {
-#ifdef X_
-       char *root;
-#endif
        char *t;
        char *assource;
        int i, j, c;
-
 #ifdef X_
-       root = savestr(argv[0]);
-       for (i = strlen(root); i > 0 && root[i - 1] != '/'; --i)
+       char *pathptr;
+       struct stat statbuf;
+
+       for (i = strlen(argv[0]); i > 0 && argv[0][i - 1] != '/'; --i)
                ;
-       root[i] = 0;
-       cpp = strspl(root, "../lib/cpp");
-       ccom = strspl(root, "../lib/ccom");
-       sccom = strspl(root, "../lib/sccom");
-       c2 = strspl(root, "../lib/c2");
-       as = strspl(root, "as");
-       ld = strspl(root, "ld");
-       crt0 = strspl(root, "../lib/crt0.o");
+       if (i)
+               bcopy(argv[0], bin, i);
+       else if ((pathptr = getenv("PATH")) != 0)
+               do {
+                       for (; pathptr[i] && pathptr[i] != ':'; ++i)
+                               ;
+                       bcopy(pathptr, bin, i);
+                       bin[i++] = '/';
+                       strcpy(bin + i, argv[0]);
+                       if (stat(bin, &statbuf) == 0)
+                               break;
+                       pathptr += i;
+                       i = 0;
+               } while (pathptr[-1]);
+       bin[i] = 0;
+       cpp = strspl(bin, "../lib/cpp");
+       ccom = strspl(bin, "../lib/ccom");
+       sccom = strspl(bin, "../lib/sccom");
+       c2 = strspl(bin, "../lib/c2");
+       as = strspl(bin, "as");
+       ld = strspl(bin, "ld");
+       crt0 = strspl(bin, "../lib/crt0.o");
 #endif
+
        /* ld currently adds upto 5 args; 10 is room to spare */
        av = (char **)calloc(argc+10, sizeof (char **));
        clist = (char **)calloc(argc, sizeof (char **));
@@ -128,10 +146,7 @@ void main(argc, argv) int argc; char **argv; {
                case 'p':
                        proflag++;
 #ifdef X_
-                       t = "../lib/mcrt0.o";
-                       if (argv[i][2] == 'g')
-                               t = "../usr/lib/gcrt0.o";
-                       crt0 = strspl(root, t);
+                       crt0 = strspl(bin, argv[i][2] == 'g' ? "../usr/lib/gcrt0.o" : "../lib/mcrt0.o");
 #else
                        crt0 = "/lib/mcrt0.o";
                        if (argv[i][2] == 'g')
index 8429568..40a5faa 100644 (file)
--- a/bin/ld.c
+++ b/bin/ld.c
@@ -58,6 +58,10 @@ static char sccsid[] = "@(#)ld.c     5.4 (Berkeley) 11/26/85";
 /*#include <sys/stat.h>*/
 /*#include <sys/file.h>*/
 
+#ifdef X_
+char   bin[MAXPATHLEN];
+#endif
+
 /*
  * Basic strategy:
  *
@@ -437,20 +441,33 @@ void bflushc __P((register struct biobuf *bp, int c));
 void bseek __P((register struct biobuf *bp, register off_t off));
 
 void main(argc, argv) int argc; char **argv; {
-#ifdef X_
-       char *root;
-#endif
        register int c, i;
        int num;
        register char *ap, **p;
        char save;
-
 #ifdef X_
-       root = savestr(argv[0]);
-       for (i = strlen(root); i > 0 && root[i - 1] != '/'; --i)
+       char *pathptr;
+       struct stat statbuf;
+
+       for (i = strlen(argv[0]); i > 0 && argv[0][i - 1] != '/'; --i)
                ;
-       root[i] = 0;
+       if (i)
+               bcopy(argv[0], bin, i);
+       else if ((pathptr = getenv("PATH")) != 0)
+               do {
+                       for (; pathptr[i] && pathptr[i] != ':'; ++i)
+                               ;
+                       bcopy(pathptr, bin, i);
+                       bin[i++] = '/';
+                       strcpy(bin + i, argv[0]);
+                       if (stat(bin, &statbuf) == 0)
+                               break;
+                       pathptr += i;
+                       i = 0;
+               } while (pathptr[-1]);
+       bin[i] = 0;
 #endif
+
        if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
                signal(SIGINT, (void (*) __P((int sig)))delexit);
                signal(SIGTERM, (void (*) __P((int sig)))delexit);
@@ -474,9 +491,9 @@ void main(argc, argv) int argc; char **argv; {
        }
        /* add default search directories */
 #ifdef X_
-       dirs[ndir++] = strspl(root, "../lib");
-       dirs[ndir++] = strspl(root, "../usr/lib");
-       dirs[ndir++] = strspl(root, "../usr/local/lib");
+       dirs[ndir++] = strspl(bin, "../lib");
+       dirs[ndir++] = strspl(bin, "../usr/lib");
+       dirs[ndir++] = strspl(bin, "../usr/local/lib");
 #else
        dirs[ndir++] = "/lib";
        dirs[ndir++] = "/usr/lib";
index 599a255..3ef8c73 100644 (file)
@@ -265,32 +265,18 @@ void replace(dp, pwd) DBM *dp; struct passwd *pwd; {
 #else
 #define        COMPACT(e)      tp = pwd->pw_/**/e; while (*cp++ = *tp++);
 #endif
-#ifdef X_
-/* without this adjustment it tries to access x_pwd->x_pw_x_name etc */
-       COMPACT(nox_name);
-       COMPACT(nox_passwd);
-#else
        COMPACT(name);
        COMPACT(passwd);
-#endif
        bcopy((char *)&pwd->pw_uid, cp, sizeof (int));
        cp += sizeof (int);
        bcopy((char *)&pwd->pw_gid, cp, sizeof (int));
        cp += sizeof (int);
        bcopy((char *)&pwd->pw_quota, cp, sizeof (int));
        cp += sizeof (int);
-#ifdef X_
-/* without this adjustment it tries to access x_pwd->x_pw_x_name etc */
-       COMPACT(nox_comment);
-       COMPACT(nox_gecos);
-       COMPACT(nox_dir);
-       COMPACT(nox_shell);
-#else
        COMPACT(comment);
        COMPACT(gecos);
        COMPACT(dir);
        COMPACT(shell);
-#endif
        content.dptr = buf;
        content.dsize = cp - buf;
        key.dptr = pwd->pw_name;
diff --git a/env.sh b/env.sh
index 7af5aed..aa7e08d 100644 (file)
--- a/env.sh
+++ b/env.sh
@@ -1,4 +1,8 @@
 export ROOT=`pwd`
+
 export INCLUDE=$ROOT/cross/usr/include
 export SCRIPTS=$ROOT/scripts
+export STAGE0=$ROOT/stage0
+export STAGE1=$ROOT/stage1
+
 export PATH=$SCRIPTS:$PATH
index 6d2ab2f..43ef93a 100644 (file)
@@ -48,32 +48,18 @@ static struct passwd *fetchpw(key) datum key; {
 #else
 #define        EXPAND(e)       passwd.pw_/**/e = tp; while (*tp++ = *cp++);
 #endif
-#ifdef X_
-/* without this adjustment it tries to access x_passwd.x_pw_x_name etc */
-       EXPAND(nox_name);
-       EXPAND(nox_passwd);
-#else
        EXPAND(name);
        EXPAND(passwd);
-#endif
        bcopy(cp, (char *)&passwd.pw_uid, sizeof (int));
        cp += sizeof (int);
        bcopy(cp, (char *)&passwd.pw_gid, sizeof (int));
        cp += sizeof (int);
        bcopy(cp, (char *)&passwd.pw_quota, sizeof (int));
        cp += sizeof (int);
-#ifdef X_
-/* without this adjustment it tries to access x_passwd.x_pw_x_name etc */
-       EXPAND(nox_comment);
-       EXPAND(nox_gecos);
-       EXPAND(nox_dir);
-       EXPAND(nox_shell);
-#else
        EXPAND(comment);
        EXPAND(gecos);
        EXPAND(dir);
        EXPAND(shell);
-#endif
         return (&passwd);
 }
 
index e4eb702..f74c1a6 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_stdlib.h>
+#pragma include <stdlib.h>
 
 #include <gen.h>
 
index 564ab52..70a6be4 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_math.h>
+#pragma include <math.h>
 
 #include <math.h>
 
index 0807ef6..c4aae10 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_unistd.h>
+#pragma include <unistd.h>
 
 #include <sys/proc.h>
 
index dd85009..aa5180f 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/proc.h>
index 082ae6f..5c92fe8 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/proc.h>
index 9f3d0d2..0bd7d30 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_stat.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/stat.h>
index 46d3932..577dc1e 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/stat.h>
index b20e086..d991db9 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/proc.h>
index ebeb7ae..6793efd 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index 7f5c7b5..1251310 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index e66602c..5a3058a 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index 0f5d1f2..9ee2997 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/exec.h>
index 7705868..3f3dee8 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_stat.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/stat.h>
index caca052..f39e5a0 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/stat.h>
index 1c2a6f9..49b2a6e 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/proc.h>
index 2310669..19af9c7 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_stat.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/stat.h>
index 743186c..3f8672a 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/file.h>
index f7b00a6..0ec14a1 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_unistd.h>
+#pragma include <unistd.h>
 
 #include <sys.h>
 
index 76e1870..456a3fe 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <sys.h>
 #include <sys/types.h>
index fe2b58a..21281e5 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <sys.h>
 #include <sys/types.h>
index 72fd918..dc56465 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <sys.h>
 #include <sys/types.h>
index a9b4c9d..8d8c435 100644 (file)
@@ -1,4 +1,4 @@
-/*#include <nox_unistd.h>*/
+/*#pragma include <unistd.h>*/
 
 #include <sys.h>
 
index 910e582..8017e56 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys.h>
index 0a4f720..89d98fe 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_unistd.h>
+#pragma include <unistd.h>
 
 int getpid() {
        return (int)nox_getpid();
index 7f5fb62..2637199 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_unistd.h>
+#pragma include <unistd.h>
 
 int getpid() {
        return (int)nox_getppid();
index 9e03b22..bcc1176 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <sys/nox_resource.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <sys/resource.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/resource.h>
index 629eb49..f1f4010 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_time.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <sys/time.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/time.h>
index 3bf1cd9..728e65b 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <sys.h>
 #include <sys/types.h>
index c0e825c..1ba32ef 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <sys/nox_ioctl.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/ioctl.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <string.h>
 #include <sys/errno.h>
index aa26d49..b8f1893 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index a9a0e6a..a2312e9 100644 (file)
@@ -1,9 +1,9 @@
-#include <nox_dirent.h>
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <nox_string.h>
-#include <sys/nox_wait.h>
-#include <nox_unistd.h>
+#pragma include <dirent.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <string.h>
+#pragma include <sys/wait.h>
+#pragma include <unistd.h>
 
 #include <gen.h>
 #include <string.h>
index 0161a04..70e558c 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef _LINUX_SYS_LINUX_H_
 #define _LINUX_SYS_LINUX_H_
 
-#include <nox_signal.h>
-#include <sys/nox_resource.h>
-#include <sys/nox_stat.h>
-#include <sys/nox_types.h>
+#pragma include <signal.h>
+#pragma include <sys/resource.h>
+#pragma include <sys/stat.h>
+#pragma include <sys/types.h>
 
 #include <sys/resource.h>
 #include <sys/stat.h>
index 93ce8ac..9f3e5e6 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index f7f1399..4b27271 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_stat.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/stat.h>
index b622afa..a6cc157 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index 733da21..133a744 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index 7adbb30..40b358e 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index a4f369e..32c4cfe 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <nox_unistd.h>
-#include <sys/nox_uio.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <unistd.h>
+#pragma include <sys/uio.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index 2592df0..91d8f3f 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/proc.h>
index cdccc10..18d12dd 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys.h>
index 8919b7f..8caa7fa 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys.h>
index 2cafd12..51ac735 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys.h>
index 7b8802d..6285b5f 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_time.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <sys/time.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/time.h>
index 181f300..8253b16 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_stdlib.h>
-#include <sys/nox_signal.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <stdlib.h>
+#pragma include <sys/signal.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <sys/signal.h>
 #include <sys/types.h>
index 38ea4dc..58692d9 100644 (file)
@@ -1,8 +1,8 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <sys/nox_signal.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <sys/signal.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/signal.h>
index a98768f..fd3edc8 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_stdlib.h>
-#include <sys/nox_signal.h>
-#include <sys/nox_types.h>
-#include <nox_unistd.h>
+#pragma include <stdlib.h>
+#pragma include <sys/signal.h>
+#pragma include <sys/types.h>
+#pragma include <unistd.h>
 
 #include <sys/signal.h>
 #include <sys/types.h>
index 6d593bd..43075b3 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <nox_signal.h>
-#include <nox_stdlib.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <signal.h>
+#pragma include <stdlib.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index 6ddf5ec..5eb0fad 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_stat.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/stat.h>
index 75d0ced..f2bc7fa 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <errno.h>
 #include <sys/file.h>
index f6f64cf..1ce300b 100644 (file)
@@ -1,4 +1,4 @@
-#include <nox_unistd.h>
+#pragma include <unistd.h>
 
 #include <sys.h>
 
index fc1b062..69e1865 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/file.h>
index bdf9bac..66b869e 100644 (file)
@@ -1,5 +1,5 @@
-#include <sys/nox_stat.h>
-#include <sys/nox_types.h>
+#pragma include <sys/stat.h>
+#pragma include <sys/types.h>
 
 #include <sys/stat.h>
 
index d573238..eacc22a 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index a90b80c..65b9e04 100644 (file)
@@ -1,6 +1,6 @@
-#include <nox_errno.h>
-#include <sys/nox_time.h>
-#include <sys/nox_types.h>
+#pragma include <errno.h>
+#pragma include <sys/time.h>
+#pragma include <sys/types.h>
 
 #include <errno.h>
 #include <sys/time.h>
index d4c80f6..c98b8c2 100644 (file)
@@ -1,8 +1,8 @@
-#include <nox_errno.h>
-#include <nox_fcntl.h>
-#include <nox_stdlib.h>
-#include <sys/nox_stat.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <fcntl.h>
+#pragma include <stdlib.h>
+#pragma include <sys/stat.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index d8a65c1..e98bd75 100644 (file)
@@ -1,8 +1,8 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <sys/nox_types.h>
-#include <sys/nox_wait.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <sys/types.h>
+#pragma include <sys/wait.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/types.h>
index 9ffdffc..220e9d2 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <sys/nox_resource.h>
-#include <sys/nox_types.h>
-#include <sys/nox_wait.h>
+#pragma include <errno.h>
+#pragma include <sys/resource.h>
+#pragma include <sys/types.h>
+#pragma include <sys/wait.h>
 
 #include <sys/errno.h>
 #include <sys/resource.h>
index 6bc2520..bea7e40 100644 (file)
@@ -1,5 +1,5 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
+#pragma include <errno.h>
+#pragma include <unistd.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
index bb6c521..d5f4c8d 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_errno.h>
-#include <nox_stdlib.h>
-#include <nox_unistd.h>
-#include <sys/nox_uio.h>
+#pragma include <errno.h>
+#pragma include <stdlib.h>
+#pragma include <unistd.h>
+#pragma include <sys/uio.h>
 
 #include <sys/errno.h>
 #include <sys/file.h>
diff --git a/n.sh b/n.sh
index 06d5285..0890e61 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -1,18 +1,11 @@
 #!/bin/sh -e
 
 ROOT=`pwd`
-PATH=$ROOT/scripts:$PATH
-
-rm -rf cross
-mkdir -p cross/bin
-mkdir -p cross/lib
-mkdir -p cross/usr/bin
-mkdir -p cross/usr/include
-mkdir -p cross/usr/lib
-
-(cd xify && make clean && make && make install)
-(cd include && make.sh SHARED=copies install)
+STAGE0=$ROOT/stage0
+STAGE1=$ROOT/stage1
+OLDPATH="$PATH"
 
+# these should always exist, but are sometimes lost due to git on empty dirs
 mkdir -p lib/libc/compat-4.1/profiled
 mkdir -p lib/libc/compat-sys5/profiled
 mkdir -p lib/libc/gen/profiled
@@ -26,10 +19,48 @@ mkdir -p lib/libc/net/profiled
 mkdir -p lib/libc/ns/profiled
 mkdir -p lib/libc/stdio/profiled
 mkdir -p lib/libc/sys/profiled
-(cd lib/libc && make.sh clean && make.sh && make.sh install)
 
-(cd usr.bin/yacc && make.sh clean && make.sh && make.sh install)
-(cd usr.bin/lex && make.sh clean && make.sh && make.sh install)
+rm -rf $STAGE0
+mkdir -p $STAGE0/bin
+mkdir -p $STAGE0/lib
+mkdir -p $STAGE0/usr/bin
+mkdir -p $STAGE0/usr/include
+mkdir -p $STAGE0/usr/lib
+
+export PATH="$STAGE0/bin:$STAGE0/usr/bin:$OLDPATH"
+
+(cd xify && make clean && PATH="$OLDPATH" make && make DESTDIR=$STAGE0 install)
+(cd include && make SHARED=copies DESTDIR=$STAGE0 install)
+cat <<EOF >$STAGE0/usr/include/setjmp.h
+#pragma include <setjmp.h>
+#pragma typedef jmp_buf
+EOF
+cat <<EOF >$STAGE0/usr/include/stdarg.h
+#pragma include <stdarg.h>
+#pragma keyword va_start va_arg va_endarg
+#pragma typedef va_list
+EOF
+cat <<EOF >$STAGE0/usr/include/stdint.h
+#pragma include <stdint.h>
+#pragma typedef int8_t int16_t int32_t int64_t intptr_t ssize_t
+#pragma typedef uint8_t uint16_t uint32_t uint64_t uintptr_t size_t
+EOF
+rm -f $STAGE0/usr/include/varargs.h
+(cd lib/libc && make clean && make && make DESTDIR=$STAGE0 install)
+(cd usr.bin/yacc && make clean && make && make DESTDIR=$STAGE0 install)
+cat - usr.bin/yacc/yaccpar <<EOF >$STAGE0/usr/lib/yaccpar
+#pragma ifdef __GNUC__
+#pragma pragma GCC diagnostic ignored "-Wunused-label"
+#pragma endif
+EOF
+(cd usr.bin/lex && make clean && make && make DESTDIR=$STAGE0 install)
+
+rm -rf $STAGE1
+mkdir -p $STAGE1/bin
+mkdir -p $STAGE1/lib
+mkdir -p $STAGE1/usr/bin
+mkdir -p $STAGE1/usr/include
+mkdir -p $STAGE1/usr/lib
 
-(cd bin && make.sh clean && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= install)
-(cd usr.bin && make.sh clean && make.sh SUBDIR=find NSTD= KMEM= && make.sh SUBDIR=find NSTD= KMEM= install)
+(cd bin && make clean && make SUBDIR="as csh diff sed sh tp" NSTD= KMEM= && make DESTDIR=$STAGE1 SUBDIR="as csh diff sed sh tp" NSTD= KMEM= install)
+(cd usr.bin && make clean && make SUBDIR="find lex yacc" NSTD= KMEM= && make DESTDIR=$STAGE1 SUBDIR="find lex yacc" NSTD= KMEM= install)
diff --git a/scripts/make.sh b/scripts/make.sh
deleted file mode 100755 (executable)
index beea003..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-ROOT=`dirname $0`/..
-ROOT=`cd $ROOT && pwd`
-make X_="x_" CC="$ROOT/cross/bin/hostcc -Dunix -Dvax" LD="$ROOT/cross/bin/hostld" YACC="$ROOT/cross/usr/bin/yacc" LEX="$ROOT/cross/usr/bin/lex" DESTDIR="$ROOT/cross" "$@"
diff --git a/scripts/make0.sh b/scripts/make0.sh
new file mode 100755 (executable)
index 0000000..ae35161
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+ROOT=`dirname $0`/..
+ROOT=`cd $ROOT && pwd`
+STAGE0=$ROOT/stage0
+PATH=$STAGE0/bin:$STAGE0/usr/bin:$PATH make DESTDIR=$STAGE0 "$@"
index 7c3ebe1..adc7284 100644 (file)
@@ -25,7 +25,7 @@
        /* sizes and limits */
 
 /* Nick changed memory size to reflect that some words allocated are pointers */
-# ifdef HUGE
+# ifdef _HUGE
 # define ACTSIZE 12000
 # define MEMSIZE (24000 * sizeof(char *) / sizeof(int))
 # define NSTATES 750
index 5c95a14..50bc5d5 100644 (file)
@@ -17,6 +17,6 @@
 # define PARSER "/usr/lib/yaccpar"
 
        /* basic size of the Yacc implementation */
-# define HUGE
+# define _HUGE
 
 #endif
diff --git a/usr.bin/yacc/uniqify.sed b/usr.bin/yacc/uniqify.sed
new file mode 100644 (file)
index 0000000..12dd1d8
--- /dev/null
@@ -0,0 +1,9 @@
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@HUGE@/@_HUGE@/
+
+s/@//g
+s/ATSIGN/@/g
diff --git a/usr.bin/yacc/x_yaccpar b/usr.bin/yacc/x_yaccpar
deleted file mode 100644 (file)
index 0a2b8e0..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-#if defined(DOSCCS) && !defined(lint)
-static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
-#endif
-
-#ifdef __GNUC__
-#pragma nox_GCC nox_diagnostic nox_ignored "-Wunused-label"
-#endif
-
-#
-# define YYFLAG -1000
-# define YYERROR goto yyerrlab
-# define YYACCEPT return(0)
-# define YYABORT return(1)
-
-/*     parser for yacc output  */
-
-#ifdef YYDEBUG
-int yydebug = 0; /* 1 for debugging */
-#endif
-YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
-int yychar = -1; /* current input token number */
-int yynerrs = 0;  /* number of errors */
-short yyerrflag = 0;  /* error recovery flag */
-
-int yyparse() {
-
-       short yys[YYMAXDEPTH];
-       short yyj, yym;
-       register YYSTYPE *yypvt;
-       register short yystate, *yyps, yyn;
-       register YYSTYPE *yypv;
-       register short *yyxi;
-
-       yystate = 0;
-       yychar = -1;
-       yynerrs = 0;
-       yyerrflag = 0;
-       yyps= &yys[-1];
-       yypv= &yyv[-1];
-
- yystack:    /* put a state and value onto the stack */
-
-#ifdef YYDEBUG
-       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
-#endif
-               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
-               *yyps = yystate;
-               ++yypv;
-               *yypv = yyval;
-
- yynewstate:
-
-       yyn = yypact[yystate];
-
-       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
-
-       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
-       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
-
-       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
-               yychar = -1;
-               yyval = yylval;
-               yystate = yyn;
-               if( yyerrflag > 0 ) --yyerrflag;
-               goto yystack;
-               }
-
- yydefault:
-       /* default state action */
-
-       if( (yyn=yydef[yystate]) == -2 ) {
-               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
-               /* look through exception table */
-
-               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
-
-               while( *(yyxi+=2) >= 0 ){
-                       if( *yyxi == yychar ) break;
-                       }
-               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
-               }
-
-       if( yyn == 0 ){ /* error */
-               /* error ... attempt to resume parsing */
-
-               switch( yyerrflag ){
-
-               case 0:   /* brand new error */
-
-                       yyerror( "syntax error" );
-               yyerrlab:
-                       ++yynerrs;
-
-               case 1:
-               case 2: /* incompletely recovered error ... try again */
-
-                       yyerrflag = 3;
-
-                       /* find a state where "error" is a legal shift action */
-
-                       while ( yyps >= yys ) {
-                          yyn = yypact[*yyps] + YYERRCODE;
-                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
-                             yystate = yyact[yyn];  /* simulate a shift of "error" */
-                             goto yystack;
-                             }
-                          yyn = yypact[*yyps];
-
-                          /* the current yyps has no shift onn "error", pop stack */
-
-#ifdef YYDEBUG
-                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
-#endif
-                          --yyps;
-                          --yypv;
-                          }
-
-                       /* there is no state on the stack with an error shift ... abort */
-
-       yyabort:
-                       return(1);
-
-
-               case 3:  /* no shift yet; clobber input char */
-
-#ifdef YYDEBUG
-                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
-#endif
-
-                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
-                       yychar = -1;
-                       goto yynewstate;   /* try again in the same state */
-
-                       }
-
-               }
-
-       /* reduction by production yyn */
-
-#ifdef YYDEBUG
-               if( yydebug ) printf("reduce %d\n",yyn);
-#endif
-               yyps -= yyr2[yyn];
-               yypvt = yypv;
-               yypv -= yyr2[yyn];
-               yyval = yypv[1];
-               yym=yyn;
-                       /* consult goto table to find next state */
-               yyn = yyr1[yyn];
-               yyj = yypgo[yyn] + *yyps + 1;
-               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
-               switch(yym){
-                       $A
-               }
-               goto yystack;  /* stack new state and value */
-
-       }
index 228718f..7ef3af2 100644 (file)
@@ -10,7 +10,9 @@
 /*#include "files.h" dextern.h*/
 
 #ifdef X_
-#include <string.h>
+#include <gen.h>
+/*#include <strings.h> gen.h*/
+#include <sys/stat.h>
 #endif
 
 #if defined(DOSCCS) && !defined(lint)
@@ -72,10 +74,25 @@ static char parser[] = PARSER;
 int main(argc, argv) int argc; char *argv[]; {
 #ifdef X_
        int i;
+       char *pathptr;
+       struct stat statbuf;
 
        for (i = strlen(argv[0]); i > 0 && argv[0][i - 1] != '/'; --i)
                ;
-       bcopy(argv[0], parser, i);
+       if (i)
+               bcopy(argv[0], parser, i);
+       else if ((pathptr = getenv("PATH")) != 0)
+               do {
+                       for (; pathptr[i] && pathptr[i] != ':'; ++i)
+                               ;
+                       bcopy(pathptr, parser, i);
+                       parser[i++] = '/';
+                       strcpy(parser + i, argv[0]);
+                       if (stat(parser, &statbuf) == 0)
+                               break;
+                       pathptr += i;
+                       i = 0;
+               } while (pathptr[-1]);
        strcpy(parser + i, "../lib/yaccpar");
 #endif
 
index a1fa85e..892d7e2 100644 (file)
@@ -1,15 +1,13 @@
-ROOT=..
-CC=gcc -g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
-DESTDIR=${ROOT}/cross
+CFLAGS=-fno-strict-aliasing -g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result
 
 xifyfilt: xifyfilt.c
-       ${CC} -o $@ xifyfilt.c
+       ${CC} ${CFLAGS} -o $@ xifyfilt.c
 
 clean:
        rm -f xifyfilt *.o
 
 install: xifyfilt
-       install hostcc.sh ${DESTDIR}/bin/hostcc
-       install hostld.sh ${DESTDIR}/bin/hostld
+       install cc.sh ${DESTDIR}/bin/cc
+       install ld.sh ${DESTDIR}/bin/ld
        install -s xifyfilt ${DESTDIR}/lib
        install xify.sh ${DESTDIR}/lib/xify
index c681a8c..0333532 100755 (executable)
@@ -1,14 +1,21 @@
 #!/bin/sh
 
-BIN=`dirname $0`
-cpp="$BIN/../lib/cpp"
-ccom="$BIN/../lib/ccom"
-sccom="$BIN/../lib/sccom"
-c2="$BIN/../lib/c2"
-as="$BIN/as"
+BIN="$0"
+if ! echo $BIN |grep -q /
+then
+  BIN=`which $BIN`
+fi
+BIN=`dirname $BIN`
+
+hostcpp=cpp
+include="$BIN/../usr/include"
+xify="$BIN/../lib/xify"
+hostcc=gcc
 ld="$BIN/ld"
 rm=rm
 
+export PATH=/bin:/usr/bin
+
 clist=
 llist=
 plist=
@@ -25,9 +32,10 @@ Gflag=
 Mflag=
 debug=
 dflag=
+xflag=
 nc=0
 nxo=0
-crt0="$BIN/../lib/crto0.o"
+crt0="$BIN/../lib/crt0.o"
 
 while test $# -ge 1
 do
@@ -111,6 +119,9 @@ do
   -d*)
     dflag=$1
     ;;
+  -X)
+    xflag=1
+    ;;
   -*)
     echo "$0: error: bad flag $1" >&2
     exit 1
@@ -162,6 +173,7 @@ done
 #echo "Mflag=$Mflag"
 #echo "debug=$debug"
 #echo "dflag=$dflag"
+#echo "xflag=$xflag"
 #echo "nc=$nc"
 #echo "nxo=$nxo"
 #echo "crt0=$crt0"
@@ -181,6 +193,7 @@ then
   if test -z "$pflag"
   then
     tmp=`mktemp /tmp/ctmXXXXXX`
+    rm $tmp # we only want $tmp.i, $tmp.s and so on
   else
     tmp=
   fi
@@ -211,9 +224,11 @@ then
       fi
       if test -n "$debug"
       then
-        echo $cpp $i$j$plist
+#        echo $hostcpp $i$j $plist
+        echo $hostcpp $i$j -nostdinc -DX_ -Dunix -Dvax$plist -I$include
       fi
-      if ! $cpp $i$j$plist
+#      if ! $hostcpp $i$j$plist
+      if ! $hostcpp $i$j -nostdinc -DX_ -Dunix -Dvax$plist -I$include
       then
         cflag=1
         eflag=1
@@ -225,6 +240,27 @@ then
         continue
       fi
 
+      j=
+      if test -z "$xflag"
+      then
+        j=" $tmp.c"
+      fi
+      if test -n "$debug"
+      then
+        echo $xify $tmp_i$j
+      fi
+      if ! $xify $tmp_i$j
+      then
+        cflag=1
+        eflag=1
+        continue
+      fi
+      if test -n "$xflag"
+      then
+        cflag=1
+        continue
+      fi
+
       if test -n "$sflag"
       then
         if test $nc -eq 1 -a -n "$outfile"
@@ -234,69 +270,136 @@ then
           tmp_s=`echo $i |sed -e 's/.$/s/'`
         fi
       else
-        tmp_s="$tmp.s"
+# optimization: don't call compiler and assembler separately unless have -S
+        tmp_s="$tmp.c"
+        assource="$tmp_s"
+# since we can't "goto" out of enclosing if, duplicate all code until "done"
+        if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
+        then
+          j="$outfile"
+        else
+          j=`echo $i |sed -e 's/.$/o/'`
+        fi
+    #    if test -n "$Rflag"
+    #    then
+    #      j="$j -R"
+    #    fi
+    #    if test -n "$dflag"
+    #    then
+    #      j="$j $dflag"
+    #    fi
+        j="$j -fno-strict-aliasing"
+        if test -n "$proflag"
+        then
+          j="$j -pg"
+        fi
+        if test -n "$gflag" -o -n "$Gflag"
+        then
+          j="$j -g"
+        fi
+        if test -z "$wflag"
+        then
+          j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
+        fi
+        if test -n "$debug"
+        then
+    #      echo $as -o $j $assource
+          echo $hostcc -o $j -c $assource
+        fi
+    #    if ! $as -o $j $assource && $? -gt 1
+        if ! $hostcc -o $j -c $assource
+        then
+          cflag=1
+          eflag=1
+          continue
+        fi
+        if test -n "$tmp_s"
+        then
+          $rm -f $tmp_s
+        fi
+        continue
+# else
+#        tmp_s="$tmp.s"
+# end
       fi
 
-      if test -n "$fflag"
-      then
-        j="$sccom"
-      else
-        j="$ccom"
-      fi
-      if test -n "$oflag"
-      then
-        k="$tmp.c2s"
-      else
-        k="$tmp_s"
-      fi
+#      if test -n "$oflag"
+#      then
+#        k="$tmp.c2s"
+#      else
+#        k="$tmp_s"
+#      fi
+#      if test -n "$proflag"
+#      then
+#        k="$k -XP"
+#      fi
+#      if test -n "$gflag"
+#      then
+#        k="$k -Xg"
+#      elif test -n "$Gflag"
+#      then
+#        k="$k -XG"
+#      fi
+#      if test -n "$wflag"
+#      then
+#        k="$k -w"
+#      fi
+#      if test -n "$debug"
+#      then
+#        echo $j $tmp_i $k
+#      fi
+#      if ! $j $tmp_i $k
+#      then
+#        cflag=1
+#        eflag=1
+#        continue
+#      fi
+#      $rm -f $tmp_i
+#
+#      if test -n "$oflag"
+#      then
+#        if test -n "$debug"
+#        then
+#          echo $c2 $tmp.c2s $tmp_s
+#        fi
+#        if ! $c2 $tmp.c2s $tmp_s
+#        then
+#          $rm -f $tmp_s
+#          tmp_s="$tmp.c2s"
+#        else
+#          $rm -f $tmp.c2s
+#        fi
+#      fi
+      j="$tmp_s -fno-strict-aliasing"
       if test -n "$proflag"
       then
-        k="$k -XP"
+        j="$j -pg"
       fi
-      if test -n "$gflag"
+      if test -n "$gflag" -o -n "$Gflag"
       then
-        k="$k -Xg"
-      elif test -n "$Gflag"
-      then
-        k="$k -XG"
+        j="$j -g"
       fi
-      if test -n "$wflag"
+      if test -z "$wflag"
       then
-        k="$k -w"
+        j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
       fi
       if test -n "$debug"
       then
-        echo $j $tmp_i $k
+        echo $hostcc -o $j -S $tmp.c
       fi
-      if ! $j $tmp_i $k
+      if ! $hostcc -o $j -S $tmp.c
       then
         cflag=1
         eflag=1
         continue
       fi
-      $rm -f $tmp_i
 
-      if test -n "$oflag"
-      then
-        if test -n "$debug"
-        then
-          echo $c2 $tmp.c2s $tmp_s
-        fi
-        if ! $c2 $tmp.c2s $tmp_s
-        then
-          $rm -f $tmp_s
-          tmp_s="$tmp.c2s"
-        else
-          $rm -f $tmp.c2s
-        fi
-      fi
-
-      if test -n "$sflag"
-      then
+#      if test -n "$sflag"
+#      then
         continue
-      fi
-
-      assource="$tmp_s"
+#      fi
+#
+#      assource="$tmp_s"
     fi
 
     if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
@@ -305,19 +408,34 @@ then
     else
       j=`echo $i |sed -e 's/.$/o/'`
     fi
-    if test -n "$Rflag"
+#    if test -n "$Rflag"
+#    then
+#      j="$j -R"
+#    fi
+#    if test -n "$dflag"
+#    then
+#      j="$j $dflag"
+#    fi
+    j="$j -fno-strict-aliasing"
+    if test -n "$proflag"
+    then
+      j="$j -pg"
+    fi
+    if test -n "$gflag" -o -n "$Gflag"
     then
-      j="$j -R"
+      j="$j -g"
     fi
-    if test -n "$dflag"
+    if test -z "$wflag"
     then
-      j="$j $dflag"
+      j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
     fi
     if test -n "$debug"
     then
-      echo $as -o $j $assource
+#      echo $as -o $j $assource
+      echo $hostcc -o $j -c $assource
     fi
-    if ! $as -o $j $assource && $? -gt 1
+#    if ! $as -o $j $assource && $? -gt 1
+    if ! $hostcc -o $j -c $assource
     then
       cflag=1
       eflag=1
diff --git a/xify/hostcc.sh b/xify/hostcc.sh
deleted file mode 100755 (executable)
index a7af0a8..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-#!/bin/sh
-
-BIN=`dirname $0`
-cpp=/lib/cpp
-include="$BIN/../usr/include"
-xify="$BIN/../lib/xify"
-cc=/usr/bin/gcc
-ld="$BIN/hostld"
-rm=rm
-
-clist=
-llist=
-plist=
-cflag=
-oflag=
-pflag=
-sflag=
-Rflag=
-exflag=
-proflag=
-fflag=
-gflag=
-Gflag=
-Mflag=
-debug=
-dflag=
-xflag=
-nc=0
-nxo=0
-crt0="$BIN/../lib/crto0.o"
-
-while test $# -ge 1
-do
-  case "$1" in
-  -S)
-    sflag=1
-    cflag=1
-    ;;
-  -o)
-    if test -z "$2"
-    then
-      echo "$0: error: -o where?" >&2
-      exit 1
-    fi
-    outfile=$2
-    shift
-    if echo $outfile |grep -q '\.c$'
-    then
-      echo "$0: error: -o would overwrite $outfile" >&2
-      exit 1
-    fi
-    ;;
-  -R)
-    Rflag=1
-    ;;
-  -O)
-    oflag=1
-    ;;
-  -p)
-    proflag=1
-    crt0="$BIN/../lib/mcrt0.o"
-    ;;
-  -pg)
-    proflag=1
-    crt0="$BIN/../usr/lib/gcrt0.o"
-    ;;
-  -f)
-    fflag=1
-    ;;
-  -go)
-    Gflag=1
-    ;;
-  -g)
-    gflag=1
-    ;;
-  -w)
-    wflag=1
-    ;;
-  -E)
-    exflag=1
-    pflag=1
-    plist="$plist $1" # this is ignored by 4.3bsd cpp
-    ;;
-  -P)
-    pflag=1
-    echo "$0: warning: -P option obsolete; you should use -E instead"
-    plist="$plist $1"
-    ;;
-  -c)
-    cflag=1
-    ;;
-  -M*)
-    exflag=1
-    pflag=1
-    Mflag=1
-    plist="$plist $1"
-    ;;
-  -Dnox_*)
-    plist="$plist `echo $1 |sed -e 's/^-Dnox_/-D/'`"
-    ;;
-  -D*)
-    plist="$plist `echo $1 |sed -e 's/^-D/-Dx_/'`"
-    ;;
-  -Unox_*)
-    plist="$plist `echo $1 |sed -e 's/^-Unox_/-U/'`"
-    ;;
-  -U*)
-    plist="$plist `echo $1 |sed -e 's/^-U/-Ux_/'`"
-    ;;
-  -I*)
-    plist="$plist $1"
-    ;;
-  -C)
-    plist="$plist $1"
-    ;;
-  -L*)
-    llist="$llist $1"
-    ;;
-  # chpass and passname stuff not implemented
-  -d)
-    debug=1
-    ;;
-  -d*)
-    dflag=$1
-    ;;
-  -X)
-    xflag=1
-    ;;
-  -*)
-    echo "$0: error: bad flag $1" >&2
-    exit 1
-    ;;
-  *)
-    t=$1
-    if echo $t |grep -q '\.[cs]$' || test -n "$exflag"
-    then
-      clist="$clist $t"
-      nc=`expr $nc + 1`
-      t=`echo $t |sed -e 's/.$/o/'`
-    fi
-
-    dup=
-    for i in $llist
-    do
-      if test "$i" = "$t"
-      then
-        dup=1
-        break
-      fi
-    done
-    if test -z "$dup"
-    then
-      llist="$llist $t"
-      if echo $t |grep -q '\.o$'
-      then
-        nxo=`expr $nxo + 1`
-      fi
-    fi
-    ;;
-  esac
-  shift
-done
-
-#echo "clist=$clist"
-#echo "llist=$llist"
-#echo "plist=$plist"
-#echo "cflag=$cflag"
-#echo "oflag=$oflag"
-#echo "pflag=$pflag"
-#echo "sflag=$sflag"
-#echo "Rflag=$Rflag"
-#echo "exflag=$exflag"
-#echo "proflag=$proflag"
-#echo "fflag=$fflag"
-#echo "gflag=$gflag"
-#echo "Gflag=$Gflag"
-#echo "Mflag=$Mflag"
-#echo "debug=$debug"
-#echo "dflag=$dflag"
-#echo "xflag=$xflag"
-#echo "nc=$nc"
-#echo "nxo=$nxo"
-#echo "crt0=$crt0"
-
-if test \( -n "$gflag" -o -n "$Gflag" \) -a -n "$oflag"
-then
-  echo "$0: warning: -g disables -O" >&2
-  oflag=
-fi
-
-eflag=
-
-if test -n "$clist"
-then
-  # signal stuff not implemented
-
-  if test -z "$pflag"
-  then
-    tmp=`mktemp /tmp/ctmXXXXXX`
-  else
-    tmp=
-  fi
-
-  for i in $clist
-  do
-    if test $nc -gt 1 -a -z "$Mflag"
-    then
-      echo "$i:"
-    fi
-
-    if test -z "$Mflag" && echo $i |grep -q '\.s$'
-    then
-      tmp_s=
-      assource=$i
-    else
-      if test -n "$pflag"
-      then
-        tmp_i=`echo $i |sed -e 's/.$/i/'`
-      else
-        tmp_i="$tmp.i"
-      fi
-
-      j=
-      if test -z "$exflag"
-      then
-        j=" $tmp_i"
-      fi
-      if test -n "$debug"
-      then
-#        echo $cpp $i$j$plist
-        echo $cpp $i$j -nostdinc$plist -I$include
-      fi
-#      if ! $cpp $i$j$plist
-      if ! $cpp $i$j -nostdinc$plist -I$include
-      then
-        cflag=1
-        eflag=1
-        continue
-      fi
-      if test -n "$pflag"
-      then
-        cflag=1
-        continue
-      fi
-
-      j=
-      if test -z "$xflag"
-      then
-        j=" $tmp.c"
-      fi
-      if test -n "$debug"
-      then
-        echo $xify $tmp_i$j
-      fi
-      if ! $xify $tmp_i$j
-      then
-        cflag=1
-        eflag=1
-        continue
-      fi
-      if test -n "$xflag"
-      then
-        cflag=1
-        continue
-      fi
-
-      if test -n "$sflag"
-      then
-        if test $nc -eq 1 -a -n "$outfile"
-        then
-          tmp_s="$outfile"
-        else
-          tmp_s=`echo $i |sed -e 's/.$/s/'`
-        fi
-      else
-# optimization: don't call compiler and assembler separately unless have -S
-        tmp_s="$tmp.c"
-        assource="$tmp_s"
-# since we can't "goto" out of enclosing if, duplicate all code until "done"
-        if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
-        then
-          j="$outfile"
-        else
-          j=`echo $i |sed -e 's/.$/o/'`
-        fi
-    #    if test -n "$Rflag"
-    #    then
-    #      j="$j -R"
-    #    fi
-    #    if test -n "$dflag"
-    #    then
-    #      j="$j $dflag"
-    #    fi
-        j="$j -fno-strict-aliasing"
-        if test -n "$proflag"
-        then
-          j="$j -pg"
-        fi
-        if test -n "$gflag" -o -n "$Gflag"
-        then
-          j="$j -g"
-        fi
-        if test -z "$wflag"
-        then
-          j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
-        fi
-        if test -n "$debug"
-        then
-    #      echo $as -o $j $assource
-          echo $cc -o $j -c $assource
-        fi
-    #    if ! $as -o $j $assource && $? -gt 1
-        if ! $cc -o $j -c $assource
-        then
-          cflag=1
-          eflag=1
-          continue
-        fi
-        if test -n "$tmp_s"
-        then
-          $rm -f $tmp_s
-        fi
-        continue
-# else
-#        tmp_s="$tmp.s"
-# end
-      fi
-
-#      if test -n "$oflag"
-#      then
-#        k="$tmp.c2s"
-#      else
-#        k="$tmp_s"
-#      fi
-#      if test -n "$proflag"
-#      then
-#        k="$k -XP"
-#      fi
-#      if test -n "$gflag"
-#      then
-#        k="$k -Xg"
-#      elif test -n "$Gflag"
-#      then
-#        k="$k -XG"
-#      fi
-#      if test -n "$wflag"
-#      then
-#        k="$k -w"
-#      fi
-#      if test -n "$debug"
-#      then
-#        echo $j $tmp_i $k
-#      fi
-#      if ! $j $tmp_i $k
-#      then
-#        cflag=1
-#        eflag=1
-#        continue
-#      fi
-#      $rm -f $tmp_i
-#
-#      if test -n "$oflag"
-#      then
-#        if test -n "$debug"
-#        then
-#          echo $c2 $tmp.c2s $tmp_s
-#        fi
-#        if ! $c2 $tmp.c2s $tmp_s
-#        then
-#          $rm -f $tmp_s
-#          tmp_s="$tmp.c2s"
-#        else
-#          $rm -f $tmp.c2s
-#        fi
-#      fi
-      j="$tmp_s -fno-strict-aliasing"
-      if test -n "$proflag"
-      then
-        j="$j -pg"
-      fi
-      if test -n "$gflag" -o -n "$Gflag"
-      then
-        j="$j -g"
-      fi
-      if test -z "$wflag"
-      then
-        j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
-      fi
-      if test -n "$debug"
-      then
-        echo $cc -o $j -S $tmp.c
-      fi
-      if ! $cc -o $j -S $tmp.c
-      then
-        cflag=1
-        eflag=1
-        continue
-      fi
-
-#      if test -n "$sflag"
-#      then
-        continue
-#      fi
-#
-#      assource="$tmp_s"
-    fi
-
-    if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
-    then
-      j="$outfile"
-    else
-      j=`echo $i |sed -e 's/.$/o/'`
-    fi
-#    if test -n "$Rflag"
-#    then
-#      j="$j -R"
-#    fi
-#    if test -n "$dflag"
-#    then
-#      j="$j $dflag"
-#    fi
-    j="$j -fno-strict-aliasing"
-    if test -n "$proflag"
-    then
-      j="$j -pg"
-    fi
-    if test -n "$gflag" -o -n "$Gflag"
-    then
-      j="$j -g"
-    fi
-    if test -z "$wflag"
-    then
-      j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
-    fi
-    if test -n "$debug"
-    then
-#      echo $as -o $j $assource
-      echo $cc -o $j -c $assource
-    fi
-#    if ! $as -o $j $assource && $? -gt 1
-    if ! $cc -o $j -c $assource
-    then
-      cflag=1
-      eflag=1
-      continue
-    fi
-    if test -n "$tmp_s"
-    then
-      $rm -f $tmp_s
-    fi
-  done
-fi
-
-if test -z "$cflag" -a -n "$llist"
-then
-  if test -n "$outfile"
-  then
-    j=" -o $outfile"
-  else
-    j=
-  fi
-  if test -n "$gflag" -o -n "$Gflag"
-  then
-    k=" -lg"
-  else
-    k=
-  fi
-  if test -n "$proflag"
-  then
-    k="$k -lc_p"
-  else
-    k="$k -lc"
-  fi
-  if test -n "$debug"
-  then
-    echo $ld -X $crt0$j $llist$k
-  fi
-  if ! $ld -X $crt0$j $llist$k
-  then
-    eflag=1
-  elif test $nc -eq 1 -a $nxo -eq 1 -a -z "$eflag"
-  then
-    set $clist
-    $rm -f `echo $1 |sed -e 's/.$/o/'`
-  fi
-fi
-
-#echo "eflag=$eflag"
-exit $eflag
similarity index 94%
rename from xify/hostld.sh
rename to xify/ld.sh
index 04069f5..06d33be 100755 (executable)
@@ -1,12 +1,20 @@
 #!/bin/sh
 
-BIN=`dirname $0`
-cc=/usr/bin/gcc
-ld=/usr/bin/ld
+BIN="$0"
+if ! echo $BIN |grep -q /
+then
+  BIN=`which $BIN`
+fi
+BIN=`dirname $BIN`
+
+hostcc=gcc
+hostld=ld
 mkdir=mkdir
 ln=ln
 rm=rm
 
+export PATH=/bin:/usr/bin
+
 outfile=
 dirs=
 files=
@@ -142,9 +150,9 @@ fi
 
 if test -n "$rflag"
 then
-  cmd="$ld"
+  cmd="$hostld"
 else
-  cmd="$cc"
+  cmd="$hostcc"
 fi
 if test -n "$outfile"
 then
index 0105d7b..725ab4a 100755 (executable)
@@ -1,9 +1,6 @@
 #!/bin/sh
 (
   cat <<EOF
-#ifndef X_
-#define X_
-
 #include <stdint.h>
 
 #define _va_arg_short(argp) va_arg(argp, int)
@@ -19,8 +16,6 @@ typedef int32_t x_long;
 typedef uint16_t x_unsigned_short;
 typedef uint32_t x_unsigned_int;
 typedef uint32_t x_unsigned_long;
-
-#endif
 EOF
   "`dirname "$0"`/xifyfilt" <$1 |sed -e 's/\(extern\|register\|static\) x_int\([        ]\+\(int\|long\|short\|unsigned\|x_Bignum\|x_Iptr\|x_YYSTYPE\|x_bytetoktype\|x_bool\|x_caddr_t\|x_chptr\|x_datum\|x_inttoktype\|x_lgtype\|x_off_t\|x_time_t\|x_u_char\|x_u_int\|x_u_short\|x_u_long\)\)/\1\2/g; s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
 ) >$2
index 2eb5ec9..baa387a 100644 (file)
@@ -107,6 +107,30 @@ int main(int argc, char **argv) {
               }
               continue;
             }
+            else if (n == 7 && memcmp(r, "keyword", 7) == 0) {
+              while (isblank(r[n]))
+                ++n;
+              p = r + n;
+              l = 0;
+              while (isalpha(p[l]) || p[l] == '_') {
+                while (isalnum(p[l]) || p[l] == '_')
+                  ++l;
+ fprintf(stderr, "keyword name: ");
+ fwrite(p, l, 1, stderr);
+ putc('\n', stderr);
+                while (isblank(p[l]))
+                  ++l;
+                p += l;
+                l = 0;
+              }
+              if (p[l] != '\n') {
+                fprintf(stderr, "%s: warning: garbage after #pragma keyword: ", argv[0]);
+                while (p[l] && p[l] != '\n')
+                  putc(p[l++], stderr);
+                putc('\n', stderr);
+              }
+              continue;
+            }
           }
           fwrite(p, l, 1, stdout);
           fputs(p + l + m, stdout);