Compiling with Make
We have already seen some example usage with Make. Here, we will recap on what Make is and how we can use it to compile programs so that we don't have to type GCC commands.
Getting ready
All you need for this recipe is the GCC compiler and Make. You have already installed these tools if you followed Chapter 1, Getting the Necessary Tools and Writing Our First Linux Programs.
How to do it…
We will write a small program that calculates the circumference of a circle, given the radius. We will then use the Make tool to compile it. The Make tool is smart enough to figure out the name of the source code file.
- Write the following code and save it as
circumference.c
. This program is built on the same code asmph-to-kph.c
from the previous chapter:#include <stdio.h> #include <stdlib.h> #include <string.h> #define PI 3.14159 int main(void) { Â Â Â char radius[20] = { 0 }; Â Â Â while(fgets(radius, sizeof...