4

Hi I am stuck in this problem for long time. I expect output "ok" for this makefile. But I get syntax error on calling make:

ifeq (0, 0)

/bin/sh: 1: Syntax error: word unexpected (expecting ")")

make: *** [default] Error 2

Code:

CHK = 0

default:
    ifeq ($(CHK), 0)
        echo "ok"
    else
        echo "not ok"
    endif
1
  • 1
    This is not make syntax but rather a non-portable gmake extension. Commented Feb 24, 2020 at 16:09

1 Answer 1

11

These are Makefile directives, not shell directives, so they shouldn’t be tab-prefixed:

CHK = 0

default:
ifeq ($(CHK), 0)
    echo "ok"
else
    echo "not ok"
endif

Otherwise Make passes them to the shell, rather than handling them itself.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.