I want to use the variables from another Makefile under the directory ~/kernelbuild/linux-3.14.37 in my own shell script.Following is the variables that I need:VERSION = 3PATCHLEVEL = 14SUBLEVEL = 37The problem is that I am not allowed to change the Makefile, so export variable is not an option here. Also, I have seen people saying to have a separate file that contains all the common variables need. This is practical but I need to put everything just in my single shell script.I tried to include . ~/kernelbuild/linux-3.14.37/Makefile in my shell script and I thought I should be able to use those variables, but it gives me following errors:/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 1: VERSION: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 2: PATCHLEVEL: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 3: SUBLEVEL: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 4: EXTRAVERSION: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 5: NAME: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 17: MAKEFLAGS: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 20: unexport: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 26: unexport: command not found/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 47: syntax error near unexpected token `$(origin V),'/home/jl4347/kernelbuild/linux-3.14.37/Makefile: line 47: `ifeq ($(origin V), command line)'I think that's because the Makefile is not following the syntax rules for shell script. How can I do that then?Thanks in advance!
How to take variables from another Makefile in shell script
shell script;arch linux;kernel modules;make
You may try to extract the values with grep and sed. For example:filename=$HOME/kernelbuild/linux-3.14.37/Makefileversion=$(grep -m 1 VERSION $filename | sed 's/^.*= //g')This greps for first occurrence of VERSION in Makefile