HomeModules Module 2.1 (Makefiles) Apply
I ntroduce
C onnect
A pply
R eflect
E xtend

Apply - Makefiles

Given the following Makefile:


CC = /usr/bin/cc
CFLAGS = -W -O
LIBS = -lm

server: server.c create_socket.o
$(CC) $(CFLAGS) server.c create_socket.o $(LIBS)

client: client.c++ make_connection.o
$(CC) $(CFLAGS) client.c++ create_socket.o $(LIBS)

create_socket.o: create_socket.c
$(CC) $(CFLAGS) -c create_socket.c -o create_socket.o

make_connection.o: make_connection.c
$(CC) $(CFLAGS) -c make_connection.c -o make_connection.o

clean:
rm server client *.o


Question 1 - Makefiles

What programs are created with this Makefile?

 

Question 2 - Makefiles

 

What does the command

make clean

do?

 

Question 3 - Makefiles

Which libraries are linked with the client and server?

 

Question 4 - Makefiles

What "variables" are defined in this Makefile?

server.c, create_socket.o and client.c, make_connection.o
$(CC) $(CFLAGS) server.c create_socket.o $(LIBS)
CC, CFLAGS, LIBS

 

Question 5 - Makfiles

If you wanted to use a different compiler, which line should you change?

 

 

Click here to move on to the next section (Reflect).