121 lines
2.9 KiB
Makefile
121 lines
2.9 KiB
Makefile
WWW = ${PWD}/www
|
|
SITE = ${PWD}/site
|
|
SCRIPTS = ${PWD}/scripts
|
|
LOCAL = /var/www/htdocs
|
|
REMOTE = sdk@codevoid.de:/home/www/htdocs/shagen
|
|
|
|
# do everything by default
|
|
all: build-and-upload-all
|
|
@echo "done."
|
|
|
|
# Create the photo galleries and create the index and preview html
|
|
# pages in site/, so they get parsed in the compile step
|
|
PHOTODIRS != find photos/* -maxdepth 0 -mindepth 0 -type d
|
|
photos: ${PHOTODIRS}
|
|
mkdir -p ${SITE}/photos
|
|
cd photos && sh ${SCRIPTS}/mkphotoindex.sh > index.html
|
|
find photos -type f -not -name "*.html" -exec install -D {} www/{} \;
|
|
find photos -type f -name "*.html" -exec install -D {} site/{} \;
|
|
|
|
optimize:
|
|
find photos -name "*.jpg" -type f -exec jpegoptim -w 12 --all-progressive --strip-all "{}" +
|
|
|
|
calendar:
|
|
mkdir -p ${SITE}/uugcal
|
|
cd ${SITE}/uugcal && sh ${SCRIPTS}/mkuugcalendar.sh > index.html
|
|
|
|
${PHOTODIRS}:
|
|
cd "$@" && sh ${SCRIPTS}/mkphotos.sh > index.html
|
|
|
|
# invoke zod and compile the website into the www/ dir
|
|
compile:
|
|
mkdir -p ${WWW}
|
|
zod ${SITE} ${WWW}
|
|
|
|
# after mixing different generators in the compile step, let's tidy and
|
|
# indent the output properly (XXX is there a tool that does _only_
|
|
# indent?)
|
|
tidy:
|
|
find ${WWW} -type f -name "*.html" \
|
|
-exec tidy -q -i -m -c -w 120 -f /dev/null {} \;
|
|
find ${WWW} -type f -name "*.html" \
|
|
-exec sed -i '/.*meta name="generator".*/d' {} \;
|
|
|
|
# create gzip variants of text files, so they can be served by httpds
|
|
# gzip-static extension
|
|
gzip:
|
|
find ${WWW} -type f \
|
|
\( -name "*.html" -o -name "*.css" \) \
|
|
-exec gzip -kf9 {} \;
|
|
|
|
# set permissions so the web server can read the file
|
|
fixperms:
|
|
doas chown -R sdk:www ${WWW}
|
|
doas chmod -R ugo+wrX,go-w ${WWW}
|
|
|
|
# we can upload to the local and the remote webserver at the same time
|
|
upload-local: stagit
|
|
doas rsync -a --delete ${WWW}/ ${LOCAL}/
|
|
upload-remote: stagit
|
|
doas rsync -a --delete -e ssh ${WWW}/ ${REMOTE}/
|
|
upload-all: upload-local upload-remote
|
|
|
|
build:
|
|
make clean; \
|
|
make photos; \
|
|
make stagit; \
|
|
make calendar; \
|
|
make compile; \
|
|
make tidy; \
|
|
make fixperms;
|
|
|
|
build-and-upload-all:
|
|
make build; \
|
|
make upload-all;
|
|
|
|
# deploy to the local webserver for preview
|
|
local:
|
|
make build; \
|
|
make upload-local;
|
|
remote:
|
|
make build; \
|
|
make upload-remote
|
|
|
|
# clean up temporary files and everything that can be regenerated very fast
|
|
clean:
|
|
rm -rf ${WWW}/photos
|
|
rm -rf ${SITE}/photos
|
|
rm -f photos/index.html
|
|
rm -f photos/*/*.html
|
|
rm -rf ${SITE}/uugcal
|
|
rm -rf ${WWW}
|
|
|
|
# clean and also delete all generated images
|
|
realclean: clean
|
|
rm -rf photos/*/{thm,mid}
|
|
|
|
|
|
### TARGETS BELOW ARE ONLY FOR CONVENIENCE
|
|
|
|
stagit:
|
|
scripts/reposync.sh
|
|
|
|
git-add:
|
|
find site/photos -type f \
|
|
-not -name "*.html" \
|
|
-not -path "*/thm/*" \
|
|
-not -path "*/mid/*" \
|
|
-exec git add "{}" +
|
|
|
|
# watch files and rebuild automatically
|
|
notify:
|
|
ulimit -n 1024; \
|
|
find ${SITE} ${SCRIPTS} -not -path "*/photos/*" -type f \
|
|
| inotifywait -m -e modify --fromfile - \
|
|
| while read line; \
|
|
do \
|
|
make; \
|
|
done
|
|
|
|
.PHONY: ${PHOTODIRS} ${REPOS}
|