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)

Upvotes: 1

Views: 83

Answers (1)

Klaus
Klaus

Reputation: 25613

Make is very sensitive for spaces :-)

Your line:

ifeq ( $(OS), Windows_NT)

must be:

ifeq ($(OS),Windows_NT)

Upvotes: 2

Related Questions