about summary refs log tree commit diff stats
path: root/build/latex/academia/build.sh
blob: c67ad527b97c411234d6f95ad43168051ea73895 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env sh

file="./%INIT_APPLICATION_NAME.tex"
dst=build

clear=false

for arg in "$@"; do
    case "$arg" in
    "--clear")
        clear=true
        ;;
    --*)
        echo "No such option: '$arg'"
        exit 2
        ;;
    *)
        file="$arg"
        ;;
    esac
done

# find all directories which are not the destination dir or inside it
find . -type d -not -name "$dst" -not -path "./$dst/*" -printf '%P\n' | while IFS= read -r dir; do
    mkdir --parents "$dst/$dir"
done

test "$clear" = true && rm "$dst/${file%tex}out"

latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "$file"