-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmakefile
147 lines (102 loc) · 3.76 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
ifeq ($(OS),Windows_NT)
uname_S := Windows
WinBuild = 1
BFLAGS= -DWinBuild
else
uname_S := $(shell uname -s)
ifeq ($(uname_S),Darwin)
uname_S := DARWIN
MacBuild = 1
LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
CPPFLAGS="-I/opt/homebrew/opt/openssl/include"
BFLAGS= -DMacBuild
else
WinBuild = 0
BFLAGS=
endif
endif
$(info $$uname_S is [${uname_S}])
$(info $$LDFLAGS is [${LDFLAGS}])
$(info $$CPPFLAGS is [${CPPFLAGS}])
$(info $$BFLAGS is [${BFLAGS}])
# Declaration of variables
CC = gcc
CC_FLAGS = -w -g $(CPPFLAGS)
TMP = $(SRCS:.c=.c~)
OBJ = *.o *.c~ talker talker2 listener showip conlisten genlisten hostent ptrent getaddrinfo givemeSockets security1 tcpechoserv sendmeudp receivemeudpreceivemeudp_recv tcpbasicclient simptcplisten ticlient tiserver simpletcpserver simpletcpclient socketoptions signal sslc ssls interrrupted macros broadcast_udp support iomodels-blocking iomodels-nonblocking iomodels-signal tc
all: talker talker2 listener showip conlisten genlisten hostent ptrent getaddrinfo givemeSockets security1 tcpechoserv sendmeudp receivemeudp receivemeudp_recv tcpbasicclient simptcplisten ticlient tiserver simpletcpserver simpletcpclient socketoptions signal sslc ssls interrupted macros broadcast_udp support iomodels-blocking iomodels-nonblocking iomodels-signal tc
# targets
tc: trivial-tcp-server.c
$(CC) -Wall -o tc trivial-tcp-server.c
iomodels-blocking: io-models-blocking.c
$(CC) -Wall -o iomodels-blocking io-models-blocking.c
iomodels-nonblocking: io-models-nonblocking.c
$(CC) -Wall -o iomodels-nonblocking io-models-nonblocking.c
iomodels-signal: io-models-signal.c
$(CC) -Wall -o iomodels-signal io-models-signal.c
support: support.c
$(CC) -Wall -o support support.c -Wint-to-pointer-cast
broadcast_udp: broadcast_udp.c
$(CC) -Wall -o broadcast_udp broadcast_udp.c
## By adding -D<variable_name> we can add defines from compiler arguments.
macros: macros.c
$(CC) -Wall -o macros macros.c -DmyDEFINE
interrupted: interrupted.o
$(CC) -Wall -o interrupted interrupted.c
sslc: sslconnect.o
$(CC) -Wall $(CC_FLAGS) $(BFLAGS) -o sslc sslconnect.c -lssl -lcrypto $(LDFLAGS)
ssls: sslserver.o
$(CC) -Wall $(CC_FLAGS) $(BFLAGS) -o ssls sslserver.c -lssl -lcrypto $(LDFLAGS)
signal: signal.o
$(CC) signal.o -o signal
security1: security1.o
$(CC) security1.o -o security1 -lcrypto -lssl $(LDFLAGS)
givemeSockets: givemeSockets.o
$(CC) givemeSockets.o -o givemeSockets
getaddrinfo: getaddrinfo.o
$(CC) getaddrinfo.o -o getaddrinfo
hostent: hostent.o
$(CC) hostent.o -o hostent
ptrent: ptrent.o
$(CC) ptrent.o -o ptrent
sendmeudp: sendmeudp.o
$(CC) sendmeudp.o -o sendmeudp
receivemeudp: receivemeudp.o
$(CC) receivemeudp.o -o receivemeudp
receivemeudp_recv: receivemeudp_recv.o
$(CC) receivemeudp_recv.o -o receivemeudp_recv
talker: talker.o
$(CC) talker.o -o talker
talker2: talker2.o
$(CC) talker2.o -o talker2
listener: listener.o
$(CC) listener.o -o listener
conlisten: concurr-tcp.o
$(CC) concurr-tcp.o -o conlisten
genlisten: concurr-tcp-gen.o
$(CC) concurr-tcp-gen.o -o genlisten
simptcplisten: simple-tcp-gen.o
$(CC) simple-tcp-gen.o -o simptcplisten
tcpbasicclient: tcp_basic_client.o
$(CC) tcp_basic_client.o -o tcpbasicclient
showip: showip.o
$(CC) showip.o -o showip
tcpechoserv: tcp_select_server.o
$(CC) tcp_select_server.o -o tcpechoserv
ticlient: titfortat-tcp-client.o
$(CC) titfortat-tcp-client.o -o $@
tiserver: titfortat-tcp-server.o
$(CC) titfortat-tcp-server.o -o $@
simpletcpserver: simple-tcp-server.o
$(CC) simple-tcp-server.o -o $@
simpletcpclient: simple-tcp-client.o
$(CC) simple-tcp-client.o -o $@
socketoptions: socketoptions.o
$(CC) socketoptions.o -o $@
### Build stuff
# To obtain object files
%.o: %.c
$(CC) -c $(CC_FLAGS) $(BFLAGS) $< -o $@
# To remove generated files
clean:
rm -f $(OBJ)