-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile-ipython.include
55 lines (48 loc) · 1.45 KB
/
Makefile-ipython.include
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
### Requires the Makefile.include file from
### http://github.com/ransford/pdflatex-makefile
###
### generic GNU make Makefile for .ipynb -> .tex -> .pdf.
### charles at charlesledoux.com
### https://github.com/cledoux/pdflatex-makefile
###
### Recommended usage:
### 1. echo 'include Makefile-ipython.include' > Makefile
### 2. Optional: Edit the Makefile to override $(TARGET)
### and anything else (e.g., PDFVIEWER, TEMPLATE, AFTERALL)
###
### Final result:
### % cat Makefile
### TARGET=mynotebook
### PDFVIEWER=open -a 'Adobe Acrobat Professional'
### TEMPLATE=notebook_template.tplx
### AFTERALL=mypostprocessingstep
### include Makefile-ipython.include
###
### mypostprocessingstep:
### # do something...
###
NOTEBOOK=$(TARGET).ipynb
TEX=$(TARGET).tex
NBCONVERT_ARGS = --to=latex
ifneq ($(TEMPLATE),)
NBCONVERT_ARGS += --template=$(TEMPLATE)
endif
PDF_MAKE ?= Makefile.include
# The PDF make needs TARGET set as well
export TARGET
all: $(TEX)
$(MAKE) -f $(PDF_MAKE) all
view: $(TEX)
$(MAKE) -f $(PDF_MAKE) view
$(TEX): $(NOTEBOOK)
ipython nbconvert $(NBCONVERT_ARGS) $(NOTEBOOK)
clean:
$(MAKE) -f $(PDF_MAKE) clean
$(RM) -r $(TARGET)_files
$(RM) $(TEX)
# Look for any rules not found here in the parent.
# https://www.gnu.org/software/make/manual/html_node/Overriding-Makefiles.html
# I removed the force part because this was causing it to attempt to run
# commands Makefile and Makefile.include
%:
$(MAKE) -f $(PDF_MAKE) $@