summaryrefslogtreecommitdiff
path: root/Makefile
blob: c8db1a60c314f99e6fec38db68e9c6c7ac8af509 (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
91
92
93
94
95
96
97
98
99
100
101
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
THUMB_DIR := $(IMG_DIR)/thumb
TXT_DIR := $(IMG_DIR)/txt

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

IMG_ALBUMS := $(wildcard $(IMG_DIR)/albums/*)

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 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) $(THUMB_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_ALBUMS) $(WEBP_IMG) $(THUMB_IMG)
	./pictures.rb
	
$(TEST_DIR)/videos.html: $(VIDEO_MP4) $(VIDEO_WEBP)
	./videos.rb

# $(TEST_DIR)/social/create.html: 
# 	./social.rb create
	
# $(TEST_DIR)/social/announce.html: 
# 	./social.rb announce
	
$(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 $@

$(THUMB_DIR)/%.webp: $(JPEG_DIR)/%.jpeg
	magick $< -resize 150x100 -quality 85 $@

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