summaryrefslogtreecommitdiff
path: root/Makefile
blob: 68a300c338efb3b14fa7a7c49138d540eec0fbda (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
# 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/mkocrtxt.sh

BIN = $(SRC:.c=)
MAN = $(SRC:.c=.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 -c $@ $(LIB)
	@ranlib $@

install: all
	mkdir -p $(DESTDIR)$(PREFIX)/bin
	cp -f $(BIN) $(GUI) $(DESTDIR)$(PREFIX)/bin
	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)
	cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)

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

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

# quick and dirty; a real debian dev should create a real .deb
dist-deb:
	mkdir -p deb
	cp config.mk config.mk.orig
	sed 's/^PREFIX =.*/PREFIX = deb\/usr/g' < config.mk.orig > config.mk
	make install
	mv config.mk.orig config.mk
	cp $(EXTRAS) deb/usr/bin/
	chmod +x deb/usr/bin/*
	mkdir -p deb/usr/share/doc/$(NAME)
	cp $(DOC) deb/usr/share/doc/$(NAME)
	mv deb/usr/share/doc/$(NAME)/COPYING deb/usr/share/doc/$(NAME)/copyright
	mkdir -p deb/DEBIAN
	printf "Package: %s\nVersion: %s-1\nArchitecture: i386\nDepends: libc6, tcl, tk\n" "$(NAME)" "$(VERSION)" > deb/DEBIAN/control
	fakeroot dpkg-deb --build deb
	mv deb.deb $(NAME)_$(VERSION)-1_i386.deb
	rm -rf deb
	echo $(NAME)_$(VERSION)-1_i386.deb

getxbookgui.exe: getxbookgui.tcl
	@echo STARPACK $@
	@sdx qwrap getxbookgui.tcl
	@sdx unwrap getxbookgui.kit
	@sdx wrap $@ -runtime $(W32TCLKIT)
	@rm -r getxbookgui.kit getxbookgui.vfs

getxbookgui: getxbookgui.tcl
	@echo STARPACK $@
	@sdx qwrap getxbookgui.tcl
	@sdx unwrap getxbookgui.kit
	@sdx wrap $@ -runtime $(MACTCLKIT)
	@rm -r getxbookgui.kit getxbookgui.vfs

# needs to be run from a mingw setup
dist-win: $(BIN) $(GUI:.tcl=.exe)
	mkdir -p $(NAME)-win
	cp $(OBJ:.o=.exe) $(GUI:.tcl=.exe) $(NAME)-win
	for f in LEGAL README COPYING; do \
	sed 's/$$/\r/g' < $$f > $(NAME)-win/$$f.txt; done
	zip -j $(NAME)-$(VERSION)-win.zip $(NAME)-win/*
	gpg -b < $(NAME)-$(VERSION)-win.zip > $(NAME)-$(VERSION)-win.zip.sig
	rm -rf $(NAME)-win
	echo $(NAME)-$(VERSION)-win.zip $(NAME)-$(VERSION)-win.zip.sig

# needs to be run from a mac
dist-mac: $(BIN) $(GUI:.tcl=)
	mkdir -p $(NAME)-$(VERSION)/$(NAME).app/Contents/MacOS
	mkdir -p $(NAME)-$(VERSION)/$(NAME).app/Contents/Resources
	cp $(BIN) $(GUI:.tcl=) $(NAME)-$(VERSION)/$(NAME).app/Contents/MacOS/
	for f in $(DOC); do cp $$f $(NAME)-$(VERSION)/$$f.txt; done
	echo '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundlePackageType</key><string>APPL</string>'"<key>CFBundleExecutable</key><string>getxbookgui</string><key>CFBundleVersion</key><string>$(VERSION)</string><key>CFBundleName</key><string>$(NAME)</string></dict></plist>" > $(NAME)-$(VERSION)/$(NAME).app/Contents/Info.plist
	hdiutil create -srcfolder $(NAME) $(NAME)-$(VERSION).dmg
	hdiutil internet-enable -yes $(NAME)-$(VERSION).dmg
	gpg -b < $(NAME)-$(VERSION)-mac.dmg > $(NAME)-$(VERSION)-mac.dmg.sig
	rm -rf $(NAME)-$(VERSION)
	echo $(NAME)-$(VERSION)-mac.dmg $(NAME)-$(VERSION)-mac.dmg.sig

index.html: doap.ttl README
	echo making 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 "</style></head><body>" >> $@
	smu < README >> $@
	echo "<h2>download</h2>" >> $@
	echo "[$(NAME) $(VERSION) source]($(NAME)-$(VERSION).tar.bz2) ([sig]($(NAME)-$(VERSION).tar.bz2.sig)) ($(RELDATE))" | smu >> $@
	echo "[$(NAME) $(VERSION) windows]($(NAME)-$(VERSION)-win.zip) ([sig]($(NAME)-$(VERSION)-win.zip.sig)) ($(RELDATE))" | smu >> $@
	echo "[$(NAME) $(VERSION) mac]($(NAME)-$(VERSION)-mac.dmg) ([sig]($(NAME)-$(VERSION)-mac.dmg.sig)) ($(RELDATE))" | smu >> $@
	echo '<hr />' >> $@
	sh websummary.sh doap.ttl | smu >> $@
	echo '</body></html>' >> $@

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