summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2015-09-14 21:58:04 -0500
committerBobby Bingham <koorogi@koorogi.info>2015-09-15 22:43:33 -0500
commitf71dbb43a3f09b3409683e4fca4f9ec60774914d (patch)
tree0a56bb1e78753796eb35183a48dd189216223d15 /Makefile
parentba2468c582934a97445f78bbbbb652386c642439 (diff)
better accounting of build dependencies
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 15 insertions, 5 deletions
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