-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (30 loc) · 895 Bytes
/
Makefile
File metadata and controls
39 lines (30 loc) · 895 Bytes
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
# Compiler and debugger
CC = gcc
DB = gdb
# Output executable
TARGET = obj/program
# Source files
SRCS = utils/cell.c utils/grid.c graphics/sdl2.c utils/dim.c utils/line.c seir.c main.c
# Compiler flags
CFLAGS = `sdl2-config --cflags`
LDFLAGS = -lm `sdl2-config --libs` -lSDL2_ttf
# Folder to bundle all runtime files
BUNDLE_DIR = bundle
LIBS_TO_COPY = \
$(shell ldd $(TARGET) | grep -E 'SDL2|SDL2_ttf' | awk '{print $$3}')
# Build the program
build: $(TARGET)
$(TARGET): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $(TARGET) $(LDFLAGS)
# Bundle target: copies executable and required libraries
bundle: build
mkdir -p $(BUNDLE_DIR)
cp $(TARGET) $(BUNDLE_DIR)/
ldd $(TARGET) | grep -E 'SDL2|SDL2_ttf' | awk '{print $$3}' | while read lib; do cp -u "$$lib" $(BUNDLE_DIR)/; done
# Debug build
gdb: CFLAGS += -g
gdb: build
$(DB) $(TARGET)
# Clean build artifacts
clean:
rm -f $(TARGET)