Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two string variables in Makefile

Tags:

makefile

I have the following code:

LOCAL_VERSION := $(shell some_binary -v | head -n 1)
REMOTE_VERSION := $(shell curl -s https://example.com/key)

all:
    ifeq($(REMOTE_VERSION), $(LOCAL_VERSION))
        @echo yes
    endfi

But I am getting this:

user:tmp user$ make
ifeq(v0.11.1, v0.11.1)
/bin/sh: -c: line 0: syntax error near unexpected token `v0.11.1,'
/bin/sh: -c: line 0: `ifeq(v0.11.1, v0.11.1)'
make: *** [all] Error

I am on Mac OSX, but it's using GNU Make anyway.

like image 518
CppLearner Avatar asked Mar 13 '19 03:03

CppLearner


1 Answers

ifeq should not be indented, e.g.

LOCAL_VERSION := $(shell some_binary -v | head -n 1)
REMOTE_VERSION := $(shell curl -s https://example.com/key)

all:
ifeq ($(REMOTE_VERSION), $(LOCAL_VERSION))
    @echo yes
else
    @echo NO
endif
like image 56
Alex Cohn Avatar answered Oct 20 '22 02:10

Alex Cohn