dcsimg
Linux Today: Linux News On Internet Time.




More on LinuxToday


Linux.com: Getting Started with Make - Part 3: Directives

Nov 23, 2000, 14:06 (0 Talkback[s])
(Other stories by Derek Barber)

WEBINAR:
On-Demand

Re-Imagining Linux Platforms to Meet the Needs of Cloud Service Providers


"Directives are commands which you can put in your Makefiles to provide some neat enhancements. A very useful directive, called the include directive, allows you to include the contents of other files in your makefile. This can be very handy for organizing a large makefile into several files, among other things. There are also directives that provide the ability of conditional inclusion -- they decide whether to include or skip certain parts of a makefile based upon the value of variables. Finally, there is also a directive that enhances the handling of variables: the define directive."

"First, let's look at the include directive. The include directive is used to include the contents of a specified file into your makefile at a specified place. This is very useful for many things, especially with the organization of data and with the reusability of common makefile data. Before we get into an example, let's look at the general syntax of the include directive:

  include filenames... 
Please note that you can include shell wildcard characters in the filenames parameter."

"Conditional directives are used when you would like to execute or ignore certain parts of a makefile depending upon the values of variables. This can be very useful when deciding to set certain compilation parameters based upon the installed libraries or the locations of files. The syntax of a simple conditional directive is as follows:

  conditional-directive 
  commands executed if conditional is true 
  else 
  commands executed if conditional is false
  endif 
In the above syntax, the conditional-directive parameter can be one of several conditional directives."

Complete Story

Related Stories: