0

Basically I have simple makefile in Windows. I've read this thread. They are saying if I have a file named for example clean in the same folder of makefile and I have a command for cleaning some files in makefile and its name is clean, then makefile will not run the command. It rather shows this message

'clean' is up-to-date

Now to cope with the problem, I should add .PHONY : clean, therefore, even if I do have another file in the same folder called clean, makefile will run the actual command. This is my understanding. Adding phony has absolutely no effect whatsoever. It prints out this message again.

'clean' is up-to-date

This is my makefile in Windows. Note: I use nmake

# Specify compiler 
CC = cl.exe

# Specify flags
# /Zi -- Enable debugging    
# /O2 -- 
CFLAGS = /EHsc /c /W1 /Zi /O2

# Specify linker
LINK = link.exe

.PHONY : all
all : app

# Link the object files into a binary
app : main.o
    $(LINK) /OUT:app.exe main.o 

# Compile the source files into object files 
main.o : main.cpp
    $(CC) $(CFLAGS) main.cpp /Fomain.o 

# Clean target
.PHONY : clean
clean:
    del *.o *.exe *.pdb

main.cpp

#include <iostream>

int main()
{
    std::cout << "Hello World!" << std::endl;
    return 0;
}

Files in the same folder.

enter image description here

Community
  • 1
  • 1
CroCo
  • 5,531
  • 9
  • 56
  • 88

0 Answers0