Search code examples
nmake

How can I convert a list of space separated files to comma separated files, in nmake?


Let's say I have a makefile (using nmake) with a SOURCES macro like this:

SOURCES = C:\folder\file1.cpp C:\folder\file2.cpp C:\folder\file3.cpp

I have a tool that needs to input these files as items in a comma separated list, like this:

C:\folder\file1.cpp,C:\folder\file2.cpp,C:\folder\file3.cpp

Is there a way, in nmake, to convert SOURCES into a comma separated list?

Edit:

Will this work (note the space after the colon)?

COMMALIST=$(SOURCES: =,) 

Solution

  • Turns out my suggested approach can work. The sole caveat is that you need careful spacing for the inputs. For instance, using the question's SOURCES example, COMMALIST would be:

    ,C:\folder\file1.cpp,C:\folder\file2.cpp,C:\folder\file3.cpp
    

    By removing the leading space, I get the output I desire.