diff --git a/Makefile b/Makefile index d76b07f..c53cb97 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ PROJDIR := src LEKTOR := lektor --project $(PROJDIR) BUILD_DIR := $$($(LEKTOR) project-info --output-path) +RESOLVED_BUILD_DIR := $$( \ + if [ $$(readlink 'src/content/recipes') == "../../data/distribution/" ]; \ + then echo "$(PWD)/bin"; \ + else echo "$(BUILD_DIR)"; fi) .PHONY: help help: @@ -73,8 +77,10 @@ deploy: # technically this isnt needed anymore but it simplyfies latex development .PHONY: pdf pdf: + @echo + @echo 'Generating PDF from tex source ...' @SECONDS=0; \ - "$(PROJDIR)/_tex-to-pdf/build_manually.sh" \ + "$(PROJDIR)/_tex-to-pdf/build_manually.sh" "$(RESOLVED_BUILD_DIR)" \ && echo "done. finished after $${SECONDS}s." # Helper methods on all recipes diff --git a/src/_tex-to-pdf/build_manually.sh b/src/_tex-to-pdf/build_manually.sh index e4c3d14..9ff4691 100755 --- a/src/_tex-to-pdf/build_manually.sh +++ b/src/_tex-to-pdf/build_manually.sh @@ -1,15 +1,21 @@ #!/bin/sh +BUILD_DIR=$1 + +if [ $# != 1 ] || [ ! -d "$BUILD_DIR" ]; then + echo "Usage: ${0##*/} path/to/build-dir/" + exit 1 +fi + cd "${0%/*}" || exit 1 rm -rf out mkdir -p out -build_dir=$(lektor project-info --output-path) -echo "\\\\def\\\\buildDir{$build_dir}" > out/builddir.tex +echo "\\\\def\\\\buildDir{$BUILD_DIR}" > out/builddir.tex -find "$build_dir" -name "*.tex" | while read -r x; do +find "$BUILD_DIR" -name "*.tex" | while read -r x; do bname=$(basename "${x%.tex}") # remove extension and parent dir - shortname=${x#"$build_dir"} + shortname=${x#"$BUILD_DIR"} for i in 1 2; do echo lualatex "$shortname [$i/2]" lualatex --halt-on-error --output-directory out "$x" > /dev/null || exit 13