Skip to content

Commit ce8cd9a

Browse files
committed
Makefile: add checks to make sure build is static
1 parent 7d2a465 commit ce8cd9a

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

Makefile

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,54 @@ $(BIN)/ghost.darwin.%:
8888
GOOS=darwin GOARCH=$* $(GO) build $(LDFLAGS) -o $@ $(CURDIR)/cmd/ghost
8989

9090
ghost-darwin: $(GHOST_DARWIN_BINS) $(GHOST_DARWIN_BINS:=.sha1)
91+
ifeq ($(STATIC), true)
92+
$(call cmd_msg,VERIFY,macOS binaries)
93+
@echo "Verifying macOS ghost binaries..."
94+
@for binary in $(GHOST_DARWIN_BINS); do \
95+
if [ -f "$$binary" ]; then \
96+
echo "Checking $$binary:"; \
97+
file "$$binary" | grep -q "Mach-O" && \
98+
echo "✓ $$binary is a Mach-O executable (macOS binary)" || \
99+
(echo "WARNING: Could not verify $$binary format" && file "$$binary"); \
100+
fi; \
101+
done
102+
endif
103+
104+
# Verify static linking when STATIC=true
105+
verify-static:
106+
ifeq ($(STATIC), true)
107+
$(call cmd_msg,VERIFY,binary linking)
108+
@echo "Verifying ghost binary linking..."
109+
@for binary in $(GHOST_LINUX_BINS); do \
110+
if [ -f "$$binary" ]; then \
111+
echo "Checking $$binary (Linux):"; \
112+
if ldd "$$binary" 2>/dev/null | grep -q "=>"; then \
113+
echo "ERROR: $$binary is dynamically linked!"; \
114+
ldd "$$binary"; \
115+
exit 1; \
116+
else \
117+
echo "✓ $$binary is statically linked"; \
118+
fi; \
119+
fi; \
120+
done
121+
@if [ -f "$(BIN)/ghost" ]; then \
122+
echo "Checking $(BIN)/ghost (local platform):"; \
123+
if [ "$$(uname)" = "Darwin" ]; then \
124+
echo "✓ $(BIN)/ghost built for macOS (dynamic linking expected)"; \
125+
else \
126+
if ldd "$(BIN)/ghost" 2>/dev/null | grep -q "=>"; then \
127+
echo "ERROR: $(BIN)/ghost is dynamically linked!"; \
128+
ldd "$(BIN)/ghost"; \
129+
exit 1; \
130+
else \
131+
echo "✓ $(BIN)/ghost is statically linked"; \
132+
fi; \
133+
fi; \
134+
fi
135+
@echo "Ghost binary linking verified successfully!"
136+
endif
91137

92-
build-go: overlordd ghost ghost-linux
138+
build-go: overlordd ghost ghost-linux verify-static
93139

94140
build-py:
95141
@ln -sf ../py/ghost.py bin

0 commit comments

Comments
 (0)