-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (53 loc) · 1.77 KB
/
Makefile
File metadata and controls
66 lines (53 loc) · 1.77 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
CXX = g++
CXXFLAGS = -std=c++17 -Wall -O2
LDFLAGS =
# Check for pkg-config
ifneq ($(shell which pkg-config),)
SDL2_CFLAGS = $(shell pkg-config --cflags sdl2 SDL2_ttf)
SDL2_LIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
else
# Fallback for systems without pkg-config (e.g. some macOS setups without it)
# Assumes headers/libs are in standard search paths
SDL2_CFLAGS = -I/usr/include/SDL2 -D_REENTRANT
SDL2_LIBS = -lSDL2 -lSDL2_ttf
endif
CXXFLAGS += $(SDL2_CFLAGS)
LDFLAGS += $(SDL2_LIBS)
TARGET = NotepadInc
SRC_DIRS = src src/States src/Utils
BUILD_DIR = build
# Recursively find sources
SRCS = $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
# Create object file paths (preserving structure in build dir is tricky with simple makefile,
# let's just use flattened structure or mkdir -p)
OBJS = $(patsubst %.cpp, $(BUILD_DIR)/%.o, $(SRCS))
# Default Host Build
CXX = g++
CXXFLAGS = -std=c++17 -Wall -O2
LDFLAGS =
# Check for pkg-config for Host
ifneq ($(shell which pkg-config),)
SDL2_CFLAGS = $(shell pkg-config --cflags sdl2 SDL2_ttf)
SDL2_LIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
else
SDL2_CFLAGS = -I/usr/include/SDL2 -D_REENTRANT
SDL2_LIBS = -lSDL2 -lSDL2_ttf
endif
CXXFLAGS += $(SDL2_CFLAGS)
LDFLAGS += $(SDL2_LIBS)
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
# Compilation rule that handles subdirectories
$(BUILD_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Miyoo Mini Cross-Compilation Target
# Usage: make miyoo
miyoo: CXX = arm-linux-gnueabihf-g++
miyoo: CXXFLAGS = -std=c++17 -Wall -O3 -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 -DMIYOO
miyoo: LDFLAGS = -lSDL2 -lSDL2_ttf -lm -ldl -lpthread -lrt
miyoo: clean $(TARGET)
clean:
rm -rf $(BUILD_DIR) $(TARGET)
.PHONY: all clean miyoo