summaryrefslogtreecommitdiff
path: root/Makefile
blob: b19ed1c287fba33ee4e7bbae7af246466f27d043 (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
##
# pacpur - A PUR helper that minimizes user interaction
##

VERSION = $(shell git describe --always | sed 's%-%.%g')

PREFIX = /usr/local

BINDIR = $(PREFIX)/bin
DATAROOTDIR = $(PREFIX)/share
DOCDIR = $(DATAROOTDIR)/doc/pacpur
MANPREFIX = $(DATAROOTDIR)/man
MSGFMT = $(shell command -v msgfmt 2>/dev/null)
POD2MAN = $(shell command -v pod2man 2>/dev/null)

LIBRARY = $(shell pkg-config --variable=libmakepkgdir libmakepkg)
ifeq ($(LIBRARY),)
	LIBRARY = $(DATAROOTDIR)/makepkg
endif

TRANSLATIONS = \
	ca \
	da \
	de \
	es \
	fi \
	fr \
	hu \
	it \
	ja \
	nb \
	nl \
	pl \
	pt \
	ru \
	sk \
	sl \
	sr \
	sr@latin \
	tr \
	zh_CN

# default target
all: doc

# documentation
doc:
ifneq ($(POD2MAN),)
	@echo "Generating documentation..."
	@pod2man -u -s 8 -c "Pacpur Manual" -n "PACPUR" -r "pacpur $(VERSION)" < ./README.pod > ./pacpur.8
endif

# aux
install: doc
	@echo "Installing..."
	@install -Dm644 ./config $(DESTDIR)$(DOCDIR)/config.example
	@sed -E "s%(declare -r version=).*%\1\'$(VERSION)\'%;s%/usr/share/makepkg%$(LIBRARY)%" ./pacpur | \
		install -Dm755 /dev/stdin $(DESTDIR)$(BINDIR)/pacpur
	@install -Dm644 ./completions/bash.completion $(DESTDIR)$(DATAROOTDIR)/bash-completion/completions/pacpur
	@install -Dm644 ./completions/zsh.completion $(DESTDIR)$(DATAROOTDIR)/zsh/site-functions/_pacpur
	@install -Dm644 ./LICENSE -t $(DESTDIR)$(DATAROOTDIR)/licenses/pacpur
ifneq ($(POD2MAN),)
	@install -Dm644 ./pacpur.8 -t $(DESTDIR)$(MANPREFIX)/man8
endif
ifneq ($(MSGFMT),)
	for i in $(TRANSLATIONS); do \
		mkdir -p "$(DESTDIR)$(DATAROOTDIR)/locale/$$i/LC_MESSAGES/"; \
		$(MSGFMT) ./po/$$i.po -o "$(DESTDIR)$(DATAROOTDIR)/locale/$$i/LC_MESSAGES/pacpur.mo"; \
	done
endif

uninstall:
	@echo "Uninstalling..."
	@$(RM) $(DESTDIR)$(DOCDIR)/config.example
	@$(RM) $(DESTDIR)$(BINDIR)/pacpur
	@$(RM) $(DESTDIR)$(DATAROOTDIR)/bash-completion/completions/pacpur
	@$(RM) $(DESTDIR)$(DATAROOTDIR)/zsh/site-functions/_pacpur
	@$(RM) $(DESTDIR)$(DATAROOTDIR)/licenses/pacpur/LICENSE
	@$(RM) $(DESTDIR)$(MANPREFIX)/man8/pacpur.8
	@for i in $(TRANSLATIONS); do \
		$(RM) "$(DESTDIR)$(DATAROOTDIR)/locale/$$i/LC_MESSAGES/pacpur.mo"; \
	done

clean:
	@echo "Cleaning..."
	@$(RM) ./pacpur.8

.PHONY: doc install uninstall clean