summaryrefslogtreecommitdiff
path: root/Konzerte/2019_09_29/make
blob: 4acd8e5cb52682a6ba40b690854a6514d9b00a05 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash

set -e

cd "$(dirname "$0")"

teile_params=(
  'Kanons/Er_ist_wie_ein_Baum'
  'Denn_er_hat_seinen_Engeln_'
  'Den_Tag_an_dem_wir_feiern_segne_Gott'
)

rm -f *.pre

for teil_params in "${teile_params[@]}"
do
  if [ -z "${teil_params%%'"'*}" ]; then
    continue
  fi
  teil="${teil_params%%:*}"
  params="${teil_params#${teil}}"
  params="${params#:}"
  (
    cd ../../${teil}
    sed -n '
      s/^\([^:]*%\|'"${teil##*/}"'\)\.pdf.*:\s*//
      T
      :a
        /\\$/ {
          N
          s/\\\n/ /
          ta
        }
      s/\n.*$//
      s/%/'"${teil##*/}"'/g
      p
    ' Makefile | \
      tr ' ' '\n' | \
      grep '\.pre$' | \
      xargs -r make ${params} "$@"
  )
done

{
  printf '\n\n'
  cat alles.ly
  printf '\n\n'
} | \
  while read -r line
  do
    if [[ "${line}" = '%LOOP%'* ]]
    then
      loopLines="${loopLines}
${line#%LOOP%}"
    else
      if [ -n "${loopLines}" ]
      then
        for teil_param in "${teile_params[@]}"
        do
          teil="${teil_param%%:*}"
          echo "${loopLines}" | \
            if [ -z ${teil%%'"'*} ]; then
              sed '
                s/\\include "[^"]*"/\\markup { '"${teil_param}"'" }/g
              '
            else
              cat
            fi | \
            sed "
              s|%TEIL%|${teil}|g
              s|%TEIL-BASE%|${teil##*/}|g
              /%IF \([^=%]\+\)!=\1%/d
              s|%IF [^=%]\+!=[^=%]\+%||g
              s|%IF \([^=%]*[^=!%]\)=\1%||g
              /%IF [^=%]\+=[^=%]\+%/d
            "
        done
        unset loopLines
      fi
      echo "${line}"
    fi
  done > alles.pre

lilypond alles.pre

#ps2pdf -sPAPERSIZE=a4 - empty.pdf </dev/null
#pdfunite empty.pdf alles.pdf alles_.pdf
#mv alles_.pdf alles.pdf