In the makefile on Windows.
With the following make version:
PS C:\projects> make --version
GNU Make 4.1
Built for i686-w64-mingw32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
I have tried to set SHELL := pwsh / COMSPEC := pwsh and run command without explicit shell specifying:
# COMSPEC := pwsh -c
SHELL := pwsh -c
VAR=asdf/asdf
.PHONY: get_var
get_var:
@Write-Output $(VAR)
without success. I've got an error:
PS C:\projects\makefile_factory> make -f .\fi.makefile get_var
process_begin: CreateProcess(NULL, Write-Output asdf/asdf, ...) failed.
make (e=2): ═х єфрхЄё эрщЄш єърчрээ√щ Їрщы.
.\fi.makefile:10: recipe for target 'get_var' failed
make: *** [get_var] Error 2
If shell specified explicitly in the command, it works:
# COMSPEC := pwsh -c
# SHELL := pwsh -c
VAR=asdf/asdf
.PHONY: get_var
get_var:
@pwsh -c Write-Output $(VAR)
run:
PS C:\projects\makefile_factory> make -f .\fi.makefile get_var
asdf/asdf
Also, i've looked into make documentation:
However, on MS-DOS and MS-Windows the value of SHELL in the environment is used, since on those systems most users do not set this variable, and therefore it is most likely set specifically to be used by make. On MS-DOS, if the setting of SHELL is not suitable for make, you can set the variable MAKESHELL to the shell that make should use; if set it will be used as the shell instead of the value of SHELL.
So i tried to set environment variable SHELL/MAKESHELL with no result:
PS C:\projects\makefile_factory> $env:SHELL
C:\Program Files\PowerShell\7\pwsh.exe
PS C:\projects\makefile_factory> $env:MAKESHELL
C:\Program Files\PowerShell\7\pwsh.exe
PS C:\projects\makefile_factory> make -f .\fi.makefile get_var
Write-Output asdf/asdf
process_begin: CreateProcess(NULL, Write-Output asdf/asdf, ...) failed.
make (e=2): ═х єфрхЄё эрщЄш єърчрээ√щ Їрщы.
.\fi.makefile:9: recipe for target 'get_var' failed
make: *** [get_var] Error 2
So, isn't there a way to specify pwsh as a default shell?
SHELLvariable, not justpwsh, and adding the-coption to the.SHELLFLAGSvariable (note you need at least GNU make 3.82 for this). If that doesn't work I don't know...