• 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. prt-get Command Examples in Linux
  2. doctl kubernetes cluster: Manage Kubernetes clusters and view configuration options relating to clusters
  3. duplicity: Creates incremental, compressed, encrypted and versioned backups
  4. CentOS / RHEL : How to find RPM installation date and time
  5. autorandr Command Examples in Linux
  6. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  7. mkfs.fat: command not found
  8. electrum: Ergonomic Bitcoin wallet and private key management
  9. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 7 to scan more than 16,383 LUNs
  10. enum4linux: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright