The only standard for makefiles is Posix (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html). This is not followed by Visual Studios, and the MinGW make is actually GNU make, which has an option to be Posix compatible, but has a very large number of extensions. (I'm not sure about Eclipse and CodeBlocks, but they probably use GNU make as well.)
The makefile you use is largely independent of the compiler. The Posix standard make is a minimum make; I would recommend using GNU make everywhere, mainly because it is portable, and it is the most powerful in terms of features. On the other hand, it's not easy to learn (and none of the makes I know are particularly readable). Still, I've used the same GNU makefiles under Solaris (with Sun CC and g++), Linux (with g++) and Windows (with MSVC and g++).
With regards to running C++ from the makefile, I also do this all the time, as well as running Python and shell scripts. There are two ways to do this:
- You want to integrate the output of your C++ into the makefile itself, GNU make is really your only solution (I think), using `$(shell ... )` (Where I worked until recently, the "reference" was the VS project files; we used `$(shell ...)` to invoke a Python script which parsed the project files to generate the list of target files and dependencies in the makefile.)
- If you want to invoke a C++ program to generate sources for
later compilation, you can create dependencies for the source
file:
machineGenerated.cpp : somethingElse myPreProcessor myPreProcessor somethingElse > machineGenerated.cpp
You can also have rules to build `myPreProcessor` in the makefile.
One thing I've found useful when supporting multiple platforms:
dependsPath := $(strip $(arch))-$(strip $(syst))-$(strip $(comp))
configPath := conf/$(dependsPath)
include $(makefilesDir)/$(configPath)/system.mk
Normally, I'll set shell variables for my default arch, syst and
comp (compiler), but I can override them on the command line,
and so compile with both g++ and VC++ on the same machine (or
i686
and x86-64
).