scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 539711e6996064f0c0f82f9d0d059bb3ef3fba26
parent 965f99f62dacaa76319aa06eed1540fe5c97f4d7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 16 Jan 2019 18:31:28 +0000

[libc] Don't rebuild the library always

Diffstat:
Mscripts/mklib | 4++--
Msrc/libc/.gitignore | 2+-
Msrc/libc/Makefile | 14+++++---------
Asrc/libc/Makefile.libc | 12++++++++++++
Asrc/libc/mklst | 9+++++++++
5 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/scripts/mklib b/scripts/mklib @@ -35,9 +35,9 @@ lib=${out-a.out} if ! test -f $lib then - ${AR:-ar} -qv $lib $(lorder $@ | tsort) + ${AR:-ar} $ARFLAGS -qv $lib $(lorder $@ | tsort) else - ${AR:-ar} -ruv $lib $(lorder $@ | tsort) + ${AR:-ar} $ARFLAGS -ruv $lib $(lorder $@ | tsort) fi ${RL:-ranlib} $RLFLAGS $lib diff --git a/src/libc/.gitignore b/src/libc/.gitignore @@ -1 +1 @@ -objlst +objlst.mk diff --git a/src/libc/Makefile b/src/libc/Makefile @@ -3,7 +3,6 @@ PROJECTDIR =../.. include $(PROJECTDIR)/scripts/rules.mk include rules.mk -TARGET = $(LIBCDIR)/libc.a DIRS = arch\ assert\ ctype\ @@ -13,18 +12,15 @@ DIRS = arch\ string\ time\ -all: $(DIRS) - +@$(MAKE) $(TARGET) +all: $(DIRS) objlst.mk + +@$(MAKE) -f Makefile.libc $(DIRS): FORCE +@cd $@ && $(MAKE) -objlst: - find . -name '*.o' > $@ - -$(TARGET): objlst FORCE - mklib -o $@ `cat objlst` +objlst.mk: FORCE + mklst $@ clean: $(FORALL) - rm -f objlst + rm -f objlst.mk diff --git a/src/libc/Makefile.libc b/src/libc/Makefile.libc @@ -0,0 +1,12 @@ +.POSIX: +PROJECTDIR =../.. +include $(PROJECTDIR)/scripts/rules.mk +include rules.mk +include objlst.mk + +TARGET = $(LIBDIR)/libc.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + mklib -o $@ $? diff --git a/src/libc/mklst b/src/libc/mklst @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +rm -f $1 +trap 'r=$?;rm -f $$.tmp;exit $r' HUP EXIT QUIT TERM + +(echo OBJS=\\ + find . -name '*.o' | sed 's/$/\\/') > $$.tmp && mv $$.tmp $1