Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.34 KB

File metadata and controls

54 lines (37 loc) · 1.34 KB

Notes on Makefiles

General format for Makefiles

target: dependencies
    command
  • target is the thing that will be created
  • dependencies are the things that must be available for the command to run
  • command is the command to run given dependencies (also called the recipe)

Simple makefile

Create a text file called Makefile containing:

say_hello:
    echo "Hello there!"

Inside the directory containing Makefile, run it by executing the command make. The output should be

Hello there!

Create multiple directories

DIR_DATA := data
DIR_BUILD := build

DIRS := $(DIR_DATA) $(DIR_BUILD)

$(DIRS):
    mkdir -p $@

Variable definitions

Misc

  • To run a specific make file (say you have multiple make files Makefile.custom1, Makefile.custom2, etc.), make -f Makefile.custom1

References