Hello, fellow Embedded Wizards!!
In the previous blog post on build systems, we learned what a build system is and its significance in the software life cycle. We ended that post by introducing the
make build system. Today we will dive deeper into the
make build system and learn how it can be used to simplify the build process.
In the realm of embedded software development, where projects grow in complexity, the need for efficient and automated build systems becomes utmost. Enter
make - a tool that simplifies the compilation, dependency management, and execution of your code. In this blog post, we will explore the syntax and structure of
What's a Makefile? 🤔
Makefile is a script executed by the make tool that lets the developer define the flow of the build process. It works by defining dependencies between the source files and specifying the commands required to compile and link them. So, now the developer can compile the codebase using a single command, instead of manually compiling each source file separately.
For this tutorial, we will use a simple calculator application as an example. You can access the source code for this tutorial from the inpyjama GitHub page.
The repository structure consists of the following files and directories:
- LICENSE: This file contains the license under which the code in the repository is released. It specifies the permissions, restrictions, and obligations associated with using the code.
- Makefile: The Makefile is used for building and managing the project. It includes instructions on how to compile the source code, handle dependencies, and generate the final executable or other artifacts.
- README.md: This is the main README file for the repository.
- src: This directory contains the source code files of the project. It may include subdirectories for organizing the codebase further. The source code includes the
main.cand multiple subdirectories that implement functionalities for the calculator.
Let's have a look at the Makefile and try to understand its structure and build flow.