modified to generate individual dependencies for each target

This commit is contained in:
Markus Fröschle
2013-12-19 17:28:42 +00:00
parent 72c7b9a963
commit 87e594a928

View File

@@ -104,6 +104,7 @@ ASRCS= \
illegal_instruction.S \ illegal_instruction.S \
xhdi_vec.S xhdi_vec.S
SRCS=$(ASRCS) $(CSRCS)
COBJS=$(patsubst %.c,%.o,$(CSRCS)) COBJS=$(patsubst %.c,%.o,$(CSRCS))
AOBJS=$(patsubst %.S,%.o,$(ASRCS)) AOBJS=$(patsubst %.S,%.o,$(ASRCS))
@@ -122,9 +123,8 @@ lib: $(LIBS)
.PHONY: clean .PHONY: clean
clean: clean:
for d in $(TRGTDIRS);\ for d in $(TRGTDIRS);\
do rm -f $$d/*.map $$d/*.s19 $$d/*.elf $$d/*.lk $$d/*.a $$d/objs/* ;\ do rm -f $$d/*.map $$d/*.s19 $$d/*.elf $$d/*.lk $$d/*.a $$d/objs/* $$d/depend;\
done done
rm -f depend
rm -f tags rm -f tags
@@ -153,6 +153,23 @@ $(1)/objs/%.o:%.S
endef endef
$(foreach DIR,$(TRGTDIRS),$(eval $(call CC_TEMPLATE,$(DIR)))) $(foreach DIR,$(TRGTDIRS),$(eval $(call CC_TEMPLATE,$(DIR))))
# rules for depend
define DEP_TEMPLATE
ifneq (clean,$(MAKECMDGOALS))
-include $(1)/depend
endif
ifeq (firebee,$(1))
MACHINE=MACHINE_FIREBEE
else
MACHINE=MACHINE_M5484LITE
endif
$(1)/depend:$(SRCS)
$(CC) $$(CFLAGS) -D$$(MACHINE) $(INCLUDE) -M $$^ | sed -e "s#^\(.*\).o:#$$d/objs/\1.o:#" > $$@
endef
$(foreach DIR,$(TRGTDIRS),$(eval $(call DEP_TEMPLATE,$(DIR))))
# #
# generate pattern rules for libraries # generate pattern rules for libraries
# #
@@ -204,12 +221,6 @@ endef
$(foreach DIR,$(TRGTDIRS),$(eval $(call EX_TEMPLATE,$(DIR)))) $(foreach DIR,$(TRGTDIRS),$(eval $(call EX_TEMPLATE,$(DIR))))
depend: $(ASRCS) $(CSRCS)
- rm -f depend
for d in $(TRGTDIRS);\
do $(CC) $(CFLAGS) $(INCLUDE) -M $(ASRCS) $(CSRCS) | sed -e "s#^\(.*\).o:#$$d/objs/\1.o:#" >> depend; \
done
indent: $(CSRCS) indent: $(CSRCS)
indent $< indent $<
@@ -217,10 +228,6 @@ indent: $(CSRCS)
tags: tags:
ctags sources/* include/* ctags sources/* include/*
ifneq (clean,$(MAKECMDGOALS))
-include depend
endif
.PHONY: printvars .PHONY: printvars
printvars: printvars:
@$(foreach V,$(.VARIABLES), $(if $(filter-out environment% default automatic, $(origin $V)),$(warning $V=$($V)))) @$(foreach V,$(.VARIABLES), $(if $(filter-out environment% default automatic, $(origin $V)),$(warning $V=$($V))))