yashaswini jayshankar
yashaswini jayshankar

Reputation: 64

Makefile:21: *** recipe commences before first target. Stop

I was trying to build a make file to load a plugin from snap telemetry...when I was trying with the command sudo make build it is showing Makefile:21: *** recipe commences before first target. Stop. this error....In make file I added

export GOROOT=/usr/local/go
export GOPATH=/home/intel/Downloads/snap-tele/gopath
export PATH=$PATH:/usr/local/go/bin:/home/intel/Downloads/snap-tele/gopath/src/github.com/Masterminds/glide
echo $PATH

My make file looks like below when I do cat -e -t -v Makefile where ^I shows tab space and $ represents end of line

^Iexport GOROOT=/usr/local/go$
^Iexport GOPATH=/home/intel/Downloads/snap-tele/gopath$
^Iexport PATH=$PATH:/usr/local/go/bin:/home/intel/Downloads/snap-tele/gopath/src/github.com/Masterminds/glide$
^Iecho $PATH$
$
default:$
^I$(MAKE) deps$
^I$(MAKE) all$
deps:$
^Ibash -c "./scripts/deps.sh"$
test:$
^Ibash -c "./scripts/test.sh $(TEST_TYPE)"$
test-legacy:$
^Ibash -c "./scripts/test.sh legacy"$
test-small:$
^Ibash -c "./scripts/test.sh small"$
test-medium:$
^Ibash -c "./scripts/test.sh medium"$
test-large:$
^Ibash -c "./scripts/test.sh large"$
test-all:$
^I$(MAKE) test-small$
^I$(MAKE) test-medium$
^I$(MAKE) test-large$
check:$
^I$(MAKE) test$
all:$
^Ibash -c "./scripts/build.sh"$
$

Where might be the problem?..as per my knowledge I have given correct tab places..

Upvotes: 4

Views: 9653

Answers (1)

HardcoreHenry
HardcoreHenry

Reputation: 6387

A few things: First, make expects targets/recipe's in the form of:

target: [deps...]
<tab> recipe 1
<tab> recipe 2

And it will run the recipes if and only if the target needs to be rebuilt. You don't specify a target, but you do specify lines that start with tabs (recipes). Make is complaining that you have recipes without a target (as it should).

However, that being said, it does not appear as though you want your lines to be run as part of a recipe (it wouldn't work anyways, as exported variables are not remembered from one recipe line to another, let alone between targets).

You likely want to do:

export GOROOT=/usr/local/go
export GOPATH=/home/intel/Downloads/snap-tele/gopath
export PATH:=${PATH}:/usr/local/go/bin:/home/intel/Downloads/snap-tele/gopath/src/github.com/Masterminds/glide
$(info PATH=${PATH})

without any preceding tabs. The lack of tabs means that make will interpret the commands as part of the makefile interpreter in the make parsing stage. Notice that echo is a shell command, which make does not understand, so I replaced it with make's $(info ... ) which is equivalent.

Edit: Sorry, I missed the access to $PATH -- Make would interpret this as $P followed by the literal ATH. You should use ${PATH} in this case. You should also use := instead of = to avoid recursive assignments (see https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC59)

Upvotes: 1

Related Questions