em70
em70

Reputation: 6081

AutoMake conditional compilation issue

I am trying to do this in automake

platform=$(uname)
ifeq ($(platform), Darwin)
    stmt = ...
else
    stmt1 = ...
endif

But I get

error: else without if

error: endif without if

What am I doing wrong?

Upvotes: 2

Views: 2416

Answers (1)

ptomato
ptomato

Reputation: 57920

  • Remove the indentation so that all the statements start in column 1.
  • With Automake conditionals, you first have to define a conditional variable in your configure script, like this:

    AM_CONDITIONAL([DARWIN], [test $(uname) -eq "Darwin"])
    

    then in the Automake file, do this:

    if DARWIN
    stmt = ...
    else
    stmt1 = ...
    endif
    

Alternatively, just write the if statement in bash script as the body of a rule in your Automake file.

Upvotes: 5

Related Questions