-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (74 loc) · 2.36 KB
/
Copy pathMakefile
File metadata and controls
89 lines (74 loc) · 2.36 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
CC ?= cc
SRC := $(shell find src -name '*.c' | sort)
BIN_DIR := build
TARGET := $(BIN_DIR)/osxfetch
# Build profile:
# auto - detect from current machine (default)
# arm64 - Apple Silicon
# ppc - PowerPC-era Macs
# intel - 64-bit Intel Macs
# intel32 - 32-bit Intel Macs
# universal-intel - i386 + x86_64 fat binary
PROFILE ?= auto
# Keep flags conservative for old Apple toolchains.
CFLAGS_COMMON := -O2 -Wall -std=c99
LDFLAGS := -framework IOKit -framework CoreFoundation -framework CoreServices -framework OpenGL -framework Cocoa
.PHONY: all run clean help arm64 ppc intel intel32 universal-intel
# Default: build + run
all: run
run: $(TARGET)
@echo "Running $(TARGET)..."
@./$(TARGET)
$(TARGET): $(SRC) $(BIN_DIR)
@profile="$(PROFILE)"; \
if [ "$$profile" = "auto" ]; then \
arch="$$(uname -m)"; \
case "$$arch" in \
arm64|aarch64) profile="arm64" ;; \
ppc|powerpc*) profile="ppc" ;; \
i386|i686) profile="intel32" ;; \
x86_64) profile="intel" ;; \
*) profile="generic" ;; \
esac; \
fi; \
case "$$profile" in \
arm64) ARCH_FLAGS="-arch arm64" ;; \
ppc) ARCH_FLAGS="-arch ppc" ;; \
intel) ARCH_FLAGS="-arch x86_64" ;; \
intel32) ARCH_FLAGS="-arch i386" ;; \
universal-intel) ARCH_FLAGS="-arch i386 -arch x86_64" ;; \
generic) ARCH_FLAGS="" ;; \
*) echo "Unknown PROFILE='$$profile'"; exit 1 ;; \
esac; \
echo "Building profile=$$profile"; \
echo "$(CC) $(CFLAGS_COMMON) $$ARCH_FLAGS $(SRC) -o $(TARGET) $(LDFLAGS)"; \
$(CC) $(CFLAGS_COMMON) $$ARCH_FLAGS $(SRC) -o $(TARGET) $(LDFLAGS)
$(BIN_DIR):
@mkdir -p $(BIN_DIR)
# Convenience profile targets
arm64:
@$(MAKE) PROFILE=arm64 run
ppc:
@$(MAKE) PROFILE=ppc run
intel:
@$(MAKE) PROFILE=intel run
intel32:
@$(MAKE) PROFILE=intel32 run
universal-intel:
@$(MAKE) PROFILE=universal-intel run
clean:
@rm -rf $(BIN_DIR)
help:
@echo "osxfetch Makefile"
@echo
@echo "Default target: make (build + run with PROFILE=auto)"
@echo
@echo "Profiles:"
@echo " make arm64 # modern Apple Silicon"
@echo " make ppc # PowerPC-era Macs (10.0-10.5)"
@echo " make intel # Intel 64-bit (10.5-10.15)"
@echo " make intel32 # Intel 32-bit (where supported)"
@echo " make universal-intel # i386 + x86_64 fat binary"
@echo
@echo "Other:"
@echo " make clean"