NMake returns an error when using $ (shell)

I am new to nmake and I need to change the construction of the script. I want to execute a command and commit the result to a variable, which will then be used throughout the script. However, when I try to use the shell command, I get the following error message:

makefile(4) : fatal error U1000: syntax error : ')' missing in macro invocation
Stop.

I put together one line of script to test the shell command.

Makefile:

CMDRESULT = $(shell hostname)

all:
    echo $(CMDRESULT)

The nmake version is used here:

>nmake /?

Microsoft (R) Program Maintenance Utility Version 11.00.60610.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Does nmake support shell command? Is there another option in nmake to execute a command and capture the result?

+4
source share
3 answers

nmake, , . . nmake:

!IF [hostname>hostname.tmp] == 0
H_NAME = \
!INCLUDE hostname.tmp
!IF [del hostname.tmp] == 0
!ENDIF
!ENDIF

[for execution] return code . . " , nmake", .

+3

. Microsoft NMAKE (, shell). $ Nmake.

Shell . gnu.

Nmake (shell) , , , . .

:

!IF [..dos command..] != 0 
   command
!ENDIF

:

all: 
   if comparison command

DOS/Windows .

Update:

, , :

, ; , !

, , Makefile . , Makefile Makefile ( , ).

!IFNDEF MAKE
MAKE=NMAKE
!ENDIF
!IFNDEF SHELLVALUE
!   IF [echo off && FOR /F "usebackq" %i IN (`hostname`) DO  SET SHELLVALUE=%i && $(MAKE)  /$(MAKEFLAGS) /nologo /f $(MAKEDIR)\Makefile && exit /b  ] == 0
!     MESSAGE Make completed
!   ELSE
!     ERROR Error in nmake
!   ENDIF
!ELSE
# $(SHELLVALUE) now contains the string returned from the command USERNAME
!MESSAGE Shellvalue is $(SHELLVALUE)
#      Put the parts of the makefile that depend on SHELLVALUE here
!ENDIF
#
# To be a valid makefile it must have some rules to perform
all:
     @echo;$(SHELLVALUE)

, , , , , hostname.

+1

(, , ) make, $(MAKEFLAGS). , make - "nmake clean" , "nmake", (, "" ).

0

All Articles