Makefile: refine image dependency
This commit is contained in:
parent
6f2c345320
commit
c3ffbc97c3
6 changed files with 17 additions and 16 deletions
15
Makefile
15
Makefile
|
@ -123,14 +123,19 @@ $(LIBS): %:
|
|||
@$(MAKE) -s -C $(AM_HOME)/$* archive
|
||||
|
||||
### Rule (link): objects (`*.o`) and libraries (`*.a`) -> `IMAGE.elf`, the final ELF binary to be packed into image (ld)
|
||||
$(IMAGE).elf: $(OBJS) $(LIBS)
|
||||
$(IMAGE).elf: $(LINKAGE)
|
||||
@echo \# Creating image [$(ARCH)]
|
||||
@echo + LD "->" $(IMAGE_REL).elf
|
||||
@$(LD) $(LDFLAGS) -o $(IMAGE).elf --start-group $(LINKAGE) --end-group
|
||||
ifneq ($(filter $(ARCH),native),)
|
||||
$(CXX) -o $@ -Wl,--whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS_CXX)
|
||||
else
|
||||
@$(LD) $(LDFLAGS) -o $@ --start-group $^ --end-group
|
||||
endif
|
||||
|
||||
### Rule (archive): objects (`*.o`) -> `ARCHIVE.a` (ar)
|
||||
$(ARCHIVE): $(OBJS)
|
||||
@echo + AR "->" $(shell realpath $@ --relative-to .)
|
||||
@$(AR) rcs $(ARCHIVE) $(OBJS)
|
||||
@$(AR) rcs $@ $^
|
||||
|
||||
### Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
|
||||
-include $(addprefix $(DST_DIR)/, $(addsuffix .d, $(basename $(SRCS))))
|
||||
|
@ -140,8 +145,8 @@ $(ARCHIVE): $(OBJS)
|
|||
### Build order control
|
||||
image: image-dep
|
||||
archive: $(ARCHIVE)
|
||||
image-dep: $(OBJS) $(LIBS)
|
||||
@echo \# Creating image [$(ARCH)]
|
||||
image-dep: $(LIBS) $(IMAGE).elf
|
||||
.NOTPARALLEL: image-dep
|
||||
.PHONY: image image-dep archive run $(LIBS)
|
||||
|
||||
### Clean a single project (remove `build/`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue