I'm a C++ programmer and have experience with GCC on Linux. I want to develop an application in Windows , so i need a full guide to mingw make files, variables and mingw32-make. Is there anybody who can introduce a resource for this?
2 Answers
mingw32-make is just a pre-built version of GNU make, so http://www.gnu.org/software/make/manual/ should have all of the information you need.
7 Comments
$SHELL environment variable, which Unix make doesn't, and of course, if you use $(shell ...), it will depend on the shell you invoke and the tools you have installed. (But if the shell is bash, and you have CygWin installed and in your path, it works pretty much like Unix.)make in the MinGW distribution is lacking some functionality, not the program named mingw32-make. (But maybe it's the opposite---the page isn't too clear, and I can't find any other documentation about this on the site.)mingw32-make is really a different version of make loosely patched to support Win32-style paths, and will not work properly if used in connection with any Unix-style shell -- in fact, problems will occur if it finds sh in PATH. In general, you cannot use the same makefiles written for make with mingw32-make.minggw32-make seem to have been removed and it's use have likely been deprecated from any recent mingw packages, at least on Cygwin. I haven't seen this for years, unless I have missed something.The main difference I came across is that mingw32-make will use windows PATH. So if you try to run it from git bash it won't behave quite like you expect it to (namely, it will invoke bat scripts when you don't expect it to, and shims also don't quite work).
Setting SHELL := /bin/bash or anything similar won't have any effect (which you can debug by running make -d), but you can still make it use bash instead of sh by setting SHELL := bash.exe. That's doesn't solve the windows PATH problem though.
What I did notice however is that if I additionally set .SHELLFLAGS := -euo pipefail -c then it suddenly behaves properly in git bash, as if it starts using Unix-like paths (would be great if someone could confirm / explain why exactly).
So I ended up with the following in my Makefile:
ifeq ($(OS),Windows_NT) SHELL := bash.exe else SHELL := /usr/bin/env bash endif .SHELLFLAGS := -eo pipefail -c With that setup it appears to behave normally in git bash, just like on Linux.