-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (82 loc) · 2.92 KB
/
Makefile
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
#########################################################
#
# Makefile to tweet blog updates based on new entries in
# the _posts directory.
# Account: @SidDarthious
# Archive: tweet-record/tweet-archive.zip
#
# Siddharth Maddali
# May 2020
#
#########################################################
ROOT=${HOME}/local/siddharth-maddali.github.io
BOT=${ROOT}/update-bot.py
ZIP=/usr/bin/zip
#H2P=/usr/bin/wkhtmltopdf
DOCCREAT=${ROOT}/createDocs.py
# auto-tweeting variables
POSTS=$(wildcard ${ROOT}/tweet-record/*.md)
TWEETS=$(POSTS:.md=.tweet)
ARCHIVE=${ROOT}/tweet-record/tweet-archive.zip
# generate all docs
WEB=$(wildcard ${ROOT}/docs/{cv,resume}/*.tex)
PDF=$(WEB:.tex=.pdf)
DOCLIST=${ROOT}/docs/docs.list
#H2PFLAGS=--encoding utf-8 --enable-local-file-access --page-size A4 --margin-top 5mm --margin-bottom 5mm --margin-left 5mm --margin-right 5mm
DOCCREATFLAGS=
#########################################################
# Make directives
#########################################################
#--------------------------------------------------------------
# creates a new <filename>.tweet for every <filename>.md
%.tweet: %.md
$(BOT) $< $@
# archives all <filename>.tweet into existing archive.
$(ARCHIVE):$(TWEETS)
$(ZIP) -rv $(ARCHIVE) $(TWEETS)
#--------------------------------------------------------------
# builds pdfs from html pages in docs directory
%.pdf: %.html
-$(H2P) $(H2PFLAGS) $< $@
@cp $@ ./professional/
# generates list of pdfs as text file.
$(DOCLIST):$(PDF)
@echo $(PDF) > $(DOCLIST)
#--------------------------------------------------------------
.PHONY: updatelinks tweet touch clean docs test
# updatelinks:
# creates symlinks of all new blog posts
# within the staging directory.
updatelinks:
diff $(ROOT)/_posts/ $(ROOT)/tweet-record/ |\
grep "^Only in $(ROOT)/_posts" |\
awk '{ print $$(4); }' |\
xargs -I '{}' ln -s $(ROOT)/_posts/{} -t $(ROOT)/tweet-record/
# tweet:
# build the target i.e., local copy of tweets, and eventually the archive.
tweet: $(ARCHIVE)
# touch:
# Fast-forwards status of all blog posts as tweeted, regardless
# of whether post has been updated or not. Used to avoid tweeting
# same blog post multiple times after an edit.
touch:
@echo WARNING: Resetting timestamps of all existing posts...
ls $(ROOT)/tweet-record/*.tweet |\
sed "s/\.tweet//g" |\
xargs -I '{}' basename {} |\
xargs -I '{}' bash -c "\
unlink $(ROOT)/tweet-record/{}.md && \
ln -s $(ROOT)/_posts/{}.md -t $(ROOT)/tweet-record && \
touch $(ROOT)/tweet-record/{}.tweet"
touch $(ARCHIVE)
# clean:
# Flushes everything away removes record of auto-tweeted posts.
# WARNING: Doing this and then running 'make updatelinks' followed
# by 'make tweet' will auto-tweet EVERY POST since the beginning!
clean:
rm -f $(ROOT)/tweet-record/*.tweet $(ARCHIVE)
ls $(ROOT)/tweet-record/*.md | xargs -I '{}' unlink {}
# docs:
# Rebuilds pdf documents
docs: $(DOCLIST)