-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (93 loc) · 3.2 KB
/
Makefile
File metadata and controls
133 lines (93 loc) · 3.2 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#Directories
OBJDIR = obj
TESTOBJDIR = tests/obj
TESTBINDIR = tests/bin
#CC specifies which compiler we're using
CC = g++
BMLsrc = $(wildcard src/*.cpp)
BMLobj := $(notdir $(BMLsrc))
BMLobj := $(addprefix $(OBJDIR)/, $(BMLobj))
BMLobj := $(BMLobj:.cpp=.o)
testsrc = $(wildcard tests/src/*.cpp)
testobj := $(notdir $(testsrc))
testobj := $(addprefix $(TESTOBJDIR)/, $(testobj))
testobj := $(testobj:.cpp=.o)
testbin := $(notdir $(testsrc))
testbin := $(addprefix $(TESTBINDIR)/, $(testbin))
testbin := $(testbin:.cpp=)
#CFLAGS specifies the additional compilation options we're using
CFLAGS := -Wall -Wextra -std=c++17
#IFLAGS specifies which directory to check for include
IFLAGS := -Iinc
#LFLAGS specify the libraries we're linking against
LFLAGS := -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lBML
#WFLAGS specifies that we know what we are doing with ar
WFLAGS := -no_warning_for_no_symbols
# If Windows (BOOOOOO)
ifdef OS
RM = del /Q
FixPath = $(subst /,\,$1)
disp := echo
bold := THIS LOOKS LIKE SHIT BECAUSE YOU USE WINDOWS
sgr0 := Loser
# AHHH I HATE WINDOWS
# WHAT DO I HAVE TO LIKE INCLUDE THESE IN THE REPO NOW?!
LFLAGS := -LC:\Development\sdks\i686-w64-mingw32\lib -LC:\Users\benja\Documents\GitHub\BML\bin\libBML.a
IFLAGS := -IC:\Development\sdks\i686-w64-mingw32\include -IC:\Users\benja\Documents\GitHub\BML\inc
EXT := .lib
# If Unix (YAAYYYY!!!)
else
disp := @printf
# Bold Text Variables
bold := $(shell tput bold)
sgr0 := $(shell tput sgr0)
EXT := .a
ifeq ($(shell uname), Darwin)
LPATH = /usr/local/lib
HEADERPATH = /usr/local/include/BML/
else
LPATH = /usr/lib
HEADERPATH = /usr/include/BML/
endif
endif
#all rule for just compiling everything
.PHONY: all
all: BML build Tests
.PHONY: BML
BML: $(BMLobj)
#Tests for only compiling tests
.PHONY: Tests
Tests: BML build install $(testbin)
.PHONY: build
build: $(BMLobj)
$(disp) "$(testbin)"
$(disp) "\n$(bold)----------Building BML LIB File----------------$(sgr0)\n"
ar rc bin/libBML$(EXT) $(BMLobj)
ranlib bin/libBML$(EXT)
.PHONY: install
install: build
@printf "\n$(bold)----------INSTALLING LIBRARY TO DIRECTORY-------$(sgr0)\n"
sudo install -m 644 bin/libBML$(EXT) $(LPATH)
@printf "\n$(bold)--------------PLACING HEADER FILES--------------$(sgr0)\n"
sudo cp -rf inc/* $(HEADERPATH)
ValgrindTest: Tests
valgrind --track-origins=yes --suppressions=window.supp --leak-check=full --show-leak-kinds=all ./tests/bin/AnimationTest
# Rules for Building Tests Binary
tests/bin/%: $(testobj)
$(disp) "\n$(bold)----------COMPILING TEST FILE: $(notdir $@)----------$(sgr0)\n"
$(CC) tests/obj/$(notdir $@).o $(CFLAGS) $(LFLAGS) -o $@
# Rules for BML obj files
$(OBJDIR)/%.o: src/%.cpp
$(disp) "\n$(bold)----------COMPILING BML OBJ FILE: $(notdir $@)----------$(sgr0)\n"
$(CC) $^ $(CFLAGS) $(IFLAGS) -c -o $@
# Rules for test obj files
$(TESTOBJDIR)/%.o: tests/src/%.cpp
$(disp) "\n$(bold)----------COMPILING TEST OBJ FILE: $(notdir $@)----------$(sgr0)\n"
$(CC) $^ $(CFLAGS) $(IFLAGS) -c -o $@
.PHONY: clean
clean:
@printf "\n$(bold)----------REMOVING PREVIOUS BUILDS----------$(sgr0)\n"
rm -f $(BMLobj)
rm -f $(testobj)
rm -f bin/*
rm -f a.out tests/bin/*