shithub: scc

Download patch

ref: 5ff88bbbdc2dfa981b970e96fed3244dcfd87310
parent: f2e04e5f2f85f9dda6d813a9a47a95995de1e5aa
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Jan 16 13:31:28 EST 2019

[libc] Don't rebuild the library always

--- a/scripts/mklib
+++ b/scripts/mklib
@@ -35,9 +35,9 @@
 
 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
--- a/src/libc/.gitignore
+++ b/src/libc/.gitignore
@@ -1,1 +1,1 @@
-objlst
+objlst.mk
--- a/src/libc/Makefile
+++ b/src/libc/Makefile
@@ -3,7 +3,6 @@
 include $(PROJECTDIR)/scripts/rules.mk
 include rules.mk
 
-TARGET = $(LIBCDIR)/libc.a
 DIRS = arch\
        assert\
        ctype\
@@ -13,18 +12,15 @@
        string\
        time\
 
-all: $(DIRS)
-	+@$(MAKE) $(TARGET)
+all: $(DIRS) objlst.mk
+	+@$(MAKE) -f Makefile.libc
 
 $(DIRS): FORCE
 	+@cd $@ && $(MAKE)
 
-objlst:
-	find . -name '*.o' > $@
+objlst.mk: FORCE
+	mklst $@
 
-$(TARGET): objlst FORCE
-	mklib -o $@ `cat objlst`
-
 clean:
 	$(FORALL)
-	rm -f objlst
+	rm -f objlst.mk
--- /dev/null
+++ b/src/libc/Makefile.libc
@@ -1,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 $@ $?
--- /dev/null
+++ b/src/libc/mklst
@@ -1,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