Mikko-Pentti Einari Eronen Mikko-Pentti Einari Eronen - 3 months ago 25
C++ Question

Makefile Os detection and ifeq not getting triggered

I'm struggling to get my ifeq condition to be triggered.
I know my makefile probably is looking silly on all parts anyway, but that is why I am here, to ask.

My Makefile condition is as follows:

COMPILER = g++

TARGET_WIN32 = engine.exe
SOURCES_WIN32 = main.cpp os_win32.cpp
FLAGS_WIN32 = -mwindows

TARGET_LINUX = engine
SOURCES_LINUX = main.cpp os_linux.cpp
FLAGS_LINUX = -lX11

ifeq ( $(OS), Windows_NT)
TARGET = $(TARGET_WIN32)
SOURCES = $(SOURCES_WIN32)
FLAGS = $(FLAGS_WIN32)
else
TARGET = $(TARGET_LINUX)
SOURCES = $(SOURCES_LINUX)
FLAGS = $(FLAGS_LINUX)
endif

all:
@echo $(OS)

$(COMPILER) -o $(TARGET) $(SOURCES) $(FLAGS)

Answer

Make is very sensitive for spaces :-)

Your line:

ifeq ( $(OS), Windows_NT)

must be:

ifeq ($(OS),Windows_NT)