判斷函式

ifeq ifneq

$(if <condition>,<then-part>)

$(if <condition>,<then-part>,<else-part>)

ifneq (<arg1>, <arg2>)

ifneq '<arg1>' '<arg2>'

ifneq "<arg1>" "<arg2>"

ifneq "<arg1>" '<arg2>'

ifneq '<arg1>' "<arg2>"

if函數可以包含「else」部分,或是不含。即if函數的參數可以是兩個,也可以是三個。

make是在讀取Makefile時就計算條件表達式的值,並根據條件表達式的值來選擇語句,所以,你最好不要把自動化變量(如「$@」等)放入條件表達式中,因為自動化變量是在運行時才有的。

ifeq ($(CC),gcc)
        $(CC) -o foo $(objects) $(libs_for_gcc)
else
        $(CC) -o foo $(objects) $(normal_libs)
endif
ifeq ($(TARGET_ARCH), arm)
        LOCAL_SRC_FILES := ...
else ifeq ($(TARGET_ARCH), x86)
        LOCAL_SRC_FILES := ...
else ifeq ($(TARGET_ARCH), mips)
        LOCAL_SRC_FILES := ...
else 
        LOCAL_SRC_FILES := ...
endif

ifdef ifndef

ifdef CATEGORY
    $(info CATEGORY defined)
else
    $(info CATEGORY undefined)
endif

or

$(or condition1[,condition2][,condition3]...)

and

$(and condition1[,condition2][,condition3]...)

results matching ""

    No results matching ""