Hi, In the example hello world Makefile, this line in shown for the extension of the executable "EXE = .exe" It is in fact not actually necessary to do this on Windows, the .exe extension is added automatically This reduces complexity in the Makefile at absolutely no cost. I don't know of any other operating systems that put extensions on executables, so I'm not really sure what its purpose is. It also makes the following reduntant: "This is very much a Windows-first style of Makefile, but still allows it to be comfortably used on other systems. On Linux this make invocation strips away the .exe extension:" "make EXE=" Perhaps this section of the article should be removed? I think it's not necessary or helpful. Best wishes, Peter D.
It's true that GCC automatically adds the extension. However, if the Makefile target lacks the extension then make always rebuilds the target unnecessarily, because the target and compiler output file name disagree. Furthermore, the "clean" target will not work correctly unless the file name arguments have the correct extension. I resolve both issues using "EXE" as a convention as described. On Windows I set it in my .profile so that all of my Makefiles automatically work by default regardless of where I'm building: https://github.com/skeeto/dotfiles/blob/62d3408100049ba6b48be790fb5976b0272c4eae/w64devkit.profile#L3 If not set, the Makefile will still mostly work thanks to GCC's behavior, even if less optimal, which acts as a kind of fallback.