Not sure if anyone else has gotten this to work, but I'm having no end of trouble even with the following simple line in my Makefile running mingw32-make
:
mklink Mk Makefile
The following created the link, but mingw32-make
puked and threw error 255 thereafter:
$(shell cmd /c 'mklink Mk Makefile')
Nothing else is problematic, and I have a relatively complex makefile. Only mklink
is doing this. (Apparently msys has it's own problems with ln
so going down that path appears pointless.)
The following works for me, (on Win7 Home Premium, in VirtualBox), provided I invoke it in a shell running with administrator privilege:
$ cat makefile.tst
all:
cmd /c "mklink mk makefile.tst"
@echo "Success!"
$ make -f makefile.tst
cmd /c "mklink mk makefile.tst"
symbolic link created for mk <<===>> makefile.tst
Success!
$ rm mk
$ mingw32-make -f makefile.tst
cmd /c "mklink mk makefile.tst"
symbolic link created for mk <<===>> makefile.tst
Success!
My shell, in this case is MSYS sh.exe
, invoked via msys.bat
from cmd.exe
with UAC escalation to administrator privilege. This is so that I can show that the mklink
command works both in MSYS' own make.exe
, and in mingw32-make.exe
; (of course, the mingw32-make.exe
example also works directly from the elevated cmd.exe
shell itself).
I suspect that attempting to use mklink
directly within the makefile, without the cmd /c
preamble, may not work because mklink
is a cmd.exe
built-in, which GNU make may not know to run this way ... it reports a CreateProcess
failure, because the specified file cannot be found, when I try it.
Your use of make's $(shell ...)
construct would not work, because that causes make to invoke the command in the wrong phase of operation ... when parsing the makefile itself, and constructing its dependency graph, rather than as a command to run when the containing rule is invoked, where it will now attempt to execute the output from the $(shell ...)
command as a command in its own right; this is clearly not what you want!