linux - Makefile:make 期间出错

标签 linux makefile

我有以下两个 makefile:

Makefile1:

SUBDIRS = src
SDIRS=src
TOP?=.. 
RECURSIVE_MAKE= [ -n "$(SDIRS)" ] && for i in $(SDIRS) ; do \
            (cd $$i && echo "making $$target in $(DIR)/$$i..." && \
            $(MAKE) -e TOP=$(TOP)/.. $$target INCLUDES='$(INCLUDES)') || exit 1; \
        done;

subdirs:
    @target=all; $(RECURSIVE_MAKE)

all: subdirs

include $(BUILD_TOP)/build_control/symstream/subdirs.mk

Makefile2(子目录.mk):

#   This is a stand-alone file to distribute targets to
#   sub-directories. Include this file alone.  

#  Make bug: It loses track of if/endif over a $(eval) call.
ifndef __subdirs_include
__subdirs_include = yes

#   This only works for the standard targets defined in $(TARGETS)
#   in utils.mk. However this list can be extended with +=.

install:: install-hdrs 

include $(BUILD_TOP)/build_control/symstream/utils.mk
include $(BUILD_TOP)/build_control/symstream/platform.mk

#  This creates a recursion rule for each pair of target and subdirectory.
#  The target for doing T in directory D is named T+D. 
#  If there is a "$(D_needs) = subdirs" then the subdirs become prerequisites
#  of D.
define __target_subdir
.PHONY:: $(1)+$(2)
$(1)+$(2) :: $(3); +$(MAKE) -C $(2) $(1)
endef

$(foreach t,$(TARGETS),\
    $(foreach d,$(strip $(SUBDIRS) $(SUBDIRS_y)),\
    $(eval $(call __target_subdir,$(t),$(d),$(patsubst %,$(t)+%,$($(d)_needs))))))

$(foreach t,$(TARGETS),\
    $(foreach d,$(strip $(SUBDIRS) $(SUBDIRS_y)),$(eval $(t)::$(t)+$(d))))


endif # __subdirs_include

执行 Makefile1 时出现以下错误:

subdirs.mk:30: *** target file `all' has both : and :: entries.  Stop.

有人可以帮忙解决这个问题吗?

最佳答案

您应该发布 subdirs.mk 来确定,但似乎您有普通和双列 目标全部的规则。

来自GNU make manual :

When a target appears in multiple rules, all the rules must be the same type: all ordinary, or all double-colon.

关于linux - Makefile:make 期间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17312725/

相关文章:

c - mov后正确读取gdb值

c - 你好,关于《APUE》中10.11的信号源

c++ - MakeFile 只编译一个文件

c++ - grpc编译错误protobuf 3.2.0(文件是用旧版本的protoc生成的)Ubuntu 16.04

php - mv 命令不能从 bash 脚本 php 工作

linux - zsh 参数扩展语法 : combining default value and conversion to upper case

c++ - 生成文件 : Header in different Directory - Error

c++ - 使用 Automake 进行单元测试

python - 无论我将MPI Parallel设置为false还是true,我都继续收到MPI错误

linux - 在 bash 中用 ' ' 替换 '\'