don't regenerate the feeds when non-note m4 files change
[~bandali/site] / GNUmakefile
CommitLineData
06611295
AB
1# GNUmakefile --- GNU Makefile for building my personal site
2
3# Copyright (C) 2020-2021 Amin Bandali <bandali@gnu.org>
4
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see
17# <https://www.gnu.org/licenses/>.
18
19
29f0d7b9
AB
20SITE_DOMAIN := 'https://shemshak.org'
21SITE_PREFIX := '/~bandali'
22SITE_URL := '$(SITE_DOMAIN)$(SITE_PREFIX)'
23
553a0296 24SRC := $(filter-out $(wildcard meta_*), $(wildcard *.m4))
8c1ba2f2 25OUTPUTS := $(patsubst %.m4,out/%.html, $(SRC))
c867ac90 26STATIC := $(patsubst static/%,out/%, $(filter-out static/GNUmakefile, $(wildcard static/* static/.*)))
ccd7a480 27NOTES := $(shell ./get-notes.sh)
38037201 28
c867ac90 29all: $(OUTPUTS) out/notes.atom out/notes.rss out/style.css out/GNUmakefile $(STATIC)
38037201 30
d9462d28
AB
31out/%.html: %.m4 header.html footer.html
32 @mkdir -p $(@D)
29f0d7b9 33 m4 -D__d=$(SITE_DOMAIN) -D__p=$(SITE_PREFIX) $< > $@
ccd7a480 34out/notes.%: meta_feed_%.m4 $(NOTES) header.html footer.html
29f0d7b9
AB
35 m4 -D__d=$(SITE_DOMAIN) -D__p=$(SITE_PREFIX) $< > $@
36 sed -i 's|href="/\([^/]\)|href="$(SITE_DOMAIN)/\1|' $@
06611295 37 sed -i 's|href="//|href="https://|' $@
c867ac90 38out/GNUmakefile: GNUmakefile ; ln -s $(PWD)/$< $@
8c1ba2f2
AB
39$(STATIC): ; ln -s $(PWD)/static/$(@F) $@
40
41# publications bibliography
842b89b2 42static/publications-partial.html: static/bandali.bib static/bandali-bib-*
64864447 43static/publications-partial.html: $(filter-out static/publications-partial.html, $(wildcard static/publications-*))
842b89b2 44static/publications-partial.html:
8c1ba2f2 45 $(MAKE) -C $(@D) $(@F)
842b89b2
AB
46out/publications.html: static/publications-partial.html
47out/bandali-bib.html: static/bandali-bib-partial.html
38037201 48
d9462d28
AB
49clean:
50 rm -rf out/
51
38037201 52deploy:
29f0d7b9 53 rsync -avzLP out/ bandali@shemshak.org:~/public_html/
e4b339cf 54
8c1ba2f2
AB
55watch:
56 while true; do \
57 echo $(SRC) header.html footer.html \
842b89b2 58 static/bandali.bib static/bandali-bib-* static/publications-* \
c867ac90 59 GNUmakefile static/GNUmakefile | \
8c1ba2f2
AB
60 tr " " "\n" | entr -d make; done
61
62.PHONY: deploy watch