Skip to content

Commit

Permalink
makefile: add target for cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
awalvie committed Jan 31, 2024
1 parent 32795f7 commit 20ea49c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ VERSION=0.0.1

.DEFAULT_GOAL := help

# Go related variables.
PLATFORMS := linux/amd64

.PHONY: build
## build: Compile the packages.
build:
Expand Down Expand Up @@ -34,6 +37,17 @@ watch:
docker-build:
@docker build -t awalvie/$(NAME):$(VERSION) -f contrib/Dockerfile .

.PHONY: build-cross
## build-cross: Build binaries for all platforms
build-cross:
@for platform in $(PLATFORMS); do \
os=$$(echo $$platform | cut -f1 -d'/'); \
arch=$$(echo $$platform | cut -f2 -d'/'); \
echo "Building for $$os/$$arch..."; \
GOOS=$$os GOARCH=$$arch go build -o bin/$$os'_'$$arch/$(NAME) cmd/$(NAME).go; \
done


.PHONY: help
all: help
## help: show this help message
Expand Down

0 comments on commit 20ea49c

Please sign in to comment.