Debian Codegraph @

Makefile

raw
1 # used to install binaries
2 SN_DESTDIR=/opt/overlaybd/snapshotter
3 SN_CFGDIR=/etc/overlaybd-snapshotter
4
5 # command
6 COMMANDS=overlaybd-snapshotter ctr convertor overlaybd-attacher
7 BINARIES=$(addprefix bin/,$(COMMANDS))
8
9 # go packages
10 GO_PACKAGES=$(shell go list ${GO_TAGS} ./... | grep -v /vendor/)
11
12 CGO_ENABLED ?= 0
13
14 all: binaries
15
16 binaries: $(BINARIES) ## build binaries into bin
17
18 # force to rebuild all the binaries
19 force:
20
21 # build a binary from cmd
22 bin/%: cmd/% force
23 @echo "$@"
24 @GOOS=linux CGO_ENABLED="$(CGO_ENABLED)" go build -ldflags "-X 'main.commitID=$$COMMIT_ID'" -o $@ ./$<
25
26 install: ## install binaries from bin
27 @mkdir -p $(SN_DESTDIR)
28 @install $(BINARIES) $(SN_DESTDIR)
29 @install -m 0644 script/overlaybd-snapshotter.service $(SN_DESTDIR)
30 @mkdir -p ${SN_CFGDIR}
31 @install -m 0644 script/config.json ${SN_CFGDIR}
32 test: ## run tests that require root
33 @go test ${GO_TESTFLAGS} ${GO_PACKAGES} -test.root
34
35 clean:
36 @rm -rf ./bin