Skip to content

Commit db39d09

Browse files
committed
Build on Windows
1 parent 3f66d00 commit db39d09

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d
2121

2222
GO ?= go
2323
GOBIN := $(shell $(GO) env GOBIN)
24-
GOOS ?= $(shell go env GOOS)
25-
GOARCH ?= $(shell go env GOARCH)
24+
GOOS ?= $(shell $(GO) env GOOS)
25+
GOARCH ?= $(shell $(GO) env GOARCH)
2626

2727
# N/B: This value is managed by Renovate, manual changes are
2828
# possible, as long as they don't disturb the formatting
2929
# (i.e. DO NOT ADD A 'v' prefix!)
3030
GOLANGCI_LINT_VERSION := 1.61.0
3131

3232
ifeq ($(GOBIN),)
33-
GOBIN := $(GOPATH)/bin
33+
GOBIN := $(shell $(GO) env GOPATH | sed -e 's!\\!/!g')/bin
3434
endif
3535

3636
# Scripts may also use CONTAINER_RUNTIME, so we need to export it.
@@ -99,11 +99,16 @@ ifeq ($(DISABLE_CGO), 1)
9999
override BUILDTAGS = exclude_graphdriver_btrfs containers_image_openpgp
100100
endif
101101

102+
BIN=bin/skopeo
103+
ifeq ($(OS),Windows_NT)
104+
BIN := $(BIN).exe
105+
endif
106+
102107
# make all DEBUG=1
103108
# Note: Uses the -N -l go compiler options to disable compiler optimizations
104109
# and inlining. Using these build options allows you to subsequently
105110
# use source debugging tools like delve.
106-
all: bin/skopeo docs
111+
all: $(BIN) docs
107112

108113
codespell:
109114
codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L fpr,uint,iff,od,ERRO -w
@@ -129,16 +134,16 @@ binary: cmd/skopeo
129134
$(CONTAINER_RUN) make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
130135

131136
# Build w/o using containers
132-
.PHONY: bin/skopeo
133-
bin/skopeo:
137+
.PHONY: $(BIN)
138+
$(BIN):
134139
$(GO) build ${GO_DYN_FLAGS} ${SKOPEO_LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo
135140
bin/skopeo.%:
136141
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo
137142
local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 bin/skopeo.windows.386.exe bin/skopeo.windows.amd64.exe
138143

139144
$(MANPAGES): %: %.md
140145
ifneq ($(DISABLE_DOCS), 1)
141-
sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@
146+
sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -out $@
142147
endif
143148

144149
docs: $(MANPAGES)

0 commit comments

Comments
 (0)