Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ####################################################################################################
  2. OBJS :=
  3. OBJS += \
  4. objs/foo.o \
  5. objs/src/bar.o \
  6. objs/src/fred.o \
  7. objs/src/hardware/spi.o \
  8. objs/goo.o \
  9. objs/src/hardware/can.o \
  10. objs/lib/spam.o \
  11. objs/lib/egg.o
  12.  
  13. ####################################################################################################
  14. all: ${OBJS}
  15. @echo Zelda, no Link
  16.  
  17. clean:
  18. $(file >clean.in,${OBJS})
  19. xargs rm -f < clean.in
  20. rm -r objs clean.in
  21.  
  22. .PHONY: all clean
  23. ####################################################################################################
  24. strcmp = $(and $(findstring $1,$2),$(findstring $2,$1))
  25.  
  26. dir_stripped_slash = $(patsubst %/,%,$(dir $1))
  27.  
  28. define make_dir_list
  29. $1$(if $(call strcmp,./,$(dir $1)),, $(call make_dir_list,$(call dir_stripped_slash,$1)))
  30. endef
  31.  
  32. define gen_build_rule
  33.  
  34. # Do not actually build.
  35. # `sleep` is used to show how make schedule the build
  36. $1 : | $(call dir_stripped_slash,$1)
  37. touch $$@
  38. @sleep 1
  39.  
  40. out_dir_list += $$(call make_dir_list,$$(call dir_stripped_slash,$1))
  41. endef
  42.  
  43. define gen_mkdir_rule
  44. $1 : | $$(call dir_stripped_slash,$1)
  45. mkdir $$@
  46.  
  47. endef
  48. ####################################################################################################
  49. out_dir_list :=
  50. $(foreach f,${OBJS}, \
  51. $(eval $(call gen_build_rule,$f)) \
  52. )
  53.  
  54. out_dir_list := $(sort $(strip ${out_dir_list}))
  55.  
  56. $(foreach d,${out_dir_list},$(eval $(call gen_mkdir_rule,$d)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement