Tidy up xified C compiler to use relative paths and not fake out explicit paths
authorNick Downing <downing.nick@gmail.com>
Mon, 23 Jan 2017 10:26:13 +0000 (21:26 +1100)
committerNick Downing <downing.nick@gmail.com>
Mon, 23 Jan 2017 10:47:31 +0000 (21:47 +1100)
34 files changed:
.gitignore
lib/libc/compat-4.1/Makefile
lib/libc/compat-sys5/Makefile
lib/libc/gen/Makefile
lib/libc/inet/Makefile
lib/libc/linux/csu/Makefile
lib/libc/linux/gen/Makefile
lib/libc/linux/sys/Makefile
lib/libc/net/Makefile
lib/libc/net/hosttable/Makefile
lib/libc/net/named/Makefile
lib/libc/ns/Makefile
lib/libc/stdio/Makefile
lib/libc/sys/Makefile
lib/libc/vax/compat-4.1/Makefile
lib/libc/vax/csu/Makefile
lib/libc/vax/gen/Makefile
lib/libc/vax/net/Makefile
lib/libc/vax/stdio/Makefile
lib/libc/vax/sys/Makefile
n.sh
scripts/Makefile [new file with mode: 0644]
scripts/errfunc.sh [moved from xify/errfunc.sh with 100% similarity]
scripts/newline.c [moved from xify/newline.c with 100% similarity]
scripts/nocomment.c [moved from xify/nocomment.c with 100% similarity]
scripts/nonvoid.sh [moved from xify/nonvoid.sh with 100% similarity]
scripts/noproto.sh [moved from xify/noproto.sh with 100% similarity]
scripts/nostring.c [moved from xify/nostring.c with 100% similarity]
test/Makefile
xify/Makefile
xify/cc.c
xify/ld.c
xify/xify.c [moved from xify/xifyfilt.c with 100% similarity]
xify/xify.sh [moved from xify/xify with 100% similarity]

index 8111d8c..b033ef0 100644 (file)
@@ -50,7 +50,7 @@ test/hello
 test/hello.txt
 xify/cc
 xify/ld
-xify/newline
-xify/nocomment
-xify/nostring
-xify/xifyfilt
+xify/xify
+scripts/newline
+scripts/nocomment
+scripts/nostring
index 4080fd5..d521d09 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -19,10 +20,10 @@ 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}
index 4af68bc..3b7c7db 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #      Makefile        1.5     85/09/05
 #
 CFLAGS=        -O ${DEFS}
@@ -11,10 +12,10 @@ 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}
index 2313b43..094e001 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -37,10 +38,10 @@ 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}
index 34fc6d8..ebf2b23 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -17,10 +18,10 @@ 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}
index d0a5e31..1729626 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -36,34 +37,34 @@ gcrt0.o: crt0.c
 #      cc -S ${DFLAGS} -DCRT0 crt0.c
 #      /lib/cpp crt0.s > x.s
 #      as -o x.o x.s
-#      ld -x -r -o crt0.o x.o
+#      ${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
 #      as -o x.o x.s
-#      ld -x -r -o moncrt0.o x.o
+#      ${LD} -x -r -o moncrt0.o x.o
 #      rm -f x.s x.o crt0.s
 #
 #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 mon.ex
 #      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
+#      ${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
 #      ex - gmon.s < gmon.ex
 #      as -o x.o gmon.s
-#      ld -x -r -o gmon.o x.o
+#      ${LD} -x -r -o gmon.o x.o
 #      rm -f x.o gmon.s
 
 tags:  
index c313fba..dadc9b6 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -12,10 +13,10 @@ 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}
index e09be89..f9498f7 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -14,10 +15,10 @@ 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
 
 syslib syslib_p: ${OBJS}
index def2b5c..d776d8b 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1983 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -22,10 +23,10 @@ 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}
index 5d9aad6..4f59870 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 
 #
 # Copyright (c) 1983 Regents of the University of California.
@@ -13,10 +14,10 @@ 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} 
index 6958409..3a58b8a 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1983 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -16,10 +17,10 @@ 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} 
index d28ab05..7a29b74 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -13,10 +14,10 @@ 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}
index 331b111..a1384bb 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -22,10 +23,10 @@ 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}
index c61a4ae..fb9b833 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -45,10 +46,10 @@ 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
 
 syslib syslib_p: ${OBJS}
index 7fe0c12..c80f3fd 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -12,10 +13,10 @@ TAGSFILE=tags
 
 .c.o:
        /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
-       -ld -X -r $*.o
+       -${LD} -X -r $*.o
        mv a.out profiled/$*.o
        /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 compat-4.1lib compat-4.1lib_p: ${OBJS}
index c12f180..b865be6 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -25,34 +26,34 @@ crt0.o:     crt0.c
        cc -S ${DFLAGS} -DCRT0 crt0.c
        /lib/cpp crt0.s > x.s
        as -o x.o x.s
-       ld -x -r -o crt0.o x.o
+       ${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
        as -o x.o x.s
-       ld -x -r -o moncrt0.o x.o
+       ${LD} -x -r -o moncrt0.o x.o
        rm -f x.s x.o crt0.s
 
 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 mon.ex
        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
+       ${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
        ex - gmon.s < gmon.ex
        as -o x.o gmon.s
-       ld -x -r -o gmon.o x.o
+       ${LD} -x -r -o gmon.o x.o
        rm -f x.o gmon.s
 
 tags:  
index d76ebb9..b13585d 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #      Makefile        4.13    86/01/09
 #
 SRCS=  _setjmp.s abs.s alloca.s atof.s bcmp.s bcopy.s bzero.s disktab.c \
@@ -13,18 +14,18 @@ TAGSFILE=tags
 
 .s.o:
        /lib/cpp -E ${DEFS} -DPROF $*.s | ${AS} -o $*.o
-       -ld -X -r $*.o
+       -${LD} -X -r $*.o
        mv a.out profiled/$*.o
        /lib/cpp -E ${DEFS} $*.s | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 .c.o:
        cc -p -c ${CFLAGS} $*.c
-       -ld -X -r $*.o
+       -${LD} -X -r $*.o
        mv a.out profiled/$*.o
        cc -c ${CFLAGS} $*.c
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 genlib genlib_p: ${OBJS}
index d63b813..be0184e 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1983 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -12,10 +13,10 @@ TAGSFILE=tags
 
 .c.o:
        /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out profiled/$*.o
        /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 netlib netlib_p: ${OBJS}
index 04c58b9..39e1f99 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -14,10 +15,10 @@ TAGSFILE=tags
 
 .c.o:
        cc -E -DPROF ${CFLAGS} $*.c | as -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out profiled/$*.o
        cc -E ${CFLAGS} $*.c | as -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 stdiolib stdiolib_p: ${OBJS}
index cbf667b..3d06ca7 100644 (file)
@@ -1,3 +1,4 @@
+LD=ld
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
@@ -74,10 +75,10 @@ TAGSFILE=tags
 
 .c.o:
        /lib/cpp -E ${DEFS} -DPROF $*.c | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out profiled/$*.o
        /lib/cpp -E ${DEFS} $*.c | ${AS} -o $*.o
-       -ld -x -r $*.o
+       -${LD} -x -r $*.o
        mv a.out $*.o
 
 syslib syslib_p: ${OBJS}
diff --git a/n.sh b/n.sh
index f5627f5..a88b013 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -9,29 +9,25 @@ mkdir -p cross/usr/include
 mkdir -p cross/usr/lib
 
 (cd xify && make clean && make && make DESTDIR=$ROOT/cross install)
+(cd include && make DESTDIR=$ROOT/cross SHARED=copies install)
 
-# new way, not working yet because no prototypes in include yet:
-#(cd include && make DESTDIR=$ROOT/cross SHARED=copies install)
-# old way:
-(cd lib/libx_c && make DESTDIR=$ROOT/cross install-headers)
-
-mkdir -p lib/libx_c/compat-4.1/profiled
-mkdir -p lib/libx_c/compat-sys5/profiled
-mkdir -p lib/libx_c/gen/profiled
-mkdir -p lib/libx_c/inet/profiled
-mkdir -p lib/libx_c/linux/gen/profiled
-mkdir -p lib/libx_c/linux/profiled
-mkdir -p lib/libx_c/linux/sys/profiled
-mkdir -p lib/libx_c/net/hosttable/profiled
-mkdir -p lib/libx_c/net/named/profiled
-mkdir -p lib/libx_c/net/profiled
-mkdir -p lib/libx_c/ns/profiled
-mkdir -p lib/libx_c/stdio/profiled
-mkdir -p lib/libx_c/sys/profiled
+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
 (
-  cd lib/libx_c && \
+  cd lib/libc && \
   make clean && \
-  FAKEROOT=$ROOT/cross PATH=$ROOT/cross/bin:$PATH make CC="cc -Dvax" && \
+  make CC="${ROOT}/cross/bin/hostcc -Dvax" LD="${ROOT}/cross/bin/hostld" && \
   make DESTDIR=$ROOT/cross install
 )
 
diff --git a/scripts/Makefile b/scripts/Makefile
new file mode 100644 (file)
index 0000000..6a7cab8
--- /dev/null
@@ -0,0 +1,17 @@
+CC=gcc -g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
+
+ALL=newline nocomment nostring
+
+all: ${ALL}
+
+newline: newline.c
+       ${CC} -o $@ newline.c
+
+nocomment: nocomment.c
+       ${CC} -o $@ nocomment.c
+
+nostring: nostring.c
+       ${CC} -o $@ nostring.c
+
+clean:
+       rm -f ${ALL}
similarity index 100%
rename from xify/errfunc.sh
rename to scripts/errfunc.sh
similarity index 100%
rename from xify/newline.c
rename to scripts/newline.c
similarity index 100%
rename from xify/nocomment.c
rename to scripts/nocomment.c
similarity index 100%
rename from xify/nonvoid.sh
rename to scripts/nonvoid.sh
similarity index 100%
rename from xify/noproto.sh
rename to scripts/noproto.sh
similarity index 100%
rename from xify/nostring.c
rename to scripts/nostring.c
index 252c20c..9c1401e 100644 (file)
@@ -1,6 +1,6 @@
 ROOT=..
-CC=FAKEROOT=${ROOT}/cross ${ROOT}/cross/bin/cc
-CFLAGS=-I. -d -g -Dvax
+CC=${ROOT}/cross/bin/hostcc
+CFLAGS=-d -g -Dvax
 
 hello: hello.o
        ${CC} ${CFLAGS} -o $@ hello.o
index 460899d..de1d994 100644 (file)
@@ -2,10 +2,9 @@ ROOT=..
 CC=gcc -g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
 DESTDIR=${ROOT}/cross
 
-BIN=cc ld
-LIB=newline nocomment nostring xifyfilt
+ALL=cc ld xify
 
-all: ${BIN} ${LIB}
+all: ${ALL}
 
 cc: cc.c
        ${CC} -DXIFY -o $@ cc.c
@@ -13,23 +12,14 @@ cc: cc.c
 ld: ld.c
        ${CC} -DXIFY -o $@ ld.c
 
-newline: newline.c
-       ${CC} -o $@ newline.c
-
-nocomment: nocomment.c
-       ${CC} -o $@ nocomment.c
-
-nostring: nostring.c
-       ${CC} -o $@ nostring.c
-
 xifyfilt: xifyfilt.c
        ${CC} -o $@ xifyfilt.c
 
 clean:
-       rm -f ${BIN} ${LIB}
+       rm -f ${ALL}
 
 install: all
-       mkdir -p ${DESTDIR}/bin
-       cp ${BIN} ${DESTDIR}/bin
-       mkdir -p ${DESTDIR}/lib
-       cp ${LIB} xify ${DESTDIR}/lib
+       install -s cc ${DESTDIR}/bin/hostcc
+       install -s ld ${DESTDIR}/bin/hostld
+       install -s xify ${DESTDIR}/lib/xifyfilt
+       install xify.sh ${DESTDIR}/lib/xify
index 3dc2600..e02bad5 100644 (file)
--- a/xify/cc.c
+++ b/xify/cc.c
@@ -23,17 +23,19 @@ static      char sccsid[] = "@(#)cc.c 4.13 9/18/85";
 
 #ifdef XIFY
 char   *gcc = "/usr/bin/gcc";
-char   *xify = "/lib/xify";
-char   *include = "/usr/include/.xify";
+char   *ld;
+char   *xify;
+char   *include;
+char   *crt0;
 #else
 char   *cpp = "/lib/cpp";
 char   *ccom = "/lib/ccom";
 char   *sccom = "/lib/sccom";
 char   *c2 = "/lib/c2";
 char   *as = "/bin/as";
-#endif
 char   *ld = "/bin/ld";
 char   *crt0 = "/lib/crt0.o";
+#endif
 
 #ifndef XIFY
 char   tmp0[30];               /* big enough for /tmp/ctm%05.5d */
@@ -113,7 +115,7 @@ char *setsuf __P((char *as, int ch));
 int xify_enqueue __P((char *in_name, char *prev_name));
 int xify_file __P((char *in_name, struct timespec *in_mtime));
 #endif
-int callsys __P((char *f, char **v));
+int callsys __P((/*char *f,*/ char **v));
 int nodup __P((char **l, char *os));
 char *savestr __P((register char *cp));
 char *strspl __P((char *left, char *right));
@@ -125,7 +127,6 @@ int main(argc, argv) int argc; char **argv; {
 #endif
        int i, j, c;
 #ifdef XIFY
-       char **p;
        struct stat statbuf;
 #endif
 
@@ -134,6 +135,22 @@ int main(argc, argv) int argc; char **argv; {
        clist = (char **)calloc(argc, sizeof (char **));
        llist = (char **)calloc(argc, sizeof (char **));
        plist = (char **)calloc(argc, sizeof (char **));
+#ifdef XIFY
+       t = argv[0];
+       j = strlen(t);
+       for (i = j; i > 0 && t[i - 1] != '/'; --i)
+               ;
+       j = (j >= 2 && t[j - 2] == 'c' && t[j - 1] == 'c') ? j - 2 : i;
+       bcopy(t, in_path, j);
+       strcpy(in_path + j, "ld");
+       ld = savestr(in_path);
+       strcpy(in_path + i, "../lib/xify");
+       xify = savestr(in_path);
+       strcpy(in_path + i, "../usr/include/.xify");
+       include = savestr(in_path);
+       strcpy(in_path + i, "../lib/crt0.o");
+       crt0 = savestr(in_path);
+#endif
        for (i = 1; i < argc; i++) {
                if (*argv[i] == '-') switch (argv[i][1]) {
 
@@ -298,22 +315,7 @@ int main(argc, argv) int argc; char **argv; {
        if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
                signal(SIGHUP, (void (*) __P((int sig)))idexit);
 #ifdef XIFY
-       plist[np++] = "-I/usr/include/.xify";
-       t = getenv("FAKEROOT");
-       if (t) {
-               xify = strspl(t, xify);
-               for (i = 0; i < np; ++i)
-                       if (plist[i][2] == '/')
-                               plist[i] = strspl("-I", strspl(t, plist[i] + 2));
-       }
-       for (i = 0; environ[i]; ++i)
-               if (strncmp(environ[i], "PATH=", 5) == 0)
-                       goto found_path_var;
-       p = (char **)calloc(i + 2, sizeof(char *));
-       bcopy(environ, p, i * sizeof(char *));
-       environ = p;
-found_path_var:
-       environ[i] = "PATH=/bin:/usr/bin";
+       plist[np++] = strspl("-I", include);
 #else
        if (pflag==0)
                sprintf(tmp0, "/tmp/ctm%05.5d", getpid());
@@ -358,7 +360,7 @@ found_path_var:
                                ++in_queue_head;
                        }
                }
-               av[0] = "gcc"; av[1] = "-o";
+               av[0] = /*"gcc"*/gcc; av[1] = "-o";
                na = 2;
                if (cflag && nc==1 && outfile)
                        av[na++] = outfile;
@@ -384,7 +386,7 @@ found_path_var:
                        av[na++] = "-c";
                av[na++] = clist[i];
                av[na] = 0;
-               if (callsys(gcc, av)) {
+               if (callsys(/*gcc,*/ av)) {
                nogood:
                        cflag++;
                        eflag++;
@@ -398,14 +400,14 @@ found_path_var:
                        assource = tmp3;
                if (pflag)
                        tmp4 = setsuf(clist[i], 'i');
-               av[0] = "cpp"; av[1] = clist[i];
+               av[0] = /*"cpp"*/cpp; av[1] = clist[i];
                na = 2;
                if (!exflag)
                        av[na++] = tmp4;
                for (j = 0; j < np; j++)
                        av[na++] = plist[j];
                av[na++] = 0;
-               if (callsys(cpp, av)) {
+               if (callsys(/*cpp,*/ av)) {
                        exfail++;
                        eflag++;
                }
@@ -420,7 +422,7 @@ found_path_var:
                                tmp3 = setsuf(clist[i], 's');
                        assource = tmp3;
                }
-               av[0] = fflag ? "sccom" : "ccom";
+               av[0] = fflag ? /*"sccom"*/sccom : /*"ccom"*/ccom;
                av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
                if (proflag)
                        av[na++] = "-XP";
@@ -432,14 +434,14 @@ found_path_var:
                if (wflag)
                        av[na++] = "-w";
                av[na] = 0;
-               if (callsys(fflag ? sccom : ccom, av)) {
+               if (callsys(/*fflag ? sccom : ccom,*/ av)) {
                        cflag++;
                        eflag++;
                        continue;
                }
                if (oflag) {
-                       av[0] = "c2"; av[1] = tmp5; av[2] = tmp3; av[3] = 0;
-                       if (callsys(c2, av)) {
+                       av[0] = /*"c2"*/c2; av[1] = tmp5; av[2] = tmp3; av[3] = 0;
+                       if (callsys(/*c2,*/ av)) {
                                unlink(tmp3);
                                tmp3 = assource = tmp5;
                        } else
@@ -449,7 +451,7 @@ found_path_var:
                        continue;
        assemble:
                cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
-               av[0] = "as"; av[1] = "-o";
+               av[0] = /*"as"*/as; av[1] = "-o";
                if (cflag && nc==1 && outfile)
                        av[2] = outfile;
                else
@@ -461,7 +463,7 @@ found_path_var:
                        av[na++] = dflag;
                av[na++] = assource;
                av[na] = 0;
-               if (callsys(as, av) > 1) {
+               if (callsys(/*as,*/ av) > 1) {
                        cflag++;
                        eflag++;
                        continue;
@@ -470,16 +472,8 @@ found_path_var:
        }
 nocom:
        if (cflag==0 && nl!=0) {
-#ifdef XIFY
-               t = getenv("FAKEROOT");
-               if (t) {
-                       ld = strspl(t, ld);
-                       if (crt0[0] == '/')
-                               crt0 = strspl(t, crt0);
-               }
-#endif
                i = 0;
-               av[0] = "ld"; av[1] = "-X"; av[2] = crt0; na = 3;
+               av[0] = /*"ld"*/ld; av[1] = "-X"; av[2] = crt0; na = 3;
                if (outfile) {
                        av[na++] = "-o";
                        av[na++] = outfile;
@@ -499,7 +493,7 @@ nocom:
                else
                        av[na++] = "-lc";
                av[na++] = 0;
-               eflag |= callsys(ld, av);
+               eflag |= callsys(/*ld,*/ av);
                if (nc==1 && nxo==1 && eflag==0)
                        unlink(setsuf(clist[0], 'o'));
        }
@@ -602,8 +596,8 @@ int xify_file(in_name, in_mtime) char *in_name; struct timespec *in_mtime; {
                }
                out_path[i + 5] = '/';
 
-               av[0] = "xify"; av[1] = in_name; av[2] = out_path; av[3] = err_path; av[4] = 0;
-               if (callsys(xify, av))
+               av[0] = /*"xify"*/xify; av[1] = in_name; av[2] = out_path; av[3] = err_path; av[4] = 0;
+               if (callsys(/*xify,*/ av))
                        return 1;
        }
 
@@ -723,24 +717,35 @@ found:
 }
 #endif
 
-int callsys(f, v) char *f; char **v; {
+int callsys(/*f,*/ v) /*char *f;*/ char **v; {
        int t, status;
+#if 1
+       int i;
+
+       if (debug) {
+               fprintf(stderr, "%s", v[0]);
+               for (i = 1; v[i]; ++i)
+                       fprintf(stderr, " %s", v[i]);
+               fprintf(stderr, "\n");
+       }
+#else
        char **cpp;
 
        if (debug) {
-               fprintf(stderr, "%s:", f);
+               fprintf(stderr, "%s:", /*f*/v[0]);
                for (cpp = v; *cpp != 0; cpp++)
                        fprintf(stderr, " %s", *cpp);
                fprintf(stderr, "\n");
        }
+#endif
        t = vfork();
        if (t == -1) {
                printf("No more processes\n");
                return (100);
        }
        if (t == 0) {
-               execv(f, v);
-               printf("Can't find %s\n", f);
+               execv(/*f*/v[0], v);
+               printf("Can't find %s\n", /*f*/v[0]);
                fflush(stdout);
                _exit(100);
        }
@@ -748,7 +753,7 @@ int callsys(f, v) char *f; char **v; {
                ;
        if ((t=(status&0377)) != 0 && t!=14) {
                if (t!=2) {
-                       printf("Fatal error in %s\n", f);
+                       printf("Fatal error in %s\n", /*f*/v[0]);
                        eflag = 8;
                }
                dexit();
index 1d19d41..a0b380d 100644 (file)
--- a/xify/ld.c
+++ b/xify/ld.c
@@ -396,7 +396,7 @@ void delexit __P((void));
 void endload __P((int argc, char **argv));
 #ifdef XIFY
 void xify_library __P((char *in_name));
-int callsys __P((char *f, char **v));
+int callsys __P((/*char *f,*/ char **v));
 #else
 void load1arg __P((register char *cp));
 int step __P((off_t nloc));
@@ -486,23 +486,16 @@ int main(argc, argv) int argc; char **argv; {
        }
        /* add default search directories */
 #ifdef XIFY
-       dirs[ndir++] = "/lib/.xify";
-       dirs[ndir++] = "/usr/lib/.xify";
-       dirs[ndir++] = "/usr/local/lib/.xify";
-       ap = getenv("FAKEROOT");
-       if (ap) {
-               for (i = 0; i < ndir; ++i)
-                       if (dirs[i][0] == '/')
-                               dirs[i] = strspl(ap, dirs[i]);
-       }
-       for (i = 0; environ[i]; ++i)
-               if (strncmp(environ[i], "PATH=", 5) == 0)
-                       goto found_path_var;
-       p = (char **)calloc(i + 2, sizeof(char *));
-       bcopy(environ, p, i * sizeof(char *));
-       environ = p;
-found_path_var:
-       environ[i] = "PATH=/bin:/usr/bin";
+       ap = argv[0];
+       for (i = strlen(ap); i > 0 && ap[i - 1] != '/'; --i)
+               ;
+       bcopy(ap, in_path, i);
+       strcpy(in_path + i, "../lib/.xify");
+       dirs[ndir++] = savestr(in_path);
+       strcpy(in_path + i, "../usr/lib/.xify");
+       dirs[ndir++] = savestr(in_path);
+       strcpy(in_path + i, "../usr/local/lib/.xify");
+       dirs[ndir++] = savestr(in_path);
 #else
        dirs[ndir++] = "/lib";
        dirs[ndir++] = "/usr/lib";
@@ -741,7 +734,7 @@ void endload(argc, argv) int argc; char **argv; {
 #ifdef XIFY
        /* ld currently adds upto 5 args; 10 is room to spare */
        av = (char **)calloc(argc+10, sizeof (char **));
-       av[0] = rflag ? "ld" : "gcc"; av[1] = "-o"; av[2] = ofilename;
+       av[0] = rflag ? /*"ld"*/ld : /*"gcc"*/gcc; av[1] = "-o"; av[2] = ofilename;
        na = 3;
        for (i = 0; i < ndir; ++i)
                av[na++] = strspl("-L", dirs[i]);
@@ -817,7 +810,7 @@ next:
                ;
        }
 #ifdef XIFY
-       if (callsys(rflag ? ld : gcc, av))
+       if (callsys(/*rflag ? ld : gcc,*/ av))
                delexit();
 #endif
        finishout();
@@ -836,6 +829,16 @@ void xify_library(in_name) char *in_name; {
                strcat(in_path + j, ".a");
                if (stat(in_path, &statbuf) == 0)
                        goto found;
+
+               strcpy(in_path + j, ".xify/libx_");
+               strcat(in_path + j, in_name);
+               strcat(in_path + j, ".a");
+               if (trace)
+                       fprintf(stderr, "unlink %s\n", in_path);
+               if (unlink(in_path) && errno != ENOENT) {
+                       filname=in_path;
+                       error(1, "can't unlink\n");
+               }
        }
        error(1, "not found\n");
        exit(1);
@@ -848,6 +851,8 @@ found:
        strcat(out_path + j, ".a");
        if (stat(out_path, &statbuf) == 0)
                return;
+       if (trace)
+               fprintf(stderr, "mkdir %s\n", dirs[i]);
        if (mkdir(dirs[i], 0777) == -1 && errno != EEXIST) {
                filname = dirs[i];
                error(1, "can't mkdir\n");
@@ -855,30 +860,43 @@ found:
        strcpy(in_path, "../lib");
        strcat(in_path, in_name);
        strcat(in_path, ".a");
+       if (trace)
+               fprintf(stderr, "symlink %s %s\n", in_path, out_path);
        if (symlink(in_path, out_path) == -1) {
                filname = out_path;
                error(1, "can't symlink\n");
        }
 }
 
-int callsys(f, v) char *f; char **v; {
+int callsys(/*f,*/ v) /*char *f;*/ char **v; {
        int t, status;
+#if 1
+       int i;
+
+       if (/*debug*/trace) {
+               fprintf(stderr, "%s", v[0]);
+               for (i = 1; v[i]; ++i)
+                       fprintf(stderr, " %s", v[i]);
+               fprintf(stderr, "\n");
+       }
+#else
        char **cpp;
 
        if (/*debug*/trace) {
-               fprintf(stderr, "%s:", f);
+               fprintf(stderr, "%s:", /*f*/v[0]);
                for (cpp = v; *cpp != 0; cpp++)
                        fprintf(stderr, " %s", *cpp);
                fprintf(stderr, "\n");
        }
+#endif
        t = vfork();
        if (t == -1) {
                printf("No more processes\n");
                return (100);
        }
        if (t == 0) {
-               execv(f, v);
-               printf("Can't find %s\n", f);
+               execv(/*f*/v[0], v);
+               printf("Can't find %s\n", /*f*/v[0]);
                fflush(stdout);
                _exit(100);
        }
@@ -886,7 +904,7 @@ int callsys(f, v) char *f; char **v; {
                ;
        if ((t=(status&0377)) != 0 && t!=14) {
                if (t!=2) {
-                       printf("Fatal error in %s\n", f);
+                       printf("Fatal error in %s\n", /*f*/v[0]);
                        /*eflag*/delarg = 8;
                }
                /*dexit*/delexit();
similarity index 100%
rename from xify/xifyfilt.c
rename to xify/xify.c
similarity index 100%
rename from xify/xify
rename to xify/xify.sh