-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (62 loc) · 2.35 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
.PHONY : test1 test2
CC = gcc
STDC = -std=gnu99
STD_FLAGS = -Wall -pedantic
THREAD_FLAGS = -lpthread
INCLUDES = -I./headers
O_FOLDER = build/objs
DEPS_FOLDER = sources/Dependencies
client_deps = sources/client.c libs/libds.so libs/libapi.so
server_deps = sources/server.c libs/libserv.so
all: client server
client: $(client_deps)
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) sources/client.c -g -o client -Wl,-rpath,./libs -L ./libs -lds -lapi $(THREAD_FLAGS)
server: $(server_deps)
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) sources/server.c -g -o server -Wl,-rpath,./libs -L ./libs -lserv -lapi $(THREAD_FLAGS)
# Libraries
libs/libds.so: $(O_FOLDER)/queue.o $(O_FOLDER)/linked_list.o $(O_FOLDER)/pthread_custom.o $(O_FOLDER)/utility.o
$(CC) -shared -o libs/libds.so $^
libs/libserv.so: $(O_FOLDER)/queue.o $(O_FOLDER)/linked_list.o $(O_FOLDER)/ht.o $(O_FOLDER)/pthread_custom.o $(O_FOLDER)/utility.o $(O_FOLDER)/config_parser.o $(O_FOLDER)/doubly_ll.o
$(CC) -shared -o libs/libserv.so $^
$(O_FOLDER)/config_parser.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/config_parser.c -g -c -fPIC -o $@
$(O_FOLDER)/pthread_custom.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/pthread_custom.c -g -c -fPIC -o $@
$(O_FOLDER)/queue.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/queue.c -g -c -fPIC -o $@
$(O_FOLDER)/doubly_ll.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/doubly_ll.c -g -c -fPIC -o $@
$(O_FOLDER)/linked_list.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/linked_list.c -g -c -fPIC -o $@
$(O_FOLDER)/ht.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/ht.c -g -c -fPIC -o $@
libs/libapi.so: $(O_FOLDER)/s_api.o $(O_FOLDER)/utility.o
$(CC) -shared -o libs/libapi.so $^
$(O_FOLDER)/s_api.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/s_api.c -g -c -fPIC -o $@
$(O_FOLDER)/utility.o:
$(CC) $(STDC) $(INCLUDES) $(STD_FLAGS) $(DEPS_FOLDER)/utility.c -g -c -fPIC -o $@
cleanall:
@echo "Garbage Removal"
-rm -f read_files/*
-rm -f expelled_dir/*
-rm -f build/objs/*.o
-rm -f libs/*.so
-rm /tmp/server_sock
-rm -rf expelled_dir
-rm -rf read_files
-rm -rf ServerLogs
-rm -rf build
-rm -rf libs
mkdir expelled_dir
mkdir read_files
mkdir build
mkdir build/objs
mkdir libs
# tests
test0: client server
./tests/test00.sh
test1: client server
./tests/test01.sh
test2: client server
./tests/test02.sh