dimanche 18 février 2018

If Else syntax Error in GNU Makefile

I am trying to get if else syntax working in Makefile

SHELL = /bin/bash
TYPE=src
RTL=src

program_%:
    ifeq ( $(TYPE),$(RTL) )   \
        echo "RTL"          ; \
    else                      \
        echo "Test"         ; \
    endif

Here is the command line

$make -f test.make prog_src

and I get the following in the output

/bin/bash: -c: line 0: syntax error near unexpected token `src,src'
/bin/bash: -c: line 0: `ifeq ( src,src )   \'
test.make:6: recipe for target 'prog_src' failed
make: *** [prog_src] Error 1

Secondly, How can i change the if statement such that instead of hard-coded variables I can do something like

program_%:
        ifeq ( $(TYPE),$* )   \
            echo "RTL"          ; \
        else                      \
            echo "Test"         ; \
        endif

Aucun commentaire:

Enregistrer un commentaire