make-web/Makefile
2023-10-24 08:08:46 +02:00

97 lines
2.6 KiB
Makefile

all:
make -s -j8 website
debug:
make website
# Extensions in src/
# 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
# pt - page with plain text
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'
PT_FILES != find src -type f -name "*.pt" | sed 's|src/||g'
STATIC_FILES != cat .control/static-files
REMOTE != cat .control/remote-ssh-target
$(PH_FILES):
echo "Create: src/$@ => www/${@:S/ph/html/}"
mkdir -p "$$(dirname www/${@})"
cat src/header.th > www/${@:S/ph/html/}
cat src/$@ >> www/${@:S/ph/html/}
cat src/footer.th >> www/${@:S/ph/html/}
$(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/}
$(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/}
website: prepare copy-static-files $(PH_FILES) $(PM_FILES) $(PS_FILES) $(PA_FILES) $(PT_FILES)
prepare:
echo "Mkdir: www"
mkdir -p www
copy-static-files: prepare
rsync -a --partial --delete --no-p --no-o --no-g --out-format="Copy: %f => www/" $(STATIC_FILES) www/
clean:
make -s _clean
_clean:
echo "Delete: www"
rm -rf www
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)
#### HELPER TARGETS ####
edit-css:
vim src/assets/style.css
make install
make edit-css