Skip to content

Commit d691019

Browse files
author
Andreas Huber
committed
Add build for macOS
1 parent 666913e commit d691019

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ SHELL = /bin/bash
1212
BUILD = go build
1313
MKDIR = mkdir -p
1414

15-
.PHONY: build build_linux build_win tag_checked_out mostlyclean
15+
.PHONY: build build_linux build_win build_mac_amd64 build_mac_arm64 tag_checked_out mostlyclean
1616

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

2222
# Build all binaries
23-
build: build_linux build_win
23+
build: build_linux build_win build_mac_amd64 build_mac_arm64
2424

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

3030
ifdef BUILDTAG
3131
# add the git tag checkout to the requirements of our build targets
32-
build_linux build_win: tag_checked_out
32+
build_linux build_win build_mac_amd64 build_mac_arm64: tag_checked_out
3333
endif
3434

3535
tag_checked_out:
@@ -67,15 +67,19 @@ LDFLAGS = -ldflags "-X github.com/csaf-poc/csaf_distribution/v3/util.SemVersion=
6767
GOARCH = amd64
6868
build_linux: GOOS = linux
6969
build_win: GOOS = windows
70+
build_mac_amd64: GOOS = darwin
7071

71-
build_linux build_win:
72+
build_mac_arm64: GOARCH = arm64
73+
build_mac_arm64: GOOS = darwin
74+
75+
build_linux build_win build_mac_amd64 build_mac_arm64:
7276
$(eval BINDIR = bin-$(GOOS)-$(GOARCH)/ )
7377
$(MKDIR) $(BINDIR)
7478
env GOARCH=$(GOARCH) GOOS=$(GOOS) $(BUILD) -o $(BINDIR) $(LDFLAGS) -v ./cmd/...
7579

7680

7781
DISTDIR := csaf_distribution-$(SEMVER)
78-
dist: build_linux build_win
82+
dist: build_linux build_win build_mac_amd64 build_mac_arm64
7983
mkdir -p dist
8084
mkdir -p dist/$(DISTDIR)-windows-amd64/bin-windows-amd64
8185
cp README.md dist/$(DISTDIR)-windows-amd64

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ Download the binaries from the most recent release assets on Github.
4747

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

0 commit comments

Comments
 (0)