From 9e9474d0caeb9a486053f67e634178ec068a1330 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Tue, 3 Jan 2017 02:20:35 +1100 Subject: [PATCH] Added lorder and ranlib to cross toolchain, started on include and libc, it makes some progress with libc but bombs out due to what seems to be a linker bug --- .gitignore | 7 +- bin/ar/n.sh | 12 +- bin/as/as0.c | 4 + bin/as/n.sh | 8 +- bin/cc/n.sh | 8 +- bin/ld/Makefile | 13 +- bin/ld/ld.c | 329 ++++++++++++++++++++++++++----- bin/ld/n.sh | 10 +- bin/nm/Makefile | 8 +- bin/nm/n.sh | 8 +- include/a.out.h | 29 ++- include/n.sh | 5 + include/nlist.h | 10 + include/ranlib.h | 14 +- lib/c2/n.sh | 8 +- lib/ccom/n.sh | 8 +- lib/cpp/cpp.c | 6 + lib/cpp/cpp.h | 2 +- lib/cpp/n.sh | 8 +- lib/cpp/yylex.c | 9 - lib/libc/Makefile | 36 ++-- lib/libc/compat-4.1/Makefile | 8 +- lib/libc/compat-43/Makefile | 8 +- lib/libc/compat-sys5/Makefile | 8 +- lib/libc/gen/Makefile | 8 +- lib/libc/inet/Makefile | 8 +- lib/libc/n.sh | 6 + lib/libc/net/Makefile | 8 +- lib/libc/net/hosttable/Makefile | 8 +- lib/libc/net/named/Makefile | 8 +- lib/libc/ns/Makefile | 8 +- lib/libc/pdp/compat-2.9/Makefile | 20 +- lib/libc/pdp/crt/Makefile | 20 +- lib/libc/pdp/csu/Makefile | 26 +-- lib/libc/pdp/gen/Makefile | 20 +- lib/libc/pdp/gen/nsym.c | 32 +-- lib/libc/pdp/net/Makefile | 20 +- lib/libc/pdp/stdio/Makefile | 20 +- lib/libc/pdp/sys/Makefile | 12 +- lib/libc/stdio/Makefile | 8 +- lib/libc/stdlib/Makefile | 8 +- lib/libc/string/Makefile | 8 +- n.sh | 35 ++-- usr.bin/Makefile | 15 +- usr.bin/n.sh | 5 + usr.bin/ranlib/Makefile | 34 ++-- usr.bin/ranlib/_ranlib.h | 23 +++ usr.bin/ranlib/build.c | 31 ++- usr.bin/ranlib/include/ar.h | 1 + usr.bin/ranlib/include/ranlib.h | 1 + usr.bin/ranlib/krcompat.h | 19 ++ usr.bin/ranlib/misc.c | 29 +-- usr.bin/ranlib/n.sh | 6 + usr.bin/ranlib/ranlib.c | 11 +- usr.bin/ranlib/touch.c | 12 +- usr.lib/libvmf/n.sh | 10 +- 56 files changed, 679 insertions(+), 367 deletions(-) create mode 100755 include/n.sh create mode 100755 lib/libc/n.sh create mode 100755 usr.bin/n.sh create mode 100644 usr.bin/ranlib/_ranlib.h create mode 120000 usr.bin/ranlib/include/ar.h create mode 120000 usr.bin/ranlib/include/ranlib.h create mode 100644 usr.bin/ranlib/krcompat.h create mode 100755 usr.bin/ranlib/n.sh diff --git a/.gitignore b/.gitignore index bb05c7d..f2e6588 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ *.[0-9] *.a *.o -host -stage +cross bin/cc/cc bin/ar/ar bin/as/as @@ -14,5 +13,9 @@ lib/ccom/c1 lib/ccom/cvopt lib/cpp/cpp lib/cpp/y.tab.c +stage usr.lib/libvmf/genlib usr.lib/libvmf/genlib_p +usr.bin/lorder +usr.bin/mkdep +usr.bin/nohup diff --git a/bin/ar/n.sh b/bin/ar/n.sh index bbc913b..e0d7173 100755 --- a/bin/ar/n.sh +++ b/bin/ar/n.sh @@ -1,8 +1,8 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/bin\/ar$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -mkdir --parents "$DESTDIR/usr/man/cat1" -mkdir --parents "$DESTDIR/usr/man/cat5" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +mkdir --parents "$CROSSDIR/usr/man/cat1" +mkdir --parents "$CROSSDIR/usr/man/cat5" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install diff --git a/bin/as/as0.c b/bin/as/as0.c index ab74f8a..fc0b148 100644 --- a/bin/as/as0.c +++ b/bin/as/as0.c @@ -3167,7 +3167,11 @@ char chartab[TASCII] = { /* a.tmp1: */ +#ifdef pdp11 +char a_tmp1[] = "/tmp/atm1XX"; +#else char a_tmp1[] = "/tmp/atm1XXXXXX"; /* linux requires 6 X's */ +#endif /* Ncps: .byte 8. */ diff --git a/bin/as/n.sh b/bin/as/n.sh index 9b9317a..f77d11d 100755 --- a/bin/as/n.sh +++ b/bin/as/n.sh @@ -1,6 +1,6 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/bin\/as$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install diff --git a/bin/cc/n.sh b/bin/cc/n.sh index 195dff1..f2126af 100755 --- a/bin/cc/n.sh +++ b/bin/cc/n.sh @@ -1,7 +1,7 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/bin\/cc$//'`" -DESTDIR="$ROOT/host" +CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install diff --git a/bin/ld/Makefile b/bin/ld/Makefile index f94ca66..51d7d99 100644 --- a/bin/ld/Makefile +++ b/bin/ld/Makefile @@ -1,13 +1,15 @@ # Version 2.2 January 24, 1998 -VPATH=../../lib/libc/pdp/gen -SRCS=ld.c nsym.c -OBJS=ld.o nsym.o +# using VPATH to compile ./nsym.o from ../../lib/libc/pdp/gen/nsym.c does not +# work if there is a ../../lib/libc.pdp/gen/nsym.o leftover from building libc +#VPATH=../../lib/libc/pdp/gen +SRCS=ld.c ../../lib/libc/pdp/gen/nsym.c +OBJS=ld.o ../../lib/libc/pdp/gen/nsym.o MAN=ld.0 MANSRC=ld.1 CFLAGS=-O -CPPFLAGS=-Iinclude -I../ar -DNUM_VM_PAGES=20 +CPPFLAGS=-Iinclude -I../ar -DSTAGEDIR=\"${STAGEDIR}\" -DNUM_VM_PAGES=20 SEPFLAG=-i all: ld ld.0 @@ -18,7 +20,8 @@ ld: ${OBJS} install: all # install -c -s -o bin -g bin -m 755 ld ${DESTDIR}/bin/ld # install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat1 - install -c -s -m 755 ld ${DESTDIR}/bin/ld + install -c -m 755 ld ${DESTDIR}/bin/ld +#-s FIX THIS install -c -m 444 ${MAN} ${DESTDIR}/usr/man/cat1 lint: diff --git a/bin/ld/ld.c b/bin/ld/ld.c index 84a9d6a..44cc985 100644 --- a/bin/ld/ld.c +++ b/bin/ld/ld.c @@ -70,6 +70,14 @@ static char *sccsid = "@(#)ld.c 4.6 1998/01/19"; #include "archive.h" #include "krcompat.h" +#ifdef pdp11 +#include +#define OFF_T off_t +#else +#include +#define OFF_T int32_t +#endif + /* * Layout of standard part of a.out file header: * u_int a_magic; magic number @@ -269,7 +277,11 @@ int iflag; /* I/D space separated */ char *ofilename = "l.out"; int infil; /* current input file descriptor */ char *filname; /* and its name */ - char tfname[] = "/tmp/ldaXXXXX"; +#if pdp11 + char tfname[14]; /*[] = "/tmp/ldaXXXXX";*/ +#else + char tfname[15]; /*[] = "/tmp/ldaXXXXXX"; linux requires 6 X's */ +#endif FILE *toutb, *doutb, *troutb, *droutb, *soutb, *voutb; @@ -300,10 +312,10 @@ int delexit PARAMS((void)); void endload PARAMS((int argc, char **argv)); VADDR sym2va PARAMS((int x)); void load1arg PARAMS((register char *cp, int flag)); -int step PARAMS((off_t nloc)); -int ldrand PARAMS((int totnum, off_t sloc)); +int step PARAMS((OFF_T nloc)); +int ldrand PARAMS((int totnum, OFF_T sloc)); void mgets PARAMS((register char *buf, int maxlen, int which)); -int load1 PARAMS((int libflg, off_t loc)); +int load1 PARAMS((int libflg, OFF_T loc)); void middle PARAMS((void)); void ldrsym PARAMS((int ix, u_int val, int type)); void setupout PARAMS((void)); @@ -314,7 +326,7 @@ void finishout PARAMS((void)); long rnd8k PARAMS((u_int siz)); void mkfsym PARAMS((char *s)); void mget PARAMS((register int *loc, int an, int which)); -void dseek PARAMS((int which, off_t aloc, int s)); +void dseek PARAMS((int which, OFF_T aloc, int s)); int get PARAMS((int which)); int getfile PARAMS((char *acp, int flag, int phase)); int libopen PARAMS((char *name, int oflags)); @@ -322,7 +334,7 @@ short *lookup PARAMS((void)); short *slookup PARAMS((char *s)); int enter PARAMS((short *hp)); void error PARAMS((int n, char *s)); -void readhdr PARAMS((off_t loc)); +void readhdr PARAMS((OFF_T loc)); void tcreat PARAMS((FILE **fpp, int tempflg)); int adrof PARAMS((char *s)); void copy PARAMS((register FILE *fp)); @@ -330,11 +342,20 @@ short *lookloc PARAMS((struct local *alp, int r)); void roundov PARAMS((void)); u_int add PARAMS((int a, int b, char *s)); int get_arobj PARAMS((int fd)); -off_t skip PARAMS((void)); +OFF_T skip PARAMS((void)); void inistr PARAMS((int which)); static void hreset PARAMS((void)); - +#ifdef pdp11 +#define outw(n, fp) putw(n, fp) +#define outd(n, fp) fwrite(&n, sizeof (OFF_T), 1, fp) +/* dget not used as we usually read a whole structure at a time */ +#else +void outw PARAMS((int n, FILE *fp)); +void outd PARAMS((OFF_T n, FILE *fp)); +OFF_T dget(int which); +#endif + int main(argc, argv) int argc; char **argv; { register int c, i; int num; @@ -389,9 +410,9 @@ int main(argc, argv) int argc; char **argv; { } } /* add default search directories */ - dirs[ndir++] = "/lib"; - dirs[ndir++] = "/usr/lib"; - dirs[ndir++] = "/usr/local/lib"; + dirs[ndir++] = STAGEDIR "/lib"; + dirs[ndir++] = STAGEDIR "/usr/lib"; + dirs[ndir++] = STAGEDIR "/usr/local/lib"; p = argv+1; /* @@ -563,9 +584,9 @@ void endload(argc, argv) int argc; char **argv; { case 'D': for (dnum = atoi(*p);dorigin < dnum; dorigin += 2) { - putw(0, doutb); + outw(0, doutb); if (rflag) - putw(0, droutb); + outw(0, droutb); } /* fall into ... */ case 'u': @@ -623,9 +644,12 @@ VADDR sym2va(x) u_short x; { * Scan file to find defined symbols. */ void load1arg(cp, flag) register char *cp; int flag; { - off_t nloc; + OFF_T nloc; int kind, tnum; - long ltnum, strsize; + OFF_T ltnum, strsize; +#ifndef pdp11 + char temp[sizeof (OFF_T)]; +#endif kind = getfile(cp, flag, 1); if (Mflag) @@ -664,7 +688,15 @@ void load1arg(cp, flag) register char *cp; int flag; { /* * Read the size of the ranlib structures (a long). */ - read(infil, <num, sizeof (ltnum)); +#ifdef pdp11 + read(infil, <num, sizeof (OFF_T)); +#else + read(infil, temp, sizeof (OFF_T)); + ltnum = ((temp[0] & 0377L) << 16) | + ((temp[1] & 0377L) << 24) | + (temp[2] & 0377L) | + ((temp[3] & 0377L) << 8); +#endif /* * calculate string table position. Add in the ranlib size (4 bytes), * the size of the ranlib structures (ltnum) from above. @@ -674,7 +706,15 @@ void load1arg(cp, flag) register char *cp; int flag; { rstrtab = NULL; lseek(infil, nloc, L_SET); - read(infil, &strsize, sizeof (long)); +#ifdef pdp11 + read(infil, &strsize, sizeof (OFF_T)); +#else + read(infil, temp, sizeof (OFF_T)); + strsize = ((temp[0] & 0377L) << 16) | + ((temp[1] & 0377L) << 24) | + (temp[2] & 0377L) | + ((temp[3] & 0377L) << 8); +#endif if (strsize <= 8192L) { rstrtab = (char *)malloc((int)strsize); @@ -722,7 +762,7 @@ void load1arg(cp, flag) register char *cp; int flag; { * is useful, record its location in the liblist structure * for use in pass2. Mark the end of the archive in libilst with a -1. */ -int step(nloc) off_t nloc; { +int step(nloc) OFF_T nloc; { lseek(infil, nloc, L_SET); if (get_arobj(infil) <= 0) { @@ -740,23 +780,26 @@ int step(nloc) off_t nloc; { return (1); } -int ldrand(totnum, sloc) int totnum; off_t sloc; { +int ldrand(totnum, sloc) int totnum; OFF_T sloc; { register int ntab; SYMBOL *sp; short *hp; VADDR vsym; LIBLIST *oldp = libp; int amt, tnum = totnum; - off_t loc; + OFF_T loc; /* * 'ar' header + member header + SYMDEF table.of.contents + long filename */ - off_t opos = (off_t)SARMAG + sizeof (struct ar_hdr) + sizeof (long) + + OFF_T opos = (OFF_T)SARMAG + sizeof (struct ar_hdr) + sizeof (OFF_T) + chdr.lname; #define TABSZ 64 char localname[NNAMESIZE]; register struct ranlib *tp; struct ranlib tab[TABSZ], *tplast; +#ifndef pdp11 + char buf[TABSZ * sizeof (struct ranlib)], *temp; +#endif while (tnum) { @@ -767,8 +810,26 @@ int ldrand(totnum, sloc) int totnum; off_t sloc; { tplast = &tab[ntab - 1]; (void)lseek(infil, opos, L_SET); amt = ntab * sizeof (struct ranlib); +#ifdef pdp11 if (read(infil, tab, amt) != amt) error(1, "EOF in ldrand"); +#else + if (read(infil, buf, amt) != amt) + error(1, "EOF in ldrand"); + temp = buf; + for (tp = tab; tp <= tplast; tp++) + { + tp->ran_un.ran_strx = ((temp[0] & 0377L) << 16) | + ((temp[1] & 0377L) << 24) | + (temp[2] & 0377L) | + ((temp[3] & 0377L) << 8); + tp->ran_off = ((temp[4] & 0377L) << 16) | + ((temp[5] & 0377L) << 24) | + (temp[6] & 0377L) | + ((temp[7] & 0377L) << 8); + temp += sizeof (struct ranlib); /* must be 8 */ + } +#endif tnum -= ntab; opos += amt; @@ -785,7 +846,7 @@ int ldrand(totnum, sloc) int totnum; off_t sloc; { else { dseek(STRINGS2, tp->ran_un.ran_strx + sloc + - sizeof (long), 07777); + sizeof (OFF_T), 07777); mgets(localname, NNAMESIZE, STRINGS2); } hp = slookup(localname); @@ -814,7 +875,7 @@ void mgets(buf, maxlen, which) register char *buf; int maxlen; int which; { { if (--sp->nibuf < 0) { - dseek(which, (off_t)(sp->bno + 1) * sp->bsize, 077777); + dseek(which, (OFF_T)(sp->bno + 1) * sp->bsize, 077777); sp->nibuf--; } if ((*buf++ = *sp->Cptr++) == 0) @@ -825,17 +886,20 @@ void mgets(buf, maxlen, which) register char *buf; int maxlen; int which; { /* * Examine a single file or archive member on pass 1. */ -int load1(libflg, loc) int libflg; off_t loc; { +int load1(libflg, loc) int libflg; OFF_T loc; { register SYMBOL *sp; int savindex; int ndef, type, mtype; long nlocal; VADDR vsym; struct nlist objsym; - off_t strloc; - long strsize; + OFF_T strloc; + OFF_T strsize; char *strtab; register struct vseg *seg; +#ifndef pdp11 + char temp[sizeof (OFF_T)]; +#endif readhdr(loc); if (filhdr.e.a_syms == 0) { @@ -856,7 +920,13 @@ int load1(libflg, loc) int libflg; off_t loc; { strloc = loc + N_STROFF(filhdr); lseek(infil, strloc, L_SET); - read(infil, &strsize, sizeof (long)); +#ifdef pdp11 + read(infil, &strsize, sizeof (OFF_T)); +#else + read(infil, temp, sizeof (OFF_T)); + strsize = ((temp[0] & 0377L) << 16) | ((temp[1] & 0377L) << 24) | + (temp[2] & 0377L) | ((temp[3] & 0377L) << 8); +#endif strtab = NULL; if (strsize <= 8192L) { @@ -868,8 +938,17 @@ int load1(libflg, loc) int libflg; off_t loc; { inistr(STRINGS); while (Input[SYMBOLS].nsize > 0) { +#ifdef pdp11 mget((int *)&objsym, sizeof objsym, SYMBOLS); type = objsym.n_type; +#else + objsym.n_un.n_strx = dget(SYMBOLS); + type = get(SYMBOLS); + objsym.n_ovly = (type >> 8) & 0377; + type &= 0377; + objsym.n_type = type; + objsym.n_value = get(SYMBOLS); +#endif if (Sflag) { mtype = type&037; if (mtype==1 || mtype>4) { @@ -887,7 +966,7 @@ int load1(libflg, loc) int libflg; off_t loc; { */ if (strtab) strncpy(cursym.n_name, (int)objsym.n_un.n_strx + - strtab - sizeof (long), NNAMESIZE); + strtab - sizeof (OFF_T), NNAMESIZE); else { dseek(STRINGS, objsym.n_un.n_strx + strloc, 077777); @@ -1185,6 +1264,9 @@ void ldrsym(ix, val, type) int ix; u_int val; int type; { void setupout() { VADDR vsym; register SYMBOL *sp; +#ifndef pdp11 + int i; +#endif tcreat(&toutb, 0); #if 0 /* see tcreat */ @@ -1227,11 +1309,42 @@ void setupout() { } else filhdr.e.a_entry = 0; filhdr.e.a_flag = (rflag==0); +#ifdef pdp11 fwrite(&filhdr.e, sizeof (filhdr.e), 1, toutb); if (numov) fwrite(&filhdr.o, sizeof (filhdr.o), 1, toutb); +#else + outw(filhdr.e.a_magic, toutb); + outw(filhdr.e.a_text, toutb); + outw(filhdr.e.a_data, toutb); + outw(filhdr.e.a_bss, toutb); + outw(filhdr.e.a_syms, toutb); + outw(filhdr.e.a_entry, toutb); + outw(0, toutb); /* filhdr.e.a_unused */ + outw(filhdr.e.a_flag, toutb); + if (numov) { + outw(filhdr.o.max_ovl, toutb); + for (i = 0; i < NOVL; i++) + outw(filhdr.o.ov_siz[i], toutb); + } +#endif +} + +#ifndef pdp11 +void outw(n, fp) int n; FILE *fp; { + putc(n & 0377, fp); + putc((n >> 8) & 0377, fp); } +void outd(n, fp) OFF_T n; FILE *fp; { + /* note weirdness as files are stored in pdp11's native layout */ + putc((int)(n >> 16) & 0377, fp); + putc((int)(n >> 24) & 0377, fp); + putc((int)n & 0377, fp); + putc((int)(n >> 8) & 0377, fp); +} +#endif + void load2arg(acp, flag) char *acp; int flag; { register char *cp; register LIBLIST *lp; @@ -1271,9 +1384,12 @@ void load2(loc) long loc; { VADDR vsym; short i; struct nlist objsym; - off_t stroff; + OFF_T stroff; char *strtab; - long strsize; + OFF_T strsize; +#ifndef pdp11 + char temp[sizeof (OFF_T)]; +#endif readhdr(loc); ctrel = torigin; @@ -1289,7 +1405,13 @@ void load2(loc) long loc; { stroff = loc + N_STROFF(filhdr); lseek(infil, stroff, L_SET); - read(infil, &strsize, sizeof (long)); +#ifdef pdp11 + read(infil, &strsize, sizeof (OFF_T)); +#else + read(infil, temp, sizeof (OFF_T)); + strsize = ((temp[0] & 0377L) << 16) | ((temp[1] & 0377L) << 24) | + (temp[2] & 0377L) | ((temp[3] & 0377L) << 8); +#endif strtab = NULL; if (strsize <= 8192L) { @@ -1302,10 +1424,19 @@ void load2(loc) long loc; { while (Input[SYMBOLS].nsize > 0) { symno++; +#ifdef pdp11 mget((int *)&objsym, sizeof objsym, SYMBOLS); +#else + objsym.n_un.n_strx = dget(SYMBOLS); + type = get(SYMBOLS); + objsym.n_ovly = (type >> 8) & 0377; + type &= 0377; + objsym.n_type = type; + objsym.n_value = get(SYMBOLS); +#endif if (strtab) strncpy(cursym.n_name, (int)objsym.n_un.n_strx + - strtab - sizeof (long), NNAMESIZE); + strtab - sizeof (OFF_T), NNAMESIZE); else { dseek(STRINGS, objsym.n_un.n_strx + stroff, 07777); @@ -1397,7 +1528,7 @@ void load2(loc) long loc; { borigin += filhdr.e.a_bss; } -void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1; FILE *b2; { +void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1, *b2; { register u_int r, t; register SYMBOL *sp; short i; @@ -1425,8 +1556,14 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1; FILE Input[TEXT].nibuf++; Input[TEXT].nsize++; t = get(TEXT); - } else + } else { +#ifdef pdp11 t = *Input[TEXT].Iptr++; +#else + t = *Input[TEXT].Cptr++ & 0377; + t |= (*Input[TEXT].Cptr++ & 0377) << 8; +#endif + } /* next relocation word */ if (--Input[RELOC].nsize <= 0) { @@ -1438,8 +1575,17 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1; FILE Input[RELOC].nibuf++; Input[RELOC].nsize++; r = get(RELOC); - } else + } else { +#ifdef pdp11 r = *Input[RELOC].Iptr++; +#else + r = *Input[RELOC].Cptr++ & 0377; + r |= (*Input[RELOC].Cptr++ & 0377) << 8; +#endif + } +#if 0 + printf("t = 0%06o r = 0%06o\n", t, r); +#endif switch (r&016) { @@ -1464,16 +1610,16 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1; FILE t += sp->n_value; r = (r&01) + ((sp->n_type-(N_EXT+N_ABS))<<1); break; -#ifndef pdp11 +#if 0 /*ndef pdp11*/ default: error(1, "relocation format botch (symbol type))"); #endif } if (r&01) t -= creloc; - putw(t, b1); + outw(t, b1); if (rflag) - putw(r, b2); + outw(r, b2); } } @@ -1483,7 +1629,7 @@ void finishout() { struct nlist objsym; VADDR vsym; int type, len; - off_t stroff; + OFF_T stroff; long dtotal, ovrnd; int thunk[THUNKSIZ / sizeof (int)]; @@ -1512,9 +1658,9 @@ void finishout() { n = torigin; while (n&077) { n += 2; - putw(0, toutb); + outw(0, toutb); if (rflag) - putw(0, troutb); + outw(0, troutb); } } if (numov) @@ -1542,7 +1688,7 @@ void finishout() { tcreat(&doutb, 1); nsym = 0; - stroff = sizeof (long); /* string table size */ + stroff = sizeof (OFF_T); /* string table size */ if (xflag == 0) { fflush(soutb); /* flush local symbol file */ @@ -1561,7 +1707,14 @@ void finishout() { fwrite(cursym.n_name, 1, len, doutb); fputc('\0', doutb); stroff += (len + 1); +#ifdef pdp11 fwrite(&objsym, sizeof (objsym), 1, toutb); +#else + outd(objsym.n_un.n_strx, toutb); + putc(objsym.n_type, toutb); + putc(objsym.n_ovly, toutb); + outw(objsym.n_value, toutb); +#endif nsym++; } fclose(soutb); @@ -1585,7 +1738,14 @@ void finishout() { fwrite(sp->n_name, 1, len, doutb); fputc('\0', doutb); stroff += (len + 1); +#ifdef pdp11 fwrite(&objsym, sizeof (objsym), 1, toutb); +#else + outd(objsym.n_un.n_strx, toutb); + putc(objsym.n_type, toutb); + putc(objsym.n_ovly, toutb); + outw(objsym.n_value, toutb); +#endif nsym++; } #ifdef whybother @@ -1599,7 +1759,7 @@ void finishout() { * Now write the length of the string table out. Then copy the temp * file containing the strings to the image being built. */ - fwrite(&stroff, sizeof (stroff), 1, toutb); + outd(stroff, toutb); copy(doutb); } /* @@ -1608,11 +1768,16 @@ void finishout() { * used earlier was only an estimate */ fflush(toutb); +#if 0 /*def pdp11*/ rewind(toutb); fread(&filhdr.e, sizeof (filhdr.e), 1, toutb); filhdr.e.a_syms = nsym * sizeof (objsym); rewind(toutb); fwrite(&filhdr.e, sizeof (filhdr.e), 1, toutb); +#else + fseek(toutb, (OFF_T)(4 * 2), SEEK_SET); + outw(nsym * sizeof (struct nlist), toutb); +#endif fclose(toutb); if (!ofilfnd) { @@ -1666,26 +1831,54 @@ void mkfsym(s) char *s; { fwrite(&cursym, sizeof (cursym), 1, soutb); } +/* THIS STUFF NEEDS TO BE REWRITTEN TO HANDLE BLOCK BOUNDARIES INTELLIGENTLY */ void mget(loc, an, which) register int *loc; int an; int which; { register int n; register STREAM *tp = &Input[which]; +#ifndef pdp11 + int temp; +#endif n = an >> 1; if ((tp->nibuf -= n) >= 0) { if ((tp->nsize -= n) > 0) { - bcopy(tp->ptr.cptr, loc, an); +#ifdef pdp11 + bcopy(tp->ptr, loc, an); tp->Iptr += n; +#else + bcopy(tp->Cptr, loc, an); + tp->Cptr += n << 1; +#endif return; } tp->nsize += n; } tp->nibuf += n; do { +#ifdef pdp11 *loc++ = get(which); +#else + /* kludgey, as we are converting to host byte order in temp, */ + /* then back to target byte order for caller to convert again */ + /* (luckily it only occurs if request crosses block boundary) */ + temp = get(which); + ((char *)loc)[0] = temp & 0377; + ((char *)loc++)[1] = (temp >> 8) & 0377; +#endif } while (--n); } -void dseek(which, aloc, s) int which; off_t aloc; int s; { +#ifndef pdp11 +OFF_T dget(which) int which; { + OFF_T temp; + + /* note weirdness as files are stored in pdp11 native layout */ + temp = get(which) & 0177777L; + return (get(which) & 0177777L) | (temp << 16); +} +#endif + +void dseek(which, aloc, s) int which; OFF_T aloc; int s; { register STREAM *sp = &Input[which]; register u_int b, o; int n; @@ -1694,7 +1887,7 @@ void dseek(which, aloc, s) int which; off_t aloc; int s; { o = aloc & (sp->bsize - 1); if (sp->bno != b) { - (void)lseek(infil, (off_t)sp->bsize * b, L_SET); + (void)lseek(infil, (OFF_T)sp->bsize * b, L_SET); if ((n = read(infil, (char *)sp->buff, sp->bsize)) < 0) n = 0; sp->bno = b; @@ -1712,19 +1905,27 @@ void dseek(which, aloc, s) int which; off_t aloc; int s; { int get(which) int which; { register STREAM *sp = &Input[which]; +#ifndef pdp11 + register int temp; +#endif if (--sp->nibuf < 0) { - dseek(which, (off_t)(sp->bno + 1) * sp->bsize, -1); + dseek(which, (OFF_T)(sp->bno + 1) * sp->bsize, -1); --sp->nibuf; } if (--sp->nsize <= 0) { if (sp->nsize < 0) error(1, "premature EOF#1"); } +#ifdef pdp11 return(*sp->Iptr++); +#else + temp = *sp->Cptr++ & 0377; + return temp | ((*sp->Cptr++ & 0377) << 8); +#endif } -int getfile(acp, flag, phase) char *acp; int flag; int phase; { /* flag 1 = fatal if file not found, -1 = not fatal */ +int getfile(acp, flag, phase) char *acp; int flag; int phase; { /* flag: 1 = fatal if file not found, -1 = not fatal */ char arcmag[SARMAG+1]; struct stat stb; @@ -1751,7 +1952,7 @@ int getfile(acp, flag, phase) char *acp; int flag; int phase; { /* flag 1 = fata arcmag[SARMAG] = 0; if (strcmp(arcmag, ARMAG)) return(0); - lseek(infil, (off_t)SARMAG, L_SET); + lseek(infil, (OFF_T)SARMAG, L_SET); if (get_arobj(infil) <= 0) return(1); if (strcmp(chdr.name, RANLIBMAG)) @@ -1883,9 +2084,20 @@ void error(n, s) int n; char *s; { errlev = 2; } -void readhdr(loc) off_t loc; { +void readhdr(loc) OFF_T loc; { dseek(TEXT, loc, sizeof filhdr); +#ifdef pdp11 mget((int *)&filhdr.e, sizeof filhdr.e, TEXT); +#else + filhdr.e.a_magic = get(TEXT); + filhdr.e.a_text = get(TEXT); + filhdr.e.a_data = get(TEXT); + filhdr.e.a_bss = get(TEXT); + filhdr.e.a_syms = get(TEXT); + filhdr.e.a_entry = get(TEXT); + get(TEXT); /* filhdr.e.a_unused */ + filhdr.e.a_flag = get(TEXT); +#endif if (filhdr.e.a_magic != A_MAGIC1) error(1, "bad magic number"); if (filhdr.e.a_text&01) @@ -1906,6 +2118,15 @@ void tcreat(fpp, tempflg) FILE **fpp; int tempflg; { #if 1 if (tempflg) { + /* note: we have to refresh the template each time, because + * linux actually checks that it ends with 6 X's, and worse, + * leaves it in an undefined state if something goes wrong + */ +#if pdp11 + strcpy(tfname, "/tmp/ldaXXXXX"); +#else + strcpy(tfname, "/tmp/ldaXXXXXX"); /* linux requires 6 X's */ +#endif if ((ufd = mkstemp(tfname)) < 0) error(2, "cannot create temp"); unlink(tfname); @@ -1965,8 +2186,8 @@ short *lookloc(alp, r) struct local *alp; int r; { void roundov() { while (torigin & 077) { - putw(0, voutb); - torigin += sizeof (int); + outw(0, voutb); + torigin += 2; } } @@ -2061,8 +2282,8 @@ int get_arobj(fd) int fd; { /* * skip - where to seek for next archive member. */ -off_t skip() { - off_t len; +OFF_T skip() { + OFF_T len; len = chdr.size + (chdr.size + chdr.lname & 1); len += sizeof (HDR); diff --git a/bin/ld/n.sh b/bin/ld/n.sh index dd60a00..4df6b16 100755 --- a/bin/ld/n.sh +++ b/bin/ld/n.sh @@ -1,8 +1,8 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/bin\/ld$//'`" -DESTDIR="$ROOT/host" +CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -mkdir --parents "$DESTDIR/usr/man/cat1" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install +CFLAGS="-g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +mkdir --parents "$CROSSDIR/usr/man/cat1" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$CROSSDIR/usr/lib" install diff --git a/bin/nm/Makefile b/bin/nm/Makefile index 19f09ee..8adb126 100644 --- a/bin/nm/Makefile +++ b/bin/nm/Makefile @@ -1,6 +1,8 @@ -VPATH=../../lib/libc/pdp/gen -SRCS=nm.c nsym.c -OBJS=nm.o nsym.o +# using VPATH to compile ./nsym.o from ../../lib/libc/pdp/gen/nsym.c does not +# work if there is a ../../lib/libc.pdp/gen/nsym.o leftover from building libc +#VPATH=../../lib/libc/pdp/gen +SRCS=nm.c ../../lib/libc/pdp/gen/nsym.c +OBJS=nm.o ../../lib/libc/pdp/gen/nsym.o CFLAGS=-O CPPFLAGS=-Iinclude -I../ar diff --git a/bin/nm/n.sh b/bin/nm/n.sh index ec4a716..cc5630a 100755 --- a/bin/nm/n.sh +++ b/bin/nm/n.sh @@ -1,6 +1,6 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/bin\/nm$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install diff --git a/include/a.out.h b/include/a.out.h index 3b5c60d..6316d9a 100644 --- a/include/a.out.h +++ b/include/a.out.h @@ -37,6 +37,13 @@ #define _AOUT_H_ #include +#ifdef pdp11 +#include +#define OFF_T off_t +#else +#include +#define OFF_T int32_t +#endif #define N_BADMAG(x) \ (((x).a_magic)!=A_MAGIC1 && ((x).a_magic)!=A_MAGIC2 && \ @@ -56,12 +63,6 @@ * must pass an extended header ('xexec') as the argument. */ -#ifdef pdp11 -#include -#else -#define off_t long -#endif - #undef PARAMS #ifdef __STDC__ #define PARAMS(args) args @@ -69,15 +70,11 @@ #define PARAMS(args) () #endif -long n_stroff PARAMS((register struct xexec *ep)); -long n_datoff PARAMS((register struct xexec *ep)); -long n_dreloc PARAMS((register struct xexec *ep)); -long n_treloc PARAMS((register struct xexec *ep)); -long n_symoff PARAMS((register struct xexec *ep)); - -#ifndef pdp11 -#undef off_t -#endif +OFF_T n_stroff PARAMS((register struct xexec *ep)); +OFF_T n_datoff PARAMS((register struct xexec *ep)); +OFF_T n_dreloc PARAMS((register struct xexec *ep)); +OFF_T n_treloc PARAMS((register struct xexec *ep)); +OFF_T n_symoff PARAMS((register struct xexec *ep)); #define N_STROFF(e) (n_stroff((struct xexec *)&e)) #define N_SYMOFF(e) (n_symoff((struct xexec *)&e)) @@ -85,6 +82,8 @@ long n_symoff PARAMS((register struct xexec *ep)); #define N_DRELOC(e) (n_dreloc((struct xexec *)&e)) #define N_TRELOC(e) (n_treloc((struct xexec *)&e)) +#undef OFF_T + #define _AOUT_INCLUDE_ #include diff --git a/include/n.sh b/include/n.sh new file mode 100755 index 0000000..833c061 --- /dev/null +++ b/include/n.sh @@ -0,0 +1,5 @@ +#!/bin/sh +ROOT="`pwd |sed -e 's/\/include$//'`" +STAGEDIR="$ROOT/stage" +mkdir --parents "$STAGEDIR/usr/include" +make SHARED=copies DESTDIR="$STAGEDIR" install diff --git a/include/nlist.h b/include/nlist.h index 0d7019c..0e0455d 100644 --- a/include/nlist.h +++ b/include/nlist.h @@ -35,7 +35,14 @@ #ifndef _NLIST_H_ #define _NLIST_H_ + #include +#ifdef pdp11 +#define OFF_T off_t +#else +#include +#define OFF_T int32_t +#endif /* * Symbol table entry format. The #ifdef's are so that programs including @@ -78,4 +85,7 @@ struct nlist { #define N_TYPE 0x1f /* mask for all the type bits */ #define N_FORMAT "%06o" /* namelist value format; XXX */ + +#undef OFF_T + #endif /* !_NLIST_H_ */ diff --git a/include/ranlib.h b/include/ranlib.h index d05873f..ffee9ef 100644 --- a/include/ranlib.h +++ b/include/ranlib.h @@ -36,15 +36,25 @@ #ifndef _RANLIB_H_ #define _RANLIB_H_ +#ifdef pdp11 +#include +#define OFF_T off_t +#else +#include +#define OFF_T int32_t +#endif + #define RANLIBMAG "__.SYMDEF" /* archive file name */ #define RANLIBSKEW 3 /* creation time offset */ struct ranlib { union { - off_t ran_strx; /* string table index */ + OFF_T ran_strx; /* string table index */ char *ran_name; /* in memory symbol name */ } ran_un; - off_t ran_off; /* archive file offset */ + OFF_T ran_off; /* archive file offset */ }; +#undef OFF_T + #endif /* !_RANLIB_H_ */ diff --git a/lib/c2/n.sh b/lib/c2/n.sh index 4d2408c..043346f 100755 --- a/lib/c2/n.sh +++ b/lib/c2/n.sh @@ -1,6 +1,6 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/lib\/c2$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/lib" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/lib" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install diff --git a/lib/ccom/n.sh b/lib/ccom/n.sh index 77367a3..fa6f1a9 100755 --- a/lib/ccom/n.sh +++ b/lib/ccom/n.sh @@ -1,6 +1,6 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/lib\/ccom$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/lib" -make clean && make LDC0FLAGS= LDC1FLAGS= PURFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/lib" +make clean && make LDC0FLAGS= LDC1FLAGS= PURFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install diff --git a/lib/cpp/cpp.c b/lib/cpp/cpp.c index 4687faf..c64db1d 100644 --- a/lib/cpp/cpp.c +++ b/lib/cpp/cpp.c @@ -851,6 +851,7 @@ char *subst(p, sp) register char *p; struct symtab *sp; { vp=acttxt; *vp++='\0'; sprintf(vp,"\"%s\"",fnames[ifno]); while (*vp++); } + /*fprintf(stderr, "expand %s params %d\n", macnam, vp[-1] & 0xff);*/ if (0!=(params= *--vp&0xFF)) {/* definition calls for params */ register char **pa; ca=acttxt; pa=actual; @@ -862,15 +863,18 @@ char *subst(p, sp) register char *p; struct symtab *sp; { maclin=lineno[ifno]; macfil=fnames[ifno]; for (plvl=1; plvl!=0; ) { *ca++='\0'; + /*fprintf(stderr, "param: ");*/ for (;;) { outp=inp=p; p=cotoken(p); if (*inp=='(') ++plvl; if (*inp==')' && --plvl==0) {--params; break;} if (plvl==1 && *inp==',') {--params; break;} + /*fwrite(inp, p - inp, 1, stderr);*/ while (inp &acttxt[BUFSIZ]) pperror("%s: actuals too long",sp->name); } + /*fputc('\n', stderr);*/ if (pa>= &actual[MAXFRM]) ppwarn(match,sp->name); else { actused[pa-actual]=0; *pa++=ca; } } @@ -884,9 +888,11 @@ char *subst(p, sp) register char *p; struct symtab *sp; { for (;;) {/* push definition onto front of input stack */ while (!iswarn(*--vp)) { if (bob(p)) {outp=inp=p; p=unfill(p);} + /*fprintf(stderr, "char: %c\n", *vp);*/ *--p= *vp; } if (*vp==warnc) {/* insert actual param */ + /*fprintf(stderr, "actual: %d\n", vp[-1] - 1);*/ ca=actual[*--vp-1]; while (*--ca) { if (bob(p)) {outp=inp=p; p=unfill(p);} diff --git a/lib/cpp/cpp.h b/lib/cpp/cpp.h index fb923db..33fe7aa 100644 --- a/lib/cpp/cpp.h +++ b/lib/cpp/cpp.h @@ -24,7 +24,7 @@ extern char cinit; /* some code depends on whether characters are sign or zero extended */ /* #if '\377' < 0 not used here, old cpp doesn't understand */ -#if pdp11 | vax | mc68000 +#if '\377' < 0 /*pdp11 | vax | mc68000*/ #define COFF 128 #else #define COFF 0 diff --git a/lib/cpp/n.sh b/lib/cpp/n.sh index c1bd4cd..1ad20ad 100755 --- a/lib/cpp/n.sh +++ b/lib/cpp/n.sh @@ -1,7 +1,7 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/lib\/cpp$//'`" -DESTDIR="$ROOT/host" +CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/lib" -make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/lib" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install diff --git a/lib/cpp/yylex.c b/lib/cpp/yylex.c index 463d9ee..73e62e6 100644 --- a/lib/cpp/yylex.c +++ b/lib/cpp/yylex.c @@ -3,15 +3,6 @@ #include #include "cpp.h" -#define isid(a) ((fastab+COFF)[a]&IB) -#define IB 1 -/* #if '\377' < 0 it would be nice if this worked properly!!!!! */ -#if pdp11 | vax | mc68000 -#define COFF 128 -#else -#define COFF 0 -#endif - static int tobinary PARAMS((char *st, int b)); int yylex() { diff --git a/lib/libc/Makefile b/lib/libc/Makefile index f92f7d2..e8f1c5f 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -43,8 +43,10 @@ HOSTLOOKUP= named #HOSTLOOKUP= hosttable # -DESTDIR= +AR=ar INSTALL=install -m 644 +LORDER=lorder +RANLIB=ranlib DFLMON= mon.o MACHINE=pdp DEFS= @@ -56,25 +58,25 @@ libc.a libc_p.a: ${MACHINE}/csu ${ALL} net/${HOSTLOOKUP} rm -rf tmp mkdir tmp cd tmp; \ - for i in ${ALL}; do ar x ../$$i/$${i}lib; done; \ - ar x ../net/${HOSTLOOKUP}/hostlib; \ - ar cr ../libc.a `lorder *.o | tsort` \ + for i in ${ALL}; do ${AR} x ../$$i/$${i}lib; done; \ + ${AR} x ../net/${HOSTLOOKUP}/hostlib; \ + ${AR} cr ../libc.a `${LORDER} *.o | tsort` \ ../${MACHINE}/csu/${DFLMON} - ar ma findiop.o libc.a exit.o - ar ma exit.o libc.a fakcu.o - ar ma fltpr.o libc.a doprnt.o - ar ma doprnt.o libc.a ffltpr.o + ${AR} ma findiop.o libc.a exit.o + ${AR} ma exit.o libc.a fakcu.o + ${AR} ma fltpr.o libc.a doprnt.o + ${AR} ma doprnt.o libc.a ffltpr.o rm -rf tmp mkdir tmp cd tmp; \ - for i in ${ALL}; do ar x ../$$i/$${i}lib_p; done; \ - ar x ../net/${HOSTLOOKUP}/hostlib_p; \ - ar cr ../libc_p.a `lorder *.o | tsort` \ + for i in ${ALL}; do ${AR} x ../$$i/$${i}lib_p; done; \ + ${AR} x ../net/${HOSTLOOKUP}/hostlib_p; \ + ${AR} cr ../libc_p.a `${LORDER} *.o | tsort` \ ../${MACHINE}/csu/${DFLMON} - ar ma findiop.o libc_p.a exit.o - ar ma exit.o libc_p.a fakcu.o - ar ma fltpr.o libc_p.a doprnt.o - ar ma doprnt.o libc_p.a ffltpr.o + ${AR} ma findiop.o libc_p.a exit.o + ${AR} ma exit.o libc_p.a fakcu.o + ${AR} ma fltpr.o libc_p.a doprnt.o + ${AR} ma doprnt.o libc_p.a ffltpr.o rm -rf tmp ${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}: FRC @@ -84,9 +86,9 @@ FRC: install: libc.a libc_p.a ${INSTALL} libc.a ${DESTDIR}/lib/libc.a - ranlib ${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 + ${RANLIB} ${DESTDIR}/usr/lib/libc_p.a cd ${MACHINE}/csu; make DESTDIR=${DESTDIR} install tags: diff --git a/lib/libc/compat-4.1/Makefile b/lib/libc/compat-4.1/Makefile index d277c95..4a95b0e 100644 --- a/lib/libc/compat-4.1/Makefile +++ b/lib/libc/compat-4.1/Makefile @@ -14,17 +14,17 @@ TAGSFILE=tags .c.o: ${CC} -p ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o compat-4.1lib compat-4.1lib_p: ${OBJS} @echo "building profiled compat-4.1lib" - @cd profiled; ar cru ../compat-4.1lib_p ${OBJS} + @cd profiled; ${AR} cru ../compat-4.1lib_p ${OBJS} @echo "buiding normal compat-4.1lib" - @ar cru compat-4.1lib ${OBJS} + @${AR} cru compat-4.1lib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/compat-43/Makefile b/lib/libc/compat-43/Makefile index a460e48..27939bd 100644 --- a/lib/libc/compat-43/Makefile +++ b/lib/libc/compat-43/Makefile @@ -11,19 +11,19 @@ OBJS= creat.o gethostid.o sethostid.o sigcompat.o \ .c.o: ${CC} -p ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o all: compat-43lib compat-43lib_p compat-43lib compat-43lib_p: ${OBJS} @echo "building profiled compat-43lib" - @cd profiled; ar cru ../compat-43lib_p ${OBJS} + @cd profiled; ${AR} cru ../compat-43lib_p ${OBJS} @echo "buiding normal compat-43lib" - @ar cru compat-43lib ${OBJS} + @${AR} cru compat-43lib ${OBJS} clean: rm -f compat-43lib compat-43lib_p *.o profiled/*.o Makefile.bak tags diff --git a/lib/libc/compat-sys5/Makefile b/lib/libc/compat-sys5/Makefile index e74c776..797afd4 100644 --- a/lib/libc/compat-sys5/Makefile +++ b/lib/libc/compat-sys5/Makefile @@ -9,17 +9,17 @@ TAGSFILE=tags .c.o: ${CC} -p ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o compat-sys5lib compat-sys5lib_p: ${OBJS} @echo "building profiled compat-sys5lib" - @cd profiled; ar cru ../compat-sys5lib_p ${OBJS} + @cd profiled; ${AR} cru ../compat-sys5lib_p ${OBJS} @echo "buiding normal compat-sys5lib" - @ar cru compat-sys5lib ${OBJS} + @${AR} cru compat-sys5lib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/gen/Makefile b/lib/libc/gen/Makefile index eb9b78e..0cd9a99 100644 --- a/lib/libc/gen/Makefile +++ b/lib/libc/gen/Makefile @@ -52,17 +52,17 @@ TAGSFILE=tags .c.o: ${CC} -p ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out $*.o genlib genlib_p: ${OBJS} @echo "building profiled genlib" - @cd profiled; ar cru ../genlib_p ${OBJS} + @cd profiled; ${AR} cru ../genlib_p ${OBJS} @echo "buiding normal genlib" - @ar cru genlib ${OBJS} + @${AR} cru genlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/inet/Makefile b/lib/libc/inet/Makefile index 1226ff4..5af3df9 100644 --- a/lib/libc/inet/Makefile +++ b/lib/libc/inet/Makefile @@ -17,17 +17,17 @@ TAGSFILE=tags .c.o: ${CC} -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o inetlib inetlib_p: ${OBJS} @echo "building profiled inetlib" - @cd profiled; ar cru ../inetlib_p ${OBJS} + @cd profiled; ${AR} cru ../inetlib_p ${OBJS} @echo "building normal inetlib" - @ar cru inetlib ${OBJS} + @${AR} cru inetlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/n.sh b/lib/libc/n.sh new file mode 100755 index 0000000..e86fa6f --- /dev/null +++ b/lib/libc/n.sh @@ -0,0 +1,6 @@ +#!/bin/sh +ROOT="`pwd |sed -e 's/\/lib\/libc$//'`" +CROSSDIR="$ROOT/cross" +STAGEDIR="$ROOT/stage" +mkdir --parents "$STAGEDIR/lib" +make clean && make AR="$CROSSDIR/bin/ar" AS="$CROSSDIR/bin/as" CC="$CROSSDIR/bin/cc" CPP="$CROSSDIR/lib/cpp" LD="$CROSSDIR/bin/ld" LORDER="$CROSSDIR/usr/bin/lorder" RANLIB="$CROSSDIR/usr/bin/ranlib" DESTDIR="$STAGEDIR" install diff --git a/lib/libc/net/Makefile b/lib/libc/net/Makefile index 426cad4..fede873 100644 --- a/lib/libc/net/Makefile +++ b/lib/libc/net/Makefile @@ -27,17 +27,17 @@ TAGSFILE=tags .c.o: ${CC} -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o netlib netlib_p: ${OBJS} @echo "building profiled netlib" - @cd profiled; ar cru ../netlib_p ${OBJS} + @cd profiled; ${AR} cru ../netlib_p ${OBJS} @echo "building normal netlib" - @ar cru netlib ${OBJS} + @${AR} cru netlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/net/hosttable/Makefile b/lib/libc/net/hosttable/Makefile index 80d6e97..95705d6 100644 --- a/lib/libc/net/hosttable/Makefile +++ b/lib/libc/net/hosttable/Makefile @@ -13,17 +13,17 @@ CFLAGS= -O ${DEFS} .c.o: ${CC} -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o hostlib hostlib_p: ${OBJS} @echo "building profiled hostlib" - @cd profiled; ar cru ../hostlib_p ${OBJS} + @cd profiled; ${AR} cru ../hostlib_p ${OBJS} @echo "building normal netlib" - @ar cru hostlib ${OBJS} + @${AR} cru hostlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/net/named/Makefile b/lib/libc/net/named/Makefile index b741fa3..dfc8430 100644 --- a/lib/libc/net/named/Makefile +++ b/lib/libc/net/named/Makefile @@ -16,17 +16,17 @@ DESTDIR= .c.o: ${CC} -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o hostlib hostlib_p: ${OBJS} @echo "building profiled hostlib" - @cd profiled; ar cru ../hostlib_p ${OBJS} + @cd profiled; ${AR} cru ../hostlib_p ${OBJS} @echo "building normal hostlib" - @ar cru hostlib ${OBJS} + @${AR} cru hostlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/ns/Makefile b/lib/libc/ns/Makefile index eda3122..3f1f643 100644 --- a/lib/libc/ns/Makefile +++ b/lib/libc/ns/Makefile @@ -13,17 +13,17 @@ TAGSFILE=tags .c.o: ${CC} -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o nslib nslib_p: ${OBJS} @echo "building profiled nslib" - @cd profiled; ar cru ../nslib_p ${OBJS} + @cd profiled; ${AR} cru ../nslib_p ${OBJS} @echo "building normal nslib" - @ar cru nslib ${OBJS} + @${AR} cru nslib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/pdp/compat-2.9/Makefile b/lib/libc/pdp/compat-2.9/Makefile index ed89735..fb795ae 100644 --- a/lib/libc/pdp/compat-2.9/Makefile +++ b/lib/libc/pdp/compat-2.9/Makefile @@ -11,26 +11,26 @@ CFLAGS= -O ${DEFS} TAGSFILE=tags .s.o: - /lib/cpp -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -x -r $*.o + ${CPP} -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -x -r $*.o mv a.out $*.o .c.o: - cc -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + ${CC} -p -c ${CFLAGS} $*.c + -${LD} -X -r $*.o mv a.out profiled/$*.o - cc -c ${CFLAGS} $*.c - -ld -x -r $*.o + ${CC} -c ${CFLAGS} $*.c + -${LD} -x -r $*.o mv a.out $*.o compat-2.9lib compat-2.9lib_p: ${OBJS} @echo "building profiled compat-2.9" - @cd profiled; ar cru ../compat-2.9lib_p ${OBJS} + @cd profiled; ${AR} cru ../compat-2.9lib_p ${OBJS} @echo "building normal compat-2.9" - @ar cru compat-2.9lib ${OBJS} + @${AR} cru compat-2.9lib ${OBJS} tags: diff --git a/lib/libc/pdp/crt/Makefile b/lib/libc/pdp/crt/Makefile index 42f6a71..2a69230 100644 --- a/lib/libc/pdp/crt/Makefile +++ b/lib/libc/pdp/crt/Makefile @@ -15,26 +15,26 @@ CFLAGS= -O ${DEFS} TAGSFILE=tags .s.o: - /lib/cpp -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -x -r $*.o + ${CPP} -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -x -r $*.o mv a.out $*.o .c.o: - cc -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + ${CC} -p -c ${CFLAGS} $*.c + -${LD} -X -r $*.o mv a.out profiled/$*.o - cc -c ${CFLAGS} $*.c - -ld -x -r $*.o + ${CC} -c ${CFLAGS} $*.c + -${LD} -x -r $*.o mv a.out $*.o crtlib crtlib_p: ${OBJS} @echo "building profiled crtlib" - @cd profiled; ar cru ../crtlib_p ${OBJS} + @cd profiled; ${AR} cru ../crtlib_p ${OBJS} @echo "building normal crtlib" - @ar cru crtlib ${OBJS} + @${AR} cru crtlib ${OBJS} tags: diff --git a/lib/libc/pdp/csu/Makefile b/lib/libc/pdp/csu/Makefile index 346157b..e02dd4a 100644 --- a/lib/libc/pdp/csu/Makefile +++ b/lib/libc/pdp/csu/Makefile @@ -24,35 +24,35 @@ install: ${OBJS} # install -c -m 0644 gcrt0.o ${DESTDIR}/usr/lib/gcrt0.o crt0.o: crt0.s - /lib/cpp ${DEFS} ${DFLAGS} crt0.s | sed 's;^#;/;' | as -o x.o - ld -x -r -o crt0.o x.o + ${CPP} ${DEFS} ${DFLAGS} crt0.s | sed 's;^#;/;' | ${AS} -o x.o + ${LD} -x -r -o crt0.o x.o rm -f x.o moncrt0.o: crt0.s - /lib/cpp ${DEFS} ${DFLAGS} -DMCRT0 crt0.s | sed 's;^#;/;' | as -o x.o - ld -x -r -o moncrt0.o x.o + ${CPP} ${DEFS} ${DFLAGS} -DMCRT0 crt0.s | sed 's;^#;/;' | ${AS} -o x.o + ${LD} -x -r -o moncrt0.o x.o rm -f x.o gcrt0.o: moncrt0.o gmon.o - ld -x -r -o gcrt0.o moncrt0.o gmon.o + ${LD} -x -r -o gcrt0.o moncrt0.o gmon.o mcrt0.o: moncrt0.o mon.o - ld -x -r -o mcrt0.o moncrt0.o mon.o + ${LD} -x -r -o mcrt0.o moncrt0.o mon.o mon.o: mon.c mcount.s mon.ex - cc ${CFLAGS} -S ${DFLAGS} mon.c + ${CC} ${CFLAGS} -S ${DFLAGS} mon.c ex - mon.s < mon.ex cat mon.s mcount.s > x.s - /lib/cpp ${DEFS} ${DFLAGS} x.s | sed 's;^#;/;' > xx.s - as - -o x.o xx.s - ld -x -r -o mon.o x.o + ${CPP} ${DEFS} ${DFLAGS} x.s | sed 's;^#;/;' > xx.s + ${AS} - -o x.o xx.s + ${LD} -x -r -o mon.o x.o rm -f x.o x.s xx.s mon.s gmon.o: gmon.c gmon.h gmon.ex - cc ${CFLAGS} -S ${DFLAGS} gmon.c + ${CC} ${CFLAGS} -S ${DFLAGS} gmon.c ex - gmon.s < gmon.ex - as -o x.o gmon.s - ld -x -r -o gmon.o x.o + ${AS} -o x.o gmon.s + ${LD} -x -r -o gmon.o x.o rm -f x.o gmon.s tags: diff --git a/lib/libc/pdp/gen/Makefile b/lib/libc/pdp/gen/Makefile index 43a27f3..5a25d3d 100644 --- a/lib/libc/pdp/gen/Makefile +++ b/lib/libc/pdp/gen/Makefile @@ -18,26 +18,26 @@ CFLAGS= -O ${DEFS} TAGSFILE=tags .s.o: - /lib/cpp -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -x -r $*.o + ${CPP} -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -x -r $*.o mv a.out $*.o .c.o: - cc -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + ${CC} -p -c ${CFLAGS} $*.c + -${LD} -X -r $*.o mv a.out profiled/$*.o - cc -c ${CFLAGS} $*.c - -ld -x -r $*.o + ${CC} -c ${CFLAGS} $*.c + -${LD} -x -r $*.o mv a.out $*.o genlib genlib_p: ${OBJS} @echo "building profiled genlib" - @cd profiled; ar cru ../genlib_p ${OBJS} + @cd profiled; ${AR} cru ../genlib_p ${OBJS} @echo "building normal genlib" - @ar cru genlib ${OBJS} + @${AR} cru genlib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/pdp/gen/nsym.c b/lib/libc/pdp/gen/nsym.c index b937336..d17ac79 100644 --- a/lib/libc/pdp/gen/nsym.c +++ b/lib/libc/pdp/gen/nsym.c @@ -17,26 +17,28 @@ #include -#ifndef pdp11 -#define off_t long +#ifdef pdp11 +#define OFF_T off_t +#else +#define OFF_T int32_t #endif -off_t +OFF_T n_stroff(ep) register struct xexec *ep; { - off_t l; + OFF_T l; l = n_symoff(ep); l += ep->e.a_syms; return(l); } -off_t +OFF_T n_datoff(ep) register struct xexec *ep; { - off_t l; + OFF_T l; l = n_treloc(ep); l -= ep->e.a_data; @@ -49,15 +51,15 @@ n_datoff(ep) * called. */ -off_t +OFF_T n_dreloc(ep) register struct xexec *ep; { - off_t l; + OFF_T l; register u_short *ov = ep->o.ov_siz; register int i; - l = (off_t)sizeof (struct exec) + ep->e.a_text + ep->e.a_data; + l = (OFF_T)sizeof (struct exec) + ep->e.a_text + ep->e.a_data; if (ep->e.a_magic == A_MAGIC5 || ep->e.a_magic == A_MAGIC6) { for (i = 0; i < NOVL; i++) @@ -68,27 +70,27 @@ n_dreloc(ep) return(l); } -off_t +OFF_T n_treloc(ep) register struct xexec *ep; { - off_t l; + OFF_T l; l = n_dreloc(ep); l -= ep->e.a_text; return(l); } -off_t +OFF_T n_symoff(ep) register struct xexec *ep; { register int i; register u_short *ov; - off_t sum, l; + OFF_T sum, l; - l = (off_t) N_TXTOFF(ep->e); - sum = (off_t)ep->e.a_text + ep->e.a_data; + l = (OFF_T) N_TXTOFF(ep->e); + sum = (OFF_T)ep->e.a_text + ep->e.a_data; if (ep->e.a_magic == A_MAGIC5 || ep->e.a_magic == A_MAGIC6) { for (ov = ep->o.ov_siz, i = 0; i < NOVL; i++) diff --git a/lib/libc/pdp/net/Makefile b/lib/libc/pdp/net/Makefile index 40ada92..080eb7e 100644 --- a/lib/libc/pdp/net/Makefile +++ b/lib/libc/pdp/net/Makefile @@ -11,26 +11,26 @@ CFLAGS= ${DEFS} TAGSFILE=tags .s.o: - /lib/cpp -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $*.o - -ld -x -r $*.o + ${CPP} -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $*.o + -${LD} -x -r $*.o mv a.out $*.o .c.o: - cc -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + ${CC} -p -c ${CFLAGS} $*.c + -${LD} -X -r $*.o mv a.out profiled/$*.o - cc -c ${CFLAGS} $*.c - -ld -x -r $*.o + ${CC} -c ${CFLAGS} $*.c + -${LD} -x -r $*.o mv a.out $*.o netlib netlib_p: ${OBJS} @echo "building profiled netlib" - @cd profiled; ar cru ../netlib_p ${OBJS} + @cd profiled; ${AR} cru ../netlib_p ${OBJS} @echo "building normal netlib" - @ar cru netlib ${OBJS} + @${AR} cru netlib ${OBJS} tags: diff --git a/lib/libc/pdp/stdio/Makefile b/lib/libc/pdp/stdio/Makefile index 1f9f835..fc9bccb 100644 --- a/lib/libc/pdp/stdio/Makefile +++ b/lib/libc/pdp/stdio/Makefile @@ -13,26 +13,26 @@ CFLAGS= -O ${DEFS} TAGSFILE=tags .s.o: - /lib/cpp -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -E -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -x -r $*.o + ${CPP} -E ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -x -r $*.o mv a.out $*.o .c.o: - cc -p -c ${CFLAGS} $*.c - -ld -X -r $*.o + ${CC} -p -c ${CFLAGS} $*.c + -${LD} -X -r $*.o mv a.out profiled/$*.o - cc -c ${CFLAGS} $*.c - -ld -x -r $*.o + ${CC} -c ${CFLAGS} $*.c + -${LD} -x -r $*.o mv a.out $*.o stdiolib stdiolib_p: ${OBJS} @echo "building profiled stdio" - @cd profiled; ar cru ../stdiolib_p ${OBJS} + @cd profiled; ${AR} cru ../stdiolib_p ${OBJS} @echo "building normal stdio" - @ar cru stdiolib ${OBJS} + @${AR} cru stdiolib ${OBJS} tags: diff --git a/lib/libc/pdp/sys/Makefile b/lib/libc/pdp/sys/Makefile index 18300fa..605484b 100644 --- a/lib/libc/pdp/sys/Makefile +++ b/lib/libc/pdp/sys/Makefile @@ -57,18 +57,18 @@ OBJS= ${PDPOBJS} ${NORM1} ${NORM2} ${LONG} ${ERROR} ${NOERROR} TAGSFILE=tags .s.o: - /lib/cpp -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} -DPROF ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out profiled/$*.o - /lib/cpp ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ - -ld -X -r $*.o + ${CPP} ${DEFS} $< | sed -e 's;^#;/;' | as -V -o $@ + -${LD} -X -r $*.o mv a.out $*.o syslib syslib_p: ${OBJS} @echo "building profiled syslib" - @cd profiled; ar cru ../syslib_p ${OBJS} + @cd profiled; ${AR} cru ../syslib_p ${OBJS} @echo "building normal syslib" - @ar cru syslib ${OBJS} + @${AR} cru syslib ${OBJS} ${NORM1}: SYS.h /usr/include/syscall.h @echo creating $*.o profiled/$*.o diff --git a/lib/libc/stdio/Makefile b/lib/libc/stdio/Makefile index 72ce4e0..ce2d7b7 100644 --- a/lib/libc/stdio/Makefile +++ b/lib/libc/stdio/Makefile @@ -31,17 +31,17 @@ TAGSFILE=tags .c.o: ${CC} -p ${CFLAGS} -c $*.c - -ld -X -r $*.o + -${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - -ld -x -r $*.o + -${LD} -x -r $*.o mv a.out $*.o stdiolib stdiolib_p: ${OBJS} @echo "building profiled stdiolib" - @cd profiled; ar cru ../stdiolib_p ${OBJS} + @cd profiled; ${AR} cru ../stdiolib_p ${OBJS} @echo "building normal stdiolib" - @ar cru stdiolib ${OBJS} + @${AR} cru stdiolib ${OBJS} tags: cwd=`pwd`; \ diff --git a/lib/libc/stdlib/Makefile b/lib/libc/stdlib/Makefile index 4b1076a..ecd966b 100644 --- a/lib/libc/stdlib/Makefile +++ b/lib/libc/stdlib/Makefile @@ -15,19 +15,19 @@ OBJS= getopt.o getsubopt.o strtol.o strtoul.o .c.o: ${CC} -p ${CFLAGS} -c $*.c - ld -X -r $*.o + ${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - ld -X -r $*.o + ${LD} -X -r $*.o mv a.out $*.o all: stdliblib stdliblib_p stdliblib stdliblib_p: ${OBJS} @echo "building profiled stdlib" - @cd profiled; ar cru ../stdliblib_p ${OBJS} + @cd profiled; ${AR} cru ../stdliblib_p ${OBJS} @echo "building normal stdlib" - @ar cru stdliblib ${OBJS} + @${AR} cru stdliblib ${OBJS} clean: rm -f ${OBJS} profiled/*.o tags Makefile.bak stdliblib stdliblib_p diff --git a/lib/libc/string/Makefile b/lib/libc/string/Makefile index b2a2e40..3997db5 100644 --- a/lib/libc/string/Makefile +++ b/lib/libc/string/Makefile @@ -15,19 +15,19 @@ OBJS= strcspn.o strpbrk.o strerror.o strsep.o strspn.o strstr.o strtok.o .c.o: ${CC} -p ${CFLAGS} -c $*.c - ld -X -r $*.o + ${LD} -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c - ld -X -r $*.o + ${LD} -X -r $*.o mv a.out $*.o all: stringlib stringlib_p stringlib stringlib_p: ${OBJS} @echo "building profiled stringlib" - @cd profiled; ar cru ../stringlib_p ${OBJS} + @cd profiled; ${AR} cru ../stringlib_p ${OBJS} @echo "building normal stringlib" - @ar cru stringlib ${OBJS} + @${AR} cru stringlib ${OBJS} clean: rm -f ${OBJS} profiled/*.o tags Makefile.bak stringlib stringlib_p diff --git a/n.sh b/n.sh index ea4a011..6d9ea79 100755 --- a/n.sh +++ b/n.sh @@ -1,20 +1,21 @@ #!/bin/sh ROOT="`pwd`" -DESTDIR="$ROOT/host" +CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/bin" -mkdir --parents "$DESTDIR/lib" -mkdir --parents "$DESTDIR/usr/lib" -mkdir --parents "$DESTDIR/usr/man/cat1" -mkdir --parents "$DESTDIR/usr/man/cat3" -mkdir --parents "$DESTDIR/usr/man/cat5" -(cd bin/ar && make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install) -(cd bin/as && make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install) -(cd bin/cc && make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install) -(cd usr.lib/libvmf && make clean && make DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install) -(cd bin/ld && make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install) -(cd bin/nm && make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install) -(cd lib/c2 && make clean && make SEPFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install) -(cd lib/ccom && make clean && make LDC0FLAGS= LDC1FLAGS= PURFLAG= DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install) -(cd lib/cpp && make clean && make SEPFLAG= DESTDIR="$DESTDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install) +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/bin" +mkdir --parents "$CROSSDIR/lib" +mkdir --parents "$CROSSDIR/usr/bin" +mkdir --parents "$CROSSDIR/usr/lib" +mkdir --parents "$CROSSDIR/usr/man/cat1" +mkdir --parents "$CROSSDIR/usr/man/cat3" +mkdir --parents "$CROSSDIR/usr/man/cat5" +(cd bin/ar && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install) +(cd bin/as && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install) +(cd bin/cc && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install) +(cd usr.lib/libvmf && make clean && make DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install) +(cd bin/ld && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" LDFLAGS="-L$DESTDIR/usr/lib" install) +(cd bin/nm && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install) +(cd lib/c2 && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install) +(cd lib/ccom && make clean && make LDC0FLAGS= LDC1FLAGS= PURFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install) +(cd lib/cpp && make clean && make SEPFLAG= DESTDIR="$CROSSDIR" STAGEDIR="$STAGEDIR" CFLAGS="$CFLAGS" install) diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 6b405df..c04d8ee 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -1,8 +1,8 @@ # Makefile 1.9 (2.11BSD GTE) 1997/7/26 # -DESTDIR= -CFLAGS= -O -SEPFLAG= -i +NM=nm +CFLAGS=-O +SEPFLAG=-i # Programs that live in subdirectories, and have makefiles of their own. # @@ -39,7 +39,7 @@ NSTD= bc egrep # KMEM= iostat -all: ${SUBDIR} ${STD} ${NSTD} ${KMEM} +all: ${SUBDIR} ${STD} ${NSTD} ${KMEM} ${SCRIPT} ${SUBDIR}: FRC cd $@; make ${MFLAGS} SEPFLAG=${SEPFLAG} @@ -49,18 +49,21 @@ FRC: ${STD} ${KMEM}: ${CC} ${CFLAGS} ${SEPFLAG} -o $@ $@.c +${SCRIPT}: + sed -e "s@^nm @${NM} @" $@.sh >$@ + install: ${STD} ${NSTD} ${KMEM} -for i in ${SUBDIR}; do \ (cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install); done -for i in ${SCRIPT}; do \ - (install -c -m 555 $$i.sh ${DESTDIR}/usr/bin/$$i); done + (install -c -m 555 $$i ${DESTDIR}/usr/bin/$$i); done -for i in ${KMEM}; do \ (install -s -g kmem -m 2755 $$i ${DESTDIR}/usr/bin/$$i); done install -s ${STD} ${NSTD} ${DESTDIR}/usr/bin clean: for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} clean); done - rm -f a.out core *.s *.o y.tab.c ${STD} ${NSTD} ${KMEM} + rm -f a.out core *.s *.o y.tab.c ${STD} ${NSTD} ${KMEM} ${SCRIPT} depend: for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} depend); done diff --git a/usr.bin/n.sh b/usr.bin/n.sh new file mode 100755 index 0000000..780a9a4 --- /dev/null +++ b/usr.bin/n.sh @@ -0,0 +1,5 @@ +#!/bin/sh +ROOT="`pwd |sed -e 's/\/usr\.bin$//'`" +CROSSDIR="$ROOT/cross" +mkdir --parents "$CROSSDIR/usr/bin" +make clean && make NM="$CROSSDIR/bin/nm" lorder && install lorder -m 755 "$DESTDIR/usr/bin" diff --git a/usr.bin/ranlib/Makefile b/usr.bin/ranlib/Makefile index be0d0dd..1ea0387 100644 --- a/usr.bin/ranlib/Makefile +++ b/usr.bin/ranlib/Makefile @@ -1,25 +1,37 @@ -SRCS= ../../bin/ar/archive.c build.c misc.c ranlib.c touch.c -OBJS= archive.o build.o ./misc.o ranlib.o touch.o -CFLAGS= -O -I. -I../../bin/ar -VPATH= ../../bin/ar +# using VPATH to compile ./archive.o from ../../bin/ar/archive.c does not work +# if there is ../../bin/ar/archive.o leftover from building ar, so we reuse it +#VPATH=../../bin/ar +SRCS=../../bin/ar/archive.c build.c misc.c ranlib.c touch.c +OBJS=../../bin/ar/archive.o build.o misc.o ranlib.o touch.o + +CFLAGS=-O +CPPFLAGS=-Iinclude -I../../bin/ar +SEPFLAG=-i all: ranlib.0 ranlib.5.0 ranlib ranlib.0: ranlib.1 - /usr/man/manroff ranlib.1 > ranlib.0 +# /usr/man/manroff ranlib.1 > ranlib.0 + nroff -man ranlib.1 > ranlib.0 ranlib.5.0: ranlib.5.5 - /usr/man/manroff ranlib.5.5 > ranlib.5.0 +# /usr/man/manroff ranlib.5.5 > ranlib.5.0 + nroff -man ranlib.5.5 > ranlib.5.0 ranlib: ${OBJS} - cc -z -o ranlib ${OBJS} + ${CC} ${SEPFLAG} -o ranlib ${OBJS} -install: - install -c -o bin -g bin -m 444 ranlib.5.0 \ +install: all +# install -c -o bin -g bin -m 444 ranlib.5.0 \ +# ${DESTDIR}/usr/man/cat5/ranlib.0 +# install -c -o bin -g bin -m 444 ranlib.0 \ +# ${DESTDIR}/usr/man/cat1/ranlib.0 +# install -c -s -o bin -g bin -m 755 ranlib ${DESTDIR}/usr/bin/ranlib + install -c -m 444 ranlib.5.0 \ ${DESTDIR}/usr/man/cat5/ranlib.0 - install -c -o bin -g bin -m 444 ranlib.0 \ + install -c -m 444 ranlib.0 \ ${DESTDIR}/usr/man/cat1/ranlib.0 - install -c -s -o bin -g bin -m 755 ranlib ${DESTDIR}/usr/bin/ranlib + install -c -s -m 755 ranlib ${DESTDIR}/usr/bin/ranlib lint: lint -havx -I. -I../../bin/ar ${SRCS} diff --git a/usr.bin/ranlib/_ranlib.h b/usr.bin/ranlib/_ranlib.h new file mode 100644 index 0000000..ba8e591 --- /dev/null +++ b/usr.bin/ranlib/_ranlib.h @@ -0,0 +1,23 @@ +#ifndef __RANLIB_H +#define __RANLIB_H 1 + +#include +#include "krcompat.h" + +/* build.c */ +int build PARAMS((void)); +int sgets PARAMS((char *buf, int n, register FILE *fp)); +/* misc.c */ +int tmp PARAMS((void)); +void *emalloc PARAMS((int len)); +char *rname PARAMS((char *path)); +void badfmt PARAMS((void)); +void error PARAMS((char *name)); +/* touch.c */ +int touch PARAMS((void)); +void settime PARAMS((int afd)); +/* ranlib.c */ +int main PARAMS((int argc, char **argv)); +void usage PARAMS((void)); + +#endif diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c index 4de32ea..c81df08 100644 --- a/usr.bin/ranlib/build.c +++ b/usr.bin/ranlib/build.c @@ -48,9 +48,12 @@ static char sccsid[] = "@(#)build.c 5.3.1 (Berkeley) 5/17/93"; #include #include #include +#include +#include +#include #include +#include "_ranlib.h" -extern off_t lseek(); extern CHDR chdr; /* converted header */ extern char *archive; /* archive name */ extern char *tname; /* temporary file "name" */ @@ -64,13 +67,13 @@ typedef struct _rlib { RLIB *rhead, **pnext; FILE *fp; -static void rexec(), symobj(); -void error(), badfmt(); long symcnt; /* symbol count */ long tsymlen; /* total string length */ -build() -{ +static void rexec PARAMS((int rfd, int wfd)); +static void symobj PARAMS((void)); + +int build() { CF cf; int afd, tfd; off_t size; @@ -116,11 +119,7 @@ build() * Read the exec structure; ignore any files that don't look * exactly right. */ -static void -rexec(rfd, wfd) - int rfd; - int wfd; -{ +static void rexec(rfd, wfd) int rfd; int wfd; { register RLIB *rp; RLIB **savnext; long nsyms; @@ -200,9 +199,7 @@ bad1: (void)lseek(rfd, (off_t)r_off, L_SET); * Write the symbol table into the archive, computing offsets as * writing. */ -static void -symobj() -{ +static void symobj() { register RLIB *rp, *next; struct ranlib rn; char hb[sizeof(struct ar_hdr) + 1], pad; @@ -270,11 +267,7 @@ symobj() (void)fflush(fp); } -sgets(buf, n, fp) - char *buf; - int n; - register FILE *fp; - { +int sgets(buf, n, fp) char *buf; int n; register FILE *fp; { register int i, c; n--; /* room for null */ @@ -287,4 +280,4 @@ sgets(buf, n, fp) } *buf = '\0'; return(i + 1); - } +} diff --git a/usr.bin/ranlib/include/ar.h b/usr.bin/ranlib/include/ar.h new file mode 120000 index 0000000..7245d58 --- /dev/null +++ b/usr.bin/ranlib/include/ar.h @@ -0,0 +1 @@ +../../../include/ar.h \ No newline at end of file diff --git a/usr.bin/ranlib/include/ranlib.h b/usr.bin/ranlib/include/ranlib.h new file mode 120000 index 0000000..bce4b4b --- /dev/null +++ b/usr.bin/ranlib/include/ranlib.h @@ -0,0 +1 @@ +../../../include/ranlib.h \ No newline at end of file diff --git a/usr.bin/ranlib/krcompat.h b/usr.bin/ranlib/krcompat.h new file mode 100644 index 0000000..62f9848 --- /dev/null +++ b/usr.bin/ranlib/krcompat.h @@ -0,0 +1,19 @@ +#ifndef _KRCOMPAT_H +#define _KRCOMPAT_H 1 + +#undef PARAMS +#ifdef __STDC__ +#include +#define PARAMS(args) args +#else +#include +#define PARAMS(args) () +#endif + +#ifdef __GNUC__ +#define NORETURN __attribute__ ((noreturn)) +#else +#define NORETURN +#endif + +#endif diff --git a/usr.bin/ranlib/misc.c b/usr.bin/ranlib/misc.c index b6251d8..8121938 100644 --- a/usr.bin/ranlib/misc.c +++ b/usr.bin/ranlib/misc.c @@ -42,16 +42,16 @@ static char sccsid[] = "@(#)misc.c 5.2 (Berkeley) 2/26/91"; #include #include #include +#include #include +#include #include "pathnames.h" +#include "_ranlib.h" -extern int errno; -extern char *archive, *malloc(); /* archive name */ -void error(); +extern char *archive; /* archive name */ char *tname = "temporary file"; /* temporary file "name" */ -tmp() -{ +int tmp() { long set, oset; int fd; char path[MAXPATHLEN]; @@ -67,10 +67,7 @@ tmp() return(fd); } -void * -emalloc(len) - int len; -{ +void *emalloc(len) int len; { char *p; if (!(p = malloc((u_int)len))) @@ -78,26 +75,18 @@ emalloc(len) return((void *)p); } -char * -rname(path) - char *path; -{ +char *rname(path) char *path; { register char *ind; return((ind = rindex(path, '/')) ? ind + 1 : path); } -void -badfmt() -{ +void badfmt() { errno = EINVAL; error(archive); } -void -error(name) - char *name; -{ +void error(name) char *name; { (void)fprintf(stderr, "ranlib: %s: %s\n", name, strerror(errno)); exit(1); } diff --git a/usr.bin/ranlib/n.sh b/usr.bin/ranlib/n.sh new file mode 100755 index 0000000..394472a --- /dev/null +++ b/usr.bin/ranlib/n.sh @@ -0,0 +1,6 @@ +#!/bin/sh +ROOT="`pwd |sed -e 's/\/usr\.bin\/ranlib$//'`" +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/usr/bin" +make clean && make SEPFLAG= DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install diff --git a/usr.bin/ranlib/ranlib.c b/usr.bin/ranlib/ranlib.c index 589fef3..caba742 100644 --- a/usr.bin/ranlib/ranlib.c +++ b/usr.bin/ranlib/ranlib.c @@ -42,19 +42,19 @@ char copyright[] = static char sccsid[] = "@(#)ranlib.c 5.6 (Berkeley) 2/26/91"; #endif +#include #include #include #include +#include #include +#include "_ranlib.h" CHDR chdr; u_int options; /* UNUSED -- keep open_archive happy */ char *archive; -main(argc, argv) - int argc; - char **argv; -{ +int main(argc, argv) int argc; char **argv; { extern int optind; int ch, eval, tflag; @@ -79,8 +79,7 @@ main(argc, argv) exit(eval); } -usage() -{ +void usage() { (void)fprintf(stderr, "usage: ranlib [-t] archive ...\n"); exit(1); } diff --git a/usr.bin/ranlib/touch.c b/usr.bin/ranlib/touch.c index 822ac51..8590f48 100644 --- a/usr.bin/ranlib/touch.c +++ b/usr.bin/ranlib/touch.c @@ -47,16 +47,14 @@ static char sccsid[] = "@(#)touch.c 5.3 (Berkeley) 3/12/91"; #include #include #include +#include #include +#include "_ranlib.h" -extern time_t time(); -extern off_t lseek(); extern CHDR chdr; /* converted header */ extern char *archive; /* archive name */ -void error(); -touch() -{ +int touch() { int afd; afd = open_archive(O_RDWR); @@ -71,9 +69,7 @@ touch() return(0); } -settime(afd) - int afd; -{ +void settime(afd) int afd; { struct ar_hdr *hdr; off_t size; char buf[50]; diff --git a/usr.lib/libvmf/n.sh b/usr.lib/libvmf/n.sh index 16a5bc6..4d06d01 100755 --- a/usr.lib/libvmf/n.sh +++ b/usr.lib/libvmf/n.sh @@ -1,7 +1,7 @@ #!/bin/sh ROOT="`pwd |sed -e 's/\/usr\.lib\/libvmf$//'`" -DESTDIR="$ROOT/host" -CFLAGS="-Wall -Wno-char-subscripts -Wno-format -Wno-parentheses" -mkdir --parents "$DESTDIR/usr/lib" -mkdir --parents "$DESTDIR/usr/man/cat3" -make clean && make DESTDIR="$DESTDIR" CFLAGS="$CFLAGS" install +CROSSDIR="$ROOT/cross" +CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses" +mkdir --parents "$CROSSDIR/usr/lib" +mkdir --parents "$CROSSDIR/usr/man/cat3" +make clean && make DESTDIR="$CROSSDIR" CFLAGS="$CFLAGS" install -- 2.34.1