-
-
Notifications
You must be signed in to change notification settings - Fork 141
/
Makefile
55 lines (45 loc) · 1.54 KB
/
Makefile
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
.PHONY: clean install install-doc
PROJECT ?= algernon
GOBUILD := go build -mod=vendor -v
# macOS and FreeBSD detection
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PREFIX ?= /usr/local
MAKE ?= make
else ifeq ($(UNAME_S),FreeBSD)
PREFIX ?= /usr/local
MAKE ?= gmake
else
PREFIX ?= /usr
MAKE ?= make
endif
MANDIR ?= $(PREFIX)/share/man/man1
UNAME_R ?= $(shell uname -r)
ifneq (,$(findstring arch,$(UNAME_R)))
# Arch Linux
LDFLAGS ?= -Wl,-O2,--sort-common,--as-needed,-z,relro,-z,now
BUILDFLAGS ?= -mod=vendor -buildmode=pie -trimpath -ldflags "-s -w -linkmode=external -extldflags $(LDFLAGS)"
else
# Default settings
BUILDFLAGS ?= -mod=vendor -trimpath
endif
algernon:
$(GOBUILD) $(BUILDFLAGS)
algernon.1.gz: algernon.1
gzip -f -k -v algernon.1
install: algernon desktop/mdview
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
install -m755 algernon "$(DESTDIR)$(PREFIX)/bin/algernon"
install -m755 desktop/mdview "$(DESTDIR)$(PREFIX)/bin/mdview"
install-doc: algernon.1.gz welcome.sh samples README.md
mkdir -p "$(DESTDIR)$(MANDIR)"
install -m644 algernon.1.gz "$(DESTDIR)$(MANDIR)/algernon.1.gz"
mkdir -p "$(DESTDIR)$(PREFIX)/usr/share/algernon"
cp -r samples "$(DESTDIR)$(PREFIX)/usr/share/algernon"
sed 's/\.\/algernon/algernon/g' welcome.sh > welcome_install.sh
install -m755 welcome_install.sh "$(DESTDIR)$(PREFIX)/usr/share/algernon/welcome.sh"
rm -f welcome_install.sh
mkdir -p "$(DESTDIR)$(PREFIX)/usr/share/doc/algernon"
install -Dm644 README.md "$(DESTDIR)$(PREFIX)/usr/share/doc/algernon/README.md"
clean:
rm -f algernon algernon.1.gz