Skip to content

Commit 532c75d

Browse files
authored
refactor(makefile): improve build targets and update versioning logic (#40)
- Removed redundant third argument from the `build` function calls. - Updated the `checksums` target to dynamically list binaries in the output directory. - Added a new `.PHONY` target for `version` to display the latest git tag version. - Simplified the `install` and `cleanup` targets for clarity and efficiency. - Improved the `help` target to provide comprehensive usage instructions. - Ensured the `clean` target effectively removes the output directory. These changes enhance the Makefile's maintainability and provide clearer, more efficient build processes.
1 parent 50099cb commit 532c75d

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

makefile

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Makefile for building Clipper
2+
# Any copyright is dedicated to the Public Domain.
3+
# https://creativecommons.org/publicdomain/zero/1.0/
24

35
# Define the output directory for the binaries
46
OUT_DIR := bin
@@ -9,7 +11,7 @@ VERSION ?= $(shell git describe --tags --always) # Get latest tag or commit has
911
REPO_URL := github.com/supitsdu/clipper
1012

1113
# Define the build targets for each platform
12-
.PHONY: all windows linux linux_arm linux_arm64 darwin darwin_arm64 clean checksums test help
14+
.PHONY: all windows linux linux_arm linux_arm64 darwin darwin_arm64 clean checksums test help version
1315

1416
# Default target: build binaries for all platforms
1517
all: windows linux linux_arm linux_arm64 darwin darwin_arm64
@@ -23,40 +25,31 @@ endef
2325

2426
# Build binaries for each platform, calling the generic build function with appropriate arguments
2527
windows: $(OUT_DIR)
26-
$(call build,windows,amd64,windows)
28+
$(call build,windows,amd64)
2729

28-
# Build binary for Linux (amd64)
2930
linux: $(OUT_DIR)
30-
$(call build,linux,amd64,linux)
31+
$(call build,linux,amd64)
3132

32-
# Build binary for Linux (arm)
3333
linux_arm: $(OUT_DIR)
34-
$(call build,linux,arm,linux)
34+
$(call build,linux,arm)
3535

36-
# Build binary for Linux (arm64)
3736
linux_arm64: $(OUT_DIR)
38-
$(call build,linux,arm64,linux)
37+
$(call build,linux,arm64)
3938

40-
# Build binary for macOS (amd64)
4139
darwin: $(OUT_DIR)
42-
$(call build,darwin,amd64,darwin)
40+
$(call build,darwin,amd64)
4341

44-
# Build binary for macOS (arm64)
4542
darwin_arm64: $(OUT_DIR)
46-
$(call build,darwin,arm64,darwin)
43+
$(call build,darwin,arm64)
4744

4845
# Generate SHA256 checksums for each binary
4946
checksums: $(OUT_DIR)
5047
@echo "Generating SHA256 checksums..."
51-
@for binary in $(WINDOWS_BIN) $(LINUX_BIN) $(LINUX_ARM_BIN) $(LINUX_ARM64_BIN) $(DARWIN_BIN) $(DARWIN_ARM64_BIN); do \
48+
@for binary in $(shell ls $(OUT_DIR)); do \
5249
sha256sum $(OUT_DIR)/$$binary > $(OUT_DIR)/$$binary.sha256; \
5350
done
5451
@echo "Checksum files generated successfully."
5552

56-
# Run tests
57-
test:
58-
go test ./...
59-
6053
# Clean the built binaries
6154
clean:
6255
rm -rf $(OUT_DIR)

0 commit comments

Comments
 (0)