-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.in
89 lines (73 loc) · 2.75 KB
/
Makefile.in
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
# Configuration options
VERSION := %version%
DATE := $(shell date)
CONFIGDIR := %configdir%
CONFIGFILE := %configfile%
LOCALEDIR := %localedir%
DOMAIN := %domain%
ORGANIZATION := %organization%
USER := %user%
PASSWORD := %password%
DESTDIR ?=
WD = build
# Flags associated to the configuration
cflag = $(if $(1),-X "github.com/bvaudour/kcp/common.$(2)=$(1)",)
LDFLAGS := $(call cflag,$(VERSION),Version)
LDFLAGS += $(call cflag,$(DATE),BuildTime)
LDFLAGS += $(call cflag,$(CONFIGDIR),ConfigBaseDir)
LDFLAGS += $(call cflag,$(CONFIGFILE),ConfigFile)
LDFLAGS += $(call cflag,$(LOCALEDIR),LocaleBaseDir)
LDFLAGS += $(call cflag,$(DOMAIN),LocaleDomain)
LDFLAGS += $(call cflag,$(ORGANIZATION),Organization)
LDFLAGS += $(call cflag,$(USER),User)
LDFLAGS += $(call cflag,$(PASSWORD),Password)
# Go build variables
GOFLAGS := -v -trimpath -mod=readonly -modcacherw
GOCMD := go build $(GOFLAGS) -ldflags='-s -w $(LDFLAGS)'
BINARIES := kcp \
pckcp
# Locale build variables
LOCALESRCDIR := resources/i18n
POFILES := $(wildcard $(LOCALESRCDIR)/*.po)
LANGS := $(notdir $(basename $(POFILES)))
MOFILES := $(addprefix $(WD)/,$(addsuffix .mo,$(LANGS)))
# Working directory
.PHONY: default build install clean gobuild uninstall
default: build
preparebuild:
mkdir -p $(WD)
${WD}/%.mo: ${LOCALESRCDIR}/%.po
msgfmt $< -o $@
gobuild:
for b in $(BINARIES); do \
$(GOCMD) -o $(WD)/$${b} ./cmd/$${b}; \
done
clean:
rm -rf $(WD)
build: preparebuild gobuild $(MOFILES)
install: build
for b in $(BINARIES); do \
install -Dm755 $(WD)/$${b} $(DESTDIR)/usr/bin/$${b}; \
install -Dm644 resources/man/$${b}.1 $(DESTDIR)/usr/share/man1/$${b}.1; \
done
for l in $(LANGS); do \
install -Dm644 $(WD)/$${l}.mo $(DESTDIR)$(LOCALEDIR)/$${l}/LC_MESSAGES/$(DOMAIN).mo; \
done
install -Dm644 resources/completion/kcp.bash $(DESTDIR)/etc/bash-completion.d/kcp
install -Dm644 resources/completion/kcp.zsh $(DESTDIR)/usr/share/zsh/site-functions/_kcp
install -Dm644 resources/completion/kcp.fish $(DESTDIR)/usr/share/fish/vendor_completions.d/kcp.fish
install -Dm644 resources/conf/kcp.conf $(DESTDIR)$(CONFIGDIR)/$(CONFIGFILE)
install -Dm644 resources/conf/exceptions $(DESTDIR)$(CONFIGDIR)/exceptions
install -Dm644 resources/conf/PKGBUILD.commented.kaos.proto $(DESTDIR)$(CONFIGDIR)/PKGBUILD.commented.kaos.proto
uninstall:
for b in $(BINARIES); do \
rm -f $(DESTDIR)/usr/bin/$${b}; \
rm -f $(DESTDIR)/usr/share/man1/$${b}.1; \
done
for l in $(LANGS); do \
rm -f $(DESTDIR)$(LOCALEDIR)/$${l}/LC_MESSAGES/$(DOMAIN).mo; \
done
rm -f $(DESTDIR)/etc/bash-completion.d/kcp
rm -f $(DESTDIR)/usr/share/zsh/site-functions/_kcp
rm -f $(DESTDIR)/usr/share/fish/vendor_completions.d/kcp.fish
rm -rf $(DESTDIR)$(CONFIGDIR)