shithub: scc

Download patch

ref: 7cd063ed492f851b6b4f68c981d88ed6a761b372
parent: 914b01afa8422ffa8ab9f125346502235e4d3163
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Aug 20 11:11:13 EDT 2018

[lib/c] Remove the separation between libc and libsys

This new solution simplifies everithing and makes easier to
write the driver.

diff: cannot open b/lib/c/target/script//null: file does not exist: 'b/lib/c/target/script//null' diff: cannot open a/lib/sys/abi//null: file does not exist: 'a/lib/sys/abi//null' diff: cannot open a/lib/sys/amd64-sysv-linux//null: file does not exist: 'a/lib/sys/amd64-sysv-linux//null' diff: cannot open a/lib/sys/i386-sysv-linux//null: file does not exist: 'a/lib/sys/i386-sysv-linux//null' diff: cannot open a/lib/sys/qbe-linux//null: file does not exist: 'a/lib/sys/qbe-linux//null' diff: cannot open a/lib/sys/z80-linux//null: file does not exist: 'a/lib/sys/z80-linux//null' diff: cannot open a/lib/sys//null: file does not exist: 'a/lib/sys//null'
--- a/lib/c/target/Makefile
+++ b/lib/c/target/Makefile
@@ -10,7 +10,7 @@
 #       z80-scc-none-none
 
 dep:
-	./objlst.sh
+	./script/objlst.sh
 
 all clean distclean:
 	$(FORALL)
--- a/lib/c/target/amd64-sysv-linux-elf/Makefile
+++ b/lib/c/target/amd64-sysv-linux-elf/Makefile
@@ -3,7 +3,11 @@
 PROJECTDIR = ../../../..
 
 include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
+include ../script/objlst.mk
+include syscall.mk
+include ../script/common.mk
 
 SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/amd64-sysv/
+
+dep:
+	../script/syscall.sh
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux-elf/syscall.lst
@@ -1,0 +1,11 @@
+#number	name
+0	_read
+1	_write
+2	_open
+3	_close
+3	_lseek
+12	_brk
+13	_rt_sigaction
+38	_getpid
+60	_Exit
+32	_kill
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux-elf/syscall.mk
@@ -1,0 +1,1 @@
+SYS = _read.o _write.o _open.o _close.o _lseek.o _brk.o _rt_sigaction.o _getpid.o _Exit.o _kill.o 
--- a/lib/c/target/amd64-sysv-openbsd-elf/Makefile
+++ b/lib/c/target/amd64-sysv-openbsd-elf/Makefile
@@ -3,7 +3,7 @@
 PROJECTDIR = ../../../..
 
 include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
+include ../script/objlst.mk
+include ../script/common.mk
 
 SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/amd64-sysv/
--- a/lib/c/target/common.mk
+++ /dev/null
@@ -1,9 +1,0 @@
-
-all: libc.a
-
-libc.a: $(OBJ)
-	$(AR) $(ARFLAGS) $@ $?
-	ranlib $@
-
-clean:
-	rm -f *.o *.a
--- a/lib/c/target/objlst.mk
+++ /dev/null
@@ -1,309 +1,0 @@
-
-OBJ = bsearch.o qsort.o \
-      abs.o __abs.o labs.o __labs.o llabs.o __llabs.o \
-      perror.o strerror.o \
-      tmpnam.o \
-      sprintf.o snprintf.o vsprintf.o vsnprintf.o \
-      printf.o fprintf.o vfprintf.o \
-      fgets.o gets.o fgetc.o fputc.o getchar.o putchar.o \
-      fputs.o puts.o fread.o fwrite.o \
-      getc.o putc.o __putc.o __getc.o \
-      rewind.o fseek.o ferror.o feof.o clearerr.o \
-      setbuf.o setvbuf.o \
-      fclose.o fopen.o freopen.o _fpopen.o _flsbuf.o stdio.o \
-      realloc.o calloc.o malloc.o \
-      __assert.o strcpy.o strcmp.o strlen.o strchr.o \
-      strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
-      strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \
-      memset.o memcpy.o memmove.o memcmp.o memchr.o \
-      isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
-      isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
-      isxdigit.o toupper.o tolower.o ctype.o setlocale.o \
-      localeconv.o atoi.o atol.o atoll.o atexit.o abort.o exit.o
-
-#rules
-__abs.o: ../../__abs.c
-	$(CC) $(SCC_CFLAGS) ../../__abs.c -c
-
-__assert.o: ../../__assert.c
-	$(CC) $(SCC_CFLAGS) ../../__assert.c -c
-
-__getc.o: ../../__getc.c
-	$(CC) $(SCC_CFLAGS) ../../__getc.c -c
-
-__labs.o: ../../__labs.c
-	$(CC) $(SCC_CFLAGS) ../../__labs.c -c
-
-__llabs.o: ../../__llabs.c
-	$(CC) $(SCC_CFLAGS) ../../__llabs.c -c
-
-__putc.o: ../../__putc.c
-	$(CC) $(SCC_CFLAGS) ../../__putc.c -c
-
-_flsbuf.o: ../../_flsbuf.c
-	$(CC) $(SCC_CFLAGS) ../../_flsbuf.c -c
-
-_fpopen.o: ../../_fpopen.c
-	$(CC) $(SCC_CFLAGS) ../../_fpopen.c -c
-
-abort.o: ../../abort.c
-	$(CC) $(SCC_CFLAGS) ../../abort.c -c
-
-abs.o: ../../abs.c
-	$(CC) $(SCC_CFLAGS) ../../abs.c -c
-
-atexit.o: ../../atexit.c
-	$(CC) $(SCC_CFLAGS) ../../atexit.c -c
-
-atoi.o: ../../atoi.c
-	$(CC) $(SCC_CFLAGS) ../../atoi.c -c
-
-atol.o: ../../atol.c
-	$(CC) $(SCC_CFLAGS) ../../atol.c -c
-
-atoll.o: ../../atoll.c
-	$(CC) $(SCC_CFLAGS) ../../atoll.c -c
-
-bsearch.o: ../../bsearch.c
-	$(CC) $(SCC_CFLAGS) ../../bsearch.c -c
-
-calloc.o: ../../calloc.c
-	$(CC) $(SCC_CFLAGS) ../../calloc.c -c
-
-clearerr.o: ../../clearerr.c
-	$(CC) $(SCC_CFLAGS) ../../clearerr.c -c
-
-ctype.o: ../../ctype.c
-	$(CC) $(SCC_CFLAGS) ../../ctype.c -c
-
-exit.o: ../../exit.c
-	$(CC) $(SCC_CFLAGS) ../../exit.c -c
-
-fclose.o: ../../fclose.c
-	$(CC) $(SCC_CFLAGS) ../../fclose.c -c
-
-feof.o: ../../feof.c
-	$(CC) $(SCC_CFLAGS) ../../feof.c -c
-
-ferror.o: ../../ferror.c
-	$(CC) $(SCC_CFLAGS) ../../ferror.c -c
-
-fgetc.o: ../../fgetc.c
-	$(CC) $(SCC_CFLAGS) ../../fgetc.c -c
-
-fgets.o: ../../fgets.c
-	$(CC) $(SCC_CFLAGS) ../../fgets.c -c
-
-fopen.o: ../../fopen.c
-	$(CC) $(SCC_CFLAGS) ../../fopen.c -c
-
-fprintf.o: ../../fprintf.c
-	$(CC) $(SCC_CFLAGS) ../../fprintf.c -c
-
-fputc.o: ../../fputc.c
-	$(CC) $(SCC_CFLAGS) ../../fputc.c -c
-
-fputs.o: ../../fputs.c
-	$(CC) $(SCC_CFLAGS) ../../fputs.c -c
-
-fread.o: ../../fread.c
-	$(CC) $(SCC_CFLAGS) ../../fread.c -c
-
-freopen.o: ../../freopen.c
-	$(CC) $(SCC_CFLAGS) ../../freopen.c -c
-
-fseek.o: ../../fseek.c
-	$(CC) $(SCC_CFLAGS) ../../fseek.c -c
-
-fwrite.o: ../../fwrite.c
-	$(CC) $(SCC_CFLAGS) ../../fwrite.c -c
-
-getc.o: ../../getc.c
-	$(CC) $(SCC_CFLAGS) ../../getc.c -c
-
-getchar.o: ../../getchar.c
-	$(CC) $(SCC_CFLAGS) ../../getchar.c -c
-
-gets.o: ../../gets.c
-	$(CC) $(SCC_CFLAGS) ../../gets.c -c
-
-isalnum.o: ../../isalnum.c
-	$(CC) $(SCC_CFLAGS) ../../isalnum.c -c
-
-isalpha.o: ../../isalpha.c
-	$(CC) $(SCC_CFLAGS) ../../isalpha.c -c
-
-isascii.o: ../../isascii.c
-	$(CC) $(SCC_CFLAGS) ../../isascii.c -c
-
-isblank.o: ../../isblank.c
-	$(CC) $(SCC_CFLAGS) ../../isblank.c -c
-
-iscntrl.o: ../../iscntrl.c
-	$(CC) $(SCC_CFLAGS) ../../iscntrl.c -c
-
-isdigit.o: ../../isdigit.c
-	$(CC) $(SCC_CFLAGS) ../../isdigit.c -c
-
-isgraph.o: ../../isgraph.c
-	$(CC) $(SCC_CFLAGS) ../../isgraph.c -c
-
-islower.o: ../../islower.c
-	$(CC) $(SCC_CFLAGS) ../../islower.c -c
-
-isprint.o: ../../isprint.c
-	$(CC) $(SCC_CFLAGS) ../../isprint.c -c
-
-ispunct.o: ../../ispunct.c
-	$(CC) $(SCC_CFLAGS) ../../ispunct.c -c
-
-isspace.o: ../../isspace.c
-	$(CC) $(SCC_CFLAGS) ../../isspace.c -c
-
-isupper.o: ../../isupper.c
-	$(CC) $(SCC_CFLAGS) ../../isupper.c -c
-
-isxdigit.o: ../../isxdigit.c
-	$(CC) $(SCC_CFLAGS) ../../isxdigit.c -c
-
-labs.o: ../../labs.c
-	$(CC) $(SCC_CFLAGS) ../../labs.c -c
-
-llabs.o: ../../llabs.c
-	$(CC) $(SCC_CFLAGS) ../../llabs.c -c
-
-localeconv.o: ../../localeconv.c
-	$(CC) $(SCC_CFLAGS) ../../localeconv.c -c
-
-malloc.o: ../../malloc.c
-	$(CC) $(SCC_CFLAGS) ../../malloc.c -c
-
-memchr.o: ../../memchr.c
-	$(CC) $(SCC_CFLAGS) ../../memchr.c -c
-
-memcmp.o: ../../memcmp.c
-	$(CC) $(SCC_CFLAGS) ../../memcmp.c -c
-
-memcpy.o: ../../memcpy.c
-	$(CC) $(SCC_CFLAGS) ../../memcpy.c -c
-
-memmove.o: ../../memmove.c
-	$(CC) $(SCC_CFLAGS) ../../memmove.c -c
-
-memset.o: ../../memset.c
-	$(CC) $(SCC_CFLAGS) ../../memset.c -c
-
-perror.o: ../../perror.c
-	$(CC) $(SCC_CFLAGS) ../../perror.c -c
-
-printf.o: ../../printf.c
-	$(CC) $(SCC_CFLAGS) ../../printf.c -c
-
-putc.o: ../../putc.c
-	$(CC) $(SCC_CFLAGS) ../../putc.c -c
-
-putchar.o: ../../putchar.c
-	$(CC) $(SCC_CFLAGS) ../../putchar.c -c
-
-puts.o: ../../puts.c
-	$(CC) $(SCC_CFLAGS) ../../puts.c -c
-
-qsort.o: ../../qsort.c
-	$(CC) $(SCC_CFLAGS) ../../qsort.c -c
-
-rand.o: ../../rand.c
-	$(CC) $(SCC_CFLAGS) ../../rand.c -c
-
-realloc.o: ../../realloc.c
-	$(CC) $(SCC_CFLAGS) ../../realloc.c -c
-
-rewind.o: ../../rewind.c
-	$(CC) $(SCC_CFLAGS) ../../rewind.c -c
-
-setbuf.o: ../../setbuf.c
-	$(CC) $(SCC_CFLAGS) ../../setbuf.c -c
-
-setlocale.o: ../../setlocale.c
-	$(CC) $(SCC_CFLAGS) ../../setlocale.c -c
-
-setvbuf.o: ../../setvbuf.c
-	$(CC) $(SCC_CFLAGS) ../../setvbuf.c -c
-
-snprintf.o: ../../snprintf.c
-	$(CC) $(SCC_CFLAGS) ../../snprintf.c -c
-
-sprintf.o: ../../sprintf.c
-	$(CC) $(SCC_CFLAGS) ../../sprintf.c -c
-
-stdio.o: ../../stdio.c
-	$(CC) $(SCC_CFLAGS) ../../stdio.c -c
-
-strcat.o: ../../strcat.c
-	$(CC) $(SCC_CFLAGS) ../../strcat.c -c
-
-strchr.o: ../../strchr.c
-	$(CC) $(SCC_CFLAGS) ../../strchr.c -c
-
-strcmp.o: ../../strcmp.c
-	$(CC) $(SCC_CFLAGS) ../../strcmp.c -c
-
-strcoll.o: ../../strcoll.c
-	$(CC) $(SCC_CFLAGS) ../../strcoll.c -c
-
-strcpy.o: ../../strcpy.c
-	$(CC) $(SCC_CFLAGS) ../../strcpy.c -c
-
-strcspn.o: ../../strcspn.c
-	$(CC) $(SCC_CFLAGS) ../../strcspn.c -c
-
-strerror.o: ../../strerror.c
-	$(CC) $(SCC_CFLAGS) ../../strerror.c -c
-
-strlen.o: ../../strlen.c
-	$(CC) $(SCC_CFLAGS) ../../strlen.c -c
-
-strncat.o: ../../strncat.c
-	$(CC) $(SCC_CFLAGS) ../../strncat.c -c
-
-strncmp.o: ../../strncmp.c
-	$(CC) $(SCC_CFLAGS) ../../strncmp.c -c
-
-strncpy.o: ../../strncpy.c
-	$(CC) $(SCC_CFLAGS) ../../strncpy.c -c
-
-strpbrk.o: ../../strpbrk.c
-	$(CC) $(SCC_CFLAGS) ../../strpbrk.c -c
-
-strrchr.o: ../../strrchr.c
-	$(CC) $(SCC_CFLAGS) ../../strrchr.c -c
-
-strspn.o: ../../strspn.c
-	$(CC) $(SCC_CFLAGS) ../../strspn.c -c
-
-strstr.o: ../../strstr.c
-	$(CC) $(SCC_CFLAGS) ../../strstr.c -c
-
-strtok.o: ../../strtok.c
-	$(CC) $(SCC_CFLAGS) ../../strtok.c -c
-
-strxfrm.o: ../../strxfrm.c
-	$(CC) $(SCC_CFLAGS) ../../strxfrm.c -c
-
-tmpnam.o: ../../tmpnam.c
-	$(CC) $(SCC_CFLAGS) ../../tmpnam.c -c
-
-tolower.o: ../../tolower.c
-	$(CC) $(SCC_CFLAGS) ../../tolower.c -c
-
-toupper.o: ../../toupper.c
-	$(CC) $(SCC_CFLAGS) ../../toupper.c -c
-
-vfprintf.o: ../../vfprintf.c
-	$(CC) $(SCC_CFLAGS) ../../vfprintf.c -c
-
-vsnprintf.o: ../../vsnprintf.c
-	$(CC) $(SCC_CFLAGS) ../../vsnprintf.c -c
-
-vsprintf.o: ../../vsprintf.c
-	$(CC) $(SCC_CFLAGS) ../../vsprintf.c -c
-
--- a/lib/c/target/objlst.sh
+++ /dev/null
@@ -1,20 +1,0 @@
-#!/bin/sh
-
-set -e
-
-
-(cd ..
-echo H
-echo '/^#rules/+;$c'
-
-for i in *.c
-do
-	cat <<EOF
-${i%.c}.o: ../../$i
-	\$(CC) \$(SCC_CFLAGS) ../../$i -c
-
-EOF
-done
-
-echo .
-echo w)  | ed -s objlst.mk
--- /dev/null
+++ b/lib/c/target/script/amd64-sysv.sh
@@ -1,0 +1,15 @@
+#!/bin/sh
+
+#
+# This job is very easy because app and kernel ABI are identical
+# until the 4th parameter, so we only have to set the syscall
+# number in rax
+
+awk '/^#/	{next}
+		{name=$2 ".s"
+	        printf ".global %s\n" \
+	               "%s:\n" \
+	               "\tmovq\t$%d,%%rax\n" \
+	               "\tsyscall\n" \
+	               "\tret\n", $2, $2, $1 > name
+	        close(name)}' syscall.lst
--- /dev/null
+++ b/lib/c/target/script/common.mk
@@ -1,0 +1,14 @@
+SYSASM = $(SYS:.o=.s)
+
+all: libc.a
+
+libc.a: $(OBJ) $(SYS)
+	$(AR) $(ARFLAGS) $@ $?
+	ranlib $@
+
+clean:
+	rm -f *.o *.a
+	rm -f $(SYSASM)
+
+$(SYSASM): syscall.lst
+	../script/amd64-sysv.sh
--- /dev/null
+++ b/lib/c/target/script/objlst.mk
@@ -1,0 +1,309 @@
+
+OBJ = bsearch.o qsort.o \
+      abs.o __abs.o labs.o __labs.o llabs.o __llabs.o \
+      perror.o strerror.o \
+      tmpnam.o \
+      sprintf.o snprintf.o vsprintf.o vsnprintf.o \
+      printf.o fprintf.o vfprintf.o \
+      fgets.o gets.o fgetc.o fputc.o getchar.o putchar.o \
+      fputs.o puts.o fread.o fwrite.o \
+      getc.o putc.o __putc.o __getc.o \
+      rewind.o fseek.o ferror.o feof.o clearerr.o \
+      setbuf.o setvbuf.o \
+      fclose.o fopen.o freopen.o _fpopen.o _flsbuf.o stdio.o \
+      realloc.o calloc.o malloc.o \
+      __assert.o strcpy.o strcmp.o strlen.o strchr.o \
+      strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
+      strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \
+      memset.o memcpy.o memmove.o memcmp.o memchr.o \
+      isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
+      isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
+      isxdigit.o toupper.o tolower.o ctype.o setlocale.o \
+      localeconv.o atoi.o atol.o atoll.o atexit.o abort.o exit.o
+
+#rules
+__abs.o: ../../__abs.c
+	$(CC) $(SCC_CFLAGS) ../../__abs.c -c
+
+__assert.o: ../../__assert.c
+	$(CC) $(SCC_CFLAGS) ../../__assert.c -c
+
+__getc.o: ../../__getc.c
+	$(CC) $(SCC_CFLAGS) ../../__getc.c -c
+
+__labs.o: ../../__labs.c
+	$(CC) $(SCC_CFLAGS) ../../__labs.c -c
+
+__llabs.o: ../../__llabs.c
+	$(CC) $(SCC_CFLAGS) ../../__llabs.c -c
+
+__putc.o: ../../__putc.c
+	$(CC) $(SCC_CFLAGS) ../../__putc.c -c
+
+_flsbuf.o: ../../_flsbuf.c
+	$(CC) $(SCC_CFLAGS) ../../_flsbuf.c -c
+
+_fpopen.o: ../../_fpopen.c
+	$(CC) $(SCC_CFLAGS) ../../_fpopen.c -c
+
+abort.o: ../../abort.c
+	$(CC) $(SCC_CFLAGS) ../../abort.c -c
+
+abs.o: ../../abs.c
+	$(CC) $(SCC_CFLAGS) ../../abs.c -c
+
+atexit.o: ../../atexit.c
+	$(CC) $(SCC_CFLAGS) ../../atexit.c -c
+
+atoi.o: ../../atoi.c
+	$(CC) $(SCC_CFLAGS) ../../atoi.c -c
+
+atol.o: ../../atol.c
+	$(CC) $(SCC_CFLAGS) ../../atol.c -c
+
+atoll.o: ../../atoll.c
+	$(CC) $(SCC_CFLAGS) ../../atoll.c -c
+
+bsearch.o: ../../bsearch.c
+	$(CC) $(SCC_CFLAGS) ../../bsearch.c -c
+
+calloc.o: ../../calloc.c
+	$(CC) $(SCC_CFLAGS) ../../calloc.c -c
+
+clearerr.o: ../../clearerr.c
+	$(CC) $(SCC_CFLAGS) ../../clearerr.c -c
+
+ctype.o: ../../ctype.c
+	$(CC) $(SCC_CFLAGS) ../../ctype.c -c
+
+exit.o: ../../exit.c
+	$(CC) $(SCC_CFLAGS) ../../exit.c -c
+
+fclose.o: ../../fclose.c
+	$(CC) $(SCC_CFLAGS) ../../fclose.c -c
+
+feof.o: ../../feof.c
+	$(CC) $(SCC_CFLAGS) ../../feof.c -c
+
+ferror.o: ../../ferror.c
+	$(CC) $(SCC_CFLAGS) ../../ferror.c -c
+
+fgetc.o: ../../fgetc.c
+	$(CC) $(SCC_CFLAGS) ../../fgetc.c -c
+
+fgets.o: ../../fgets.c
+	$(CC) $(SCC_CFLAGS) ../../fgets.c -c
+
+fopen.o: ../../fopen.c
+	$(CC) $(SCC_CFLAGS) ../../fopen.c -c
+
+fprintf.o: ../../fprintf.c
+	$(CC) $(SCC_CFLAGS) ../../fprintf.c -c
+
+fputc.o: ../../fputc.c
+	$(CC) $(SCC_CFLAGS) ../../fputc.c -c
+
+fputs.o: ../../fputs.c
+	$(CC) $(SCC_CFLAGS) ../../fputs.c -c
+
+fread.o: ../../fread.c
+	$(CC) $(SCC_CFLAGS) ../../fread.c -c
+
+freopen.o: ../../freopen.c
+	$(CC) $(SCC_CFLAGS) ../../freopen.c -c
+
+fseek.o: ../../fseek.c
+	$(CC) $(SCC_CFLAGS) ../../fseek.c -c
+
+fwrite.o: ../../fwrite.c
+	$(CC) $(SCC_CFLAGS) ../../fwrite.c -c
+
+getc.o: ../../getc.c
+	$(CC) $(SCC_CFLAGS) ../../getc.c -c
+
+getchar.o: ../../getchar.c
+	$(CC) $(SCC_CFLAGS) ../../getchar.c -c
+
+gets.o: ../../gets.c
+	$(CC) $(SCC_CFLAGS) ../../gets.c -c
+
+isalnum.o: ../../isalnum.c
+	$(CC) $(SCC_CFLAGS) ../../isalnum.c -c
+
+isalpha.o: ../../isalpha.c
+	$(CC) $(SCC_CFLAGS) ../../isalpha.c -c
+
+isascii.o: ../../isascii.c
+	$(CC) $(SCC_CFLAGS) ../../isascii.c -c
+
+isblank.o: ../../isblank.c
+	$(CC) $(SCC_CFLAGS) ../../isblank.c -c
+
+iscntrl.o: ../../iscntrl.c
+	$(CC) $(SCC_CFLAGS) ../../iscntrl.c -c
+
+isdigit.o: ../../isdigit.c
+	$(CC) $(SCC_CFLAGS) ../../isdigit.c -c
+
+isgraph.o: ../../isgraph.c
+	$(CC) $(SCC_CFLAGS) ../../isgraph.c -c
+
+islower.o: ../../islower.c
+	$(CC) $(SCC_CFLAGS) ../../islower.c -c
+
+isprint.o: ../../isprint.c
+	$(CC) $(SCC_CFLAGS) ../../isprint.c -c
+
+ispunct.o: ../../ispunct.c
+	$(CC) $(SCC_CFLAGS) ../../ispunct.c -c
+
+isspace.o: ../../isspace.c
+	$(CC) $(SCC_CFLAGS) ../../isspace.c -c
+
+isupper.o: ../../isupper.c
+	$(CC) $(SCC_CFLAGS) ../../isupper.c -c
+
+isxdigit.o: ../../isxdigit.c
+	$(CC) $(SCC_CFLAGS) ../../isxdigit.c -c
+
+labs.o: ../../labs.c
+	$(CC) $(SCC_CFLAGS) ../../labs.c -c
+
+llabs.o: ../../llabs.c
+	$(CC) $(SCC_CFLAGS) ../../llabs.c -c
+
+localeconv.o: ../../localeconv.c
+	$(CC) $(SCC_CFLAGS) ../../localeconv.c -c
+
+malloc.o: ../../malloc.c
+	$(CC) $(SCC_CFLAGS) ../../malloc.c -c
+
+memchr.o: ../../memchr.c
+	$(CC) $(SCC_CFLAGS) ../../memchr.c -c
+
+memcmp.o: ../../memcmp.c
+	$(CC) $(SCC_CFLAGS) ../../memcmp.c -c
+
+memcpy.o: ../../memcpy.c
+	$(CC) $(SCC_CFLAGS) ../../memcpy.c -c
+
+memmove.o: ../../memmove.c
+	$(CC) $(SCC_CFLAGS) ../../memmove.c -c
+
+memset.o: ../../memset.c
+	$(CC) $(SCC_CFLAGS) ../../memset.c -c
+
+perror.o: ../../perror.c
+	$(CC) $(SCC_CFLAGS) ../../perror.c -c
+
+printf.o: ../../printf.c
+	$(CC) $(SCC_CFLAGS) ../../printf.c -c
+
+putc.o: ../../putc.c
+	$(CC) $(SCC_CFLAGS) ../../putc.c -c
+
+putchar.o: ../../putchar.c
+	$(CC) $(SCC_CFLAGS) ../../putchar.c -c
+
+puts.o: ../../puts.c
+	$(CC) $(SCC_CFLAGS) ../../puts.c -c
+
+qsort.o: ../../qsort.c
+	$(CC) $(SCC_CFLAGS) ../../qsort.c -c
+
+rand.o: ../../rand.c
+	$(CC) $(SCC_CFLAGS) ../../rand.c -c
+
+realloc.o: ../../realloc.c
+	$(CC) $(SCC_CFLAGS) ../../realloc.c -c
+
+rewind.o: ../../rewind.c
+	$(CC) $(SCC_CFLAGS) ../../rewind.c -c
+
+setbuf.o: ../../setbuf.c
+	$(CC) $(SCC_CFLAGS) ../../setbuf.c -c
+
+setlocale.o: ../../setlocale.c
+	$(CC) $(SCC_CFLAGS) ../../setlocale.c -c
+
+setvbuf.o: ../../setvbuf.c
+	$(CC) $(SCC_CFLAGS) ../../setvbuf.c -c
+
+snprintf.o: ../../snprintf.c
+	$(CC) $(SCC_CFLAGS) ../../snprintf.c -c
+
+sprintf.o: ../../sprintf.c
+	$(CC) $(SCC_CFLAGS) ../../sprintf.c -c
+
+stdio.o: ../../stdio.c
+	$(CC) $(SCC_CFLAGS) ../../stdio.c -c
+
+strcat.o: ../../strcat.c
+	$(CC) $(SCC_CFLAGS) ../../strcat.c -c
+
+strchr.o: ../../strchr.c
+	$(CC) $(SCC_CFLAGS) ../../strchr.c -c
+
+strcmp.o: ../../strcmp.c
+	$(CC) $(SCC_CFLAGS) ../../strcmp.c -c
+
+strcoll.o: ../../strcoll.c
+	$(CC) $(SCC_CFLAGS) ../../strcoll.c -c
+
+strcpy.o: ../../strcpy.c
+	$(CC) $(SCC_CFLAGS) ../../strcpy.c -c
+
+strcspn.o: ../../strcspn.c
+	$(CC) $(SCC_CFLAGS) ../../strcspn.c -c
+
+strerror.o: ../../strerror.c
+	$(CC) $(SCC_CFLAGS) ../../strerror.c -c
+
+strlen.o: ../../strlen.c
+	$(CC) $(SCC_CFLAGS) ../../strlen.c -c
+
+strncat.o: ../../strncat.c
+	$(CC) $(SCC_CFLAGS) ../../strncat.c -c
+
+strncmp.o: ../../strncmp.c
+	$(CC) $(SCC_CFLAGS) ../../strncmp.c -c
+
+strncpy.o: ../../strncpy.c
+	$(CC) $(SCC_CFLAGS) ../../strncpy.c -c
+
+strpbrk.o: ../../strpbrk.c
+	$(CC) $(SCC_CFLAGS) ../../strpbrk.c -c
+
+strrchr.o: ../../strrchr.c
+	$(CC) $(SCC_CFLAGS) ../../strrchr.c -c
+
+strspn.o: ../../strspn.c
+	$(CC) $(SCC_CFLAGS) ../../strspn.c -c
+
+strstr.o: ../../strstr.c
+	$(CC) $(SCC_CFLAGS) ../../strstr.c -c
+
+strtok.o: ../../strtok.c
+	$(CC) $(SCC_CFLAGS) ../../strtok.c -c
+
+strxfrm.o: ../../strxfrm.c
+	$(CC) $(SCC_CFLAGS) ../../strxfrm.c -c
+
+tmpnam.o: ../../tmpnam.c
+	$(CC) $(SCC_CFLAGS) ../../tmpnam.c -c
+
+tolower.o: ../../tolower.c
+	$(CC) $(SCC_CFLAGS) ../../tolower.c -c
+
+toupper.o: ../../toupper.c
+	$(CC) $(SCC_CFLAGS) ../../toupper.c -c
+
+vfprintf.o: ../../vfprintf.c
+	$(CC) $(SCC_CFLAGS) ../../vfprintf.c -c
+
+vsnprintf.o: ../../vsnprintf.c
+	$(CC) $(SCC_CFLAGS) ../../vsnprintf.c -c
+
+vsprintf.o: ../../vsprintf.c
+	$(CC) $(SCC_CFLAGS) ../../vsprintf.c -c
+
--- /dev/null
+++ b/lib/c/target/script/objlst.sh
@@ -1,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+
+(cd ..
+echo H
+echo '/^#rules/+;$c'
+
+for i in *.c
+do
+	cat <<EOF
+${i%.c}.o: ../../$i
+	\$(CC) \$(SCC_CFLAGS) ../../$i -c
+
+EOF
+done
+
+echo .
+echo w)  | ed -s objlst.mk
--- /dev/null
+++ b/lib/c/target/script/syscall.sh
@@ -1,0 +1,8 @@
+#!/bin/sh
+
+(echo '/SYS/c'
+ awk 'BEGIN  {printf "SYS = "}
+      ! /^#/ {printf "%s.o ", $2}
+      END    {print ""}' syscall.lst
+ echo .
+ echo w) | ed -s syscall.mk
--- a/lib/sys/Makefile
+++ /dev/null
@@ -1,14 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../..
-
-include $(PROJECTDIR)/rules.mk
-
-all clean distclean:
-	+@pwd=$$PWD ;\
-	for i in $(SYSS); \
-	do \
-		cd $$i; \
-		$(MAKE) -e SYS=$i $@ ;\
-		cd $$pwd; \
-	done
--- a/lib/sys/abi/amd64-sysv.sh
+++ /dev/null
@@ -1,15 +1,0 @@
-#!/bin/sh
-
-#
-# This job is very easy because app and kernel ABI are identical
-# until the 4th parameter, so we only have to set the syscall
-# number in rax
-
-awk '/^#/	{next}
-		{name=$2 ".s"
-	        printf ".global %s\n" \
-	               "%s:\n" \
-	               "\tmovq\t$%d,%%rax\n" \
-	               "\tsyscall\n" \
-	               "\tret\n", $2, $2, $1 > name
-	        close(name)}' syscall.lst
--- a/lib/sys/amd64-sysv-linux/Makefile
+++ /dev/null
@@ -1,4 +1,0 @@
-.POSIX:
-
-include ../common.mk
-ABI = amd64-sysv
--- a/lib/sys/amd64-sysv-linux/syscall.lst
+++ /dev/null
@@ -1,11 +1,0 @@
-#number	name
-0	_read
-1	_write
-2	_open
-3	_close
-3	_lseek
-12	_brk
-13	_rt_sigaction
-38	_getpid
-60	_Exit
-32	_kill
--- a/lib/sys/common.mk
+++ /dev/null
@@ -1,14 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../..
-
-include $(PROJECTDIR)/rules.mk
-
-all clean distclean: system.mk
-	+$(MAKE) ABI=$(ABI) -f ../libsys.mk $@
-
-system.mk: syscall.lst
-	rm -f $@; trap "rm -f $$$$.mk" 0 2 3; \
-	awk 'BEGIN{printf "OBJ = "} \
-	     ! /^#/ {printf "%s.o ", $$2}' syscall.lst > $$$$.mk && \
-	mv $$$$.mk $@
--- a/lib/sys/i386-sysv-linux/Makefile
+++ /dev/null
@@ -1,3 +1,0 @@
-.POSIX:
-
-include ../Makefile.sys
--- a/lib/sys/libsys.mk
+++ /dev/null
@@ -1,25 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../..
-
-include $(PROJECTDIR)/rules.mk
-include system.mk
-
-ASM = $(OBJ:.o=.s)
-
-all: libsys.a
-
-libsys.a: $(OBJ)
-	$(AR) $(ARFLAGS) $@ $?
-	ranlib $@
-
-$(ASM): syscall.lst
-	../abi/$(ABI).sh
-
-clean:
-	rm -f $(ASM)
-	rm -f $(OBJ)
-	rm -f libsys.a
-
-distclean: clean
-	rm -f system.mk
--- a/lib/sys/qbe-linux/Makefile
+++ /dev/null
@@ -1,4 +1,0 @@
-.POSIX:
-
-include ../common.mk
-ABI=amd64-sysv
--- a/lib/sys/qbe-linux/syscall.lst
+++ /dev/null
@@ -1,11 +1,0 @@
-#number	name
-0	_read
-1	_write
-2	_open
-3	_close
-3	_lseek
-12	_brk
-13	_rt_sigaction
-38	_getpid
-60	_Exit
-32	_kill
--- a/lib/sys/z80-linux/Makefile
+++ /dev/null
@@ -1,3 +1,0 @@
-.POSIX:
-
-include ../Makefile.sys