Skip to content

Commit

Permalink
Add build for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Huber committed Oct 6, 2023
1 parent 666913e commit d691019
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ SHELL = /bin/bash
BUILD = go build
MKDIR = mkdir -p

.PHONY: build build_linux build_win tag_checked_out mostlyclean
.PHONY: build build_linux build_win build_mac_amd64 build_mac_arm64 tag_checked_out mostlyclean

all:
@echo choose a target from: build build_linux build_win mostlyclean
@echo choose a target from: build build_linux build_win build_mac_amd64 build_mac_arm64 mostlyclean
@echo prepend \`make BUILDTAG=1\` to checkout the highest git tag before building
@echo or set BUILDTAG to a specific tag

# Build all binaries
build: build_linux build_win
build: build_linux build_win build_mac_amd64 build_mac_arm64

# if BUILDTAG == 1 set it to the highest git tag
ifeq ($(strip $(BUILDTAG)),1)
Expand All @@ -29,7 +29,7 @@ endif

ifdef BUILDTAG
# add the git tag checkout to the requirements of our build targets
build_linux build_win: tag_checked_out
build_linux build_win build_mac_amd64 build_mac_arm64: tag_checked_out
endif

tag_checked_out:
Expand Down Expand Up @@ -67,15 +67,19 @@ LDFLAGS = -ldflags "-X github.com/csaf-poc/csaf_distribution/v3/util.SemVersion=
GOARCH = amd64
build_linux: GOOS = linux
build_win: GOOS = windows
build_mac_amd64: GOOS = darwin

build_linux build_win:
build_mac_arm64: GOARCH = arm64
build_mac_arm64: GOOS = darwin

build_linux build_win build_mac_amd64 build_mac_arm64:
$(eval BINDIR = bin-$(GOOS)-$(GOARCH)/ )
$(MKDIR) $(BINDIR)
env GOARCH=$(GOARCH) GOOS=$(GOOS) $(BUILD) -o $(BINDIR) $(LDFLAGS) -v ./cmd/...


DISTDIR := csaf_distribution-$(SEMVER)
dist: build_linux build_win
dist: build_linux build_win build_mac_amd64 build_mac_arm64
mkdir -p dist
mkdir -p dist/$(DISTDIR)-windows-amd64/bin-windows-amd64
cp README.md dist/$(DISTDIR)-windows-amd64
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ Download the binaries from the most recent release assets on Github.

- Build Go components Makefile supplies the following targets:
- Build For GNU/Linux System: `make build_linux`
- Build For Windows System (cross build): `make build_win`
- Build For both linux and windows: `make build`
- Build from a specific github tag by passing the intended tag to the `BUILDTAG` variable.
- Build For Windows System (cross build): `make build_win`
- Build For macOS on Intel Processor (AMD64) (cross build): `make build_mac_amd64`
- Build For macOS on Apple Silicon (ARM64) (cross build): `make build_mac_arm64`
- Build For Linux, Mac and Windows: `make build`
- Build from a specific GitHub tag by passing the intended tag to the `BUILDTAG` variable.
E.g. `make BUILDTAG=v1.0.0 build` or `make BUILDTAG=1 build_linux`.
The special value `1` means checking out the highest github tag for the build.
- Remove the generated binaries und their directories: `make mostlyclean`
Expand Down

0 comments on commit d691019

Please sign in to comment.