Makefile ifeq logical or

前端 未结 5 812
有刺的猬
有刺的猬 2020-12-02 06:51

How do you perform a logical OR using make\'s ifeq operator?

e.g., I have (simplified):

ifeq ($(GCC_MINOR), 4)
    CFLAGS += -fno-strict         


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 07:29

    ifeq ($(GCC_MINOR), 4)
        CFLAGS += -fno-strict-overflow
    endif
    ifeq ($(GCC_MINOR), 5)
        CFLAGS += -fno-strict-overflow
    endif
    

    Another you can consider using in this case is:

    GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
    
    # -Wstrict-overflow: http://www.airs.com/blog/archives/120
    ifeq ($(GCC42_OR_LATER),1)
      CFLAGS += -Wstrict-overflow
    endif
    

    I actually use the same in my code because I don't want to maintain a separate config or Configure.

    But you have to use a portable, non-anemic make, like GNU make (gmake), and not Posix's make.

    And it does not address the issue of logical AND and OR.

提交回复
热议问题