Makefile (2519B)
1 # Copyright (C) 2017-2026 |Méso|Star> (contact@meso-star.com) 2 # 3 # This file is part of Méso-Web. 4 # 5 # Méso-Web 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 # Méso-Web 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 Méso-Web. If not, see <http://www.gnu.org/licenses/>. 17 18 .POSIX: 19 .SUFFIXES: .md .html .sh .lint .shlint 20 21 include config.mk 22 23 LINT=$(HTML:.html=.lint) $(SH:.sh=.shlint) templates/redirect.lint 24 MD=$(SHTML:.sh=.md) 25 26 default: build 27 28 build clean distclean lint install: hooks index 29 @$(MAKE) -f.hooks -f.index -fMakefile $@__ \ 30 HTML=" $$(sty-list html | tr '\n' ' ')" \ 31 SHTML="$$(sty-list shtml | tr '\n' ' ')" \ 32 HOOK=" $$(sty-list hook | tr '\n' ' ')" \ 33 SH=" $$(sty-list shell | tr '\n' ' ')" 34 35 hooks index: 36 sty-$@ > .$@ 37 38 build__: $(HTML) $(HOOK:.sh=.hook) 39 40 clean__: 41 rm -f .hooks 42 rm -f $(HTML) 43 rm -f $(SHTML:.sh=.md) 44 45 install__: $(HTML) $(SIG) 46 @rsync -avzrR --delete-after --progress \ 47 --chmod=Dg+s,g+w,Fg+w --chown=:$(GROUP) --omit-dir-times \ 48 sty.css $(HTML) $$(sty-list subdir) $(RESOURCES) \ 49 $(PREFIX) 50 51 ################################################################################ 52 # Generate content 53 ################################################################################ 54 $(HTML): menu.tsv templates/footer.html 55 56 .sh.md: 57 @cd -- "$$(dirname "$<")"; \ 58 $(SHELL) ./"$$(basename "$<")" > "$$(basename "$@")" 59 60 .md.html: 61 @echo "Building $@" 62 @{ \ 63 sty-genhead $${PWD}/$@; \ 64 $(MD2HTML) $<; \ 65 cat templates/footer.html; \ 66 } > $@ 67 68 ################################################################################ 69 # Check files 70 ################################################################################ 71 .html.lint: 72 @echo "Linting $<" 73 @tidy --show-info no -qe $< 74 75 .sh.shlint: 76 @echo "Linting $<" 77 @# Scripts are executed relative to their section directory. 78 @# Scripts belonging to the compilation system are executed 79 @# relative to the working directory. 80 @i="$<"; \ 81 if [ "$${i%%/*}" != "scripts" ]; then \ 82 cd -- "$${i%%/*}"; \ 83 i="$${i#*/}"; \ 84 fi; \ 85 shellcheck -e SC1091 -o all -x "$${i}" 86 87 lint__: $(LINT)