9
votes

I just download the android open source project and tried to build it with make the I receive the message:

build/core/prebuilt.mk:91: *** recipe commences before first target.  Stop.

Here is the corresponding make file snippet (The first line here being line number 89):

ifneq ($(prebuilt_module_is_a_library),)
  ifneq ($(LOCAL_IS_HOST_MODULE),)
    $(transform-host-ranlib-copy-hack)
  else
    $(transform-ranlib-copy-hack)
  endif
endif

I am not sure what's wrong with this make file? The preceding white space on line 91 is a tab.

3
The TAB means that Make interprets line 91 as a command, which should be part of a rule. The snippet is enough to go on; if it is part of a rule, Make is somehow failing to parse the first line of the rule correctly, and if it is not part of a rule, line 91 should not be a command and should not begin with a TAB. - Beta
The question is what comes BEFORE this in the makefile? It seems likely that the variable transform-host-ranlib-copy-hack is supposed to be part of a recipe, so having it be preceded by a TAB is correct. The problem is that make doesn't think you're in a recipe context, which means that something before the ifeq you've shown is not right. My suspicion is that the version of make you have is not compatible with the version used by the author of the open source project and whatever comes before the ifeq is not portable between them. - MadScientist
@MadScientist It seems to be the case. It needs make version 3.8.1 and my make version is 4.0. I thought it is backward compatible. - darklord
There is no version 3.8.1. I guess you mean 3.81. They are mostly backward-compatible but there are incompatible changes over time (3.81 was released in 2006). The differences are usually easy to deal with and often the older syntax was not intended to be valid but wasn't checked properly. Without seeing the lines before the ifeq that's about all I can say. See git.savannah.gnu.org/cgit/make.git/tree/NEWS for info on changes to each version of make. - MadScientist

3 Answers

16
votes

Make is very touchy about spaces and tabs, it treats indented lines as commands, so you need to remove them. E.g. it should be:

ifneq ($(prebuilt_module_is_a_library),)
ifneq ($(LOCAL_IS_HOST_MODULE),)
$(transform-host-ranlib-copy-hack)
else
$(transform-ranlib-copy-hack)
endif
endif
4
votes

I got the same error message because of tabs after line continuation:

SOURCES := a.cpp \
b.cpp \<tab><tab>
c.cpp \
d.cpp
3
votes

I build AOSP 2.3.1 on Ubuntu 16, then got the same error as you have. Then I changed the make version from v4.1 to v3.81, notice that v3.82 also is the wrong version. Finally I build AOSP successfully!