Je possède ce fichier C:Pourquoi ce fichier Makefile ne fonctionne-t-il pas?
// test.c
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
Et ce Makefile
OBJS=$(patsubst %.c,%.o,$(wildcard *.c))
EXEC=hello.exe
all: $(EXEC)
$(EXEC): $(OBJS)
.PHONY: all
Quand je fais make
il ne crée pas mon objectif hello.exe
pourquoi?
$ make
cc -c -o hello.o hello.c
Il n'a pas non plus travailler avec hello.exe
:
$ make hello.exe
make: Nothing to be done for 'hello.exe'.
Et hello.exe
n'existe pas:
$ ls hello.exe
ls: cannot access 'hello.exe': No such file or directory
J'utilise cette version de GNU Make
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
Copyright (C) 1988-2016 Free Software Foundation, Inc.
EDIT
Cela fonctionne réellement quand je nomme mon exécutable le même de n'importe lequel de mes fichiers. Il fonctionne avec:
EXEC=hello
Voir:
$ make
cc -c -o hello.o hello.c
cc hello.o -o hello
Cela dit, je ne comprends pas pourquoi il ne fonctionne que de cette façon.