Android makefile错误:配方在第一个目标

时间:2016-05-18 11:24:08

标签: android makefile

在构建期间,我收到此错误

  

Android.mk:145:***食谱在第一个目标之前开始。停止。

我的编译器应该是来自android工具链的gcc。

这是有趣的食谱

ifneq ($(MTK_TEE_SUPPORT),yes)
trustzone:
else
ifeq ($(MTK_IN_HOUSE_TEE_SUPPORT),yes)
# export for build.sh
#include $(MTK_PATH_CUSTOM)/trustzone/custom.mk
#export TEE_DRAM_SIZE:=$(MEMSIZE)
#export MTEE_CUSTOM_CFG_DIR:=$(MTK_PATH_CUSTOM)/trustzone
export HOST_OS
TRUST_TEE_IMAGES := $(OUT_DIR)/target/product/$(MTK_PROJECT_NAME)/trustzone/bin/tz.img
trustzone: 
else # for TRUSTONIC_TEE_SUPPORT
trustzone: mcDriverDaemon
endif
endif
ifeq ($(TRUSTZONE_PARTITION),yes)
  ifneq ($(wildcard $(TRUST_TEE_WD)/build.sh),)
    $(hide) echo $(SHOWTIME) $@ ing ...            //this is line 145
    $(hide) echo -e \\t\\t\\t\\b\\b\\b\\bLOG: $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log
    $(hide) rm -f $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log_err
    $(hide) $(SHELL) $(TZ_BUILD_SCRIPT) $(MTK_PROJECT_NAME) $(DEAL_STDOUT)
    $(hide) cp -f $(TRUST_TEE_IMAGES) $(LOG_DIR)/$(MTK_PROJECT_NAME)/
    $(hide) mkdir -p $(LOG_DIR)/$(MTK_PROJECT_NAME)/system/etc/
    $(hide) cp -f $(TRUST_TEE_IMAGES) $(LOG_DIR)/$(MTK_PROJECT_NAME)/system/etc/trustzone.bin
  else
    $(hide) echo Not find $(TRUST_TEE_WD)/build.sh, skip $@.
  endif
else
    $(hide) echo Not support $@.
endif

droidcore: trustzone

endif

2 个答案:

答案 0 :(得分:1)

我认为这是GNU make中的一个错误。由于ifeq / endif,它应该关闭该规则。对于这个具体的例子,你可以更简单地重写它:

PREREQ =

ifeq ($(MTK_TEE_SUPPORT),yes)
 ifeq ($(MTK_IN_HOUSE_TEE_SUPPORT),yes)
# export for build.sh
#include $(MTK_PATH_CUSTOM)/trustzone/custom.mk
#export TEE_DRAM_SIZE:=$(MEMSIZE)
#export MTEE_CUSTOM_CFG_DIR:=$(MTK_PATH_CUSTOM)/trustzone
export HOST_OS
TRUST_TEE_IMAGES := $(OUT_DIR)/target/product/$(MTK_PROJECT_NAME)/trustzone/bin/tz.img

 else # for TRUSTONIC_TEE_SUPPORT
PREREQ = mcDriverDaemon
 endif
endif
trustzone: $(PREREQ)
ifeq ($(TRUSTZONE_PARTITION),yes)
  ifneq ($(wildcard $(TRUST_TEE_WD)/build.sh),)
        $(hide) echo $(SHOWTIME) $@ ing ...            //this is line 145
        $(hide) echo -e \\t\\t\\t\\b\\b\\b\\bLOG: $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log
        $(hide) rm -f $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log $(LOG_DIR)$(MTK_PROJECT_NAME)_$@.log_err
        $(hide) $(SHELL) $(TZ_BUILD_SCRIPT) $(MTK_PROJECT_NAME) $(DEAL_STDOUT)
        $(hide) cp -f $(TRUST_TEE_IMAGES) $(LOG_DIR)/$(MTK_PROJECT_NAME)/
        $(hide) mkdir -p $(LOG_DIR)/$(MTK_PROJECT_NAME)/system/etc/
        $(hide) cp -f $(TRUST_TEE_IMAGES) $(LOG_DIR)/$(MTK_PROJECT_NAME)/system/etc/trustzone.bin
  else
        $(hide) echo Not find $(TRUST_TEE_WD)/build.sh, skip $@.
  endif
else
        $(hide) echo Not support $@.
endif

但请在Savannah bug追踪器中报告此错误:https://savannah.gnu.org/bugs/?func=additem&group=make

这是一个极小的重现案例:

ifneq ($(FOO),yes)
foobar:
else
BAR = bar
foobar:
endif
        @echo one

如果你跑:

$ make
Makefile:7: *** recipe commences before first target.  Stop.

$ make FOO=yes
one

显然else中的变量赋值在未采用else路径时会破坏。

答案 1 :(得分:0)

我发现问题是Gnu Make版本。在this official page 它清楚地表明Android构建系统参考make版本是3.81-3.82。我安装了其中一个以前的版本,现在makefile没有任何错误,不需要任何补丁。