M option in make command, Makefile

user1047069 picture user1047069 · Nov 30, 2013 · Viewed 19.9k times · Source
make -C ~/kernel-2.6 M=`pwd` modules

What is the meaning in M='pwd' in the line above ?

I could not understand the explanation :

The M= option causes that makefile to move back into your module source directory before trying to build the modules target.

Can you make this more clear ?

Answer

mcabreb picture mcabreb · Jun 12, 2014

M is not an option for make. Note it lacks the hyphen. M is a variable assigned to the execution of make. If make executes a Makefile script, this script can read the variable M and use its contents.

In the example you provide, make will read Makefile in ~/kernel-2.6 and assign your present working directory to variable M. Typically, this will allow for make to return to your current directory after processing Makefile.