-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.linux
More file actions
54 lines (41 loc) · 2.05 KB
/
Makefile.linux
File metadata and controls
54 lines (41 loc) · 2.05 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# stubs-builder Makefile for Linux.
# Stub binaries for compressed Node.js executables.
# Include common definitions.
include ../build-infra/make/common.mk
include ../build-infra/make/platform-linux.mk
include ../build-infra/make/crypto.mk
# curl support for HTTPS update checking.
include make/curl.mk
# zstd compression library (vendored, cross-platform).
include ../bin-infra/make/zstd.mk
# Disable LTO — stubs links pre-built curl archives that may use
# a different GCC LTO version (e.g., curl built with GCC 13, Alpine 3.21
# ships GCC 14). LTO bytecode is not cross-version compatible.
# -fno-lto is required explicitly so GCC skips LTO sections in the archives.
OPT_FLAGS := $(filter-out -flto,$(OPT_FLAGS)) -fno-lto
LDFLAGS_BASE := $(filter-out -flto,$(LDFLAGS_BASE)) -fno-lto
TARGET_CLI = smol_stub
SOURCE_CLI = src/socketsecurity/stubs-builder/elf_stub.c \
../build-infra/src/socketsecurity/build-infra/binary_format_finder.c \
../bin-infra/src/socketsecurity/bin-infra/smol_segment.c \
../bin-infra/src/socketsecurity/bin-infra/smol_segment_reader.c \
../build-infra/src/socketsecurity/build-infra/file_utils.c \
../build-infra/src/socketsecurity/build-infra/path_utils.c
SRC_DIR = src
CFLAGS = -Wall -Wextra $(OPT_FLAGS) -std=c11 $(POSIX_MACROS) -Isrc $(COMMON_INCLUDES) $(ZSTD_CFLAGS) $(CURL_CFLAGS) -DVERSION=\"$(VERSION)\"
LDFLAGS = $(LDFLAGS_BASE) $(ZSTD_LDFLAGS) $(CURL_LDFLAGS) $(CRYPTO_LDFLAGS) -lz $(LINUX_STD_LIBS)
# Check that required build tools are available.
check-tools:
@command -v $(CC) >/dev/null 2>&1 || { echo "ERROR: $(CC) not found. Install build tools first."; exit 1; }
@command -v make >/dev/null 2>&1 || { echo "ERROR: make not found"; exit 1; }
# Build stub binary.
all: check-tools $(ZSTD_LIB) $(OUT_DIR)/$(TARGET_CLI)
$(OUT_DIR)/$(TARGET_CLI): $(SOURCE_CLI) $(ZSTD_LIB) | $(OUT_DIR)
$(CC) $(CFLAGS) -o $@ $(SOURCE_CLI) $(LDFLAGS)
@echo "Built: $(OUT_DIR)/$(TARGET_CLI)"
$(OUT_DIR):
mkdir -p $@
# Clean build artifacts.
clean:
rm -rf $(OUT_DIR)
.PHONY: all clean check-tools