Makefile If-Then Else and Loops

前端 未结 4 1550
青春惊慌失措
青春惊慌失措 2020-12-24 10:18

Can someone explain how to use if-then statements and for loops in Makefiles? I can\'t seem to find any good documentation with examples.

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 11:14

    Conditional Forms

    Simple

    conditional-directive
    text-if-true
    endif
    

    Moderately Complex

    conditional-directive
    text-if-true
    else
    text-if-false
    endif
    

    More Complex

    conditional-directive
    text-if-one-is-true
    else
    conditional-directive
    text-if-true
    else
    text-if-false
    endif
    endif
    

    Conditional Directives

    If Equal Syntax

    ifeq (arg1, arg2)
    ifeq 'arg1' 'arg2'
    ifeq "arg1" "arg2"
    ifeq "arg1" 'arg2'
    ifeq 'arg1' "arg2"
    

    If Not Equal Syntax

    ifneq (arg1, arg2)
    ifneq 'arg1' 'arg2'
    ifneq "arg1" "arg2"
    ifneq "arg1" 'arg2'
    ifneq 'arg1' "arg2"
    

    If Defined Syntax

    ifdef variable-name
    

    If Not Defined Syntax

    ifndef variable-name  
    

    foreach Function

    foreach Function Syntax

    $(foreach var, list, text)  
    

    foreach Semantics
    For each whitespace separated word in "list", the variable named by "var" is set to that word and text is executed.

提交回复
热议问题