-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.mk
More file actions
146 lines (124 loc) · 4.64 KB
/
Copy pathinclude.mk
File metadata and controls
146 lines (124 loc) · 4.64 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
IMG=images
ZIPDIR=zipdir
ZIPCACHEDIR=$(ZIPDIR)/$(PROJECT)
BOOKSDIR=ebooks
TXT=$(PROJECT)-utf8.txt
HTML=$(PROJECT).html
# legacy
PPGEN_SRC=$(PROJECT)-src.txt
PPGEN=$(HOME)/dp/ppgen/ppgen.py
PPGEN_PY=python3.11
EBOOKMAKER_URL=https://ebookmaker.pglaf.org
# Default book ID, taken from the form at PGLAF's ebookmaker
# Can be overridden at runtime with 'id' parameter
DEFAULT_BOOK_ID = 10001
book_id ?= $(DEFAULT_BOOK_ID)
# App name (for "open" command) for text viewer
TEXTVIEWPROG=Visual Studio Code
# App name (for "open" command) for HTML viewer
HTMLVIEWPROG=Safari
default:
@echo "make zip: create zipfile (PPtools, PPwb, DU, ebookmaker)"
@echo "make sr: create zip file to submit to SR (incl. ebooks/)"
@echo ""
@echo "make vt: open UTF8 text file in viewer"
@echo "make vh: open HTML file in viewer"
@echo "make view: open both UTF8 text and HTML versions in viewers"
@echo "make serve: start a python3 web server on port 8000"
@echo " (handy for e.g. iPhone Simulator on Mac)"
@echo ""
@echo "make ebooksget: fetch ebooks from PGLAF ebookmaker"
@echo ""
@echo " -- you MUST specify the cache ID"
@echo " ex: make ebooksget cache=20220507205607"
@echo ""
@echo " -- you MAY specify an ebook ID (default: $(DEFAULT_BOOK_ID))"
@echo " ex: make ebooksget cache=20220507205607 book_id=1234"
@echo ""
@echo "make legacy: show list of legacy make targets"
legacy:
@echo "These legacy targets are included for backward compatibility"
@echo "with ppgen, or else as examples."
@echo ""
@echo "make ppv: create zip file to submit to PPV"
@echo "make ppgen: output UTF8 text & HTML files from ppgen source"
# View text
vt:
open -a "$(TEXTVIEWPROG)" $(TXT)
# View HTML
vh:
open -a "$(HTMLVIEWPROG)" $(HTML)
# View both text & HTML files
view: vt vh
# Start a Python3 web server on localhost:8000.
#
# This can be useful when you want to use a viewer such as the
# iPhone Simulator, which can speak to the network, but can't
# access the Mac filesystem. It may be useful for simulators
# on other platforms as well.
serve:
@echo ""
@echo " **************************************************"
@echo " *** Starting server on http://localhost:8000 ***"
@echo " *** Press Ctrl-C to terminate. ***"
@echo " **************************************************"
@echo ""
python3 -m http.server
# Smooth Readers can also include ebooks. Anything in the ebooks/
# directory will get sucked into this.
sr:
rm -f $(ZIPDIR)/$(PROJECT)-sr.zip
rm -rf $(ZIPCACHEDIR)
mkdir -p $(ZIPCACHEDIR)/$(IMG)/
cp $(TXT) $(HTML) $(ZIPCACHEDIR)
cp -r $(IMG)/ $(ZIPCACHEDIR)/$(IMG)/
rm -rf $(ZIPCACHEDIR)/$(IMG)/{.DS_Store,*.pxd,*.xcf}
cp -r $(BOOKSDIR)/ $(ZIPCACHEDIR)/
rm -f $(ZIPCACHEDIR)/{.DS_Store,output.txt}
cd $(ZIPCACHEDIR) && zip -r ../$(PROJECT)-sr.zip .
# Zip file suitable for:
# - PP workbench
# - PPtools
# - ebookmaker online
# - Direct Upload
# What to include in a zip file for PG direct upload:
# - a single zip file containing all files
# - do not include any .bin or Thumbs.db files
# - verify there are no restricted permissions on the files or directories
zip:
rm -f $(ZIPDIR)/$(PROJECT).zip
rm -rf $(ZIPCACHEDIR)
mkdir -p $(ZIPCACHEDIR)/$(IMG)/
cp $(TXT) $(HTML) $(ZIPCACHEDIR)
cp -r $(IMG)/ $(ZIPCACHEDIR)/$(IMG)/
rm -rf $(ZIPCACHEDIR)/$(IMG)/{.DS_Store,*.pxd,*.xcf}
cd $(ZIPCACHEDIR) && zip -r ../$(PROJECT).zip .
ebooksdir:
mkdir -p $(BOOKSDIR)
ebooksget: ebooksdir
ifndef cache
@echo 'Missing param: "cache" not defined'
else
curl -s -o $(BOOKSDIR)/output.txt $(EBOOKMAKER_URL)/cache/$(cache)/output.txt
curl -s -o $(BOOKSDIR)/$(PROJECT)-images.mobi $(EBOOKMAKER_URL)/cache/$(cache)/$(book_id)-images.mobi
curl -s -o $(BOOKSDIR)/$(PROJECT)-epub.epub $(EBOOKMAKER_URL)/cache/$(cache)/$(book_id)-epub.epub
curl -s -o $(BOOKSDIR)/$(PROJECT)-images-epub.epub $(EBOOKMAKER_URL)/cache/$(cache)/$(book_id)-images-epub.epub
curl -s -o $(BOOKSDIR)/$(PROJECT)-images-epub3.epub $(EBOOKMAKER_URL)/cache/$(cache)/$(book_id)-images-epub3.epub
@ls -ltr $(BOOKSDIR)
endif
# Per PPV, the zip should have files at the root, not contain
# a directory which then contains the files. -April 2022
# PPV should include the .bin files.
ppv:
rm -f $(ZIPDIR)/$(PROJECT)-ppv.zip
rm -rf $(ZIPCACHEDIR)
mkdir -p $(ZIPCACHEDIR)/$(IMG)/
cp $(TXT) $(TXT).bin $(HTML) $(HTML).bin $(ZIPCACHEDIR)
cp -r $(IMG)/ $(ZIPCACHEDIR)/$(IMG)/
rm -rf $(ZIPCACHEDIR)/$(IMG)/{.DS_Store,*.pxd,*.xcf}
cd $(ZIPCACHEDIR) && zip -r ../$(PROJECT)-ppv.zip .
$(TXT): $(PPGEN_SRC)
$(PPGEN_PY) $(PPGEN) -i $(PPGEN_SRC) -o u
$(HTML): $(PPGEN_SRC)
$(PPGEN_PY) $(PPGEN) -i $(PPGEN_SRC) -o h -img
ppgen: $(TXT) $(HTML)