-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
101 lines (75 loc) · 2.25 KB
/
makefile
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
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (c) 2008-2010 Alexandre Dupas <[email protected]>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
SONGBOOKS := $(wildcard *.sb)
TARGETS = $(SONGBOOKS:%.sb=%)
PDF = $(TARGETS:%=%.pdf)
CHORDS = chords.tex
CHORDS_SRC = $(shell ls songs/*/*.sg)
PRINT=printf "%s\n"
PRINTTAB=printf "\t%s\n"
MAKE_SONGBOOK=./songbook.py
MAKE_INDEX=./songbook-makeindex.py
MAKE_CHORDS=./utils/songbook-gtab.py
ifeq ($(shell which lilypond),)
LILYPOND=$(ECHO) "** lilypond not found" >&2 ; $(ECHO) lilypond
LILYFILE=''
else
LILYPOND=lilypond
LILY_SRC=$(wildcard lilypond/*.ly)
LILYFILE=$(LILY_SRC:%.ly=%.pdf)
endif
LATEX=pdflatex $(LATEX_OPTIONS)
CROP=pdfcrop
############################################################
### Targets
default: songbook.pdf
all: $(PDF)
pdf: $(PDF)
xpdf $<
lilypond: $(LILYFILE)
clean:
@rm -f $(TARGETS:%=%.d) $(TARGETS:%=%.tex) $(TARGETS:%=%.aux) \
$(TARGETS:%=%.toc) $(TARGETS:%=%.out) $(TARGETS:%=%.log) \
$(TARGETS:%=%.nav) $(TARGETS:%=%.snm)
@rm -f *.sbx *.sxd
cleanall: clean
@rm -f $(PDF)
@rm -f $(LILYFILE)
depend:
############################################################
$(PDF): %.pdf: %.tex %.aux
%.aux: %.tex
$(LATEX) $<
%.sbx: %.sxd
$(MAKE_INDEX) $< > $@
%.tex: %.sb
$(MAKE_SONGBOOK) -s $< -o $@
%.d: %.sb
$(MAKE_SONGBOOK) -s $< -d -o $@
%.pdf: %.ly
@$(LILYPOND) --output=$(@:%.pdf=%) $<
$(CROP) $@ $@
# @rm $(@:%.pdf=%.ps)
$(CHORDS): $(CHORDS_SRC)
$(MAKE_CHORDS) -o $@
ifeq (.pdf,$(suffix $(MAKECMDGOALS)))
include $(MAKECMDGOALS:%.pdf=%.d)
else ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),cleanall)
include $(TARGETS:%=%.d)
endif
endif