make:循环依赖下降 [英] make: Circular dependency dropped

查看:404
本文介绍了make:循环依赖下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很长时间关于stackoverflow和其他make手册,网站的信息,但是找不到make函数中的任何尾随空格或未使用.您能帮我解决此警告信息吗?

make: Circular main.asm.o <- main.asm dependency dropped.

Makefile:

AS:=yasm
CC:=gcc
OUTPUTDIR:=$(shell pwd)/bin
ASFLAGS:=-g dwarf2 -f elf64 -a x86
CFLAGS:=-g

SOURCES=$(wildcard *.asm)
OBJECTS=$(patsubst %.asm,%.o,$(SOURCES))

%.o: $(SOURCES)
    $(AS) $(ASFLAGS) -o $(OUTPUTDIR)/$(OBJECTS) $<

all: $(OBJECTS)
    $(CC) $(CFLAGS) -o httpd $(OUTPUTDIR)/$(OBJECTS)

clean:
    rm $(OUTPUTDIR)/*
    rm httpd

main.asm:

section .text
  global main
  extern exit

main:
  mov rdi, 1
    call exit   

谢谢:)

解决方案

您的错误是这一行:

%.o: $(SOURCES)

可能会扩展为类似的内容

%.o: main.asm foo.asm bar.asm

这意味着很像

main.asm.o: main.asm
foo.asm.o: foo.asm
bar.asm.o: bar.asm
    ....

那是大约",因为您在这里混淆了语法.

您正在将普通规则(target: source)与通配符规则(%.target: %.source)混淆.您可能想要的是

%.o: %.asm
    $(AS) $(ASFLAGS) -o $@ $<

教了如何结合使用.asm文件和

%.o: $(SOURCES)

来制作.o个文件

httpd: $(SOURCES:.asm=.o)
    $(CC) $(CFLAGS) -o httpd $*

告诉Make如何将各种.o文件组合到httpd可执行文件中. $(SOURCES:.asm=.o)变量引用扩展为作为依赖项的.o文件列表,并且Make现在知道如何从相应的.asm文件创建那些.o文件.

I've already searched a long time on stackoverflow and other make manuals, websites but cannot find any trailing whitespace or miss usage in make functions. Can you help me solve this warning message ?

make: Circular main.asm.o <- main.asm dependency dropped.

Makefile:

AS:=yasm
CC:=gcc
OUTPUTDIR:=$(shell pwd)/bin
ASFLAGS:=-g dwarf2 -f elf64 -a x86
CFLAGS:=-g

SOURCES=$(wildcard *.asm)
OBJECTS=$(patsubst %.asm,%.o,$(SOURCES))

%.o: $(SOURCES)
    $(AS) $(ASFLAGS) -o $(OUTPUTDIR)/$(OBJECTS) $<

all: $(OBJECTS)
    $(CC) $(CFLAGS) -o httpd $(OUTPUTDIR)/$(OBJECTS)

clean:
    rm $(OUTPUTDIR)/*
    rm httpd

main.asm:

section .text
  global main
  extern exit

main:
  mov rdi, 1
    call exit   

thanks you :)

解决方案

Your error is this line:

%.o: $(SOURCES)

which presumably expands to something like

%.o: main.asm foo.asm bar.asm

What that means is something very approximately like

main.asm.o: main.asm
foo.asm.o: foo.asm
bar.asm.o: bar.asm
    ....

That's 'approximately' because you're mixing up the syntax here.

You're confusing an ordinary rule (target: source) with a wildcard rule (%.target: %.source). What you probably want is

%.o: %.asm
    $(AS) $(ASFLAGS) -o $@ $<

which teaches Make how to make .o files from .asm files, combined with

httpd: $(SOURCES:.asm=.o)
    $(CC) $(CFLAGS) -o httpd $*

which tells Make how to combine the various .o files into the httpd executable. The $(SOURCES:.asm=.o) variable reference expands to a list of .o files as dependencies, and Make now knows how to create those .o files from the corresponding .asm files.

这篇关于make:循环依赖下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆