Split build rule in two parts : linking and binary image creation.
authorNathael Pajani <nathael.pajani@ed3l.fr>
Mon, 28 Jul 2014 08:56:15 +0000 (10:56 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:04 +0000 (17:03 +0100)
Makefile

index ad75333..872c5c6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ LINKOPTS = -static -nostartfiles -Wl,--gc-sections -Wl,--build-id=none \
 
 
 .PHONY: all
-all: $(NAME)
+all: $(NAME).bin
 
 prog: CFLAGS += -DEEPROM_WRITE
 prog: clean all
@@ -26,13 +26,15 @@ OBJDIR = objs
 SRC = $(shell find . -name \*.c)
 OBJS = ${SRC:%.c=${OBJDIR}/%.o}
 
+$(NAME).bin: $(NAME)
+       @echo "Creating image : \e[32m$@\e[37m"
+       @$(CROSS_COMPILE)objcopy -R .stack -R .bss -O binary $^ $@
+       @ls -l $@
+       @echo Done.
+
 $(NAME): $(OBJS)
        @echo "Linking ..."
        @$(CC) $(CFLAGS) $(LINKOPTS) $(OBJS) -o $@ -I$(INCLUDES)
-       @echo "Creating image : \e[32m$@.bin\e[37m"
-       @$(CROSS_COMPILE)objcopy -R .stack -R .bss -O binary $@ $@.bin
-       @ls -l $@.bin
-       @echo Done.
 
 ${OBJDIR}/%.o: %.c
        @mkdir -p $(dir $@)