Started to get VAX-targeted lib/libc build working, can build up to gen/abort.c
authorNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 17:07:29 +0000 (04:07 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 17:07:29 +0000 (04:07 +1100)
21 files changed:
.gitignore
bin/as/bignum1.c
lib/libc/Makefile
lib/libc/Makefile.linux [new file with mode: 0644]
lib/libc/linux/csu/Makefile
lib/libc/linux/gen/Makefile
lib/libc/linux/sys/Makefile
lib/libc/linux/sys/mkdir.c [new file with mode: 0644]
lib/libc/linux/sys/rmdir.c [new file with mode: 0644]
lib/libc/vax/compat-4.1/Makefile
lib/libc/vax/compat-sys5/Makefile
lib/libc/vax/csu/Makefile
lib/libc/vax/gen/Makefile
lib/libc/vax/net/Makefile
lib/libc/vax/sys/Makefile
lib/pcc/Makefile
lib/pcc/config.h
lib/pcc/ndu.h
lib/pcc/trees.c
n.sh
scripts/fixmake.sh

index 583b690..2d56b8c 100644 (file)
@@ -76,6 +76,7 @@ cproto-4.6/cproto
 cproto-4.6/lex.yy.c
 cproto-4.6/stamp-h
 cproto-4.6/y.tab.c
+lib/c2/c2
 lib/cpp/cpp
 lib/cpp/cpy.c
 lib/libc/compat-4.1/compat-4.1lib
index 64a714b..c33d199 100644 (file)
@@ -6,6 +6,11 @@
 /*#include "asnumber.h" as.h*/
 /*#include "instrs.h" as.h*/
 
+#ifdef X_
+/* temporarily pass atof() to host library until we have a better solution */
+#pragma include <math.h>
+#endif
+
 /*
  * Copyright (c) 1982 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
@@ -26,7 +31,11 @@ static char sccsid[] = "@(#)bignum1.c        5.1 (Berkeley) 4/30/85";
 Bignum as_atof(numbuf, radix, ovfp) char *numbuf; int radix; Ovf *ovfp; {
        Bignum  number;
        extern  int     errno;
+#ifdef X_
+       double  nox_atof();
+#else
        double  atof();
+#endif
 
        number = Znumber;
        errno = 0;
@@ -35,7 +44,11 @@ Bignum as_atof(numbuf, radix, ovfp) char *numbuf; int radix; Ovf *ovfp; {
        case TYPD:
                number.num_tag = TYPD;
                *ovfp = 0;
+#ifdef X_
+               number.num_num.numFd_float.Fd_value = nox_atof(numbuf);
+#else
                number.num_num.numFd_float.Fd_value = atof(numbuf);
+#endif
                break;
        case TYPG:
        case TYPH:
index 832b525..15fb840 100644 (file)
@@ -42,8 +42,7 @@ HOSTLOOKUP=   named
 DESTDIR=
 INSTALL=install -m 644
 DFLMON=        mon.o
-MACHINE=linux
-#vax
+MACHINE=vax
 DEFS=
 COMPAT=        compat-4.1 compat-sys5
 ALL=   gen inet net ns stdio sys ${COMPAT} ${MACHINE}
@@ -54,19 +53,15 @@ libc.a libc_p.a: ${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}
        -mkdir tmp
        for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
        cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib
-#      ls tmp/*.o | sort -t/ +1 > t1
-       ls tmp/*.o | LC_ALL=C sort -t/ > t1
-       ar cr libc.a `lorder \`cat t1\` | tsort`
-# ${MACHINE}/csu/${DFLMON}
+       ls tmp/*.o | sort -t/ +1 > t1
+       ar cr libc.a `lorder \`cat t1\` | tsort` ${MACHINE}/csu/${DFLMON}
        ar ma findiop.o libc.a exit.o
        ar ma exit.o libc.a fakcu.o
        rm -f t1 tmp/*
        for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
        cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib_p
-#      ls tmp/*.o | sort -t/ +1 > t1
-       ls tmp/*.o | LC_ALL=C sort -t/ > t1
-       ar cr libc_p.a `lorder \`cat t1\` | tsort`
-# ${MACHINE}/csu/${DFLMON}
+       ls tmp/*.o | sort -t/ +1 > t1
+       ar cr libc_p.a `lorder \`cat t1\` | tsort` ${MACHINE}/csu/${DFLMON}
        ar ma findiop.o libc_p.a exit.o
        ar ma exit.o libc_p.a fakcu.o
        rm -rf t1 tmp
diff --git a/lib/libc/Makefile.linux b/lib/libc/Makefile.linux
new file mode 100644 (file)
index 0000000..832b525
--- /dev/null
@@ -0,0 +1,101 @@
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved.  The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+#      @(#)Makefile    4.19 (Berkeley) 3/9/86
+#
+#
+# The system has two monitoring schemes, utilizing either ``prof''
+# or ``gprof''. DFLMON determines the default profiler; mon.o
+# specifies that ``prof'' is the default, gmon.o specifies that
+# ``gprof'' is the default.
+#
+# Machine dependent routines are located in a subtree which parallels
+# the top directories.  This subtree is identified by the machine name.
+#
+# Compatibility routines are kept in directories with a prefixing
+# ``compat'' (so they all sort together).
+# 
+# The C run-time startup code is always machine dependent and expected
+# to be located in ${MACHINE}/csu
+#
+# All files contain sccsid strings, but these are not compiled into
+# library objects by default, as a space-saving measure.  To produce
+# a library that contains these strings in every object except
+# system call stubs, add -DLIBC_SCCS to DEFS below; to put these
+# strings into system call stubs, use -DSYSLIBC_SCCS.
+#
+# There are two possible methods of doing host name look up.  They are
+# to use the name server or /etc/hosts. HOSTLOOKUP defines which method
+# is to be compiled into libc  :
+#                                                                   
+#      defining HOSTLOOKUP to be "named", compiles the         
+#      host lookup routines that use the BIND name server.
+#
+#      defining HOSTLOOKUP to be "hosttable", compiles
+#      the host lookup routines that use /etc/hosts.
+#
+#HOSTLOOKUP=   hosttable
+HOSTLOOKUP=    named
+#                                                      
+DESTDIR=
+INSTALL=install -m 644
+DFLMON=        mon.o
+MACHINE=linux
+#vax
+DEFS=
+COMPAT=        compat-4.1 compat-sys5
+ALL=   gen inet net ns stdio sys ${COMPAT} ${MACHINE}
+TAGSFILE=tags
+
+libc.a libc_p.a: ${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}
+       rm -rf t1 tmp
+       -mkdir tmp
+       for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
+       cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib
+#      ls tmp/*.o | sort -t/ +1 > t1
+       ls tmp/*.o | LC_ALL=C sort -t/ > t1
+       ar cr libc.a `lorder \`cat t1\` | tsort`
+# ${MACHINE}/csu/${DFLMON}
+       ar ma findiop.o libc.a exit.o
+       ar ma exit.o libc.a fakcu.o
+       rm -f t1 tmp/*
+       for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
+       cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib_p
+#      ls tmp/*.o | sort -t/ +1 > t1
+       ls tmp/*.o | LC_ALL=C sort -t/ > t1
+       ar cr libc_p.a `lorder \`cat t1\` | tsort`
+# ${MACHINE}/csu/${DFLMON}
+       ar ma findiop.o libc_p.a exit.o
+       ar ma exit.o libc_p.a fakcu.o
+       rm -rf t1 tmp
+
+${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}: FRC
+       cd $@; make ${MFLAGS} DEFS=${DEFS}
+
+FRC:
+
+install: 
+       ${INSTALL} libc.a ${DESTDIR}/lib/libc.a
+       ranlib ${DESTDIR}/lib/libc.a
+       ${INSTALL} libc_p.a ${DESTDIR}/usr/lib/libc_p.a
+       ranlib ${DESTDIR}/usr/lib/libc_p.a
+       cd ${MACHINE}/csu; make DESTDIR=${DESTDIR} install
+
+tags:
+       for i in ${ALL}; do \
+               (cd $$i; make ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \
+       done
+       cd net/${HOSTLOOKUP}; \
+               make ${MFLAGS} TAGSFILE=../../${TAGSFILE} tags
+
+clean:
+       for i in ${MACHINE}/csu ${ALL} net/hosttable net/named; \
+               do (cd $$i; make ${MFLAGS} clean); done
+       rm -f t1 tmp/*.o
+       -rmdir tmp
+
+depend:
+       for i in ${MACHINE}/csu ${ALL} net/hosttable net/named; \
+               do (cd $$i; make ${MFLAGS} DEFS=${DEFS} depend); done
index 1729626..fe68311 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
@@ -34,15 +35,15 @@ gcrt0.o: crt0.c
        ${CC} -DGCRT0 -o $@ -c crt0.c
 
 #crt0.o:       crt0.c
-#      cc -S ${DFLAGS} -DCRT0 crt0.c
-#      /lib/cpp crt0.s > x.s
+#      ${CC} -S ${DFLAGS} -DCRT0 crt0.c
+#      ${CPP} crt0.s > x.s
 #      as -o x.o x.s
 #      ${LD} -x -r -o crt0.o x.o
 #      rm -f x.s x.o crt0.s
 #
 #moncrt0.o: crt0.c
-#      cc -S ${DFLAGS} -DMCRT0 crt0.c
-#      /lib/cpp crt0.s > x.s
+#      ${CC} -S ${DFLAGS} -DMCRT0 crt0.c
+#      ${CPP} crt0.s > x.s
 #      as -o x.o x.s
 #      ${LD} -x -r -o moncrt0.o x.o
 #      rm -f x.s x.o crt0.s
@@ -54,14 +55,14 @@ gcrt0.o: crt0.c
 #      ${LD} -x -r -o mcrt0.o moncrt0.o mon.o
 #
 #mon.o: mon.c mon.ex
-#      cc -S ${DEFS} ${DFLAGS} mon.c
+#      ${CC} -S ${DEFS} ${DFLAGS} mon.c
 #      ex - mon.s < mon.ex
 #      as -o x.o mon.s
 #      ${LD} -x -r -o mon.o x.o
 #      rm -f x.o mon.s
 #
 #gmon.o: gmon.c gmon.h gmon.ex
-#      cc -S ${DEFS} ${DFLAGS} gmon.c
+#      ${CC} -S ${DEFS} ${DFLAGS} gmon.c
 #      ex - gmon.s < gmon.ex
 #      as -o x.o gmon.s
 #      ${LD} -x -r -o gmon.o x.o
@@ -83,7 +84,7 @@ lint: crt0.c
 
 depend:
        for i in ${SRCS}; do \
-           cc -M ${DEFS} ${DFLAGS} $$i | awk ' { if ($$1 != prev) \
+           ${CC} -M ${DEFS} ${DFLAGS} $$i | awk ' { if ($$1 != prev) \
                { if (rec != "") print rec; rec = $$0; prev = $$1; } \
                else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
                else rec = rec " " $$2 } } \
index dadc9b6..4569f20 100644 (file)
@@ -32,7 +32,7 @@ clean:
 
 depend:
        for i in ${SRCS}; do \
-           cc -M ${DEFS} $$i | awk ' { if ($$1 != prev) \
+           ${CC} -M ${DEFS} $$i | awk ' { if ($$1 != prev) \
                { if (rec != "") print rec; rec = $$0; prev = $$1; } \
                else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
                else rec = rec " " $$2 } } \
index 8061612..57636cd 100644 (file)
@@ -11,19 +11,19 @@ SRCS=       brk.c chdir.c chmod.c chown.c chroot.c close.c dup2.c dup.c execve.c \
        _exit.c fchmod.c fchown.c fork.c fstat.c ftruncate.c getdtablesize.c \
        getegid.c geteuid.c getgid.c getpagesize.c getpgrp.c getpid.c \
        getppid.c getrusage.c gettimeofday.c getuid.c ioctl.c link.c linux.c \
-       lseek.c lstat.c pipe.c read.c readlink.c readv.c sbrk.c setpgrp.c \
-       setregid.c setreuid.c settimeofday.c sigblock.c sigpause.c \
-       sigsetmask.c sigvec.c stat.c symlink.c sync.c truncate.c umask.c \
-       unlink.c utimes.c vopen.c wait.c wait3.c write.c writev.c
+       lseek.c lstat.c mkdir.c pipe.c read.c readlink.c rmdir.c readv.c \
+       sbrk.c setpgrp.c setregid.c setreuid.c settimeofday.c sigblock.c \
+       sigpause.c sigsetmask.c sigvec.c stat.c symlink.c sync.c truncate.c \
+       umask.c unlink.c utimes.c vopen.c wait.c wait3.c write.c writev.c
 
 OBJS=  brk.o chdir.o chmod.o chown.o chroot.o close.o dup2.o dup.o execve.o \
        _exit.o fchmod.o fchown.o fork.o fstat.o ftruncate.o getdtablesize.o \
        getegid.o geteuid.o getgid.o getpagesize.o getpgrp.o getpid.o \
        getppid.o getrusage.o gettimeofday.o getuid.o ioctl.o link.o linux.o \
-       lseek.o lstat.o pipe.o read.o readlink.o readv.o sbrk.o setpgrp.o \
-       setregid.o setreuid.o settimeofday.o sigblock.o sigpause.o \
-       sigsetmask.o sigvec.o stat.o symlink.o sync.o truncate.o umask.o \
-       unlink.o utimes.o vopen.o wait.o wait3.o write.o writev.o
+       lseek.o lstat.o mkdir.o pipe.o read.o readlink.o rmdir.o readv.o \
+       sbrk.o setpgrp.o setregid.o setreuid.o settimeofday.o sigblock.o \
+       sigpause.o sigsetmask.o sigvec.o stat.o symlink.o sync.o truncate.o \
+       umask.o unlink.o utimes.o vopen.o wait.o wait3.o write.o writev.o
 
 TAGSFILE=tags
 
@@ -48,7 +48,7 @@ clean:
 
 depend:
        for i in ${SRCS}; do \
-           cc -M ${DEFS} $$i | awk ' { if ($$1 != prev) \
+           ${CC} -M ${DEFS} $$i | awk ' { if ($$1 != prev) \
                { if (rec != "") print rec; rec = $$0; prev = $$1; } \
                else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
                else rec = rec " " $$2 } } \
diff --git a/lib/libc/linux/sys/mkdir.c b/lib/libc/linux/sys/mkdir.c
new file mode 100644 (file)
index 0000000..78067ab
--- /dev/null
@@ -0,0 +1,14 @@
+#pragma include <errno.h>
+#pragma include <sys/stat.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int mkdir(p, m) char *p; int m; {
+       if (nox_mkdir(p, ttoh_mode(m))) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/rmdir.c b/lib/libc/linux/sys/rmdir.c
new file mode 100644 (file)
index 0000000..d194b11
--- /dev/null
@@ -0,0 +1,14 @@
+#pragma include <errno.h>
+#pragma include <unistd.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include "linux.h"
+
+int rmdir(p) char *p; {
+       if (nox_rmdir(p)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
index e5d6f3c..4942894 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
@@ -12,10 +13,10 @@ CFLAGS= ${DEFS}
 TAGSFILE=tags
 
 .c.o:
-       /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
        -${LD} -X -r $*.o
        mv a.out profiled/$*.o
-       /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out $*.o
 
index 6f0920a..43af691 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
@@ -12,10 +13,10 @@ CFLAGS= ${DEFS}
 TAGSFILE=tags
 
 .c.o:
-       /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
        -${LD} -X -r $*.o
        mv a.out profiled/$*.o
-       /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out $*.o
 
index 4e3fd80..b7184ce 100644 (file)
@@ -1,3 +1,4 @@
+CPP=${CPP}
 LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
@@ -24,14 +25,14 @@ install: ${OBJS}
 
 crt0.o:        crt0.c
        ${CC} -S ${DFLAGS} -DCRT0 crt0.c
-       /lib/cpp crt0.s > x.s
+       ${CPP} crt0.s > x.s
        as -o x.o x.s
        ${LD} -x -r -o crt0.o x.o
        rm -f x.s x.o crt0.s
 
 moncrt0.o: crt0.c
        ${CC} -S ${DFLAGS} -DMCRT0 crt0.c
-       /lib/cpp crt0.s > x.s
+       ${CPP} crt0.s > x.s
        as -o x.o x.s
        ${LD} -x -r -o moncrt0.o x.o
        rm -f x.s x.o crt0.s
index bd1584a..b91643a 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #      Makefile        4.13    86/01/09
 #
@@ -13,10 +14,10 @@ CFLAGS=     -O ${DEFS}
 TAGSFILE=tags
 
 .s.o:
-       /lib/cpp -E ${DEFS} -DPROF $*.s | ${AS} -o $*.o
+       ${CPP} -E ${DEFS} -DPROF $*.s | ${AS} -o $*.o
        -${LD} -X -r $*.o
        mv a.out profiled/$*.o
-       /lib/cpp -E ${DEFS} $*.s | ${AS} -o $*.o
+       ${CPP} -E ${DEFS} $*.s | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out $*.o
 
index 6993f16..94c1744 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #
 # Copyright (c) 1983 Regents of the University of California.
@@ -12,10 +13,10 @@ CFLAGS=     ${DEFS}
 TAGSFILE=tags
 
 .c.o:
-       /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out profiled/$*.o
-       /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+       ${CPP} -E ${CFLAGS} $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out $*.o
 
index f6fb1d0..4192978 100644 (file)
@@ -1,3 +1,4 @@
+CPP=/lib/cpp
 LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
@@ -74,10 +75,10 @@ OBJS=       Ovfork.o Ovadvise.o \
 TAGSFILE=tags
 
 .c.o:
-       /lib/cpp -E ${DEFS} -DPROF $*.c | ${AS} -o $*.o
+       ${CPP} -E ${DEFS} -DPROF $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out profiled/$*.o
-       /lib/cpp -E ${DEFS} $*.c | ${AS} -o $*.o
+       ${CPP} -E ${DEFS} $*.c | ${AS} -o $*.o
        -${LD} -x -r $*.o
        mv a.out $*.o
 
index f321262..548c25a 100644 (file)
@@ -179,8 +179,8 @@ fcomm2.o: $(P2INCS) $M/common.c
 
 install: all
        install -s ${TESTDIR}/ccom ${DESTDIR}/lib/ccom
-       install -s ${TESTDIR}/sccom ${DESTDIR}/lib/sccom
-       install -s ${TESTDIR}/f1 ${DESTDIR}/lib/f1
+#      install -s ${TESTDIR}/sccom ${DESTDIR}/lib/sccom
+#      install -s ${TESTDIR}/f1 ${DESTDIR}/lib/f1
 
 GREP=  egrep
 
index 5402969..301b2f7 100644 (file)
@@ -12,7 +12,8 @@
 /*
  * These flags control global compiler operation.
  */
-#define        BUFSTDERR       1               /* buffer output to stderr */
+/* note: following doesn't work, because returning from main() destroys buf */
+/*#define      BUFSTDERR       1*/             /* buffer output to stderr */
 #define STDPRTREE      1               /* means include prtree */
 #define NESTCALLS      1               /* disallow two concurrent store()'s */
 #define        FLEXNAMES       1               /* arbitrary length identifiers */
index 27f539b..0b8744a 100644 (file)
@@ -39,9 +39,23 @@ union ndu {
 #else
                char    *name;
                int     stalign;
+#endif
+#ifdef __x86_64__
+ /* this is very non-ideal, code such as the following in pftn.c,
+  *    p->tn.rval = p->in.left->tn.rval;
+  *    p->in.type = p->in.left->in.type;
+  * uses the different node types interchangeably, just align them for now
+  */
+ int pad0;
 #endif
                CONSZ   lval;
+#ifdef __x86_64__
+ int pad1;
+#endif
                int     rval;
+#ifdef __x86_64__
+ int pad2;
+#endif
        } tn;
        struct {                /* branch node */
                int     op;
index f375b0b..73f675e 100644 (file)
@@ -1230,6 +1230,7 @@ NODE *block(o, l, r, t, d, s) int o; register NODE *l; register NODE *r; TWORD t
        register NODE *p;
 
        p = talloc();
+ /*fprintf(stderr, "block(%d, %p, %p, %d, %d, %d)=%p\n", o, l, r, t, d, s, p);*/
        p->in.op = o;
        p->in.left = l;
        p->in.right = r;
diff --git a/n.sh b/n.sh
index 93a70bd..8357b83 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -5,69 +5,74 @@ 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
-mkdir -p lib/libc/inet/profiled
-mkdir -p lib/libc/linux/gen/profiled
-mkdir -p lib/libc/linux/profiled
-mkdir -p lib/libc/linux/sys/profiled
-mkdir -p lib/libc/net/hosttable/profiled
-mkdir -p lib/libc/net/named/profiled
-mkdir -p lib/libc/net/profiled
-mkdir -p lib/libc/ns/profiled
-mkdir -p lib/libc/stdio/profiled
-mkdir -p lib/libc/sys/profiled
+## 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
+#mkdir -p lib/libc/inet/profiled
+#mkdir -p lib/libc/linux/gen/profiled
+#mkdir -p lib/libc/linux/profiled
+#mkdir -p lib/libc/linux/sys/profiled
+#mkdir -p lib/libc/net/hosttable/profiled
+#mkdir -p lib/libc/net/named/profiled
+#mkdir -p lib/libc/net/profiled
+#mkdir -p lib/libc/ns/profiled
+#mkdir -p lib/libc/stdio/profiled
+#mkdir -p lib/libc/sys/profiled
+#
+#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
+#
+#(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 keyword setjmp longjmp
+##pragma typedef jmp_buf
+#EOF
+#cat <<EOF >$STAGE0/usr/include/stdarg.h
+##pragma include <stdarg.h>
+##pragma keyword va_start va_arg va_end
+##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
+#cat <<EOF >$STAGE0/usr/include/varargs.h
+##pragma include <varargs.h>
+##pragma keyword va_alist va_dcl va_start va_arg va_end
+##pragma typedef va_list
+#EOF
+#
+#export PATH="$STAGE0/bin:$STAGE0/usr/bin:$OLDPATH"
+#
+#(cd lib/libc && make clean && make -f Makefile.linux && make -f Makefile.linux 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 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)
+#(cd lib && make clean && make SUBDIR="c2 cpp pcc" && make SUBDIR="c2 cpp pcc" DESTDIR=$STAGE1 install)
+#(cd include && make SHARED=copies DESTDIR=$STAGE1 install)
+#
+export PATH="$STAGE1/bin:$STAGE1/usr/bin:$OLDPATH"
 
-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 keyword setjmp longjmp
-#pragma typedef jmp_buf
-EOF
-cat <<EOF >$STAGE0/usr/include/stdarg.h
-#pragma include <stdarg.h>
-#pragma keyword va_start va_arg va_end
-#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
-cat <<EOF >$STAGE0/usr/include/varargs.h
-#pragma include <varargs.h>
-#pragma keyword va_alist va_dcl va_start va_arg va_end
-#pragma typedef va_list
-EOF
-(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 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)
-(cd lib/cpp && make clean && make && make DESTDIR=$STAGE1 install)
-(cd include && make SHARED=copies DESTDIR=$STAGE1 install)
+(cd lib/libc && make clean && make CPP=$STAGE1/lib/cpp && make DESTDIR=$STAGE1 install)
index 9a874f4..691759a 100755 (executable)
@@ -7,7 +7,7 @@ fi
 
 while test $# -ge 1
 do
-  sed -e 's/   \(-\)\?cc /     \1${CC} /; s/   \(-\)\?ld /     \1${LD} /; s/   \(-\)\?yacc /   \1${YACC} /; s/ \(-\)\?lex /    \1${LEX} /; s/\([        ]\)cc -M /\1${CC} -M /g; /^# DO NOT DELETE THIS LINE -- make depend uses it$/{N; q}' -i $1
+  sed -e 's/   \(-\)\?cc /     \1${CC} /; s/   \(-\)\?ld /     \1${LD} /; s/   \(-\)\?yacc /   \1${YACC} /; s/ \(-\)\?lex /    \1${LEX} /; s/  \(-\)\?\/lib\/cpp /     \1${CPP} /; s/\([        ]\)cc -M /\1${CC} -M /g; /^# DO NOT DELETE THIS LINE -- make depend uses it$/{N; q}' -i $1
   if grep -q '\${LD}' $1 && ! grep -q '^LD[     ]*=' $1
   then
     sed -e '1iLD=ld' -i $1
@@ -20,5 +20,9 @@ do
   then
     sed -e '1iLEX=lex' -i $1
   fi
+  if grep -q '\${CPP}' $1 && ! grep -q '^CPP[   ]*=' $1
+  then
+    sed -e '1iCPP=/lib/cpp' -i $1
+  fi
   shift
 done