-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (47 loc) · 1.73 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
# This file is part of clipsync (C)2023 by Marco Paganini
# Please see http://github.com/marcopaganini/clipsync for details.
.PHONY: appimage arch clean install install-appimage
bin := clipsync
bindir := /usr/local/bin
appdir := ./AppDir
archdir := arch
src := $(wildcard *.go)
git_tag := $(shell git describe --always --tags)
# Default target
${bin}: Makefile ${src}
go build -v -ldflags "-X main.BuildVersion=${git_tag}" -o "${bin}"
clean:
rm -f "${bin}"
rm -f "docs/${bin}.1"
rm -rf "${appdir}"
rm -rf "${archdir}"
rm -f *.AppImage
install: ${bin}
install -m 755 "${bin}" "${bindir}"
appimage: ${bin}
rm -rf "${appdir}"
export VERSION="$$(git describe --exact-match --tags 2>/dev/null || git rev-parse --short HEAD)"; \
linuxdeploy-x86_64.AppImage \
--appdir AppDir \
-e ${bin} \
-i resources/${bin}.png \
--create-desktop-file \
--output appimage
install-appimage: appimage
export VERSION="$$(git describe --exact-match --tags 2>/dev/null || git rev-parse --short HEAD)"; \
export APPIMAGE="${bin}-$${VERSION}-x86_64.AppImage"; \
install -m 755 "$${APPIMAGE}" "${bindir}/${bin}"
# Creates cross-compiled tarred versions (for releases).
arch: Makefile ${src}
for ga in "linux/amd64"; do \
export GOOS="$${ga%/*}"; \
export GOARCH="$${ga#*/}"; \
dst="./${archdir}/$${GOOS}-$${GOARCH}"; \
mkdir -p "$${dst}"; \
echo "=== Building $${GOOS}/$${GOARCH} ==="; \
go build -v -ldflags "-X main.Build=${git_tag}" -o "$${dst}/${bin}"; \
[ -s LICENSE ] && install -m 644 LICENSE "$${dst}"; \
[ -s README.md ] && install -m 644 README.md "$${dst}"; \
[ -s docs/${bin}.1 ] && install -m 644 docs/${bin}.1 "$${dst}"; \
tar -C "${archdir}" -zcvf "${archdir}/${bin}-$${GOOS}-$${GOARCH}.tar.gz" "$${dst##*/}"; \
done