-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
37 lines (28 loc) · 789 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
CC = g++
CFLAGS = -g -O3
TARGET = main
# Dir's for header .cpp and obj files
IDIR=include
SDIR=src
ODIR=$(SDIR)/obj
SRCS=$(wildcard $(SDIR)/*.cpp) # Identify all source files
DEPS=$(wildcard $(IDIR)/*.hpp) # Identify all include files
OBJ=$(patsubst $(SDIR)/%.cpp,$(ODIR)/%.o,$(SRCS)) # Indentify object file names
# Rule to make all .cpp files into object files
# -c tells the compiler to create obj file.
# If any header file is changed then all
# files all compiled again
$(ODIR)/%.o: $(SDIR)/%.cpp $(DEPS)
@$(CC) $< -c -o $@ $(CFLAGS)
# Rule to make obj files into exectuable
make: $(OBJ)
@$(CC) -o $(TARGET) $(OBJ) $(CFLAGS)
.PHONY: print clean cleanall
print:
@echo $(SRCS)
@echo $(OBJ)
@echo $(DEPS)
clean:
@rm -f $(ODIR)/*.o
cleanall:
@rm -f $(TARGET) $(ODIR)/*.o