psversion:
!IF [for /F %i in ('powershell $$psversiontable.psversion.major') do @set PSvr=%i]
!ENDIF
psversion:
! IF [powershell $$PSVersionTable.PSVersion.major] <= 2
! ERROR
! ENDIF
psversion:
psvr = [powershell $$PSVersionTable.PSVersion.major]
! IF $(psvr) <= 2
! ERROR
! ENDIF
IF $(psvr) <= 2
вам вообще недоступна, в принципе :)powershell -nologo -noprofile "exit $psversiontable.psversion.major"
@powershell -nologo -noprofile "exit $psversiontable.psversion.major"
@echo %ERRORLEVEL%
Another way to use exit codes is during preprocessing. You can run a command
or program and test its exit code using the !IF preprocessing directive. For more
information, see “Executing a Program in Preprocessing” on page 575.
chkpsver :
! IF [powershell -nologo -noprofile "exit $$psversiontable.psversion.major"] == 2
! ERROR Для работы требуется версия программы «PowerShell» версии 3.0 или выше
! ELSE
! MESSAGE ok
! ENDIF
Calling NMAKE Recursively
In a commands block, you can specify a call to NMAKE itself. Either invoke
the MAKE macro or specify NMAKE literally. The following NMAKE
information is available to the called NMAKE session during recursion:
� Environment-variable macros (see “Inherited Macros” on page 563). To
cause all macros to be inherited, specify the /V option.
� The MAKEFLAGS macro. If .IGNORE (or !CMDSWITCHES +I) is set,
MAKEFLAGS contains an I when it is passed to the recursive call.
Likewise, if .SILENT (or !CMDSWITCHES +S) is set, MAKEFLAGS
contains an S when passed to the call.
� Macros specified on the command line for the recursive call.
� All information in TOOLS.INI.
Inference rules defined in the makefile are not passed to the called NMAKE
session. Settings for .SUFFIXES and .PRECIOUS are also not inherited.
However, you can make .SUFFIXES, .PRECIOUS, and all inference rules
available to the recursive call either by specifying them in TOOLS.INI or by
placing them in a file that is specified in an !INCLUDE directive in the makefile
for each NMAKE session.