-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (30 loc) · 872 Bytes
/
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
GO := go
PKGS = $(shell $(GO) list ./... | grep -v /vendor/)
ARCH ?= $(shell go env GOARCH)
OS ?= $(shell go env GOOS)
OUT_DIR := build
OUTBIN_DIR := ${OUT_DIR}/bin
SRC_PREFIX := github.com/ponypaver/docker-tunnel/cmd
PKG_PREFIX := github.com/ponypaver/docker-tunnel/pkg
ALL_TARGETS := dockertunnel cli
ALL_TARGETS_WITH_OS := $(addsuffix -os-%,$(ALL_TARGETS))
all: $(ALL_TARGETS)
# cross compile all targets
# eg: make all-os-linux
all-os-%:
@$(MAKE) OS=$* all
# compile with default platform options
# eg: make
$(ALL_TARGETS):
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 $(GO) build -ldflags "${LDFLAGS}" -o $(OUTBIN_DIR)/$(OS)/$@ $(SRC_PREFIX)/$@
# cross compile
# eg: make dockertunnel-os-linux
$(ALL_TARGETS_WITH_OS):
@$(MAKE) OS=$* $(firstword $(subst -os-, ,$@))
build: all
test:
@$(GO) test $(PKGS)
.PHONY: test
clean:
@rm -rf ${OUT_DIR}/*
.PHONY: clean