This repository was archived by the owner on Mar 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (80 loc) · 3.14 KB
/
Makefile
File metadata and controls
99 lines (80 loc) · 3.14 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# OrdinalFuzzer Makefile
CC = clang
AS = as
OBJC_FLAGS = -fobjc-arc
DEPLOY_TARGET = -mmacosx-version-min=10.13
CFLAGS = -Wall -Wextra -Wno-incompatible-pointer-types -O2 -g \
$(OBJC_FLAGS) -Wno-deprecated-declarations -Wno-unguarded-availability-new \
$(DEPLOY_TARGET)
RELEASE_CFLAGS = -Wall -Wextra -Wno-incompatible-pointer-types -O3 -DNDEBUG \
$(OBJC_FLAGS) -Wno-deprecated-declarations -Wno-unguarded-availability-new \
$(DEPLOY_TARGET)
LDFLAGS = -framework Foundation -framework IOKit -framework Security \
-framework CoreFoundation -framework ImageIO -framework CoreGraphics \
-framework CoreML -framework Accelerate -framework Metal \
-framework JavaScriptCore -framework CoreText \
-framework AppKit -framework Cocoa -framework AVFoundation \
-framework IOSurface \
-lsqlite3 -lbsm -lz -lcompression
# UniformTypeIdentifiers is macOS 11+ only - weak link it
LDFLAGS += -weak_framework UniformTypeIdentifiers
# Detect architecture
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),arm64)
ASM_ARCH = arm64
ASM_FLAGS = -arch arm64
else
ASM_ARCH = x86_64
ASM_FLAGS = -arch x86_64
endif
SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
CRASH_DIR = crashes
# Source files
OBJC_SRCS = $(wildcard $(SRC_DIR)/core/*.m) \
$(wildcard $(SRC_DIR)/vulns/*.m) \
$(wildcard $(SRC_DIR)/utils/*.m) \
$(wildcard $(SRC_DIR)/gui/*.m)
ASM_SRCS = $(wildcard $(SRC_DIR)/asm/*.s)
OBJC_OBJS = $(patsubst $(SRC_DIR)/%.m,$(BUILD_DIR)/%.o,$(OBJC_SRCS))
ASM_OBJS = $(patsubst $(SRC_DIR)/%.s,$(BUILD_DIR)/%.o,$(ASM_SRCS))
ALL_OBJS = $(OBJC_OBJS) $(ASM_OBJS)
# Release objects go under build/release/
RELEASE_OBJC_OBJS = $(patsubst $(SRC_DIR)/%.m,$(BUILD_DIR)/release/%.o,$(OBJC_SRCS))
RELEASE_ASM_OBJS = $(patsubst $(SRC_DIR)/%.s,$(BUILD_DIR)/release/%.o,$(ASM_SRCS))
RELEASE_ALL_OBJS = $(RELEASE_OBJC_OBJS) $(RELEASE_ASM_OBJS)
TARGET = $(BUILD_DIR)/ordinal_fuzzer
RELEASE_TARGET = $(BUILD_DIR)/ordinal_fuzzer_release
.PHONY: all clean dirs release
all: dirs $(TARGET)
@echo "Build complete: $(TARGET)"
release: dirs $(RELEASE_TARGET)
@echo "Release build complete: $(RELEASE_TARGET)"
dirs:
@mkdir -p $(BUILD_DIR)/core $(BUILD_DIR)/vulns $(BUILD_DIR)/asm $(BUILD_DIR)/utils $(BUILD_DIR)/gui
@mkdir -p $(BUILD_DIR)/release/core $(BUILD_DIR)/release/vulns $(BUILD_DIR)/release/asm $(BUILD_DIR)/release/utils $(BUILD_DIR)/release/gui
@mkdir -p $(CRASH_DIR) logs reports
$(TARGET): $(ALL_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
$(RELEASE_TARGET): $(RELEASE_ALL_OBJS)
$(CC) $(RELEASE_CFLAGS) $(LDFLAGS) -o $@ $^
strip $@
@echo "Stripped debug symbols from $@"
# Debug build pattern rules
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.m
$(CC) $(CFLAGS) -I$(INC_DIR) -c -o $@ $<
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.s
$(AS) $(ASM_FLAGS) -o $@ $<
# Release build pattern rules
$(BUILD_DIR)/release/%.o: $(SRC_DIR)/%.m
$(CC) $(RELEASE_CFLAGS) -I$(INC_DIR) -c -o $@ $<
$(BUILD_DIR)/release/%.o: $(SRC_DIR)/%.s
$(AS) $(ASM_FLAGS) -o $@ $<
clean:
rm -rf $(BUILD_DIR)
install: all
cp $(TARGET) /usr/local/bin/ordinal_fuzzer
.PHONY: test
test: all
./$(TARGET) --self-test