Skip to content

Commit 57110df

Browse files
committed
Makefile: simplify relative build path logic
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
1 parent f437ef5 commit 57110df

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ require-%:
117117

118118
build: WHAT ?= ./cmd/... ./cli/cmd/...
119119
build: require-jq require-go require-git verify-go-versions ## Build the project
120-
for W in $(WHAT); do \
121-
cd $${W%...} && ROOT=$$(go list -m -f "{{.Path}}") && ROOT=.$${ROOT#github.com/kcp-dev/kcp} && cd - && \
122-
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILDFLAGS) -ldflags="$(LDFLAGS)" -o $(shell pwd)/bin .$${W#$${ROOT}}; \
120+
set -x; for W in $(WHAT); do \
121+
W=$$(echo "$${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
122+
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILDFLAGS) -ldflags="$(LDFLAGS)" -o bin $${W}; \
123123
done
124124
ln -sf kubectl-workspace bin/kubectl-workspaces
125125
ln -sf kubectl-workspace bin/kubectl-ws
@@ -131,9 +131,9 @@ build-all:
131131

132132
install: WHAT ?= ./cmd/... ./cli/cmd/...
133133
install: require-jq require-go require-git verify-go-versions ## Install the project
134-
for W in $(WHAT); do \
135-
cd $${W%...} && ROOT=$$(go list -m -f "{{.Path}}") && ROOT=.$${ROOT#github.com/kcp-dev/kcp} && cd - && \
136-
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" .$${W#$${ROOT}}; \
134+
set -x; for W in $(WHAT); do \
135+
W=$$(echo "$${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
136+
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $${W}; \
137137
done
138138
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-ws
139139
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-workspaces

0 commit comments

Comments
 (0)