software: dependencies the Werner way

This commit is contained in:
Sebastien Bourdeauducq 2012-02-03 12:25:55 +01:00
parent 1a4a6eb445
commit 1ad44b6571
2 changed files with 20 additions and 5 deletions

View File

@ -43,3 +43,15 @@ CFLAGS = -O9 -Wall -Wstrict-prototypes -Wold-style-definition -Wshadow \
-msign-extend-enabled -fno-builtin -fsigned-char \ -msign-extend-enabled -fno-builtin -fsigned-char \
-fsingle-precision-constant $(INCLUDES) -fsingle-precision-constant $(INCLUDES)
LDFLAGS = -nostdlib -nodefaultlibs LDFLAGS = -nostdlib -nodefaultlibs
# compile and generate dependencies, based on
# http://scottmcpeak.com/autodepend/autodepend.html
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
@$(CC_normal) -MM $(CFLAGS) $*.c > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp

View File

@ -3,6 +3,9 @@ include $(MMDIR)/software/include.mak
OBJECTS=divsi3.o libc.o console.o system.o board.o uart.o softfloat.o softfloat-glue.o vsnprintf.o atof.o OBJECTS=divsi3.o libc.o console.o system.o board.o uart.o softfloat.o softfloat-glue.o vsnprintf.o atof.o
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
all: libbase.a all: libbase.a
libbase.a: $(OBJECTS) libbase.a: $(OBJECTS)
@ -12,4 +15,4 @@ libbase.a: $(OBJECTS)
.PHONY: clean .PHONY: clean
clean: clean:
rm -f *.o libbase.a .*~ *~ Makefile.bak rm -f $(OBJECTS) $(OBJECTS:.o=.d) libbase.a .*~ *~ Makefile.bak