-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (52 loc) · 1.55 KB
/
Copy pathMakefile
File metadata and controls
67 lines (52 loc) · 1.55 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
##### Makefile
##### recommended compiler and make is gcc
##### for Windows please use MinGW
##### (after installing please put C:\msys64\ucrt64\bin and
##### C:\msys64\usr\bin to system environment variable "Path")
# Compiler settings - Can be customized.
CC = g++
CXXFLAGS = -std=c++20 -Wall -O3
LDFLAGS =
# Makefile settings - Can be customized.
APPNAME = Calendar
EXT = .cpp
SRCDIR = src
OBJDIR = obj
BINDIR = bin
############## Do not change anything from here downwards! #############
SRC = $(wildcard $(SRCDIR)/*$(EXT))
OBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)/%.o)
DEP = $(OBJ:$(OBJDIR)/%.o=%.d)
MKDIR = mkdir
RM = rm
########################################################################
####################### Targets beginning here #########################
########################################################################
# Default target
all: $(OBJDIR)/ $(BINDIR)/ $(APPNAME)
# Builds the app
$(APPNAME): $(OBJ)
$(CC) $(CXXFLAGS) -o $(BINDIR)/$@ $^ $(LDFLAGS)
# Creates obj folder if doesn't exist
%/:
$(MKDIR) $@
# Creates the dependecy rules
%.d: $(SRCDIR)/%$(EXT)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:%.d=$(OBJDIR)/%.o) >$@
# Includes all .h files
-include $(DEP)
# Building rule for .o files and its .c/.cpp in combination with all .h
$(OBJDIR)/%.o: $(SRCDIR)/%$(EXT)
$(CC) $(CXXFLAGS) -o $@ -c $<
# Cleans complete project
.PHONY: clean
clean:
$(RM) $(OBJ) $(DEP) $(BINDIR)/$(APPNAME)
# Cleans only all files with the extension .d
.PHONY: cleandep
cleandep:
$(RM) $(DEP)
# run after build
.PHONY: run
run: all
./$(BINDIR)/$(APPNAME)