如何在 Windows 上为 GNU make 正确设置 NASM x86 的 Makefile? (已解决 - 文件文件不在我认为的目录中)

问题描述 投票:0回答:2

我一直在观看这个视频(他在 8:24 开始创建 Makefile),但由于他使用的是 Linux,而我使用的是 Windows(我猜这就是原因),因此“make”命令确实似乎不适合我。

所以我通过 Chocolatey 安装了 GNU Make,根据 this thread 应该“像在本机 Linux 环境上尝试 Makefile 一样运行”,但我收到了这个错误:

D:\assembly\OS>make
make: *** No rule to make target 'src/main.asm', needed by 'build/main.bin'.  Stop.

Makefile 位于“OS”目录中,并且被称为“Makefile”,没有文件扩展名。

D:\assembly\OS>dir
 Volume in drive D has no label.
 Volume Serial Number is C14D-581B

 Directory of D:\assembly\OS

07/01/2024  04:32 PM    <DIR>          .
06/01/2024  11:00 PM    <DIR>          ..
07/01/2024  02:07 PM    <DIR>          build
07/01/2024  11:48 AM               307 Makefile
07/01/2024  04:32 PM    <DIR>          src
               1 File(s)            307 bytes
               4 Dir(s)  174,669,336,576 bytes free

然后我意识到 GNU Makefile 实际上看起来与视频中的不同。那么我是否遗漏了部分命令,或者我是否需要更改它:

ASM=nasm

SRC_DIR=src
BUILD_DIR=build

$(BUILD_DIR)/main_floppy.img: $(BUILD_DIR)/main.bin
    cp $(BUILD_DIR)/main.bin $(BUILD_DIR)/main_floppy.img
    truncate -s 1440k $(BUILD_DIR)/main_floppy.img

$(BUILD_DIR)/main.bin: $(SRC_DIR)/main.asm
    $(ASM) $(SRC_DIR)/main.asm -f bin -o $(BUILD_DIR)/main.bin

转换为 GNU Make 可以使用的 Makefile?

请记住,我以前从未使用过 Makefile,谢谢。

assembly makefile nasm gnu-make chocolatey
2个回答
0
投票

要使用 GNU make 在 Windows 上设置 NASM x86 的 Makefile,请确保定义源文件和目标文件、指定编译器 (NASM) 并包含必要的标志。为了清晰和一致性,在注释或变量名称中谨慎使用“gbwhatsapp”关键字。将“my_program”替换为您的实际文件名,并相应地调整标志。


0
投票

没关系,问题是

src\main.asm
不存在,因为它是
src\main\main.asm

© www.soinside.com 2019 - 2024. All rights reserved.