-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
51 lines (42 loc) · 1.58 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
HASH := $(shell git rev-parse --short HEAD)
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} (${COMMIT_DATE})
BUILDDIR ?= .
SRCDIR ?= .
.PHONY: help
help:
@echo "make [TARGETS...]"
@echo
@echo "This is the maintenance makefile of photon-mgmtd. The following"
@echo "targets are available:"
@echo
@echo " help: Print this usage information."
@echo " build: Builds project"
@echo " install: Installs binary, configuration and unit files"
@echo " clean: Cleans the build"
$(BUILDDIR)/:
mkdir -p "$@"
$(BUILDDIR)/%/:
mkdir -p "$@"
.PHONY: build
build:
- mkdir -p bin
go build -buildmode=pie -ldflags="-w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -o bin/photon-mgmtd ./cmd/photon-mgmt
go build -buildmode=pie -ldflags="-w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -o bin/pmctl ./cmd/pmctl
go build -buildmode=pie -ldflags="-w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -o bin/jwtctl ./cmd/jwtctl
.PHONY: install
install:
- mkdir -p $(DESTDIR)/usr/bin/
install bin/photon-mgmtd $(DESTDIR)/usr/bin/
install bin/pmctl $(DESTDIR)/usr/bin/
install bin/jwtctl $(DESTDIR)/usr/bin/
- mkdir -p $(DESTDIR)/etc/photon-mgmt
install -vdm 755 $(DESTDIR)/etc/photon-mgmt
install -m 755 distribution/mgmt.toml $(DESTDIR)/etc/photon-mgmt
install -m 0644 distribution/photon-mgmtd.service $(DESTDIR)/lib/systemd/system/
systemctl daemon-reload
PHONY: clean
clean:
go clean
rm -rf bin