-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCppTemplate1.mk
45 lines (35 loc) · 877 Bytes
/
CppTemplate1.mk
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
# https://github.com/tch0/MyConfigurations/blob/master/MakefileTemplate/CppTemplate1.mk
# Makefile template 1:
# For C++ sigle files, every C++ file will get a executable.
# make debug=yes to compile with -g
# make system=windows for windows system
.PHONY : all
.PHONY .IGNORE : clean
# add you own include path/library path/link library to CXXFLAGS
CXX = g++
CXXFLAGS +=
RM = rm
# debug
ifeq ($(debug), yes)
CXXFLAGS += -g
else
CXXFLAGS += -O3
endif
# filenames and targets
all_source_files := $(wildcard *.cpp)
all_targets := $(basename $(all_source_files))
# all targets
all : $(all_targets)
# compile
% : %.cpp
-$(CXX) $^ -o $@ $(CXXFLAGS)
# system: affect how to clean and executable file name
# value: windows/unix
system = unix
ifeq ($(system), windows)
all_targets := $(addsuffix .exe, $(all_targets))
RM := del
endif
# clean
clean :
-$(RM) $(all_targets)