M option in make command, Makefile

c, linux, linux-device-driver, linux-kernel, makefile

Solution

`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`.

Problem

``` 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 ?

Original source