-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
106 lines (84 loc) · 3.68 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
CC = gcc
LINKER = gcc -o
CLIBS = -lcurl -lm -lpthread
rm = rm -f
all: CFLAGS = -Wall -Werror -pedantic -std=gnu99 -Wno-unused-result -O3
debug: CFLAGS = -Wall -Werror -pedantic -std=gnu99 -g
SRCDIR = src
TESTDIR = test
OBJDIR = obj
BINDIR = bin
COMMONDIR = $(SRCDIR)/common
CLIENTDIR = $(SRCDIR)/client
WINPROBDIR = $(SRCDIR)/winprob
TESTCOMMONDIR = $(TESTDIR)/common
TESTALLDIR = $(TESTDIR)/unit
TESTAIDIR = $(TESTDIR)/ai
CLIENT_INCSRC = $(COMMONDIR) $(CLIENTDIR)
WINPROB_INCSRC = $(COMMONDIR) $(WINPROBDIR)
TEST_INCSRC = $(COMMONDIR) $(TESTCOMMONDIR)
TESTALL_INCSRC = $(COMMONDIR) $(TESTCOMMONDIR) $(TESTALLDIR)
TESTAI_INCSRC = $(COMMONDIR) $(TESTCOMMONDIR) $(TESTAIDIR)
CLIENT_INC = $(foreach d, $(CLIENT_INCSRC), -I$d)
WINPROB_INC = $(foreach d, $(WINPROB_INCSRC), -I$d)
TEST_INC = $(foreach d, $(TEST_INCSRC), -I$d)
TESTALL_INC = $(foreach d, $(TESTALL_INCSRC), -I$d)
TESTAI_INC = $(foreach d, $(TESTAI_INCSRC), -I$d)
COMMON_SOURCES = $(wildcard $(COMMONDIR)/*.c)
CLIENT_SOURCES = $(wildcard $(CLIENTDIR)/*.c)
WINPROB_SOURCES = $(wildcard $(WINPROBDIR)/*.c)
TESTCOMMON_SOURCES = $(wildcard $(TESTCOMMONDIR)/*.c)
TESTALL_SOURCES = $(wildcard $(TESTALLDIR)/*.c)
TESTAI_SOURCES = $(wildcard $(TESTAIDIR)/*.c)
COMMON_OBJECTS := $(patsubst $(COMMONDIR)/%.c, $(OBJDIR)/%.o, $(COMMON_SOURCES))
CLIENT_OBJECTS := $(patsubst $(CLIENTDIR)/%.c, $(OBJDIR)/%.o, $(CLIENT_SOURCES))
WINPROB_OBJECTS := $(patsubst $(WINPROBDIR)/%.c, $(OBJDIR)/%.o, $(WINPROB_SOURCES))
TESTCOMMON_OBJECTS := $(patsubst $(TESTCOMMONDIR)/%.c, $(OBJDIR)/%.o, $(TESTCOMMON_SOURCES))
TESTALL_OBJECTS := $(patsubst $(TESTALLDIR)/%.c, $(OBJDIR)/%.o, $(TESTALL_SOURCES))
TESTAI_OBJECTS := $(patsubst $(TESTAIDIR)/%.c, $(OBJDIR)/%.o, $(TESTAI_SOURCES))
OBJECTS := $(wildcard $(OBJDIR)/*.o)
TARGETS := pokerclient winprob testall testai
TARGETS := $(foreach t, $(TARGETS), $(BINDIR)/$t)
all: $(TARGETS)
debug: $(TARGETS)
ctags -R *
$(BINDIR)/pokerclient: $(COMMON_OBJECTS) $(CLIENT_OBJECTS)
@echo "\t[link] "$@
@$(LINKER) $@ $(CFLAGS) $(CLIENT_INC) $(COMMON_OBJECTS) $(CLIENT_OBJECTS) $(CLIBS)
@echo "\n"$@" built successfully.\n"
$(BINDIR)/winprob: $(COMMON_OBJECTS) $(WINPROB_OBJECTS)
@echo "\t[link] "$@
@$(LINKER) $@ $(CFLAGS) $(WINPROB_INC) $(COMMON_OBJECTS) $(WINPROB_OBJECTS) $(CLIBS)
@echo "\n"$@" built successfully.\n"
$(BINDIR)/testall: $(COMMON_OBJECTS) $(TESTCOMMON_OBJECTS) $(TESTALL_OBJECTS)
@echo "\t[link] "$@
@$(LINKER) $@ $(CFLAGS) $(TESTALL_INC) $(COMMON_OBJECTS) $(TESTCOMMON_OBJECTS) $(TESTALL_OBJECTS) $(CLIBS)
@echo "\n"$@" built successfully.\n"
$(BINDIR)/testai: $(COMMON_OBJECTS) $(TESTCOMMON_OBJECTS) $(TESTAI_OBJECTS)
@echo "\t[link] "$@
@$(LINKER) $@ $(CFLAGS) $(TESTAI_INC) $(COMMON_OBJECTS) $(TESTCOMMON_OBJECTS) $(TESTAI_OBJECTS) $(CLIBS)
@echo "\n"$@" built successfully.\n"
$(COMMON_OBJECTS): $(OBJDIR)/%.o : $(COMMONDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) -c $< -o $@ $(CLIBS)
$(CLIENT_OBJECTS): $(OBJDIR)/%.o : $(CLIENTDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) $(CLIENT_INC) -c $< -o $@ $(CLIBS)
$(WINPROB_OBJECTS): $(OBJDIR)/%.o : $(WINPROBDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) $(WINPROB_INC) -c $< -o $@ $(CLIBS)
$(TESTCOMMON_OBJECTS): $(OBJDIR)/%.o : $(TESTCOMMONDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) $(TEST_INC) -c $< -o $@ $(CLIBS)
$(TESTALL_OBJECTS): $(OBJDIR)/%.o : $(TESTALLDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) $(TESTALL_INC) -c $< -o $@ $(CLIBS)
$(TESTAI_OBJECTS): $(OBJDIR)/%.o : $(TESTAIDIR)/%.c
@echo "\t[compile] "$<
@$(CC) $(CFLAGS) $(TESTAI_INC) -c $< -o $@ $(CLIBS)
clean:
@echo "Removing object files"
@$(rm) $(OBJECTS)
remove: clean
@echo "Removing object files and binaries
@$(rm) $(TARGETS)