Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####################################################################################################
- OBJS :=
- OBJS += \
- objs/foo.o \
- objs/src/bar.o \
- objs/src/fred.o \
- objs/src/hardware/spi.o \
- objs/goo.o \
- objs/src/hardware/can.o \
- objs/lib/spam.o \
- objs/lib/egg.o
- ####################################################################################################
- all: ${OBJS}
- @echo Zelda, no Link
- clean:
- $(file >clean.in,${OBJS})
- xargs rm -f < clean.in
- rm -r objs clean.in
- .PHONY: all clean
- ####################################################################################################
- strcmp = $(and $(findstring $1,$2),$(findstring $2,$1))
- dir_stripped_slash = $(patsubst %/,%,$(dir $1))
- define make_dir_list
- $1$(if $(call strcmp,./,$(dir $1)),, $(call make_dir_list,$(call dir_stripped_slash,$1)))
- endef
- define gen_build_rule
- # Do not actually build.
- # `sleep` is used to show how make schedule the build
- $1 : | $(call dir_stripped_slash,$1)
- touch $$@
- @sleep 1
- out_dir_list += $$(call make_dir_list,$$(call dir_stripped_slash,$1))
- endef
- define gen_mkdir_rule
- $1 : | $$(call dir_stripped_slash,$1)
- mkdir $$@
- endef
- ####################################################################################################
- out_dir_list :=
- $(foreach f,${OBJS}, \
- $(eval $(call gen_build_rule,$f)) \
- )
- out_dir_list := $(sort $(strip ${out_dir_list}))
- $(foreach d,${out_dir_list},$(eval $(call gen_mkdir_rule,$d)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement