summaryrefslogtreecommitdiff
path: root/Makefile
blob: 90d1241a9bc04b2d40ee64e534c9a32fbad56e04 (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
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
147
148
149
150
151
152
153
154
# See COPYING file for copyright and license details.
include config.mk

NAME = getxbook

SRC = getgbook.c getabook.c getbnbook.c
LIB = util.o
GUI = getxbookgui.tcl
DOC = README COPYING INSTALL LEGAL
EXTRAS = extras/mkpdf.sh extras/mkocrpdf.sh extras/mkdjvu.sh extras/mkocrtxt.sh extras/mkocrdjvu.sh

BIN = $(SRC:.c=)
MAN = $(SRC:.c=.1) $(GUI:.tcl=.1) $(NAME).1
OBJ = $(SRC:.c=.o) $(LIB)

all: $(BIN)

$(OBJ): util.h config.mk
$(BIN): util.a

.o:
	@echo LD $@
	@$(LD) -o $@ $< util.a $(LDFLAGS)

.c.o:
	@echo CC $<
	@$(CC) -c $(CFLAGS) $<

util.a: $(LIB)
	@echo AR $@
	@$(AR) -r -s -c $@ $(LIB)

install: all
	mkdir -p $(DESTDIR)$(PREFIX)/bin
	cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
	sed "s:^set iconpath .*:set iconpath \"$(PREFIX)/share/pixmaps\":" < $(GUI) \
	    > $(DESTDIR)$(PREFIX)/bin/$(GUI:.tcl=)
	chmod +x $(DESTDIR)$(PREFIX)/bin/getxbookgui
	mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps
	cp icons/* $(DESTDIR)$(PREFIX)/share/pixmaps/
	mkdir -p $(DESTDIR)$(MANPREFIX)/man1
	for f in $(MAN); do sed "s/VERSION/$(VERSION)/g" < $$f > $(DESTDIR)$(MANPREFIX)/man1/$$f; done

uninstall:
	cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN) $(GUI:.tcl=)
	cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
	rm -rf $(DESTDIR)$(PREFIX)/share/$(NAME)

clean:
	rm -f -- $(BIN) $(OBJ) util.a index.html comparison.html

dist:
	mkdir -p $(NAME)-$(VERSION)
	cp $(SRC) $(GUI) $(DOC) $(MAN) util.h util.c Makefile config.mk $(NAME)-$(VERSION)
	mkdir -p $(NAME)-$(VERSION)/icons
	cp icons/* $(NAME)-$(VERSION)/icons/
	mkdir -p $(NAME)-$(VERSION)/extras
	cp $(EXTRAS) $(NAME)-$(VERSION)/extras/
	tar c $(NAME)-$(VERSION) | xz > $(NAME)-$(VERSION).tar.xz
	gpg -b < $(NAME)-$(VERSION).tar.xz > $(NAME)-$(VERSION).tar.xz.sig
	rm -rf $(NAME)-$(VERSION)
	echo $(NAME)-$(VERSION).tar.xz $(NAME)-$(VERSION).tar.xz.sig

# needs config.mk set up to build statically
dist-static: $(BIN)
	mkdir -p $(NAME)-$(VERSION)
	sed '/^\tset cmd / i set cmdbin [file join ./ $$cmdbin]' < getxbookgui.tcl > $(NAME)-$(VERSION)/getxbookgui.tcl
	cp $(BIN) $(DOC) $(MAN) config.mk $(NAME)-$(VERSION)
	sed 's/^install: all$$/install:/' < Makefile > $(NAME)-$(VERSION)/Makefile
	mkdir -p $(NAME)-$(VERSION)/icons
	cp icons/* $(NAME)-$(VERSION)/icons/
	mkdir -p $(NAME)-$(VERSION)/extras
	cp $(EXTRAS) $(NAME)-$(VERSION)/extras/
	tar c $(NAME)-$(VERSION) | xz > $(NAME)-$(VERSION)-static.tar.xz
	gpg -b < $(NAME)-$(VERSION)-static.tar.xz > $(NAME)-$(VERSION)-static.tar.xz
	rm -rf $(NAME)-$(VERSION)
	echo $(NAME)-$(VERSION)-static.tar.xz $(NAME)-$(VERSION)-static.tar.xz.sig

# builds a basic .deb package
dist-deb:
	debian/rules clean
	fakeroot debian/rules binary

# builds package and debian support files (.sig etc)
dist-debpkg:
	dpkg-buildpackage

getxbookgui.exe: getxbookgui.tcl
	echo STARPACK $@
	sed 's/ icons/ .. icons/' < getxbookgui.tcl > getxbookgui-win.tcl
	sed -i '/^\tset cmd / i set cmdbin [file join tools $$cmdbin]' getxbookgui-win.tcl
	sdx qwrap getxbookgui-win.tcl getxbookgui
	sdx unwrap getxbookgui.kit
	cp -f getxbook.ico getxbookgui.vfs/tclkit.ico
	echo 'FileDescription "Book downloader"' > getxbookgui.vfs/tclkit.inf
	sdx wrap $@ -runtime $(W32TCLKIT)
	rm -r getxbookgui-win.tcl getxbookgui.kit getxbookgui.vfs

# needs config.mk set up to use mingw
dist-win: $(BIN) $(GUI:.tcl=.exe)
	mkdir -p $(NAME)-win/tools
	cp $(GUI:.tcl=.exe) $(NAME)-win
	for f in $(BIN); do cp $$f.exe $(NAME)-win/tools/$$f.exe; done
	mkdir -p $(NAME)-win/icons
	cp icons/* $(NAME)-win/icons/
	for f in LEGAL README COPYING; do \
	sed 's/$$/\r/g' < $$f > $(NAME)-win/$$f.txt; done
	for f in *1; do \
	b=`basename $$f .1`; \
	groff -m man -T utf8 < $$f | col -bx | sed 's/$$/\r/g' > $(NAME)-win/tools/$$b.txt; done
	mv $(NAME)-win/tools/getxbookgui.txt $(NAME)-win/
	cd $(NAME)-win; zip -r ../$(NAME)-$(VERSION)-win.zip .;cd ..
	rm -rf $(NAME)-win
	echo $(NAME)-$(VERSION)-win.zip $(NAME)-$(VERSION)-win.zip.sig

index.html: doap.ttl README
	echo making webpage
	echo '<?xml version="1.0" encoding="UTF-8"?>' > $@
	echo "<!DOCTYPE html><html><head><title>$(NAME)</title>" >> $@
	echo '<link rel="alternate" type="text/turtle" title="rdf" href="doap.ttl" />' >> $@
	echo '<style type="text/css">' >> $@
	echo "body {font-family:sans-serif; width:38em; margin:auto; max-width:94%;}" >> $@
	echo "h1 {font-size:1.6em; text-align:center;}" >> $@
	echo "a {text-decoration:none; border-bottom:thin dotted;}" >> $@
	echo "img {margin: auto; border: thin solid; display: block;}" >> $@
	echo "</style></head><body>" >> $@
	sed '5q' < README | smu >> $@
	echo '<p><img src="screenshot1.png" alt="screenshot"/></p>' >> $@
	echo "<h2>download</h2>" >> $@
	echo "[$(NAME) $(VERSION) source]($(NAME)-$(VERSION).tar.xz) ([sig]($(NAME)-$(VERSION).tar.xz.sig)) ($(RELDATE))" | smu >> $@
	echo "[$(NAME) $(VERSION) linux static]($(NAME)-$(VERSION)-static.tar.xz) ([sig]($(NAME)-$(VERSION)-static.tar.xz.sig)) ($(RELDATE))" | smu >> $@
	echo "$(NAME) for mac os x [available from Homebrew](http://brew.sh/)" | smu >> $@
	echo "[$(NAME) $(VERSION) windows]($(NAME)-$(VERSION)-win.zip) ([sig]($(NAME)-$(VERSION)-win.zip.sig)) ($(RELDATE))" | smu >> $@
	sed '1,5d' < README | smu >> $@
	echo "[comparison with similar programs](comparison)" | smu >> $@
	echo '<hr />' >> $@
	sh websummary.sh doap.ttl | smu >> $@
	echo '</body></html>' >> $@

comparison.html: comparison.txt
	echo making comparison webpage
	echo "<!DOCTYPE html><html><head><title>$(NAME)</title>" > $@
	echo '<link rel="alternate" type="text/turtle" title="rdf" href="doap.ttl" />' >> $@
	echo '<style type="text/css">' >> $@
	echo "body {font-family:sans-serif; width:38em; margin:auto; max-width:94%;}" >> $@
	echo "h1 {font-size:1.6em; text-align:center;}" >> $@
	echo "a {text-decoration:none; border-bottom:thin dotted;}" >> $@
	echo "img {margin: auto; border: thin solid; display: block;}" >> $@
	echo "</style></head><body>" >> $@
	smu < comparison.txt >> $@
	echo '</body></html>' >> $@

.PHONY: all clean install uninstall dist dist-win dist-deb dist-debpkg
.SILENT: index.html comparison.html dist