Makefile: Add rules for saving output references.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 14 Mar 2022 17:57:02 +0000 (17:57 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 14 Mar 2022 20:06:39 +0000 (20:06 +0000)
Makefile

index 8cfecb5..257b254 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -159,3 +159,24 @@ $(LINKS): link/%:
                        ln -frs $*.m3u8 "$$t.new" && mv "$$t.new" "$$t" ;; \
                esac
 .PHONY: link $(LINKS)
+
+SAVE                    = $(foreach p,$(PLAYLISTS), save/$p)
+FORCE_SAVE              = $(foreach p,$(PLAYLISTS), force-save/$p)
+save: $(SAVE)
+force-save: $(FORCE_SAVE)
+$(SAVE): save/%: %.m3u8
+       $(V_AT) \
+               ok=nil; \
+               if ! [ -f "ref/$*.m3u8" ]; then \
+                 $(call v-print,SAVE,$*); \
+                 cp $< ref/$*.m3u8.new && mv ref/$*.m3u8.new ref/$*.m3u8; \
+               fi
+.PHONY: save $(SAVE)
+$(FORCE_SAVE): force-save/%: %.m3u8
+       $(V_AT) \
+               ok=nil; \
+               if ! [ -f "ref/$*.m3u8" ] || ! cmp -s $< ref/$*.m3u8; then \
+                 $(call v-print,SAVE,$*); \
+                 cp $< ref/$*.m3u8.new && mv ref/$*.m3u8.new ref/$*.m3u8; \
+               fi
+.PHONY: save $(SAVE)