-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
44 lines (34 loc) · 947 Bytes
/
makefile
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
CC = g++
CFLAGS = -std=c++17 -Wall
LDFLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lopenal -lalut -lenet -pthread
MEDIADIR := media
TARGET := myapp
RELEASE := release.zip
INCDIR := include
OBJDIR := obj
SRCS := $(wildcard src/*/*/*/*.cpp) $(wildcard src/*/*/*.cpp) $(wildcard src/*/*.cpp) $(wildcard src/*.cpp)
OBJS := $(patsubst src/%.cpp,obj/%.o,$(SRCS))
DEPS := $(OBJS:.o=.d)
CFLAGS += -MMD -MP
all: $(DIRS) $(TARGET)
debug: CFLAGS+= -g
debug: $(DIRS) $(TARGET)
release: $(RELEASE)
release: LDFLAGS:= -Bstatic $(LDFLAGS)
$(RELEASE):$(DIRS) $(TARGET)
mkdir -p bin
rm -f $(RELEASE)
cp $(TARGET) bin/$(TARGET)
cp -r $(MEDIADIR) bin/$(MEDIADIR)
cd bin; zip -r ../$(RELEASE) *
rm -rf bin
$(DIRS):
mkdir -p $(DIRS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) -I $(INCDIR)
$(OBJDIR)/%.o: src/%.cpp
@mkdir -p $(@D)
$(CC) -c $< -o $@ $(CFLAGS) -I $(INCDIR)
clean:
rm -rf $(TARGET) $(OBJDIR) $(DEPS) $(RELEASE)
-include $(DEPS)