• 2 Posts
  • 5 Comments
Joined 3 years ago
cake
Cake day: July 16th, 2023

help-circle

  • Oh right, that was not the whole Makefile, only the part that caused problems. As @fruitcantfly@programming.dev pointed out, it breaks down with more SOURCE files and populates the newly created directories with only the first SOURCE file. After some more poking and reading I found a method that works by using define:

    define rule
    $(DESTINATION)/$(shell echo $(notdir $(1)) | sed -E 's/^([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md$$/\1\/\2\/\3\/\4.md/'): $(1) | $(DESTINATION)/$(shell echo $(notdir $(1)) | sed -E 's/^([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md$$/\1\/\2\/\3/')
    	/bin/bash ./myscript.sh $$< > $$@
    endef
    
    $(foreach f,$(SOURCE),$(eval $(call rule,$(f))))
    

    I feel like this is an abuse of Make, but it works. When is it a good idea to delegate the building process to other tools?