-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
175 lines (147 loc) · 5.57 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
VPATH = algos arch ds graphs net sorting trees tests
CFLAGS := gcc -g -std=c11 -Wall -Wextra -Wpedantic -Ialgos -Ids -Igraphs -Isorting -Itrees
CPPFLAGS := g++ -std=c++11 -Wall -Wextra -Wpedantic
ALGO_PROGS := binary_search
ALGO_OBJS := $(addsuffix .o,$(ALGO_PROGS))
ALGO_TESTS := $(addsuffix _test,$(ALGO_PROGS))
ARCH_PROGS := b2n n2b h2n h2b binadd \
isodd div16 bitcmp endiancheck
ARCH_OBJS := $(addsuffix .o,$(ALGO_PROGS))
DS_PROGS := array c_buffer cl_list dl_list h_table \
p_queue queue sl_list stack str
DS_OBJS := $(addsuffix .o,$(DS_PROGS))
DS_TESTS := $(addsuffix _test,$(DS_PROGS))
GRAPH_PROGS := graph
GRAPH_OBJS := $(addsuffix .o,$(GRAPH_PROGS))
GRAPH_TESTS := $(addsuffix _test,$(GRAPH_PROGS))
SORT_PROGS := bubble_sort heap_sort insertion_sort merge_sort \
quick_sort selection_sort
SORT_OBJS := $(addsuffix .o,$(SORT_PROGS))
SORT_TESTS := $(addsuffix _test,$(SORT_PROGS))
TREES_PROGS := bs_tree bs_tree_map rb_tree rb_tree_map trie
TREES_OBJS := $(addsuffix .o,$(TREES_PROGS))
TREES_TESTS := $(addsuffix _test,$(TREES_PROGS))
NET_PROGS := daytime_server \
daytime_client \
stream_server \
stream_client \
multi_http_server \
access \
atexit \
broken_pipe \
byte_order \
conn_recv_buff_mss \
date \
date_cli \
date_cli_read_peek \
date_cli_recv_buff \
date_cli_getsockname \
date_serv \
date_serv_print_cli \
dup2 \
echo_cli \
echo_cli_chargen \
echo_cli_connect_timeo \
echo_cli_linger \
echo_cli_poll \
echo_cli_select \
echo_cli_sigpipe \
echo_cli_udp \
echo_cli_udp_connect \
echo_cli_udp_dns \
echo_serv \
echo_serv_stdio \
echo_serv_tcp_udp \
echo_serv_udp \
f1 \
file_lock \
file_traversal \
file_type \
gai \
get_host_names \
get_host_names_addr \
getnameinfo_timeo \
http_server \
http_server_image \
http_server_multi \
http_server_nonblock \
iocopy \
ipv4_bind \
ipv6_bind \
inet_pton_loose \
local_ip_addrs \
mmap \
msg_queue_srv \
msg_queue_cli \
pass \
pipe \
prompt \
prompt_signal \
read_write \
send_recv_buff_sizes \
setbuf \
shared_mem_srv \
shared_mem_cli \
sleep \
system \
umask \
uname \
zombie
.PHONY: all
all: algo-tests ds-tests graphs-tests sorting-tests trees-tests
# compiling algo objects
$(ALGO_OBJS):%.o: %.c %.h
$(CFLAGS) -c $^
# compiling ds objects
$(DS_OBJS):%.o: %.c %.h
$(CFLAGS) -c $^
# compiling graphs objects
$(GRAPH_OBJS):%.o: %.c %.h
$(CFLAGS) -c $^
# compiling sorting objects
$(SORT_OBJS):%.o: %.c %.h
$(CFLAGS) -c $^
# compiling tree objects
$(TREES_OBJS):%.o: %.c %.h
$(CFLAGS) -c $^
# compiling algo tests
$(ALGO_TESTS):%: %.c $(ALGO_OBJS) array.o
$(CFLAGS) $^ -o bin/$@
# compiling ds tests
$(DS_TESTS):%: %.c $(DS_OBJS) bs_tree.o
$(CFLAGS) $^ -o bin/$@
# compiling graph tests
$(GRAPH_TESTS):%: %.c $(GRAPH_OBJS) array.o stack.o queue.o dl_list.o
$(CFLAGS) $^ -o bin/$@
# compiling sorting tests
$(SORT_TESTS):%: %.c $(SORT_OBJS) array.o p_queue.o bs_tree.o
$(CFLAGS) $^ -o bin/$@
# compiling tree tests
$(TREES_TESTS):%: %.c $(TREES_OBJS) array.o
$(CFLAGS) $^ -o bin/$@
# hangman program
hangman: other/hangman/hangman.c array.o
$(CFLAGS) $^ -o bin/$@
cp other/hangman/words.txt bin/words.txt
# network programs
$(NET_PROGS):%: net/%.c
$(CFLAGS) $^ -o bin/$@
# arch programs
$(ARCH_PROGS):%: arch/%.c
$(CFLAGS) $^ -o bin/$@
# Run tests
algo-tests: $(ALGO_TESTS)
for t in $^; do ./bin/$$t; done
ds-tests: $(DS_TESTS)
for t in $^; do ./bin/$$t; done
graphs-tests: $(GRAPH_TESTS)
for t in $^; do ./bin/$$t; done
sorting-tests: $(SORT_TESTS)
for t in $^; do ./bin/$$t; done
trees-tests: $(TREES_TESTS)
for t in $^; do ./bin/$$t; done
.PHONY: clean
clean:
rm -f ./*.o ./*.h.gch ./*/*.h.gch
rm -fr ./bin
mkdir ./bin && touch ./bin/.gitkeep