forked from thecardkid/terminally-tetris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (66 loc) · 1.97 KB
/
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
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
85
86
87
88
# A Makefile based on the Google Test sample Makefile
# https://github.com/google/googletest/blob/master/googletest/make/Makefile
#
# Modified with the help of http://nuclear.mutantstargoat.com/articles/make/
#
# SYNOPSIS:
#
# make - makes the main file.
# make clean - removes all files generated by make.
# make test - runs all tests
# Create a build directory
BUILD_DIR = build
dummy_build_folder := $(shell mkdir -p $(BUILD_DIR))
# Which compilers to use
CPP=g++ -std=c++11
C=gcc
# Where to find source code.
SRC_DIR = src
# Test code
TEST_DIR = tests
# Where to find build objects
BUILD_DIR = build
# The working directory
CURRENT_DIR = $(shell pwd)
# Dependency header files
DEP_HEADERS = $(SRC_DIR)/*.h
TEST_HEADERS = $(TEST_DIR)/*.h
VPATH = $(SRC_DIR):$(BUILD_DIR)
# Flags passed to the preprocessor.
# Set Google Test's header directory as a system directory, such that
# the compiler doesn't generate warnings in Google Test headers.
CPPFLAGS += -isystem $(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -pthread
# C flags
CFLAGS = -std=c99
# Graphics flags
GRAPHICSFLAGS = -lglut -lGL -lGLU
# ncurses flag
LDFLAGS = -lncurses
# The Makefile's run command
RUN = $(BUILD_DIR)/ttetris
# Build targets.
.PHONY: all
all : $(RUN)
LD_LIBRARY_PATH=$(CURRENT_DIR)/build
.PHONY: clean
clean :
rm -f $(BUILD_DIR)/*
# Builds the main file.
OBJ = $(BUILD_DIR)/main.o \
$(BUILD_DIR)/utils.o $(BUILD_DIR)/renderer.o \
$(BUILD_DIR)/block_factory.o $(BUILD_DIR)/controller.o \
$(BUILD_DIR)/scorer.o
# ==== Make rules ====
$(BUILD_DIR)/ttetris: $(OBJ)
$(C) $^ -o $@ $(LDFLAGS) $(CFLAGS)
# Builds the dependency object files.
$(BUILD_DIR)/main.o : $(SRC_DIR)/main.c $(DEP_HEADERS)
$(C) -c $< -o $@ $(CFLAGS)
# Builds cpp files in src/
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h
$(CPP) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
# Builds c files in src/
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c $(SRC_DIR)/%.h $(DEP_HEADERS)
$(C) -c $< -o $@ $(CFLAGS)