4.6. Control Structures and Directives

Control structures inside makefiles enable you to make some logical decisions depending upon certain conditions. Make supports four types of decision-making directives as listed below:

  1. The ifeq directive

  2. The ifneq directive

  3. The ifdef directive

  4. The ifndef directive

These directives are explained next. In addition to these directives, you can also use the for control structure to execute a loop a specified number of times. Let us have a look at each of these.

4.6.1. The ifeq Directive

The ifeq directive is used to compare two values and make a decision based upon the result. The general format of this directive is as follows:

 ifeq (value1, value2) block if value 1 is equal to value2 else block if value 1 is ...

Get Linux Development Platform: Configuring, Using, and Maintaining a Complete Programming Environment, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.