O'Reilly logo

Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required