Make Concepts

From NovaOrdis Knowledge Base
Revision as of 22:08, 10 January 2024 by Ovidiu (talk | contribs) (→‎External)
Jump to navigation Jump to search

Internal

.PHONY

By default, make targets are assumed to be files on disk. They will be built from other files as result of executing make with that name as argument. However, sometimes you want make to run commands that do not represent physical files in the filesystem, and if there's a file with the same name in the filesystem, make will be confused and will pick up the file. To avoid this, you can disambiguate with .PHONY:

.PHONY: clean
clean: 
  rm -rf *.o


Variables

CURDIR

CURDIR refers to the directory make is run from:

something:
	"$(CURDIR)/scripts/something.sh"

Automatic Variables

https://www.gnu.org/software/make/manual/make.html#Automatic-Variables

$@

The file name of the target of the rule. In a pattern rule that has multiple targets $@ is the name of whichever target caused the rule’s recipe to be run.