Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.69 KB

README.md

File metadata and controls

58 lines (38 loc) · 1.69 KB

Makefiles

Learning Makefiles: A Beginner's Guide

Makefiles are essential in the Linux ecosystem for managing program compilation and linking. Let's explore what they are, why they exist, and how to create a basic Makefile.

for running this tutorial in your shell :

$ git clone https://github.com/SkillfulElectro/Makefiles.git
$ make

the automatated version opens each example for you and then runs it to you see the result .

What Are Makefiles?

Makefiles guide the make utility during compilation and linking. They determine which parts of a program need recompilation, making development more efficient.

Why Do Makefiles Exist?

Makefiles decide which files require recompilation. When files change, Make ensures only necessary parts get recompiled.

Alternatives to Make

While Make is widely used, other build systems exist:

  • SCons, CMake, Bazel, and Ninja for C/C++ projects.
  • Ant, Maven, and Gradle for Java.
  • Go, Rust, and TypeScript have their own build tools.
  • Interpreted languages like Python, Ruby, and raw JavaScript don't need Makefiles.

Versions and Types of Make

This guide focuses on GNU Make, the standard implementation on Linux and macOS.

Basic Makefile Example

Create a Makefile with the following content:

hello:
    echo "Hello, World"

Remember to use TABs for indentation. Run make in the same directory to see the output:

$ make
echo "Hello, World"
Hello, World

For more resources, explore the Makefile Cookbook for templates and detailed comments.

Happy coding! 🛠️🌟

source :

https://www.gnu.org/software/make/manual/html_node/

https://makefiletutorial.com/