Add `Shark'.
[epls] / Makefile
index 30acdd8..9e3117e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,11 @@ force:
 V                      ?= 0
 V_AT                    = $(V_AT_$V)
 V_AT_0                  = @
+v-print                         = $(call v-print.$V,$1,$2)
+v-print.1               = :
+v-print.0               = printf "  %-8s %s\n" "$1" "$2"
 v-tag                   = $(call v-tag.$V,$1)
-v-tag.0                         = @printf "  %-8s %s\n" "$1" "$@";
+v-tag.0                         = @$(call v-print.0,$1,$@);
 
 TARGETS                         =
 CLEANFILES             += $(TARGETS)
@@ -62,7 +65,7 @@ $(call declare-playlist, fawlty-towers, F,Fawlty Towers)
 $(call declare-playlist, firefly, F,Firefly)
 #$(call declare-playlist, the-flash, F,The Flash)
 $(call declare-playlist, fry-and-laurie, F,A Bit of Fry and Laurie)
-#$(call declare-playlist, game-of-thrones, G,Game of Thrones)
+$(call declare-playlist, game-of-thrones, G,Game of Thrones)
 #$(call declare-playlist, godfather-ii, G/The Godfather Trilogy,02. Part II)
 #$(call declare-playlist, gotham, G,Gotham)
 #$(call declare-playlist, hannibal, H,Hannibal)
@@ -87,9 +90,9 @@ $(call declare-playlist, macgyver, M,MacGyver)
 #$(call declare-playlist, harry-potter, P,Harry Potter)
 $(call declare-playlist, flying-circus, P,Monty Python's Flying Circus) #'
 $(call declare-playlist, robin-of-sherwood, R,Robin of Sherwood)
-#$(call declare-playlist, rome, R,Rome)
+$(call declare-playlist, rome, R,Rome)
 #$(call declare-playlist, sanctuary, S,Sanctuary)
-#$(call declare-playlist, shark, S,Shark)
+$(call declare-playlist, shark, S,Shark)
 #$(call declare-playlist, the-shield, S,The Shield)
 #$(call declare-playlist, smallville, S,Smallville)
 #$(call declare-playlist, george-smiley, S,George Smiley)
@@ -108,8 +111,8 @@ $(call declare-playlist, stargate-sg1, S,Stargate SG-1)
 #$(call declare-playlist, ultraviolet, U,Ultraviolet)
 #$(call declare-playlist, v-1983, V,V (1983))
 #$(call declare-playlist, v-2009, V,V (2009))
-#$(call declare-playlist, the-wire, W,The Wire)
-#$(call declare-playlist, waking-the-dead, W,Waking the Dead)
+$(call declare-playlist, the-wire, W,The Wire)
+$(call declare-playlist, waking-the-dead, W,Waking the Dead)
 #$(call declare-playlist, wonder-woman-1975, W,Wonder Woman (1975))
 #$(call declare-playlist, yes-minister, Y,Yes Minister)
 #$(call declare-playlist, the-young-ones, Y,The Young Ones)
@@ -137,11 +140,43 @@ all: $(TARGETS)
 CHECKS                  = $(foreach p,$(PLAYLISTS), check/$p)
 check: $(CHECKS)
 $(CHECKS): check/%: %.m3u8
-       diff -u $< ref/$*.m3u8
+       $(V_AT)diff -u $< ref/$*.m3u8
 .PHONY: check $(CHECKS)
 
 LINKS                   = $(foreach p,$(PLAYLISTS), link/$p)
 link: $(LINKS)
 $(LINKS): link/%:
-       ln -frs $*.m3u8 "$(ARCHIVEROOT)/$($*_INITIAL)/$($*_FULLNAME).m3u8"
+       $(V_AT) \
+               ok=nil t="$(ARCHIVEROOT)/$($*_INITIAL)/$($*_FULLNAME).m3u8"; \
+               if [ -L "$$t" ]; then \
+                 case $$(realpath "$$t") in \
+                   "$(abspath $*.m3u8)") ok=t ;; \
+                 esac; \
+               fi; \
+               case $$ok in \
+                 t) ;; \
+                 *) $(call v-print,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)