improved Makefile

This commit is contained in:
inets 2015-04-14 11:15:16 +02:00
parent 36f57fc34f
commit 51923cf4c4
7 changed files with 18 additions and 7 deletions

View file

@ -1,14 +1,25 @@
TARGETS = echo_server echo_client
TARGETS = server client echo_server echo_client
CC = gcc
CFLAGS = -g -D$(DEFINES)
CFLAGS = -g
ifdef DEFINES
CFLAGS += -D$(DEFINES)
endif
all: $(TARGETS) Makefile
clean:
rm -f $(TARGETS)
rm -f *.o *.~
rm -f *.o *~
echo_server: echo_server.o
echo_client: echo_client.o
server: server.o
client: client.o
# Compile with echo support
echo_server: server.c
$(CC) $(CFLAGS) -DECHO $^ -o $@
echo_client: client.c
$(CC) $(CFLAGS) -DECHO $^ -o $@
.PHONY: all clean

BIN
session1/udp_echo/client Executable file

Binary file not shown.

View file

@ -20,7 +20,7 @@ int main(int argc, char *argv[])
{
int fd;
char *lineptr = NULL;
ssize_t linelen = 0;
size_t linelen = 0;
struct sockaddr_in sa = { .sin_family = AF_INET };

BIN
session1/udp_echo/echo_client Executable file

Binary file not shown.

BIN
session1/udp_echo/echo_server Executable file

Binary file not shown.

BIN
session1/udp_echo/server Executable file

Binary file not shown.

View file

@ -45,7 +45,7 @@ int main(int argc, char *argv[])
while (1) {
salen = sizeof(sa);
msglen = recvfrom(fd, &line, sizeof(line), 0, (struct sockaddr *) &sa, &salen)
msglen = recvfrom(fd, &line, sizeof(line), 0, (struct sockaddr *) &sa, &salen);
if (msglen == -1)
handle_error("Failed to recv");