summaryrefslogtreecommitdiff
path: root/Makefile
blob: eec9eef0740c8089ba232deb409478cd4c6970ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
export PATH := /etc/profiles/per-user/ch/bin:$(PATH)

MEDIA_DIR := /srv/media
TEST_DIR := /srv/www/pdp8-test
PUB_DIR := /srv/www/pdp8

MUSIC_DIR := $(MEDIA_DIR)/music
FLAC := $(wildcard $(MUSIC_DIR)/*/*.flac)
MP3 := $(subst flac, mp3, $(FLAC))

IMG_DIR := $(MEDIA_DIR)/pictures
WEBP_DIR := $(IMG_DIR)/webp
JPEG_DIR := $(IMG_DIR)/jpeg
TXT_DIR := $(IMG_DIR)/txt

JPEG_IMG := $(wildcard $(JPEG_DIR)/*.jpeg)
WEBP_IMG := $(subst jpeg, webp, $(JPEG_IMG))
TXT_IMG := $(subst jpeg, txt, $(JPEG_IMG))

IMG_COLLECTIONS := $(wildcard $(IMG_DIR)/collections/*)

VIDEO_DIR := /srv/media/videos
VIDEO_WEBM := $(wildcard $(VIDEO_DIR)/*/*.webm)
VIDEO_MP4 := $(subst webm, mp4, $(VIDEO_WEBM))
VIDEO_WEBP := $(subst webm, webp, $(VIDEO_WEBM))
VIDEO_PNG := $(subst webm, png, $(VIDEO_WEBM))

CLIMBING_DIR := /srv/media/climbing
CLIMBING_WEBM := $(wildcard $(CLIMBING_DIR)/*.webm)
CLIMBING_MP4 := $(subst webm,mp4, $(CLIMBING_WEBM))
CLIMBING_WEBP := $(subst webm,webp, $(CLIMBING_WEBM))

HTML := index.html music.html pictures.html videos.html climbing.html about.html code.html contact.html social/create.html social/announce.html 
OTHER := pdp8.png 540px-PDP-8_.jpg style.css robots.txt sitemap.txt rss.xml

TEST_HTML := $(addprefix $(TEST_DIR)/, $(HTML))
TEST_OTHER := $(addprefix $(TEST_DIR)/, $(OTHER))
PUB_HTML := $(addprefix $(PUB_DIR)/, $(HTML))

all: test
	cd $(TEST_DIR); git commit -am "$$(date)"; git push; cd $(PUB_DIR); git pull

test: $(TEST_HTML) $(TEST_OTHER)

pictures: $(WEBP_IMG) $(TXT_IMG) 

$(TEST_DIR)/rss.xml: $(TEST_HTML)
	./rss.rb 

$(TEST_DIR)/index.html: $(TEST_DIR)/music.html
	cp $< $@

$(TEST_DIR)/music.html: $(MP3)
	./music.rb

$(TEST_DIR)/pictures.html: $(IMG_COLLECTIONS)
	./pictures.rb
	
$(TEST_DIR)/videos.html: $(VIDEO_MP4) $(VIDEO_WEBP)
	./videos.rb
	
$(TEST_DIR)/climbing.html: $(CLIMBING_MP4) $(CLIMBING_WEBP)
	./climbing.rb

$(TEST_DIR)/%.html: ./html/%.html
	./file.rb $< 

$(TEST_DIR)/%.png: ./html/%.png
	cp $< $@

$(TEST_DIR)/%.jpg: ./html/%.jpg
	cp $< $@

$(TEST_DIR)/%.css: ./html/%.css
	cp $< $@

$(TEST_DIR)/%.txt: ./html/%.txt
	cp $< $@

%.mp3: %.flac
	ffmpeg -i $< -y -vsync 0 -ab 256k -map_metadata 0 -id3v2_version 3 $@

%.webp: %.webm
	ffmpeg -i $< -loglevel error -vf thumbnail -frames:v 1 -c:v png -f image2pipe - | magick - $@

$(WEBP_DIR)/%.webp: $(JPEG_DIR)/%.jpeg
	magick $< -resize 1536x1024 -quality 85 $@

%.mp4: %.webm
	ffmpeg -i $< -vf scale=1280:-2 -c:v h264 -c:a aac -b:a 128k -strict -2 -movflags faststart $@