-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (53 loc) · 1.56 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
# echo -e colors
# WARN : don't put " and use the echo command, not echo -e
LIGHT_ORANGE_COLOR=\e[38;5;216m
TURQUOISE_COLOR=\e[38;5;43m
LIGHT_BLUE_COLOR=\e[38;5;153m
RED_COLOR=\e[38;5;196m
NO_COLOR=\e[0m
# vars
ECHO = @echo # @echo hides this command in terminal, not its output
BIN=bin/main
INCLUDE=inc/
CC=g++
GDB_DEBUGGER_FLAGS=-g
PERSONAL_COMPIL_FLAGS=-D DEBUG # use own flags, see util.hpp
CFLAGS=-I $(INCLUDE) -march=native -O3 $(PERSONAL_COMPIL_FLAGS) $(GDB_DEBUGGER_FLAGS)
LDLIBS=
LDFLAGS=--ansi --pedantic -Wall --std=c++11
SRCS=$(wildcard src/**/*.cpp) $(wildcard src/*.cpp) $(wildcard *.cpp)
OBJS=$(SRCS:src/%.cpp=obj/%.o)
# targets
# set default target : https://stackoverflow.com/questions/2057689/how-does-make-app-know-default-target-to-build-if-no-target-is-specified
.DEFAULT_GOAL := default
.PHONY: default build clean run rebuild rr ww dirs clear
default: build
build: $(BIN)
$(BIN): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
obj/%.o: src/%.cpp
mkdir -p $(dir $@)
$(CC) -o $@ -c $^ $(CFLAGS)
clean:
rm -rf bin/* obj/*
run: $(BIN)
$(ECHO) "$(TURQUOISE_COLOR)*** Executing code *** $(NO_COLOR)"
./$(BIN)
# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
THIS_FILE := $(lastword $(MAKEFILE_LIST))
rebuild:
@$(MAKE) -f $(THIS_FILE) clean
@$(MAKE) -f $(THIS_FILE) build
rr: # rebuild and rerun
@$(MAKE) -f $(THIS_FILE) clean
@$(MAKE) -f $(THIS_FILE) build
@$(MAKE) -f $(THIS_FILE) run
ww: # where and what
pwd
ls -alt
dirs:
mkdir -p bin/
mkdir -p obj/
clear: # alias of clean
@$(MAKE) -f $(THIS_FILE) clean