-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
43 lines (34 loc) · 1006 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
# the name of the executable to be created
BIN_NAME = nessie
CXX = g++
CXXFLAGS = -g -Wall -Wextra
LIBS =
# Folders
SRC_PATH = ./src
BUILD_PATH = ./build
BIN_PATH = ./bin
# Code lists
SRC_EXT = cpp
SOURCES := $(shell find $(SRC_PATH) -type f -name *.$(SRC_EXT))
OBJECTS := $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
INCLUDES = -I include -I vendor -I /usr/include
# SDL flags
SDL_CFLAGS := $(shell sdl2-config --cflags)
SDL_LDFLAGS := $(shell sdl2-config --libs)
#SDL_LDFLAGS := $(shell sdl2-config --libs sdl2 SDL2_image)
# Function used to check variables. Use on the command line:
# make print-VARNAME
# Useful for debugging and adding features
print-%: ; @echo $*=$($*)
# link the executable
$(BIN_PATH)/$(BIN_NAME): $(OBJECTS)
$(CXX) $(OBJECTS) -o $@ $(SDL_LDFLAGS)
$(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT) | dirs
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ $(SDL_CFLAGS)
.PHONY: dirs
dirs:
mkdir -p $(dir $(OBJECTS))
mkdir -p $(BIN_PATH)
.PHONEY: clean
clean:
rm -r build/