forked from LytixDev/wander
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (61 loc) · 2.21 KB
/
Copy pathMakefile
File metadata and controls
84 lines (61 loc) · 2.21 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
# Nicolai Brand (lytix.dev), Callum Gran 2022-2023
# See LICENSE for license info
OBJDIR = .obj
SRC = src
DIRS := $(shell find $(SRC) -type d -not -wholename "src/client" -not -wholename "src/gui")
SRCS := $(shell find $(SRC) -type f -name "*.c" -not -wholename "src/client/*" -not -wholename "src/gui/*")
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
CFLAGS = -Iinclude -Wall -Wextra -Wshadow -std=c11
CFLAGS += -DLOGGING
LDFLAGS = -pthread
LDLIBS = -lm
.PHONY: format clean tags bear $(OBJDIR)
TARGET = wander
TARGET_CLIENT = client
TARGET_GUI = gui
TARGET_GUI_MACOS = gui_macos
all: $(TARGET)
$(OBJDIR)/%.o: %.c Makefile | $(OBJDIR)
@echo [CC] $@
@$(CC) -c $(CFLAGS) $< -o $@
$(TARGET): $(OBJS)
@echo [LD] $@
@$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
debug: CFLAGS += -g -DDEBUG
debug: $(TARGET)
clean:
rm -rf $(OBJDIR) $(TARGET) $(TARGET_CLIENT) $(TARGET_GUI) $(TARGET_GUI_MACOS)
tags:
@ctags -R
bear:
@bear -- make
format:
python format.py
$(TARGET_CLIENT):
$(CC) src/client/client.c src/wander/packet.c $(CFLAGS) -o $(TARGET_CLIENT)
$(OBJDIR):
$(foreach dir, $(DIRS), $(shell mkdir -p $(OBJDIR)/$(dir)))
gui: CFLAGS += -DGUI -I/usr/include/freetype2 -I/usr/include/libpng16
gui: LDLIBS += -lglfw -lGLU -lGL -lXrandr -lXxf86vm -lXi -lXinerama -lX11 -lrt -ldl -lfreetype -lGLEW
GUI_SRCS := $(shell find $(SRC)/gui -type f -name "*.c")
GUI_OBJS := $(GUI_SRCS:$(SRC)/gui/%.c=$(OBJDIR)/$(SRC)/gui/%.o)
$(TARGET_GUI): $(GUI_OBJS) $(OBJS)
@echo [LD] $@
@$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(OBJDIR)/$(SRC)/gui/%.o: $(SRC)/gui/%.c Makefile | $(OBJDIR)/$(SRC)/gui
@echo [CC] $@
@$(CC) -c $(CFLAGS) $< -o $@
$(OBJDIR)/$(SRC)/gui:
@mkdir -p $@
$(TARGET_GUI_MACOS): CFLAGS += -DGUI -I/usr/local/include -I/usr/local/include/freetype2
$(TARGET_GUI_MACOS): LDLIBS += -L/usr/local/lib -lglfw -framework OpenGL -lfreetype -lGLEW
GUI_MACOS_SRCS := $(shell find $(SRC)/gui -type f -name "*.c")
GUI_MACOS_OBJS := $(GUI_MACOS_SRCS:$(SRC)/gui/%.c=$(OBJDIR)/$(SRC)/gui_macos/%.o)
$(TARGET_GUI_MACOS): $(GUI_MACOS_OBJS) $(OBJS)
@echo [LD] $@
@$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(OBJDIR)/$(SRC)/gui_macos/%.o: $(SRC)/gui/%.c Makefile | $(OBJDIR)/$(SRC)/gui_macos
@echo [CC] $@
@$(CC) -c $(CFLAGS) $< -o $@
$(OBJDIR)/$(SRC)/gui_macos:
@mkdir -p $@