Makefile (2492B)
1 # Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com) 2 # 3 # This program is free software: you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation, either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 .POSIX: 17 .SUFFIXES: .md .html .sh .lint .shlint 18 19 include config.mk 20 21 LINT=$(HTML:.html=.lint) $(SH:.sh=.shlint) templates/redirect.lint 22 MD=$(SHTML:.sh=.md) 23 24 default: build 25 26 build clean distclean lint install: hooks index 27 @$(MAKE) -f.hooks -f.index -fMakefile $@__ \ 28 HTML=" $$(sty-list html | tr '\n' ' ')" \ 29 SHTML="$$(sty-list shtml | tr '\n' ' ')" \ 30 HOOK=" $$(sty-list hook | tr '\n' ' ')" \ 31 SH=" $$(sty-list shell | tr '\n' ' ')" 32 33 hooks index: 34 sty-$@ > .$@ 35 36 build__: $(HTML) $(HOOK:.sh=.hook) 37 38 clean__: 39 rm -f .hooks 40 rm -f $(HTML) 41 rm -f $(SHTML:.sh=.md) 42 43 install__: $(HTML) $(SIG) 44 @rsync -avzrR --delete-after --progress \ 45 --chmod=Dg+s,g+w,Fg+w --chown=:$(GROUP) --omit-dir-times \ 46 sty.css $(HTML) $$(sty-list subdir) $(RESOURCES) \ 47 $(PREFIX) 48 49 ################################################################################ 50 # Generate content 51 ################################################################################ 52 $(HTML): menu.tsv templates/footer.html 53 54 .sh.md: 55 @cd -- "$$(dirname "$<")"; \ 56 $(SHELL) ./"$$(basename "$<")" > "$$(basename "$@")" 57 58 .md.html: 59 @echo "Building $@" 60 @{ \ 61 sty-genhead $${PWD}/$@; \ 62 $(MD2HTML) $<; \ 63 cat templates/footer.html; \ 64 } > $@ 65 66 ################################################################################ 67 # Check files 68 ################################################################################ 69 .html.lint: 70 @echo "Linting $<" 71 @tidy --show-info no -qe $< 72 73 .sh.shlint: 74 @echo "Linting $<" 75 @# Scripts are executed relative to their section directory. 76 @# Scripts belonging to the compilation system are executed 77 @# relative to the working directory. 78 @i="$<"; \ 79 if [ "$${i%%/*}" != "scripts" ]; then \ 80 cd -- "$${i%%/*}"; \ 81 i="$${i#*/}"; \ 82 fi; \ 83 shellcheck -e SC1091 -o all -x "$${i}" 84 85 lint__: $(LINT)