Get the App
SLTechnology News&Howtos  ›  Servers  › 

Makefile(03)_ condition judgment

Shulou Source: shulou.com Published: 2022-06-02 21:03:07 09月24日 Update

8. Conditional judgment statement 8.1. rule of grammar

Conditional judgment statements are supported in Makefile, which can directly compare the values and constant values of two different variables.

Note: conditional judgment statements can only be used to control the statements actually executed by make, not the execution of commands in rules.

Conditional interpretation grammar description:

Conditional judgment keyword:

Example:

.PHONY: testvar1: = Avar2: = $(var1) var3: = test: ifeq ($(var1), $(var2)) @ echo "var1 = = var2" else @ echo "var1! = var2" endif ifneq ($(var2) ) @ echo "var2 is NOT empty" else @ echo "var2 is empty" endif ifdef var2 @ echo "var2 is NOT empty" else @ echo "var2 is empty" endif ifndef var3 @ echo "var3 is empty" else @ echo "var3 is NOT empty" endif

Output result:

8.2. Engineering experience

1. Conditional judgment statements can be preceded by spaces, but cannot have Tab characters ('\ t')

two。 Do not use automatic variables ($@ $^ @) in conditional statements

Tags: Conditions statements different variables methods examples results expressions rules syntax stages control output valid same two keywords content commands Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno Xiaomi Shulou Tech Info Linux