mardi 29 octobre 2019

Basic if else statement in Makefile

I'm trying to execute a simple if else statement in a Makefile:

check:
  if [ -z "$(APP_NAME)" ]; then \
    echo "Empty" \
  else \
    echo "Not empty" \
  fi

When I execute make check I get the following error:

if [ -z "" ]; then
/bin/bash: -c: line 1: syntax error: unexpected end of file
make: *** [check] Error 2

Any idea what I'm doing wrong?

I know I can use the following, but I have a lot of logic after the echos so I need to spread it out across multiple lines:

check:
  [ -z "$(PATH)" ] && echo "Empty" || echo "Not empty"

Aucun commentaire:

Enregistrer un commentaire