shithub: scc

Download patch

ref: 9503ac891d1ea5513193c0eb0f857f876eb793d2
parent: b9c46d54a5af0105df3edf2b858459b71c2283bf
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 12 12:28:35 EDT 2018

[nm] Improve Makefile

This patch introduces mkdep.sh script which can be used
iin other Makefiles to update the inclusion dependencies.
In our project is so easy because we don't have recursive
inclusion and we always use " for our internal headers.
In the few cases where we use <> then we have to set them
manually.

--- /dev/null
+++ b/mkdep.sh
@@ -1,0 +1,11 @@
+#!/bin/sh
+
+set -e
+trap "rm -f $$.tmp" 0 2 3
+
+(sed '/^#deps/q' Makefile
+for i in *.c
+do
+	sed -n '/#include "/ s/#include "\(.*\)"/'$i': \1/p' $i
+done |
+sort) > $$.tmp && mv $$.tmp Makefile
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -8,15 +8,9 @@
 OBJ       = main.o coff32.o formats.o
 
 all: nm
+	mkdir -p $(PROJECTDIR)/rootdir/bin
+	cp nm $(PROJECTDIR)/rootdir/bin/nm
 
-main.o: $(INCDIR)/scc.h $(INCDIR)/ar.h $(INCDIR)/arg.h nm.h
-coff32.o: nm.h
-coff32.o: ../inc/coff32/filehdr.h
-coff32.o: ../inc/coff32/scnhdr.h
-coff32.o: ../inc/coff32/syms.h
-coff32.o: ../inc/scc.h
-formats.o: nm.h
-
 nm: $(OBJ) $(LIBDIR)/libscc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
 
@@ -24,7 +18,21 @@
 	+cd $(LIBDIR) && $(MAKE)
 
 dep:
+	$(PROJECTDIR)/mkdep.sh
+
 clean:
 	rm -f nm *.o
 
 distclean: clean
+
+#deps
+coff32.c: ../inc/coff32/filehdr.h
+coff32.c: ../inc/coff32/scnhdr.h
+coff32.c: ../inc/coff32/syms.h
+coff32.c: ../inc/scc.h
+coff32.c: nm.h
+formats.c: nm.h
+main.c: ../inc/arg.h
+main.c: ../inc/ar.h
+main.c: ../inc/scc.h
+main.c: nm.h