Makefile (5489B)
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 18 # Default install directories 19 PREFIX = /usr/local 20 APPPREFIX = $(PREFIX)/share 21 BINPREFIX = $(PREFIX)/bin 22 MANPREFIX = $(PREFIX)/share/man 23 24 # Compilation/Linker flags used to compile build system tools 25 CFLAGS=-std=c99 -Wall -Wextra -Os 26 LDFLAGS= 27 28 default: sty-genhead 29 30 .c.o: 31 $(CC) $(CFLAGS) -c $< -o $@ 32 33 sty-genhead: src/sty-genhead.o 34 $(CC) $(CFLAGS) -o $@ src/sty-genhead.o $(LDFLAGS) 35 36 install: sty-genhead 37 install() { mode="$$1"; prefix="$$2"; shift 2; \ 38 mkdir -p "$${prefix}"; \ 39 cp "$$@" "$${prefix}"; \ 40 chmod "$${mode}" "$${prefix}/$${@##*/}"; \ 41 }; \ 42 install 755 "$(DESTDIR)$(BINPREFIX)" sty-genhead; \ 43 install 755 "$(DESTDIR)$(BINPREFIX)" src/sty.sh; \ 44 install 755 "$(DESTDIR)$(BINPREFIX)" src/sty-hooks; \ 45 install 755 "$(DESTDIR)$(BINPREFIX)" src/sty-index; \ 46 install 755 "$(DESTDIR)$(BINPREFIX)" src/sty-list; \ 47 install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/sty-genhead.1; \ 48 install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/sty-hooks.1; \ 49 install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/sty-index.1; \ 50 install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/sty-list.1; \ 51 install 644 "$(DESTDIR)$(MANPREFIX)/man7" doc/star-typesetting.7; \ 52 install 644 "$(DESTDIR)$(PREFIX)/share/doc/star-ty" README.md; \ 53 install 644 "$(DESTDIR)$(PREFIX)/share/doc/star-ty" COPYING; \ 54 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty" example/Makefile; \ 55 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty" example/config.mk; \ 56 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty" example/sty.css; \ 57 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty" example/menu.tsv; \ 58 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home" example/home/documentation.sh; \ 59 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home" example/home/index.tsv; \ 60 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home" example/home/overview.md; \ 61 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks" example/home/hooks/00-find-man-pages.sh; \ 62 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks" example/home/hooks/01-convert-man-pages.sh; \ 63 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks" example/home/hooks/man-pages.sh; \ 64 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/examples" example/examples/index.tsv; \ 65 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/examples" example/examples/lorem-ipsum-fr.md; \ 66 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/examples" example/examples/lorem-ipsum-la.md; \ 67 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/examples/images" example/examples/images/prompt.png; \ 68 install 644 "$(DESTDIR)$(APPPREFIX)/star-ty/templates" example/templates/footer.html 69 sed 's#@README@#$(DESTDIR)$(PREFIX)/share/doc/star-ty/README.md#g' \ 70 example/home/about.sh.in > "$(DESTDIR)$(APPPREFIX)/star-ty/home/about.sh" 71 chmod 644 "$(DESTDIR)$(APPPREFIX)/star-ty/home/about.sh" 72 73 uninstall: 74 rm -f "$(DESTDIR)$(BINPREFIX)/sty-genhead" 75 rm -f "$(DESTDIR)$(BINPREFIX)/sty.sh" 76 rm -f "$(DESTDIR)$(BINPREFIX)/sty-hooks" 77 rm -f "$(DESTDIR)$(BINPREFIX)/sty-index" 78 rm -f "$(DESTDIR)$(BINPREFIX)/sty-list" 79 rm -f "$(DESTDIR)$(MANPREFIX)/man1/sty-genhead.1" 80 rm -f "$(DESTDIR)$(MANPREFIX)/man1/sty-hooks.1" 81 rm -f "$(DESTDIR)$(MANPREFIX)/man1/sty-index.1" 82 rm -f "$(DESTDIR)$(MANPREFIX)/man1/sty-list.1" 83 rm -f "$(DESTDIR)$(MANPREFIX)/man7/star-typesetting.7" 84 rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-ty/README.md" 85 rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-ty/COPYING" 86 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/Makefile" 87 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/config.mk" 88 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/sty.css" 89 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/menu.tsv" 90 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/index.tsv" 91 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/about.sh" 92 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/documentation.sh" 93 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/overview.md" 94 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks/00-find-man-pages.sh" 95 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks/01-convert-man-pages.sh" 96 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/home/hooks/man-pages.sh" 97 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/examples/index.tsv" 98 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/examples/lorem-ipsum-fr.md" 99 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/examples/lorem-ipsum-la.md" 100 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/examples/images/prompt.png" 101 rm -f "$(DESTDIR)$(APPPREFIX)/star-ty/templates/footer.html" 102 103 clean: 104 rm -f src/sty-genhead.o sty-genhead 105 106 lint: 107 shellcheck -o all -P src -x src/sty.sh 108 shellcheck -o all -P src -x src/sty-hooks 109 shellcheck -o all -P src -x src/sty-index 110 shellcheck -o all -P src -x src/sty-list 111 mandoc -Tlint -Wall doc/sty-genhead.1 || [ $$? -le 1 ] 112 mandoc -Tlint -Wall doc/sty-hooks.1 || [ $$? -le 1 ] 113 mandoc -Tlint -Wall doc/sty-index.1 || [ $$? -le 1 ] 114 mandoc -Tlint -Wall doc/sty-list.1 || [ $$? -le 1 ] 115 mandoc -Tlint -Wall doc/star-typesetting.7 || [ $$? -le 1 ]