首页 > 解决方案 > What is the nmake equivalent of filter-out?

问题描述

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

标签: makefilecmakegnu-makenmake

解决方案


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.


推荐阅读