-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (52 loc) · 1.55 KB
/
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
54
55
56
57
58
59
60
# This is a recursive makefile- do not use in production
# convert to canonical make chain when time permits
#
# recursive file search
rfilelist=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rfilelist,$d/,$2))
# the name of program
TARGET = quetest
CC = g++
# C++ compiler flags
CFLAGS += -Wall -c -std=c++17 #`wx-config --cxxflags` -DBANNER - banner decding not ready yet
LIBS += #`wx-config --libs` -pthread -lconfig
EXT = cc
# source files
SRC = ./src
SRCS := $(call rfilelist,$(SRC),*.$(EXT))
INCLUDES = ./include
CFLAGS += $(addprefix -I,$(INCLUDES))
OBJS = $(SRCS:%.$(EXT)=%.o)
DEBUG_HELPERS = $(SRCS:%.$(EXT)=%.debug)
OPTIMIZE_HELPERS = $(SRCS:%.$(EXT)=%.optim)
OBJDEBOUT = $(@:%.debug=%.o)
OBJOPTOUT = $(@:%.optim=%.o)
DEBOUT = $(@:%.debug=%.$(EXT))
OPTOUT = $(@:%.optim=%.$(EXT))
# rules for debug build and optimized build
%.debug: %.$(EXT)
$(CC) $(CFLAGS) -ggdb -D_DEBUG -DDEBUG -o $(OBJDEBOUT) $(DEBOUT)
rm -f $(@.debug=%.debug)
touch -f $@
%.optim: %.$(EXT)
$(CC) $(CFLAGS) -O2 -DNDEBUG -o $(OBJOPTOUT) $(OPTOUT)
rm -f $(@.optim=%.optim)
touch -f $@
# rules for object files
%.o: %.$(EXT)
$(CC) $(CFLAGS) $?
# default build
all: debug
# debug build
debug: $(DEBUG_HELPERS)
test -s $@ || mkdir $@
$(CC) $(OBJS) -o debug/$(TARGET) $(LIBS)
rm -f $(DEBUG_HELPERS)
# optimized build
optim: $(OPTIMIZE_HELPERS)
test -s $@ || mkdir $@
$(CC) $(OBJS) -o optim/$(TARGET) $(LIBS)
rm -f $(OPTIMIZE_HELPERS)
strip optim/$(TARGET)
# clean rule
clean:
rm -f $(OBJS) $(DEBUG_HELPERS) $(OPTIMIZE_HELPERS)