Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit aa2771d

Browse files
Makefile: Add release target for binary compression and adjust zip/targz dependencies
1 parent 7764fdc commit aa2771d

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ TAR_ARCHIVE = powershell-wrapper.tar.gz
2020
BUILD_FLAGS = -ldflags="-s -w" -trimpath
2121

2222
# Phony Targets
23-
.PHONY: all debug clean dist zip targz
23+
.PHONY: all debug clean dist zip targz release
2424

2525
# Default Target
2626
all: $(TARGET32) $(TARGET64)
2727

2828
# Debug Build
2929
debug: BUILD_FLAGS := -ldflags="-X main.compileForceDebug=on"
30-
debug: all
30+
debug: clean all
3131

3232
# 64-bit Executable
3333
$(TARGET64): $(SRCS)
@@ -43,7 +43,7 @@ $(TARGET32): $(SRCS)
4343
dist: zip targz
4444

4545
# Create ZIP Archive
46-
zip: $(TARGET32) $(TARGET64)
46+
zip: release
4747
@mkdir -p $(DIST_ZIP_DIR)/32 $(DIST_ZIP_DIR)/64
4848
@echo "Copying executables and profile.ps1 to ZIP distribution directories..."
4949
cp $(TARGET32) $(DIST_ZIP_DIR)/32/powershell.exe
@@ -54,7 +54,7 @@ zip: $(TARGET32) $(TARGET64)
5454
@echo "ZIP archive created at $(ZIP_ARCHIVE)"
5555

5656
# Create TAR.GZ Archive
57-
targz: $(TARGET32) $(TARGET64)
57+
targz: release
5858
@mkdir -p $(DIST_TAR_DIR)/32 $(DIST_TAR_DIR)/64
5959
@echo "Copying executables and profile.ps1 to TAR.GZ distribution directories..."
6060
cp $(TARGET32) $(DIST_TAR_DIR)/32/powershell.exe
@@ -64,6 +64,21 @@ targz: $(TARGET32) $(TARGET64)
6464
tar -czvf $(TAR_ARCHIVE) -C $(DIST_TAR_DIR) profile.ps1 32 64
6565
@echo "TAR.GZ archive created at $(TAR_ARCHIVE)"
6666

67+
# Release Target
68+
release: clean all
69+
@echo "Selecting UPX command..."
70+
@if command -v upx >/dev/null 2>&1; then \
71+
UPXCMD=upx; \
72+
elif command -v upx-ucl >/dev/null 2>&1; then \
73+
UPXCMD=upx-ucl; \
74+
else \
75+
echo "Error: Neither upx nor upx-ucl found."; \
76+
exit 1; \
77+
fi; \
78+
echo "Compressing binaries with $$UPXCMD..."; \
79+
$$UPXCMD --best --lzma $(TARGET32) $(TARGET64)
80+
@echo "Binaries compressed."
81+
6782
# Clean Build and Distribution Artifacts
6883
clean:
6984
@echo "Cleaning build and distribution directories..."

0 commit comments

Comments
 (0)