-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (35 loc) · 829 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
#-----------------------------------#
# Demo Makefile #
#-----------------------------------#
# Compiler
CXX = g++
# Target
TARGET = read_header
# Debugging
# Do make DEBUG=1 for debug build, otherwise build with level 2 optimization
ifeq ($(DEBUG), 1)
DBG = -g -O0
else
DBG = -O2
endif
# Options and includes
OPTS = -Wall $(DBG)
INCL_PATHS = -I./
# Flags for c++ files
CPPFLAGS = $(OPTS) $(INCL_PATHS)
# Link flags & libraries
LDFLAGS = $(OPTS)
LDLIBS =
# Objects and includes
SRCS = $(wildcard *.cpp)
OBJS = $(patsubst %.cpp,%.o,$(SRCS))
INCL = $(wildcard *.h) Makefile
.PHONEY: all clean
# Rules
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@
clean:
@printf "Cleaning: \n"
@find . -type f -name '*.o' -print0 | xargs -0 -I % sh -c 'printf "% "; rm -f %'
rm -f $(TARGET)