-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (31 loc) · 866 Bytes
/
Makefile
File metadata and controls
38 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.PHONY: all build build-all clean
BINARY_NAME := mrai
OUTPUT_DIR := bin
# OS/Arch combinations
TARGETS := \
linux/amd64 \
darwin/amd64 \
darwin/arm64 \
windows/amd64
# Default target
all: build-all
# Build for current system
build:
@echo "Building for current system..."
@mkdir -p $(OUTPUT_DIR)
@go build -o $(OUTPUT_DIR)/$(BINARY_NAME) main.go
@echo "Build complete: $(OUTPUT_DIR)/$(BINARY_NAME)"
# Build for all targets
build-all:
@echo "Cross-compiling..."
@mkdir -p $(OUTPUT_DIR)
@$(foreach target,$(TARGETS), \
GOOS=$(word 1,$(subst /, ,$(target))) \
GOARCH=$(word 2,$(subst /, ,$(target))) \
go build -o $(OUTPUT_DIR)/$(BINARY_NAME)-$(subst /,-,$(target))$(if $(findstring windows,$(target)),.exe,) main.go &&) true
@echo "All builds complete."
# Clean up
clean:
@echo "Cleaning up..."
@rm -rf $(OUTPUT_DIR)
@echo "Clean complete."