• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

What are makefiles in Linux

by admin

A makefile is a file that contains instructions used by a compiler to build a program from source code. These instructions typically define the resources that the program depends on in order to function properly, as well as any additional directives as defined by the developer. In the following simple example, the program executable myprog depends on two object files, mymain.o and myfunc.o: myprog:

mymain.o myfunc.o
    gcc -o myprog mymain.o myfunc.o
mymain.o: mymain.c
    gcc -c mymain.c
myfunc.o: myfunc.c
    gcc -c myfunc.c

On the second line, gcc compiles the objects necessary for the program to run. On the remaining lines, each object is associated with a C source code file, then compiled using that source file. Using this approach, if you make changes to a single C source file (e.g., mymain.c), the make command will be able to efficiently rebuild the program based on the directives in the makefile.

Filed Under: Linux

Some more articles you might also be interested in …

  1. dir Command Examples in Linux
  2. “git merge-base” Command Examples
  3. latte-dock Command Examples in Linux
  4. renice: command not found
  5. mat2 Command Examples
  6. AdGuardHome – A network-wide software for blocking ads & tracking (Command Examples)
  7. mate-screenshot: command not found
  8. drupal-check: Check Drupal PHP code for deprecations
  9. gs Command Examples in Linux
  10. ld Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright