From f71dbb43a3f09b3409683e4fca4f9ec60774914d Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Mon, 14 Sep 2015 21:58:04 -0500 Subject: better accounting of build dependencies --- Makefile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 925dbc2..061914e 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ INSTALL = ./tools/install.sh -include config.mak BOOTSRCS = $(sort $(wildcard boot/*.c)) +BOOTOBJS = $(patsubst %.c,%.o,$(BOOTSRCS)) BOOTELFS = $(patsubst %.c,%.elf,$(BOOTSRCS)) BOOTBINS = $(patsubst boot/%.c,share/boot/%,$(BOOTSRCS)) @@ -24,14 +25,18 @@ DATA = $(sort $(wildcard src/*.bin)) OBJS = $(SRCS:.c=.o) $(DATA:.bin=.o) BINS = bin/saturn-mkboot bin/saturn-mkiso +DEPENDS = $(SRCS:.c=.d) $(BOOTSRCS:.c=.d) + .PHONY: all clean install install-bins install-data all: $(BINS) $(BOOTBINS) +-include $(DEPENDS) + install: install-bins install-data clean: - rm -f $(BINS) $(OBJS) $(BOOTBINS) $(BOOTELFS) + rm -f $(BINS) $(OBJS) $(BOOTBINS) $(BOOTELFS) $(BOOTOBJS) $(DEPENDS) bin/saturn-mkboot: src/securitycode.o src/symbols.o @@ -41,16 +46,19 @@ bin/%: src/%.o share/boot/%: boot/%.elf $(SATURN_OBJCOPY) -O binary $< $@ -%.elf: %.c boot/ldscript +%.elf: %.o boot/ldscript $(SATURN_CC) $(SATURN_CFLAGS) $(SATURN_LDFLAGS) -T boot/ldscript $< -o $@ %.c: %.bin tools/bin2c $< > $@ -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ +boot/%.o: boot/%.c + $(SATURN_CC) $(SATURN_CFLAGS) -c $< -o $@ + $(SATURN_CC) -MM $(SATURN_CFLAGS) $< -MT $@ > boot/$*.d -src/saturn-mkboot.o: src/paths.h +src/%.o: src/%.c + $(CC) $(CFLAGS) -c $< -o $@ + $(CC) -MM $(CFLAGS) $< -MT $@ > src/$*.d src/paths.h: config.mak echo "#define DATA_PATH \"$(sharedir)\"" > $@ @@ -64,3 +72,5 @@ $(DESTDIR)$(sharedir)/%: share/% install-bins: $(BINS:bin/%=$(DESTDIR)$(bindir)/%) install-data: $(BOOTBINS:share/%=$(DESTDIR)$(sharedir)/%) + +.PRECIOUS: src/%.o boot/%.o %.elf %.c -- cgit v1.2.3