Nmake adds to variables

  • Utility: NMake
  • Platform: Windows 7

I have the following makefile

FILE = $(shell) *.c FILE += $(shell) *.cpp exec: @echo $(FILE) 

This works great with make. This causes the following error with nmake

 makefile(2) : fatal error U1036: syntax error : too many names to left of '=' Stop. 

What could be the reason?

No line

 FILE += $(shell) *.cpp 

nmake works great.

+6
source share
2 answers

The syntax += is a GNU Make extension that was first introduced in Sun make in the late 80s. It is not part of the syntax of the POSIX make standard or the original AT & T make .

If you use extensions, you end up when switching to a system that does not support them. You either have to redo things (hard) or stick to the original system.


One way to modify the file to work with nmake is probably:

 FILE1 = $(shell) *.c FILE2 = $(shell) *.cpp FILE = $(FILE1) $(FILE2) exec: @echo $(FILE) 

Or, given that the shell macro is not defined, even:

 FILE1 = *.c FILE2 = *.cpp FILE = $(FILE1) $(FILE2) exec: @echo $(FILE) 
+5
source

Instead

 FILE = $(shell) *.c FILE += $(shell) *.cpp 

you should use

 FILE = $(shell) *.c FILE = $(shell) *.cpp $(FILE) 

The expansion strategy is different from nmake and make. nmake expands everything before starting to evaluate rules, and make does it only at times when it is necessary, and since this gives problems, it has two extension options, as described on the information pages.

I personally like nmake better. And by the way, use "jom" instead of "nmake".

+2
source

Source: https://habr.com/ru/post/911547/


All Articles