scc

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

commit fb902b31fa5a8661b34750acd22c634ada216990
parent 7269bad586839a83c2365821df22c6181934ba72
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 12 Mar 2018 16:28:35 +0100

[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.

Diffstat:
Amkdep.sh | 11+++++++++++
Mnm/Makefile | 24++++++++++++++++--------
2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/mkdep.sh b/mkdep.sh @@ -0,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 diff --git a/nm/Makefile b/nm/Makefile @@ -8,14 +8,8 @@ include $(LIBDIR)/libdep.mk OBJ = main.o coff32.o formats.o all: 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 + mkdir -p $(PROJECTDIR)/rootdir/bin + cp nm $(PROJECTDIR)/rootdir/bin/nm nm: $(OBJ) $(LIBDIR)/libscc.a $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ @@ -24,7 +18,21 @@ $(LIBDIR)/libscc.a: $(LIB-OBJ) +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