![write makefile for c program write makefile for c program](https://windows-cdn.softpedia.com/screenshots/Makefile-Creator_2.png)
By running make, hello will still be built using hello.c, however, now we are also building it for GDB debugging with the -g flag, for debug-level optimization with -Og, and with all warnings turned on with -Wall.
![write makefile for c program write makefile for c program](https://discourse.odriverobotics.com/uploads/default/original/2X/1/1228f53d740ac02e49217471d78b3a31a2a51d43.png)
Once all of the dependencies are verified and up to date, then the action is executed.Įxample: Let's look at a Makefile to build a simple C program called hello.cĬFLAGS=-g -Wall -Og CC=gcc hello: hello.c $(CC) $(CFLAGS) -o hello hello.c action The action must be tabbed over it has to be one tab, not spaces. This way make only executes rules if something has changed and will automatically try and create missing dependencies by using their own rules to build them. When make finishes that action to build the dependency, then it will verify it exists and continue down the chain of dependencies.
![write makefile for c program write makefile for c program](https://i.ytimg.com/vi/JlLxFzuPWes/maxresdefault.jpg)
Rule_name: The rule name is what is to be built. Rule1: dependency1 dependency2 action rule2: dependency1 dependency2 dependenc圓 action