Ich habe diese C-Datei:Warum funktioniert dieses Makefile nicht?
// test.c
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
Und dieses Makefile
OBJS=$(patsubst %.c,%.o,$(wildcard *.c))
EXEC=hello.exe
all: $(EXEC)
$(EXEC): $(OBJS)
.PHONY: all
Wenn ich make
tun es nicht mein Ziel schaffen hello.exe
warum?
$ make
cc -c -o hello.o hello.c
Es ist entweder nicht mit hello.exe
arbeiten:
$ make hello.exe
make: Nothing to be done for 'hello.exe'.
Und hello.exe
existiert nicht:
$ ls hello.exe
ls: cannot access 'hello.exe': No such file or directory
Ich benutze diese Version von GNU
Make$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
Copyright (C) 1988-2016 Free Software Foundation, Inc.
BEARBEITEN
Es funktioniert tatsächlich, wenn ich meine ausführbare Datei die gleiche von irgendwelchen meiner Dateien nenne. So funktioniert es mit:
EXEC=hello
See:
$ make
cc -c -o hello.o hello.c
cc hello.o -o hello
Das sagte ich verstehe nicht, warum es nur so funktioniert.