-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (45 loc) · 1.29 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
CC=gcc
CFLAGS=-Wall -g -Iutils -Iinclude -pthread
BIN=bin/
SRC=src/
OBJS=obj/serverutils.o
EXECUTABLES=bin/webserver
SHOWIP=showip
SOCKET=socket
SERVER=webserver
LIB=lib/serverutils.a lib/httputils.a lib/fileutils.a
all: $(EXECUTABLES)
clean:
rm -f obj/* bin/* lib/*
showip: bin/$(SHOWIP)
bin/showip: obj/showip.o
$(CC) $(CFLAGS) -o bin/$(SHOWIP) obj/$(SHOWIP).o
obj/showip.o: src/$(SHOWIP).c
$(CC) $(CFLAGS) -o obj/showip.o -c src/$(SHOWIP).c
socket: bin/$(SOCKET)
bin/$(SOCKET): obj/$(SOCKET).o
$(CC) $(CFLAGS) -o bin/$(SOCKET) obj/$(SOCKET).o
obj/$(SOCKET).o: src/$(SOCKET).c
$(CC) $(CFLAGS) -o obj/$(SOCKET).o -c src/$(SOCKET).c
# Compile the server
server: bin/$(SERVER)
bin/$(SERVER): src/$(SERVER).c $(LIB)
$(CC) $(CFLAGS) -o $@ $< $(LIB)
# Library for server utilities
lib/serverutils.a: obj/serverutils.o
ar ru $@ $<
ranlib $@
obj/serverutils.o: utils/serverutils.c
$(CC) $(CFLAGS) -c -o obj/serverutils.o utils/serverutils.c
# Library for http utilities
lib/httputils.a: obj/httputils.o
ar ru $@ $<
ranlib $@
obj/httputils.o: utils/httputils.c
$(CC) $(CFLAGS) -c -o obj/httputils.o utils/httputils.c
# Library for file utilities
lib/fileutils.a: obj/fileutils.o
ar ru $@ $<
ranlib $@
obj/fileutils.o: utils/fileutils.c
$(CC) $(CFLAGS) -c -o obj/fileutils.o utils/fileutils.c