Exercise 45. A Simple TCP/IP Client

Im going to use the RingBuffer to create a very simplistic network testing tool that I call netclient. To do this, I have to add some stuff to the Makefile to handle little programs in the bin/ directory.

Augment the Makefile

First, add a variable for the programs just like the unit test’s TESTS and TEST_SRC variables:

PROGRAMS_SRC=$(wildcard bin/*.c) PROGRAMS=$(patsubst %.c,%,$(PROGRAMS_SRC))

Then, you want to add the PROGRAMS to the all target:

all: $(TARGET) $(SO_TARGET) tests $(PROGRAMS)

Then, add PROGRAMS to the rm line in the clean target:

rm –rf build $(OBJECTS) $(TESTS) $(PROGRAMS)

Finally, you just need a target ...

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.