summaryrefslogtreecommitdiff
path: root/Makefile
blob: 47ebced967c7d68e819e231c0932125c6a2f1d7b (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
#
#  Keyringer Makefile by Silvio Rhatto (rhatto at riseup.net).
#
#  This Makefile is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 3 of the License, or any later version.
#
#  This Makefile is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along with
#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
#  Place - Suite 330, Boston, MA 02111-1307, USA
#

PACKAGE  = keyringer
VERSION  = $(shell ./keyringer | head -n 1 | cut -d ' ' -f 2)
PREFIX  ?= /usr/local
MANDIR	?=$(PREFIX)/share/man
ARCHIVE ?= tarballs
INSTALL  = /usr/bin/install

.PHONY: clean install_lib install_bin install_doc install_man install_completion install build_man tarball release debian web web_deploy uninstall

clean:
	find . -name *~ | xargs rm -f # clean local backups

install_lib:
	$(INSTALL) -D -m 0755 lib/keyringer/functions $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/functions
	$(INSTALL) -D -m 0755 -d lib/keyringer/actions $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/actions
	$(INSTALL) -D -m 0755 lib/keyringer/actions/* $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/actions
	$(INSTALL) -D -m 0755 -d share/keyringer/editors $(DESTDIR)/$(PREFIX)/share/$(PACKAGE)/editors
	$(INSTALL) -D -m 0644 share/keyringer/editors/* $(DESTDIR)/$(PREFIX)/share/$(PACKAGE)/editors

uninstall_lib:
	rm -f $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/functions
	rm -f $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/actions/*
	rmdir $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE)/actions 2> /dev/null || true
	rmdir $(DESTDIR)/$(PREFIX)/lib/$(PACKAGE) 2> /dev/null || true
	rm -f $(DESTDIR)/$(PREFIX)/share/$(PACKAGE)/editors/*
	rmdir $(DESTDIR)/$(PREFIX)/share/$(PACKAGE)/editors 2> /dev/null || true
	rmdir $(DESTDIR)/$(PREFIX)/share/$(PACKAGE) 2> /dev/null || true
	rmdir -p $(DESTDIR)/$(PREFIX)/lib 2>/dev/null || true

install_bin:
	$(INSTALL) -D -m 0755 keyringer $(DESTDIR)/$(PREFIX)/bin/keyringer

uninstall_bin:
	rm -f $(DESTDIR)/$(PREFIX)/bin/keyringer
	rmdir -p $(DESTDIR)/$(PREFIX)/bin 2>/dev/null || true

install_doc:
	$(INSTALL) -D -m 0644 index.md $(DESTDIR)/$(PREFIX)/share/doc/$(PACKAGE)/README.md
	$(INSTALL) -D -m 0644 LICENSE $(DESTDIR)/$(PREFIX)/share/doc/$(PACKAGE)/LICENSE

uninstall_doc:
	rm -f $(DESTDIR)/$(PREFIX)/share/doc/$(PACKAGE)/LICENSE
	rm -f $(DESTDIR)/$(PREFIX)/share/doc/$(PACKAGE)/README.md
	rmdir $(DESTDIR)/$(PREFIX)/share/doc/$(PACKAGE) 2>/dev/null || true
	rmdir $(DESTDIR)/$(PREFIX)/share/doc 2>/dev/null || true

install_man:
	$(INSTALL) -D -m 0644 share/man/keyringer.1 $(DESTDIR)/$(MANDIR)/man1/keyringer.1

uninstall_man:
	rm -f $(DESTDIR)/$(PREFIX)/share/man/man1/keyringer.1
	rmdir -p $(DESTDIR)/$(PREFIX)/share/man/man1 2> /dev/null || true

install_completion:
	$(INSTALL) -D -m 0644 lib/keyringer/completions/bash/keyringer $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/keyringer
	$(INSTALL) -D -m 0644 lib/keyringer/completions/zsh/_keyringer $(DESTDIR)/$(PREFIX)/share/zsh/site-functions/_keyringer

uninstall_completion:
	rm -f $(DESTDIR)/$(PREFIX)/share/zsh/site-functions/_keyringer
	rm -f $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/keyringer
	rmdir -p $(DESTDIR)/$(PREFIX)/share/zsh/site-functions 2> /dev/null || true
	rmdir -p $(DESTDIR)/$(PREFIX)/share/bash-completion/completions 2> /dev/null || true

install: clean
	@make install_lib install_bin install_doc install_man install_completion

uninstall: uninstall_completion uninstall_man uninstall_doc uninstall_bin uninstall_lib
	rmdir -p $(DESTDIR)/$(PREFIX)/share 2>/dev/null || true

build_man:
	# Pipe output to sed to avoid http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html
	# Fixed in http://johnmacfarlane.net/pandoc/releases.html#pandoc-1.10-2013-01-19
	pandoc -s -w man share/man/keyringer.1.md -o share/man/keyringer.1
	sed -i -e 's/--/\\-\\-/g' share/man/keyringer.1

tarball:
	mkdir -p $(ARCHIVE)
	git archive --prefix=keyringer-$(VERSION)/ --format=tar HEAD | bzip2 > $(ARCHIVE)/keyringer-$(VERSION).tar.bz2

release:
	@make build_man
	git commit -a -m "Keyringer $(VERSION)"
	# See https://github.com/nvie/gitflow/issues/87
	#     https://github.com/nvie/gitflow/pull/160
	#     https://github.com/nvie/gitflow/issues/50
	#git flow release finish -s -m "Keyringer $(VERSION)" $(VERSION)
	#git flow release finish -s $(VERSION)
	git checkout master
	git merge develop
	@make tarball
	gpg --use-agent --armor --detach-sign --output $(ARCHIVE)/keyringer-$(VERSION).tar.bz2.asc $(ARCHIVE)/keyringer-$(VERSION).tar.bz2
	scp $(ARCHIVE)/keyringer-$(VERSION).tar.bz2* keyringer:/var/sites/keyringer/releases/
	# We're doing tagging afterwards:
	# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568375
	#git tag -s $(VERSION) -m "Keyringer $(VERSION)"
	git checkout develop

debian:
	git checkout debian
	# Setup a temporary .gitignore to allow "gbp import-orig" to work without issues
	# This .gitignore will be removed by "gbp import-orig" anyway, but it allow it to run without complaining of untracked files
	git checkout develop .gitignore
	git add .gitignore
	git commit -m 'Chore: set a temporary .gitignore so "gbp import-origin" does not complain'
	gbp import-orig --upstream-vcs-tag=$(VERSION) $(ARCHIVE)/keyringer-$(VERSION).tar.bz2
	# Fine tune debian/changelog prepared by git-dch
	dch -e
	git commit -a -m "Updating debian/changelog"
	gbp buildpackage --git-tag-only --git-sign-tags --git-ignore-new

web:
	@ikiwiki --setup ikiwiki.yaml

web_deploy:
	@rsync -avz --delete www/ blog:/var/sites/keyringer/www/

publish: web web_deploy