Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile: problem getting ifstatement to work =(

Tags:

c++

makefile

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

The echo's aren't printing, and the BOOST_PATH isn't changing, I don't think... So... I'm not sure what I'm doing wrong here... =\

like image 743
NullVoxPopuli Avatar asked Apr 07 '26 07:04

NullVoxPopuli


2 Answers

You can't put commands in a Makefile independent of targets. You need to introduce a target which displays the OS. Also, you're lacking '$()'. Use e.g.

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)
like image 71
Erik Avatar answered Apr 09 '26 19:04

Erik


You’re not defining the UNAME variable anywhere. You probably want something like this:

UNAME = $(shell uname)
like image 20
Konrad Rudolph Avatar answered Apr 09 '26 21:04

Konrad Rudolph