top of page

A Simple Makefile

Updated: May 14, 2023


This post presents a simple Makefile that can be used to build 2 programs. Its written to use implicit rules.


Prerequisties


To use this Makefile you need make and GCC. On Ubuntu 16.04.3:

Type sudo apt-get update

Type sudo apt-get install build-essential



Files


Makefile


UDPEchoClient.c


UDPEchoServer.c


Practical.c


Practical.h


Usage


Copy everything into one directory

Type make to clean and build everything

Type make all to build everything

Type make clean to clean everything


Run It


Type ./UDPEchoServer 49152 in one terminal

Type ./UDPEchoClient localhost "Hello!" 49152 repeatedly in another terminal



References

  • This code is from p. 54-59 of TCP/IP Sockets in C: Practical Guide for Programmers (The Morgan Kaufmann Practical Guides Series) 2nd Edition [Amazon] and [link]

  • GNU image from [link]

bottom of page