Makefile 为什么';这个文件不行吗?

Makefile 为什么';这个文件不行吗?,makefile,gnu-make,Makefile,Gnu Make,我有一个C文件: // test.c #include <stdio.h> int main() { printf("Hello World!\n"); return 0; } 当我做make时,它不会创建我的目标hello.exe为什么 $ make cc -c -o hello.o hello.c 它既不能与hello.exe一起工作,也不能与一起工作: $ make hello.exe make: Nothing to be done for 'he

我有一个C文件:

// test.c
#include <stdio.h>

int main()
{
    printf("Hello World!\n");
    return 0;
}
当我做
make
时,它不会创建我的目标
hello.exe
为什么

$ make
cc    -c -o hello.o hello.c
它既不能与
hello.exe一起工作,也不能与
一起工作:

$ make hello.exe
make: Nothing to be done for 'hello.exe'.
而且
hello.exe
不存在:

$ ls hello.exe
ls: cannot access 'hello.exe': No such file or directory
我使用这个版本的GNU Make

$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
Copyright (C) 1988-2016 Free Software Foundation, Inc.
编辑

当我将我的可执行文件命名为与我的任何文件相同的名称时,它实际上起作用。因此,它适用于:

EXEC=hello 
见:


也就是说,我不明白为什么它只能这样工作。

带有
hello.exe
的版本不起作用,因为
make
没有隐式规则告诉它如何将一堆
*.o
转换为一个
*.exe

但它确实有隐式规则(至少是POSIX指定的规则)将
hello.c
转换为
hello.o
并链接到
hello


记住,Unix不是DOS。当您在Unix上时,请忘记
.exe

带有
hello.exe
的版本不起作用,因为
make
没有隐式规则告诉它如何将一堆
*.o
转换为单个
*.exe

但它确实有隐式规则(至少是POSIX指定的规则)将
hello.c
转换为
hello.o
并链接到
hello

记住,Unix不是DOS。在Unix上时,请忘记
.exe

EXEC=hello 
$ make
cc    -c -o hello.o hello.c
cc   hello.o   -o hello