-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (35 loc) · 1.29 KB
/
Copy pathMakefile
File metadata and controls
44 lines (35 loc) · 1.29 KB
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
# container-init build
#
# Static binaries for linux/amd64 and linux/arm64. CGO disabled so the result
# is a single self-contained executable that runs as PID 1 in any rootfs.
PKG := github.com/emrul/container-init
BIN_DIR := bin
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
GOFLAGS := -trimpath
TAGS := osusergo,netgo
.PHONY: all build build-amd64 build-arm64 test tidy clean
all: build
build: build-amd64 build-arm64
build-amd64:
@mkdir -p $(BIN_DIR)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' \
-o $(BIN_DIR)/container-init.linux-amd64 ./cmd/container-init
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' \
-o $(BIN_DIR)/systemd1-shim.linux-amd64 ./cmd/systemd1-shim
build-arm64:
@mkdir -p $(BIN_DIR)
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' \
-o $(BIN_DIR)/container-init.linux-arm64 ./cmd/container-init
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' \
-o $(BIN_DIR)/systemd1-shim.linux-arm64 ./cmd/systemd1-shim
test:
go test ./...
tidy:
go mod tidy
clean:
rm -rf $(BIN_DIR)