Skip to content

Commit eaa48fa

Browse files
committed
Cleanups and small fixes
1 parent 9a7c8dc commit eaa48fa

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

Makefile

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
# Variables:
2-
# V=1 for verbose output.
3-
# BINNAME=step to change the name of the executable
4-
# PREFIX=bin/ to change the build output path
5-
# DESTDIR=/usr/local/bin to change the install path
6-
# GOOS_OVERRIDE="GOOS=linux GOARCH=arm GOARM=6" to change OS and arch
7-
# CGO_OVERRIDE="CGO_ENABLED=1" to enable CGO
8-
#
91
# Run `make bootstrap` to set up your local environment.
102
# To build using go, use `make build`
113
# For a binary that's in parity with how our CI system builds,
124
# run `make goreleaser` to build using GoReleaser Pro.
135

6+
# Variables:
7+
# V=1 for verbose output.
8+
9+
# the name of the executable
10+
BINNAME?=step
11+
12+
# the build output path
13+
PREFIX?=bin
14+
15+
# the install path
16+
DESTDIR?=/usr/local/bin
17+
18+
# GOOS_OVERRIDE="GOOS=linux GOARCH=arm GOARM=6" to change OS and arch
19+
GOOS_OVERRIDE?=
20+
21+
# CGO_OVERRIDE="CGO_ENABLED=1" to enable CGO
22+
CGO_OVERRIDE?=CGO_ENABLED=0
23+
1424
all: lint test build
1525

1626
ci: test build
@@ -55,12 +65,8 @@ else
5565
endif
5666

5767
Q=$(if $V,,@)
58-
PREFIX?=
5968
SRC=$(shell find . -type f -name '*.go')
60-
GOOS_OVERRIDE ?=
61-
CGO_OVERRIDE ?= CGO_ENABLED=0
6269
OUTPUT_ROOT=output/
63-
BINNAME?=step
6470

6571
GORELEASER_BUILD_ID?=default
6672
ifdef DEBUG
@@ -86,25 +92,25 @@ bootstra%:
8692
# Build
8793
#########################################
8894

89-
build: $(PREFIX)bin/$(BINNAME)
95+
build: $(PREFIX)/$(BINNAME)
9096
@echo "Build Complete!"
9197

92-
$(PREFIX)bin/$(BINNAME):
93-
$Q mkdir -p $(@D)
98+
$(PREFIX)/$(BINNAME):
99+
$Q mkdir -p $(PREFIX)
94100
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) go build \
95101
-v \
96-
-o $(PREFIX)bin/$(BINNAME) \
102+
-o $(PREFIX)/$(BINNAME) \
97103
$(GCFLAGS) $(LDFLAGS) \
98104
github.com/smallstep/cli/cmd/step
99105

100106
goreleaser:
101-
$Q mkdir -p $(@D)
107+
$Q mkdir -p $(PREFIX)
102108
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) goreleaser build \
103109
--id $(GORELEASER_BUILD_ID) \
104110
--snapshot \
105111
--single-target \
106112
--clean \
107-
--output $(PREFIX)bin/$(BINNAME)
113+
--output $(PREFIX)/$(BINNAME)
108114

109115
.PHONY: build goreleaser
110116

@@ -123,7 +129,7 @@ race:
123129

124130
integrate: integration
125131

126-
integration: bin/$(BINNAME)
132+
integration: build
127133
$Q $(CGO_OVERRIDE) gotestsum -- -tags=integration ./integration/...
128134

129135
.PHONY: integrate integration
@@ -150,14 +156,12 @@ govulncheck:
150156
# Install
151157
#########################################
152158

153-
DESTDIR?=/usr/local/
154-
155-
install: $(PREFIX)bin/$(BINNAME)
156-
$Q mkdir -p $(DESTDIR)bin/
157-
$Q install $(PREFIX)bin/$(BINNAME) $(DESTDIR)bin/$(BINNAME)
159+
install: $(PREFIX)/$(BINNAME)
160+
$Q mkdir -p $(DESTDIR)/
161+
$Q install $(PREFIX)/$(BINNAME) $(DESTDIR)/$(BINNAME)
158162

159163
uninstall:
160-
$Q rm -f $(DESTDIR)/bin/$(BINNAME)
164+
$Q rm -f $(DESTDIR)/$(BINNAME)
161165

162166
.PHONY: install uninstall
163167

@@ -166,7 +170,7 @@ uninstall:
166170
#########################################
167171

168172
clean:
169-
$Q rm -f bin/$(BINNAME)
173+
$Q rm -f $(PREFIX)/$(BINNAME)
170174
$Q rm -rf dist
171175

172176
.PHONY: clean
@@ -182,7 +186,7 @@ define BUNDLE_MAKE
182186
# $(2) -- Go Architecture (e.g. amd64, arm, arm64, etc.)
183187
# $(3) -- Go ARM architectural family (e.g. 7, 8, etc.)
184188
# $(4) -- Parent directory for executables generated by 'make'.
185-
$Q GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)bin/$(BINNAME)
189+
$Q GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)/$(BINNAME)
186190
endef
187191

188192
binary-linux-amd64:

0 commit comments

Comments
 (0)