Skip to content

Commit 1984dd8

Browse files
cfergeauanjannath
authored andcommitted
Makefile: Remove confusing rule
This rule: $(BUILD_DIR)/$(GOOS)-$(GOARCH): mkdir -p $(BUILD_DIR)/$(GOOS)-$(GOARCH) may make one think that it will create the right directory in cross builds, but this is misleading, GOOS/GOARCH are set at the very beginning of the Makefile, and the name of the directory which is created is fixed at the time the Makefile is parsed (to linux/amd64/ on a linux machine for example). As "go build" will create the target directory if needed, we can get rid of this rule.
1 parent b2559b5 commit 1984dd8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,13 @@ binappend:
7979
$(CURDIR)/bin/crc$(IS_EXE):
8080
go install -ldflags="$(VERSION_VARIABLES)" ./cmd/crc
8181

82-
$(BUILD_DIR)/$(GOOS)-$(GOARCH):
83-
mkdir -p $(BUILD_DIR)/$(GOOS)-$(GOARCH)
84-
85-
$(BUILD_DIR)/darwin-amd64/crc: $(BUILD_DIR)/$(GOOS)-$(GOARCH)
82+
$(BUILD_DIR)/darwin-amd64/crc:
8683
GOARCH=amd64 GOOS=darwin go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/darwin-amd64/crc ./cmd/crc
8784

88-
$(BUILD_DIR)/linux-amd64/crc: $(BUILD_DIR)/$(GOOS)-$(GOARCH)
85+
$(BUILD_DIR)/linux-amd64/crc:
8986
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/linux-amd64/crc ./cmd/crc
9087

91-
$(BUILD_DIR)/windows-amd64/crc.exe: $(BUILD_DIR)/$(GOOS)-$(GOARCH)
88+
$(BUILD_DIR)/windows-amd64/crc.exe:
9289
GOARCH=amd64 GOOS=windows go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/windows-amd64/crc.exe ./cmd/crc
9390

9491
.PHONY: cross ## Cross compiles all binaries

0 commit comments

Comments
 (0)