1

I've been given a makefile for ubuntu, and I'm trying to use it with nmake on Windows 10.

nmake doesn't seem to recognize the filter-out keyword such as in the following line:

OBJS_TEST = $(filter-out $(EXE_OBJ), $(OBJS))

Does nmake have a keyword with the same functionality?

For completeness, the lines from the beginning of the file before the above line (and a few lines below) are as follows:

EXE = main
TEST = test
OBJS_DIR = .objs

###############################################
### THE LINE IN QUESTION IS BELOW #############
OBJS_TEST = $(filter-out $(EXE_OBJ), $(OBJS))
###############################################

CPP_TEST = $(wildcard tests/*.cpp)

# CPP_TEST += uiuc/catch/catchmain.cpp
# The above line doesn't work with the "+=" extension in nmake; replace with below.
CPP_TEST = $(CPP_TEST) $(wildcard tests/*.cpp)

The error reported is:

fatal error U1001: syntax error : illegal character '-' in macro
butterflyknife
  • 1,438
  • 8
  • 17

1 Answers1

1

As far as I'm aware there is no equivalent to filter-out in nmake. Also, nmake does not support the wildcard function so you'll have to deal with that. And, I'm suspicious that your replacement for += won't work; in most versions of POSIX make FOO = $(FOO) is illegal as it gives an infinite loop of variable lookup. Maybe nmake works differently, though.

nmake is SO different from POSIX make and GNU make that you will either have to rewrite the makefile from scratch, or else just go get a version of GNU make for Windows (or build it yourself). GNU make is quite portable and runs well on Windows. That would be a LOT less work.

MadScientist
  • 92,819
  • 9
  • 109
  • 136
  • wow, OK that's pretty emphatic. Thanks for saving me hours of time! ... I'm a bit puzzled about nmake now, though. I assumed it was for compatibility to POSIX and gnu make, but now it seems like a Microsoft-specific thing, and why would they bother with creating nmake when they already had vcxproj and sln files? (No need to answer, just thinking aloud). – butterflyknife Jun 30 '20 at 08:27
  • 1
    I'm one of the last people who should be commenting on Windows tools, but nmake long predates visual studio, and its proj and sln files. – MadScientist Jun 30 '20 at 12:34