MAC_BOOST_PATH = -L/opt/local/lib
LINUX_BOOST_PATH = -L/usr/lib/
DEFAULT_PATH = -L/usr/local/lib
BOOST_PATH = $(DEFAULT_PATH)
ifeq ($(UNAME), Darwin)
BOOST_PATH = MAC_BOOST_PATH
@echo Compiling for Mac OS X
@echo
endif
ifeq ($(UNAME), Linux)
BOOST_PATH = LINUX_BOOST_PATH
@echo Compiling for Linux
@echo
endif
回声没有打印,BOOST_PATH 没有改变,我不认为......所以......我不确定我在这里做错了什么......=\
最佳答案
您不能将命令放在独立于目标的 Makefile 中。您需要引入一个显示操作系统的目标。另外,您缺少“$()”。使用例如
UNAME=$(shell uname)
MAC_BOOST_PATH = -L/opt/local/lib
LINUX_BOOST_PATH = -L/usr/lib/
DEFAULT_PATH = -L/usr/local/lib
BOOST_PATH = $(DEFAULT_PATH)
ifeq ($(UNAME),Darwin)
BOOST_PATH=$(MAC_BOOST_PATH)
endif
ifeq ($(UNAME),Linux)
BOOST_PATH=$(LINUX_BOOST_PATH)
endif
all: showos
showos:
@echo compiling for $(UNAME)
关于c++ - Makefile:使 if 语句起作用的问题 =(,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5821188/