-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmakefile
53 lines (40 loc) · 919 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
45
46
47
48
49
50
51
52
53
# Name of the project
PROJ_NAME=pcv
# .cpp files
C_SOURCE=$(wildcard ./src/*.cpp)
# .h files
H_SOURCE=$(wildcard ./src/*.h)
# Object files
OBJ=$(subst .cpp,.o,$(subst src,obj,$(C_SOURCE)))
# Compiler and linker
CC=g++
# Flags for compiler
CC_FLAGS=-c \
-O3 \
-std=c++17 \
-Wall
# Command used at clean target
RM = rm -rf
#
# Compilation and linking
#
all: objFolder $(PROJ_NAME)
$(PROJ_NAME): $(OBJ)
@ echo 'Building binary using GCC linker: $@'
$(CC) $^ -o $@
@ echo 'Finished building binary: $@'
@ echo ' '
./obj/%.o: ./src/%.cpp ./src/%.h
@ echo 'Building target using GCC compiler: $<'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
./obj/main.o: ./src/main.cpp $(H_SOURCE)
@ echo 'Building target using GCC compiler: $<'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
objFolder:
@ mkdir -p obj
clean:
@ $(RM) ./obj/*.o $(PROJ_NAME) *~
@ rmdir obj
.PCVS: all clean