-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (43 loc) · 1.52 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
PLATEX = platex
DVIPDFMX = dvipdfmx
TARGET = document
OUTPUT_DIR = build
BUILDED_TARGET = $(OUTPUT_DIR)/$(TARGET)
BRANCH = HEAD
SUBMODULE_BRANCH = master
YEAR = $(shell cat README.md | head -n 1 | sed -e 's/^\([0-9]*\).*/\1/')
TEST_TARGET = $(shell ls src/*/?kai.tex src/hajimeni.tex) $(shell tools/auto_input.sh show)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
# for Linux
PDF_READER = evince
endif
ifeq ($(UNAME_S),Darwin)
# for MacOSX
PDF_READER = open
endif
all: $(BUILDED_TARGET).dvi
pdf: $(BUILDED_TARGET).pdf
git:
@git checkout $(BRANCH) > /dev/null
@git submodule init > /dev/null
@git submodule update > /dev/null
@git submodule foreach 'git checkout $(SUBMODULE_BRANCH)' > /dev/null
$(BUILDED_TARGET).dvi: $(TARGET).tex git
mkdir -p $(OUTPUT_DIR)
ruby tools/auto_input.rb
$(PLATEX) -interaction=nonstopmode -output-directory=$(OUTPUT_DIR) $(TARGET).tex
$(PLATEX) -interaction=nonstopmode -output-directory=$(OUTPUT_DIR) $(TARGET).tex
$(BUILDED_TARGET).pdf: $(BUILDED_TARGET).dvi
$(DVIPDFMX) -o $(BUILDED_TARGET).pdf $(BUILDED_TARGET).dvi
allclean: clean
cd $(OUTPUT_DIR) && rm -rf $(TARGET).pdf
clean:
cd $(OUTPUT_DIR) && rm -rf *.dvi *.log *.aux *.toc
open: $(BUILDED_TARGET).pdf
$(PDF_READER) $(BUILDED_TARGET).pdf &
test: git
@mkdir -p $(OUTPUT_DIR)
@tools/auto_input.sh
@$(PLATEX) -interaction=nonstopmode -output-directory=$(OUTPUT_DIR) $(TARGET).tex > /dev/null || (ruby tools/filter-error.rb $(BUILDED_TARGET).log && false)
@echo $(TEST_TARGET) | YEAR=$(YEAR) xargs ruby ta9boh/ta9boh.rb $(OPTION)