-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 1.25 KB
/
Copy pathMakefile
File metadata and controls
58 lines (46 loc) · 1.25 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
# ===============================
# GraphXML Makefile
# Cross-platform Desktop: Linux / macOS / Windows (MSYS2)
# ===============================
# Compiler
CC ?= gcc
CFLAGS ?= -std=c11 -O2 -Wall -Wextra -Iinclude
# Source files
SRC := src/main.c src/parser.c src/renderer.c src/utils.c
OBJ := $(SRC:.c=.o)
# Output binary
BIN := graphxml
# SDL2 paths (optional override)
SDL_CFLAGS ?= $(shell sdl2-config --cflags)
SDL_LDFLAGS ?= $(shell sdl2-config --libs)
# Libraries
LIBS := -lSDL2_ttf -lm
# Detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# macOS
CFLAGS += $(SDL_CFLAGS)
LDFLAGS := $(SDL_LDFLAGS) $(LIBS)
else ifeq ($(UNAME_S),Linux)
# Linux
CFLAGS += $(SDL_CFLAGS)
LDFLAGS := $(SDL_LDFLAGS) $(LIBS)
else ifeq ($(OS),Windows_NT)
# Windows (MSYS2 / MinGW)
CFLAGS += -I/mingw64/include/SDL2
LDFLAGS := -L/mingw64/lib -lmingw32 -lSDL2main -lSDL2 -lSDL2_ttf -lm
endif
# ===============================
# Rules
# ===============================
all: $(BIN)
$(BIN): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJ) $(BIN)
# Optional: run example
run: $(BIN)
@echo "Running GraphXML example..."
./$(BIN) examples/example.graphxml assets/fonts/DejaVuSans.ttf