使用 make 构建时,ASM 文件的“循环依赖性下降”

'Circular dependency dropped` with ASM files when building with make

问题是当我构建我的项目时,make 给出了关于 ASM 文件的循环依赖性的恼人消息。奇怪的是,对于以完全相同的方式编译的 C 文件,不会显示该消息。这是生成文件:

# VV4OS Makefile. Here are the main targets:
# I.   all (can be called without specifying the target) - builds everything
# II.  install - copies the kernel to a disk image.
# III. clean - removes the files that are created by this build system
# and thus can be recovered.
# You can set up the build system by changing the build constants.

# Here come build constants.
# If you can't build VV4OS consider changing them.

# Used tools.

MAKE=make

MOUNT=mount
UMOUNT=umount

SUDO=sudo

# I don't know if there are systems where RM, CP or MKDIR command isn't standard.
# I've added them just in case.

RM=rm
RMFLAGS=-f

CP=cp
CPFLAGS=

MKDIR=mkdir
MKDIRFLAGS=-p

# Compilers (and the linker) and their flags.

ASM=nasm
ASMFLAGS=-felf32

CC=/home/alexander/opt/cross/bin/i686-elf-gcc
CFLAGS=-Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude

LINKER=/home/alexander/opt/cross/bin/i686-elf-gcc
LFLAGS=-ffreestanding -nostdlib -lgcc -T linker.ld

# Files.

SOURCES=$(wildcard *.c) $(wildcard */*.c) $(wildcard */*/*.c) \
    $(wildcard *.asm) $(wildcard */*.asm) $(wildcard */*/*.asm)

OBJECTS=$(SOURCES:=.o)

KERNEL=kernel.elf

DISK_IMG=disk.img
IMG_OFFSET=1048576 # Where the partition starts in bytes (NOT in sectors)
IMG_MNTDIR=/mnt/

# Destination paths.

KERNEL_DEST_PATH=/sys/vv4os/
KERNEL_DEST_NAME=kernel.elf

# These targets are executed whenever they called even if there are ready files with their names.

.PHONY: all install clean

# Here comes the build system code.
# Do not modify it unless your IQ level is higher than 110.

# Build everything (currently only the kernel).
# You can simply call make if you want to do it.

all:
    $(MAKE) $(KERNEL)

# Installs the kernel to a disk image.

install: $(KERNEL) $(DISK_IMG)
    $(MOUNT) -o loop,offset=$(IMG_OFFSET) $(DISK_IMG) $(IMG_MNTDIR)
    $(MKDIR) $(MKDIRFLAGS) $(IMG_MNTDIR)/$(KERNEL_DEST_PATH)
    $(CP) $(KERNEL) $(IMG_MNTDIR)/$(KERNEL_DEST_PATH)/$(KERNEL_DEST_NAME)
    $(UMOUNT) $(IMG_MNTDIR)

# Only builds the kernel.

$(KERNEL): $(OBJECTS)
    $(LINKER) $(LFLAGS) -o $@ $^

# Assemblies assembly files with assembler.

%.asm.o: %.asm
    $(ASM) $(ASMFLAGS) $< -o $@

# Compiles C files with compiler.

%.c.o: %.c
    $(CC) $(CFLAGS) $< -o $@

# Removes all the files that are created by make (and thus can be recovered).

clean:
    $(RM) $(RMFLAGS) $(OBJECTS) $(KERNEL)

这是构建日志:

$ make
make kernel.elf
make[1]: Entering directory '/home/alexander/Documents/vv4os'
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude io/term.c -o io/term.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude io/keyboard.c -o io/keyboard.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude hdd/hdd.c -o hdd/hdd.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude hdd/mbr.c -o hdd/mbr.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude libc/stdlib.c -o libc/stdlib.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude libc/string.c -o libc/string.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude libc/stdio.c -o libc/stdio.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude isr/isr.c -o isr/isr.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude isr/descriptor_tables.c -o isr/descriptor_tables.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude isr/timer.c -o isr/timer.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude general/system.c -o general/system.c.o
/home/alexander/opt/cross/bin/i686-elf-gcc -Wall -Wextra -Werror -ffreestanding -std=c11 -c -Iinclude general/kernel.c -o general/kernel.c.o
make[1]: Circular boot/boot.asm <- boot/boot.asm.o dependency dropped.
nasm -felf32 boot/boot.asm -o boot/boot.asm.o
make[1]: Circular isr/interrupts.asm <- isr/interrupts.asm.o dependency dropped.
nasm -felf32 isr/interrupts.asm -o isr/interrupts.asm.o
/home/alexander/opt/cross/bin/i686-elf-gcc -ffreestanding -nostdlib -lgcc -T linker.ld -o kernel.elf io/term.c.o io/keyboard.c.o hdd/hdd.c.o hdd/mbr.c.o libc/stdlib.c.o libc/string.c.o libc/stdio.c.o isr/isr.c.o isr/descriptor_tables.c.o isr/timer.c.o general/system.c.o general/kernel.c.o boot/boot.asm.o isr/interrupts.asm.o
make[1]: Leaving directory '/home/alexander/Documents/vv4os'

可能是什么问题?

更新:
当目标像

时,它总是给出这样的消息
file.asm.o: file.asm
    nasm file.asm -o file.asm.o

在 file.asm 是任何汇编文件的地方执行(它适用于空文件)。

问题是您的 .asm 文件与内置的 %: %.o 规则匹配。此规则允许您键入 make foo 以从 foo.o 创建名为 foo 的可执行文件,类似于您可以使用相同命令从名为 foo.c 的文件构建可执行文件的方式。为了防止它匹配此规则,您需要创建一个匹配 .asm 个文件的隐式规则:

%.asm:

你的 .c 文件不需要这个,因为已经有一个内置的 %.c: 规则。