Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Makefile(03)_ condition judgment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report