scc

suckless C compiler
git clone git://git.suckless.org/scc
Log | Files | Refs | README | LICENSE

commit f9f434747f348c70f60f06fddab5de2e02616a8c
parent 80786a2342984eefadc4b2b1c6402dacbb57bfa8
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu,  9 Mar 2017 12:33:55 +0100

[libc] Improve Makefile system using dynamic list

Diffstat:
libc/src/Makefile | 32++++++++++++++++++++++----------
libc/src/sys/amd64-linux/system.mk | 1-
libc/src/sys/amd64-sysv-linux/Makefile | 35+++++++++++++++++++++++------------
libc/src/sys/qbe-linux/Makefile | 35+++++++++++++++++++++++------------
libc/src/sys/qbe-linux/system.mk | 1-
libc/src/sys/z80-linux/Makefile | 33+++++++++++++++++++++++++++++++++
libc/src/sys/z80-linux/syscall.lst | 0
7 files changed, 101 insertions(+), 36 deletions(-)

diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -2,7 +2,11 @@ .POSIX: include ../../config.mk -include sys/$(ARCH)-$(SYS)/system.mk + +SYSDIR = sys/$(ARCH)-$(SYS) +SYSINC = $(SYSDIR)/system.mk + +-include $(SYSINC) LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \ strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \ @@ -14,18 +18,26 @@ LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \ localeconv.o atoi.o atexit.o exit.o \ printf.o fprintf.o vfprintf.o \ realloc.o calloc.o malloc.o +LIBCSYSOBJ = $(SYSOBJ:%=$(SYSDIR)/%) +OBJ = $(LIBCOBJ) $(LIBCSYSOBJ) -OBJ = $(LIBCOBJ) $(SYSOBJ) +all: all.bootstrap +all.start: libc.a -all: libc.a +clean: clean.bootstrap +clean.start: + rm -f *.o libc.a + cd $(SYSDIR) && $(MAKE) -e clean -$(SYSOBJ): - cd sys/$(ARCH)-$(SYS) && make all +all.bootstrap clean.bootstrap: $(SYSINC) + $(MAKE) -e $(@:%.bootstrap=%.start) -libc.a: $(OBJ) - $(AR) $(ARFLAGS) $@ $? +$(SYSINC): $(SYSDIR)/Makefile $(SYSDIR)/syscall.lst + cd $(SYSDIR) && $(MAKE) -e system.mk + +libc.a: $(SYSINC) $(OBJ) + $(AR) $(ARFLAGS) $@ $(OBJ) ranlib $@ -clean: - rm -f *.o libc.a - cd sys/$(ARCH)-$(SYS) && make clean +$(LIBCSYSOBJ): + cd $(SYSDIR) && $(MAKE) -e diff --git a/libc/src/sys/amd64-linux/system.mk b/libc/src/sys/amd64-linux/system.mk @@ -1 +0,0 @@ -$(SYSOBJ) = _read.o _write.o _open.o _close.o _lseek.o _brk.o _rt_sigaction.o _getpid.o _Exit.o _kill.o _sbrk.o diff --git a/libc/src/sys/amd64-sysv-linux/Makefile b/libc/src/sys/amd64-sysv-linux/Makefile @@ -2,21 +2,32 @@ .POSIX: include ../../../../config.mk +-include system.mk +-include sysgen.mk -OBJ_GEN = _read.o _write.o _open.o _close.o _lseek.o _brk.o\ - _rt_sigaction.o _getpid.o _Exit.o _kill.o +GENASM = $(GENOBJ:.o=.s) +OBJ = -ASM_GEN = $(OBJ_GEN:.o=.s) -OBJ = $(OBJ_GEN) +all: all.bootstrap +all.start: $(SYSOBJ) -all: $(OBJ) system.mk +clean: clean.bootstrap +clean.start: + rm -f *.o $(GENASM) system.mk sysgen.mk -system.mk: Makefile - echo SYSOBJ = $(OBJ) > system.mk +all.bootstrap clean.bootstrap: system.mk sysgen.mk + $(MAKE) -e $(@:%.bootstrap=%.start) -$(ASM_GEN): syscall.lst - awk -f syscall.awk < syscall.lst +system.mk: Makefile syscall.lst + printf '%s ' 'SYSOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + $(OBJ) \ + > $@ + +sysgen.mk: syscall.lst + printf '%s ' 'GENOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + > $@ -clean: - rm -f *.o - rm -f $(ASM_GEN) +$(GENASM): syscall.lst + awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/qbe-linux/Makefile b/libc/src/sys/qbe-linux/Makefile @@ -2,21 +2,32 @@ .POSIX: include ../../../../config.mk +-include system.mk +-include sysgen.mk -OBJ_GEN = _read.o _write.o _open.o _close.o _lseek.o _brk.o\ - _rt_sigaction.o _getpid.o _Exit.o _kill.o +GENASM = $(GENOBJ:.o=.s) +OBJ = -ASM_GEN = $(OBJ_GEN:.o=.s) -OBJ = $(OBJ_GEN) +all: all.bootstrap +all.start: $(SYSOBJ) -all: $(OBJ) system.mk +clean: clean.bootstrap +clean.start: + rm -f *.o $(GENASM) system.mk sysgen.mk -system.mk: Makefile - echo SYSOBJ = $(OBJ) > system.mk +all.bootstrap clean.bootstrap: system.mk sysgen.mk + $(MAKE) -e $(@:%.bootstrap=%.start) -$(ASM_GEN): syscall.lst - awk -f syscall.awk < syscall.lst +system.mk: Makefile syscall.lst + printf '%s ' 'SYSOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + $(OBJ) \ + > $@ + +sysgen.mk: syscall.lst + printf '%s ' 'GENOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + > $@ -clean: - rm -f *.o - rm -f $(ASM_GEN) +$(GENASM): syscall.lst + awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/qbe-linux/system.mk b/libc/src/sys/qbe-linux/system.mk @@ -1 +0,0 @@ -$(SYSOBJ) = _read.o _write.o _open.o _close.o _lseek.o _brk.o _rt_sigaction.o _getpid.o _Exit.o _kill.o _sbrk.o diff --git a/libc/src/sys/z80-linux/Makefile b/libc/src/sys/z80-linux/Makefile @@ -0,0 +1,33 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../../../config.mk +-include system.mk +-include sysgen.mk + +GENASM = $(GENOBJ:.o=.s) +OBJ = + +all: all.bootstrap +all.start: $(SYSOBJ) + +clean: clean.bootstrap +clean.start: + rm -f *.o $(GENASM) system.mk sysgen.mk + +all.bootstrap clean.bootstrap: system.mk sysgen.mk + $(MAKE) -e $(@:%.bootstrap=%.start) + +system.mk: Makefile syscall.lst + printf '%s ' 'SYSOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + $(OBJ) \ + > $@ + +sysgen.mk: syscall.lst + printf '%s ' 'GENOBJ =' \ + "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ + > $@ + +$(GENASM): syscall.lst + awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/z80-linux/syscall.lst b/libc/src/sys/z80-linux/syscall.lst