shithub: scc

Download patch

ref: 6c792854e115de8998dcf5d8beca5cf1bb6b6e4d
parent: fc1c8d49847235fe32bc3541d6a489c45462fffd
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Aug 20 03:16:13 EDT 2018

[lib/c] Fix build system

--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -1,4 +1,8 @@
 .POSIX:
 
+PROJECTDIR = ../..
+
+DIRS = target
+
 all dep clean distclean:
-	+cd target && $(MAKE) $@
+	$(FORALL)
--- a/lib/c/target/Makefile
+++ b/lib/c/target/Makefile
@@ -4,9 +4,13 @@
 include $(PROJECTDIR)/rules.mk
 
 DIRS = amd64-sysv-linux-elf \
-       amd64-sysv-openbsd-elf \
-       i386-sysv-linux-elf \
-       z80-scc-none-none
+       amd64-sysv-openbsd-elf
 
-all dep clean distclean:
+#       i386-sysv-linux-elf \
+#       z80-scc-none-none
+
+dep:
+	./objlst.sh
+
+all clean distclean:
 	$(FORALL)
--- a/lib/c/target/amd64-sysv-linux-elf/Makefile
+++ b/lib/c/target/amd64-sysv-linux-elf/Makefile
@@ -6,4 +6,4 @@
 include ../objlst.mk
 include ../common.mk
 
-SCC_CFLAGS = -I../../include -I../../include/bits/amd64-sysv/
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/amd64-sysv/
--- a/lib/c/target/amd64-sysv-linux-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
-	cat <<EOF
-$i: ../../${i%.o}.c
-	\$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- a/lib/c/target/amd64-sysv-openbsd-elf/Makefile
+++ b/lib/c/target/amd64-sysv-openbsd-elf/Makefile
@@ -5,3 +5,5 @@
 include $(PROJECTDIR)/rules.mk
 include ../objlst.mk
 include ../common.mk
+
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/amd64-sysv/
--- a/lib/c/target/amd64-sysv-openbsd-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
-	cat <<EOF
-$i: ../../${i%.o}.c
-	\$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- a/lib/c/target/common.mk
+++ b/lib/c/target/common.mk
@@ -5,11 +5,5 @@
 	$(AR) $(ARFLAGS) $@ $?
 	ranlib $@
 
-dep:
-	gendep.sh $(OBJ)
-
 clean:
-	rm -f *.o
-
-distclean: clean
-	rm -f makefile
+	rm -f *.o *.a
--- a/lib/c/target/i386-sysv-linux-elf/Makefile
+++ b/lib/c/target/i386-sysv-linux-elf/Makefile
@@ -5,3 +5,5 @@
 include $(PROJECTDIR)/rules.mk
 include ../objlst.mk
 include ../common.mk
+
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/i386-sysv/
--- a/lib/c/target/i386-sysv-linux-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
-	cat <<EOF
-$i: ../../${i%.o}.c
-	\$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- a/lib/c/target/objlst.mk
+++ b/lib/c/target/objlst.mk
@@ -20,3 +20,290 @@
       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/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
--- a/lib/c/target/z80-scc-none-none/Makefile
+++ b/lib/c/target/z80-scc-none-none/Makefile
@@ -5,3 +5,5 @@
 include $(PROJECTDIR)/rules.mk
 include ../objlst.mk
 include ../common.mk
+
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/z80-none/
--- a/lib/c/target/z80-scc-none-none/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
-	cat <<EOF
-$i: ../../${i%.o}.c
-	\$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile