Commit | Line | Data |
---|---|---|
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 |
20 | SITE_DOMAIN := 'https://shemshak.org' |
21 | SITE_PREFIX := '/~bandali' | |
22 | SITE_URL := '$(SITE_DOMAIN)$(SITE_PREFIX)' | |
23 | ||
553a0296 | 24 | SRC := $(filter-out $(wildcard meta_*), $(wildcard *.m4)) |
8c1ba2f2 | 25 | OUTPUTS := $(patsubst %.m4,out/%.html, $(SRC)) |
c867ac90 | 26 | STATIC := $(patsubst static/%,out/%, $(filter-out static/GNUmakefile, $(wildcard static/* static/.*))) |
38037201 | 27 | |
c867ac90 | 28 | all: $(OUTPUTS) out/notes.atom out/notes.rss out/style.css out/GNUmakefile $(STATIC) |
38037201 | 29 | |
d9462d28 AB |
30 | out/%.html: %.m4 header.html footer.html |
31 | @mkdir -p $(@D) | |
29f0d7b9 | 32 | m4 -D__d=$(SITE_DOMAIN) -D__p=$(SITE_PREFIX) $< > $@ |
dcc71b98 | 33 | out/notes.%: meta_feed_%.m4 $(SRC) header.html footer.html |
29f0d7b9 AB |
34 | m4 -D__d=$(SITE_DOMAIN) -D__p=$(SITE_PREFIX) $< > $@ |
35 | sed -i 's|href="/\([^/]\)|href="$(SITE_DOMAIN)/\1|' $@ | |
06611295 | 36 | sed -i 's|href="//|href="https://|' $@ |
c867ac90 | 37 | out/GNUmakefile: GNUmakefile ; ln -s $(PWD)/$< $@ |
8c1ba2f2 AB |
38 | $(STATIC): ; ln -s $(PWD)/static/$(@F) $@ |
39 | ||
40 | # publications bibliography | |
842b89b2 | 41 | static/publications-partial.html: static/bandali.bib static/bandali-bib-* |
64864447 | 42 | static/publications-partial.html: $(filter-out static/publications-partial.html, $(wildcard static/publications-*)) |
842b89b2 | 43 | static/publications-partial.html: |
8c1ba2f2 | 44 | $(MAKE) -C $(@D) $(@F) |
842b89b2 AB |
45 | out/publications.html: static/publications-partial.html |
46 | out/bandali-bib.html: static/bandali-bib-partial.html | |
38037201 | 47 | |
d9462d28 AB |
48 | clean: |
49 | rm -rf out/ | |
50 | ||
38037201 | 51 | deploy: |
29f0d7b9 | 52 | rsync -avzLP out/ bandali@shemshak.org:~/public_html/ |
e4b339cf | 53 | |
8c1ba2f2 AB |
54 | watch: |
55 | while true; do \ | |
56 | echo $(SRC) header.html footer.html \ | |
842b89b2 | 57 | static/bandali.bib static/bandali-bib-* static/publications-* \ |
c867ac90 | 58 | GNUmakefile static/GNUmakefile | \ |
8c1ba2f2 AB |
59 | tr " " "\n" | entr -d make; done |
60 | ||
61 | .PHONY: deploy watch |