7

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?

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
Hesam Qodsi
  • 1,569
  • 3
  • 25
  • 38

2 Answers2

8

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.

James Kanze
  • 150,581
  • 18
  • 184
  • 329
  • According to http://mingw.org/wiki/FAQ mingw32-make is "lacking in some functionality" compared to normal make. – Tormod Volden Jul 16 '13 at 19:19
  • 2
    @TormodVolden Interesting. I don't know what functionality they are talking about; I tend to use mingw32-make even under CygWin. It's faster, and at least in the past, has been more up to date. There are differences: mingw32-make respects the `$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.) – James Kanze Jul 17 '13 at 08:09
  • 1
    @TormodVolden On rereading the page you site, I understand it to be saying that the program named `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.) – James Kanze Jul 17 '13 at 08:15
  • 1
    There are also other important differences. `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`. – alecov Mar 15 '16 at 12:24
  • `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. – not2qubit Dec 14 '18 at 08:38
  • `mingw32-make` is still shipped with MinGW32-w64. While CMake is complaining about `sh` in `$PATH` when trying to generate MinGW Makefiles, I never had problems creating Unix Makefiles after renaming/copying `mingw32-make.exe` to `make.exe`. – WolleTD Jan 02 '19 at 10:37
  • Oh, I just found the build configuration for mingw32-make. There are exactly two patches applied to upstream-make that seem to not drastically change any behaviour: https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-make – WolleTD Jan 02 '19 at 11:03
1

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.

nirvana-msu
  • 3,877
  • 2
  • 19
  • 28