make-web/Makefile

97 lines
2.6 KiB
Makefile
Raw Normal View History

2023-10-23 22:39:52 +02:00
all:
2023-10-24 08:08:46 +02:00
make -s -j8 website
2023-10-23 13:19:55 +02:00
2023-10-23 22:39:52 +02:00
debug:
make website
# Extensions in src/
2023-10-23 13:19:55 +02:00
# th - template with html code
# ph - page with html code
# pm - page with markdown code
# ps - page with shell code
# pa - page with asciidoctor code
2023-10-23 22:39:52 +02:00
# pt - page with plain text
2023-10-23 13:19:55 +02:00
PH_FILES != find src -type f -name "*.ph" | sed 's|src/||g'
PM_FILES != find src -type f -name "*.pm" | sed 's|src/||g'
PS_FILES != find src -type f -name "*.ps" | sed 's|src/||g'
PA_FILES != find src -type f -name "*.pa" | sed 's|src/||g'
2023-10-23 22:39:52 +02:00
PT_FILES != find src -type f -name "*.pt" | sed 's|src/||g'
2023-10-23 13:19:55 +02:00
2023-10-23 22:39:52 +02:00
STATIC_FILES != cat .control/static-files
REMOTE != cat .control/remote-ssh-target
2023-10-23 13:19:55 +02:00
$(PH_FILES):
echo "Create: src/$@ => www/${@:S/ph/html/}"
2023-10-23 22:39:52 +02:00
mkdir -p "$$(dirname www/${@})"
2023-10-23 13:19:55 +02:00
cat src/header.th > www/${@:S/ph/html/}
cat src/$@ >> www/${@:S/ph/html/}
cat src/footer.th >> www/${@:S/ph/html/}
2023-10-23 22:39:52 +02:00
$(PT_FILES):
echo "Create: src/$@ => www/${@:S/pt/html/}"
mkdir -p "$$(dirname www/${@})"
cat src/header.th > www/${@:S/pt/html/}
echo "<pre>" >> www/${@:S/pt/html/}
cat src/$@ >> www/${@:S/pt/html/}
echo "</pre>" >> www/${@:S/pt/html/}
cat src/footer.th >> www/${@:S/pt/html/}
2023-10-23 13:19:55 +02:00
$(PM_FILES):
echo "Create: src/$@ => www/${@:S/pm/html/}"
mkdir -p "$$(dirname www/${@})"
cat src/header.th > www/${@:S/pm/html/}
discount -f fencedcode src/$@ >> www/${@:S/pm/html/}
cat src/footer.th >> www/${@:S/pm/html/}
$(PS_FILES):
echo "Create: src/$@ => www/${@:S/ps/html/}"
mkdir -p "$$(dirname www/${@})"
cat src/header.th > www/${@:S/ps/html/}
ksh src/$@ >> www/${@:S/ps/html/}
cat src/footer.th >> www/${@:S/ps/html/}
$(PA_FILES):
echo "Create: src/$@ => www/${@:S/pa/html/}"
mkdir -p "$$(dirname www/${@})"
cat src/header.th > www/${@:S/pa/html/}
asciidoctor -e \
-r asciidoctor-diagram \
-a imagesdir=/tmp/adoc-tmp \
-a stylesheet! \
-a data-uri \
-o - src/$@ >> www/${@:S/pa/html/}
cat src/footer.th >> www/${@:S/pa/html/}
2023-10-23 22:39:52 +02:00
website: prepare copy-static-files $(PH_FILES) $(PM_FILES) $(PS_FILES) $(PA_FILES) $(PT_FILES)
2023-10-23 13:19:55 +02:00
prepare:
echo "Mkdir: www"
mkdir -p www
copy-static-files: prepare
2023-10-23 22:39:52 +02:00
rsync -a --partial --delete --no-p --no-o --no-g --out-format="Copy: %f => www/" $(STATIC_FILES) www/
2023-10-23 13:19:55 +02:00
clean:
2023-10-23 22:39:52 +02:00
make -s _clean
_clean:
echo "Delete: www"
2023-10-23 13:19:55 +02:00
rm -rf www
2023-10-23 22:39:52 +02:00
install:
make -s _install
_install: website
echo "Fixing Permissions in www/"
doas chown -R sdk:www www
doas chmod -R ugo+Xrw www
echo "Deploy: www/ => /var/www/htdocs/"
cd www && doas rsync -a --partial --delete --exclude "*/cache/*" --out-format="Deploy: %f => /var/www/htdocs/%f" * $(REMOTE)
2023-10-24 08:08:46 +02:00
#### HELPER TARGETS ####
edit-css:
vim src/assets/style.css
make install
make edit-css