Makefile: Add rules for saving output references.
[epls] / Makefile
1 ### -*-makefile-*-
2
3 all:
4 clean::; rm -f $(CLEANFILES)
5 force:
6 .PHONY: all clean
7
8 V ?= 0
9 V_AT = $(V_AT_$V)
10 V_AT_0 = @
11 v-print = $(call v-print.$V,$1,$2)
12 v-print.1 = :
13 v-print.0 = printf " %-8s %s\n" "$1" "$2"
14 v-tag = $(call v-tag.$V,$1)
15 v-tag.0 = @$(call v-print.0,$1,$@);
16
17 TARGETS =
18 CLEANFILES += $(TARGETS)
19
20 TARGETS += $(addsuffix .m3u8,$(PLAYLISTS))
21
22 define %declare-playlist
23 PLAYLISTS += $1
24 $1_INITIAL = $2
25 $1_FULLNAME = $3
26 endef
27 declare-playlist = $(eval $(call %declare-playlist,$1,$2,$3))
28
29 ARCHIVEROOT = ../archive
30
31 $(call declare-playlist, 24, \#,24)
32 $(call declare-playlist, agent-carter, A,Agent Carter)
33 #$(call declare-playlist, agents-of-shield, A,Agents of SHIELD)
34 #$(call declare-playlist, andromeda, A,Andromeda)
35 #$(call declare-playlist, arrow, A,Arrow)
36 #$(call declare-playlist, arrowverse, A,Arrowverse)
37 #$(call declare-playlist, a-team, A,The A-Team)
38 #$(call declare-playlist, the-americans, A,The Americans)
39 $(call declare-playlist, allo-allo, A,'Allo 'Allo!)
40 $(call declare-playlist, angel, A,Angel)
41 $(call declare-playlist, babylon-5, B,Babylon 5)
42 #$(call declare-playlist, batman-1966, B,Batman (1966 series))
43 $(call declare-playlist, bsg-1978, B,Battlestar Galactica (1978))
44 #$(call declare-playlist, bsg-1980, B,Battlestar Galactica 1980)
45 #$(call declare-playlist, bsg-2003, B,Battlestar Galactica (2003))
46 #$(call declare-playlist, batwoman, B,Batwoman)
47 $(call declare-playlist, between-the-lines, B,Between the Lines)
48 #$(call declare-playlist, blackadder, B,Blackadder)
49 $(call declare-playlist, blakes-7, B,Blake's 7) #'
50 $(call declare-playlist, brass-eye, B,Brass Eye)
51 $(call declare-playlist, the-bridge, B,The Bridge)
52 $(call declare-playlist, btvs, B,Buffy the Vampire Slayer)
53 #$(call declare-playlist, caprica, C,Caprica)
54 #$(call declare-playlist, constantine, C,Constantine)
55 #$(call declare-playlist, cracker, C,Cracker)
56 #$(call declare-playlist, crow-stairway, C,The Crow—Stairway to Heaven)
57 #$(call declare-playlist, danger-mouse, D,Danger Mouse)
58 #$(call declare-playlist, dark-angel, D,Dark Angel)
59 #$(call declare-playlist, the-day-today, D,The Day Today)
60 #$(call declare-playlist, dexter, D,Dexter)
61 $(call declare-playlist, dollhouse, D,Dollhouse)
62 #$(call declare-playlist, engrenages, E,Engrenages)
63 #$(call declare-playlist, equalizer, E,The Equalizer (1985))
64 $(call declare-playlist, fawlty-towers, F,Fawlty Towers)
65 $(call declare-playlist, firefly, F,Firefly)
66 #$(call declare-playlist, the-flash, F,The Flash)
67 $(call declare-playlist, fry-and-laurie, F,A Bit of Fry and Laurie)
68 #$(call declare-playlist, game-of-thrones, G,Game of Thrones)
69 #$(call declare-playlist, godfather-ii, G/The Godfather Trilogy,02. Part II)
70 #$(call declare-playlist, gotham, G,Gotham)
71 #$(call declare-playlist, hannibal, H,Hannibal)
72 #$(call declare-playlist, hhgttg, H,The Hitchhiker's Guide to the Galaxy) #'
73 $(call declare-playlist, sherlock-holmes, H,Sherlock Holmes (1984))
74 #$(call declare-playlist, house-of-cards, H,House of Cards)
75 #$(call declare-playlist, into-the-labyrinth, I,Into the Labyrinth)
76 #$(call declare-playlist, it-2017, I,It (2017))
77 #$(call declare-playlist, snyder-justice, J,Justice League (Snyder cut))
78 #$(call declare-playlist, kill-bill, K,Kill Bill)
79 #$(call declare-playlist, the-killing, K,The Killing)
80 #$(call declare-playlist, kingdom-of-heaven, K,Kingdom of Heaven (Definitive Edition))
81 #$(call declare-playlist, knight-rider, K,Knight Rider)
82 #$(call declare-playlist, legends-of-tomrrow, L,Legends of Tomorrow)
83 #$(call declare-playlist, lexx, L,Lexx)
84 #$(call declare-playlist, lois-and-clark, L,Lois and Clark—The New Adventures of Superman)
85 $(call declare-playlist, morse, M,Inspector Morse)
86 $(call declare-playlist, macgyver, M,MacGyver)
87 #$(call declare-playlist, metallica-s-and-m, M,Metallica—S&M)
88 #$(call declare-playlist, the-night-manager, N,The Night Manager)
89 #$(call declare-playlist, person-of-interest, P,Person of Interest)
90 #$(call declare-playlist, harry-potter, P,Harry Potter)
91 $(call declare-playlist, flying-circus, P,Monty Python's Flying Circus) #'
92 $(call declare-playlist, robin-of-sherwood, R,Robin of Sherwood)
93 #$(call declare-playlist, rome, R,Rome)
94 #$(call declare-playlist, sanctuary, S,Sanctuary)
95 #$(call declare-playlist, shark, S,Shark)
96 #$(call declare-playlist, the-shield, S,The Shield)
97 #$(call declare-playlist, smallville, S,Smallville)
98 #$(call declare-playlist, george-smiley, S,George Smiley)
99 $(call declare-playlist, spartacus, S,Spartacus)
100 #$(call declare-playlist, spooks, S,Spooks)
101 #$(call declare-playlist, star-wars, S,Star Wars)
102 $(call declare-playlist, stargate-sg1, S,Stargate SG-1)
103 #$(call declare-playlist, stargate-atlantis, S,Stargate Atlantis)
104 #$(call declare-playlist, stargate-universe, S,Stargate Universe)
105 #$(call declare-playlist, state-of-play, S,State of Play)
106 #$(call declare-playlist, supergirl, S,Supergirl)
107 #$(call declare-playlist, terminator-scc, T,Terminator—The Sarah Connor Chronicles)
108 #$(call declare-playlist, traffik, T,Traffik)
109 #$(call declare-playlist, the-tripods, T,The Tripods)
110 #$(call declare-playlist, tru-calling, T,Tru Calling)
111 #$(call declare-playlist, ultraviolet, U,Ultraviolet)
112 #$(call declare-playlist, v-1983, V,V (1983))
113 #$(call declare-playlist, v-2009, V,V (2009))
114 #$(call declare-playlist, the-wire, W,The Wire)
115 #$(call declare-playlist, waking-the-dead, W,Waking the Dead)
116 #$(call declare-playlist, wonder-woman-1975, W,Wonder Woman (1975))
117 #$(call declare-playlist, yes-minister, Y,Yes Minister)
118 #$(call declare-playlist, the-young-ones, Y,The Young Ones)
119
120 $(call declare-playlist, drwho-marco-polo, D/Doctor Who,S01E04 D. Marco Polo)
121 $(call declare-playlist, drwho-crusade, D/Doctor Who,S02E06 P. The Crusade)
122 $(call declare-playlist, drwho-masterplan, D/Doctor Who,S03E04 V. The Daleks' Master Plan) #'
123 $(call declare-playlist, drwho-massacre, D/Doctor Who,S03E05 W. The Massacre of St Bartholomew's Eve) #'
124 $(call declare-playlist, drwho-toymaker, D/Doctor Who,S03E07 Y. The Celestial Toymaker)
125 $(call declare-playlist, drwho-savages, D/Doctor Who,S03E09 AA. The Savages)
126 $(call declare-playlist, drwho-smugglers, D/Doctor Who,S04E01 CC. The Smugglers)
127 $(call declare-playlist, drwho-highlanders, D/Doctor Who,S04E04 FF. The Highlanders)
128 $(call declare-playlist, drwho-snowmen, D/Doctor Who,S05E02 NN. The Abominable Snowmen)
129 $(call declare-playlist, drwho-wheel, D/Doctor Who,S05E07 SS. The Wheel in Space)
130 $(call declare-playlist, drwho-invasion, D/Doctor Who,S06E03 VV. The Invasion)
131 $(call declare-playlist, drwho-pirates, D/Doctor Who,S06E06 YY. The Space Pirates)
132 $(call declare-playlist, drwho-war-games, D/Doctor Who,S06E07 ZZ. The War Games)
133 $(call declare-playlist, drwho-silurians, D/Doctor Who,S07E02 BBB. Doctor Who and the Silurians)
134
135 all: $(TARGETS)
136
137 %.m3u8: %.epls mkm3u
138 $(call v-tag,MKM3U)./mkm3u "$<" >"$@.new" && mv "$@.new" "$@"
139
140 CHECKS = $(foreach p,$(PLAYLISTS), check/$p)
141 check: $(CHECKS)
142 $(CHECKS): check/%: %.m3u8
143 $(V_AT)diff -u $< ref/$*.m3u8
144 .PHONY: check $(CHECKS)
145
146 LINKS = $(foreach p,$(PLAYLISTS), link/$p)
147 link: $(LINKS)
148 $(LINKS): link/%:
149 $(V_AT) \
150 ok=nil t="$(ARCHIVEROOT)/$($*_INITIAL)/$($*_FULLNAME).m3u8"; \
151 if [ -L "$$t" ]; then \
152 case $$(realpath "$$t") in \
153 "$(abspath $*.m3u8)") ok=t ;; \
154 esac; \
155 fi; \
156 case $$ok in \
157 t) ;; \
158 *) $(call v-print,LINK,$*); \
159 ln -frs $*.m3u8 "$$t.new" && mv "$$t.new" "$$t" ;; \
160 esac
161 .PHONY: link $(LINKS)
162
163 SAVE = $(foreach p,$(PLAYLISTS), save/$p)
164 FORCE_SAVE = $(foreach p,$(PLAYLISTS), force-save/$p)
165 save: $(SAVE)
166 force-save: $(FORCE_SAVE)
167 $(SAVE): save/%: %.m3u8
168 $(V_AT) \
169 ok=nil; \
170 if ! [ -f "ref/$*.m3u8" ]; then \
171 $(call v-print,SAVE,$*); \
172 cp $< ref/$*.m3u8.new && mv ref/$*.m3u8.new ref/$*.m3u8; \
173 fi
174 .PHONY: save $(SAVE)
175 $(FORCE_SAVE): force-save/%: %.m3u8
176 $(V_AT) \
177 ok=nil; \
178 if ! [ -f "ref/$*.m3u8" ] || ! cmp -s $< ref/$*.m3u8; then \
179 $(call v-print,SAVE,$*); \
180 cp $< ref/$*.m3u8.new && mv ref/$*.m3u8.new ref/$*.m3u8; \
181 fi
182 .PHONY: save $(SAVE)