1diff -rNU3 dist.orig/Makefile.in dist/Makefile.in 2--- dist.orig/Makefile.in 2006-04-01 08:40:04.000000000 +0200 3+++ dist/Makefile.in 2014-08-18 08:57:25.000000000 +0200 4@@ -330,6 +330,8 @@ 5 am--refresh: 6 @: 7 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 8+ @echo "NOT REBUILDING $@" 9+NetBSD_DISABLED_Makefile.in: 10 @for dep in $?; do \ 11 case '$(am__configure_deps)' in \ 12 *$$dep*) \ 13@@ -357,6 +359,8 @@ 14 $(SHELL) ./config.status --recheck 15 16 $(top_srcdir)/configure: $(am__configure_deps) 17+ @echo "NOT REBUILDING $@" 18+NetBSD_DISABLED_configure: 19 cd $(srcdir) && $(AUTOCONF) 20 $(ACLOCAL_M4): $(am__aclocal_m4_deps) 21 cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 22@@ -371,6 +375,8 @@ 23 @rm -f stamp-h1 24 cd $(top_builddir) && $(SHELL) ./config.status config.h 25 $(srcdir)/config.h.in: $(am__configure_deps) 26+ @echo "NOT REBUILDING $@" 27+NetBSD_DISABLED_config.h.in: 28 cd $(top_srcdir) && $(AUTOHEADER) 29 rm -f stamp-h1 30 touch $@ 31diff -rNU3 dist.orig/ansi2knr.c dist/ansi2knr.c 32--- dist.orig/ansi2knr.c 2006-04-01 08:40:04.000000000 +0200 33+++ dist/ansi2knr.c 2014-08-18 08:46:57.000000000 +0200 34@@ -1,6 +1,6 @@ 35 /* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */ 36 37-/*$Id: ansi2knr.c,v 1.3 2000/04/13 03:41:48 lpd Exp $*/ 38+/*$Id: ansi2knr.c,v 1.1.1.1 2014/08/18 06:46:57 christos Exp $*/ 39 /* Convert ANSI C function definitions to K&R ("traditional C") syntax */ 40 41 /* 42diff -rNU3 dist.orig/config/config.guess dist/config/config.guess 43--- dist.orig/config/config.guess 2006-04-01 08:41:00.000000000 +0200 44+++ dist/config/config.guess 2014-08-18 09:12:47.000000000 +0200 45@@ -939,6 +939,9 @@ 46 sparc:Linux:*:* | sparc64:Linux:*:*) 47 echo ${UNAME_MACHINE}-unknown-linux-gnu 48 exit ;; 49+ tile*:Linux:*:*) 50+ echo ${UNAME_MACHINE}-unknown-linux-gnu 51+ exit 0 ;; 52 vax:Linux:*:*) 53 echo ${UNAME_MACHINE}-dec-linux-gnu 54 exit ;; 55diff -rNU3 dist.orig/configure.in dist/configure.in 56--- dist.orig/configure.in 2006-04-01 08:36:40.000000000 +0200 57+++ dist/configure.in 2014-08-18 08:46:47.000000000 +0200 58@@ -19,7 +19,7 @@ 59 AC_INIT([GNU make],[3.81],[bug-make@gnu.org]) 60 61 AC_PREREQ(2.59) 62-AC_REVISION([[$Id: configure.in,v 1.142 2006/04/01 06:36:40 psmith Exp $]]) 63+AC_REVISION([[$Id: configure.in,v 1.1.1.1 2014/08/18 06:46:47 christos Exp $]]) 64 65 # Autoconf setup 66 AC_CONFIG_AUX_DIR(config) 67diff -rNU3 dist.orig/doc/make.info dist/doc/make.info 68--- dist.orig/doc/make.info 2006-04-01 08:41:04.000000000 +0200 69+++ dist/doc/make.info 1970-01-01 01:00:00.000000000 +0100 70@@ -1,184 +0,0 @@ 71-This is make.info, produced by makeinfo version 4.8 from make.texi. 72- 73- This file documents the GNU `make' utility, which determines 74-automatically which pieces of a large program need to be recompiled, 75-and issues the commands to recompile them. 76- 77- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make 78-Manual', for GNU `make' version 3.81. 79- 80- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 81-1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software 82-Foundation, Inc. 83- 84- Permission is granted to copy, distribute and/or modify this 85- document under the terms of the GNU Free Documentation License, 86- Version 1.2 or any later version published by the Free Software 87- Foundation; with no Invariant Sections, with the Front-Cover Texts 88- being "A GNU Manual," and with the Back-Cover Texts as in (a) 89- below. A copy of the license is included in the section entitled 90- "GNU Free Documentation License." 91- 92- (a) The FSF's Back-Cover Text is: "You have freedom to copy and 93- modify this GNU Manual, like GNU software. Copies published by 94- the Free Software Foundation raise funds for GNU development." 95- 96-INFO-DIR-SECTION GNU Packages 97-START-INFO-DIR-ENTRY 98-* Make: (make). Remake files automatically. 99-END-INFO-DIR-ENTRY 100- 101- 102-Indirect: 103-make.info-1: 1297 104-make.info-2: 301265 105- 106-Tag Table: 107-(Indirect) 108-Node: Top1297 109-Node: Overview14702 110-Node: Preparing15712 111-Node: Reading16684 112-Node: Bugs17611 113-Node: Introduction19441 114-Node: Rule Introduction21033 115-Node: Simple Makefile22777 116-Node: How Make Works26406 117-Node: Variables Simplify29061 118-Node: make Deduces31267 119-Node: Combine By Prerequisite33007 120-Node: Cleanup34036 121-Node: Makefiles35455 122-Node: Makefile Contents36421 123-Node: Makefile Names39376 124-Node: Include40987 125-Ref: Include-Footnote-144619 126-Node: MAKEFILES Variable44753 127-Node: MAKEFILE_LIST Variable46263 128-Node: Special Variables47531 129-Node: Remaking Makefiles51038 130-Node: Overriding Makefiles55287 131-Node: Reading Makefiles57340 132-Node: Secondary Expansion60244 133-Node: Rules67678 134-Node: Rule Example70350 135-Node: Rule Syntax71207 136-Node: Prerequisite Types73710 137-Node: Wildcards75486 138-Node: Wildcard Examples77204 139-Node: Wildcard Pitfall78460 140-Node: Wildcard Function80249 141-Node: Directory Search82033 142-Node: General Search83175 143-Node: Selective Search84890 144-Node: Search Algorithm87878 145-Node: Commands/Search90397 146-Node: Implicit/Search91743 147-Node: Libraries/Search92687 148-Node: Phony Targets94779 149-Node: Force Targets99865 150-Node: Empty Targets100910 151-Node: Special Targets102208 152-Node: Multiple Targets109382 153-Node: Multiple Rules111257 154-Node: Static Pattern113493 155-Node: Static Usage114145 156-Node: Static versus Implicit117866 157-Node: Double-Colon119610 158-Node: Automatic Prerequisites121267 159-Node: Commands125545 160-Node: Command Syntax126753 161-Node: Splitting Lines128778 162-Node: Variables in Commands131759 163-Node: Echoing133086 164-Node: Execution134378 165-Ref: Execution-Footnote-1135629 166-Node: Choosing the Shell135775 167-Node: Parallel139744 168-Node: Errors143337 169-Node: Interrupts146983 170-Node: Recursion148570 171-Node: MAKE Variable150664 172-Node: Variables/Recursion152931 173-Node: Options/Recursion158372 174-Node: -w Option163537 175-Node: Sequences164532 176-Node: Empty Commands167544 177-Node: Using Variables168718 178-Node: Reference171831 179-Node: Flavors173390 180-Node: Advanced179128 181-Node: Substitution Refs179633 182-Node: Computed Names181186 183-Node: Values185730 184-Node: Setting186643 185-Node: Appending188679 186-Node: Override Directive192605 187-Node: Defining193989 188-Node: Environment196453 189-Node: Target-specific198702 190-Node: Pattern-specific201669 191-Node: Conditionals203071 192-Node: Conditional Example203781 193-Node: Conditional Syntax206358 194-Node: Testing Flags212083 195-Node: Functions213185 196-Node: Syntax of Functions214605 197-Node: Text Functions216804 198-Node: File Name Functions225375 199-Node: Conditional Functions230597 200-Node: Foreach Function232971 201-Node: Call Function236183 202-Node: Value Function239068 203-Node: Eval Function240505 204-Node: Origin Function242779 205-Node: Flavor Function245997 206-Node: Shell Function247063 207-Node: Make Control Functions248697 208-Node: Running250366 209-Node: Makefile Arguments252355 210-Node: Goals253071 211-Node: Instead of Execution257812 212-Node: Avoiding Compilation261098 213-Node: Overriding263073 214-Node: Testing265371 215-Node: Options Summary267256 216-Node: Implicit Rules277382 217-Node: Using Implicit279530 218-Node: Catalogue of Rules283069 219-Node: Implicit Variables292419 220-Node: Chained Rules297254 221-Node: Pattern Rules301265 222-Node: Pattern Intro302801 223-Node: Pattern Examples305698 224-Node: Automatic Variables307507 225-Node: Pattern Match314878 226-Node: Match-Anything Rules316514 227-Node: Canceling Rules320389 228-Node: Last Resort321105 229-Node: Suffix Rules322952 230-Node: Implicit Rule Search326681 231-Node: Archives330200 232-Node: Archive Members330898 233-Node: Archive Update332511 234-Node: Archive Symbols334425 235-Node: Archive Pitfalls335659 236-Node: Archive Suffix Rules336382 237-Node: Features337929 238-Node: Missing346484 239-Node: Makefile Conventions350222 240-Node: Makefile Basics351008 241-Node: Utilities in Makefiles354175 242-Node: Command Variables356313 243-Node: Directory Variables359883 244-Node: Standard Targets374023 245-Ref: Standard Targets-Footnote-1387142 246-Node: Install Command Categories387242 247-Node: Quick Reference391768 248-Node: Error Messages402464 249-Node: Complex Makefile410154 250-Node: GNU Free Documentation License418872 251-Node: Concept Index441321 252-Node: Name Index506510 253- 254-End Tag Table 255diff -rNU3 dist.orig/doc/make.info-1 dist/doc/make.info-1 256--- dist.orig/doc/make.info-1 2006-04-01 08:41:04.000000000 +0200 257+++ dist/doc/make.info-1 1970-01-01 01:00:00.000000000 +0100 258@@ -1,7261 +0,0 @@ 259-This is make.info, produced by makeinfo version 4.8 from make.texi. 260- 261- This file documents the GNU `make' utility, which determines 262-automatically which pieces of a large program need to be recompiled, 263-and issues the commands to recompile them. 264- 265- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make 266-Manual', for GNU `make' version 3.81. 267- 268- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 269-1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software 270-Foundation, Inc. 271- 272- Permission is granted to copy, distribute and/or modify this 273- document under the terms of the GNU Free Documentation License, 274- Version 1.2 or any later version published by the Free Software 275- Foundation; with no Invariant Sections, with the Front-Cover Texts 276- being "A GNU Manual," and with the Back-Cover Texts as in (a) 277- below. A copy of the license is included in the section entitled 278- "GNU Free Documentation License." 279- 280- (a) The FSF's Back-Cover Text is: "You have freedom to copy and 281- modify this GNU Manual, like GNU software. Copies published by 282- the Free Software Foundation raise funds for GNU development." 283- 284-INFO-DIR-SECTION GNU Packages 285-START-INFO-DIR-ENTRY 286-* Make: (make). Remake files automatically. 287-END-INFO-DIR-ENTRY 288- 289- 290-File: make.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) 291- 292-GNU `make' 293-********** 294- 295-This file documents the GNU `make' utility, which determines 296-automatically which pieces of a large program need to be recompiled, 297-and issues the commands to recompile them. 298- 299- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make 300-Manual', for GNU `make' version 3.81. 301- 302- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 303-1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software 304-Foundation, Inc. 305- 306- Permission is granted to copy, distribute and/or modify this 307- document under the terms of the GNU Free Documentation License, 308- Version 1.2 or any later version published by the Free Software 309- Foundation; with no Invariant Sections, with the Front-Cover Texts 310- being "A GNU Manual," and with the Back-Cover Texts as in (a) 311- below. A copy of the license is included in the section entitled 312- "GNU Free Documentation License." 313- 314- (a) The FSF's Back-Cover Text is: "You have freedom to copy and 315- modify this GNU Manual, like GNU software. Copies published by 316- the Free Software Foundation raise funds for GNU development." 317- 318-* Menu: 319- 320-* Overview:: Overview of `make'. 321-* Introduction:: An introduction to `make'. 322-* Makefiles:: Makefiles tell `make' what to do. 323-* Rules:: Rules describe when a file must be remade. 324-* Commands:: Commands say how to remake a file. 325-* Using Variables:: You can use variables to avoid repetition. 326-* Conditionals:: Use or ignore parts of the makefile based 327- on the values of variables. 328-* Functions:: Many powerful ways to manipulate text. 329-* Invoking make: Running. How to invoke `make' on the command line. 330-* Implicit Rules:: Use implicit rules to treat many files alike, 331- based on their file names. 332-* Archives:: How `make' can update library archives. 333-* Features:: Features GNU `make' has over other `make's. 334-* Missing:: What GNU `make' lacks from other `make's. 335-* Makefile Conventions:: Conventions for writing makefiles for 336- GNU programs. 337-* Quick Reference:: A quick reference for experienced users. 338-* Error Messages:: A list of common errors generated by `make'. 339-* Complex Makefile:: A real example of a straightforward, 340- but nontrivial, makefile. 341- 342-* GNU Free Documentation License:: License for copying this manual 343-* Concept Index:: Index of Concepts 344-* Name Index:: Index of Functions, Variables, & Directives 345- 346- --- The Detailed Node Listing --- 347- 348-Overview of `make' 349- 350-* Preparing:: Preparing and Running Make 351-* Reading:: On Reading this Text 352-* Bugs:: Problems and Bugs 353- 354-An Introduction to Makefiles 355- 356-* Rule Introduction:: What a rule looks like. 357-* Simple Makefile:: A Simple Makefile 358-* How Make Works:: How `make' Processes This Makefile 359-* Variables Simplify:: Variables Make Makefiles Simpler 360-* make Deduces:: Letting `make' Deduce the Commands 361-* Combine By Prerequisite:: Another Style of Makefile 362-* Cleanup:: Rules for Cleaning the Directory 363- 364-Writing Makefiles 365- 366-* Makefile Contents:: What makefiles contain. 367-* Makefile Names:: How to name your makefile. 368-* Include:: How one makefile can use another makefile. 369-* MAKEFILES Variable:: The environment can specify extra makefiles. 370-* MAKEFILE_LIST Variable:: Discover which makefiles have been read. 371-* Special Variables:: Other special variables. 372-* Remaking Makefiles:: How makefiles get remade. 373-* Overriding Makefiles:: How to override part of one makefile 374- with another makefile. 375-* Reading Makefiles:: How makefiles are parsed. 376-* Secondary Expansion:: How and when secondary expansion is performed. 377- 378-Writing Rules 379- 380-* Rule Example:: An example explained. 381-* Rule Syntax:: General syntax explained. 382-* Prerequisite Types:: There are two types of prerequisites. 383-* Wildcards:: Using wildcard characters such as `*'. 384-* Directory Search:: Searching other directories for source files. 385-* Phony Targets:: Using a target that is not a real file's name. 386-* Force Targets:: You can use a target without commands 387- or prerequisites to mark other targets 388- as phony. 389-* Empty Targets:: When only the date matters and the 390- files are empty. 391-* Special Targets:: Targets with special built-in meanings. 392-* Multiple Targets:: When to make use of several targets in a rule. 393-* Multiple Rules:: How to use several rules with the same target. 394-* Static Pattern:: Static pattern rules apply to multiple targets 395- and can vary the prerequisites according to 396- the target name. 397-* Double-Colon:: How to use a special kind of rule to allow 398- several independent rules for one target. 399-* Automatic Prerequisites:: How to automatically generate rules giving 400- prerequisites from source files themselves. 401- 402-Using Wildcard Characters in File Names 403- 404-* Wildcard Examples:: Several examples 405-* Wildcard Pitfall:: Problems to avoid. 406-* Wildcard Function:: How to cause wildcard expansion where 407- it does not normally take place. 408- 409-Searching Directories for Prerequisites 410- 411-* General Search:: Specifying a search path that applies 412- to every prerequisite. 413-* Selective Search:: Specifying a search path 414- for a specified class of names. 415-* Search Algorithm:: When and how search paths are applied. 416-* Commands/Search:: How to write shell commands that work together 417- with search paths. 418-* Implicit/Search:: How search paths affect implicit rules. 419-* Libraries/Search:: Directory search for link libraries. 420- 421-Static Pattern Rules 422- 423-* Static Usage:: The syntax of static pattern rules. 424-* Static versus Implicit:: When are they better than implicit rules? 425- 426-Writing the Commands in Rules 427- 428-* Command Syntax:: Command syntax features and pitfalls. 429-* Echoing:: How to control when commands are echoed. 430-* Execution:: How commands are executed. 431-* Parallel:: How commands can be executed in parallel. 432-* Errors:: What happens after a command execution error. 433-* Interrupts:: What happens when a command is interrupted. 434-* Recursion:: Invoking `make' from makefiles. 435-* Sequences:: Defining canned sequences of commands. 436-* Empty Commands:: Defining useful, do-nothing commands. 437- 438-Command Syntax 439- 440-* Splitting Lines:: Breaking long command lines for readability. 441-* Variables in Commands:: Using `make' variables in commands. 442- 443-Command Execution 444- 445-* Choosing the Shell:: How `make' chooses the shell used 446- to run commands. 447- 448-Recursive Use of `make' 449- 450-* MAKE Variable:: The special effects of using `$(MAKE)'. 451-* Variables/Recursion:: How to communicate variables to a sub-`make'. 452-* Options/Recursion:: How to communicate options to a sub-`make'. 453-* -w Option:: How the `-w' or `--print-directory' option 454- helps debug use of recursive `make' commands. 455- 456-How to Use Variables 457- 458-* Reference:: How to use the value of a variable. 459-* Flavors:: Variables come in two flavors. 460-* Advanced:: Advanced features for referencing a variable. 461-* Values:: All the ways variables get their values. 462-* Setting:: How to set a variable in the makefile. 463-* Appending:: How to append more text to the old value 464- of a variable. 465-* Override Directive:: How to set a variable in the makefile even if 466- the user has set it with a command argument. 467-* Defining:: An alternate way to set a variable 468- to a verbatim string. 469-* Environment:: Variable values can come from the environment. 470-* Target-specific:: Variable values can be defined on a per-target 471- basis. 472-* Pattern-specific:: Target-specific variable values can be applied 473- to a group of targets that match a pattern. 474- 475-Advanced Features for Reference to Variables 476- 477-* Substitution Refs:: Referencing a variable with 478- substitutions on the value. 479-* Computed Names:: Computing the name of the variable to refer to. 480- 481-Conditional Parts of Makefiles 482- 483-* Conditional Example:: Example of a conditional 484-* Conditional Syntax:: The syntax of conditionals. 485-* Testing Flags:: Conditionals that test flags. 486- 487-Functions for Transforming Text 488- 489-* Syntax of Functions:: How to write a function call. 490-* Text Functions:: General-purpose text manipulation functions. 491-* File Name Functions:: Functions for manipulating file names. 492-* Conditional Functions:: Functions that implement conditions. 493-* Foreach Function:: Repeat some text with controlled variation. 494-* Call Function:: Expand a user-defined function. 495-* Value Function:: Return the un-expanded value of a variable. 496-* Eval Function:: Evaluate the arguments as makefile syntax. 497-* Origin Function:: Find where a variable got its value. 498-* Flavor Function:: Find out the flavor of a variable. 499-* Shell Function:: Substitute the output of a shell command. 500-* Make Control Functions:: Functions that control how make runs. 501- 502-How to Run `make' 503- 504-* Makefile Arguments:: How to specify which makefile to use. 505-* Goals:: How to use goal arguments to specify which 506- parts of the makefile to use. 507-* Instead of Execution:: How to use mode flags to specify what 508- kind of thing to do with the commands 509- in the makefile other than simply 510- execute them. 511-* Avoiding Compilation:: How to avoid recompiling certain files. 512-* Overriding:: How to override a variable to specify 513- an alternate compiler and other things. 514-* Testing:: How to proceed past some errors, to 515- test compilation. 516-* Options Summary:: Summary of Options 517- 518-Using Implicit Rules 519- 520-* Using Implicit:: How to use an existing implicit rule 521- to get the commands for updating a file. 522-* Catalogue of Rules:: A list of built-in implicit rules. 523-* Implicit Variables:: How to change what predefined rules do. 524-* Chained Rules:: How to use a chain of implicit rules. 525-* Pattern Rules:: How to define new implicit rules. 526-* Last Resort:: How to define commands for rules which 527- cannot find any. 528-* Suffix Rules:: The old-fashioned style of implicit rule. 529-* Implicit Rule Search:: The precise algorithm for applying 530- implicit rules. 531- 532-Defining and Redefining Pattern Rules 533- 534-* Pattern Intro:: An introduction to pattern rules. 535-* Pattern Examples:: Examples of pattern rules. 536-* Automatic Variables:: How to use automatic variables in the 537- commands of implicit rules. 538-* Pattern Match:: How patterns match. 539-* Match-Anything Rules:: Precautions you should take prior to 540- defining rules that can match any 541- target file whatever. 542-* Canceling Rules:: How to override or cancel built-in rules. 543- 544-Using `make' to Update Archive Files 545- 546-* Archive Members:: Archive members as targets. 547-* Archive Update:: The implicit rule for archive member targets. 548-* Archive Pitfalls:: Dangers to watch out for when using archives. 549-* Archive Suffix Rules:: You can write a special kind of suffix rule 550- for updating archives. 551- 552-Implicit Rule for Archive Member Targets 553- 554-* Archive Symbols:: How to update archive symbol directories. 555- 556- 557-File: make.info, Node: Overview, Next: Introduction, Prev: Top, Up: Top 558- 559-1 Overview of `make' 560-******************** 561- 562-The `make' utility automatically determines which pieces of a large 563-program need to be recompiled, and issues commands to recompile them. 564-This manual describes GNU `make', which was implemented by Richard 565-Stallman and Roland McGrath. Development since Version 3.76 has been 566-handled by Paul D. Smith. 567- 568- GNU `make' conforms to section 6.2 of `IEEE Standard 1003.2-1992' 569-(POSIX.2). 570- 571- Our examples show C programs, since they are most common, but you 572-can use `make' with any programming language whose compiler can be run 573-with a shell command. Indeed, `make' is not limited to programs. You 574-can use it to describe any task where some files must be updated 575-automatically from others whenever the others change. 576- 577-* Menu: 578- 579-* Preparing:: Preparing and Running Make 580-* Reading:: On Reading this Text 581-* Bugs:: Problems and Bugs 582- 583- 584-File: make.info, Node: Preparing, Next: Reading, Prev: Overview, Up: Overview 585- 586-Preparing and Running Make 587-========================== 588- 589- To prepare to use `make', you must write a file called the 590-"makefile" that describes the relationships among files in your program 591-and provides commands for updating each file. In a program, typically, 592-the executable file is updated from object files, which are in turn 593-made by compiling source files. 594- 595- Once a suitable makefile exists, each time you change some source 596-files, this simple shell command: 597- 598- make 599- 600-suffices to perform all necessary recompilations. The `make' program 601-uses the makefile data base and the last-modification times of the 602-files to decide which of the files need to be updated. For each of 603-those files, it issues the commands recorded in the data base. 604- 605- You can provide command line arguments to `make' to control which 606-files should be recompiled, or how. *Note How to Run `make': Running. 607- 608- 609-File: make.info, Node: Reading, Next: Bugs, Prev: Preparing, Up: Overview 610- 611-1.1 How to Read This Manual 612-=========================== 613- 614-If you are new to `make', or are looking for a general introduction, 615-read the first few sections of each chapter, skipping the later 616-sections. In each chapter, the first few sections contain introductory 617-or general information and the later sections contain specialized or 618-technical information. The exception is the second chapter, *Note An 619-Introduction to Makefiles: Introduction, all of which is introductory. 620- 621- If you are familiar with other `make' programs, see *Note Features 622-of GNU `make': Features, which lists the enhancements GNU `make' has, 623-and *Note Incompatibilities and Missing Features: Missing, which 624-explains the few things GNU `make' lacks that others have. 625- 626- For a quick summary, see *Note Options Summary::, *Note Quick 627-Reference::, and *Note Special Targets::. 628- 629- 630-File: make.info, Node: Bugs, Prev: Reading, Up: Overview 631- 632-1.2 Problems and Bugs 633-===================== 634- 635-If you have problems with GNU `make' or think you've found a bug, 636-please report it to the developers; we cannot promise to do anything but 637-we might well want to fix it. 638- 639- Before reporting a bug, make sure you've actually found a real bug. 640-Carefully reread the documentation and see if it really says you can do 641-what you're trying to do. If it's not clear whether you should be able 642-to do something or not, report that too; it's a bug in the 643-documentation! 644- 645- Before reporting a bug or trying to fix it yourself, try to isolate 646-it to the smallest possible makefile that reproduces the problem. Then 647-send us the makefile and the exact results `make' gave you, including 648-any error or warning messages. Please don't paraphrase these messages: 649-it's best to cut and paste them into your report. When generating this 650-small makefile, be sure to not use any non-free or unusual tools in 651-your commands: you can almost always emulate what such a tool would do 652-with simple shell commands. Finally, be sure to explain what you 653-expected to occur; this will help us decide whether the problem was 654-really in the documentation. 655- 656- Once you have a precise problem you can report it in one of two ways. 657-Either send electronic mail to: 658- 659- bug-make@gnu.org 660- 661-or use our Web-based project management tool, at: 662- 663- http://savannah.gnu.org/projects/make/ 664- 665-In addition to the information above, please be careful to include the 666-version number of `make' you are using. You can get this information 667-with the command `make --version'. Be sure also to include the type of 668-machine and operating system you are using. One way to obtain this 669-information is by looking at the final lines of output from the command 670-`make --help'. 671- 672- 673-File: make.info, Node: Introduction, Next: Makefiles, Prev: Overview, Up: Top 674- 675-2 An Introduction to Makefiles 676-****************************** 677- 678-You need a file called a "makefile" to tell `make' what to do. Most 679-often, the makefile tells `make' how to compile and link a program. 680- 681- In this chapter, we will discuss a simple makefile that describes 682-how to compile and link a text editor which consists of eight C source 683-files and three header files. The makefile can also tell `make' how to 684-run miscellaneous commands when explicitly asked (for example, to remove 685-certain files as a clean-up operation). To see a more complex example 686-of a makefile, see *Note Complex Makefile::. 687- 688- When `make' recompiles the editor, each changed C source file must 689-be recompiled. If a header file has changed, each C source file that 690-includes the header file must be recompiled to be safe. Each 691-compilation produces an object file corresponding to the source file. 692-Finally, if any source file has been recompiled, all the object files, 693-whether newly made or saved from previous compilations, must be linked 694-together to produce the new executable editor. 695- 696-* Menu: 697- 698-* Rule Introduction:: What a rule looks like. 699-* Simple Makefile:: A Simple Makefile 700-* How Make Works:: How `make' Processes This Makefile 701-* Variables Simplify:: Variables Make Makefiles Simpler 702-* make Deduces:: Letting `make' Deduce the Commands 703-* Combine By Prerequisite:: Another Style of Makefile 704-* Cleanup:: Rules for Cleaning the Directory 705- 706- 707-File: make.info, Node: Rule Introduction, Next: Simple Makefile, Prev: Introduction, Up: Introduction 708- 709-2.1 What a Rule Looks Like 710-========================== 711- 712-A simple makefile consists of "rules" with the following shape: 713- 714- TARGET ... : PREREQUISITES ... 715- COMMAND 716- ... 717- ... 718- 719- A "target" is usually the name of a file that is generated by a 720-program; examples of targets are executable or object files. A target 721-can also be the name of an action to carry out, such as `clean' (*note 722-Phony Targets::). 723- 724- A "prerequisite" is a file that is used as input to create the 725-target. A target often depends on several files. 726- 727- A "command" is an action that `make' carries out. A rule may have 728-more than one command, each on its own line. *Please note:* you need 729-to put a tab character at the beginning of every command line! This is 730-an obscurity that catches the unwary. 731- 732- Usually a command is in a rule with prerequisites and serves to 733-create a target file if any of the prerequisites change. However, the 734-rule that specifies commands for the target need not have 735-prerequisites. For example, the rule containing the delete command 736-associated with the target `clean' does not have prerequisites. 737- 738- A "rule", then, explains how and when to remake certain files which 739-are the targets of the particular rule. `make' carries out the 740-commands on the prerequisites to create or update the target. A rule 741-can also explain how and when to carry out an action. *Note Writing 742-Rules: Rules. 743- 744- A makefile may contain other text besides rules, but a simple 745-makefile need only contain rules. Rules may look somewhat more 746-complicated than shown in this template, but all fit the pattern more 747-or less. 748- 749- 750-File: make.info, Node: Simple Makefile, Next: How Make Works, Prev: Rule Introduction, Up: Introduction 751- 752-2.2 A Simple Makefile 753-===================== 754- 755-Here is a straightforward makefile that describes the way an executable 756-file called `edit' depends on eight object files which, in turn, depend 757-on eight C source and three header files. 758- 759- In this example, all the C files include `defs.h', but only those 760-defining editing commands include `command.h', and only low level files 761-that change the editor buffer include `buffer.h'. 762- 763- edit : main.o kbd.o command.o display.o \ 764- insert.o search.o files.o utils.o 765- cc -o edit main.o kbd.o command.o display.o \ 766- insert.o search.o files.o utils.o 767- 768- main.o : main.c defs.h 769- cc -c main.c 770- kbd.o : kbd.c defs.h command.h 771- cc -c kbd.c 772- command.o : command.c defs.h command.h 773- cc -c command.c 774- display.o : display.c defs.h buffer.h 775- cc -c display.c 776- insert.o : insert.c defs.h buffer.h 777- cc -c insert.c 778- search.o : search.c defs.h buffer.h 779- cc -c search.c 780- files.o : files.c defs.h buffer.h command.h 781- cc -c files.c 782- utils.o : utils.c defs.h 783- cc -c utils.c 784- clean : 785- rm edit main.o kbd.o command.o display.o \ 786- insert.o search.o files.o utils.o 787- 788-We split each long line into two lines using backslash-newline; this is 789-like using one long line, but is easier to read. 790- 791- To use this makefile to create the executable file called `edit', 792-type: 793- 794- make 795- 796- To use this makefile to delete the executable file and all the object 797-files from the directory, type: 798- 799- make clean 800- 801- In the example makefile, the targets include the executable file 802-`edit', and the object files `main.o' and `kbd.o'. The prerequisites 803-are files such as `main.c' and `defs.h'. In fact, each `.o' file is 804-both a target and a prerequisite. Commands include `cc -c main.c' and 805-`cc -c kbd.c'. 806- 807- When a target is a file, it needs to be recompiled or relinked if any 808-of its prerequisites change. In addition, any prerequisites that are 809-themselves automatically generated should be updated first. In this 810-example, `edit' depends on each of the eight object files; the object 811-file `main.o' depends on the source file `main.c' and on the header 812-file `defs.h'. 813- 814- A shell command follows each line that contains a target and 815-prerequisites. These shell commands say how to update the target file. 816-A tab character must come at the beginning of every command line to 817-distinguish command lines from other lines in the makefile. (Bear in 818-mind that `make' does not know anything about how the commands work. 819-It is up to you to supply commands that will update the target file 820-properly. All `make' does is execute the commands in the rule you have 821-specified when the target file needs to be updated.) 822- 823- The target `clean' is not a file, but merely the name of an action. 824-Since you normally do not want to carry out the actions in this rule, 825-`clean' is not a prerequisite of any other rule. Consequently, `make' 826-never does anything with it unless you tell it specifically. Note that 827-this rule not only is not a prerequisite, it also does not have any 828-prerequisites, so the only purpose of the rule is to run the specified 829-commands. Targets that do not refer to files but are just actions are 830-called "phony targets". *Note Phony Targets::, for information about 831-this kind of target. *Note Errors in Commands: Errors, to see how to 832-cause `make' to ignore errors from `rm' or any other command. 833- 834- 835-File: make.info, Node: How Make Works, Next: Variables Simplify, Prev: Simple Makefile, Up: Introduction 836- 837-2.3 How `make' Processes a Makefile 838-=================================== 839- 840-By default, `make' starts with the first target (not targets whose 841-names start with `.'). This is called the "default goal". ("Goals" 842-are the targets that `make' strives ultimately to update. You can 843-override this behavior using the command line (*note Arguments to 844-Specify the Goals: Goals.) or with the `.DEFAULT_GOAL' special variable 845-(*note Other Special Variables: Special Variables.). 846- 847- In the simple example of the previous section, the default goal is to 848-update the executable program `edit'; therefore, we put that rule first. 849- 850- Thus, when you give the command: 851- 852- make 853- 854-`make' reads the makefile in the current directory and begins by 855-processing the first rule. In the example, this rule is for relinking 856-`edit'; but before `make' can fully process this rule, it must process 857-the rules for the files that `edit' depends on, which in this case are 858-the object files. Each of these files is processed according to its 859-own rule. These rules say to update each `.o' file by compiling its 860-source file. The recompilation must be done if the source file, or any 861-of the header files named as prerequisites, is more recent than the 862-object file, or if the object file does not exist. 863- 864- The other rules are processed because their targets appear as 865-prerequisites of the goal. If some other rule is not depended on by the 866-goal (or anything it depends on, etc.), that rule is not processed, 867-unless you tell `make' to do so (with a command such as `make clean'). 868- 869- Before recompiling an object file, `make' considers updating its 870-prerequisites, the source file and header files. This makefile does not 871-specify anything to be done for them--the `.c' and `.h' files are not 872-the targets of any rules--so `make' does nothing for these files. But 873-`make' would update automatically generated C programs, such as those 874-made by Bison or Yacc, by their own rules at this time. 875- 876- After recompiling whichever object files need it, `make' decides 877-whether to relink `edit'. This must be done if the file `edit' does 878-not exist, or if any of the object files are newer than it. If an 879-object file was just recompiled, it is now newer than `edit', so `edit' 880-is relinked. 881- 882- Thus, if we change the file `insert.c' and run `make', `make' will 883-compile that file to update `insert.o', and then link `edit'. If we 884-change the file `command.h' and run `make', `make' will recompile the 885-object files `kbd.o', `command.o' and `files.o' and then link the file 886-`edit'. 887- 888- 889-File: make.info, Node: Variables Simplify, Next: make Deduces, Prev: How Make Works, Up: Introduction 890- 891-2.4 Variables Make Makefiles Simpler 892-==================================== 893- 894-In our example, we had to list all the object files twice in the rule 895-for `edit' (repeated here): 896- 897- edit : main.o kbd.o command.o display.o \ 898- insert.o search.o files.o utils.o 899- cc -o edit main.o kbd.o command.o display.o \ 900- insert.o search.o files.o utils.o 901- 902- Such duplication is error-prone; if a new object file is added to the 903-system, we might add it to one list and forget the other. We can 904-eliminate the risk and simplify the makefile by using a variable. 905-"Variables" allow a text string to be defined once and substituted in 906-multiple places later (*note How to Use Variables: Using Variables.). 907- 908- It is standard practice for every makefile to have a variable named 909-`objects', `OBJECTS', `objs', `OBJS', `obj', or `OBJ' which is a list 910-of all object file names. We would define such a variable `objects' 911-with a line like this in the makefile: 912- 913- objects = main.o kbd.o command.o display.o \ 914- insert.o search.o files.o utils.o 915- 916-Then, each place we want to put a list of the object file names, we can 917-substitute the variable's value by writing `$(objects)' (*note How to 918-Use Variables: Using Variables.). 919- 920- Here is how the complete simple makefile looks when you use a 921-variable for the object files: 922- 923- objects = main.o kbd.o command.o display.o \ 924- insert.o search.o files.o utils.o 925- 926- edit : $(objects) 927- cc -o edit $(objects) 928- main.o : main.c defs.h 929- cc -c main.c 930- kbd.o : kbd.c defs.h command.h 931- cc -c kbd.c 932- command.o : command.c defs.h command.h 933- cc -c command.c 934- display.o : display.c defs.h buffer.h 935- cc -c display.c 936- insert.o : insert.c defs.h buffer.h 937- cc -c insert.c 938- search.o : search.c defs.h buffer.h 939- cc -c search.c 940- files.o : files.c defs.h buffer.h command.h 941- cc -c files.c 942- utils.o : utils.c defs.h 943- cc -c utils.c 944- clean : 945- rm edit $(objects) 946- 947- 948-File: make.info, Node: make Deduces, Next: Combine By Prerequisite, Prev: Variables Simplify, Up: Introduction 949- 950-2.5 Letting `make' Deduce the Commands 951-====================================== 952- 953-It is not necessary to spell out the commands for compiling the 954-individual C source files, because `make' can figure them out: it has an 955-"implicit rule" for updating a `.o' file from a correspondingly named 956-`.c' file using a `cc -c' command. For example, it will use the 957-command `cc -c main.c -o main.o' to compile `main.c' into `main.o'. We 958-can therefore omit the commands from the rules for the object files. 959-*Note Using Implicit Rules: Implicit Rules. 960- 961- When a `.c' file is used automatically in this way, it is also 962-automatically added to the list of prerequisites. We can therefore omit 963-the `.c' files from the prerequisites, provided we omit the commands. 964- 965- Here is the entire example, with both of these changes, and a 966-variable `objects' as suggested above: 967- 968- objects = main.o kbd.o command.o display.o \ 969- insert.o search.o files.o utils.o 970- 971- edit : $(objects) 972- cc -o edit $(objects) 973- 974- main.o : defs.h 975- kbd.o : defs.h command.h 976- command.o : defs.h command.h 977- display.o : defs.h buffer.h 978- insert.o : defs.h buffer.h 979- search.o : defs.h buffer.h 980- files.o : defs.h buffer.h command.h 981- utils.o : defs.h 982- 983- .PHONY : clean 984- clean : 985- rm edit $(objects) 986- 987-This is how we would write the makefile in actual practice. (The 988-complications associated with `clean' are described elsewhere. See 989-*Note Phony Targets::, and *Note Errors in Commands: Errors.) 990- 991- Because implicit rules are so convenient, they are important. You 992-will see them used frequently. 993- 994- 995-File: make.info, Node: Combine By Prerequisite, Next: Cleanup, Prev: make Deduces, Up: Introduction 996- 997-2.6 Another Style of Makefile 998-============================= 999- 1000-When the objects of a makefile are created only by implicit rules, an 1001-alternative style of makefile is possible. In this style of makefile, 1002-you group entries by their prerequisites instead of by their targets. 1003-Here is what one looks like: 1004- 1005- objects = main.o kbd.o command.o display.o \ 1006- insert.o search.o files.o utils.o 1007- 1008- edit : $(objects) 1009- cc -o edit $(objects) 1010- 1011- $(objects) : defs.h 1012- kbd.o command.o files.o : command.h 1013- display.o insert.o search.o files.o : buffer.h 1014- 1015-Here `defs.h' is given as a prerequisite of all the object files; 1016-`command.h' and `buffer.h' are prerequisites of the specific object 1017-files listed for them. 1018- 1019- Whether this is better is a matter of taste: it is more compact, but 1020-some people dislike it because they find it clearer to put all the 1021-information about each target in one place. 1022- 1023- 1024-File: make.info, Node: Cleanup, Prev: Combine By Prerequisite, Up: Introduction 1025- 1026-2.7 Rules for Cleaning the Directory 1027-==================================== 1028- 1029-Compiling a program is not the only thing you might want to write rules 1030-for. Makefiles commonly tell how to do a few other things besides 1031-compiling a program: for example, how to delete all the object files 1032-and executables so that the directory is `clean'. 1033- 1034- Here is how we could write a `make' rule for cleaning our example 1035-editor: 1036- 1037- clean: 1038- rm edit $(objects) 1039- 1040- In practice, we might want to write the rule in a somewhat more 1041-complicated manner to handle unanticipated situations. We would do 1042-this: 1043- 1044- .PHONY : clean 1045- clean : 1046- -rm edit $(objects) 1047- 1048-This prevents `make' from getting confused by an actual file called 1049-`clean' and causes it to continue in spite of errors from `rm'. (See 1050-*Note Phony Targets::, and *Note Errors in Commands: Errors.) 1051- 1052-A rule such as this should not be placed at the beginning of the 1053-makefile, because we do not want it to run by default! Thus, in the 1054-example makefile, we want the rule for `edit', which recompiles the 1055-editor, to remain the default goal. 1056- 1057- Since `clean' is not a prerequisite of `edit', this rule will not 1058-run at all if we give the command `make' with no arguments. In order 1059-to make the rule run, we have to type `make clean'. *Note How to Run 1060-`make': Running. 1061- 1062- 1063-File: make.info, Node: Makefiles, Next: Rules, Prev: Introduction, Up: Top 1064- 1065-3 Writing Makefiles 1066-******************* 1067- 1068-The information that tells `make' how to recompile a system comes from 1069-reading a data base called the "makefile". 1070- 1071-* Menu: 1072- 1073-* Makefile Contents:: What makefiles contain. 1074-* Makefile Names:: How to name your makefile. 1075-* Include:: How one makefile can use another makefile. 1076-* MAKEFILES Variable:: The environment can specify extra makefiles. 1077-* MAKEFILE_LIST Variable:: Discover which makefiles have been read. 1078-* Special Variables:: Other special variables. 1079-* Remaking Makefiles:: How makefiles get remade. 1080-* Overriding Makefiles:: How to override part of one makefile 1081- with another makefile. 1082-* Reading Makefiles:: How makefiles are parsed. 1083-* Secondary Expansion:: How and when secondary expansion is performed. 1084- 1085- 1086-File: make.info, Node: Makefile Contents, Next: Makefile Names, Prev: Makefiles, Up: Makefiles 1087- 1088-3.1 What Makefiles Contain 1089-========================== 1090- 1091-Makefiles contain five kinds of things: "explicit rules", "implicit 1092-rules", "variable definitions", "directives", and "comments". Rules, 1093-variables, and directives are described at length in later chapters. 1094- 1095- * An "explicit rule" says when and how to remake one or more files, 1096- called the rule's "targets". It lists the other files that the 1097- targets depend on, called the "prerequisites" of the target, and 1098- may also give commands to use to create or update the targets. 1099- *Note Writing Rules: Rules. 1100- 1101- * An "implicit rule" says when and how to remake a class of files 1102- based on their names. It describes how a target may depend on a 1103- file with a name similar to the target and gives commands to 1104- create or update such a target. *Note Using Implicit Rules: 1105- Implicit Rules. 1106- 1107- * A "variable definition" is a line that specifies a text string 1108- value for a variable that can be substituted into the text later. 1109- The simple makefile example shows a variable definition for 1110- `objects' as a list of all object files (*note Variables Make 1111- Makefiles Simpler: Variables Simplify.). 1112- 1113- * A "directive" is a command for `make' to do something special while 1114- reading the makefile. These include: 1115- 1116- * Reading another makefile (*note Including Other Makefiles: 1117- Include.). 1118- 1119- * Deciding (based on the values of variables) whether to use or 1120- ignore a part of the makefile (*note Conditional Parts of 1121- Makefiles: Conditionals.). 1122- 1123- * Defining a variable from a verbatim string containing 1124- multiple lines (*note Defining Variables Verbatim: Defining.). 1125- 1126- * `#' in a line of a makefile starts a "comment". It and the rest 1127- of the line are ignored, except that a trailing backslash not 1128- escaped by another backslash will continue the comment across 1129- multiple lines. A line containing just a comment (with perhaps 1130- spaces before it) is effectively blank, and is ignored. If you 1131- want a literal `#', escape it with a backslash (e.g., `\#'). 1132- Comments may appear on any line in the makefile, although they are 1133- treated specially in certain situations. 1134- 1135- Within a command script (if the line begins with a TAB character) 1136- the entire line is passed to the shell, just as with any other 1137- line that begins with a TAB. The shell decides how to interpret 1138- the text: whether or not this is a comment is up to the shell. 1139- 1140- Within a `define' directive, comments are not ignored during the 1141- definition of the variable, but rather kept intact in the value of 1142- the variable. When the variable is expanded they will either be 1143- treated as `make' comments or as command script text, depending on 1144- the context in which the variable is evaluated. 1145- 1146- 1147-File: make.info, Node: Makefile Names, Next: Include, Prev: Makefile Contents, Up: Makefiles 1148- 1149-3.2 What Name to Give Your Makefile 1150-=================================== 1151- 1152-By default, when `make' looks for the makefile, it tries the following 1153-names, in order: `GNUmakefile', `makefile' and `Makefile'. 1154- 1155- Normally you should call your makefile either `makefile' or 1156-`Makefile'. (We recommend `Makefile' because it appears prominently 1157-near the beginning of a directory listing, right near other important 1158-files such as `README'.) The first name checked, `GNUmakefile', is not 1159-recommended for most makefiles. You should use this name if you have a 1160-makefile that is specific to GNU `make', and will not be understood by 1161-other versions of `make'. Other `make' programs look for `makefile' and 1162-`Makefile', but not `GNUmakefile'. 1163- 1164- If `make' finds none of these names, it does not use any makefile. 1165-Then you must specify a goal with a command argument, and `make' will 1166-attempt to figure out how to remake it using only its built-in implicit 1167-rules. *Note Using Implicit Rules: Implicit Rules. 1168- 1169- If you want to use a nonstandard name for your makefile, you can 1170-specify the makefile name with the `-f' or `--file' option. The 1171-arguments `-f NAME' or `--file=NAME' tell `make' to read the file NAME 1172-as the makefile. If you use more than one `-f' or `--file' option, you 1173-can specify several makefiles. All the makefiles are effectively 1174-concatenated in the order specified. The default makefile names 1175-`GNUmakefile', `makefile' and `Makefile' are not checked automatically 1176-if you specify `-f' or `--file'. 1177- 1178- 1179-File: make.info, Node: Include, Next: MAKEFILES Variable, Prev: Makefile Names, Up: Makefiles 1180- 1181-3.3 Including Other Makefiles 1182-============================= 1183- 1184-The `include' directive tells `make' to suspend reading the current 1185-makefile and read one or more other makefiles before continuing. The 1186-directive is a line in the makefile that looks like this: 1187- 1188- include FILENAMES... 1189- 1190-FILENAMES can contain shell file name patterns. If FILENAMES is empty, 1191-nothing is included and no error is printed. 1192- 1193- Extra spaces are allowed and ignored at the beginning of the line, 1194-but a tab is not allowed. (If the line begins with a tab, it will be 1195-considered a command line.) Whitespace is required between `include' 1196-and the file names, and between file names; extra whitespace is ignored 1197-there and at the end of the directive. A comment starting with `#' is 1198-allowed at the end of the line. If the file names contain any variable 1199-or function references, they are expanded. *Note How to Use Variables: 1200-Using Variables. 1201- 1202- For example, if you have three `.mk' files, `a.mk', `b.mk', and 1203-`c.mk', and `$(bar)' expands to `bish bash', then the following 1204-expression 1205- 1206- include foo *.mk $(bar) 1207- 1208- is equivalent to 1209- 1210- include foo a.mk b.mk c.mk bish bash 1211- 1212- When `make' processes an `include' directive, it suspends reading of 1213-the containing makefile and reads from each listed file in turn. When 1214-that is finished, `make' resumes reading the makefile in which the 1215-directive appears. 1216- 1217- One occasion for using `include' directives is when several programs, 1218-handled by individual makefiles in various directories, need to use a 1219-common set of variable definitions (*note Setting Variables: Setting.) 1220-or pattern rules (*note Defining and Redefining Pattern Rules: Pattern 1221-Rules.). 1222- 1223- Another such occasion is when you want to generate prerequisites from 1224-source files automatically; the prerequisites can be put in a file that 1225-is included by the main makefile. This practice is generally cleaner 1226-than that of somehow appending the prerequisites to the end of the main 1227-makefile as has been traditionally done with other versions of `make'. 1228-*Note Automatic Prerequisites::. 1229- 1230- If the specified name does not start with a slash, and the file is 1231-not found in the current directory, several other directories are 1232-searched. First, any directories you have specified with the `-I' or 1233-`--include-dir' option are searched (*note Summary of Options: Options 1234-Summary.). Then the following directories (if they exist) are 1235-searched, in this order: `PREFIX/include' (normally `/usr/local/include' 1236-(1)) `/usr/gnu/include', `/usr/local/include', `/usr/include'. 1237- 1238- If an included makefile cannot be found in any of these directories, 1239-a warning message is generated, but it is not an immediately fatal 1240-error; processing of the makefile containing the `include' continues. 1241-Once it has finished reading makefiles, `make' will try to remake any 1242-that are out of date or don't exist. *Note How Makefiles Are Remade: 1243-Remaking Makefiles. Only after it has tried to find a way to remake a 1244-makefile and failed, will `make' diagnose the missing makefile as a 1245-fatal error. 1246- 1247- If you want `make' to simply ignore a makefile which does not exist 1248-and cannot be remade, with no error message, use the `-include' 1249-directive instead of `include', like this: 1250- 1251- -include FILENAMES... 1252- 1253- This acts like `include' in every way except that there is no error 1254-(not even a warning) if any of the FILENAMES do not exist. For 1255-compatibility with some other `make' implementations, `sinclude' is 1256-another name for `-include'. 1257- 1258- ---------- Footnotes ---------- 1259- 1260- (1) GNU Make compiled for MS-DOS and MS-Windows behaves as if PREFIX 1261-has been defined to be the root of the DJGPP tree hierarchy. 1262- 1263- 1264-File: make.info, Node: MAKEFILES Variable, Next: MAKEFILE_LIST Variable, Prev: Include, Up: Makefiles 1265- 1266-3.4 The Variable `MAKEFILES' 1267-============================ 1268- 1269-If the environment variable `MAKEFILES' is defined, `make' considers 1270-its value as a list of names (separated by whitespace) of additional 1271-makefiles to be read before the others. This works much like the 1272-`include' directive: various directories are searched for those files 1273-(*note Including Other Makefiles: Include.). In addition, the default 1274-goal is never taken from one of these makefiles and it is not an error 1275-if the files listed in `MAKEFILES' are not found. 1276- 1277- The main use of `MAKEFILES' is in communication between recursive 1278-invocations of `make' (*note Recursive Use of `make': Recursion.). It 1279-usually is not desirable to set the environment variable before a 1280-top-level invocation of `make', because it is usually better not to 1281-mess with a makefile from outside. However, if you are running `make' 1282-without a specific makefile, a makefile in `MAKEFILES' can do useful 1283-things to help the built-in implicit rules work better, such as 1284-defining search paths (*note Directory Search::). 1285- 1286- Some users are tempted to set `MAKEFILES' in the environment 1287-automatically on login, and program makefiles to expect this to be done. 1288-This is a very bad idea, because such makefiles will fail to work if 1289-run by anyone else. It is much better to write explicit `include' 1290-directives in the makefiles. *Note Including Other Makefiles: Include. 1291- 1292- 1293-File: make.info, Node: MAKEFILE_LIST Variable, Next: Special Variables, Prev: MAKEFILES Variable, Up: Makefiles 1294- 1295-3.5 The Variable `MAKEFILE_LIST' 1296-================================ 1297- 1298-As `make' reads various makefiles, including any obtained from the 1299-`MAKEFILES' variable, the command line, the default files, or from 1300-`include' directives, their names will be automatically appended to the 1301-`MAKEFILE_LIST' variable. They are added right before `make' begins to 1302-parse them. 1303- 1304- This means that if the first thing a makefile does is examine the 1305-last word in this variable, it will be the name of the current makefile. 1306-Once the current makefile has used `include', however, the last word 1307-will be the just-included makefile. 1308- 1309- If a makefile named `Makefile' has this content: 1310- 1311- name1 := $(lastword $(MAKEFILE_LIST)) 1312- 1313- include inc.mk 1314- 1315- name2 := $(lastword $(MAKEFILE_LIST)) 1316- 1317- all: 1318- @echo name1 = $(name1) 1319- @echo name2 = $(name2) 1320- 1321-then you would expect to see this output: 1322- 1323- name1 = Makefile 1324- name2 = inc.mk 1325- 1326- *Note Text Functions::, for more information on the `word' and 1327-`words' functions used above. *Note The Two Flavors of Variables: 1328-Flavors, for more information on simply-expanded (`:=') variable 1329-definitions. 1330- 1331- 1332-File: make.info, Node: Special Variables, Next: Remaking Makefiles, Prev: MAKEFILE_LIST Variable, Up: Makefiles 1333- 1334-3.6 Other Special Variables 1335-=========================== 1336- 1337-GNU `make' also supports other special variables. Unless otherwise 1338-documented here, these values lose their special properties if they are 1339-set by a makefile or on the command line. 1340- 1341-`.DEFAULT_GOAL' 1342- Sets the default goal to be used if no targets were specified on 1343- the command line (*note Arguments to Specify the Goals: Goals.). 1344- The `.DEFAULT_GOAL' variable allows you to discover the current 1345- default goal, restart the default goal selection algorithm by 1346- clearing its value, or to explicitly set the default goal. The 1347- following example illustrates these cases: 1348- 1349- # Query the default goal. 1350- ifeq ($(.DEFAULT_GOAL),) 1351- $(warning no default goal is set) 1352- endif 1353- 1354- .PHONY: foo 1355- foo: ; @echo $@ 1356- 1357- $(warning default goal is $(.DEFAULT_GOAL)) 1358- 1359- # Reset the default goal. 1360- .DEFAULT_GOAL := 1361- 1362- .PHONY: bar 1363- bar: ; @echo $@ 1364- 1365- $(warning default goal is $(.DEFAULT_GOAL)) 1366- 1367- # Set our own. 1368- .DEFAULT_GOAL := foo 1369- 1370- This makefile prints: 1371- 1372- no default goal is set 1373- default goal is foo 1374- default goal is bar 1375- foo 1376- 1377- Note that assigning more than one target name to `.DEFAULT_GOAL' is 1378- illegal and will result in an error. 1379- 1380-`MAKE_RESTARTS' 1381- This variable is set only if this instance of `make' has restarted 1382- (*note How Makefiles Are Remade: Remaking Makefiles.): it will 1383- contain the number of times this instance has restarted. Note 1384- this is not the same as recursion (counted by the `MAKELEVEL' 1385- variable). You should not set, modify, or export this variable. 1386- 1387-`.VARIABLES' 1388- Expands to a list of the _names_ of all global variables defined 1389- so far. This includes variables which have empty values, as well 1390- as built-in variables (*note Variables Used by Implicit Rules: 1391- Implicit Variables.), but does not include any variables which are 1392- only defined in a target-specific context. Note that any value 1393- you assign to this variable will be ignored; it will always return 1394- its special value. 1395- 1396-`.FEATURES' 1397- Expands to a list of special features supported by this version of 1398- `make'. Possible values include: 1399- 1400- `archives' 1401- Supports `ar' (archive) files using special filename syntax. 1402- *Note Using `make' to Update Archive Files: Archives. 1403- 1404- `check-symlink' 1405- Supports the `-L' (`--check-symlink-times') flag. *Note 1406- Summary of Options: Options Summary. 1407- 1408- `else-if' 1409- Supports "else if" non-nested conditionals. *Note Syntax of 1410- Conditionals: Conditional Syntax. 1411- 1412- `jobserver' 1413- Supports "job server" enhanced parallel builds. *Note 1414- Parallel Execution: Parallel. 1415- 1416- `second-expansion' 1417- Supports secondary expansion of prerequisite lists. 1418- 1419- `order-only' 1420- Supports order-only prerequisites. *Note Types of 1421- Prerequisites: Prerequisite Types. 1422- 1423- `target-specific' 1424- Supports target-specific and pattern-specific variable 1425- assignments. *Note Target-specific Variable Values: 1426- Target-specific. 1427- 1428- 1429-`.INCLUDE_DIRS' 1430- Expands to a list of directories that `make' searches for included 1431- makefiles (*note Including Other Makefiles: Include.). 1432- 1433- 1434- 1435-File: make.info, Node: Remaking Makefiles, Next: Overriding Makefiles, Prev: Special Variables, Up: Makefiles 1436- 1437-3.7 How Makefiles Are Remade 1438-============================ 1439- 1440-Sometimes makefiles can be remade from other files, such as RCS or SCCS 1441-files. If a makefile can be remade from other files, you probably want 1442-`make' to get an up-to-date version of the makefile to read in. 1443- 1444- To this end, after reading in all makefiles, `make' will consider 1445-each as a goal target and attempt to update it. If a makefile has a 1446-rule which says how to update it (found either in that very makefile or 1447-in another one) or if an implicit rule applies to it (*note Using 1448-Implicit Rules: Implicit Rules.), it will be updated if necessary. 1449-After all makefiles have been checked, if any have actually been 1450-changed, `make' starts with a clean slate and reads all the makefiles 1451-over again. (It will also attempt to update each of them over again, 1452-but normally this will not change them again, since they are already up 1453-to date.) 1454- 1455- If you know that one or more of your makefiles cannot be remade and 1456-you want to keep `make' from performing an implicit rule search on 1457-them, perhaps for efficiency reasons, you can use any normal method of 1458-preventing implicit rule lookup to do so. For example, you can write an 1459-explicit rule with the makefile as the target, and an empty command 1460-string (*note Using Empty Commands: Empty Commands.). 1461- 1462- If the makefiles specify a double-colon rule to remake a file with 1463-commands but no prerequisites, that file will always be remade (*note 1464-Double-Colon::). In the case of makefiles, a makefile that has a 1465-double-colon rule with commands but no prerequisites will be remade 1466-every time `make' is run, and then again after `make' starts over and 1467-reads the makefiles in again. This would cause an infinite loop: 1468-`make' would constantly remake the makefile, and never do anything 1469-else. So, to avoid this, `make' will *not* attempt to remake makefiles 1470-which are specified as targets of a double-colon rule with commands but 1471-no prerequisites. 1472- 1473- If you do not specify any makefiles to be read with `-f' or `--file' 1474-options, `make' will try the default makefile names; *note What Name to 1475-Give Your Makefile: Makefile Names. Unlike makefiles explicitly 1476-requested with `-f' or `--file' options, `make' is not certain that 1477-these makefiles should exist. However, if a default makefile does not 1478-exist but can be created by running `make' rules, you probably want the 1479-rules to be run so that the makefile can be used. 1480- 1481- Therefore, if none of the default makefiles exists, `make' will try 1482-to make each of them in the same order in which they are searched for 1483-(*note What Name to Give Your Makefile: Makefile Names.) until it 1484-succeeds in making one, or it runs out of names to try. Note that it 1485-is not an error if `make' cannot find or make any makefile; a makefile 1486-is not always necessary. 1487- 1488- When you use the `-t' or `--touch' option (*note Instead of 1489-Executing the Commands: Instead of Execution.), you would not want to 1490-use an out-of-date makefile to decide which targets to touch. So the 1491-`-t' option has no effect on updating makefiles; they are really 1492-updated even if `-t' is specified. Likewise, `-q' (or `--question') 1493-and `-n' (or `--just-print') do not prevent updating of makefiles, 1494-because an out-of-date makefile would result in the wrong output for 1495-other targets. Thus, `make -f mfile -n foo' will update `mfile', read 1496-it in, and then print the commands to update `foo' and its prerequisites 1497-without running them. The commands printed for `foo' will be those 1498-specified in the updated contents of `mfile'. 1499- 1500- However, on occasion you might actually wish to prevent updating of 1501-even the makefiles. You can do this by specifying the makefiles as 1502-goals in the command line as well as specifying them as makefiles. 1503-When the makefile name is specified explicitly as a goal, the options 1504-`-t' and so on do apply to them. 1505- 1506- Thus, `make -f mfile -n mfile foo' would read the makefile `mfile', 1507-print the commands needed to update it without actually running them, 1508-and then print the commands needed to update `foo' without running 1509-them. The commands for `foo' will be those specified by the existing 1510-contents of `mfile'. 1511- 1512- 1513-File: make.info, Node: Overriding Makefiles, Next: Reading Makefiles, Prev: Remaking Makefiles, Up: Makefiles 1514- 1515-3.8 Overriding Part of Another Makefile 1516-======================================= 1517- 1518-Sometimes it is useful to have a makefile that is mostly just like 1519-another makefile. You can often use the `include' directive to include 1520-one in the other, and add more targets or variable definitions. 1521-However, if the two makefiles give different commands for the same 1522-target, `make' will not let you just do this. But there is another way. 1523- 1524- In the containing makefile (the one that wants to include the other), 1525-you can use a match-anything pattern rule to say that to remake any 1526-target that cannot be made from the information in the containing 1527-makefile, `make' should look in another makefile. *Note Pattern 1528-Rules::, for more information on pattern rules. 1529- 1530- For example, if you have a makefile called `Makefile' that says how 1531-to make the target `foo' (and other targets), you can write a makefile 1532-called `GNUmakefile' that contains: 1533- 1534- foo: 1535- frobnicate > foo 1536- 1537- %: force 1538- @$(MAKE) -f Makefile $@ 1539- force: ; 1540- 1541- If you say `make foo', `make' will find `GNUmakefile', read it, and 1542-see that to make `foo', it needs to run the command `frobnicate > foo'. 1543-If you say `make bar', `make' will find no way to make `bar' in 1544-`GNUmakefile', so it will use the commands from the pattern rule: `make 1545--f Makefile bar'. If `Makefile' provides a rule for updating `bar', 1546-`make' will apply the rule. And likewise for any other target that 1547-`GNUmakefile' does not say how to make. 1548- 1549- The way this works is that the pattern rule has a pattern of just 1550-`%', so it matches any target whatever. The rule specifies a 1551-prerequisite `force', to guarantee that the commands will be run even 1552-if the target file already exists. We give `force' target empty 1553-commands to prevent `make' from searching for an implicit rule to build 1554-it--otherwise it would apply the same match-anything rule to `force' 1555-itself and create a prerequisite loop! 1556- 1557- 1558-File: make.info, Node: Reading Makefiles, Next: Secondary Expansion, Prev: Overriding Makefiles, Up: Makefiles 1559- 1560-3.9 How `make' Reads a Makefile 1561-=============================== 1562- 1563-GNU `make' does its work in two distinct phases. During the first 1564-phase it reads all the makefiles, included makefiles, etc. and 1565-internalizes all the variables and their values, implicit and explicit 1566-rules, and constructs a dependency graph of all the targets and their 1567-prerequisites. During the second phase, `make' uses these internal 1568-structures to determine what targets will need to be rebuilt and to 1569-invoke the rules necessary to do so. 1570- 1571- It's important to understand this two-phase approach because it has a 1572-direct impact on how variable and function expansion happens; this is 1573-often a source of some confusion when writing makefiles. Here we will 1574-present a summary of the phases in which expansion happens for different 1575-constructs within the makefile. We say that expansion is "immediate" 1576-if it happens during the first phase: in this case `make' will expand 1577-any variables or functions in that section of a construct as the 1578-makefile is parsed. We say that expansion is "deferred" if expansion 1579-is not performed immediately. Expansion of deferred construct is not 1580-performed until either the construct appears later in an immediate 1581-context, or until the second phase. 1582- 1583- You may not be familiar with some of these constructs yet. You can 1584-reference this section as you become familiar with them, in later 1585-chapters. 1586- 1587-Variable Assignment 1588-------------------- 1589- 1590-Variable definitions are parsed as follows: 1591- 1592- IMMEDIATE = DEFERRED 1593- IMMEDIATE ?= DEFERRED 1594- IMMEDIATE := IMMEDIATE 1595- IMMEDIATE += DEFERRED or IMMEDIATE 1596- 1597- define IMMEDIATE 1598- DEFERRED 1599- endef 1600- 1601- For the append operator, `+=', the right-hand side is considered 1602-immediate if the variable was previously set as a simple variable 1603-(`:='), and deferred otherwise. 1604- 1605-Conditional Statements 1606----------------------- 1607- 1608-All instances of conditional syntax are parsed immediately, in their 1609-entirety; this includes the `ifdef', `ifeq', `ifndef', and `ifneq' 1610-forms. Of course this means that automatic variables cannot be used in 1611-conditional statements, as automatic variables are not set until the 1612-command script for that rule is invoked. If you need to use automatic 1613-variables in a conditional you _must_ use shell conditional syntax, in 1614-your command script proper, for these tests, not `make' conditionals. 1615- 1616-Rule Definition 1617---------------- 1618- 1619-A rule is always expanded the same way, regardless of the form: 1620- 1621- IMMEDIATE : IMMEDIATE ; DEFERRED 1622- DEFERRED 1623- 1624- That is, the target and prerequisite sections are expanded 1625-immediately, and the commands used to construct the target are always 1626-deferred. This general rule is true for explicit rules, pattern rules, 1627-suffix rules, static pattern rules, and simple prerequisite definitions. 1628- 1629- 1630-File: make.info, Node: Secondary Expansion, Prev: Reading Makefiles, Up: Makefiles 1631- 1632-3.10 Secondary Expansion 1633-======================== 1634- 1635-In the previous section we learned that GNU `make' works in two 1636-distinct phases: a read-in phase and a target-update phase (*note How 1637-`make' Reads a Makefile: Reading Makefiles.). GNU make also has the 1638-ability to enable a _second expansion_ of the prerequisites (only) for 1639-some or all targets defined in the makefile. In order for this second 1640-expansion to occur, the special target `.SECONDEXPANSION' must be 1641-defined before the first prerequisite list that makes use of this 1642-feature. 1643- 1644- If that special target is defined then in between the two phases 1645-mentioned above, right at the end of the read-in phase, all the 1646-prerequisites of the targets defined after the special target are 1647-expanded a _second time_. In most circumstances this secondary 1648-expansion will have no effect, since all variable and function 1649-references will have been expanded during the initial parsing of the 1650-makefiles. In order to take advantage of the secondary expansion phase 1651-of the parser, then, it's necessary to _escape_ the variable or 1652-function reference in the makefile. In this case the first expansion 1653-merely un-escapes the reference but doesn't expand it, and expansion is 1654-left to the secondary expansion phase. For example, consider this 1655-makefile: 1656- 1657- .SECONDEXPANSION: 1658- ONEVAR = onefile 1659- TWOVAR = twofile 1660- myfile: $(ONEVAR) $$(TWOVAR) 1661- 1662- After the first expansion phase the prerequisites list of the 1663-`myfile' target will be `onefile' and `$(TWOVAR)'; the first 1664-(unescaped) variable reference to ONEVAR is expanded, while the second 1665-(escaped) variable reference is simply unescaped, without being 1666-recognized as a variable reference. Now during the secondary expansion 1667-the first word is expanded again but since it contains no variable or 1668-function references it remains the static value `onefile', while the 1669-second word is now a normal reference to the variable TWOVAR, which is 1670-expanded to the value `twofile'. The final result is that there are 1671-two prerequisites, `onefile' and `twofile'. 1672- 1673- Obviously, this is not a very interesting case since the same result 1674-could more easily have been achieved simply by having both variables 1675-appear, unescaped, in the prerequisites list. One difference becomes 1676-apparent if the variables are reset; consider this example: 1677- 1678- .SECONDEXPANSION: 1679- AVAR = top 1680- onefile: $(AVAR) 1681- twofile: $$(AVAR) 1682- AVAR = bottom 1683- 1684- Here the prerequisite of `onefile' will be expanded immediately, and 1685-resolve to the value `top', while the prerequisite of `twofile' will 1686-not be full expanded until the secondary expansion and yield a value of 1687-`bottom'. 1688- 1689- This is marginally more exciting, but the true power of this feature 1690-only becomes apparent when you discover that secondary expansions 1691-always take place within the scope of the automatic variables for that 1692-target. This means that you can use variables such as `$@', `$*', etc. 1693-during the second expansion and they will have their expected values, 1694-just as in the command script. All you have to do is defer the 1695-expansion by escaping the `$'. Also, secondary expansion occurs for 1696-both explicit and implicit (pattern) rules. Knowing this, the possible 1697-uses for this feature increase dramatically. For example: 1698- 1699- .SECONDEXPANSION: 1700- main_OBJS := main.o try.o test.o 1701- lib_OBJS := lib.o api.o 1702- 1703- main lib: $$($$@_OBJS) 1704- 1705- Here, after the initial expansion the prerequisites of both the 1706-`main' and `lib' targets will be `$($@_OBJS)'. During the secondary 1707-expansion, the `$@' variable is set to the name of the target and so 1708-the expansion for the `main' target will yield `$(main_OBJS)', or 1709-`main.o try.o test.o', while the secondary expansion for the `lib' 1710-target will yield `$(lib_OBJS)', or `lib.o api.o'. 1711- 1712- You can also mix functions here, as long as they are properly 1713-escaped: 1714- 1715- main_SRCS := main.c try.c test.c 1716- lib_SRCS := lib.c api.c 1717- 1718- .SECONDEXPANSION: 1719- main lib: $$(patsubst %.c,%.o,$$($$@_SRCS)) 1720- 1721- This version allows users to specify source files rather than object 1722-files, but gives the same resulting prerequisites list as the previous 1723-example. 1724- 1725- Evaluation of automatic variables during the secondary expansion 1726-phase, especially of the target name variable `$$@', behaves similarly 1727-to evaluation within command scripts. However, there are some subtle 1728-differences and "corner cases" which come into play for the different 1729-types of rule definitions that `make' understands. The subtleties of 1730-using the different automatic variables are described below. 1731- 1732-Secondary Expansion of Explicit Rules 1733-------------------------------------- 1734- 1735-During the secondary expansion of explicit rules, `$$@' and `$$%' 1736-evaluate, respectively, to the file name of the target and, when the 1737-target is an archive member, the target member name. The `$$<' 1738-variable evaluates to the first prerequisite in the first rule for this 1739-target. `$$^' and `$$+' evaluate to the list of all prerequisites of 1740-rules _that have already appeared_ for the same target (`$$+' with 1741-repetitions and `$$^' without). The following example will help 1742-illustrate these behaviors: 1743- 1744- .SECONDEXPANSION: 1745- 1746- foo: foo.1 bar.1 $$< $$^ $$+ # line #1 1747- 1748- foo: foo.2 bar.2 $$< $$^ $$+ # line #2 1749- 1750- foo: foo.3 bar.3 $$< $$^ $$+ # line #3 1751- 1752- In the first prerequisite list, all three variables (`$$<', `$$^', 1753-and `$$+') expand to the empty string. In the second, they will have 1754-values `foo.1', `foo.1 bar.1', and `foo.1 bar.1' respectively. In the 1755-third they will have values `foo.1', `foo.1 bar.1 foo.2 bar.2', and 1756-`foo.1 bar.1 foo.2 bar.2' respectively. 1757- 1758- Rules undergo secondary expansion in makefile order, except that the 1759-rule with the command script is always evaluated last. 1760- 1761- The variables `$$?' and `$$*' are not available and expand to the 1762-empty string. 1763- 1764-Secondary Expansion of Static Pattern Rules 1765-------------------------------------------- 1766- 1767-Rules for secondary expansion of static pattern rules are identical to 1768-those for explicit rules, above, with one exception: for static pattern 1769-rules the `$$*' variable is set to the pattern stem. As with explicit 1770-rules, `$$?' is not available and expands to the empty string. 1771- 1772-Secondary Expansion of Implicit Rules 1773-------------------------------------- 1774- 1775-As `make' searches for an implicit rule, it substitutes the stem and 1776-then performs secondary expansion for every rule with a matching target 1777-pattern. The value of the automatic variables is derived in the same 1778-fashion as for static pattern rules. As an example: 1779- 1780- .SECONDEXPANSION: 1781- 1782- foo: bar 1783- 1784- foo foz: fo%: bo% 1785- 1786- %oo: $$< $$^ $$+ $$* 1787- 1788- When the implicit rule is tried for target `foo', `$$<' expands to 1789-`bar', `$$^' expands to `bar boo', `$$+' also expands to `bar boo', and 1790-`$$*' expands to `f'. 1791- 1792- Note that the directory prefix (D), as described in *Note Implicit 1793-Rule Search Algorithm: Implicit Rule Search, is appended (after 1794-expansion) to all the patterns in the prerequisites list. As an 1795-example: 1796- 1797- .SECONDEXPANSION: 1798- 1799- /tmp/foo.o: 1800- 1801- %.o: $$(addsuffix /%.c,foo bar) foo.h 1802- 1803- The prerequisite list after the secondary expansion and directory 1804-prefix reconstruction will be `/tmp/foo/foo.c /tmp/var/bar/foo.c 1805-foo.h'. If you are not interested in this reconstruction, you can use 1806-`$$*' instead of `%' in the prerequisites list. 1807- 1808- 1809-File: make.info, Node: Rules, Next: Commands, Prev: Makefiles, Up: Top 1810- 1811-4 Writing Rules 1812-*************** 1813- 1814-A "rule" appears in the makefile and says when and how to remake 1815-certain files, called the rule's "targets" (most often only one per 1816-rule). It lists the other files that are the "prerequisites" of the 1817-target, and "commands" to use to create or update the target. 1818- 1819- The order of rules is not significant, except for determining the 1820-"default goal": the target for `make' to consider, if you do not 1821-otherwise specify one. The default goal is the target of the first 1822-rule in the first makefile. If the first rule has multiple targets, 1823-only the first target is taken as the default. There are two 1824-exceptions: a target starting with a period is not a default unless it 1825-contains one or more slashes, `/', as well; and, a target that defines 1826-a pattern rule has no effect on the default goal. (*Note Defining and 1827-Redefining Pattern Rules: Pattern Rules.) 1828- 1829- Therefore, we usually write the makefile so that the first rule is 1830-the one for compiling the entire program or all the programs described 1831-by the makefile (often with a target called `all'). *Note Arguments to 1832-Specify the Goals: Goals. 1833- 1834-* Menu: 1835- 1836-* Rule Example:: An example explained. 1837-* Rule Syntax:: General syntax explained. 1838-* Prerequisite Types:: There are two types of prerequisites. 1839-* Wildcards:: Using wildcard characters such as `*'. 1840-* Directory Search:: Searching other directories for source files. 1841-* Phony Targets:: Using a target that is not a real file's name. 1842-* Force Targets:: You can use a target without commands 1843- or prerequisites to mark other targets 1844- as phony. 1845-* Empty Targets:: When only the date matters and the 1846- files are empty. 1847-* Special Targets:: Targets with special built-in meanings. 1848-* Multiple Targets:: When to make use of several targets in a rule. 1849-* Multiple Rules:: How to use several rules with the same target. 1850-* Static Pattern:: Static pattern rules apply to multiple targets 1851- and can vary the prerequisites according to 1852- the target name. 1853-* Double-Colon:: How to use a special kind of rule to allow 1854- several independent rules for one target. 1855-* Automatic Prerequisites:: How to automatically generate rules giving 1856- prerequisites from source files themselves. 1857- 1858- 1859-File: make.info, Node: Rule Example, Next: Rule Syntax, Prev: Rules, Up: Rules 1860- 1861-4.1 Rule Example 1862-================ 1863- 1864-Here is an example of a rule: 1865- 1866- foo.o : foo.c defs.h # module for twiddling the frobs 1867- cc -c -g foo.c 1868- 1869- Its target is `foo.o' and its prerequisites are `foo.c' and 1870-`defs.h'. It has one command, which is `cc -c -g foo.c'. The command 1871-line starts with a tab to identify it as a command. 1872- 1873- This rule says two things: 1874- 1875- * How to decide whether `foo.o' is out of date: it is out of date if 1876- it does not exist, or if either `foo.c' or `defs.h' is more recent 1877- than it. 1878- 1879- * How to update the file `foo.o': by running `cc' as stated. The 1880- command does not explicitly mention `defs.h', but we presume that 1881- `foo.c' includes it, and that that is why `defs.h' was added to 1882- the prerequisites. 1883- 1884- 1885-File: make.info, Node: Rule Syntax, Next: Prerequisite Types, Prev: Rule Example, Up: Rules 1886- 1887-4.2 Rule Syntax 1888-=============== 1889- 1890-In general, a rule looks like this: 1891- 1892- TARGETS : PREREQUISITES 1893- COMMAND 1894- ... 1895- 1896-or like this: 1897- 1898- TARGETS : PREREQUISITES ; COMMAND 1899- COMMAND 1900- ... 1901- 1902- The TARGETS are file names, separated by spaces. Wildcard 1903-characters may be used (*note Using Wildcard Characters in File Names: 1904-Wildcards.) and a name of the form `A(M)' represents member M in 1905-archive file A (*note Archive Members as Targets: Archive Members.). 1906-Usually there is only one target per rule, but occasionally there is a 1907-reason to have more (*note Multiple Targets in a Rule: Multiple 1908-Targets.). 1909- 1910- The COMMAND lines start with a tab character. The first command may 1911-appear on the line after the prerequisites, with a tab character, or may 1912-appear on the same line, with a semicolon. Either way, the effect is 1913-the same. There are other differences in the syntax of command lines. 1914-*Note Writing the Commands in Rules: Commands. 1915- 1916- Because dollar signs are used to start `make' variable references, 1917-if you really want a dollar sign in a target or prerequisite you must 1918-write two of them, `$$' (*note How to Use Variables: Using Variables.). 1919-If you have enabled secondary expansion (*note Secondary Expansion::) 1920-and you want a literal dollar sign in the prerequisites lise, you must 1921-actually write _four_ dollar signs (`$$$$'). 1922- 1923- You may split a long line by inserting a backslash followed by a 1924-newline, but this is not required, as `make' places no limit on the 1925-length of a line in a makefile. 1926- 1927- A rule tells `make' two things: when the targets are out of date, 1928-and how to update them when necessary. 1929- 1930- The criterion for being out of date is specified in terms of the 1931-PREREQUISITES, which consist of file names separated by spaces. 1932-(Wildcards and archive members (*note Archives::) are allowed here too.) 1933-A target is out of date if it does not exist or if it is older than any 1934-of the prerequisites (by comparison of last-modification times). The 1935-idea is that the contents of the target file are computed based on 1936-information in the prerequisites, so if any of the prerequisites 1937-changes, the contents of the existing target file are no longer 1938-necessarily valid. 1939- 1940- How to update is specified by COMMANDS. These are lines to be 1941-executed by the shell (normally `sh'), but with some extra features 1942-(*note Writing the Commands in Rules: Commands.). 1943- 1944- 1945-File: make.info, Node: Prerequisite Types, Next: Wildcards, Prev: Rule Syntax, Up: Rules 1946- 1947-4.3 Types of Prerequisites 1948-========================== 1949- 1950-There are actually two different types of prerequisites understood by 1951-GNU `make': normal prerequisites such as described in the previous 1952-section, and "order-only" prerequisites. A normal prerequisite makes 1953-two statements: first, it imposes an order of execution of build 1954-commands: any commands necessary to build any of a target's 1955-prerequisites will be fully executed before any commands necessary to 1956-build the target. Second, it imposes a dependency relationship: if any 1957-prerequisite is newer than the target, then the target is considered 1958-out-of-date and must be rebuilt. 1959- 1960- Normally, this is exactly what you want: if a target's prerequisite 1961-is updated, then the target should also be updated. 1962- 1963- Occasionally, however, you have a situation where you want to impose 1964-a specific ordering on the rules to be invoked _without_ forcing the 1965-target to be updated if one of those rules is executed. In that case, 1966-you want to define "order-only" prerequisites. Order-only 1967-prerequisites can be specified by placing a pipe symbol (`|') in the 1968-prerequisites list: any prerequisites to the left of the pipe symbol 1969-are normal; any prerequisites to the right are order-only: 1970- 1971- TARGETS : NORMAL-PREREQUISITES | ORDER-ONLY-PREREQUISITES 1972- 1973- The normal prerequisites section may of course be empty. Also, you 1974-may still declare multiple lines of prerequisites for the same target: 1975-they are appended appropriately. Note that if you declare the same 1976-file to be both a normal and an order-only prerequisite, the normal 1977-prerequisite takes precedence (since they are a strict superset of the 1978-behavior of an order-only prerequisite). 1979- 1980- 1981-File: make.info, Node: Wildcards, Next: Directory Search, Prev: Prerequisite Types, Up: Rules 1982- 1983-4.4 Using Wildcard Characters in File Names 1984-=========================================== 1985- 1986-A single file name can specify many files using "wildcard characters". 1987-The wildcard characters in `make' are `*', `?' and `[...]', the same as 1988-in the Bourne shell. For example, `*.c' specifies a list of all the 1989-files (in the working directory) whose names end in `.c'. 1990- 1991- The character `~' at the beginning of a file name also has special 1992-significance. If alone, or followed by a slash, it represents your home 1993-directory. For example `~/bin' expands to `/home/you/bin'. If the `~' 1994-is followed by a word, the string represents the home directory of the 1995-user named by that word. For example `~john/bin' expands to 1996-`/home/john/bin'. On systems which don't have a home directory for 1997-each user (such as MS-DOS or MS-Windows), this functionality can be 1998-simulated by setting the environment variable HOME. 1999- 2000- Wildcard expansion is performed by `make' automatically in targets 2001-and in prerequisites. In commands the shell is responsible for 2002-wildcard expansion. In other contexts, wildcard expansion happens only 2003-if you request it explicitly with the `wildcard' function. 2004- 2005- The special significance of a wildcard character can be turned off by 2006-preceding it with a backslash. Thus, `foo\*bar' would refer to a 2007-specific file whose name consists of `foo', an asterisk, and `bar'. 2008- 2009-* Menu: 2010- 2011-* Wildcard Examples:: Several examples 2012-* Wildcard Pitfall:: Problems to avoid. 2013-* Wildcard Function:: How to cause wildcard expansion where 2014- it does not normally take place. 2015- 2016- 2017-File: make.info, Node: Wildcard Examples, Next: Wildcard Pitfall, Prev: Wildcards, Up: Wildcards 2018- 2019-4.4.1 Wildcard Examples 2020------------------------ 2021- 2022-Wildcards can be used in the commands of a rule, where they are expanded 2023-by the shell. For example, here is a rule to delete all the object 2024-files: 2025- 2026- clean: 2027- rm -f *.o 2028- 2029- Wildcards are also useful in the prerequisites of a rule. With the 2030-following rule in the makefile, `make print' will print all the `.c' 2031-files that have changed since the last time you printed them: 2032- 2033- print: *.c 2034- lpr -p $? 2035- touch print 2036- 2037-This rule uses `print' as an empty target file; see *Note Empty Target 2038-Files to Record Events: Empty Targets. (The automatic variable `$?' is 2039-used to print only those files that have changed; see *Note Automatic 2040-Variables::.) 2041- 2042- Wildcard expansion does not happen when you define a variable. 2043-Thus, if you write this: 2044- 2045- objects = *.o 2046- 2047-then the value of the variable `objects' is the actual string `*.o'. 2048-However, if you use the value of `objects' in a target, prerequisite or 2049-command, wildcard expansion will take place at that time. To set 2050-`objects' to the expansion, instead use: 2051- 2052- objects := $(wildcard *.o) 2053- 2054-*Note Wildcard Function::. 2055- 2056- 2057-File: make.info, Node: Wildcard Pitfall, Next: Wildcard Function, Prev: Wildcard Examples, Up: Wildcards 2058- 2059-4.4.2 Pitfalls of Using Wildcards 2060---------------------------------- 2061- 2062-Now here is an example of a naive way of using wildcard expansion, that 2063-does not do what you would intend. Suppose you would like to say that 2064-the executable file `foo' is made from all the object files in the 2065-directory, and you write this: 2066- 2067- objects = *.o 2068- 2069- foo : $(objects) 2070- cc -o foo $(CFLAGS) $(objects) 2071- 2072-The value of `objects' is the actual string `*.o'. Wildcard expansion 2073-happens in the rule for `foo', so that each _existing_ `.o' file 2074-becomes a prerequisite of `foo' and will be recompiled if necessary. 2075- 2076- But what if you delete all the `.o' files? When a wildcard matches 2077-no files, it is left as it is, so then `foo' will depend on the 2078-oddly-named file `*.o'. Since no such file is likely to exist, `make' 2079-will give you an error saying it cannot figure out how to make `*.o'. 2080-This is not what you want! 2081- 2082- Actually it is possible to obtain the desired result with wildcard 2083-expansion, but you need more sophisticated techniques, including the 2084-`wildcard' function and string substitution. *Note The Function 2085-`wildcard': Wildcard Function. 2086- 2087- Microsoft operating systems (MS-DOS and MS-Windows) use backslashes 2088-to separate directories in pathnames, like so: 2089- 2090- c:\foo\bar\baz.c 2091- 2092- This is equivalent to the Unix-style `c:/foo/bar/baz.c' (the `c:' 2093-part is the so-called drive letter). When `make' runs on these 2094-systems, it supports backslashes as well as the Unix-style forward 2095-slashes in pathnames. However, this support does _not_ include the 2096-wildcard expansion, where backslash is a quote character. Therefore, 2097-you _must_ use Unix-style slashes in these cases. 2098- 2099- 2100-File: make.info, Node: Wildcard Function, Prev: Wildcard Pitfall, Up: Wildcards 2101- 2102-4.4.3 The Function `wildcard' 2103------------------------------ 2104- 2105-Wildcard expansion happens automatically in rules. But wildcard 2106-expansion does not normally take place when a variable is set, or 2107-inside the arguments of a function. If you want to do wildcard 2108-expansion in such places, you need to use the `wildcard' function, like 2109-this: 2110- 2111- $(wildcard PATTERN...) 2112- 2113-This string, used anywhere in a makefile, is replaced by a 2114-space-separated list of names of existing files that match one of the 2115-given file name patterns. If no existing file name matches a pattern, 2116-then that pattern is omitted from the output of the `wildcard' 2117-function. Note that this is different from how unmatched wildcards 2118-behave in rules, where they are used verbatim rather than ignored 2119-(*note Wildcard Pitfall::). 2120- 2121- One use of the `wildcard' function is to get a list of all the C 2122-source files in a directory, like this: 2123- 2124- $(wildcard *.c) 2125- 2126- We can change the list of C source files into a list of object files 2127-by replacing the `.c' suffix with `.o' in the result, like this: 2128- 2129- $(patsubst %.c,%.o,$(wildcard *.c)) 2130- 2131-(Here we have used another function, `patsubst'. *Note Functions for 2132-String Substitution and Analysis: Text Functions.) 2133- 2134- Thus, a makefile to compile all C source files in the directory and 2135-then link them together could be written as follows: 2136- 2137- objects := $(patsubst %.c,%.o,$(wildcard *.c)) 2138- 2139- foo : $(objects) 2140- cc -o foo $(objects) 2141- 2142-(This takes advantage of the implicit rule for compiling C programs, so 2143-there is no need to write explicit rules for compiling the files. 2144-*Note The Two Flavors of Variables: Flavors, for an explanation of 2145-`:=', which is a variant of `='.) 2146- 2147- 2148-File: make.info, Node: Directory Search, Next: Phony Targets, Prev: Wildcards, Up: Rules 2149- 2150-4.5 Searching Directories for Prerequisites 2151-=========================================== 2152- 2153-For large systems, it is often desirable to put sources in a separate 2154-directory from the binaries. The "directory search" features of `make' 2155-facilitate this by searching several directories automatically to find 2156-a prerequisite. When you redistribute the files among directories, you 2157-do not need to change the individual rules, just the search paths. 2158- 2159-* Menu: 2160- 2161-* General Search:: Specifying a search path that applies 2162- to every prerequisite. 2163-* Selective Search:: Specifying a search path 2164- for a specified class of names. 2165-* Search Algorithm:: When and how search paths are applied. 2166-* Commands/Search:: How to write shell commands that work together 2167- with search paths. 2168-* Implicit/Search:: How search paths affect implicit rules. 2169-* Libraries/Search:: Directory search for link libraries. 2170- 2171- 2172-File: make.info, Node: General Search, Next: Selective Search, Prev: Directory Search, Up: Directory Search 2173- 2174-4.5.1 `VPATH': Search Path for All Prerequisites 2175------------------------------------------------- 2176- 2177-The value of the `make' variable `VPATH' specifies a list of 2178-directories that `make' should search. Most often, the directories are 2179-expected to contain prerequisite files that are not in the current 2180-directory; however, `make' uses `VPATH' as a search list for both 2181-prerequisites and targets of rules. 2182- 2183- Thus, if a file that is listed as a target or prerequisite does not 2184-exist in the current directory, `make' searches the directories listed 2185-in `VPATH' for a file with that name. If a file is found in one of 2186-them, that file may become the prerequisite (see below). Rules may then 2187-specify the names of files in the prerequisite list as if they all 2188-existed in the current directory. *Note Writing Shell Commands with 2189-Directory Search: Commands/Search. 2190- 2191- In the `VPATH' variable, directory names are separated by colons or 2192-blanks. The order in which directories are listed is the order followed 2193-by `make' in its search. (On MS-DOS and MS-Windows, semi-colons are 2194-used as separators of directory names in `VPATH', since the colon can 2195-be used in the pathname itself, after the drive letter.) 2196- 2197- For example, 2198- 2199- VPATH = src:../headers 2200- 2201-specifies a path containing two directories, `src' and `../headers', 2202-which `make' searches in that order. 2203- 2204- With this value of `VPATH', the following rule, 2205- 2206- foo.o : foo.c 2207- 2208-is interpreted as if it were written like this: 2209- 2210- foo.o : src/foo.c 2211- 2212-assuming the file `foo.c' does not exist in the current directory but 2213-is found in the directory `src'. 2214- 2215- 2216-File: make.info, Node: Selective Search, Next: Search Algorithm, Prev: General Search, Up: Directory Search 2217- 2218-4.5.2 The `vpath' Directive 2219---------------------------- 2220- 2221-Similar to the `VPATH' variable, but more selective, is the `vpath' 2222-directive (note lower case), which allows you to specify a search path 2223-for a particular class of file names: those that match a particular 2224-pattern. Thus you can supply certain search directories for one class 2225-of file names and other directories (or none) for other file names. 2226- 2227- There are three forms of the `vpath' directive: 2228- 2229-`vpath PATTERN DIRECTORIES' 2230- Specify the search path DIRECTORIES for file names that match 2231- PATTERN. 2232- 2233- The search path, DIRECTORIES, is a list of directories to be 2234- searched, separated by colons (semi-colons on MS-DOS and 2235- MS-Windows) or blanks, just like the search path used in the 2236- `VPATH' variable. 2237- 2238-`vpath PATTERN' 2239- Clear out the search path associated with PATTERN. 2240- 2241-`vpath' 2242- Clear all search paths previously specified with `vpath' 2243- directives. 2244- 2245- A `vpath' pattern is a string containing a `%' character. The 2246-string must match the file name of a prerequisite that is being searched 2247-for, the `%' character matching any sequence of zero or more characters 2248-(as in pattern rules; *note Defining and Redefining Pattern Rules: 2249-Pattern Rules.). For example, `%.h' matches files that end in `.h'. 2250-(If there is no `%', the pattern must match the prerequisite exactly, 2251-which is not useful very often.) 2252- 2253- `%' characters in a `vpath' directive's pattern can be quoted with 2254-preceding backslashes (`\'). Backslashes that would otherwise quote 2255-`%' characters can be quoted with more backslashes. Backslashes that 2256-quote `%' characters or other backslashes are removed from the pattern 2257-before it is compared to file names. Backslashes that are not in 2258-danger of quoting `%' characters go unmolested. 2259- 2260- When a prerequisite fails to exist in the current directory, if the 2261-PATTERN in a `vpath' directive matches the name of the prerequisite 2262-file, then the DIRECTORIES in that directive are searched just like 2263-(and before) the directories in the `VPATH' variable. 2264- 2265- For example, 2266- 2267- vpath %.h ../headers 2268- 2269-tells `make' to look for any prerequisite whose name ends in `.h' in 2270-the directory `../headers' if the file is not found in the current 2271-directory. 2272- 2273- If several `vpath' patterns match the prerequisite file's name, then 2274-`make' processes each matching `vpath' directive one by one, searching 2275-all the directories mentioned in each directive. `make' handles 2276-multiple `vpath' directives in the order in which they appear in the 2277-makefile; multiple directives with the same pattern are independent of 2278-each other. 2279- 2280- Thus, 2281- 2282- vpath %.c foo 2283- vpath % blish 2284- vpath %.c bar 2285- 2286-will look for a file ending in `.c' in `foo', then `blish', then `bar', 2287-while 2288- 2289- vpath %.c foo:bar 2290- vpath % blish 2291- 2292-will look for a file ending in `.c' in `foo', then `bar', then `blish'. 2293- 2294- 2295-File: make.info, Node: Search Algorithm, Next: Commands/Search, Prev: Selective Search, Up: Directory Search 2296- 2297-4.5.3 How Directory Searches are Performed 2298------------------------------------------- 2299- 2300-When a prerequisite is found through directory search, regardless of 2301-type (general or selective), the pathname located may not be the one 2302-that `make' actually provides you in the prerequisite list. Sometimes 2303-the path discovered through directory search is thrown away. 2304- 2305- The algorithm `make' uses to decide whether to keep or abandon a 2306-path found via directory search is as follows: 2307- 2308- 1. If a target file does not exist at the path specified in the 2309- makefile, directory search is performed. 2310- 2311- 2. If the directory search is successful, that path is kept and this 2312- file is tentatively stored as the target. 2313- 2314- 3. All prerequisites of this target are examined using this same 2315- method. 2316- 2317- 4. After processing the prerequisites, the target may or may not need 2318- to be rebuilt: 2319- 2320- a. If the target does _not_ need to be rebuilt, the path to the 2321- file found during directory search is used for any 2322- prerequisite lists which contain this target. In short, if 2323- `make' doesn't need to rebuild the target then you use the 2324- path found via directory search. 2325- 2326- b. If the target _does_ need to be rebuilt (is out-of-date), the 2327- pathname found during directory search is _thrown away_, and 2328- the target is rebuilt using the file name specified in the 2329- makefile. In short, if `make' must rebuild, then the target 2330- is rebuilt locally, not in the directory found via directory 2331- search. 2332- 2333- This algorithm may seem complex, but in practice it is quite often 2334-exactly what you want. 2335- 2336- Other versions of `make' use a simpler algorithm: if the file does 2337-not exist, and it is found via directory search, then that pathname is 2338-always used whether or not the target needs to be built. Thus, if the 2339-target is rebuilt it is created at the pathname discovered during 2340-directory search. 2341- 2342- If, in fact, this is the behavior you want for some or all of your 2343-directories, you can use the `GPATH' variable to indicate this to 2344-`make'. 2345- 2346- `GPATH' has the same syntax and format as `VPATH' (that is, a space- 2347-or colon-delimited list of pathnames). If an out-of-date target is 2348-found by directory search in a directory that also appears in `GPATH', 2349-then that pathname is not thrown away. The target is rebuilt using the 2350-expanded path. 2351- 2352- 2353-File: make.info, Node: Commands/Search, Next: Implicit/Search, Prev: Search Algorithm, Up: Directory Search 2354- 2355-4.5.4 Writing Shell Commands with Directory Search 2356--------------------------------------------------- 2357- 2358-When a prerequisite is found in another directory through directory 2359-search, this cannot change the commands of the rule; they will execute 2360-as written. Therefore, you must write the commands with care so that 2361-they will look for the prerequisite in the directory where `make' finds 2362-it. 2363- 2364- This is done with the "automatic variables" such as `$^' (*note 2365-Automatic Variables::). For instance, the value of `$^' is a list of 2366-all the prerequisites of the rule, including the names of the 2367-directories in which they were found, and the value of `$@' is the 2368-target. Thus: 2369- 2370- foo.o : foo.c 2371- cc -c $(CFLAGS) $^ -o $@ 2372- 2373-(The variable `CFLAGS' exists so you can specify flags for C 2374-compilation by implicit rules; we use it here for consistency so it will 2375-affect all C compilations uniformly; *note Variables Used by Implicit 2376-Rules: Implicit Variables.) 2377- 2378- Often the prerequisites include header files as well, which you do 2379-not want to mention in the commands. The automatic variable `$<' is 2380-just the first prerequisite: 2381- 2382- VPATH = src:../headers 2383- foo.o : foo.c defs.h hack.h 2384- cc -c $(CFLAGS) $< -o $@ 2385- 2386- 2387-File: make.info, Node: Implicit/Search, Next: Libraries/Search, Prev: Commands/Search, Up: Directory Search 2388- 2389-4.5.5 Directory Search and Implicit Rules 2390------------------------------------------ 2391- 2392-The search through the directories specified in `VPATH' or with `vpath' 2393-also happens during consideration of implicit rules (*note Using 2394-Implicit Rules: Implicit Rules.). 2395- 2396- For example, when a file `foo.o' has no explicit rule, `make' 2397-considers implicit rules, such as the built-in rule to compile `foo.c' 2398-if that file exists. If such a file is lacking in the current 2399-directory, the appropriate directories are searched for it. If `foo.c' 2400-exists (or is mentioned in the makefile) in any of the directories, the 2401-implicit rule for C compilation is applied. 2402- 2403- The commands of implicit rules normally use automatic variables as a 2404-matter of necessity; consequently they will use the file names found by 2405-directory search with no extra effort. 2406- 2407- 2408-File: make.info, Node: Libraries/Search, Prev: Implicit/Search, Up: Directory Search 2409- 2410-4.5.6 Directory Search for Link Libraries 2411------------------------------------------ 2412- 2413-Directory search applies in a special way to libraries used with the 2414-linker. This special feature comes into play when you write a 2415-prerequisite whose name is of the form `-lNAME'. (You can tell 2416-something strange is going on here because the prerequisite is normally 2417-the name of a file, and the _file name_ of a library generally looks 2418-like `libNAME.a', not like `-lNAME'.) 2419- 2420- When a prerequisite's name has the form `-lNAME', `make' handles it 2421-specially by searching for the file `libNAME.so' in the current 2422-directory, in directories specified by matching `vpath' search paths 2423-and the `VPATH' search path, and then in the directories `/lib', 2424-`/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib', but 2425-MS-DOS/MS-Windows versions of `make' behave as if PREFIX is defined to 2426-be the root of the DJGPP installation tree). 2427- 2428- If that file is not found, then the file `libNAME.a' is searched 2429-for, in the same directories as above. 2430- 2431- For example, if there is a `/usr/lib/libcurses.a' library on your 2432-system (and no `/usr/lib/libcurses.so' file), then 2433- 2434- foo : foo.c -lcurses 2435- cc $^ -o $@ 2436- 2437-would cause the command `cc foo.c /usr/lib/libcurses.a -o foo' to be 2438-executed when `foo' is older than `foo.c' or than 2439-`/usr/lib/libcurses.a'. 2440- 2441- Although the default set of files to be searched for is `libNAME.so' 2442-and `libNAME.a', this is customizable via the `.LIBPATTERNS' variable. 2443-Each word in the value of this variable is a pattern string. When a 2444-prerequisite like `-lNAME' is seen, `make' will replace the percent in 2445-each pattern in the list with NAME and perform the above directory 2446-searches using that library filename. If no library is found, the next 2447-word in the list will be used. 2448- 2449- The default value for `.LIBPATTERNS' is `lib%.so lib%.a', which 2450-provides the default behavior described above. 2451- 2452- You can turn off link library expansion completely by setting this 2453-variable to an empty value. 2454- 2455- 2456-File: make.info, Node: Phony Targets, Next: Force Targets, Prev: Directory Search, Up: Rules 2457- 2458-4.6 Phony Targets 2459-================= 2460- 2461-A phony target is one that is not really the name of a file. It is 2462-just a name for some commands to be executed when you make an explicit 2463-request. There are two reasons to use a phony target: to avoid a 2464-conflict with a file of the same name, and to improve performance. 2465- 2466- If you write a rule whose commands will not create the target file, 2467-the commands will be executed every time the target comes up for 2468-remaking. Here is an example: 2469- 2470- clean: 2471- rm *.o temp 2472- 2473-Because the `rm' command does not create a file named `clean', probably 2474-no such file will ever exist. Therefore, the `rm' command will be 2475-executed every time you say `make clean'. 2476- 2477- The phony target will cease to work if anything ever does create a 2478-file named `clean' in this directory. Since it has no prerequisites, 2479-the file `clean' would inevitably be considered up to date, and its 2480-commands would not be executed. To avoid this problem, you can 2481-explicitly declare the target to be phony, using the special target 2482-`.PHONY' (*note Special Built-in Target Names: Special Targets.) as 2483-follows: 2484- 2485- .PHONY : clean 2486- 2487-Once this is done, `make clean' will run the commands regardless of 2488-whether there is a file named `clean'. 2489- 2490- Since it knows that phony targets do not name actual files that 2491-could be remade from other files, `make' skips the implicit rule search 2492-for phony targets (*note Implicit Rules::). This is why declaring a 2493-target phony is good for performance, even if you are not worried about 2494-the actual file existing. 2495- 2496- Thus, you first write the line that states that `clean' is a phony 2497-target, then you write the rule, like this: 2498- 2499- .PHONY: clean 2500- clean: 2501- rm *.o temp 2502- 2503- Another example of the usefulness of phony targets is in conjunction 2504-with recursive invocations of `make' (for more information, see *Note 2505-Recursive Use of `make': Recursion.). In this case the makefile will 2506-often contain a variable which lists a number of subdirectories to be 2507-built. One way to handle this is with one rule whose command is a 2508-shell loop over the subdirectories, like this: 2509- 2510- SUBDIRS = foo bar baz 2511- 2512- subdirs: 2513- for dir in $(SUBDIRS); do \ 2514- $(MAKE) -C $$dir; \ 2515- done 2516- 2517- There are a few problems with this method, however. First, any error 2518-detected in a submake is not noted by this rule, so it will continue to 2519-build the rest of the directories even when one fails. This can be 2520-overcome by adding shell commands to note the error and exit, but then 2521-it will do so even if `make' is invoked with the `-k' option, which is 2522-unfortunate. Second, and perhaps more importantly, you cannot take 2523-advantage of `make''s ability to build targets in parallel (*note 2524-Parallel Execution: Parallel.), since there is only one rule. 2525- 2526- By declaring the subdirectories as phony targets (you must do this as 2527-the subdirectory obviously always exists; otherwise it won't be built) 2528-you can remove these problems: 2529- 2530- SUBDIRS = foo bar baz 2531- 2532- .PHONY: subdirs $(SUBDIRS) 2533- 2534- subdirs: $(SUBDIRS) 2535- 2536- $(SUBDIRS): 2537- $(MAKE) -C $@ 2538- 2539- foo: baz 2540- 2541- Here we've also declared that the `foo' subdirectory cannot be built 2542-until after the `baz' subdirectory is complete; this kind of 2543-relationship declaration is particularly important when attempting 2544-parallel builds. 2545- 2546- A phony target should not be a prerequisite of a real target file; 2547-if it is, its commands are run every time `make' goes to update that 2548-file. As long as a phony target is never a prerequisite of a real 2549-target, the phony target commands will be executed only when the phony 2550-target is a specified goal (*note Arguments to Specify the Goals: 2551-Goals.). 2552- 2553- Phony targets can have prerequisites. When one directory contains 2554-multiple programs, it is most convenient to describe all of the 2555-programs in one makefile `./Makefile'. Since the target remade by 2556-default will be the first one in the makefile, it is common to make 2557-this a phony target named `all' and give it, as prerequisites, all the 2558-individual programs. For example: 2559- 2560- all : prog1 prog2 prog3 2561- .PHONY : all 2562- 2563- prog1 : prog1.o utils.o 2564- cc -o prog1 prog1.o utils.o 2565- 2566- prog2 : prog2.o 2567- cc -o prog2 prog2.o 2568- 2569- prog3 : prog3.o sort.o utils.o 2570- cc -o prog3 prog3.o sort.o utils.o 2571- 2572-Now you can say just `make' to remake all three programs, or specify as 2573-arguments the ones to remake (as in `make prog1 prog3'). Phoniness is 2574-not inherited: the prerequisites of a phony target are not themselves 2575-phony, unless explicitly declared to be so. 2576- 2577- When one phony target is a prerequisite of another, it serves as a 2578-subroutine of the other. For example, here `make cleanall' will delete 2579-the object files, the difference files, and the file `program': 2580- 2581- .PHONY: cleanall cleanobj cleandiff 2582- 2583- cleanall : cleanobj cleandiff 2584- rm program 2585- 2586- cleanobj : 2587- rm *.o 2588- 2589- cleandiff : 2590- rm *.diff 2591- 2592- 2593-File: make.info, Node: Force Targets, Next: Empty Targets, Prev: Phony Targets, Up: Rules 2594- 2595-4.7 Rules without Commands or Prerequisites 2596-=========================================== 2597- 2598-If a rule has no prerequisites or commands, and the target of the rule 2599-is a nonexistent file, then `make' imagines this target to have been 2600-updated whenever its rule is run. This implies that all targets 2601-depending on this one will always have their commands run. 2602- 2603- An example will illustrate this: 2604- 2605- clean: FORCE 2606- rm $(objects) 2607- FORCE: 2608- 2609- Here the target `FORCE' satisfies the special conditions, so the 2610-target `clean' that depends on it is forced to run its commands. There 2611-is nothing special about the name `FORCE', but that is one name 2612-commonly used this way. 2613- 2614- As you can see, using `FORCE' this way has the same results as using 2615-`.PHONY: clean'. 2616- 2617- Using `.PHONY' is more explicit and more efficient. However, other 2618-versions of `make' do not support `.PHONY'; thus `FORCE' appears in 2619-many makefiles. *Note Phony Targets::. 2620- 2621- 2622-File: make.info, Node: Empty Targets, Next: Special Targets, Prev: Force Targets, Up: Rules 2623- 2624-4.8 Empty Target Files to Record Events 2625-======================================= 2626- 2627-The "empty target" is a variant of the phony target; it is used to hold 2628-commands for an action that you request explicitly from time to time. 2629-Unlike a phony target, this target file can really exist; but the file's 2630-contents do not matter, and usually are empty. 2631- 2632- The purpose of the empty target file is to record, with its 2633-last-modification time, when the rule's commands were last executed. It 2634-does so because one of the commands is a `touch' command to update the 2635-target file. 2636- 2637- The empty target file should have some prerequisites (otherwise it 2638-doesn't make sense). When you ask to remake the empty target, the 2639-commands are executed if any prerequisite is more recent than the 2640-target; in other words, if a prerequisite has changed since the last 2641-time you remade the target. Here is an example: 2642- 2643- print: foo.c bar.c 2644- lpr -p $? 2645- touch print 2646- 2647-With this rule, `make print' will execute the `lpr' command if either 2648-source file has changed since the last `make print'. The automatic 2649-variable `$?' is used to print only those files that have changed 2650-(*note Automatic Variables::). 2651- 2652- 2653-File: make.info, Node: Special Targets, Next: Multiple Targets, Prev: Empty Targets, Up: Rules 2654- 2655-4.9 Special Built-in Target Names 2656-================================= 2657- 2658-Certain names have special meanings if they appear as targets. 2659- 2660-`.PHONY' 2661- The prerequisites of the special target `.PHONY' are considered to 2662- be phony targets. When it is time to consider such a target, 2663- `make' will run its commands unconditionally, regardless of 2664- whether a file with that name exists or what its last-modification 2665- time is. *Note Phony Targets: Phony Targets. 2666- 2667-`.SUFFIXES' 2668- The prerequisites of the special target `.SUFFIXES' are the list 2669- of suffixes to be used in checking for suffix rules. *Note 2670- Old-Fashioned Suffix Rules: Suffix Rules. 2671- 2672-`.DEFAULT' 2673- The commands specified for `.DEFAULT' are used for any target for 2674- which no rules are found (either explicit rules or implicit rules). 2675- *Note Last Resort::. If `.DEFAULT' commands are specified, every 2676- file mentioned as a prerequisite, but not as a target in a rule, 2677- will have these commands executed on its behalf. *Note Implicit 2678- Rule Search Algorithm: Implicit Rule Search. 2679- 2680-`.PRECIOUS' 2681- The targets which `.PRECIOUS' depends on are given the following 2682- special treatment: if `make' is killed or interrupted during the 2683- execution of their commands, the target is not deleted. *Note 2684- Interrupting or Killing `make': Interrupts. Also, if the target 2685- is an intermediate file, it will not be deleted after it is no 2686- longer needed, as is normally done. *Note Chains of Implicit 2687- Rules: Chained Rules. In this latter respect it overlaps with the 2688- `.SECONDARY' special target. 2689- 2690- You can also list the target pattern of an implicit rule (such as 2691- `%.o') as a prerequisite file of the special target `.PRECIOUS' to 2692- preserve intermediate files created by rules whose target patterns 2693- match that file's name. 2694- 2695-`.INTERMEDIATE' 2696- The targets which `.INTERMEDIATE' depends on are treated as 2697- intermediate files. *Note Chains of Implicit Rules: Chained Rules. 2698- `.INTERMEDIATE' with no prerequisites has no effect. 2699- 2700-`.SECONDARY' 2701- The targets which `.SECONDARY' depends on are treated as 2702- intermediate files, except that they are never automatically 2703- deleted. *Note Chains of Implicit Rules: Chained Rules. 2704- 2705- `.SECONDARY' with no prerequisites causes all targets to be treated 2706- as secondary (i.e., no target is removed because it is considered 2707- intermediate). 2708- 2709-`.SECONDEXPANSION' 2710- If `.SECONDEXPANSION' is mentioned as a target anywhere in the 2711- makefile, then all prerequisite lists defined _after_ it appears 2712- will be expanded a second time after all makefiles have been read 2713- in. *Note Secondary Expansion: Secondary Expansion. 2714- 2715- The prerequisites of the special target `.SUFFIXES' are the list 2716- of suffixes to be used in checking for suffix rules. *Note 2717- Old-Fashioned Suffix Rules: Suffix Rules. 2718- 2719-`.DELETE_ON_ERROR' 2720- If `.DELETE_ON_ERROR' is mentioned as a target anywhere in the 2721- makefile, then `make' will delete the target of a rule if it has 2722- changed and its commands exit with a nonzero exit status, just as 2723- it does when it receives a signal. *Note Errors in Commands: 2724- Errors. 2725- 2726-`.IGNORE' 2727- If you specify prerequisites for `.IGNORE', then `make' will 2728- ignore errors in execution of the commands run for those particular 2729- files. The commands for `.IGNORE' are not meaningful. 2730- 2731- If mentioned as a target with no prerequisites, `.IGNORE' says to 2732- ignore errors in execution of commands for all files. This usage 2733- of `.IGNORE' is supported only for historical compatibility. Since 2734- this affects every command in the makefile, it is not very useful; 2735- we recommend you use the more selective ways to ignore errors in 2736- specific commands. *Note Errors in Commands: Errors. 2737- 2738-`.LOW_RESOLUTION_TIME' 2739- If you specify prerequisites for `.LOW_RESOLUTION_TIME', `make' 2740- assumes that these files are created by commands that generate low 2741- resolution time stamps. The commands for `.LOW_RESOLUTION_TIME' 2742- are not meaningful. 2743- 2744- The high resolution file time stamps of many modern hosts lessen 2745- the chance of `make' incorrectly concluding that a file is up to 2746- date. Unfortunately, these hosts provide no way to set a high 2747- resolution file time stamp, so commands like `cp -p' that 2748- explicitly set a file's time stamp must discard its subsecond 2749- part. If a file is created by such a command, you should list it 2750- as a prerequisite of `.LOW_RESOLUTION_TIME' so that `make' does 2751- not mistakenly conclude that the file is out of date. For example: 2752- 2753- .LOW_RESOLUTION_TIME: dst 2754- dst: src 2755- cp -p src dst 2756- 2757- Since `cp -p' discards the subsecond part of `src''s time stamp, 2758- `dst' is typically slightly older than `src' even when it is up to 2759- date. The `.LOW_RESOLUTION_TIME' line causes `make' to consider 2760- `dst' to be up to date if its time stamp is at the start of the 2761- same second that `src''s time stamp is in. 2762- 2763- Due to a limitation of the archive format, archive member time 2764- stamps are always low resolution. You need not list archive 2765- members as prerequisites of `.LOW_RESOLUTION_TIME', as `make' does 2766- this automatically. 2767- 2768-`.SILENT' 2769- If you specify prerequisites for `.SILENT', then `make' will not 2770- print the commands to remake those particular files before 2771- executing them. The commands for `.SILENT' are not meaningful. 2772- 2773- If mentioned as a target with no prerequisites, `.SILENT' says not 2774- to print any commands before executing them. This usage of 2775- `.SILENT' is supported only for historical compatibility. We 2776- recommend you use the more selective ways to silence specific 2777- commands. *Note Command Echoing: Echoing. If you want to silence 2778- all commands for a particular run of `make', use the `-s' or 2779- `--silent' option (*note Options Summary::). 2780- 2781-`.EXPORT_ALL_VARIABLES' 2782- Simply by being mentioned as a target, this tells `make' to export 2783- all variables to child processes by default. *Note Communicating 2784- Variables to a Sub-`make': Variables/Recursion. 2785- 2786-`.NOTPARALLEL' 2787- If `.NOTPARALLEL' is mentioned as a target, then this invocation of 2788- `make' will be run serially, even if the `-j' option is given. 2789- Any recursively invoked `make' command will still be run in 2790- parallel (unless its makefile contains this target). Any 2791- prerequisites on this target are ignored. 2792- 2793- Any defined implicit rule suffix also counts as a special target if 2794-it appears as a target, and so does the concatenation of two suffixes, 2795-such as `.c.o'. These targets are suffix rules, an obsolete way of 2796-defining implicit rules (but a way still widely used). In principle, 2797-any target name could be special in this way if you break it in two and 2798-add both pieces to the suffix list. In practice, suffixes normally 2799-begin with `.', so these special target names also begin with `.'. 2800-*Note Old-Fashioned Suffix Rules: Suffix Rules. 2801- 2802- 2803-File: make.info, Node: Multiple Targets, Next: Multiple Rules, Prev: Special Targets, Up: Rules 2804- 2805-4.10 Multiple Targets in a Rule 2806-=============================== 2807- 2808-A rule with multiple targets is equivalent to writing many rules, each 2809-with one target, and all identical aside from that. The same commands 2810-apply to all the targets, but their effects may vary because you can 2811-substitute the actual target name into the command using `$@'. The 2812-rule contributes the same prerequisites to all the targets also. 2813- 2814- This is useful in two cases. 2815- 2816- * You want just prerequisites, no commands. For example: 2817- 2818- kbd.o command.o files.o: command.h 2819- 2820- gives an additional prerequisite to each of the three object files 2821- mentioned. 2822- 2823- * Similar commands work for all the targets. The commands do not 2824- need to be absolutely identical, since the automatic variable `$@' 2825- can be used to substitute the particular target to be remade into 2826- the commands (*note Automatic Variables::). For example: 2827- 2828- bigoutput littleoutput : text.g 2829- generate text.g -$(subst output,,$@) > $@ 2830- 2831- is equivalent to 2832- 2833- bigoutput : text.g 2834- generate text.g -big > bigoutput 2835- littleoutput : text.g 2836- generate text.g -little > littleoutput 2837- 2838- Here we assume the hypothetical program `generate' makes two types 2839- of output, one if given `-big' and one if given `-little'. *Note 2840- Functions for String Substitution and Analysis: Text Functions, 2841- for an explanation of the `subst' function. 2842- 2843- Suppose you would like to vary the prerequisites according to the 2844-target, much as the variable `$@' allows you to vary the commands. You 2845-cannot do this with multiple targets in an ordinary rule, but you can 2846-do it with a "static pattern rule". *Note Static Pattern Rules: Static 2847-Pattern. 2848- 2849- 2850-File: make.info, Node: Multiple Rules, Next: Static Pattern, Prev: Multiple Targets, Up: Rules 2851- 2852-4.11 Multiple Rules for One Target 2853-================================== 2854- 2855-One file can be the target of several rules. All the prerequisites 2856-mentioned in all the rules are merged into one list of prerequisites for 2857-the target. If the target is older than any prerequisite from any rule, 2858-the commands are executed. 2859- 2860- There can only be one set of commands to be executed for a file. If 2861-more than one rule gives commands for the same file, `make' uses the 2862-last set given and prints an error message. (As a special case, if the 2863-file's name begins with a dot, no error message is printed. This odd 2864-behavior is only for compatibility with other implementations of 2865-`make'... you should avoid using it). Occasionally it is useful to 2866-have the same target invoke multiple commands which are defined in 2867-different parts of your makefile; you can use "double-colon rules" 2868-(*note Double-Colon::) for this. 2869- 2870- An extra rule with just prerequisites can be used to give a few extra 2871-prerequisites to many files at once. For example, makefiles often have 2872-a variable, such as `objects', containing a list of all the compiler 2873-output files in the system being made. An easy way to say that all of 2874-them must be recompiled if `config.h' changes is to write the following: 2875- 2876- objects = foo.o bar.o 2877- foo.o : defs.h 2878- bar.o : defs.h test.h 2879- $(objects) : config.h 2880- 2881- This could be inserted or taken out without changing the rules that 2882-really specify how to make the object files, making it a convenient 2883-form to use if you wish to add the additional prerequisite 2884-intermittently. 2885- 2886- Another wrinkle is that the additional prerequisites could be 2887-specified with a variable that you set with a command argument to `make' 2888-(*note Overriding Variables: Overriding.). For example, 2889- 2890- extradeps= 2891- $(objects) : $(extradeps) 2892- 2893-means that the command `make extradeps=foo.h' will consider `foo.h' as 2894-a prerequisite of each object file, but plain `make' will not. 2895- 2896- If none of the explicit rules for a target has commands, then `make' 2897-searches for an applicable implicit rule to find some commands *note 2898-Using Implicit Rules: Implicit Rules.). 2899- 2900- 2901-File: make.info, Node: Static Pattern, Next: Double-Colon, Prev: Multiple Rules, Up: Rules 2902- 2903-4.12 Static Pattern Rules 2904-========================= 2905- 2906-"Static pattern rules" are rules which specify multiple targets and 2907-construct the prerequisite names for each target based on the target 2908-name. They are more general than ordinary rules with multiple targets 2909-because the targets do not have to have identical prerequisites. Their 2910-prerequisites must be _analogous_, but not necessarily _identical_. 2911- 2912-* Menu: 2913- 2914-* Static Usage:: The syntax of static pattern rules. 2915-* Static versus Implicit:: When are they better than implicit rules? 2916- 2917- 2918-File: make.info, Node: Static Usage, Next: Static versus Implicit, Prev: Static Pattern, Up: Static Pattern 2919- 2920-4.12.1 Syntax of Static Pattern Rules 2921-------------------------------------- 2922- 2923-Here is the syntax of a static pattern rule: 2924- 2925- TARGETS ...: TARGET-PATTERN: PREREQ-PATTERNS ... 2926- COMMANDS 2927- ... 2928- 2929-The TARGETS list specifies the targets that the rule applies to. The 2930-targets can contain wildcard characters, just like the targets of 2931-ordinary rules (*note Using Wildcard Characters in File Names: 2932-Wildcards.). 2933- 2934- The TARGET-PATTERN and PREREQ-PATTERNS say how to compute the 2935-prerequisites of each target. Each target is matched against the 2936-TARGET-PATTERN to extract a part of the target name, called the "stem". 2937-This stem is substituted into each of the PREREQ-PATTERNS to make the 2938-prerequisite names (one from each PREREQ-PATTERN). 2939- 2940- Each pattern normally contains the character `%' just once. When the 2941-TARGET-PATTERN matches a target, the `%' can match any part of the 2942-target name; this part is called the "stem". The rest of the pattern 2943-must match exactly. For example, the target `foo.o' matches the 2944-pattern `%.o', with `foo' as the stem. The targets `foo.c' and 2945-`foo.out' do not match that pattern. 2946- 2947- The prerequisite names for each target are made by substituting the 2948-stem for the `%' in each prerequisite pattern. For example, if one 2949-prerequisite pattern is `%.c', then substitution of the stem `foo' 2950-gives the prerequisite name `foo.c'. It is legitimate to write a 2951-prerequisite pattern that does not contain `%'; then this prerequisite 2952-is the same for all targets. 2953- 2954- `%' characters in pattern rules can be quoted with preceding 2955-backslashes (`\'). Backslashes that would otherwise quote `%' 2956-characters can be quoted with more backslashes. Backslashes that quote 2957-`%' characters or other backslashes are removed from the pattern before 2958-it is compared to file names or has a stem substituted into it. 2959-Backslashes that are not in danger of quoting `%' characters go 2960-unmolested. For example, the pattern `the\%weird\\%pattern\\' has 2961-`the%weird\' preceding the operative `%' character, and `pattern\\' 2962-following it. The final two backslashes are left alone because they 2963-cannot affect any `%' character. 2964- 2965- Here is an example, which compiles each of `foo.o' and `bar.o' from 2966-the corresponding `.c' file: 2967- 2968- objects = foo.o bar.o 2969- 2970- all: $(objects) 2971- 2972- $(objects): %.o: %.c 2973- $(CC) -c $(CFLAGS) $< -o $@ 2974- 2975-Here `$<' is the automatic variable that holds the name of the 2976-prerequisite and `$@' is the automatic variable that holds the name of 2977-the target; see *Note Automatic Variables::. 2978- 2979- Each target specified must match the target pattern; a warning is 2980-issued for each target that does not. If you have a list of files, 2981-only some of which will match the pattern, you can use the `filter' 2982-function to remove nonmatching file names (*note Functions for String 2983-Substitution and Analysis: Text Functions.): 2984- 2985- files = foo.elc bar.o lose.o 2986- 2987- $(filter %.o,$(files)): %.o: %.c 2988- $(CC) -c $(CFLAGS) $< -o $@ 2989- $(filter %.elc,$(files)): %.elc: %.el 2990- emacs -f batch-byte-compile $< 2991- 2992-In this example the result of `$(filter %.o,$(files))' is `bar.o 2993-lose.o', and the first static pattern rule causes each of these object 2994-files to be updated by compiling the corresponding C source file. The 2995-result of `$(filter %.elc,$(files))' is `foo.elc', so that file is made 2996-from `foo.el'. 2997- 2998- Another example shows how to use `$*' in static pattern rules: 2999- 3000- bigoutput littleoutput : %output : text.g 3001- generate text.g -$* > $@ 3002- 3003-When the `generate' command is run, `$*' will expand to the stem, 3004-either `big' or `little'. 3005- 3006- 3007-File: make.info, Node: Static versus Implicit, Prev: Static Usage, Up: Static Pattern 3008- 3009-4.12.2 Static Pattern Rules versus Implicit Rules 3010-------------------------------------------------- 3011- 3012-A static pattern rule has much in common with an implicit rule defined 3013-as a pattern rule (*note Defining and Redefining Pattern Rules: Pattern 3014-Rules.). Both have a pattern for the target and patterns for 3015-constructing the names of prerequisites. The difference is in how 3016-`make' decides _when_ the rule applies. 3017- 3018- An implicit rule _can_ apply to any target that matches its pattern, 3019-but it _does_ apply only when the target has no commands otherwise 3020-specified, and only when the prerequisites can be found. If more than 3021-one implicit rule appears applicable, only one applies; the choice 3022-depends on the order of rules. 3023- 3024- By contrast, a static pattern rule applies to the precise list of 3025-targets that you specify in the rule. It cannot apply to any other 3026-target and it invariably does apply to each of the targets specified. 3027-If two conflicting rules apply, and both have commands, that's an error. 3028- 3029- The static pattern rule can be better than an implicit rule for these 3030-reasons: 3031- 3032- * You may wish to override the usual implicit rule for a few files 3033- whose names cannot be categorized syntactically but can be given 3034- in an explicit list. 3035- 3036- * If you cannot be sure of the precise contents of the directories 3037- you are using, you may not be sure which other irrelevant files 3038- might lead `make' to use the wrong implicit rule. The choice 3039- might depend on the order in which the implicit rule search is 3040- done. With static pattern rules, there is no uncertainty: each 3041- rule applies to precisely the targets specified. 3042- 3043- 3044-File: make.info, Node: Double-Colon, Next: Automatic Prerequisites, Prev: Static Pattern, Up: Rules 3045- 3046-4.13 Double-Colon Rules 3047-======================= 3048- 3049-"Double-colon" rules are rules written with `::' instead of `:' after 3050-the target names. They are handled differently from ordinary rules 3051-when the same target appears in more than one rule. 3052- 3053- When a target appears in multiple rules, all the rules must be the 3054-same type: all ordinary, or all double-colon. If they are 3055-double-colon, each of them is independent of the others. Each 3056-double-colon rule's commands are executed if the target is older than 3057-any prerequisites of that rule. If there are no prerequisites for that 3058-rule, its commands are always executed (even if the target already 3059-exists). This can result in executing none, any, or all of the 3060-double-colon rules. 3061- 3062- Double-colon rules with the same target are in fact completely 3063-separate from one another. Each double-colon rule is processed 3064-individually, just as rules with different targets are processed. 3065- 3066- The double-colon rules for a target are executed in the order they 3067-appear in the makefile. However, the cases where double-colon rules 3068-really make sense are those where the order of executing the commands 3069-would not matter. 3070- 3071- Double-colon rules are somewhat obscure and not often very useful; 3072-they provide a mechanism for cases in which the method used to update a 3073-target differs depending on which prerequisite files caused the update, 3074-and such cases are rare. 3075- 3076- Each double-colon rule should specify commands; if it does not, an 3077-implicit rule will be used if one applies. *Note Using Implicit Rules: 3078-Implicit Rules. 3079- 3080- 3081-File: make.info, Node: Automatic Prerequisites, Prev: Double-Colon, Up: Rules 3082- 3083-4.14 Generating Prerequisites Automatically 3084-=========================================== 3085- 3086-In the makefile for a program, many of the rules you need to write often 3087-say only that some object file depends on some header file. For 3088-example, if `main.c' uses `defs.h' via an `#include', you would write: 3089- 3090- main.o: defs.h 3091- 3092-You need this rule so that `make' knows that it must remake `main.o' 3093-whenever `defs.h' changes. You can see that for a large program you 3094-would have to write dozens of such rules in your makefile. And, you 3095-must always be very careful to update the makefile every time you add 3096-or remove an `#include'. 3097- 3098- To avoid this hassle, most modern C compilers can write these rules 3099-for you, by looking at the `#include' lines in the source files. 3100-Usually this is done with the `-M' option to the compiler. For 3101-example, the command: 3102- 3103- cc -M main.c 3104- 3105-generates the output: 3106- 3107- main.o : main.c defs.h 3108- 3109-Thus you no longer have to write all those rules yourself. The 3110-compiler will do it for you. 3111- 3112- Note that such a prerequisite constitutes mentioning `main.o' in a 3113-makefile, so it can never be considered an intermediate file by implicit 3114-rule search. This means that `make' won't ever remove the file after 3115-using it; *note Chains of Implicit Rules: Chained Rules. 3116- 3117- With old `make' programs, it was traditional practice to use this 3118-compiler feature to generate prerequisites on demand with a command like 3119-`make depend'. That command would create a file `depend' containing 3120-all the automatically-generated prerequisites; then the makefile could 3121-use `include' to read them in (*note Include::). 3122- 3123- In GNU `make', the feature of remaking makefiles makes this practice 3124-obsolete--you need never tell `make' explicitly to regenerate the 3125-prerequisites, because it always regenerates any makefile that is out 3126-of date. *Note Remaking Makefiles::. 3127- 3128- The practice we recommend for automatic prerequisite generation is 3129-to have one makefile corresponding to each source file. For each 3130-source file `NAME.c' there is a makefile `NAME.d' which lists what 3131-files the object file `NAME.o' depends on. That way only the source 3132-files that have changed need to be rescanned to produce the new 3133-prerequisites. 3134- 3135- Here is the pattern rule to generate a file of prerequisites (i.e., 3136-a makefile) called `NAME.d' from a C source file called `NAME.c': 3137- 3138- %.d: %.c 3139- @set -e; rm -f $@; \ 3140- $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 3141- sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 3142- rm -f $@.$$$$ 3143- 3144-*Note Pattern Rules::, for information on defining pattern rules. The 3145-`-e' flag to the shell causes it to exit immediately if the `$(CC)' 3146-command (or any other command) fails (exits with a nonzero status). 3147- 3148- With the GNU C compiler, you may wish to use the `-MM' flag instead 3149-of `-M'. This omits prerequisites on system header files. *Note 3150-Options Controlling the Preprocessor: (gcc.info)Preprocessor Options, 3151-for details. 3152- 3153- The purpose of the `sed' command is to translate (for example): 3154- 3155- main.o : main.c defs.h 3156- 3157-into: 3158- 3159- main.o main.d : main.c defs.h 3160- 3161-This makes each `.d' file depend on all the source and header files 3162-that the corresponding `.o' file depends on. `make' then knows it must 3163-regenerate the prerequisites whenever any of the source or header files 3164-changes. 3165- 3166- Once you've defined the rule to remake the `.d' files, you then use 3167-the `include' directive to read them all in. *Note Include::. For 3168-example: 3169- 3170- sources = foo.c bar.c 3171- 3172- include $(sources:.c=.d) 3173- 3174-(This example uses a substitution variable reference to translate the 3175-list of source files `foo.c bar.c' into a list of prerequisite 3176-makefiles, `foo.d bar.d'. *Note Substitution Refs::, for full 3177-information on substitution references.) Since the `.d' files are 3178-makefiles like any others, `make' will remake them as necessary with no 3179-further work from you. *Note Remaking Makefiles::. 3180- 3181- Note that the `.d' files contain target definitions; you should be 3182-sure to place the `include' directive _after_ the first, default goal 3183-in your makefiles or run the risk of having a random object file become 3184-the default goal. *Note How Make Works::. 3185- 3186- 3187-File: make.info, Node: Commands, Next: Using Variables, Prev: Rules, Up: Top 3188- 3189-5 Writing the Commands in Rules 3190-******************************* 3191- 3192-The commands of a rule consist of one or more shell command lines to be 3193-executed, one at a time, in the order they appear. Typically, the 3194-result of executing these commands is that the target of the rule is 3195-brought up to date. 3196- 3197- Users use many different shell programs, but commands in makefiles 3198-are always interpreted by `/bin/sh' unless the makefile specifies 3199-otherwise. *Note Command Execution: Execution. 3200- 3201-* Menu: 3202- 3203-* Command Syntax:: Command syntax features and pitfalls. 3204-* Echoing:: How to control when commands are echoed. 3205-* Execution:: How commands are executed. 3206-* Parallel:: How commands can be executed in parallel. 3207-* Errors:: What happens after a command execution error. 3208-* Interrupts:: What happens when a command is interrupted. 3209-* Recursion:: Invoking `make' from makefiles. 3210-* Sequences:: Defining canned sequences of commands. 3211-* Empty Commands:: Defining useful, do-nothing commands. 3212- 3213- 3214-File: make.info, Node: Command Syntax, Next: Echoing, Prev: Commands, Up: Commands 3215- 3216-5.1 Command Syntax 3217-================== 3218- 3219-Makefiles have the unusual property that there are really two distinct 3220-syntaxes in one file. Most of the makefile uses `make' syntax (*note 3221-Writing Makefiles: Makefiles.). However, commands are meant to be 3222-interpreted by the shell and so they are written using shell syntax. 3223-The `make' program does not try to understand shell syntax: it performs 3224-only a very few specific translations on the content of the command 3225-before handing it to the shell. 3226- 3227- Each command line must start with a tab, except that the first 3228-command line may be attached to the target-and-prerequisites line with a 3229-semicolon in between. _Any_ line in the makefile that begins with a 3230-tab and appears in a "rule context" (that is, after a rule has been 3231-started until another rule or variable definition) will be considered a 3232-command line for that rule. Blank lines and lines of just comments may 3233-appear among the command lines; they are ignored. 3234- 3235- Some consequences of these rules include: 3236- 3237- * A blank line that begins with a tab is not blank: it's an empty 3238- command (*note Empty Commands::). 3239- 3240- * A comment in a command line is not a `make' comment; it will be 3241- passed to the shell as-is. Whether the shell treats it as a 3242- comment or not depends on your shell. 3243- 3244- * A variable definition in a "rule context" which is indented by a 3245- tab as the first character on the line, will be considered a 3246- command line, not a `make' variable definition, and passed to the 3247- shell. 3248- 3249- * A conditional expression (`ifdef', `ifeq', etc. *note Syntax of 3250- Conditionals: Conditional Syntax.) in a "rule context" which is 3251- indented by a tab as the first character on the line, will be 3252- considered a command line and be passed to the shell. 3253- 3254- 3255-* Menu: 3256- 3257-* Splitting Lines:: Breaking long command lines for readability. 3258-* Variables in Commands:: Using `make' variables in commands. 3259- 3260- 3261-File: make.info, Node: Splitting Lines, Next: Variables in Commands, Prev: Command Syntax, Up: Command Syntax 3262- 3263-5.1.1 Splitting Command Lines 3264------------------------------ 3265- 3266-One of the few ways in which `make' does interpret command lines is 3267-checking for a backslash just before the newline. As in normal 3268-makefile syntax, a single command can be split into multiple lines in 3269-the makefile by placing a backslash before each newline. A sequence of 3270-lines like this is considered a single command, and one instance of the 3271-shell will be invoked to run it. 3272- 3273- However, in contrast to how they are treated in other places in a 3274-makefile, backslash-newline pairs are _not_ removed from the command. 3275-Both the backslash and the newline characters are preserved and passed 3276-to the shell. How the backslash-newline is interpreted depends on your 3277-shell. If the first character of the next line after the 3278-backslash-newline is a tab, then that tab (and only that tab) is 3279-removed. Whitespace is never added to the command. 3280- 3281- For example, this makefile: 3282- 3283- all : 3284- @echo no\ 3285- space 3286- @echo no\ 3287- space 3288- @echo one \ 3289- space 3290- @echo one\ 3291- space 3292- 3293-consists of four separate shell commands where the output is: 3294- 3295- nospace 3296- nospace 3297- one space 3298- one space 3299- 3300- As a more complex example, this makefile: 3301- 3302- all : ; @echo 'hello \ 3303- world' ; echo "hello \ 3304- world" 3305- 3306-will run one shell with a command script of: 3307- 3308- echo 'hello \ 3309- world' ; echo "hello \ 3310- world" 3311- 3312-which, according to shell quoting rules, will yield the following 3313-output: 3314- 3315- hello \ 3316- world 3317- hello world 3318- 3319-Notice how the backslash/newline pair was removed inside the string 3320-quoted with double quotes (`"..."'), but not from the string quoted 3321-with single quotes (`'...''). This is the way the default shell 3322-(`/bin/sh') handles backslash/newline pairs. If you specify a 3323-different shell in your makefiles it may treat them differently. 3324- 3325- Sometimes you want to split a long line inside of single quotes, but 3326-you don't want the backslash-newline to appear in the quoted content. 3327-This is often the case when passing scripts to languages such as Perl, 3328-where extraneous backslashes inside the script can change its meaning 3329-or even be a syntax error. One simple way of handling this is to place 3330-the quoted string, or even the entire command, into a `make' variable 3331-then use the variable in the command. In this situation the newline 3332-quoting rules for makefiles will be used, and the backslash-newline 3333-will be removed. If we rewrite our example above using this method: 3334- 3335- HELLO = 'hello \ 3336- world' 3337- 3338- all : ; @echo $(HELLO) 3339- 3340-we will get output like this: 3341- 3342- hello world 3343- 3344- If you like, you can also use target-specific variables (*note 3345-Target-specific Variable Values: Target-specific.) to obtain a tighter 3346-correspondence between the variable and the command that uses it. 3347- 3348- 3349-File: make.info, Node: Variables in Commands, Prev: Splitting Lines, Up: Command Syntax 3350- 3351-5.1.2 Using Variables in Commands 3352---------------------------------- 3353- 3354-The other way in which `make' processes commands is by expanding any 3355-variable references in them (*note Basics of Variable References: 3356-Reference.). This occurs after make has finished reading all the 3357-makefiles and the target is determined to be out of date; so, the 3358-commands for targets which are not rebuilt are never expanded. 3359- 3360- Variable and function references in commands have identical syntax 3361-and semantics to references elsewhere in the makefile. They also have 3362-the same quoting rules: if you want a dollar sign to appear in your 3363-command, you must double it (`$$'). For shells like the default shell, 3364-that use dollar signs to introduce variables, it's important to keep 3365-clear in your mind whether the variable you want to reference is a 3366-`make' variable (use a single dollar sign) or a shell variable (use two 3367-dollar signs). For example: 3368- 3369- LIST = one two three 3370- all: 3371- for i in $(LIST); do \ 3372- echo $$i; \ 3373- done 3374- 3375-results in the following command being passed to the shell: 3376- 3377- for i in one two three; do \ 3378- echo $i; \ 3379- done 3380- 3381-which generates the expected result: 3382- 3383- one 3384- two 3385- three 3386- 3387- 3388-File: make.info, Node: Echoing, Next: Execution, Prev: Command Syntax, Up: Commands 3389- 3390-5.2 Command Echoing 3391-=================== 3392- 3393-Normally `make' prints each command line before it is executed. We 3394-call this "echoing" because it gives the appearance that you are typing 3395-the commands yourself. 3396- 3397- When a line starts with `@', the echoing of that line is suppressed. 3398-The `@' is discarded before the command is passed to the shell. 3399-Typically you would use this for a command whose only effect is to print 3400-something, such as an `echo' command to indicate progress through the 3401-makefile: 3402- 3403- @echo About to make distribution files 3404- 3405- When `make' is given the flag `-n' or `--just-print' it only echoes 3406-commands, it won't execute them. *Note Summary of Options: Options 3407-Summary. In this case and only this case, even the commands starting 3408-with `@' are printed. This flag is useful for finding out which 3409-commands `make' thinks are necessary without actually doing them. 3410- 3411- The `-s' or `--silent' flag to `make' prevents all echoing, as if 3412-all commands started with `@'. A rule in the makefile for the special 3413-target `.SILENT' without prerequisites has the same effect (*note 3414-Special Built-in Target Names: Special Targets.). `.SILENT' is 3415-essentially obsolete since `@' is more flexible. 3416- 3417- 3418-File: make.info, Node: Execution, Next: Parallel, Prev: Echoing, Up: Commands 3419- 3420-5.3 Command Execution 3421-===================== 3422- 3423-When it is time to execute commands to update a target, they are 3424-executed by invoking a new subshell for each command line. (In 3425-practice, `make' may take shortcuts that do not affect the results.) 3426- 3427- *Please note:* this implies that setting shell variables and 3428-invoking shell commands such as `cd' that set a context local to each 3429-process will not affect the following command lines.(1) If you want to 3430-use `cd' to affect the next statement, put both statements in a single 3431-command line. Then `make' will invoke one shell to run the entire 3432-line, and the shell will execute the statements in sequence. For 3433-example: 3434- 3435- foo : bar/lose 3436- cd $(@D) && gobble $(@F) > ../$@ 3437- 3438-Here we use the shell AND operator (`&&') so that if the `cd' command 3439-fails, the script will fail without trying to invoke the `gobble' 3440-command in the wrong directory, which could cause problems (in this 3441-case it would certainly cause `../foo' to be truncated, at least). 3442- 3443-* Menu: 3444- 3445-* Choosing the Shell:: How `make' chooses the shell used 3446- to run commands. 3447- 3448- ---------- Footnotes ---------- 3449- 3450- (1) On MS-DOS, the value of current working directory is *global*, so 3451-changing it _will_ affect the following command lines on those systems. 3452- 3453- 3454-File: make.info, Node: Choosing the Shell, Prev: Execution, Up: Execution 3455- 3456-5.3.1 Choosing the Shell 3457------------------------- 3458- 3459-The program used as the shell is taken from the variable `SHELL'. If 3460-this variable is not set in your makefile, the program `/bin/sh' is 3461-used as the shell. 3462- 3463- Unlike most variables, the variable `SHELL' is never set from the 3464-environment. This is because the `SHELL' environment variable is used 3465-to specify your personal choice of shell program for interactive use. 3466-It would be very bad for personal choices like this to affect the 3467-functioning of makefiles. *Note Variables from the Environment: 3468-Environment. 3469- 3470- Furthermore, when you do set `SHELL' in your makefile that value is 3471-_not_ exported in the environment to commands that `make' invokes. 3472-Instead, the value inherited from the user's environment, if any, is 3473-exported. You can override this behavior by explicitly exporting 3474-`SHELL' (*note Communicating Variables to a Sub-`make': 3475-Variables/Recursion.), forcing it to be passed in the environment to 3476-commands. 3477- 3478- However, on MS-DOS and MS-Windows the value of `SHELL' in the 3479-environment *is* used, since on those systems most users do not set 3480-this variable, and therefore it is most likely set specifically to be 3481-used by `make'. On MS-DOS, if the setting of `SHELL' is not suitable 3482-for `make', you can set the variable `MAKESHELL' to the shell that 3483-`make' should use; if set it will be used as the shell instead of the 3484-value of `SHELL'. 3485- 3486-Choosing a Shell in DOS and Windows 3487-................................... 3488- 3489-Choosing a shell in MS-DOS and MS-Windows is much more complex than on 3490-other systems. 3491- 3492- On MS-DOS, if `SHELL' is not set, the value of the variable 3493-`COMSPEC' (which is always set) is used instead. 3494- 3495- The processing of lines that set the variable `SHELL' in Makefiles 3496-is different on MS-DOS. The stock shell, `command.com', is 3497-ridiculously limited in its functionality and many users of `make' tend 3498-to install a replacement shell. Therefore, on MS-DOS, `make' examines 3499-the value of `SHELL', and changes its behavior based on whether it 3500-points to a Unix-style or DOS-style shell. This allows reasonable 3501-functionality even if `SHELL' points to `command.com'. 3502- 3503- If `SHELL' points to a Unix-style shell, `make' on MS-DOS 3504-additionally checks whether that shell can indeed be found; if not, it 3505-ignores the line that sets `SHELL'. In MS-DOS, GNU `make' searches for 3506-the shell in the following places: 3507- 3508- 1. In the precise place pointed to by the value of `SHELL'. For 3509- example, if the makefile specifies `SHELL = /bin/sh', `make' will 3510- look in the directory `/bin' on the current drive. 3511- 3512- 2. In the current directory. 3513- 3514- 3. In each of the directories in the `PATH' variable, in order. 3515- 3516- 3517- In every directory it examines, `make' will first look for the 3518-specific file (`sh' in the example above). If this is not found, it 3519-will also look in that directory for that file with one of the known 3520-extensions which identify executable files. For example `.exe', 3521-`.com', `.bat', `.btm', `.sh', and some others. 3522- 3523- If any of these attempts is successful, the value of `SHELL' will be 3524-set to the full pathname of the shell as found. However, if none of 3525-these is found, the value of `SHELL' will not be changed, and thus the 3526-line that sets it will be effectively ignored. This is so `make' will 3527-only support features specific to a Unix-style shell if such a shell is 3528-actually installed on the system where `make' runs. 3529- 3530- Note that this extended search for the shell is limited to the cases 3531-where `SHELL' is set from the Makefile; if it is set in the environment 3532-or command line, you are expected to set it to the full pathname of the 3533-shell, exactly as things are on Unix. 3534- 3535- The effect of the above DOS-specific processing is that a Makefile 3536-that contains `SHELL = /bin/sh' (as many Unix makefiles do), will work 3537-on MS-DOS unaltered if you have e.g. `sh.exe' installed in some 3538-directory along your `PATH'. 3539- 3540- 3541-File: make.info, Node: Parallel, Next: Errors, Prev: Execution, Up: Commands 3542- 3543-5.4 Parallel Execution 3544-====================== 3545- 3546-GNU `make' knows how to execute several commands at once. Normally, 3547-`make' will execute only one command at a time, waiting for it to 3548-finish before executing the next. However, the `-j' or `--jobs' option 3549-tells `make' to execute many commands simultaneously. 3550- 3551- On MS-DOS, the `-j' option has no effect, since that system doesn't 3552-support multi-processing. 3553- 3554- If the `-j' option is followed by an integer, this is the number of 3555-commands to execute at once; this is called the number of "job slots". 3556-If there is nothing looking like an integer after the `-j' option, 3557-there is no limit on the number of job slots. The default number of job 3558-slots is one, which means serial execution (one thing at a time). 3559- 3560- One unpleasant consequence of running several commands 3561-simultaneously is that output generated by the commands appears 3562-whenever each command sends it, so messages from different commands may 3563-be interspersed. 3564- 3565- Another problem is that two processes cannot both take input from the 3566-same device; so to make sure that only one command tries to take input 3567-from the terminal at once, `make' will invalidate the standard input 3568-streams of all but one running command. This means that attempting to 3569-read from standard input will usually be a fatal error (a `Broken pipe' 3570-signal) for most child processes if there are several. 3571- 3572- It is unpredictable which command will have a valid standard input 3573-stream (which will come from the terminal, or wherever you redirect the 3574-standard input of `make'). The first command run will always get it 3575-first, and the first command started after that one finishes will get 3576-it next, and so on. 3577- 3578- We will change how this aspect of `make' works if we find a better 3579-alternative. In the mean time, you should not rely on any command using 3580-standard input at all if you are using the parallel execution feature; 3581-but if you are not using this feature, then standard input works 3582-normally in all commands. 3583- 3584- Finally, handling recursive `make' invocations raises issues. For 3585-more information on this, see *Note Communicating Options to a 3586-Sub-`make': Options/Recursion. 3587- 3588- If a command fails (is killed by a signal or exits with a nonzero 3589-status), and errors are not ignored for that command (*note Errors in 3590-Commands: Errors.), the remaining command lines to remake the same 3591-target will not be run. If a command fails and the `-k' or 3592-`--keep-going' option was not given (*note Summary of Options: Options 3593-Summary.), `make' aborts execution. If make terminates for any reason 3594-(including a signal) with child processes running, it waits for them to 3595-finish before actually exiting. 3596- 3597- When the system is heavily loaded, you will probably want to run 3598-fewer jobs than when it is lightly loaded. You can use the `-l' option 3599-to tell `make' to limit the number of jobs to run at once, based on the 3600-load average. The `-l' or `--max-load' option is followed by a 3601-floating-point number. For example, 3602- 3603- -l 2.5 3604- 3605-will not let `make' start more than one job if the load average is 3606-above 2.5. The `-l' option with no following number removes the load 3607-limit, if one was given with a previous `-l' option. 3608- 3609- More precisely, when `make' goes to start up a job, and it already 3610-has at least one job running, it checks the current load average; if it 3611-is not lower than the limit given with `-l', `make' waits until the load 3612-average goes below that limit, or until all the other jobs finish. 3613- 3614- By default, there is no load limit. 3615- 3616- 3617-File: make.info, Node: Errors, Next: Interrupts, Prev: Parallel, Up: Commands 3618- 3619-5.5 Errors in Commands 3620-====================== 3621- 3622-After each shell command returns, `make' looks at its exit status. If 3623-the command completed successfully, the next command line is executed 3624-in a new shell; after the last command line is finished, the rule is 3625-finished. 3626- 3627- If there is an error (the exit status is nonzero), `make' gives up on 3628-the current rule, and perhaps on all rules. 3629- 3630- Sometimes the failure of a certain command does not indicate a 3631-problem. For example, you may use the `mkdir' command to ensure that a 3632-directory exists. If the directory already exists, `mkdir' will report 3633-an error, but you probably want `make' to continue regardless. 3634- 3635- To ignore errors in a command line, write a `-' at the beginning of 3636-the line's text (after the initial tab). The `-' is discarded before 3637-the command is passed to the shell for execution. 3638- 3639- For example, 3640- 3641- clean: 3642- -rm -f *.o 3643- 3644-This causes `rm' to continue even if it is unable to remove a file. 3645- 3646- When you run `make' with the `-i' or `--ignore-errors' flag, errors 3647-are ignored in all commands of all rules. A rule in the makefile for 3648-the special target `.IGNORE' has the same effect, if there are no 3649-prerequisites. These ways of ignoring errors are obsolete because `-' 3650-is more flexible. 3651- 3652- When errors are to be ignored, because of either a `-' or the `-i' 3653-flag, `make' treats an error return just like success, except that it 3654-prints out a message that tells you the status code the command exited 3655-with, and says that the error has been ignored. 3656- 3657- When an error happens that `make' has not been told to ignore, it 3658-implies that the current target cannot be correctly remade, and neither 3659-can any other that depends on it either directly or indirectly. No 3660-further commands will be executed for these targets, since their 3661-preconditions have not been achieved. 3662- 3663- Normally `make' gives up immediately in this circumstance, returning 3664-a nonzero status. However, if the `-k' or `--keep-going' flag is 3665-specified, `make' continues to consider the other prerequisites of the 3666-pending targets, remaking them if necessary, before it gives up and 3667-returns nonzero status. For example, after an error in compiling one 3668-object file, `make -k' will continue compiling other object files even 3669-though it already knows that linking them will be impossible. *Note 3670-Summary of Options: Options Summary. 3671- 3672- The usual behavior assumes that your purpose is to get the specified 3673-targets up to date; once `make' learns that this is impossible, it 3674-might as well report the failure immediately. The `-k' option says 3675-that the real purpose is to test as many of the changes made in the 3676-program as possible, perhaps to find several independent problems so 3677-that you can correct them all before the next attempt to compile. This 3678-is why Emacs' `compile' command passes the `-k' flag by default. 3679- 3680- Usually when a command fails, if it has changed the target file at 3681-all, the file is corrupted and cannot be used--or at least it is not 3682-completely updated. Yet the file's time stamp says that it is now up to 3683-date, so the next time `make' runs, it will not try to update that 3684-file. The situation is just the same as when the command is killed by a 3685-signal; *note Interrupts::. So generally the right thing to do is to 3686-delete the target file if the command fails after beginning to change 3687-the file. `make' will do this if `.DELETE_ON_ERROR' appears as a 3688-target. This is almost always what you want `make' to do, but it is 3689-not historical practice; so for compatibility, you must explicitly 3690-request it. 3691- 3692- 3693-File: make.info, Node: Interrupts, Next: Recursion, Prev: Errors, Up: Commands 3694- 3695-5.6 Interrupting or Killing `make' 3696-================================== 3697- 3698-If `make' gets a fatal signal while a command is executing, it may 3699-delete the target file that the command was supposed to update. This is 3700-done if the target file's last-modification time has changed since 3701-`make' first checked it. 3702- 3703- The purpose of deleting the target is to make sure that it is remade 3704-from scratch when `make' is next run. Why is this? Suppose you type 3705-`Ctrl-c' while a compiler is running, and it has begun to write an 3706-object file `foo.o'. The `Ctrl-c' kills the compiler, resulting in an 3707-incomplete file whose last-modification time is newer than the source 3708-file `foo.c'. But `make' also receives the `Ctrl-c' signal and deletes 3709-this incomplete file. If `make' did not do this, the next invocation 3710-of `make' would think that `foo.o' did not require updating--resulting 3711-in a strange error message from the linker when it tries to link an 3712-object file half of which is missing. 3713- 3714- You can prevent the deletion of a target file in this way by making 3715-the special target `.PRECIOUS' depend on it. Before remaking a target, 3716-`make' checks to see whether it appears on the prerequisites of 3717-`.PRECIOUS', and thereby decides whether the target should be deleted 3718-if a signal happens. Some reasons why you might do this are that the 3719-target is updated in some atomic fashion, or exists only to record a 3720-modification-time (its contents do not matter), or must exist at all 3721-times to prevent other sorts of trouble. 3722- 3723- 3724-File: make.info, Node: Recursion, Next: Sequences, Prev: Interrupts, Up: Commands 3725- 3726-5.7 Recursive Use of `make' 3727-=========================== 3728- 3729-Recursive use of `make' means using `make' as a command in a makefile. 3730-This technique is useful when you want separate makefiles for various 3731-subsystems that compose a larger system. For example, suppose you have 3732-a subdirectory `subdir' which has its own makefile, and you would like 3733-the containing directory's makefile to run `make' on the subdirectory. 3734-You can do it by writing this: 3735- 3736- subsystem: 3737- cd subdir && $(MAKE) 3738- 3739-or, equivalently, this (*note Summary of Options: Options Summary.): 3740- 3741- subsystem: 3742- $(MAKE) -C subdir 3743- 3744- You can write recursive `make' commands just by copying this example, 3745-but there are many things to know about how they work and why, and about 3746-how the sub-`make' relates to the top-level `make'. You may also find 3747-it useful to declare targets that invoke recursive `make' commands as 3748-`.PHONY' (for more discussion on when this is useful, see *Note Phony 3749-Targets::). 3750- 3751- For your convenience, when GNU `make' starts (after it has processed 3752-any `-C' options) it sets the variable `CURDIR' to the pathname of the 3753-current working directory. This value is never touched by `make' 3754-again: in particular note that if you include files from other 3755-directories the value of `CURDIR' does not change. The value has the 3756-same precedence it would have if it were set in the makefile (by 3757-default, an environment variable `CURDIR' will not override this 3758-value). Note that setting this variable has no impact on the operation 3759-of `make' (it does not cause `make' to change its working directory, 3760-for example). 3761- 3762-* Menu: 3763- 3764-* MAKE Variable:: The special effects of using `$(MAKE)'. 3765-* Variables/Recursion:: How to communicate variables to a sub-`make'. 3766-* Options/Recursion:: How to communicate options to a sub-`make'. 3767-* -w Option:: How the `-w' or `--print-directory' option 3768- helps debug use of recursive `make' commands. 3769- 3770- 3771-File: make.info, Node: MAKE Variable, Next: Variables/Recursion, Prev: Recursion, Up: Recursion 3772- 3773-5.7.1 How the `MAKE' Variable Works 3774------------------------------------ 3775- 3776-Recursive `make' commands should always use the variable `MAKE', not 3777-the explicit command name `make', as shown here: 3778- 3779- subsystem: 3780- cd subdir && $(MAKE) 3781- 3782- The value of this variable is the file name with which `make' was 3783-invoked. If this file name was `/bin/make', then the command executed 3784-is `cd subdir && /bin/make'. If you use a special version of `make' to 3785-run the top-level makefile, the same special version will be executed 3786-for recursive invocations. 3787- 3788- As a special feature, using the variable `MAKE' in the commands of a 3789-rule alters the effects of the `-t' (`--touch'), `-n' (`--just-print'), 3790-or `-q' (`--question') option. Using the `MAKE' variable has the same 3791-effect as using a `+' character at the beginning of the command line. 3792-*Note Instead of Executing the Commands: Instead of Execution. This 3793-special feature is only enabled if the `MAKE' variable appears directly 3794-in the command script: it does not apply if the `MAKE' variable is 3795-referenced through expansion of another variable. In the latter case 3796-you must use the `+' token to get these special effects. 3797- 3798- Consider the command `make -t' in the above example. (The `-t' 3799-option marks targets as up to date without actually running any 3800-commands; see *Note Instead of Execution::.) Following the usual 3801-definition of `-t', a `make -t' command in the example would create a 3802-file named `subsystem' and do nothing else. What you really want it to 3803-do is run `cd subdir && make -t'; but that would require executing the 3804-command, and `-t' says not to execute commands. 3805- 3806- The special feature makes this do what you want: whenever a command 3807-line of a rule contains the variable `MAKE', the flags `-t', `-n' and 3808-`-q' do not apply to that line. Command lines containing `MAKE' are 3809-executed normally despite the presence of a flag that causes most 3810-commands not to be run. The usual `MAKEFLAGS' mechanism passes the 3811-flags to the sub-`make' (*note Communicating Options to a Sub-`make': 3812-Options/Recursion.), so your request to touch the files, or print the 3813-commands, is propagated to the subsystem. 3814- 3815- 3816-File: make.info, Node: Variables/Recursion, Next: Options/Recursion, Prev: MAKE Variable, Up: Recursion 3817- 3818-5.7.2 Communicating Variables to a Sub-`make' 3819---------------------------------------------- 3820- 3821-Variable values of the top-level `make' can be passed to the sub-`make' 3822-through the environment by explicit request. These variables are 3823-defined in the sub-`make' as defaults, but do not override what is 3824-specified in the makefile used by the sub-`make' makefile unless you 3825-use the `-e' switch (*note Summary of Options: Options Summary.). 3826- 3827- To pass down, or "export", a variable, `make' adds the variable and 3828-its value to the environment for running each command. The sub-`make', 3829-in turn, uses the environment to initialize its table of variable 3830-values. *Note Variables from the Environment: Environment. 3831- 3832- Except by explicit request, `make' exports a variable only if it is 3833-either defined in the environment initially or set on the command line, 3834-and if its name consists only of letters, numbers, and underscores. 3835-Some shells cannot cope with environment variable names consisting of 3836-characters other than letters, numbers, and underscores. 3837- 3838- The value of the `make' variable `SHELL' is not exported. Instead, 3839-the value of the `SHELL' variable from the invoking environment is 3840-passed to the sub-`make'. You can force `make' to export its value for 3841-`SHELL' by using the `export' directive, described below. *Note 3842-Choosing the Shell::. 3843- 3844- The special variable `MAKEFLAGS' is always exported (unless you 3845-unexport it). `MAKEFILES' is exported if you set it to anything. 3846- 3847- `make' automatically passes down variable values that were defined 3848-on the command line, by putting them in the `MAKEFLAGS' variable. 3849-*Note Options/Recursion::. 3850- 3851- Variables are _not_ normally passed down if they were created by 3852-default by `make' (*note Variables Used by Implicit Rules: Implicit 3853-Variables.). The sub-`make' will define these for itself. 3854- 3855- If you want to export specific variables to a sub-`make', use the 3856-`export' directive, like this: 3857- 3858- export VARIABLE ... 3859- 3860-If you want to _prevent_ a variable from being exported, use the 3861-`unexport' directive, like this: 3862- 3863- unexport VARIABLE ... 3864- 3865-In both of these forms, the arguments to `export' and `unexport' are 3866-expanded, and so could be variables or functions which expand to a 3867-(list of) variable names to be (un)exported. 3868- 3869- As a convenience, you can define a variable and export it at the same 3870-time by doing: 3871- 3872- export VARIABLE = value 3873- 3874-has the same result as: 3875- 3876- VARIABLE = value 3877- export VARIABLE 3878- 3879-and 3880- 3881- export VARIABLE := value 3882- 3883-has the same result as: 3884- 3885- VARIABLE := value 3886- export VARIABLE 3887- 3888- Likewise, 3889- 3890- export VARIABLE += value 3891- 3892-is just like: 3893- 3894- VARIABLE += value 3895- export VARIABLE 3896- 3897-*Note Appending More Text to Variables: Appending. 3898- 3899- You may notice that the `export' and `unexport' directives work in 3900-`make' in the same way they work in the shell, `sh'. 3901- 3902- If you want all variables to be exported by default, you can use 3903-`export' by itself: 3904- 3905- export 3906- 3907-This tells `make' that variables which are not explicitly mentioned in 3908-an `export' or `unexport' directive should be exported. Any variable 3909-given in an `unexport' directive will still _not_ be exported. If you 3910-use `export' by itself to export variables by default, variables whose 3911-names contain characters other than alphanumerics and underscores will 3912-not be exported unless specifically mentioned in an `export' directive. 3913- 3914- The behavior elicited by an `export' directive by itself was the 3915-default in older versions of GNU `make'. If your makefiles depend on 3916-this behavior and you want to be compatible with old versions of 3917-`make', you can write a rule for the special target 3918-`.EXPORT_ALL_VARIABLES' instead of using the `export' directive. This 3919-will be ignored by old `make's, while the `export' directive will cause 3920-a syntax error. 3921- 3922- Likewise, you can use `unexport' by itself to tell `make' _not_ to 3923-export variables by default. Since this is the default behavior, you 3924-would only need to do this if `export' had been used by itself earlier 3925-(in an included makefile, perhaps). You *cannot* use `export' and 3926-`unexport' by themselves to have variables exported for some commands 3927-and not for others. The last `export' or `unexport' directive that 3928-appears by itself determines the behavior for the entire run of `make'. 3929- 3930- As a special feature, the variable `MAKELEVEL' is changed when it is 3931-passed down from level to level. This variable's value is a string 3932-which is the depth of the level as a decimal number. The value is `0' 3933-for the top-level `make'; `1' for a sub-`make', `2' for a 3934-sub-sub-`make', and so on. The incrementation happens when `make' sets 3935-up the environment for a command. 3936- 3937- The main use of `MAKELEVEL' is to test it in a conditional directive 3938-(*note Conditional Parts of Makefiles: Conditionals.); this way you can 3939-write a makefile that behaves one way if run recursively and another 3940-way if run directly by you. 3941- 3942- You can use the variable `MAKEFILES' to cause all sub-`make' 3943-commands to use additional makefiles. The value of `MAKEFILES' is a 3944-whitespace-separated list of file names. This variable, if defined in 3945-the outer-level makefile, is passed down through the environment; then 3946-it serves as a list of extra makefiles for the sub-`make' to read 3947-before the usual or specified ones. *Note The Variable `MAKEFILES': 3948-MAKEFILES Variable. 3949- 3950- 3951-File: make.info, Node: Options/Recursion, Next: -w Option, Prev: Variables/Recursion, Up: Recursion 3952- 3953-5.7.3 Communicating Options to a Sub-`make' 3954-------------------------------------------- 3955- 3956-Flags such as `-s' and `-k' are passed automatically to the sub-`make' 3957-through the variable `MAKEFLAGS'. This variable is set up 3958-automatically by `make' to contain the flag letters that `make' 3959-received. Thus, if you do `make -ks' then `MAKEFLAGS' gets the value 3960-`ks'. 3961- 3962- As a consequence, every sub-`make' gets a value for `MAKEFLAGS' in 3963-its environment. In response, it takes the flags from that value and 3964-processes them as if they had been given as arguments. *Note Summary 3965-of Options: Options Summary. 3966- 3967- Likewise variables defined on the command line are passed to the 3968-sub-`make' through `MAKEFLAGS'. Words in the value of `MAKEFLAGS' that 3969-contain `=', `make' treats as variable definitions just as if they 3970-appeared on the command line. *Note Overriding Variables: Overriding. 3971- 3972- The options `-C', `-f', `-o', and `-W' are not put into `MAKEFLAGS'; 3973-these options are not passed down. 3974- 3975- The `-j' option is a special case (*note Parallel Execution: 3976-Parallel.). If you set it to some numeric value `N' and your operating 3977-system supports it (most any UNIX system will; others typically won't), 3978-the parent `make' and all the sub-`make's will communicate to ensure 3979-that there are only `N' jobs running at the same time between them all. 3980-Note that any job that is marked recursive (*note Instead of Executing 3981-the Commands: Instead of Execution.) doesn't count against the total 3982-jobs (otherwise we could get `N' sub-`make's running and have no slots 3983-left over for any real work!) 3984- 3985- If your operating system doesn't support the above communication, 3986-then `-j 1' is always put into `MAKEFLAGS' instead of the value you 3987-specified. This is because if the `-j' option were passed down to 3988-sub-`make's, you would get many more jobs running in parallel than you 3989-asked for. If you give `-j' with no numeric argument, meaning to run 3990-as many jobs as possible in parallel, this is passed down, since 3991-multiple infinities are no more than one. 3992- 3993- If you do not want to pass the other flags down, you must change the 3994-value of `MAKEFLAGS', like this: 3995- 3996- subsystem: 3997- cd subdir && $(MAKE) MAKEFLAGS= 3998- 3999- The command line variable definitions really appear in the variable 4000-`MAKEOVERRIDES', and `MAKEFLAGS' contains a reference to this variable. 4001-If you do want to pass flags down normally, but don't want to pass 4002-down the command line variable definitions, you can reset 4003-`MAKEOVERRIDES' to empty, like this: 4004- 4005- MAKEOVERRIDES = 4006- 4007-This is not usually useful to do. However, some systems have a small 4008-fixed limit on the size of the environment, and putting so much 4009-information into the value of `MAKEFLAGS' can exceed it. If you see 4010-the error message `Arg list too long', this may be the problem. (For 4011-strict compliance with POSIX.2, changing `MAKEOVERRIDES' does not 4012-affect `MAKEFLAGS' if the special target `.POSIX' appears in the 4013-makefile. You probably do not care about this.) 4014- 4015- A similar variable `MFLAGS' exists also, for historical 4016-compatibility. It has the same value as `MAKEFLAGS' except that it 4017-does not contain the command line variable definitions, and it always 4018-begins with a hyphen unless it is empty (`MAKEFLAGS' begins with a 4019-hyphen only when it begins with an option that has no single-letter 4020-version, such as `--warn-undefined-variables'). `MFLAGS' was 4021-traditionally used explicitly in the recursive `make' command, like 4022-this: 4023- 4024- subsystem: 4025- cd subdir && $(MAKE) $(MFLAGS) 4026- 4027-but now `MAKEFLAGS' makes this usage redundant. If you want your 4028-makefiles to be compatible with old `make' programs, use this 4029-technique; it will work fine with more modern `make' versions too. 4030- 4031- The `MAKEFLAGS' variable can also be useful if you want to have 4032-certain options, such as `-k' (*note Summary of Options: Options 4033-Summary.), set each time you run `make'. You simply put a value for 4034-`MAKEFLAGS' in your environment. You can also set `MAKEFLAGS' in a 4035-makefile, to specify additional flags that should also be in effect for 4036-that makefile. (Note that you cannot use `MFLAGS' this way. That 4037-variable is set only for compatibility; `make' does not interpret a 4038-value you set for it in any way.) 4039- 4040- When `make' interprets the value of `MAKEFLAGS' (either from the 4041-environment or from a makefile), it first prepends a hyphen if the value 4042-does not already begin with one. Then it chops the value into words 4043-separated by blanks, and parses these words as if they were options 4044-given on the command line (except that `-C', `-f', `-h', `-o', `-W', 4045-and their long-named versions are ignored; and there is no error for an 4046-invalid option). 4047- 4048- If you do put `MAKEFLAGS' in your environment, you should be sure not 4049-to include any options that will drastically affect the actions of 4050-`make' and undermine the purpose of makefiles and of `make' itself. 4051-For instance, the `-t', `-n', and `-q' options, if put in one of these 4052-variables, could have disastrous consequences and would certainly have 4053-at least surprising and probably annoying effects. 4054- 4055- 4056-File: make.info, Node: -w Option, Prev: Options/Recursion, Up: Recursion 4057- 4058-5.7.4 The `--print-directory' Option 4059------------------------------------- 4060- 4061-If you use several levels of recursive `make' invocations, the `-w' or 4062-`--print-directory' option can make the output a lot easier to 4063-understand by showing each directory as `make' starts processing it and 4064-as `make' finishes processing it. For example, if `make -w' is run in 4065-the directory `/u/gnu/make', `make' will print a line of the form: 4066- 4067- make: Entering directory `/u/gnu/make'. 4068- 4069-before doing anything else, and a line of the form: 4070- 4071- make: Leaving directory `/u/gnu/make'. 4072- 4073-when processing is completed. 4074- 4075- Normally, you do not need to specify this option because `make' does 4076-it for you: `-w' is turned on automatically when you use the `-C' 4077-option, and in sub-`make's. `make' will not automatically turn on `-w' 4078-if you also use `-s', which says to be silent, or if you use 4079-`--no-print-directory' to explicitly disable it. 4080- 4081- 4082-File: make.info, Node: Sequences, Next: Empty Commands, Prev: Recursion, Up: Commands 4083- 4084-5.8 Defining Canned Command Sequences 4085-===================================== 4086- 4087-When the same sequence of commands is useful in making various targets, 4088-you can define it as a canned sequence with the `define' directive, and 4089-refer to the canned sequence from the rules for those targets. The 4090-canned sequence is actually a variable, so the name must not conflict 4091-with other variable names. 4092- 4093- Here is an example of defining a canned sequence of commands: 4094- 4095- define run-yacc 4096- yacc $(firstword $^) 4097- mv y.tab.c $@ 4098- endef 4099- 4100-Here `run-yacc' is the name of the variable being defined; `endef' 4101-marks the end of the definition; the lines in between are the commands. 4102-The `define' directive does not expand variable references and 4103-function calls in the canned sequence; the `$' characters, parentheses, 4104-variable names, and so on, all become part of the value of the variable 4105-you are defining. *Note Defining Variables Verbatim: Defining, for a 4106-complete explanation of `define'. 4107- 4108- The first command in this example runs Yacc on the first 4109-prerequisite of whichever rule uses the canned sequence. The output 4110-file from Yacc is always named `y.tab.c'. The second command moves the 4111-output to the rule's target file name. 4112- 4113- To use the canned sequence, substitute the variable into the 4114-commands of a rule. You can substitute it like any other variable 4115-(*note Basics of Variable References: Reference.). Because variables 4116-defined by `define' are recursively expanded variables, all the 4117-variable references you wrote inside the `define' are expanded now. 4118-For example: 4119- 4120- foo.c : foo.y 4121- $(run-yacc) 4122- 4123-`foo.y' will be substituted for the variable `$^' when it occurs in 4124-`run-yacc''s value, and `foo.c' for `$@'. 4125- 4126- This is a realistic example, but this particular one is not needed in 4127-practice because `make' has an implicit rule to figure out these 4128-commands based on the file names involved (*note Using Implicit Rules: 4129-Implicit Rules.). 4130- 4131- In command execution, each line of a canned sequence is treated just 4132-as if the line appeared on its own in the rule, preceded by a tab. In 4133-particular, `make' invokes a separate subshell for each line. You can 4134-use the special prefix characters that affect command lines (`@', `-', 4135-and `+') on each line of a canned sequence. *Note Writing the Commands 4136-in Rules: Commands. For example, using this canned sequence: 4137- 4138- define frobnicate 4139- @echo "frobnicating target $@" 4140- frob-step-1 $< -o $@-step-1 4141- frob-step-2 $@-step-1 -o $@ 4142- endef 4143- 4144-`make' will not echo the first line, the `echo' command. But it _will_ 4145-echo the following two command lines. 4146- 4147- On the other hand, prefix characters on the command line that refers 4148-to a canned sequence apply to every line in the sequence. So the rule: 4149- 4150- frob.out: frob.in 4151- @$(frobnicate) 4152- 4153-does not echo _any_ commands. (*Note Command Echoing: Echoing, for a 4154-full explanation of `@'.) 4155- 4156- 4157-File: make.info, Node: Empty Commands, Prev: Sequences, Up: Commands 4158- 4159-5.9 Using Empty Commands 4160-======================== 4161- 4162-It is sometimes useful to define commands which do nothing. This is 4163-done simply by giving a command that consists of nothing but 4164-whitespace. For example: 4165- 4166- target: ; 4167- 4168-defines an empty command string for `target'. You could also use a 4169-line beginning with a tab character to define an empty command string, 4170-but this would be confusing because such a line looks empty. 4171- 4172- You may be wondering why you would want to define a command string 4173-that does nothing. The only reason this is useful is to prevent a 4174-target from getting implicit commands (from implicit rules or the 4175-`.DEFAULT' special target; *note Implicit Rules:: and *note Defining 4176-Last-Resort Default Rules: Last Resort.). 4177- 4178- You may be inclined to define empty command strings for targets that 4179-are not actual files, but only exist so that their prerequisites can be 4180-remade. However, this is not the best way to do that, because the 4181-prerequisites may not be remade properly if the target file actually 4182-does exist. *Note Phony Targets: Phony Targets, for a better way to do 4183-this. 4184- 4185- 4186-File: make.info, Node: Using Variables, Next: Conditionals, Prev: Commands, Up: Top 4187- 4188-6 How to Use Variables 4189-********************** 4190- 4191-A "variable" is a name defined in a makefile to represent a string of 4192-text, called the variable's "value". These values are substituted by 4193-explicit request into targets, prerequisites, commands, and other parts 4194-of the makefile. (In some other versions of `make', variables are 4195-called "macros".) 4196- 4197- Variables and functions in all parts of a makefile are expanded when 4198-read, except for the shell commands in rules, the right-hand sides of 4199-variable definitions using `=', and the bodies of variable definitions 4200-using the `define' directive. 4201- 4202- Variables can represent lists of file names, options to pass to 4203-compilers, programs to run, directories to look in for source files, 4204-directories to write output in, or anything else you can imagine. 4205- 4206- A variable name may be any sequence of characters not containing `:', 4207-`#', `=', or leading or trailing whitespace. However, variable names 4208-containing characters other than letters, numbers, and underscores 4209-should be avoided, as they may be given special meanings in the future, 4210-and with some shells they cannot be passed through the environment to a 4211-sub-`make' (*note Communicating Variables to a Sub-`make': 4212-Variables/Recursion.). 4213- 4214- Variable names are case-sensitive. The names `foo', `FOO', and 4215-`Foo' all refer to different variables. 4216- 4217- It is traditional to use upper case letters in variable names, but we 4218-recommend using lower case letters for variable names that serve 4219-internal purposes in the makefile, and reserving upper case for 4220-parameters that control implicit rules or for parameters that the user 4221-should override with command options (*note Overriding Variables: 4222-Overriding.). 4223- 4224- A few variables have names that are a single punctuation character or 4225-just a few characters. These are the "automatic variables", and they 4226-have particular specialized uses. *Note Automatic Variables::. 4227- 4228-* Menu: 4229- 4230-* Reference:: How to use the value of a variable. 4231-* Flavors:: Variables come in two flavors. 4232-* Advanced:: Advanced features for referencing a variable. 4233-* Values:: All the ways variables get their values. 4234-* Setting:: How to set a variable in the makefile. 4235-* Appending:: How to append more text to the old value 4236- of a variable. 4237-* Override Directive:: How to set a variable in the makefile even if 4238- the user has set it with a command argument. 4239-* Defining:: An alternate way to set a variable 4240- to a verbatim string. 4241-* Environment:: Variable values can come from the environment. 4242-* Target-specific:: Variable values can be defined on a per-target 4243- basis. 4244-* Pattern-specific:: Target-specific variable values can be applied 4245- to a group of targets that match a pattern. 4246- 4247- 4248-File: make.info, Node: Reference, Next: Flavors, Prev: Using Variables, Up: Using Variables 4249- 4250-6.1 Basics of Variable References 4251-================================= 4252- 4253-To substitute a variable's value, write a dollar sign followed by the 4254-name of the variable in parentheses or braces: either `$(foo)' or 4255-`${foo}' is a valid reference to the variable `foo'. This special 4256-significance of `$' is why you must write `$$' to have the effect of a 4257-single dollar sign in a file name or command. 4258- 4259- Variable references can be used in any context: targets, 4260-prerequisites, commands, most directives, and new variable values. 4261-Here is an example of a common case, where a variable holds the names 4262-of all the object files in a program: 4263- 4264- objects = program.o foo.o utils.o 4265- program : $(objects) 4266- cc -o program $(objects) 4267- 4268- $(objects) : defs.h 4269- 4270- Variable references work by strict textual substitution. Thus, the 4271-rule 4272- 4273- foo = c 4274- prog.o : prog.$(foo) 4275- $(foo)$(foo) -$(foo) prog.$(foo) 4276- 4277-could be used to compile a C program `prog.c'. Since spaces before the 4278-variable value are ignored in variable assignments, the value of `foo' 4279-is precisely `c'. (Don't actually write your makefiles this way!) 4280- 4281- A dollar sign followed by a character other than a dollar sign, 4282-open-parenthesis or open-brace treats that single character as the 4283-variable name. Thus, you could reference the variable `x' with `$x'. 4284-However, this practice is strongly discouraged, except in the case of 4285-the automatic variables (*note Automatic Variables::). 4286- 4287- 4288-File: make.info, Node: Flavors, Next: Advanced, Prev: Reference, Up: Using Variables 4289- 4290-6.2 The Two Flavors of Variables 4291-================================ 4292- 4293-There are two ways that a variable in GNU `make' can have a value; we 4294-call them the two "flavors" of variables. The two flavors are 4295-distinguished in how they are defined and in what they do when expanded. 4296- 4297- The first flavor of variable is a "recursively expanded" variable. 4298-Variables of this sort are defined by lines using `=' (*note Setting 4299-Variables: Setting.) or by the `define' directive (*note Defining 4300-Variables Verbatim: Defining.). The value you specify is installed 4301-verbatim; if it contains references to other variables, these 4302-references are expanded whenever this variable is substituted (in the 4303-course of expanding some other string). When this happens, it is 4304-called "recursive expansion". 4305- 4306- For example, 4307- 4308- foo = $(bar) 4309- bar = $(ugh) 4310- ugh = Huh? 4311- 4312- all:;echo $(foo) 4313- 4314-will echo `Huh?': `$(foo)' expands to `$(bar)' which expands to 4315-`$(ugh)' which finally expands to `Huh?'. 4316- 4317- This flavor of variable is the only sort supported by other versions 4318-of `make'. It has its advantages and its disadvantages. An advantage 4319-(most would say) is that: 4320- 4321- CFLAGS = $(include_dirs) -O 4322- include_dirs = -Ifoo -Ibar 4323- 4324-will do what was intended: when `CFLAGS' is expanded in a command, it 4325-will expand to `-Ifoo -Ibar -O'. A major disadvantage is that you 4326-cannot append something on the end of a variable, as in 4327- 4328- CFLAGS = $(CFLAGS) -O 4329- 4330-because it will cause an infinite loop in the variable expansion. 4331-(Actually `make' detects the infinite loop and reports an error.) 4332- 4333- Another disadvantage is that any functions (*note Functions for 4334-Transforming Text: Functions.) referenced in the definition will be 4335-executed every time the variable is expanded. This makes `make' run 4336-slower; worse, it causes the `wildcard' and `shell' functions to give 4337-unpredictable results because you cannot easily control when they are 4338-called, or even how many times. 4339- 4340- To avoid all the problems and inconveniences of recursively expanded 4341-variables, there is another flavor: simply expanded variables. 4342- 4343- "Simply expanded variables" are defined by lines using `:=' (*note 4344-Setting Variables: Setting.). The value of a simply expanded variable 4345-is scanned once and for all, expanding any references to other 4346-variables and functions, when the variable is defined. The actual 4347-value of the simply expanded variable is the result of expanding the 4348-text that you write. It does not contain any references to other 4349-variables; it contains their values _as of the time this variable was 4350-defined_. Therefore, 4351- 4352- x := foo 4353- y := $(x) bar 4354- x := later 4355- 4356-is equivalent to 4357- 4358- y := foo bar 4359- x := later 4360- 4361- When a simply expanded variable is referenced, its value is 4362-substituted verbatim. 4363- 4364- Here is a somewhat more complicated example, illustrating the use of 4365-`:=' in conjunction with the `shell' function. (*Note The `shell' 4366-Function: Shell Function.) This example also shows use of the variable 4367-`MAKELEVEL', which is changed when it is passed down from level to 4368-level. (*Note Communicating Variables to a Sub-`make': 4369-Variables/Recursion, for information about `MAKELEVEL'.) 4370- 4371- ifeq (0,${MAKELEVEL}) 4372- whoami := $(shell whoami) 4373- host-type := $(shell arch) 4374- MAKE := ${MAKE} host-type=${host-type} whoami=${whoami} 4375- endif 4376- 4377-An advantage of this use of `:=' is that a typical `descend into a 4378-directory' command then looks like this: 4379- 4380- ${subdirs}: 4381- ${MAKE} -C $@ all 4382- 4383- Simply expanded variables generally make complicated makefile 4384-programming more predictable because they work like variables in most 4385-programming languages. They allow you to redefine a variable using its 4386-own value (or its value processed in some way by one of the expansion 4387-functions) and to use the expansion functions much more efficiently 4388-(*note Functions for Transforming Text: Functions.). 4389- 4390- You can also use them to introduce controlled leading whitespace into 4391-variable values. Leading whitespace characters are discarded from your 4392-input before substitution of variable references and function calls; 4393-this means you can include leading spaces in a variable value by 4394-protecting them with variable references, like this: 4395- 4396- nullstring := 4397- space := $(nullstring) # end of the line 4398- 4399-Here the value of the variable `space' is precisely one space. The 4400-comment `# end of the line' is included here just for clarity. Since 4401-trailing space characters are _not_ stripped from variable values, just 4402-a space at the end of the line would have the same effect (but be 4403-rather hard to read). If you put whitespace at the end of a variable 4404-value, it is a good idea to put a comment like that at the end of the 4405-line to make your intent clear. Conversely, if you do _not_ want any 4406-whitespace characters at the end of your variable value, you must 4407-remember not to put a random comment on the end of the line after some 4408-whitespace, such as this: 4409- 4410- dir := /foo/bar # directory to put the frobs in 4411- 4412-Here the value of the variable `dir' is `/foo/bar ' (with four 4413-trailing spaces), which was probably not the intention. (Imagine 4414-something like `$(dir)/file' with this definition!) 4415- 4416- There is another assignment operator for variables, `?='. This is 4417-called a conditional variable assignment operator, because it only has 4418-an effect if the variable is not yet defined. This statement: 4419- 4420- FOO ?= bar 4421- 4422-is exactly equivalent to this (*note The `origin' Function: Origin 4423-Function.): 4424- 4425- ifeq ($(origin FOO), undefined) 4426- FOO = bar 4427- endif 4428- 4429- Note that a variable set to an empty value is still defined, so `?=' 4430-will not set that variable. 4431- 4432- 4433-File: make.info, Node: Advanced, Next: Values, Prev: Flavors, Up: Using Variables 4434- 4435-6.3 Advanced Features for Reference to Variables 4436-================================================ 4437- 4438-This section describes some advanced features you can use to reference 4439-variables in more flexible ways. 4440- 4441-* Menu: 4442- 4443-* Substitution Refs:: Referencing a variable with 4444- substitutions on the value. 4445-* Computed Names:: Computing the name of the variable to refer to. 4446- 4447- 4448-File: make.info, Node: Substitution Refs, Next: Computed Names, Prev: Advanced, Up: Advanced 4449- 4450-6.3.1 Substitution References 4451------------------------------ 4452- 4453-A "substitution reference" substitutes the value of a variable with 4454-alterations that you specify. It has the form `$(VAR:A=B)' (or 4455-`${VAR:A=B}') and its meaning is to take the value of the variable VAR, 4456-replace every A at the end of a word with B in that value, and 4457-substitute the resulting string. 4458- 4459- When we say "at the end of a word", we mean that A must appear 4460-either followed by whitespace or at the end of the value in order to be 4461-replaced; other occurrences of A in the value are unaltered. For 4462-example: 4463- 4464- foo := a.o b.o c.o 4465- bar := $(foo:.o=.c) 4466- 4467-sets `bar' to `a.c b.c c.c'. *Note Setting Variables: Setting. 4468- 4469- A substitution reference is actually an abbreviation for use of the 4470-`patsubst' expansion function (*note Functions for String Substitution 4471-and Analysis: Text Functions.). We provide substitution references as 4472-well as `patsubst' for compatibility with other implementations of 4473-`make'. 4474- 4475- Another type of substitution reference lets you use the full power of 4476-the `patsubst' function. It has the same form `$(VAR:A=B)' described 4477-above, except that now A must contain a single `%' character. This 4478-case is equivalent to `$(patsubst A,B,$(VAR))'. *Note Functions for 4479-String Substitution and Analysis: Text Functions, for a description of 4480-the `patsubst' function. 4481- 4482-For example: 4483- 4484- foo := a.o b.o c.o 4485- bar := $(foo:%.o=%.c) 4486- 4487-sets `bar' to `a.c b.c c.c'. 4488- 4489- 4490-File: make.info, Node: Computed Names, Prev: Substitution Refs, Up: Advanced 4491- 4492-6.3.2 Computed Variable Names 4493------------------------------ 4494- 4495-Computed variable names are a complicated concept needed only for 4496-sophisticated makefile programming. For most purposes you need not 4497-consider them, except to know that making a variable with a dollar sign 4498-in its name might have strange results. However, if you are the type 4499-that wants to understand everything, or you are actually interested in 4500-what they do, read on. 4501- 4502- Variables may be referenced inside the name of a variable. This is 4503-called a "computed variable name" or a "nested variable reference". 4504-For example, 4505- 4506- x = y 4507- y = z 4508- a := $($(x)) 4509- 4510-defines `a' as `z': the `$(x)' inside `$($(x))' expands to `y', so 4511-`$($(x))' expands to `$(y)' which in turn expands to `z'. Here the 4512-name of the variable to reference is not stated explicitly; it is 4513-computed by expansion of `$(x)'. The reference `$(x)' here is nested 4514-within the outer variable reference. 4515- 4516- The previous example shows two levels of nesting, but any number of 4517-levels is possible. For example, here are three levels: 4518- 4519- x = y 4520- y = z 4521- z = u 4522- a := $($($(x))) 4523- 4524-Here the innermost `$(x)' expands to `y', so `$($(x))' expands to 4525-`$(y)' which in turn expands to `z'; now we have `$(z)', which becomes 4526-`u'. 4527- 4528- References to recursively-expanded variables within a variable name 4529-are reexpanded in the usual fashion. For example: 4530- 4531- x = $(y) 4532- y = z 4533- z = Hello 4534- a := $($(x)) 4535- 4536-defines `a' as `Hello': `$($(x))' becomes `$($(y))' which becomes 4537-`$(z)' which becomes `Hello'. 4538- 4539- Nested variable references can also contain modified references and 4540-function invocations (*note Functions for Transforming Text: 4541-Functions.), just like any other reference. For example, using the 4542-`subst' function (*note Functions for String Substitution and Analysis: 4543-Text Functions.): 4544- 4545- x = variable1 4546- variable2 := Hello 4547- y = $(subst 1,2,$(x)) 4548- z = y 4549- a := $($($(z))) 4550- 4551-eventually defines `a' as `Hello'. It is doubtful that anyone would 4552-ever want to write a nested reference as convoluted as this one, but it 4553-works: `$($($(z)))' expands to `$($(y))' which becomes `$($(subst 4554-1,2,$(x)))'. This gets the value `variable1' from `x' and changes it 4555-by substitution to `variable2', so that the entire string becomes 4556-`$(variable2)', a simple variable reference whose value is `Hello'. 4557- 4558- A computed variable name need not consist entirely of a single 4559-variable reference. It can contain several variable references, as 4560-well as some invariant text. For example, 4561- 4562- a_dirs := dira dirb 4563- 1_dirs := dir1 dir2 4564- 4565- a_files := filea fileb 4566- 1_files := file1 file2 4567- 4568- ifeq "$(use_a)" "yes" 4569- a1 := a 4570- else 4571- a1 := 1 4572- endif 4573- 4574- ifeq "$(use_dirs)" "yes" 4575- df := dirs 4576- else 4577- df := files 4578- endif 4579- 4580- dirs := $($(a1)_$(df)) 4581- 4582-will give `dirs' the same value as `a_dirs', `1_dirs', `a_files' or 4583-`1_files' depending on the settings of `use_a' and `use_dirs'. 4584- 4585- Computed variable names can also be used in substitution references: 4586- 4587- a_objects := a.o b.o c.o 4588- 1_objects := 1.o 2.o 3.o 4589- 4590- sources := $($(a1)_objects:.o=.c) 4591- 4592-defines `sources' as either `a.c b.c c.c' or `1.c 2.c 3.c', depending 4593-on the value of `a1'. 4594- 4595- The only restriction on this sort of use of nested variable 4596-references is that they cannot specify part of the name of a function 4597-to be called. This is because the test for a recognized function name 4598-is done before the expansion of nested references. For example, 4599- 4600- ifdef do_sort 4601- func := sort 4602- else 4603- func := strip 4604- endif 4605- 4606- bar := a d b g q c 4607- 4608- foo := $($(func) $(bar)) 4609- 4610-attempts to give `foo' the value of the variable `sort a d b g q c' or 4611-`strip a d b g q c', rather than giving `a d b g q c' as the argument 4612-to either the `sort' or the `strip' function. This restriction could 4613-be removed in the future if that change is shown to be a good idea. 4614- 4615- You can also use computed variable names in the left-hand side of a 4616-variable assignment, or in a `define' directive, as in: 4617- 4618- dir = foo 4619- $(dir)_sources := $(wildcard $(dir)/*.c) 4620- define $(dir)_print 4621- lpr $($(dir)_sources) 4622- endef 4623- 4624-This example defines the variables `dir', `foo_sources', and 4625-`foo_print'. 4626- 4627- Note that "nested variable references" are quite different from 4628-"recursively expanded variables" (*note The Two Flavors of Variables: 4629-Flavors.), though both are used together in complex ways when doing 4630-makefile programming. 4631- 4632- 4633-File: make.info, Node: Values, Next: Setting, Prev: Advanced, Up: Using Variables 4634- 4635-6.4 How Variables Get Their Values 4636-================================== 4637- 4638-Variables can get values in several different ways: 4639- 4640- * You can specify an overriding value when you run `make'. *Note 4641- Overriding Variables: Overriding. 4642- 4643- * You can specify a value in the makefile, either with an assignment 4644- (*note Setting Variables: Setting.) or with a verbatim definition 4645- (*note Defining Variables Verbatim: Defining.). 4646- 4647- * Variables in the environment become `make' variables. *Note 4648- Variables from the Environment: Environment. 4649- 4650- * Several "automatic" variables are given new values for each rule. 4651- Each of these has a single conventional use. *Note Automatic 4652- Variables::. 4653- 4654- * Several variables have constant initial values. *Note Variables 4655- Used by Implicit Rules: Implicit Variables. 4656- 4657- 4658-File: make.info, Node: Setting, Next: Appending, Prev: Values, Up: Using Variables 4659- 4660-6.5 Setting Variables 4661-===================== 4662- 4663-To set a variable from the makefile, write a line starting with the 4664-variable name followed by `=' or `:='. Whatever follows the `=' or 4665-`:=' on the line becomes the value. For example, 4666- 4667- objects = main.o foo.o bar.o utils.o 4668- 4669-defines a variable named `objects'. Whitespace around the variable 4670-name and immediately after the `=' is ignored. 4671- 4672- Variables defined with `=' are "recursively expanded" variables. 4673-Variables defined with `:=' are "simply expanded" variables; these 4674-definitions can contain variable references which will be expanded 4675-before the definition is made. *Note The Two Flavors of Variables: 4676-Flavors. 4677- 4678- The variable name may contain function and variable references, which 4679-are expanded when the line is read to find the actual variable name to 4680-use. 4681- 4682- There is no limit on the length of the value of a variable except the 4683-amount of swapping space on the computer. When a variable definition is 4684-long, it is a good idea to break it into several lines by inserting 4685-backslash-newline at convenient places in the definition. This will not 4686-affect the functioning of `make', but it will make the makefile easier 4687-to read. 4688- 4689- Most variable names are considered to have the empty string as a 4690-value if you have never set them. Several variables have built-in 4691-initial values that are not empty, but you can set them in the usual 4692-ways (*note Variables Used by Implicit Rules: Implicit Variables.). 4693-Several special variables are set automatically to a new value for each 4694-rule; these are called the "automatic" variables (*note Automatic 4695-Variables::). 4696- 4697- If you'd like a variable to be set to a value only if it's not 4698-already set, then you can use the shorthand operator `?=' instead of 4699-`='. These two settings of the variable `FOO' are identical (*note The 4700-`origin' Function: Origin Function.): 4701- 4702- FOO ?= bar 4703- 4704-and 4705- 4706- ifeq ($(origin FOO), undefined) 4707- FOO = bar 4708- endif 4709- 4710- 4711-File: make.info, Node: Appending, Next: Override Directive, Prev: Setting, Up: Using Variables 4712- 4713-6.6 Appending More Text to Variables 4714-==================================== 4715- 4716-Often it is useful to add more text to the value of a variable already 4717-defined. You do this with a line containing `+=', like this: 4718- 4719- objects += another.o 4720- 4721-This takes the value of the variable `objects', and adds the text 4722-`another.o' to it (preceded by a single space). Thus: 4723- 4724- objects = main.o foo.o bar.o utils.o 4725- objects += another.o 4726- 4727-sets `objects' to `main.o foo.o bar.o utils.o another.o'. 4728- 4729- Using `+=' is similar to: 4730- 4731- objects = main.o foo.o bar.o utils.o 4732- objects := $(objects) another.o 4733- 4734-but differs in ways that become important when you use more complex 4735-values. 4736- 4737- When the variable in question has not been defined before, `+=' acts 4738-just like normal `=': it defines a recursively-expanded variable. 4739-However, when there _is_ a previous definition, exactly what `+=' does 4740-depends on what flavor of variable you defined originally. *Note The 4741-Two Flavors of Variables: Flavors, for an explanation of the two 4742-flavors of variables. 4743- 4744- When you add to a variable's value with `+=', `make' acts 4745-essentially as if you had included the extra text in the initial 4746-definition of the variable. If you defined it first with `:=', making 4747-it a simply-expanded variable, `+=' adds to that simply-expanded 4748-definition, and expands the new text before appending it to the old 4749-value just as `:=' does (see *Note Setting Variables: Setting, for a 4750-full explanation of `:='). In fact, 4751- 4752- variable := value 4753- variable += more 4754- 4755-is exactly equivalent to: 4756- 4757- 4758- variable := value 4759- variable := $(variable) more 4760- 4761- On the other hand, when you use `+=' with a variable that you defined 4762-first to be recursively-expanded using plain `=', `make' does something 4763-a bit different. Recall that when you define a recursively-expanded 4764-variable, `make' does not expand the value you set for variable and 4765-function references immediately. Instead it stores the text verbatim, 4766-and saves these variable and function references to be expanded later, 4767-when you refer to the new variable (*note The Two Flavors of Variables: 4768-Flavors.). When you use `+=' on a recursively-expanded variable, it is 4769-this unexpanded text to which `make' appends the new text you specify. 4770- 4771- variable = value 4772- variable += more 4773- 4774-is roughly equivalent to: 4775- 4776- temp = value 4777- variable = $(temp) more 4778- 4779-except that of course it never defines a variable called `temp'. The 4780-importance of this comes when the variable's old value contains 4781-variable references. Take this common example: 4782- 4783- CFLAGS = $(includes) -O 4784- ... 4785- CFLAGS += -pg # enable profiling 4786- 4787-The first line defines the `CFLAGS' variable with a reference to another 4788-variable, `includes'. (`CFLAGS' is used by the rules for C 4789-compilation; *note Catalogue of Implicit Rules: Catalogue of Rules.) 4790-Using `=' for the definition makes `CFLAGS' a recursively-expanded 4791-variable, meaning `$(includes) -O' is _not_ expanded when `make' 4792-processes the definition of `CFLAGS'. Thus, `includes' need not be 4793-defined yet for its value to take effect. It only has to be defined 4794-before any reference to `CFLAGS'. If we tried to append to the value 4795-of `CFLAGS' without using `+=', we might do it like this: 4796- 4797- CFLAGS := $(CFLAGS) -pg # enable profiling 4798- 4799-This is pretty close, but not quite what we want. Using `:=' redefines 4800-`CFLAGS' as a simply-expanded variable; this means `make' expands the 4801-text `$(CFLAGS) -pg' before setting the variable. If `includes' is not 4802-yet defined, we get ` -O -pg', and a later definition of `includes' 4803-will have no effect. Conversely, by using `+=' we set `CFLAGS' to the 4804-_unexpanded_ value `$(includes) -O -pg'. Thus we preserve the 4805-reference to `includes', so if that variable gets defined at any later 4806-point, a reference like `$(CFLAGS)' still uses its value. 4807- 4808- 4809-File: make.info, Node: Override Directive, Next: Defining, Prev: Appending, Up: Using Variables 4810- 4811-6.7 The `override' Directive 4812-============================ 4813- 4814-If a variable has been set with a command argument (*note Overriding 4815-Variables: Overriding.), then ordinary assignments in the makefile are 4816-ignored. If you want to set the variable in the makefile even though 4817-it was set with a command argument, you can use an `override' 4818-directive, which is a line that looks like this: 4819- 4820- override VARIABLE = VALUE 4821- 4822-or 4823- 4824- override VARIABLE := VALUE 4825- 4826- To append more text to a variable defined on the command line, use: 4827- 4828- override VARIABLE += MORE TEXT 4829- 4830-*Note Appending More Text to Variables: Appending. 4831- 4832- The `override' directive was not invented for escalation in the war 4833-between makefiles and command arguments. It was invented so you can 4834-alter and add to values that the user specifies with command arguments. 4835- 4836- For example, suppose you always want the `-g' switch when you run the 4837-C compiler, but you would like to allow the user to specify the other 4838-switches with a command argument just as usual. You could use this 4839-`override' directive: 4840- 4841- override CFLAGS += -g 4842- 4843- You can also use `override' directives with `define' directives. 4844-This is done as you might expect: 4845- 4846- override define foo 4847- bar 4848- endef 4849- 4850-*Note Defining Variables Verbatim: Defining. 4851- 4852- 4853-File: make.info, Node: Defining, Next: Environment, Prev: Override Directive, Up: Using Variables 4854- 4855-6.8 Defining Variables Verbatim 4856-=============================== 4857- 4858-Another way to set the value of a variable is to use the `define' 4859-directive. This directive has an unusual syntax which allows newline 4860-characters to be included in the value, which is convenient for defining 4861-both canned sequences of commands (*note Defining Canned Command 4862-Sequences: Sequences.), and also sections of makefile syntax to use 4863-with `eval' (*note Eval Function::). 4864- 4865- The `define' directive is followed on the same line by the name of 4866-the variable and nothing more. The value to give the variable appears 4867-on the following lines. The end of the value is marked by a line 4868-containing just the word `endef'. Aside from this difference in 4869-syntax, `define' works just like `=': it creates a recursively-expanded 4870-variable (*note The Two Flavors of Variables: Flavors.). The variable 4871-name may contain function and variable references, which are expanded 4872-when the directive is read to find the actual variable name to use. 4873- 4874- You may nest `define' directives: `make' will keep track of nested 4875-directives and report an error if they are not all properly closed with 4876-`endef'. Note that lines beginning with tab characters are considered 4877-part of a command script, so any `define' or `endef' strings appearing 4878-on such a line will not be considered `make' operators. 4879- 4880- define two-lines 4881- echo foo 4882- echo $(bar) 4883- endef 4884- 4885- The value in an ordinary assignment cannot contain a newline; but the 4886-newlines that separate the lines of the value in a `define' become part 4887-of the variable's value (except for the final newline which precedes 4888-the `endef' and is not considered part of the value). 4889- 4890- When used in a command script, the previous example is functionally 4891-equivalent to this: 4892- 4893- two-lines = echo foo; echo $(bar) 4894- 4895-since two commands separated by semicolon behave much like two separate 4896-shell commands. However, note that using two separate lines means 4897-`make' will invoke the shell twice, running an independent subshell for 4898-each line. *Note Command Execution: Execution. 4899- 4900- If you want variable definitions made with `define' to take 4901-precedence over command-line variable definitions, you can use the 4902-`override' directive together with `define': 4903- 4904- override define two-lines 4905- foo 4906- $(bar) 4907- endef 4908- 4909-*Note The `override' Directive: Override Directive. 4910- 4911- 4912-File: make.info, Node: Environment, Next: Target-specific, Prev: Defining, Up: Using Variables 4913- 4914-6.9 Variables from the Environment 4915-================================== 4916- 4917-Variables in `make' can come from the environment in which `make' is 4918-run. Every environment variable that `make' sees when it starts up is 4919-transformed into a `make' variable with the same name and value. 4920-However, an explicit assignment in the makefile, or with a command 4921-argument, overrides the environment. (If the `-e' flag is specified, 4922-then values from the environment override assignments in the makefile. 4923-*Note Summary of Options: Options Summary. But this is not recommended 4924-practice.) 4925- 4926- Thus, by setting the variable `CFLAGS' in your environment, you can 4927-cause all C compilations in most makefiles to use the compiler switches 4928-you prefer. This is safe for variables with standard or conventional 4929-meanings because you know that no makefile will use them for other 4930-things. (Note this is not totally reliable; some makefiles set 4931-`CFLAGS' explicitly and therefore are not affected by the value in the 4932-environment.) 4933- 4934- When `make' runs a command script, variables defined in the makefile 4935-are placed into the environment of that command. This allows you to 4936-pass values to sub-`make' invocations (*note Recursive Use of `make': 4937-Recursion.). By default, only variables that came from the environment 4938-or the command line are passed to recursive invocations. You can use 4939-the `export' directive to pass other variables. *Note Communicating 4940-Variables to a Sub-`make': Variables/Recursion, for full details. 4941- 4942- Other use of variables from the environment is not recommended. It 4943-is not wise for makefiles to depend for their functioning on 4944-environment variables set up outside their control, since this would 4945-cause different users to get different results from the same makefile. 4946-This is against the whole purpose of most makefiles. 4947- 4948- Such problems would be especially likely with the variable `SHELL', 4949-which is normally present in the environment to specify the user's 4950-choice of interactive shell. It would be very undesirable for this 4951-choice to affect `make'; so, `make' handles the `SHELL' environment 4952-variable in a special way; see *Note Choosing the Shell::. 4953- 4954- 4955-File: make.info, Node: Target-specific, Next: Pattern-specific, Prev: Environment, Up: Using Variables 4956- 4957-6.10 Target-specific Variable Values 4958-==================================== 4959- 4960-Variable values in `make' are usually global; that is, they are the 4961-same regardless of where they are evaluated (unless they're reset, of 4962-course). One exception to that is automatic variables (*note Automatic 4963-Variables::). 4964- 4965- The other exception is "target-specific variable values". This 4966-feature allows you to define different values for the same variable, 4967-based on the target that `make' is currently building. As with 4968-automatic variables, these values are only available within the context 4969-of a target's command script (and in other target-specific assignments). 4970- 4971- Set a target-specific variable value like this: 4972- 4973- TARGET ... : VARIABLE-ASSIGNMENT 4974- 4975-or like this: 4976- 4977- TARGET ... : override VARIABLE-ASSIGNMENT 4978- 4979-or like this: 4980- 4981- TARGET ... : export VARIABLE-ASSIGNMENT 4982- 4983- Multiple TARGET values create a target-specific variable value for 4984-each member of the target list individually. 4985- 4986- The VARIABLE-ASSIGNMENT can be any valid form of assignment; 4987-recursive (`='), static (`:='), appending (`+='), or conditional 4988-(`?='). All variables that appear within the VARIABLE-ASSIGNMENT are 4989-evaluated within the context of the target: thus, any 4990-previously-defined target-specific variable values will be in effect. 4991-Note that this variable is actually distinct from any "global" value: 4992-the two variables do not have to have the same flavor (recursive vs. 4993-static). 4994- 4995- Target-specific variables have the same priority as any other 4996-makefile variable. Variables provided on the command-line (and in the 4997-environment if the `-e' option is in force) will take precedence. 4998-Specifying the `override' directive will allow the target-specific 4999-variable value to be preferred. 5000- 5001- There is one more special feature of target-specific variables: when 5002-you define a target-specific variable that variable value is also in 5003-effect for all prerequisites of this target, and all their 5004-prerequisites, etc. (unless those prerequisites override that variable 5005-with their own target-specific variable value). So, for example, a 5006-statement like this: 5007- 5008- prog : CFLAGS = -g 5009- prog : prog.o foo.o bar.o 5010- 5011-will set `CFLAGS' to `-g' in the command script for `prog', but it will 5012-also set `CFLAGS' to `-g' in the command scripts that create `prog.o', 5013-`foo.o', and `bar.o', and any command scripts which create their 5014-prerequisites. 5015- 5016- Be aware that a given prerequisite will only be built once per 5017-invocation of make, at most. If the same file is a prerequisite of 5018-multiple targets, and each of those targets has a different value for 5019-the same target-specific variable, then the first target to be built 5020-will cause that prerequisite to be built and the prerequisite will 5021-inherit the target-specific value from the first target. It will 5022-ignore the target-specific values from any other targets. 5023- 5024- 5025-File: make.info, Node: Pattern-specific, Prev: Target-specific, Up: Using Variables 5026- 5027-6.11 Pattern-specific Variable Values 5028-===================================== 5029- 5030-In addition to target-specific variable values (*note Target-specific 5031-Variable Values: Target-specific.), GNU `make' supports 5032-pattern-specific variable values. In this form, the variable is 5033-defined for any target that matches the pattern specified. If a target 5034-matches more than one pattern, all the matching pattern-specific 5035-variables are interpreted in the order in which they were defined in 5036-the makefile, and collected together into one set. Variables defined 5037-in this way are searched after any target-specific variables defined 5038-explicitly for that target, and before target-specific variables 5039-defined for the parent target. 5040- 5041- Set a pattern-specific variable value like this: 5042- 5043- PATTERN ... : VARIABLE-ASSIGNMENT 5044- 5045-or like this: 5046- 5047- PATTERN ... : override VARIABLE-ASSIGNMENT 5048- 5049-where PATTERN is a %-pattern. As with target-specific variable values, 5050-multiple PATTERN values create a pattern-specific variable value for 5051-each pattern individually. The VARIABLE-ASSIGNMENT can be any valid 5052-form of assignment. Any command-line variable setting will take 5053-precedence, unless `override' is specified. 5054- 5055- For example: 5056- 5057- %.o : CFLAGS = -O 5058- 5059-will assign `CFLAGS' the value of `-O' for all targets matching the 5060-pattern `%.o'. 5061- 5062- 5063-File: make.info, Node: Conditionals, Next: Functions, Prev: Using Variables, Up: Top 5064- 5065-7 Conditional Parts of Makefiles 5066-******************************** 5067- 5068-A "conditional" causes part of a makefile to be obeyed or ignored 5069-depending on the values of variables. Conditionals can compare the 5070-value of one variable to another, or the value of a variable to a 5071-constant string. Conditionals control what `make' actually "sees" in 5072-the makefile, so they _cannot_ be used to control shell commands at the 5073-time of execution. 5074- 5075-* Menu: 5076- 5077-* Conditional Example:: Example of a conditional 5078-* Conditional Syntax:: The syntax of conditionals. 5079-* Testing Flags:: Conditionals that test flags. 5080- 5081- 5082-File: make.info, Node: Conditional Example, Next: Conditional Syntax, Prev: Conditionals, Up: Conditionals 5083- 5084-7.1 Example of a Conditional 5085-============================ 5086- 5087-The following example of a conditional tells `make' to use one set of 5088-libraries if the `CC' variable is `gcc', and a different set of 5089-libraries otherwise. It works by controlling which of two command 5090-lines will be used as the command for a rule. The result is that 5091-`CC=gcc' as an argument to `make' changes not only which compiler is 5092-used but also which libraries are linked. 5093- 5094- libs_for_gcc = -lgnu 5095- normal_libs = 5096- 5097- foo: $(objects) 5098- ifeq ($(CC),gcc) 5099- $(CC) -o foo $(objects) $(libs_for_gcc) 5100- else 5101- $(CC) -o foo $(objects) $(normal_libs) 5102- endif 5103- 5104- This conditional uses three directives: one `ifeq', one `else' and 5105-one `endif'. 5106- 5107- The `ifeq' directive begins the conditional, and specifies the 5108-condition. It contains two arguments, separated by a comma and 5109-surrounded by parentheses. Variable substitution is performed on both 5110-arguments and then they are compared. The lines of the makefile 5111-following the `ifeq' are obeyed if the two arguments match; otherwise 5112-they are ignored. 5113- 5114- The `else' directive causes the following lines to be obeyed if the 5115-previous conditional failed. In the example above, this means that the 5116-second alternative linking command is used whenever the first 5117-alternative is not used. It is optional to have an `else' in a 5118-conditional. 5119- 5120- The `endif' directive ends the conditional. Every conditional must 5121-end with an `endif'. Unconditional makefile text follows. 5122- 5123- As this example illustrates, conditionals work at the textual level: 5124-the lines of the conditional are treated as part of the makefile, or 5125-ignored, according to the condition. This is why the larger syntactic 5126-units of the makefile, such as rules, may cross the beginning or the 5127-end of the conditional. 5128- 5129- When the variable `CC' has the value `gcc', the above example has 5130-this effect: 5131- 5132- foo: $(objects) 5133- $(CC) -o foo $(objects) $(libs_for_gcc) 5134- 5135-When the variable `CC' has any other value, the effect is this: 5136- 5137- foo: $(objects) 5138- $(CC) -o foo $(objects) $(normal_libs) 5139- 5140- Equivalent results can be obtained in another way by 5141-conditionalizing a variable assignment and then using the variable 5142-unconditionally: 5143- 5144- libs_for_gcc = -lgnu 5145- normal_libs = 5146- 5147- ifeq ($(CC),gcc) 5148- libs=$(libs_for_gcc) 5149- else 5150- libs=$(normal_libs) 5151- endif 5152- 5153- foo: $(objects) 5154- $(CC) -o foo $(objects) $(libs) 5155- 5156- 5157-File: make.info, Node: Conditional Syntax, Next: Testing Flags, Prev: Conditional Example, Up: Conditionals 5158- 5159-7.2 Syntax of Conditionals 5160-========================== 5161- 5162-The syntax of a simple conditional with no `else' is as follows: 5163- 5164- CONDITIONAL-DIRECTIVE 5165- TEXT-IF-TRUE 5166- endif 5167- 5168-The TEXT-IF-TRUE may be any lines of text, to be considered as part of 5169-the makefile if the condition is true. If the condition is false, no 5170-text is used instead. 5171- 5172- The syntax of a complex conditional is as follows: 5173- 5174- CONDITIONAL-DIRECTIVE 5175- TEXT-IF-TRUE 5176- else 5177- TEXT-IF-FALSE 5178- endif 5179- 5180- or: 5181- 5182- CONDITIONAL-DIRECTIVE 5183- TEXT-IF-ONE-IS-TRUE 5184- else CONDITIONAL-DIRECTIVE 5185- TEXT-IF-TRUE 5186- else 5187- TEXT-IF-FALSE 5188- endif 5189- 5190-There can be as many "`else' CONDITIONAL-DIRECTIVE" clauses as 5191-necessary. Once a given condition is true, TEXT-IF-TRUE is used and no 5192-other clause is used; if no condition is true then TEXT-IF-FALSE is 5193-used. The TEXT-IF-TRUE and TEXT-IF-FALSE can be any number of lines of 5194-text. 5195- 5196- The syntax of the CONDITIONAL-DIRECTIVE is the same whether the 5197-conditional is simple or complex; after an `else' or not. There are 5198-four different directives that test different conditions. Here is a 5199-table of them: 5200- 5201-`ifeq (ARG1, ARG2)' 5202-`ifeq 'ARG1' 'ARG2'' 5203-`ifeq "ARG1" "ARG2"' 5204-`ifeq "ARG1" 'ARG2'' 5205-`ifeq 'ARG1' "ARG2"' 5206- Expand all variable references in ARG1 and ARG2 and compare them. 5207- If they are identical, the TEXT-IF-TRUE is effective; otherwise, 5208- the TEXT-IF-FALSE, if any, is effective. 5209- 5210- Often you want to test if a variable has a non-empty value. When 5211- the value results from complex expansions of variables and 5212- functions, expansions you would consider empty may actually 5213- contain whitespace characters and thus are not seen as empty. 5214- However, you can use the `strip' function (*note Text Functions::) 5215- to avoid interpreting whitespace as a non-empty value. For 5216- example: 5217- 5218- ifeq ($(strip $(foo)),) 5219- TEXT-IF-EMPTY 5220- endif 5221- 5222- will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)' 5223- contains whitespace characters. 5224- 5225-`ifneq (ARG1, ARG2)' 5226-`ifneq 'ARG1' 'ARG2'' 5227-`ifneq "ARG1" "ARG2"' 5228-`ifneq "ARG1" 'ARG2'' 5229-`ifneq 'ARG1' "ARG2"' 5230- Expand all variable references in ARG1 and ARG2 and compare them. 5231- If they are different, the TEXT-IF-TRUE is effective; otherwise, 5232- the TEXT-IF-FALSE, if any, is effective. 5233- 5234-`ifdef VARIABLE-NAME' 5235- The `ifdef' form takes the _name_ of a variable as its argument, 5236- not a reference to a variable. The value of that variable has a 5237- non-empty value, the TEXT-IF-TRUE is effective; otherwise, the 5238- TEXT-IF-FALSE, if any, is effective. Variables that have never 5239- been defined have an empty value. The text VARIABLE-NAME is 5240- expanded, so it could be a variable or function that expands to 5241- the name of a variable. For example: 5242- 5243- bar = true 5244- foo = bar 5245- ifdef $(foo) 5246- frobozz = yes 5247- endif 5248- 5249- The variable reference `$(foo)' is expanded, yielding `bar', which 5250- is considered to be the name of a variable. The variable `bar' is 5251- not expanded, but its value is examined to determine if it is 5252- non-empty. 5253- 5254- Note that `ifdef' only tests whether a variable has a value. It 5255- does not expand the variable to see if that value is nonempty. 5256- Consequently, tests using `ifdef' return true for all definitions 5257- except those like `foo ='. To test for an empty value, use 5258- `ifeq ($(foo),)'. For example, 5259- 5260- bar = 5261- foo = $(bar) 5262- ifdef foo 5263- frobozz = yes 5264- else 5265- frobozz = no 5266- endif 5267- 5268- sets `frobozz' to `yes', while: 5269- 5270- foo = 5271- ifdef foo 5272- frobozz = yes 5273- else 5274- frobozz = no 5275- endif 5276- 5277- sets `frobozz' to `no'. 5278- 5279-`ifndef VARIABLE-NAME' 5280- If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE 5281- is effective; otherwise, the TEXT-IF-FALSE, if any, is effective. 5282- The rules for expansion and testing of VARIABLE-NAME are identical 5283- to the `ifdef' directive. 5284- 5285- Extra spaces are allowed and ignored at the beginning of the 5286-conditional directive line, but a tab is not allowed. (If the line 5287-begins with a tab, it will be considered a command for a rule.) Aside 5288-from this, extra spaces or tabs may be inserted with no effect anywhere 5289-except within the directive name or within an argument. A comment 5290-starting with `#' may appear at the end of the line. 5291- 5292- The other two directives that play a part in a conditional are `else' 5293-and `endif'. Each of these directives is written as one word, with no 5294-arguments. Extra spaces are allowed and ignored at the beginning of the 5295-line, and spaces or tabs at the end. A comment starting with `#' may 5296-appear at the end of the line. 5297- 5298- Conditionals affect which lines of the makefile `make' uses. If the 5299-condition is true, `make' reads the lines of the TEXT-IF-TRUE as part 5300-of the makefile; if the condition is false, `make' ignores those lines 5301-completely. It follows that syntactic units of the makefile, such as 5302-rules, may safely be split across the beginning or the end of the 5303-conditional. 5304- 5305- `make' evaluates conditionals when it reads a makefile. 5306-Consequently, you cannot use automatic variables in the tests of 5307-conditionals because they are not defined until commands are run (*note 5308-Automatic Variables::). 5309- 5310- To prevent intolerable confusion, it is not permitted to start a 5311-conditional in one makefile and end it in another. However, you may 5312-write an `include' directive within a conditional, provided you do not 5313-attempt to terminate the conditional inside the included file. 5314- 5315- 5316-File: make.info, Node: Testing Flags, Prev: Conditional Syntax, Up: Conditionals 5317- 5318-7.3 Conditionals that Test Flags 5319-================================ 5320- 5321-You can write a conditional that tests `make' command flags such as 5322-`-t' by using the variable `MAKEFLAGS' together with the `findstring' 5323-function (*note Functions for String Substitution and Analysis: Text 5324-Functions.). This is useful when `touch' is not enough to make a file 5325-appear up to date. 5326- 5327- The `findstring' function determines whether one string appears as a 5328-substring of another. If you want to test for the `-t' flag, use `t' 5329-as the first string and the value of `MAKEFLAGS' as the other. 5330- 5331- For example, here is how to arrange to use `ranlib -t' to finish 5332-marking an archive file up to date: 5333- 5334- archive.a: ... 5335- ifneq (,$(findstring t,$(MAKEFLAGS))) 5336- +touch archive.a 5337- +ranlib -t archive.a 5338- else 5339- ranlib archive.a 5340- endif 5341- 5342-The `+' prefix marks those command lines as "recursive" so that they 5343-will be executed despite use of the `-t' flag. *Note Recursive Use of 5344-`make': Recursion. 5345- 5346- 5347-File: make.info, Node: Functions, Next: Running, Prev: Conditionals, Up: Top 5348- 5349-8 Functions for Transforming Text 5350-********************************* 5351- 5352-"Functions" allow you to do text processing in the makefile to compute 5353-the files to operate on or the commands to use. You use a function in a 5354-"function call", where you give the name of the function and some text 5355-(the "arguments") for the function to operate on. The result of the 5356-function's processing is substituted into the makefile at the point of 5357-the call, just as a variable might be substituted. 5358- 5359-* Menu: 5360- 5361-* Syntax of Functions:: How to write a function call. 5362-* Text Functions:: General-purpose text manipulation functions. 5363-* File Name Functions:: Functions for manipulating file names. 5364-* Conditional Functions:: Functions that implement conditions. 5365-* Foreach Function:: Repeat some text with controlled variation. 5366-* Call Function:: Expand a user-defined function. 5367-* Value Function:: Return the un-expanded value of a variable. 5368-* Eval Function:: Evaluate the arguments as makefile syntax. 5369-* Origin Function:: Find where a variable got its value. 5370-* Flavor Function:: Find out the flavor of a variable. 5371-* Shell Function:: Substitute the output of a shell command. 5372-* Make Control Functions:: Functions that control how make runs. 5373- 5374- 5375-File: make.info, Node: Syntax of Functions, Next: Text Functions, Prev: Functions, Up: Functions 5376- 5377-8.1 Function Call Syntax 5378-======================== 5379- 5380-A function call resembles a variable reference. It looks like this: 5381- 5382- $(FUNCTION ARGUMENTS) 5383- 5384-or like this: 5385- 5386- ${FUNCTION ARGUMENTS} 5387- 5388- Here FUNCTION is a function name; one of a short list of names that 5389-are part of `make'. You can also essentially create your own functions 5390-by using the `call' builtin function. 5391- 5392- The ARGUMENTS are the arguments of the function. They are separated 5393-from the function name by one or more spaces or tabs, and if there is 5394-more than one argument, then they are separated by commas. Such 5395-whitespace and commas are not part of an argument's value. The 5396-delimiters which you use to surround the function call, whether 5397-parentheses or braces, can appear in an argument only in matching pairs; 5398-the other kind of delimiters may appear singly. If the arguments 5399-themselves contain other function calls or variable references, it is 5400-wisest to use the same kind of delimiters for all the references; write 5401-`$(subst a,b,$(x))', not `$(subst a,b,${x})'. This is because it is 5402-clearer, and because only one type of delimiter is matched to find the 5403-end of the reference. 5404- 5405- The text written for each argument is processed by substitution of 5406-variables and function calls to produce the argument value, which is 5407-the text on which the function acts. The substitution is done in the 5408-order in which the arguments appear. 5409- 5410- Commas and unmatched parentheses or braces cannot appear in the text 5411-of an argument as written; leading spaces cannot appear in the text of 5412-the first argument as written. These characters can be put into the 5413-argument value by variable substitution. First define variables 5414-`comma' and `space' whose values are isolated comma and space 5415-characters, then substitute these variables where such characters are 5416-wanted, like this: 5417- 5418- comma:= , 5419- empty:= 5420- space:= $(empty) $(empty) 5421- foo:= a b c 5422- bar:= $(subst $(space),$(comma),$(foo)) 5423- # bar is now `a,b,c'. 5424- 5425-Here the `subst' function replaces each space with a comma, through the 5426-value of `foo', and substitutes the result. 5427- 5428- 5429-File: make.info, Node: Text Functions, Next: File Name Functions, Prev: Syntax of Functions, Up: Functions 5430- 5431-8.2 Functions for String Substitution and Analysis 5432-================================================== 5433- 5434-Here are some functions that operate on strings: 5435- 5436-`$(subst FROM,TO,TEXT)' 5437- Performs a textual replacement on the text TEXT: each occurrence 5438- of FROM is replaced by TO. The result is substituted for the 5439- function call. For example, 5440- 5441- $(subst ee,EE,feet on the street) 5442- 5443- substitutes the string `fEEt on the strEEt'. 5444- 5445-`$(patsubst PATTERN,REPLACEMENT,TEXT)' 5446- Finds whitespace-separated words in TEXT that match PATTERN and 5447- replaces them with REPLACEMENT. Here PATTERN may contain a `%' 5448- which acts as a wildcard, matching any number of any characters 5449- within a word. If REPLACEMENT also contains a `%', the `%' is 5450- replaced by the text that matched the `%' in PATTERN. Only the 5451- first `%' in the PATTERN and REPLACEMENT is treated this way; any 5452- subsequent `%' is unchanged. 5453- 5454- `%' characters in `patsubst' function invocations can be quoted 5455- with preceding backslashes (`\'). Backslashes that would 5456- otherwise quote `%' characters can be quoted with more backslashes. 5457- Backslashes that quote `%' characters or other backslashes are 5458- removed from the pattern before it is compared file names or has a 5459- stem substituted into it. Backslashes that are not in danger of 5460- quoting `%' characters go unmolested. For example, the pattern 5461- `the\%weird\\%pattern\\' has `the%weird\' preceding the operative 5462- `%' character, and `pattern\\' following it. The final two 5463- backslashes are left alone because they cannot affect any `%' 5464- character. 5465- 5466- Whitespace between words is folded into single space characters; 5467- leading and trailing whitespace is discarded. 5468- 5469- For example, 5470- 5471- $(patsubst %.c,%.o,x.c.c bar.c) 5472- 5473- produces the value `x.c.o bar.o'. 5474- 5475- Substitution references (*note Substitution References: 5476- Substitution Refs.) are a simpler way to get the effect of the 5477- `patsubst' function: 5478- 5479- $(VAR:PATTERN=REPLACEMENT) 5480- 5481- is equivalent to 5482- 5483- $(patsubst PATTERN,REPLACEMENT,$(VAR)) 5484- 5485- The second shorthand simplifies one of the most common uses of 5486- `patsubst': replacing the suffix at the end of file names. 5487- 5488- $(VAR:SUFFIX=REPLACEMENT) 5489- 5490- is equivalent to 5491- 5492- $(patsubst %SUFFIX,%REPLACEMENT,$(VAR)) 5493- 5494- For example, you might have a list of object files: 5495- 5496- objects = foo.o bar.o baz.o 5497- 5498- To get the list of corresponding source files, you could simply 5499- write: 5500- 5501- $(objects:.o=.c) 5502- 5503- instead of using the general form: 5504- 5505- $(patsubst %.o,%.c,$(objects)) 5506- 5507-`$(strip STRING)' 5508- Removes leading and trailing whitespace from STRING and replaces 5509- each internal sequence of one or more whitespace characters with a 5510- single space. Thus, `$(strip a b c )' results in `a b c'. 5511- 5512- The function `strip' can be very useful when used in conjunction 5513- with conditionals. When comparing something with the empty string 5514- `' using `ifeq' or `ifneq', you usually want a string of just 5515- whitespace to match the empty string (*note Conditionals::). 5516- 5517- Thus, the following may fail to have the desired results: 5518- 5519- .PHONY: all 5520- ifneq "$(needs_made)" "" 5521- all: $(needs_made) 5522- else 5523- all:;@echo 'Nothing to make!' 5524- endif 5525- 5526- Replacing the variable reference `$(needs_made)' with the function 5527- call `$(strip $(needs_made))' in the `ifneq' directive would make 5528- it more robust. 5529- 5530-`$(findstring FIND,IN)' 5531- Searches IN for an occurrence of FIND. If it occurs, the value is 5532- FIND; otherwise, the value is empty. You can use this function in 5533- a conditional to test for the presence of a specific substring in 5534- a given string. Thus, the two examples, 5535- 5536- $(findstring a,a b c) 5537- $(findstring a,b c) 5538- 5539- produce the values `a' and `' (the empty string), respectively. 5540- *Note Testing Flags::, for a practical application of `findstring'. 5541- 5542-`$(filter PATTERN...,TEXT)' 5543- Returns all whitespace-separated words in TEXT that _do_ match any 5544- of the PATTERN words, removing any words that _do not_ match. The 5545- patterns are written using `%', just like the patterns used in the 5546- `patsubst' function above. 5547- 5548- The `filter' function can be used to separate out different types 5549- of strings (such as file names) in a variable. For example: 5550- 5551- sources := foo.c bar.c baz.s ugh.h 5552- foo: $(sources) 5553- cc $(filter %.c %.s,$(sources)) -o foo 5554- 5555- says that `foo' depends of `foo.c', `bar.c', `baz.s' and `ugh.h' 5556- but only `foo.c', `bar.c' and `baz.s' should be specified in the 5557- command to the compiler. 5558- 5559-`$(filter-out PATTERN...,TEXT)' 5560- Returns all whitespace-separated words in TEXT that _do not_ match 5561- any of the PATTERN words, removing the words that _do_ match one 5562- or more. This is the exact opposite of the `filter' function. 5563- 5564- For example, given: 5565- 5566- objects=main1.o foo.o main2.o bar.o 5567- mains=main1.o main2.o 5568- 5569- the following generates a list which contains all the object files 5570- not in `mains': 5571- 5572- $(filter-out $(mains),$(objects)) 5573- 5574-`$(sort LIST)' 5575- Sorts the words of LIST in lexical order, removing duplicate 5576- words. The output is a list of words separated by single spaces. 5577- Thus, 5578- 5579- $(sort foo bar lose) 5580- 5581- returns the value `bar foo lose'. 5582- 5583- Incidentally, since `sort' removes duplicate words, you can use it 5584- for this purpose even if you don't care about the sort order. 5585- 5586-`$(word N,TEXT)' 5587- Returns the Nth word of TEXT. The legitimate values of N start 5588- from 1. If N is bigger than the number of words in TEXT, the 5589- value is empty. For example, 5590- 5591- $(word 2, foo bar baz) 5592- 5593- returns `bar'. 5594- 5595-`$(wordlist S,E,TEXT)' 5596- Returns the list of words in TEXT starting with word S and ending 5597- with word E (inclusive). The legitimate values of S start from 1; 5598- E may start from 0. If S is bigger than the number of words in 5599- TEXT, the value is empty. If E is bigger than the number of words 5600- in TEXT, words up to the end of TEXT are returned. If S is 5601- greater than E, nothing is returned. For example, 5602- 5603- $(wordlist 2, 3, foo bar baz) 5604- 5605- returns `bar baz'. 5606- 5607-`$(words TEXT)' 5608- Returns the number of words in TEXT. Thus, the last word of TEXT 5609- is `$(word $(words TEXT),TEXT)'. 5610- 5611-`$(firstword NAMES...)' 5612- The argument NAMES is regarded as a series of names, separated by 5613- whitespace. The value is the first name in the series. The rest 5614- of the names are ignored. 5615- 5616- For example, 5617- 5618- $(firstword foo bar) 5619- 5620- produces the result `foo'. Although `$(firstword TEXT)' is the 5621- same as `$(word 1,TEXT)', the `firstword' function is retained for 5622- its simplicity. 5623- 5624-`$(lastword NAMES...)' 5625- The argument NAMES is regarded as a series of names, separated by 5626- whitespace. The value is the last name in the series. 5627- 5628- For example, 5629- 5630- $(lastword foo bar) 5631- 5632- produces the result `bar'. Although `$(lastword TEXT)' is the 5633- same as `$(word $(words TEXT),TEXT)', the `lastword' function was 5634- added for its simplicity and better performance. 5635- 5636- Here is a realistic example of the use of `subst' and `patsubst'. 5637-Suppose that a makefile uses the `VPATH' variable to specify a list of 5638-directories that `make' should search for prerequisite files (*note 5639-`VPATH' Search Path for All Prerequisites: General Search.). This 5640-example shows how to tell the C compiler to search for header files in 5641-the same list of directories. 5642- 5643- The value of `VPATH' is a list of directories separated by colons, 5644-such as `src:../headers'. First, the `subst' function is used to 5645-change the colons to spaces: 5646- 5647- $(subst :, ,$(VPATH)) 5648- 5649-This produces `src ../headers'. Then `patsubst' is used to turn each 5650-directory name into a `-I' flag. These can be added to the value of 5651-the variable `CFLAGS', which is passed automatically to the C compiler, 5652-like this: 5653- 5654- override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH))) 5655- 5656-The effect is to append the text `-Isrc -I../headers' to the previously 5657-given value of `CFLAGS'. The `override' directive is used so that the 5658-new value is assigned even if the previous value of `CFLAGS' was 5659-specified with a command argument (*note The `override' Directive: 5660-Override Directive.). 5661- 5662- 5663-File: make.info, Node: File Name Functions, Next: Conditional Functions, Prev: Text Functions, Up: Functions 5664- 5665-8.3 Functions for File Names 5666-============================ 5667- 5668-Several of the built-in expansion functions relate specifically to 5669-taking apart file names or lists of file names. 5670- 5671- Each of the following functions performs a specific transformation 5672-on a file name. The argument of the function is regarded as a series 5673-of file names, separated by whitespace. (Leading and trailing 5674-whitespace is ignored.) Each file name in the series is transformed in 5675-the same way and the results are concatenated with single spaces 5676-between them. 5677- 5678-`$(dir NAMES...)' 5679- Extracts the directory-part of each file name in NAMES. The 5680- directory-part of the file name is everything up through (and 5681- including) the last slash in it. If the file name contains no 5682- slash, the directory part is the string `./'. For example, 5683- 5684- $(dir src/foo.c hacks) 5685- 5686- produces the result `src/ ./'. 5687- 5688-`$(notdir NAMES...)' 5689- Extracts all but the directory-part of each file name in NAMES. 5690- If the file name contains no slash, it is left unchanged. 5691- Otherwise, everything through the last slash is removed from it. 5692- 5693- A file name that ends with a slash becomes an empty string. This 5694- is unfortunate, because it means that the result does not always 5695- have the same number of whitespace-separated file names as the 5696- argument had; but we do not see any other valid alternative. 5697- 5698- For example, 5699- 5700- $(notdir src/foo.c hacks) 5701- 5702- produces the result `foo.c hacks'. 5703- 5704-`$(suffix NAMES...)' 5705- Extracts the suffix of each file name in NAMES. If the file name 5706- contains a period, the suffix is everything starting with the last 5707- period. Otherwise, the suffix is the empty string. This 5708- frequently means that the result will be empty when NAMES is not, 5709- and if NAMES contains multiple file names, the result may contain 5710- fewer file names. 5711- 5712- For example, 5713- 5714- $(suffix src/foo.c src-1.0/bar.c hacks) 5715- 5716- produces the result `.c .c'. 5717- 5718-`$(basename NAMES...)' 5719- Extracts all but the suffix of each file name in NAMES. If the 5720- file name contains a period, the basename is everything starting 5721- up to (and not including) the last period. Periods in the 5722- directory part are ignored. If there is no period, the basename 5723- is the entire file name. For example, 5724- 5725- $(basename src/foo.c src-1.0/bar hacks) 5726- 5727- produces the result `src/foo src-1.0/bar hacks'. 5728- 5729-`$(addsuffix SUFFIX,NAMES...)' 5730- The argument NAMES is regarded as a series of names, separated by 5731- whitespace; SUFFIX is used as a unit. The value of SUFFIX is 5732- appended to the end of each individual name and the resulting 5733- larger names are concatenated with single spaces between them. 5734- For example, 5735- 5736- $(addsuffix .c,foo bar) 5737- 5738- produces the result `foo.c bar.c'. 5739- 5740-`$(addprefix PREFIX,NAMES...)' 5741- The argument NAMES is regarded as a series of names, separated by 5742- whitespace; PREFIX is used as a unit. The value of PREFIX is 5743- prepended to the front of each individual name and the resulting 5744- larger names are concatenated with single spaces between them. 5745- For example, 5746- 5747- $(addprefix src/,foo bar) 5748- 5749- produces the result `src/foo src/bar'. 5750- 5751-`$(join LIST1,LIST2)' 5752- Concatenates the two arguments word by word: the two first words 5753- (one from each argument) concatenated form the first word of the 5754- result, the two second words form the second word of the result, 5755- and so on. So the Nth word of the result comes from the Nth word 5756- of each argument. If one argument has more words that the other, 5757- the extra words are copied unchanged into the result. 5758- 5759- For example, `$(join a b,.c .o)' produces `a.c b.o'. 5760- 5761- Whitespace between the words in the lists is not preserved; it is 5762- replaced with a single space. 5763- 5764- This function can merge the results of the `dir' and `notdir' 5765- functions, to produce the original list of files which was given 5766- to those two functions. 5767- 5768-`$(wildcard PATTERN)' 5769- The argument PATTERN is a file name pattern, typically containing 5770- wildcard characters (as in shell file name patterns). The result 5771- of `wildcard' is a space-separated list of the names of existing 5772- files that match the pattern. *Note Using Wildcard Characters in 5773- File Names: Wildcards. 5774- 5775-`$(realpath NAMES...)' 5776- For each file name in NAMES return the canonical absolute name. A 5777- canonical name does not contain any `.' or `..' components, nor 5778- any repeated path separators (`/') or symlinks. In case of a 5779- failure the empty string is returned. Consult the `realpath(3)' 5780- documentation for a list of possible failure causes. 5781- 5782-`$(abspath NAMES...)' 5783- For each file name in NAMES return an absolute name that does not 5784- contain any `.' or `..' components, nor any repeated path 5785- separators (`/'). Note that, in contrast to `realpath' function, 5786- `abspath' does not resolve symlinks and does not require the file 5787- names to refer to an existing file or directory. Use the 5788- `wildcard' function to test for existence. 5789- 5790- 5791-File: make.info, Node: Conditional Functions, Next: Foreach Function, Prev: File Name Functions, Up: Functions 5792- 5793-8.4 Functions for Conditionals 5794-============================== 5795- 5796-There are three functions that provide conditional expansion. A key 5797-aspect of these functions is that not all of the arguments are expanded 5798-initially. Only those arguments which need to be expanded, will be 5799-expanded. 5800- 5801-`$(if CONDITION,THEN-PART[,ELSE-PART])' 5802- The `if' function provides support for conditional expansion in a 5803- functional context (as opposed to the GNU `make' makefile 5804- conditionals such as `ifeq' (*note Syntax of Conditionals: 5805- Conditional Syntax.). 5806- 5807- The first argument, CONDITION, first has all preceding and 5808- trailing whitespace stripped, then is expanded. If it expands to 5809- any non-empty string, then the condition is considered to be true. 5810- If it expands to an empty string, the condition is considered to 5811- be false. 5812- 5813- If the condition is true then the second argument, THEN-PART, is 5814- evaluated and this is used as the result of the evaluation of the 5815- entire `if' function. 5816- 5817- If the condition is false then the third argument, ELSE-PART, is 5818- evaluated and this is the result of the `if' function. If there is 5819- no third argument, the `if' function evaluates to nothing (the 5820- empty string). 5821- 5822- Note that only one of the THEN-PART or the ELSE-PART will be 5823- evaluated, never both. Thus, either can contain side-effects 5824- (such as `shell' function calls, etc.) 5825- 5826-`$(or CONDITION1[,CONDITION2[,CONDITION3...]])' 5827- The `or' function provides a "short-circuiting" OR operation. 5828- Each argument is expanded, in order. If an argument expands to a 5829- non-empty string the processing stops and the result of the 5830- expansion is that string. If, after all arguments are expanded, 5831- all of them are false (empty), then the result of the expansion is 5832- the empty string. 5833- 5834-`$(and CONDITION1[,CONDITION2[,CONDITION3...]])' 5835- The `and' function provides a "short-circuiting" AND operation. 5836- Each argument is expanded, in order. If an argument expands to an 5837- empty string the processing stops and the result of the expansion 5838- is the empty string. If all arguments expand to a non-empty 5839- string then the result of the expansion is the expansion of the 5840- last argument. 5841- 5842- 5843- 5844-File: make.info, Node: Foreach Function, Next: Call Function, Prev: Conditional Functions, Up: Functions 5845- 5846-8.5 The `foreach' Function 5847-========================== 5848- 5849-The `foreach' function is very different from other functions. It 5850-causes one piece of text to be used repeatedly, each time with a 5851-different substitution performed on it. It resembles the `for' command 5852-in the shell `sh' and the `foreach' command in the C-shell `csh'. 5853- 5854- The syntax of the `foreach' function is: 5855- 5856- $(foreach VAR,LIST,TEXT) 5857- 5858-The first two arguments, VAR and LIST, are expanded before anything 5859-else is done; note that the last argument, TEXT, is *not* expanded at 5860-the same time. Then for each word of the expanded value of LIST, the 5861-variable named by the expanded value of VAR is set to that word, and 5862-TEXT is expanded. Presumably TEXT contains references to that 5863-variable, so its expansion will be different each time. 5864- 5865- The result is that TEXT is expanded as many times as there are 5866-whitespace-separated words in LIST. The multiple expansions of TEXT 5867-are concatenated, with spaces between them, to make the result of 5868-`foreach'. 5869- 5870- This simple example sets the variable `files' to the list of all 5871-files in the directories in the list `dirs': 5872- 5873- dirs := a b c d 5874- files := $(foreach dir,$(dirs),$(wildcard $(dir)/*)) 5875- 5876- Here TEXT is `$(wildcard $(dir)/*)'. The first repetition finds the 5877-value `a' for `dir', so it produces the same result as `$(wildcard 5878-a/*)'; the second repetition produces the result of `$(wildcard b/*)'; 5879-and the third, that of `$(wildcard c/*)'. 5880- 5881- This example has the same result (except for setting `dirs') as the 5882-following example: 5883- 5884- files := $(wildcard a/* b/* c/* d/*) 5885- 5886- When TEXT is complicated, you can improve readability by giving it a 5887-name, with an additional variable: 5888- 5889- find_files = $(wildcard $(dir)/*) 5890- dirs := a b c d 5891- files := $(foreach dir,$(dirs),$(find_files)) 5892- 5893-Here we use the variable `find_files' this way. We use plain `=' to 5894-define a recursively-expanding variable, so that its value contains an 5895-actual function call to be reexpanded under the control of `foreach'; a 5896-simply-expanded variable would not do, since `wildcard' would be called 5897-only once at the time of defining `find_files'. 5898- 5899- The `foreach' function has no permanent effect on the variable VAR; 5900-its value and flavor after the `foreach' function call are the same as 5901-they were beforehand. The other values which are taken from LIST are 5902-in effect only temporarily, during the execution of `foreach'. The 5903-variable VAR is a simply-expanded variable during the execution of 5904-`foreach'. If VAR was undefined before the `foreach' function call, it 5905-is undefined after the call. *Note The Two Flavors of Variables: 5906-Flavors. 5907- 5908- You must take care when using complex variable expressions that 5909-result in variable names because many strange things are valid variable 5910-names, but are probably not what you intended. For example, 5911- 5912- files := $(foreach Esta escrito en espanol!,b c ch,$(find_files)) 5913- 5914-might be useful if the value of `find_files' references the variable 5915-whose name is `Esta escrito en espanol!' (es un nombre bastante largo, 5916-no?), but it is more likely to be a mistake. 5917- 5918- 5919-File: make.info, Node: Call Function, Next: Value Function, Prev: Foreach Function, Up: Functions 5920- 5921-8.6 The `call' Function 5922-======================= 5923- 5924-The `call' function is unique in that it can be used to create new 5925-parameterized functions. You can write a complex expression as the 5926-value of a variable, then use `call' to expand it with different values. 5927- 5928- The syntax of the `call' function is: 5929- 5930- $(call VARIABLE,PARAM,PARAM,...) 5931- 5932- When `make' expands this function, it assigns each PARAM to 5933-temporary variables `$(1)', `$(2)', etc. The variable `$(0)' will 5934-contain VARIABLE. There is no maximum number of parameter arguments. 5935-There is no minimum, either, but it doesn't make sense to use `call' 5936-with no parameters. 5937- 5938- Then VARIABLE is expanded as a `make' variable in the context of 5939-these temporary assignments. Thus, any reference to `$(1)' in the 5940-value of VARIABLE will resolve to the first PARAM in the invocation of 5941-`call'. 5942- 5943- Note that VARIABLE is the _name_ of a variable, not a _reference_ to 5944-that variable. Therefore you would not normally use a `$' or 5945-parentheses when writing it. (You can, however, use a variable 5946-reference in the name if you want the name not to be a constant.) 5947- 5948- If VARIABLE is the name of a builtin function, the builtin function 5949-is always invoked (even if a `make' variable by that name also exists). 5950- 5951- The `call' function expands the PARAM arguments before assigning 5952-them to temporary variables. This means that VARIABLE values 5953-containing references to builtin functions that have special expansion 5954-rules, like `foreach' or `if', may not work as you expect. 5955- 5956- Some examples may make this clearer. 5957- 5958- This macro simply reverses its arguments: 5959- 5960- reverse = $(2) $(1) 5961- 5962- foo = $(call reverse,a,b) 5963- 5964-Here FOO will contain `b a'. 5965- 5966- This one is slightly more interesting: it defines a macro to search 5967-for the first instance of a program in `PATH': 5968- 5969- pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) 5970- 5971- LS := $(call pathsearch,ls) 5972- 5973-Now the variable LS contains `/bin/ls' or similar. 5974- 5975- The `call' function can be nested. Each recursive invocation gets 5976-its own local values for `$(1)', etc. that mask the values of 5977-higher-level `call'. For example, here is an implementation of a "map" 5978-function: 5979- 5980- map = $(foreach a,$(2),$(call $(1),$(a))) 5981- 5982- Now you can MAP a function that normally takes only one argument, 5983-such as `origin', to multiple values in one step: 5984- 5985- o = $(call map,origin,o map MAKE) 5986- 5987- and end up with O containing something like `file file default'. 5988- 5989- A final caution: be careful when adding whitespace to the arguments 5990-to `call'. As with other functions, any whitespace contained in the 5991-second and subsequent arguments is kept; this can cause strange 5992-effects. It's generally safest to remove all extraneous whitespace when 5993-providing parameters to `call'. 5994- 5995- 5996-File: make.info, Node: Value Function, Next: Eval Function, Prev: Call Function, Up: Functions 5997- 5998-8.7 The `value' Function 5999-======================== 6000- 6001-The `value' function provides a way for you to use the value of a 6002-variable _without_ having it expanded. Please note that this does not 6003-undo expansions which have already occurred; for example if you create 6004-a simply expanded variable its value is expanded during the definition; 6005-in that case the `value' function will return the same result as using 6006-the variable directly. 6007- 6008- The syntax of the `value' function is: 6009- 6010- $(value VARIABLE) 6011- 6012- Note that VARIABLE is the _name_ of a variable; not a _reference_ to 6013-that variable. Therefore you would not normally use a `$' or 6014-parentheses when writing it. (You can, however, use a variable 6015-reference in the name if you want the name not to be a constant.) 6016- 6017- The result of this function is a string containing the value of 6018-VARIABLE, without any expansion occurring. For example, in this 6019-makefile: 6020- 6021- FOO = $PATH 6022- 6023- all: 6024- @echo $(FOO) 6025- @echo $(value FOO) 6026- 6027-The first output line would be `ATH', since the "$P" would be expanded 6028-as a `make' variable, while the second output line would be the current 6029-value of your `$PATH' environment variable, since the `value' function 6030-avoided the expansion. 6031- 6032- The `value' function is most often used in conjunction with the 6033-`eval' function (*note Eval Function::). 6034- 6035- 6036-File: make.info, Node: Eval Function, Next: Origin Function, Prev: Value Function, Up: Functions 6037- 6038-8.8 The `eval' Function 6039-======================= 6040- 6041-The `eval' function is very special: it allows you to define new 6042-makefile constructs that are not constant; which are the result of 6043-evaluating other variables and functions. The argument to the `eval' 6044-function is expanded, then the results of that expansion are parsed as 6045-makefile syntax. The expanded results can define new `make' variables, 6046-targets, implicit or explicit rules, etc. 6047- 6048- The result of the `eval' function is always the empty string; thus, 6049-it can be placed virtually anywhere in a makefile without causing 6050-syntax errors. 6051- 6052- It's important to realize that the `eval' argument is expanded 6053-_twice_; first by the `eval' function, then the results of that 6054-expansion are expanded again when they are parsed as makefile syntax. 6055-This means you may need to provide extra levels of escaping for "$" 6056-characters when using `eval'. The `value' function (*note Value 6057-Function::) can sometimes be useful in these situations, to circumvent 6058-unwanted expansions. 6059- 6060- Here is an example of how `eval' can be used; this example combines 6061-a number of concepts and other functions. Although it might seem 6062-overly complex to use `eval' in this example, rather than just writing 6063-out the rules, consider two things: first, the template definition (in 6064-`PROGRAM_template') could need to be much more complex than it is here; 6065-and second, you might put the complex, "generic" part of this example 6066-into another makefile, then include it in all the individual makefiles. 6067-Now your individual makefiles are quite straightforward. 6068- 6069- PROGRAMS = server client 6070- 6071- server_OBJS = server.o server_priv.o server_access.o 6072- server_LIBS = priv protocol 6073- 6074- client_OBJS = client.o client_api.o client_mem.o 6075- client_LIBS = protocol 6076- 6077- # Everything after this is generic 6078- 6079- .PHONY: all 6080- all: $(PROGRAMS) 6081- 6082- define PROGRAM_template 6083- $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) 6084- ALL_OBJS += $$($(1)_OBJS) 6085- endef 6086- 6087- $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog)))) 6088- 6089- $(PROGRAMS): 6090- $(LINK.o) $^ $(LDLIBS) -o $@ 6091- 6092- clean: 6093- rm -f $(ALL_OBJS) $(PROGRAMS) 6094- 6095- 6096-File: make.info, Node: Origin Function, Next: Flavor Function, Prev: Eval Function, Up: Functions 6097- 6098-8.9 The `origin' Function 6099-========================= 6100- 6101-The `origin' function is unlike most other functions in that it does 6102-not operate on the values of variables; it tells you something _about_ 6103-a variable. Specifically, it tells you where it came from. 6104- 6105- The syntax of the `origin' function is: 6106- 6107- $(origin VARIABLE) 6108- 6109- Note that VARIABLE is the _name_ of a variable to inquire about; not 6110-a _reference_ to that variable. Therefore you would not normally use a 6111-`$' or parentheses when writing it. (You can, however, use a variable 6112-reference in the name if you want the name not to be a constant.) 6113- 6114- The result of this function is a string telling you how the variable 6115-VARIABLE was defined: 6116- 6117-`undefined' 6118- if VARIABLE was never defined. 6119- 6120-`default' 6121- if VARIABLE has a default definition, as is usual with `CC' and so 6122- on. *Note Variables Used by Implicit Rules: Implicit Variables. 6123- Note that if you have redefined a default variable, the `origin' 6124- function will return the origin of the later definition. 6125- 6126-`environment' 6127- if VARIABLE was defined as an environment variable and the `-e' 6128- option is _not_ turned on (*note Summary of Options: Options 6129- Summary.). 6130- 6131-`environment override' 6132- if VARIABLE was defined as an environment variable and the `-e' 6133- option _is_ turned on (*note Summary of Options: Options Summary.). 6134- 6135-`file' 6136- if VARIABLE was defined in a makefile. 6137- 6138-`command line' 6139- if VARIABLE was defined on the command line. 6140- 6141-`override' 6142- if VARIABLE was defined with an `override' directive in a makefile 6143- (*note The `override' Directive: Override Directive.). 6144- 6145-`automatic' 6146- if VARIABLE is an automatic variable defined for the execution of 6147- the commands for each rule (*note Automatic Variables::). 6148- 6149- This information is primarily useful (other than for your curiosity) 6150-to determine if you want to believe the value of a variable. For 6151-example, suppose you have a makefile `foo' that includes another 6152-makefile `bar'. You want a variable `bletch' to be defined in `bar' if 6153-you run the command `make -f bar', even if the environment contains a 6154-definition of `bletch'. However, if `foo' defined `bletch' before 6155-including `bar', you do not want to override that definition. This 6156-could be done by using an `override' directive in `foo', giving that 6157-definition precedence over the later definition in `bar'; 6158-unfortunately, the `override' directive would also override any command 6159-line definitions. So, `bar' could include: 6160- 6161- ifdef bletch 6162- ifeq "$(origin bletch)" "environment" 6163- bletch = barf, gag, etc. 6164- endif 6165- endif 6166- 6167-If `bletch' has been defined from the environment, this will redefine 6168-it. 6169- 6170- If you want to override a previous definition of `bletch' if it came 6171-from the environment, even under `-e', you could instead write: 6172- 6173- ifneq "$(findstring environment,$(origin bletch))" "" 6174- bletch = barf, gag, etc. 6175- endif 6176- 6177- Here the redefinition takes place if `$(origin bletch)' returns 6178-either `environment' or `environment override'. *Note Functions for 6179-String Substitution and Analysis: Text Functions. 6180- 6181- 6182-File: make.info, Node: Flavor Function, Next: Shell Function, Prev: Origin Function, Up: Functions 6183- 6184-8.10 The `flavor' Function 6185-========================== 6186- 6187-The `flavor' function is unlike most other functions (and like `origin' 6188-function) in that it does not operate on the values of variables; it 6189-tells you something _about_ a variable. Specifically, it tells you the 6190-flavor of a variable (*note The Two Flavors of Variables: Flavors.). 6191- 6192- The syntax of the `flavor' function is: 6193- 6194- $(flavor VARIABLE) 6195- 6196- Note that VARIABLE is the _name_ of a variable to inquire about; not 6197-a _reference_ to that variable. Therefore you would not normally use a 6198-`$' or parentheses when writing it. (You can, however, use a variable 6199-reference in the name if you want the name not to be a constant.) 6200- 6201- The result of this function is a string that identifies the flavor 6202-of the variable VARIABLE: 6203- 6204-`undefined' 6205- if VARIABLE was never defined. 6206- 6207-`recursive' 6208- if VARIABLE is a recursively expanded variable. 6209- 6210-`simple' 6211- if VARIABLE is a simply expanded variable. 6212- 6213- 6214- 6215-File: make.info, Node: Shell Function, Next: Make Control Functions, Prev: Flavor Function, Up: Functions 6216- 6217-8.11 The `shell' Function 6218-========================= 6219- 6220-The `shell' function is unlike any other function other than the 6221-`wildcard' function (*note The Function `wildcard': Wildcard Function.) 6222-in that it communicates with the world outside of `make'. 6223- 6224- The `shell' function performs the same function that backquotes 6225-(``') perform in most shells: it does "command expansion". This means 6226-that it takes as an argument a shell command and evaluates to the 6227-output of the command. The only processing `make' does on the result 6228-is to convert each newline (or carriage-return / newline pair) to a 6229-single space. If there is a trailing (carriage-return and) newline it 6230-will simply be removed. 6231- 6232- The commands run by calls to the `shell' function are run when the 6233-function calls are expanded (*note How `make' Reads a Makefile: Reading 6234-Makefiles.). Because this function involves spawning a new shell, you 6235-should carefully consider the performance implications of using the 6236-`shell' function within recursively expanded variables vs. simply 6237-expanded variables (*note The Two Flavors of Variables: Flavors.). 6238- 6239- Here are some examples of the use of the `shell' function: 6240- 6241- contents := $(shell cat foo) 6242- 6243-sets `contents' to the contents of the file `foo', with a space (rather 6244-than a newline) separating each line. 6245- 6246- files := $(shell echo *.c) 6247- 6248-sets `files' to the expansion of `*.c'. Unless `make' is using a very 6249-strange shell, this has the same result as `$(wildcard *.c)' (as long 6250-as at least one `.c' file exists). 6251- 6252- 6253-File: make.info, Node: Make Control Functions, Prev: Shell Function, Up: Functions 6254- 6255-8.12 Functions That Control Make 6256-================================ 6257- 6258-These functions control the way make runs. Generally, they are used to 6259-provide information to the user of the makefile or to cause make to stop 6260-if some sort of environmental error is detected. 6261- 6262-`$(error TEXT...)' 6263- Generates a fatal error where the message is TEXT. Note that the 6264- error is generated whenever this function is evaluated. So, if 6265- you put it inside a command script or on the right side of a 6266- recursive variable assignment, it won't be evaluated until later. 6267- The TEXT will be expanded before the error is generated. 6268- 6269- For example, 6270- 6271- ifdef ERROR1 6272- $(error error is $(ERROR1)) 6273- endif 6274- 6275- will generate a fatal error during the read of the makefile if the 6276- `make' variable `ERROR1' is defined. Or, 6277- 6278- ERR = $(error found an error!) 6279- 6280- .PHONY: err 6281- err: ; $(ERR) 6282- 6283- will generate a fatal error while `make' is running, if the `err' 6284- target is invoked. 6285- 6286-`$(warning TEXT...)' 6287- This function works similarly to the `error' function, above, 6288- except that `make' doesn't exit. Instead, TEXT is expanded and 6289- the resulting message is displayed, but processing of the makefile 6290- continues. 6291- 6292- The result of the expansion of this function is the empty string. 6293- 6294-`$(info TEXT...)' 6295- This function does nothing more than print its (expanded) 6296- argument(s) to standard output. No makefile name or line number 6297- is added. The result of the expansion of this function is the 6298- empty string. 6299- 6300- 6301-File: make.info, Node: Running, Next: Implicit Rules, Prev: Functions, Up: Top 6302- 6303-9 How to Run `make' 6304-******************* 6305- 6306-A makefile that says how to recompile a program can be used in more 6307-than one way. The simplest use is to recompile every file that is out 6308-of date. Usually, makefiles are written so that if you run `make' with 6309-no arguments, it does just that. 6310- 6311- But you might want to update only some of the files; you might want 6312-to use a different compiler or different compiler options; you might 6313-want just to find out which files are out of date without changing them. 6314- 6315- By giving arguments when you run `make', you can do any of these 6316-things and many others. 6317- 6318- The exit status of `make' is always one of three values: 6319-`0' 6320- The exit status is zero if `make' is successful. 6321- 6322-`2' 6323- The exit status is two if `make' encounters any errors. It will 6324- print messages describing the particular errors. 6325- 6326-`1' 6327- The exit status is one if you use the `-q' flag and `make' 6328- determines that some target is not already up to date. *Note 6329- Instead of Executing the Commands: Instead of Execution. 6330- 6331-* Menu: 6332- 6333-* Makefile Arguments:: How to specify which makefile to use. 6334-* Goals:: How to use goal arguments to specify which 6335- parts of the makefile to use. 6336-* Instead of Execution:: How to use mode flags to specify what 6337- kind of thing to do with the commands 6338- in the makefile other than simply 6339- execute them. 6340-* Avoiding Compilation:: How to avoid recompiling certain files. 6341-* Overriding:: How to override a variable to specify 6342- an alternate compiler and other things. 6343-* Testing:: How to proceed past some errors, to 6344- test compilation. 6345-* Options Summary:: Summary of Options 6346- 6347- 6348-File: make.info, Node: Makefile Arguments, Next: Goals, Prev: Running, Up: Running 6349- 6350-9.1 Arguments to Specify the Makefile 6351-===================================== 6352- 6353-The way to specify the name of the makefile is with the `-f' or 6354-`--file' option (`--makefile' also works). For example, `-f altmake' 6355-says to use the file `altmake' as the makefile. 6356- 6357- If you use the `-f' flag several times and follow each `-f' with an 6358-argument, all the specified files are used jointly as makefiles. 6359- 6360- If you do not use the `-f' or `--file' flag, the default is to try 6361-`GNUmakefile', `makefile', and `Makefile', in that order, and use the 6362-first of these three which exists or can be made (*note Writing 6363-Makefiles: Makefiles.). 6364- 6365- 6366-File: make.info, Node: Goals, Next: Instead of Execution, Prev: Makefile Arguments, Up: Running 6367- 6368-9.2 Arguments to Specify the Goals 6369-================================== 6370- 6371-The "goals" are the targets that `make' should strive ultimately to 6372-update. Other targets are updated as well if they appear as 6373-prerequisites of goals, or prerequisites of prerequisites of goals, etc. 6374- 6375- By default, the goal is the first target in the makefile (not 6376-counting targets that start with a period). Therefore, makefiles are 6377-usually written so that the first target is for compiling the entire 6378-program or programs they describe. If the first rule in the makefile 6379-has several targets, only the first target in the rule becomes the 6380-default goal, not the whole list. You can manage the selection of the 6381-default goal from within your makefile using the `.DEFAULT_GOAL' 6382-variable (*note Other Special Variables: Special Variables.). 6383- 6384- You can also specify a different goal or goals with command-line 6385-arguments to `make'. Use the name of the goal as an argument. If you 6386-specify several goals, `make' processes each of them in turn, in the 6387-order you name them. 6388- 6389- Any target in the makefile may be specified as a goal (unless it 6390-starts with `-' or contains an `=', in which case it will be parsed as 6391-a switch or variable definition, respectively). Even targets not in 6392-the makefile may be specified, if `make' can find implicit rules that 6393-say how to make them. 6394- 6395- `Make' will set the special variable `MAKECMDGOALS' to the list of 6396-goals you specified on the command line. If no goals were given on the 6397-command line, this variable is empty. Note that this variable should 6398-be used only in special circumstances. 6399- 6400- An example of appropriate use is to avoid including `.d' files 6401-during `clean' rules (*note Automatic Prerequisites::), so `make' won't 6402-create them only to immediately remove them again: 6403- 6404- sources = foo.c bar.c 6405- 6406- ifneq ($(MAKECMDGOALS),clean) 6407- include $(sources:.c=.d) 6408- endif 6409- 6410- One use of specifying a goal is if you want to compile only a part of 6411-the program, or only one of several programs. Specify as a goal each 6412-file that you wish to remake. For example, consider a directory 6413-containing several programs, with a makefile that starts like this: 6414- 6415- .PHONY: all 6416- all: size nm ld ar as 6417- 6418- If you are working on the program `size', you might want to say 6419-`make size' so that only the files of that program are recompiled. 6420- 6421- Another use of specifying a goal is to make files that are not 6422-normally made. For example, there may be a file of debugging output, 6423-or a version of the program that is compiled specially for testing, 6424-which has a rule in the makefile but is not a prerequisite of the 6425-default goal. 6426- 6427- Another use of specifying a goal is to run the commands associated 6428-with a phony target (*note Phony Targets::) or empty target (*note 6429-Empty Target Files to Record Events: Empty Targets.). Many makefiles 6430-contain a phony target named `clean' which deletes everything except 6431-source files. Naturally, this is done only if you request it 6432-explicitly with `make clean'. Following is a list of typical phony and 6433-empty target names. *Note Standard Targets::, for a detailed list of 6434-all the standard target names which GNU software packages use. 6435- 6436-`all' 6437- Make all the top-level targets the makefile knows about. 6438- 6439-`clean' 6440- Delete all files that are normally created by running `make'. 6441- 6442-`mostlyclean' 6443- Like `clean', but may refrain from deleting a few files that people 6444- normally don't want to recompile. For example, the `mostlyclean' 6445- target for GCC does not delete `libgcc.a', because recompiling it 6446- is rarely necessary and takes a lot of time. 6447- 6448-`distclean' 6449-`realclean' 6450-`clobber' 6451- Any of these targets might be defined to delete _more_ files than 6452- `clean' does. For example, this would delete configuration files 6453- or links that you would normally create as preparation for 6454- compilation, even if the makefile itself cannot create these files. 6455- 6456-`install' 6457- Copy the executable file into a directory that users typically 6458- search for commands; copy any auxiliary files that the executable 6459- uses into the directories where it will look for them. 6460- 6461-`print' 6462- Print listings of the source files that have changed. 6463- 6464-`tar' 6465- Create a tar file of the source files. 6466- 6467-`shar' 6468- Create a shell archive (shar file) of the source files. 6469- 6470-`dist' 6471- Create a distribution file of the source files. This might be a 6472- tar file, or a shar file, or a compressed version of one of the 6473- above, or even more than one of the above. 6474- 6475-`TAGS' 6476- Update a tags table for this program. 6477- 6478-`check' 6479-`test' 6480- Perform self tests on the program this makefile builds. 6481- 6482- 6483-File: make.info, Node: Instead of Execution, Next: Avoiding Compilation, Prev: Goals, Up: Running 6484- 6485-9.3 Instead of Executing the Commands 6486-===================================== 6487- 6488-The makefile tells `make' how to tell whether a target is up to date, 6489-and how to update each target. But updating the targets is not always 6490-what you want. Certain options specify other activities for `make'. 6491- 6492-`-n' 6493-`--just-print' 6494-`--dry-run' 6495-`--recon' 6496- "No-op". The activity is to print what commands would be used to 6497- make the targets up to date, but not actually execute them. 6498- 6499-`-t' 6500-`--touch' 6501- "Touch". The activity is to mark the targets as up to date without 6502- actually changing them. In other words, `make' pretends to compile 6503- the targets but does not really change their contents. 6504- 6505-`-q' 6506-`--question' 6507- "Question". The activity is to find out silently whether the 6508- targets are up to date already; but execute no commands in either 6509- case. In other words, neither compilation nor output will occur. 6510- 6511-`-W FILE' 6512-`--what-if=FILE' 6513-`--assume-new=FILE' 6514-`--new-file=FILE' 6515- "What if". Each `-W' flag is followed by a file name. The given 6516- files' modification times are recorded by `make' as being the 6517- present time, although the actual modification times remain the 6518- same. You can use the `-W' flag in conjunction with the `-n' flag 6519- to see what would happen if you were to modify specific files. 6520- 6521- With the `-n' flag, `make' prints the commands that it would 6522-normally execute but does not execute them. 6523- 6524- With the `-t' flag, `make' ignores the commands in the rules and 6525-uses (in effect) the command `touch' for each target that needs to be 6526-remade. The `touch' command is also printed, unless `-s' or `.SILENT' 6527-is used. For speed, `make' does not actually invoke the program 6528-`touch'. It does the work directly. 6529- 6530- With the `-q' flag, `make' prints nothing and executes no commands, 6531-but the exit status code it returns is zero if and only if the targets 6532-to be considered are already up to date. If the exit status is one, 6533-then some updating needs to be done. If `make' encounters an error, 6534-the exit status is two, so you can distinguish an error from a target 6535-that is not up to date. 6536- 6537- It is an error to use more than one of these three flags in the same 6538-invocation of `make'. 6539- 6540- The `-n', `-t', and `-q' options do not affect command lines that 6541-begin with `+' characters or contain the strings `$(MAKE)' or 6542-`${MAKE}'. Note that only the line containing the `+' character or the 6543-strings `$(MAKE)' or `${MAKE}' is run regardless of these options. 6544-Other lines in the same rule are not run unless they too begin with `+' 6545-or contain `$(MAKE)' or `${MAKE}' (*Note How the `MAKE' Variable Works: 6546-MAKE Variable.) 6547- 6548- The `-W' flag provides two features: 6549- 6550- * If you also use the `-n' or `-q' flag, you can see what `make' 6551- would do if you were to modify some files. 6552- 6553- * Without the `-n' or `-q' flag, when `make' is actually executing 6554- commands, the `-W' flag can direct `make' to act as if some files 6555- had been modified, without actually modifying the files. 6556- 6557- Note that the options `-p' and `-v' allow you to obtain other 6558-information about `make' or about the makefiles in use (*note Summary 6559-of Options: Options Summary.). 6560- 6561- 6562-File: make.info, Node: Avoiding Compilation, Next: Overriding, Prev: Instead of Execution, Up: Running 6563- 6564-9.4 Avoiding Recompilation of Some Files 6565-======================================== 6566- 6567-Sometimes you may have changed a source file but you do not want to 6568-recompile all the files that depend on it. For example, suppose you add 6569-a macro or a declaration to a header file that many other files depend 6570-on. Being conservative, `make' assumes that any change in the header 6571-file requires recompilation of all dependent files, but you know that 6572-they do not need to be recompiled and you would rather not waste the 6573-time waiting for them to compile. 6574- 6575- If you anticipate the problem before changing the header file, you 6576-can use the `-t' flag. This flag tells `make' not to run the commands 6577-in the rules, but rather to mark the target up to date by changing its 6578-last-modification date. You would follow this procedure: 6579- 6580- 1. Use the command `make' to recompile the source files that really 6581- need recompilation, ensuring that the object files are up-to-date 6582- before you begin. 6583- 6584- 2. Make the changes in the header files. 6585- 6586- 3. Use the command `make -t' to mark all the object files as up to 6587- date. The next time you run `make', the changes in the header 6588- files will not cause any recompilation. 6589- 6590- If you have already changed the header file at a time when some files 6591-do need recompilation, it is too late to do this. Instead, you can use 6592-the `-o FILE' flag, which marks a specified file as "old" (*note 6593-Summary of Options: Options Summary.). This means that the file itself 6594-will not be remade, and nothing else will be remade on its account. 6595-Follow this procedure: 6596- 6597- 1. Recompile the source files that need compilation for reasons 6598- independent of the particular header file, with `make -o 6599- HEADERFILE'. If several header files are involved, use a separate 6600- `-o' option for each header file. 6601- 6602- 2. Touch all the object files with `make -t'. 6603- 6604- 6605-File: make.info, Node: Overriding, Next: Testing, Prev: Avoiding Compilation, Up: Running 6606- 6607-9.5 Overriding Variables 6608-======================== 6609- 6610-An argument that contains `=' specifies the value of a variable: `V=X' 6611-sets the value of the variable V to X. If you specify a value in this 6612-way, all ordinary assignments of the same variable in the makefile are 6613-ignored; we say they have been "overridden" by the command line 6614-argument. 6615- 6616- The most common way to use this facility is to pass extra flags to 6617-compilers. For example, in a properly written makefile, the variable 6618-`CFLAGS' is included in each command that runs the C compiler, so a 6619-file `foo.c' would be compiled something like this: 6620- 6621- cc -c $(CFLAGS) foo.c 6622- 6623- Thus, whatever value you set for `CFLAGS' affects each compilation 6624-that occurs. The makefile probably specifies the usual value for 6625-`CFLAGS', like this: 6626- 6627- CFLAGS=-g 6628- 6629- Each time you run `make', you can override this value if you wish. 6630-For example, if you say `make CFLAGS='-g -O'', each C compilation will 6631-be done with `cc -c -g -O'. (This also illustrates how you can use 6632-quoting in the shell to enclose spaces and other special characters in 6633-the value of a variable when you override it.) 6634- 6635- The variable `CFLAGS' is only one of many standard variables that 6636-exist just so that you can change them this way. *Note Variables Used 6637-by Implicit Rules: Implicit Variables, for a complete list. 6638- 6639- You can also program the makefile to look at additional variables of 6640-your own, giving the user the ability to control other aspects of how 6641-the makefile works by changing the variables. 6642- 6643- When you override a variable with a command argument, you can define 6644-either a recursively-expanded variable or a simply-expanded variable. 6645-The examples shown above make a recursively-expanded variable; to make a 6646-simply-expanded variable, write `:=' instead of `='. But, unless you 6647-want to include a variable reference or function call in the _value_ 6648-that you specify, it makes no difference which kind of variable you 6649-create. 6650- 6651- There is one way that the makefile can change a variable that you 6652-have overridden. This is to use the `override' directive, which is a 6653-line that looks like this: `override VARIABLE = VALUE' (*note The 6654-`override' Directive: Override Directive.). 6655- 6656- 6657-File: make.info, Node: Testing, Next: Options Summary, Prev: Overriding, Up: Running 6658- 6659-9.6 Testing the Compilation of a Program 6660-======================================== 6661- 6662-Normally, when an error happens in executing a shell command, `make' 6663-gives up immediately, returning a nonzero status. No further commands 6664-are executed for any target. The error implies that the goal cannot be 6665-correctly remade, and `make' reports this as soon as it knows. 6666- 6667- When you are compiling a program that you have just changed, this is 6668-not what you want. Instead, you would rather that `make' try compiling 6669-every file that can be tried, to show you as many compilation errors as 6670-possible. 6671- 6672- On these occasions, you should use the `-k' or `--keep-going' flag. 6673-This tells `make' to continue to consider the other prerequisites of 6674-the pending targets, remaking them if necessary, before it gives up and 6675-returns nonzero status. For example, after an error in compiling one 6676-object file, `make -k' will continue compiling other object files even 6677-though it already knows that linking them will be impossible. In 6678-addition to continuing after failed shell commands, `make -k' will 6679-continue as much as possible after discovering that it does not know 6680-how to make a target or prerequisite file. This will always cause an 6681-error message, but without `-k', it is a fatal error (*note Summary of 6682-Options: Options Summary.). 6683- 6684- The usual behavior of `make' assumes that your purpose is to get the 6685-goals up to date; once `make' learns that this is impossible, it might 6686-as well report the failure immediately. The `-k' flag says that the 6687-real purpose is to test as much as possible of the changes made in the 6688-program, perhaps to find several independent problems so that you can 6689-correct them all before the next attempt to compile. This is why Emacs' 6690-`M-x compile' command passes the `-k' flag by default. 6691- 6692- 6693-File: make.info, Node: Options Summary, Prev: Testing, Up: Running 6694- 6695-9.7 Summary of Options 6696-====================== 6697- 6698-Here is a table of all the options `make' understands: 6699- 6700-`-b' 6701-`-m' 6702- These options are ignored for compatibility with other versions of 6703- `make'. 6704- 6705-`-B' 6706-`--always-make' 6707- Consider all targets out-of-date. GNU `make' proceeds to consider 6708- targets and their prerequisites using the normal algorithms; 6709- however, all targets so considered are always remade regardless of 6710- the status of their prerequisites. To avoid infinite recursion, if 6711- `MAKE_RESTARTS' (*note Other Special Variables: Special 6712- Variables.) is set to a number greater than 0 this option is 6713- disabled when considering whether to remake makefiles (*note How 6714- Makefiles Are Remade: Remaking Makefiles.). 6715- 6716-`-C DIR' 6717-`--directory=DIR' 6718- Change to directory DIR before reading the makefiles. If multiple 6719- `-C' options are specified, each is interpreted relative to the 6720- previous one: `-C / -C etc' is equivalent to `-C /etc'. This is 6721- typically used with recursive invocations of `make' (*note 6722- Recursive Use of `make': Recursion.). 6723- 6724-`-d' 6725- Print debugging information in addition to normal processing. The 6726- debugging information says which files are being considered for 6727- remaking, which file-times are being compared and with what 6728- results, which files actually need to be remade, which implicit 6729- rules are considered and which are applied--everything interesting 6730- about how `make' decides what to do. The `-d' option is 6731- equivalent to `--debug=a' (see below). 6732- 6733-`--debug[=OPTIONS]' 6734- Print debugging information in addition to normal processing. 6735- Various levels and types of output can be chosen. With no 6736- arguments, print the "basic" level of debugging. Possible 6737- arguments are below; only the first character is considered, and 6738- values must be comma- or space-separated. 6739- 6740- `a (all)' 6741- All types of debugging output are enabled. This is 6742- equivalent to using `-d'. 6743- 6744- `b (basic)' 6745- Basic debugging prints each target that was found to be 6746- out-of-date, and whether the build was successful or not. 6747- 6748- `v (verbose)' 6749- A level above `basic'; includes messages about which 6750- makefiles were parsed, prerequisites that did not need to be 6751- rebuilt, etc. This option also enables `basic' messages. 6752- 6753- `i (implicit)' 6754- Prints messages describing the implicit rule searches for 6755- each target. This option also enables `basic' messages. 6756- 6757- `j (jobs)' 6758- Prints messages giving details on the invocation of specific 6759- subcommands. 6760- 6761- `m (makefile)' 6762- By default, the above messages are not enabled while trying 6763- to remake the makefiles. This option enables messages while 6764- rebuilding makefiles, too. Note that the `all' option does 6765- enable this option. This option also enables `basic' 6766- messages. 6767- 6768-`-e' 6769-`--environment-overrides' 6770- Give variables taken from the environment precedence over 6771- variables from makefiles. *Note Variables from the Environment: 6772- Environment. 6773- 6774-`-f FILE' 6775-`--file=FILE' 6776-`--makefile=FILE' 6777- Read the file named FILE as a makefile. *Note Writing Makefiles: 6778- Makefiles. 6779- 6780-`-h' 6781-`--help' 6782- Remind you of the options that `make' understands and then exit. 6783- 6784-`-i' 6785-`--ignore-errors' 6786- Ignore all errors in commands executed to remake files. *Note 6787- Errors in Commands: Errors. 6788- 6789-`-I DIR' 6790-`--include-dir=DIR' 6791- Specifies a directory DIR to search for included makefiles. *Note 6792- Including Other Makefiles: Include. If several `-I' options are 6793- used to specify several directories, the directories are searched 6794- in the order specified. 6795- 6796-`-j [JOBS]' 6797-`--jobs[=JOBS]' 6798- Specifies the number of jobs (commands) to run simultaneously. 6799- With no argument, `make' runs as many jobs simultaneously as 6800- possible. If there is more than one `-j' option, the last one is 6801- effective. *Note Parallel Execution: Parallel, for more 6802- information on how commands are run. Note that this option is 6803- ignored on MS-DOS. 6804- 6805-`-k' 6806-`--keep-going' 6807- Continue as much as possible after an error. While the target that 6808- failed, and those that depend on it, cannot be remade, the other 6809- prerequisites of these targets can be processed all the same. 6810- *Note Testing the Compilation of a Program: Testing. 6811- 6812-`-l [LOAD]' 6813-`--load-average[=LOAD]' 6814-`--max-load[=LOAD]' 6815- Specifies that no new jobs (commands) should be started if there 6816- are other jobs running and the load average is at least LOAD (a 6817- floating-point number). With no argument, removes a previous load 6818- limit. *Note Parallel Execution: Parallel. 6819- 6820-`-L' 6821-`--check-symlink-times' 6822- On systems that support symbolic links, this option causes `make' 6823- to consider the timestamps on any symbolic links in addition to the 6824- timestamp on the file referenced by those links. When this option 6825- is provided, the most recent timestamp among the file and the 6826- symbolic links is taken as the modification time for this target 6827- file. 6828- 6829-`-n' 6830-`--just-print' 6831-`--dry-run' 6832-`--recon' 6833- Print the commands that would be executed, but do not execute them. 6834- *Note Instead of Executing the Commands: Instead of Execution. 6835- 6836-`-o FILE' 6837-`--old-file=FILE' 6838-`--assume-old=FILE' 6839- Do not remake the file FILE even if it is older than its 6840- prerequisites, and do not remake anything on account of changes in 6841- FILE. Essentially the file is treated as very old and its rules 6842- are ignored. *Note Avoiding Recompilation of Some Files: Avoiding 6843- Compilation. 6844- 6845-`-p' 6846-`--print-data-base' 6847- Print the data base (rules and variable values) that results from 6848- reading the makefiles; then execute as usual or as otherwise 6849- specified. This also prints the version information given by the 6850- `-v' switch (see below). To print the data base without trying to 6851- remake any files, use `make -qp'. To print the data base of 6852- predefined rules and variables, use `make -p -f /dev/null'. The 6853- data base output contains filename and linenumber information for 6854- command and variable definitions, so it can be a useful debugging 6855- tool in complex environments. 6856- 6857-`-q' 6858-`--question' 6859- "Question mode". Do not run any commands, or print anything; just 6860- return an exit status that is zero if the specified targets are 6861- already up to date, one if any remaking is required, or two if an 6862- error is encountered. *Note Instead of Executing the Commands: 6863- Instead of Execution. 6864- 6865-`-r' 6866-`--no-builtin-rules' 6867- Eliminate use of the built-in implicit rules (*note Using Implicit 6868- Rules: Implicit Rules.). You can still define your own by writing 6869- pattern rules (*note Defining and Redefining Pattern Rules: 6870- Pattern Rules.). The `-r' option also clears out the default list 6871- of suffixes for suffix rules (*note Old-Fashioned Suffix Rules: 6872- Suffix Rules.). But you can still define your own suffixes with a 6873- rule for `.SUFFIXES', and then define your own suffix rules. Note 6874- that only _rules_ are affected by the `-r' option; default 6875- variables remain in effect (*note Variables Used by Implicit 6876- Rules: Implicit Variables.); see the `-R' option below. 6877- 6878-`-R' 6879-`--no-builtin-variables' 6880- Eliminate use of the built-in rule-specific variables (*note 6881- Variables Used by Implicit Rules: Implicit Variables.). You can 6882- still define your own, of course. The `-R' option also 6883- automatically enables the `-r' option (see above), since it 6884- doesn't make sense to have implicit rules without any definitions 6885- for the variables that they use. 6886- 6887-`-s' 6888-`--silent' 6889-`--quiet' 6890- Silent operation; do not print the commands as they are executed. 6891- *Note Command Echoing: Echoing. 6892- 6893-`-S' 6894-`--no-keep-going' 6895-`--stop' 6896- Cancel the effect of the `-k' option. This is never necessary 6897- except in a recursive `make' where `-k' might be inherited from 6898- the top-level `make' via `MAKEFLAGS' (*note Recursive Use of 6899- `make': Recursion.) or if you set `-k' in `MAKEFLAGS' in your 6900- environment. 6901- 6902-`-t' 6903-`--touch' 6904- Touch files (mark them up to date without really changing them) 6905- instead of running their commands. This is used to pretend that 6906- the commands were done, in order to fool future invocations of 6907- `make'. *Note Instead of Executing the Commands: Instead of 6908- Execution. 6909- 6910-`-v' 6911-`--version' 6912- Print the version of the `make' program plus a copyright, a list 6913- of authors, and a notice that there is no warranty; then exit. 6914- 6915-`-w' 6916-`--print-directory' 6917- Print a message containing the working directory both before and 6918- after executing the makefile. This may be useful for tracking 6919- down errors from complicated nests of recursive `make' commands. 6920- *Note Recursive Use of `make': Recursion. (In practice, you 6921- rarely need to specify this option since `make' does it for you; 6922- see *Note The `--print-directory' Option: -w Option.) 6923- 6924-`--no-print-directory' 6925- Disable printing of the working directory under `-w'. This option 6926- is useful when `-w' is turned on automatically, but you do not 6927- want to see the extra messages. *Note The `--print-directory' 6928- Option: -w Option. 6929- 6930-`-W FILE' 6931-`--what-if=FILE' 6932-`--new-file=FILE' 6933-`--assume-new=FILE' 6934- Pretend that the target FILE has just been modified. When used 6935- with the `-n' flag, this shows you what would happen if you were 6936- to modify that file. Without `-n', it is almost the same as 6937- running a `touch' command on the given file before running `make', 6938- except that the modification time is changed only in the 6939- imagination of `make'. *Note Instead of Executing the Commands: 6940- Instead of Execution. 6941- 6942-`--warn-undefined-variables' 6943- Issue a warning message whenever `make' sees a reference to an 6944- undefined variable. This can be helpful when you are trying to 6945- debug makefiles which use variables in complex ways. 6946- 6947- 6948-File: make.info, Node: Implicit Rules, Next: Archives, Prev: Running, Up: Top 6949- 6950-10 Using Implicit Rules 6951-*********************** 6952- 6953-Certain standard ways of remaking target files are used very often. For 6954-example, one customary way to make an object file is from a C source 6955-file using the C compiler, `cc'. 6956- 6957- "Implicit rules" tell `make' how to use customary techniques so that 6958-you do not have to specify them in detail when you want to use them. 6959-For example, there is an implicit rule for C compilation. File names 6960-determine which implicit rules are run. For example, C compilation 6961-typically takes a `.c' file and makes a `.o' file. So `make' applies 6962-the implicit rule for C compilation when it sees this combination of 6963-file name endings. 6964- 6965- A chain of implicit rules can apply in sequence; for example, `make' 6966-will remake a `.o' file from a `.y' file by way of a `.c' file. 6967- 6968- The built-in implicit rules use several variables in their commands 6969-so that, by changing the values of the variables, you can change the 6970-way the implicit rule works. For example, the variable `CFLAGS' 6971-controls the flags given to the C compiler by the implicit rule for C 6972-compilation. 6973- 6974- You can define your own implicit rules by writing "pattern rules". 6975- 6976- "Suffix rules" are a more limited way to define implicit rules. 6977-Pattern rules are more general and clearer, but suffix rules are 6978-retained for compatibility. 6979- 6980-* Menu: 6981- 6982-* Using Implicit:: How to use an existing implicit rule 6983- to get the commands for updating a file. 6984-* Catalogue of Rules:: A list of built-in implicit rules. 6985-* Implicit Variables:: How to change what predefined rules do. 6986-* Chained Rules:: How to use a chain of implicit rules. 6987-* Pattern Rules:: How to define new implicit rules. 6988-* Last Resort:: How to define commands for rules which 6989- cannot find any. 6990-* Suffix Rules:: The old-fashioned style of implicit rule. 6991-* Implicit Rule Search:: The precise algorithm for applying 6992- implicit rules. 6993- 6994- 6995-File: make.info, Node: Using Implicit, Next: Catalogue of Rules, Prev: Implicit Rules, Up: Implicit Rules 6996- 6997-10.1 Using Implicit Rules 6998-========================= 6999- 7000-To allow `make' to find a customary method for updating a target file, 7001-all you have to do is refrain from specifying commands yourself. Either 7002-write a rule with no command lines, or don't write a rule at all. Then 7003-`make' will figure out which implicit rule to use based on which kind 7004-of source file exists or can be made. 7005- 7006- For example, suppose the makefile looks like this: 7007- 7008- foo : foo.o bar.o 7009- cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS) 7010- 7011-Because you mention `foo.o' but do not give a rule for it, `make' will 7012-automatically look for an implicit rule that tells how to update it. 7013-This happens whether or not the file `foo.o' currently exists. 7014- 7015- If an implicit rule is found, it can supply both commands and one or 7016-more prerequisites (the source files). You would want to write a rule 7017-for `foo.o' with no command lines if you need to specify additional 7018-prerequisites, such as header files, that the implicit rule cannot 7019-supply. 7020- 7021- Each implicit rule has a target pattern and prerequisite patterns. 7022-There may be many implicit rules with the same target pattern. For 7023-example, numerous rules make `.o' files: one, from a `.c' file with the 7024-C compiler; another, from a `.p' file with the Pascal compiler; and so 7025-on. The rule that actually applies is the one whose prerequisites 7026-exist or can be made. So, if you have a file `foo.c', `make' will run 7027-the C compiler; otherwise, if you have a file `foo.p', `make' will run 7028-the Pascal compiler; and so on. 7029- 7030- Of course, when you write the makefile, you know which implicit rule 7031-you want `make' to use, and you know it will choose that one because you 7032-know which possible prerequisite files are supposed to exist. *Note 7033-Catalogue of Implicit Rules: Catalogue of Rules, for a catalogue of all 7034-the predefined implicit rules. 7035- 7036- Above, we said an implicit rule applies if the required 7037-prerequisites "exist or can be made". A file "can be made" if it is 7038-mentioned explicitly in the makefile as a target or a prerequisite, or 7039-if an implicit rule can be recursively found for how to make it. When 7040-an implicit prerequisite is the result of another implicit rule, we say 7041-that "chaining" is occurring. *Note Chains of Implicit Rules: Chained 7042-Rules. 7043- 7044- In general, `make' searches for an implicit rule for each target, and 7045-for each double-colon rule, that has no commands. A file that is 7046-mentioned only as a prerequisite is considered a target whose rule 7047-specifies nothing, so implicit rule search happens for it. *Note 7048-Implicit Rule Search Algorithm: Implicit Rule Search, for the details 7049-of how the search is done. 7050- 7051- Note that explicit prerequisites do not influence implicit rule 7052-search. For example, consider this explicit rule: 7053- 7054- foo.o: foo.p 7055- 7056-The prerequisite on `foo.p' does not necessarily mean that `make' will 7057-remake `foo.o' according to the implicit rule to make an object file, a 7058-`.o' file, from a Pascal source file, a `.p' file. For example, if 7059-`foo.c' also exists, the implicit rule to make an object file from a C 7060-source file is used instead, because it appears before the Pascal rule 7061-in the list of predefined implicit rules (*note Catalogue of Implicit 7062-Rules: Catalogue of Rules.). 7063- 7064- If you do not want an implicit rule to be used for a target that has 7065-no commands, you can give that target empty commands by writing a 7066-semicolon (*note Defining Empty Commands: Empty Commands.). 7067- 7068- 7069-File: make.info, Node: Catalogue of Rules, Next: Implicit Variables, Prev: Using Implicit, Up: Implicit Rules 7070- 7071-10.2 Catalogue of Implicit Rules 7072-================================ 7073- 7074-Here is a catalogue of predefined implicit rules which are always 7075-available unless the makefile explicitly overrides or cancels them. 7076-*Note Canceling Implicit Rules: Canceling Rules, for information on 7077-canceling or overriding an implicit rule. The `-r' or 7078-`--no-builtin-rules' option cancels all predefined rules. 7079- 7080- This manual only documents the default rules available on POSIX-based 7081-operating systems. Other operating systems, such as VMS, Windows, 7082-OS/2, etc. may have different sets of default rules. To see the full 7083-list of default rules and variables available in your version of GNU 7084-`make', run `make -p' in a directory with no makefile. 7085- 7086- Not all of these rules will always be defined, even when the `-r' 7087-option is not given. Many of the predefined implicit rules are 7088-implemented in `make' as suffix rules, so which ones will be defined 7089-depends on the "suffix list" (the list of prerequisites of the special 7090-target `.SUFFIXES'). The default suffix list is: `.out', `.a', `.ln', 7091-`.o', `.c', `.cc', `.C', `.cpp', `.p', `.f', `.F', `.r', `.y', `.l', 7092-`.s', `.S', `.mod', `.sym', `.def', `.h', `.info', `.dvi', `.tex', 7093-`.texinfo', `.texi', `.txinfo', `.w', `.ch' `.web', `.sh', `.elc', 7094-`.el'. All of the implicit rules described below whose prerequisites 7095-have one of these suffixes are actually suffix rules. If you modify 7096-the suffix list, the only predefined suffix rules in effect will be 7097-those named by one or two of the suffixes that are on the list you 7098-specify; rules whose suffixes fail to be on the list are disabled. 7099-*Note Old-Fashioned Suffix Rules: Suffix Rules, for full details on 7100-suffix rules. 7101- 7102-Compiling C programs 7103- `N.o' is made automatically from `N.c' with a command of the form 7104- `$(CC) -c $(CPPFLAGS) $(CFLAGS)'. 7105- 7106-Compiling C++ programs 7107- `N.o' is made automatically from `N.cc', `N.cpp', or `N.C' with a 7108- command of the form `$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)'. We 7109- encourage you to use the suffix `.cc' for C++ source files instead 7110- of `.C'. 7111- 7112-Compiling Pascal programs 7113- `N.o' is made automatically from `N.p' with the command `$(PC) -c 7114- $(PFLAGS)'. 7115- 7116-Compiling Fortran and Ratfor programs 7117- `N.o' is made automatically from `N.r', `N.F' or `N.f' by running 7118- the Fortran compiler. The precise command used is as follows: 7119- 7120- `.f' 7121- `$(FC) -c $(FFLAGS)'. 7122- 7123- `.F' 7124- `$(FC) -c $(FFLAGS) $(CPPFLAGS)'. 7125- 7126- `.r' 7127- `$(FC) -c $(FFLAGS) $(RFLAGS)'. 7128- 7129-Preprocessing Fortran and Ratfor programs 7130- `N.f' is made automatically from `N.r' or `N.F'. This rule runs 7131- just the preprocessor to convert a Ratfor or preprocessable 7132- Fortran program into a strict Fortran program. The precise 7133- command used is as follows: 7134- 7135- `.F' 7136- `$(FC) -F $(CPPFLAGS) $(FFLAGS)'. 7137- 7138- `.r' 7139- `$(FC) -F $(FFLAGS) $(RFLAGS)'. 7140- 7141-Compiling Modula-2 programs 7142- `N.sym' is made from `N.def' with a command of the form `$(M2C) 7143- $(M2FLAGS) $(DEFFLAGS)'. `N.o' is made from `N.mod'; the form is: 7144- `$(M2C) $(M2FLAGS) $(MODFLAGS)'. 7145- 7146-Assembling and preprocessing assembler programs 7147- `N.o' is made automatically from `N.s' by running the assembler, 7148- `as'. The precise command is `$(AS) $(ASFLAGS)'. 7149- 7150- `N.s' is made automatically from `N.S' by running the C 7151- preprocessor, `cpp'. The precise command is `$(CPP) $(CPPFLAGS)'. 7152- 7153-Linking a single object file 7154- `N' is made automatically from `N.o' by running the linker 7155- (usually called `ld') via the C compiler. The precise command 7156- used is `$(CC) $(LDFLAGS) N.o $(LOADLIBES) $(LDLIBS)'. 7157- 7158- This rule does the right thing for a simple program with only one 7159- source file. It will also do the right thing if there are multiple 7160- object files (presumably coming from various other source files), 7161- one of which has a name matching that of the executable file. 7162- Thus, 7163- 7164- x: y.o z.o 7165- 7166- when `x.c', `y.c' and `z.c' all exist will execute: 7167- 7168- cc -c x.c -o x.o 7169- cc -c y.c -o y.o 7170- cc -c z.c -o z.o 7171- cc x.o y.o z.o -o x 7172- rm -f x.o 7173- rm -f y.o 7174- rm -f z.o 7175- 7176- In more complicated cases, such as when there is no object file 7177- whose name derives from the executable file name, you must write 7178- an explicit command for linking. 7179- 7180- Each kind of file automatically made into `.o' object files will 7181- be automatically linked by using the compiler (`$(CC)', `$(FC)' or 7182- `$(PC)'; the C compiler `$(CC)' is used to assemble `.s' files) 7183- without the `-c' option. This could be done by using the `.o' 7184- object files as intermediates, but it is faster to do the 7185- compiling and linking in one step, so that's how it's done. 7186- 7187-Yacc for C programs 7188- `N.c' is made automatically from `N.y' by running Yacc with the 7189- command `$(YACC) $(YFLAGS)'. 7190- 7191-Lex for C programs 7192- `N.c' is made automatically from `N.l' by running Lex. The actual 7193- command is `$(LEX) $(LFLAGS)'. 7194- 7195-Lex for Ratfor programs 7196- `N.r' is made automatically from `N.l' by running Lex. The actual 7197- command is `$(LEX) $(LFLAGS)'. 7198- 7199- The convention of using the same suffix `.l' for all Lex files 7200- regardless of whether they produce C code or Ratfor code makes it 7201- impossible for `make' to determine automatically which of the two 7202- languages you are using in any particular case. If `make' is 7203- called upon to remake an object file from a `.l' file, it must 7204- guess which compiler to use. It will guess the C compiler, because 7205- that is more common. If you are using Ratfor, make sure `make' 7206- knows this by mentioning `N.r' in the makefile. Or, if you are 7207- using Ratfor exclusively, with no C files, remove `.c' from the 7208- list of implicit rule suffixes with: 7209- 7210- .SUFFIXES: 7211- .SUFFIXES: .o .r .f .l ... 7212- 7213-Making Lint Libraries from C, Yacc, or Lex programs 7214- `N.ln' is made from `N.c' by running `lint'. The precise command 7215- is `$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i'. The same command is 7216- used on the C code produced from `N.y' or `N.l'. 7217- 7218-TeX and Web 7219- `N.dvi' is made from `N.tex' with the command `$(TEX)'. `N.tex' 7220- is made from `N.web' with `$(WEAVE)', or from `N.w' (and from 7221- `N.ch' if it exists or can be made) with `$(CWEAVE)'. `N.p' is 7222- made from `N.web' with `$(TANGLE)' and `N.c' is made from `N.w' 7223- (and from `N.ch' if it exists or can be made) with `$(CTANGLE)'. 7224- 7225-Texinfo and Info 7226- `N.dvi' is made from `N.texinfo', `N.texi', or `N.txinfo', with 7227- the command `$(TEXI2DVI) $(TEXI2DVI_FLAGS)'. `N.info' is made from 7228- `N.texinfo', `N.texi', or `N.txinfo', with the command 7229- `$(MAKEINFO) $(MAKEINFO_FLAGS)'. 7230- 7231-RCS 7232- Any file `N' is extracted if necessary from an RCS file named 7233- either `N,v' or `RCS/N,v'. The precise command used is 7234- `$(CO) $(COFLAGS)'. `N' will not be extracted from RCS if it 7235- already exists, even if the RCS file is newer. The rules for RCS 7236- are terminal (*note Match-Anything Pattern Rules: Match-Anything 7237- Rules.), so RCS files cannot be generated from another source; 7238- they must actually exist. 7239- 7240-SCCS 7241- Any file `N' is extracted if necessary from an SCCS file named 7242- either `s.N' or `SCCS/s.N'. The precise command used is 7243- `$(GET) $(GFLAGS)'. The rules for SCCS are terminal (*note 7244- Match-Anything Pattern Rules: Match-Anything Rules.), so SCCS 7245- files cannot be generated from another source; they must actually 7246- exist. 7247- 7248- For the benefit of SCCS, a file `N' is copied from `N.sh' and made 7249- executable (by everyone). This is for shell scripts that are 7250- checked into SCCS. Since RCS preserves the execution permission 7251- of a file, you do not need to use this feature with RCS. 7252- 7253- We recommend that you avoid using of SCCS. RCS is widely held to 7254- be superior, and is also free. By choosing free software in place 7255- of comparable (or inferior) proprietary software, you support the 7256- free software movement. 7257- 7258- Usually, you want to change only the variables listed in the table 7259-above, which are documented in the following section. 7260- 7261- However, the commands in built-in implicit rules actually use 7262-variables such as `COMPILE.c', `LINK.p', and `PREPROCESS.S', whose 7263-values contain the commands listed above. 7264- 7265- `make' follows the convention that the rule to compile a `.X' source 7266-file uses the variable `COMPILE.X'. Similarly, the rule to produce an 7267-executable from a `.X' file uses `LINK.X'; and the rule to preprocess a 7268-`.X' file uses `PREPROCESS.X'. 7269- 7270- Every rule that produces an object file uses the variable 7271-`OUTPUT_OPTION'. `make' defines this variable either to contain `-o 7272-$@', or to be empty, depending on a compile-time option. You need the 7273-`-o' option to ensure that the output goes into the right file when the 7274-source file is in a different directory, as when using `VPATH' (*note 7275-Directory Search::). However, compilers on some systems do not accept 7276-a `-o' switch for object files. If you use such a system, and use 7277-`VPATH', some compilations will put their output in the wrong place. A 7278-possible workaround for this problem is to give `OUTPUT_OPTION' the 7279-value `; mv $*.o $@'. 7280- 7281- 7282-File: make.info, Node: Implicit Variables, Next: Chained Rules, Prev: Catalogue of Rules, Up: Implicit Rules 7283- 7284-10.3 Variables Used by Implicit Rules 7285-===================================== 7286- 7287-The commands in built-in implicit rules make liberal use of certain 7288-predefined variables. You can alter the values of these variables in 7289-the makefile, with arguments to `make', or in the environment to alter 7290-how the implicit rules work without redefining the rules themselves. 7291-You can cancel all variables used by implicit rules with the `-R' or 7292-`--no-builtin-variables' option. 7293- 7294- For example, the command used to compile a C source file actually 7295-says `$(CC) -c $(CFLAGS) $(CPPFLAGS)'. The default values of the 7296-variables used are `cc' and nothing, resulting in the command `cc -c'. 7297-By redefining `CC' to `ncc', you could cause `ncc' to be used for all C 7298-compilations performed by the implicit rule. By redefining `CFLAGS' to 7299-be `-g', you could pass the `-g' option to each compilation. _All_ 7300-implicit rules that do C compilation use `$(CC)' to get the program 7301-name for the compiler and _all_ include `$(CFLAGS)' among the arguments 7302-given to the compiler. 7303- 7304- The variables used in implicit rules fall into two classes: those 7305-that are names of programs (like `CC') and those that contain arguments 7306-for the programs (like `CFLAGS'). (The "name of a program" may also 7307-contain some command arguments, but it must start with an actual 7308-executable program name.) If a variable value contains more than one 7309-argument, separate them with spaces. 7310- 7311- The following tables describe of some of the more commonly-used 7312-predefined variables. This list is not exhaustive, and the default 7313-values shown here may not be what are selected by `make' for your 7314-environment. To see the complete list of predefined variables for your 7315-instance of GNU `make' you can run `make -p' in a directory with no 7316-makefiles. 7317- 7318- Here is a table of some of the more common variables used as names of 7319-programs in built-in rules: makefiles. 7320- 7321-`AR' 7322- Archive-maintaining program; default `ar'. 7323- 7324-`AS' 7325- Program for compiling assembly files; default `as'. 7326- 7327-`CC' 7328- Program for compiling C programs; default `cc'. 7329- 7330-`CO' 7331- Program for checking out files from RCS; default `co'. 7332- 7333-`CXX' 7334- Program for compiling C++ programs; default `g++'. 7335- 7336-`CO' 7337- Program for extracting a file from RCS; default `co'. 7338- 7339-`CPP' 7340- Program for running the C preprocessor, with results to standard 7341- output; default `$(CC) -E'. 7342- 7343-`FC' 7344- Program for compiling or preprocessing Fortran and Ratfor programs; 7345- default `f77'. 7346- 7347-`GET' 7348- Program for extracting a file from SCCS; default `get'. 7349- 7350-`LEX' 7351- Program to use to turn Lex grammars into source code; default 7352- `lex'. 7353- 7354-`YACC' 7355- Program to use to turn Yacc grammars into source code; default 7356- `yacc'. 7357- 7358-`LINT' 7359- Program to use to run lint on source code; default `lint'. 7360- 7361-`M2C' 7362- Program to use to compile Modula-2 source code; default `m2c'. 7363- 7364-`PC' 7365- Program for compiling Pascal programs; default `pc'. 7366- 7367-`MAKEINFO' 7368- Program to convert a Texinfo source file into an Info file; default 7369- `makeinfo'. 7370- 7371-`TEX' 7372- Program to make TeX DVI files from TeX source; default `tex'. 7373- 7374-`TEXI2DVI' 7375- Program to make TeX DVI files from Texinfo source; default 7376- `texi2dvi'. 7377- 7378-`WEAVE' 7379- Program to translate Web into TeX; default `weave'. 7380- 7381-`CWEAVE' 7382- Program to translate C Web into TeX; default `cweave'. 7383- 7384-`TANGLE' 7385- Program to translate Web into Pascal; default `tangle'. 7386- 7387-`CTANGLE' 7388- Program to translate C Web into C; default `ctangle'. 7389- 7390-`RM' 7391- Command to remove a file; default `rm -f'. 7392- 7393- Here is a table of variables whose values are additional arguments 7394-for the programs above. The default values for all of these is the 7395-empty string, unless otherwise noted. 7396- 7397-`ARFLAGS' 7398- Flags to give the archive-maintaining program; default `rv'. 7399- 7400-`ASFLAGS' 7401- Extra flags to give to the assembler (when explicitly invoked on a 7402- `.s' or `.S' file). 7403- 7404-`CFLAGS' 7405- Extra flags to give to the C compiler. 7406- 7407-`CXXFLAGS' 7408- Extra flags to give to the C++ compiler. 7409- 7410-`COFLAGS' 7411- Extra flags to give to the RCS `co' program. 7412- 7413-`CPPFLAGS' 7414- Extra flags to give to the C preprocessor and programs that use it 7415- (the C and Fortran compilers). 7416- 7417-`FFLAGS' 7418- Extra flags to give to the Fortran compiler. 7419- 7420-`GFLAGS' 7421- Extra flags to give to the SCCS `get' program. 7422- 7423-`LDFLAGS' 7424- Extra flags to give to compilers when they are supposed to invoke 7425- the linker, `ld'. 7426- 7427-`LFLAGS' 7428- Extra flags to give to Lex. 7429- 7430-`YFLAGS' 7431- Extra flags to give to Yacc. 7432- 7433-`PFLAGS' 7434- Extra flags to give to the Pascal compiler. 7435- 7436-`RFLAGS' 7437- Extra flags to give to the Fortran compiler for Ratfor programs. 7438- 7439-`LINTFLAGS' 7440- Extra flags to give to lint. 7441- 7442- 7443-File: make.info, Node: Chained Rules, Next: Pattern Rules, Prev: Implicit Variables, Up: Implicit Rules 7444- 7445-10.4 Chains of Implicit Rules 7446-============================= 7447- 7448-Sometimes a file can be made by a sequence of implicit rules. For 7449-example, a file `N.o' could be made from `N.y' by running first Yacc 7450-and then `cc'. Such a sequence is called a "chain". 7451- 7452- If the file `N.c' exists, or is mentioned in the makefile, no 7453-special searching is required: `make' finds that the object file can be 7454-made by C compilation from `N.c'; later on, when considering how to 7455-make `N.c', the rule for running Yacc is used. Ultimately both `N.c' 7456-and `N.o' are updated. 7457- 7458- However, even if `N.c' does not exist and is not mentioned, `make' 7459-knows how to envision it as the missing link between `N.o' and `N.y'! 7460-In this case, `N.c' is called an "intermediate file". Once `make' has 7461-decided to use the intermediate file, it is entered in the data base as 7462-if it had been mentioned in the makefile, along with the implicit rule 7463-that says how to create it. 7464- 7465- Intermediate files are remade using their rules just like all other 7466-files. But intermediate files are treated differently in two ways. 7467- 7468- The first difference is what happens if the intermediate file does 7469-not exist. If an ordinary file B does not exist, and `make' considers 7470-a target that depends on B, it invariably creates B and then updates 7471-the target from B. But if B is an intermediate file, then `make' can 7472-leave well enough alone. It won't bother updating B, or the ultimate 7473-target, unless some prerequisite of B is newer than that target or 7474-there is some other reason to update that target. 7475- 7476- The second difference is that if `make' _does_ create B in order to 7477-update something else, it deletes B later on after it is no longer 7478-needed. Therefore, an intermediate file which did not exist before 7479-`make' also does not exist after `make'. `make' reports the deletion 7480-to you by printing a `rm -f' command showing which file it is deleting. 7481- 7482- Ordinarily, a file cannot be intermediate if it is mentioned in the 7483-makefile as a target or prerequisite. However, you can explicitly mark 7484-a file as intermediate by listing it as a prerequisite of the special 7485-target `.INTERMEDIATE'. This takes effect even if the file is mentioned 7486-explicitly in some other way. 7487- 7488- You can prevent automatic deletion of an intermediate file by 7489-marking it as a "secondary" file. To do this, list it as a 7490-prerequisite of the special target `.SECONDARY'. When a file is 7491-secondary, `make' will not create the file merely because it does not 7492-already exist, but `make' does not automatically delete the file. 7493-Marking a file as secondary also marks it as intermediate. 7494- 7495- You can list the target pattern of an implicit rule (such as `%.o') 7496-as a prerequisite of the special target `.PRECIOUS' to preserve 7497-intermediate files made by implicit rules whose target patterns match 7498-that file's name; see *Note Interrupts::. 7499- 7500- A chain can involve more than two implicit rules. For example, it is 7501-possible to make a file `foo' from `RCS/foo.y,v' by running RCS, Yacc 7502-and `cc'. Then both `foo.y' and `foo.c' are intermediate files that 7503-are deleted at the end. 7504- 7505- No single implicit rule can appear more than once in a chain. This 7506-means that `make' will not even consider such a ridiculous thing as 7507-making `foo' from `foo.o.o' by running the linker twice. This 7508-constraint has the added benefit of preventing any infinite loop in the 7509-search for an implicit rule chain. 7510- 7511- There are some special implicit rules to optimize certain cases that 7512-would otherwise be handled by rule chains. For example, making `foo' 7513-from `foo.c' could be handled by compiling and linking with separate 7514-chained rules, using `foo.o' as an intermediate file. But what 7515-actually happens is that a special rule for this case does the 7516-compilation and linking with a single `cc' command. The optimized rule 7517-is used in preference to the step-by-step chain because it comes 7518-earlier in the ordering of rules. 7519- 7520diff -rNU3 dist.orig/doc/make.info-2 dist/doc/make.info-2 7521--- dist.orig/doc/make.info-2 2006-04-01 08:41:04.000000000 +0200 7522+++ dist/doc/make.info-2 1970-01-01 01:00:00.000000000 +0100 7523@@ -1,4393 +0,0 @@ 7524-This is make.info, produced by makeinfo version 4.8 from make.texi. 7525- 7526- This file documents the GNU `make' utility, which determines 7527-automatically which pieces of a large program need to be recompiled, 7528-and issues the commands to recompile them. 7529- 7530- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make 7531-Manual', for GNU `make' version 3.81. 7532- 7533- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 7534-1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software 7535-Foundation, Inc. 7536- 7537- Permission is granted to copy, distribute and/or modify this 7538- document under the terms of the GNU Free Documentation License, 7539- Version 1.2 or any later version published by the Free Software 7540- Foundation; with no Invariant Sections, with the Front-Cover Texts 7541- being "A GNU Manual," and with the Back-Cover Texts as in (a) 7542- below. A copy of the license is included in the section entitled 7543- "GNU Free Documentation License." 7544- 7545- (a) The FSF's Back-Cover Text is: "You have freedom to copy and 7546- modify this GNU Manual, like GNU software. Copies published by 7547- the Free Software Foundation raise funds for GNU development." 7548- 7549-INFO-DIR-SECTION GNU Packages 7550-START-INFO-DIR-ENTRY 7551-* Make: (make). Remake files automatically. 7552-END-INFO-DIR-ENTRY 7553- 7554- 7555-File: make.info, Node: Pattern Rules, Next: Last Resort, Prev: Chained Rules, Up: Implicit Rules 7556- 7557-10.5 Defining and Redefining Pattern Rules 7558-========================================== 7559- 7560-You define an implicit rule by writing a "pattern rule". A pattern 7561-rule looks like an ordinary rule, except that its target contains the 7562-character `%' (exactly one of them). The target is considered a 7563-pattern for matching file names; the `%' can match any nonempty 7564-substring, while other characters match only themselves. The 7565-prerequisites likewise use `%' to show how their names relate to the 7566-target name. 7567- 7568- Thus, a pattern rule `%.o : %.c' says how to make any file `STEM.o' 7569-from another file `STEM.c'. 7570- 7571- Note that expansion using `%' in pattern rules occurs *after* any 7572-variable or function expansions, which take place when the makefile is 7573-read. *Note How to Use Variables: Using Variables, and *Note Functions 7574-for Transforming Text: Functions. 7575- 7576-* Menu: 7577- 7578-* Pattern Intro:: An introduction to pattern rules. 7579-* Pattern Examples:: Examples of pattern rules. 7580-* Automatic Variables:: How to use automatic variables in the 7581- commands of implicit rules. 7582-* Pattern Match:: How patterns match. 7583-* Match-Anything Rules:: Precautions you should take prior to 7584- defining rules that can match any 7585- target file whatever. 7586-* Canceling Rules:: How to override or cancel built-in rules. 7587- 7588- 7589-File: make.info, Node: Pattern Intro, Next: Pattern Examples, Prev: Pattern Rules, Up: Pattern Rules 7590- 7591-10.5.1 Introduction to Pattern Rules 7592------------------------------------- 7593- 7594-A pattern rule contains the character `%' (exactly one of them) in the 7595-target; otherwise, it looks exactly like an ordinary rule. The target 7596-is a pattern for matching file names; the `%' matches any nonempty 7597-substring, while other characters match only themselves. 7598- 7599- For example, `%.c' as a pattern matches any file name that ends in 7600-`.c'. `s.%.c' as a pattern matches any file name that starts with 7601-`s.', ends in `.c' and is at least five characters long. (There must 7602-be at least one character to match the `%'.) The substring that the 7603-`%' matches is called the "stem". 7604- 7605- `%' in a prerequisite of a pattern rule stands for the same stem 7606-that was matched by the `%' in the target. In order for the pattern 7607-rule to apply, its target pattern must match the file name under 7608-consideration and all of its prerequisites (after pattern substitution) 7609-must name files that exist or can be made. These files become 7610-prerequisites of the target. 7611- 7612- Thus, a rule of the form 7613- 7614- %.o : %.c ; COMMAND... 7615- 7616-specifies how to make a file `N.o', with another file `N.c' as its 7617-prerequisite, provided that `N.c' exists or can be made. 7618- 7619- There may also be prerequisites that do not use `%'; such a 7620-prerequisite attaches to every file made by this pattern rule. These 7621-unvarying prerequisites are useful occasionally. 7622- 7623- A pattern rule need not have any prerequisites that contain `%', or 7624-in fact any prerequisites at all. Such a rule is effectively a general 7625-wildcard. It provides a way to make any file that matches the target 7626-pattern. *Note Last Resort::. 7627- 7628- Pattern rules may have more than one target. Unlike normal rules, 7629-this does not act as many different rules with the same prerequisites 7630-and commands. If a pattern rule has multiple targets, `make' knows that 7631-the rule's commands are responsible for making all of the targets. The 7632-commands are executed only once to make all the targets. When searching 7633-for a pattern rule to match a target, the target patterns of a rule 7634-other than the one that matches the target in need of a rule are 7635-incidental: `make' worries only about giving commands and prerequisites 7636-to the file presently in question. However, when this file's commands 7637-are run, the other targets are marked as having been updated themselves. 7638- 7639- The order in which pattern rules appear in the makefile is important 7640-since this is the order in which they are considered. Of equally 7641-applicable rules, only the first one found is used. The rules you 7642-write take precedence over those that are built in. Note however, that 7643-a rule whose prerequisites actually exist or are mentioned always takes 7644-priority over a rule with prerequisites that must be made by chaining 7645-other implicit rules. 7646- 7647- 7648-File: make.info, Node: Pattern Examples, Next: Automatic Variables, Prev: Pattern Intro, Up: Pattern Rules 7649- 7650-10.5.2 Pattern Rule Examples 7651----------------------------- 7652- 7653-Here are some examples of pattern rules actually predefined in `make'. 7654-First, the rule that compiles `.c' files into `.o' files: 7655- 7656- %.o : %.c 7657- $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ 7658- 7659-defines a rule that can make any file `X.o' from `X.c'. The command 7660-uses the automatic variables `$@' and `$<' to substitute the names of 7661-the target file and the source file in each case where the rule applies 7662-(*note Automatic Variables::). 7663- 7664- Here is a second built-in rule: 7665- 7666- % :: RCS/%,v 7667- $(CO) $(COFLAGS) $< 7668- 7669-defines a rule that can make any file `X' whatsoever from a 7670-corresponding file `X,v' in the subdirectory `RCS'. Since the target 7671-is `%', this rule will apply to any file whatever, provided the 7672-appropriate prerequisite file exists. The double colon makes the rule 7673-"terminal", which means that its prerequisite may not be an intermediate 7674-file (*note Match-Anything Pattern Rules: Match-Anything Rules.). 7675- 7676- This pattern rule has two targets: 7677- 7678- %.tab.c %.tab.h: %.y 7679- bison -d $< 7680- 7681-This tells `make' that the command `bison -d X.y' will make both 7682-`X.tab.c' and `X.tab.h'. If the file `foo' depends on the files 7683-`parse.tab.o' and `scan.o' and the file `scan.o' depends on the file 7684-`parse.tab.h', when `parse.y' is changed, the command `bison -d parse.y' 7685-will be executed only once, and the prerequisites of both `parse.tab.o' 7686-and `scan.o' will be satisfied. (Presumably the file `parse.tab.o' 7687-will be recompiled from `parse.tab.c' and the file `scan.o' from 7688-`scan.c', while `foo' is linked from `parse.tab.o', `scan.o', and its 7689-other prerequisites, and it will execute happily ever after.) 7690- 7691- 7692-File: make.info, Node: Automatic Variables, Next: Pattern Match, Prev: Pattern Examples, Up: Pattern Rules 7693- 7694-10.5.3 Automatic Variables 7695--------------------------- 7696- 7697-Suppose you are writing a pattern rule to compile a `.c' file into a 7698-`.o' file: how do you write the `cc' command so that it operates on the 7699-right source file name? You cannot write the name in the command, 7700-because the name is different each time the implicit rule is applied. 7701- 7702- What you do is use a special feature of `make', the "automatic 7703-variables". These variables have values computed afresh for each rule 7704-that is executed, based on the target and prerequisites of the rule. 7705-In this example, you would use `$@' for the object file name and `$<' 7706-for the source file name. 7707- 7708- It's very important that you recognize the limited scope in which 7709-automatic variable values are available: they only have values within 7710-the command script. In particular, you cannot use them anywhere within 7711-the target list of a rule; they have no value there and will expand to 7712-the empty string. Also, they cannot be accessed directly within the 7713-prerequisite list of a rule. A common mistake is attempting to use 7714-`$@' within the prerequisites list; this will not work. However, there 7715-is a special feature of GNU `make', secondary expansion (*note 7716-Secondary Expansion::), which will allow automatic variable values to 7717-be used in prerequisite lists. 7718- 7719- Here is a table of automatic variables: 7720- 7721-`$@' 7722- The file name of the target of the rule. If the target is an 7723- archive member, then `$@' is the name of the archive file. In a 7724- pattern rule that has multiple targets (*note Introduction to 7725- Pattern Rules: Pattern Intro.), `$@' is the name of whichever 7726- target caused the rule's commands to be run. 7727- 7728-`$%' 7729- The target member name, when the target is an archive member. 7730- *Note Archives::. For example, if the target is `foo.a(bar.o)' 7731- then `$%' is `bar.o' and `$@' is `foo.a'. `$%' is empty when the 7732- target is not an archive member. 7733- 7734-`$<' 7735- The name of the first prerequisite. If the target got its 7736- commands from an implicit rule, this will be the first 7737- prerequisite added by the implicit rule (*note Implicit Rules::). 7738- 7739-`$?' 7740- The names of all the prerequisites that are newer than the target, 7741- with spaces between them. For prerequisites which are archive 7742- members, only the member named is used (*note Archives::). 7743- 7744-`$^' 7745- The names of all the prerequisites, with spaces between them. For 7746- prerequisites which are archive members, only the member named is 7747- used (*note Archives::). A target has only one prerequisite on 7748- each other file it depends on, no matter how many times each file 7749- is listed as a prerequisite. So if you list a prerequisite more 7750- than once for a target, the value of `$^' contains just one copy 7751- of the name. This list does *not* contain any of the order-only 7752- prerequisites; for those see the `$|' variable, below. 7753- 7754-`$+' 7755- This is like `$^', but prerequisites listed more than once are 7756- duplicated in the order they were listed in the makefile. This is 7757- primarily useful for use in linking commands where it is 7758- meaningful to repeat library file names in a particular order. 7759- 7760-`$|' 7761- The names of all the order-only prerequisites, with spaces between 7762- them. 7763- 7764-`$*' 7765- The stem with which an implicit rule matches (*note How Patterns 7766- Match: Pattern Match.). If the target is `dir/a.foo.b' and the 7767- target pattern is `a.%.b' then the stem is `dir/foo'. The stem is 7768- useful for constructing names of related files. 7769- 7770- In a static pattern rule, the stem is part of the file name that 7771- matched the `%' in the target pattern. 7772- 7773- In an explicit rule, there is no stem; so `$*' cannot be determined 7774- in that way. Instead, if the target name ends with a recognized 7775- suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), `$*' is 7776- set to the target name minus the suffix. For example, if the 7777- target name is `foo.c', then `$*' is set to `foo', since `.c' is a 7778- suffix. GNU `make' does this bizarre thing only for compatibility 7779- with other implementations of `make'. You should generally avoid 7780- using `$*' except in implicit rules or static pattern rules. 7781- 7782- If the target name in an explicit rule does not end with a 7783- recognized suffix, `$*' is set to the empty string for that rule. 7784- 7785- `$?' is useful even in explicit rules when you wish to operate on 7786-only the prerequisites that have changed. For example, suppose that an 7787-archive named `lib' is supposed to contain copies of several object 7788-files. This rule copies just the changed object files into the archive: 7789- 7790- lib: foo.o bar.o lose.o win.o 7791- ar r lib $? 7792- 7793- Of the variables listed above, four have values that are single file 7794-names, and three have values that are lists of file names. These seven 7795-have variants that get just the file's directory name or just the file 7796-name within the directory. The variant variables' names are formed by 7797-appending `D' or `F', respectively. These variants are semi-obsolete 7798-in GNU `make' since the functions `dir' and `notdir' can be used to get 7799-a similar effect (*note Functions for File Names: File Name 7800-Functions.). Note, however, that the `D' variants all omit the 7801-trailing slash which always appears in the output of the `dir' 7802-function. Here is a table of the variants: 7803- 7804-`$(@D)' 7805- The directory part of the file name of the target, with the 7806- trailing slash removed. If the value of `$@' is `dir/foo.o' then 7807- `$(@D)' is `dir'. This value is `.' if `$@' does not contain a 7808- slash. 7809- 7810-`$(@F)' 7811- The file-within-directory part of the file name of the target. If 7812- the value of `$@' is `dir/foo.o' then `$(@F)' is `foo.o'. `$(@F)' 7813- is equivalent to `$(notdir $@)'. 7814- 7815-`$(*D)' 7816-`$(*F)' 7817- The directory part and the file-within-directory part of the stem; 7818- `dir' and `foo' in this example. 7819- 7820-`$(%D)' 7821-`$(%F)' 7822- The directory part and the file-within-directory part of the target 7823- archive member name. This makes sense only for archive member 7824- targets of the form `ARCHIVE(MEMBER)' and is useful only when 7825- MEMBER may contain a directory name. (*Note Archive Members as 7826- Targets: Archive Members.) 7827- 7828-`$(<D)' 7829-`$(<F)' 7830- The directory part and the file-within-directory part of the first 7831- prerequisite. 7832- 7833-`$(^D)' 7834-`$(^F)' 7835- Lists of the directory parts and the file-within-directory parts 7836- of all prerequisites. 7837- 7838-`$(+D)' 7839-`$(+F)' 7840- Lists of the directory parts and the file-within-directory parts 7841- of all prerequisites, including multiple instances of duplicated 7842- prerequisites. 7843- 7844-`$(?D)' 7845-`$(?F)' 7846- Lists of the directory parts and the file-within-directory parts of 7847- all prerequisites that are newer than the target. 7848- 7849- Note that we use a special stylistic convention when we talk about 7850-these automatic variables; we write "the value of `$<'", rather than 7851-"the variable `<'" as we would write for ordinary variables such as 7852-`objects' and `CFLAGS'. We think this convention looks more natural in 7853-this special case. Please do not assume it has a deep significance; 7854-`$<' refers to the variable named `<' just as `$(CFLAGS)' refers to the 7855-variable named `CFLAGS'. You could just as well use `$(<)' in place of 7856-`$<'. 7857- 7858- 7859-File: make.info, Node: Pattern Match, Next: Match-Anything Rules, Prev: Automatic Variables, Up: Pattern Rules 7860- 7861-10.5.4 How Patterns Match 7862-------------------------- 7863- 7864-A target pattern is composed of a `%' between a prefix and a suffix, 7865-either or both of which may be empty. The pattern matches a file name 7866-only if the file name starts with the prefix and ends with the suffix, 7867-without overlap. The text between the prefix and the suffix is called 7868-the "stem". Thus, when the pattern `%.o' matches the file name 7869-`test.o', the stem is `test'. The pattern rule prerequisites are 7870-turned into actual file names by substituting the stem for the character 7871-`%'. Thus, if in the same example one of the prerequisites is written 7872-as `%.c', it expands to `test.c'. 7873- 7874- When the target pattern does not contain a slash (and it usually does 7875-not), directory names in the file names are removed from the file name 7876-before it is compared with the target prefix and suffix. After the 7877-comparison of the file name to the target pattern, the directory names, 7878-along with the slash that ends them, are added on to the prerequisite 7879-file names generated from the pattern rule's prerequisite patterns and 7880-the file name. The directories are ignored only for the purpose of 7881-finding an implicit rule to use, not in the application of that rule. 7882-Thus, `e%t' matches the file name `src/eat', with `src/a' as the stem. 7883-When prerequisites are turned into file names, the directories from the 7884-stem are added at the front, while the rest of the stem is substituted 7885-for the `%'. The stem `src/a' with a prerequisite pattern `c%r' gives 7886-the file name `src/car'. 7887- 7888- 7889-File: make.info, Node: Match-Anything Rules, Next: Canceling Rules, Prev: Pattern Match, Up: Pattern Rules 7890- 7891-10.5.5 Match-Anything Pattern Rules 7892------------------------------------ 7893- 7894-When a pattern rule's target is just `%', it matches any file name 7895-whatever. We call these rules "match-anything" rules. They are very 7896-useful, but it can take a lot of time for `make' to think about them, 7897-because it must consider every such rule for each file name listed 7898-either as a target or as a prerequisite. 7899- 7900- Suppose the makefile mentions `foo.c'. For this target, `make' 7901-would have to consider making it by linking an object file `foo.c.o', 7902-or by C compilation-and-linking in one step from `foo.c.c', or by 7903-Pascal compilation-and-linking from `foo.c.p', and many other 7904-possibilities. 7905- 7906- We know these possibilities are ridiculous since `foo.c' is a C 7907-source file, not an executable. If `make' did consider these 7908-possibilities, it would ultimately reject them, because files such as 7909-`foo.c.o' and `foo.c.p' would not exist. But these possibilities are so 7910-numerous that `make' would run very slowly if it had to consider them. 7911- 7912- To gain speed, we have put various constraints on the way `make' 7913-considers match-anything rules. There are two different constraints 7914-that can be applied, and each time you define a match-anything rule you 7915-must choose one or the other for that rule. 7916- 7917- One choice is to mark the match-anything rule as "terminal" by 7918-defining it with a double colon. When a rule is terminal, it does not 7919-apply unless its prerequisites actually exist. Prerequisites that 7920-could be made with other implicit rules are not good enough. In other 7921-words, no further chaining is allowed beyond a terminal rule. 7922- 7923- For example, the built-in implicit rules for extracting sources from 7924-RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does 7925-not exist, `make' will not even consider trying to make it as an 7926-intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'. RCS 7927-and SCCS files are generally ultimate source files, which should not be 7928-remade from any other files; therefore, `make' can save time by not 7929-looking for ways to remake them. 7930- 7931- If you do not mark the match-anything rule as terminal, then it is 7932-nonterminal. A nonterminal match-anything rule cannot apply to a file 7933-name that indicates a specific type of data. A file name indicates a 7934-specific type of data if some non-match-anything implicit rule target 7935-matches it. 7936- 7937- For example, the file name `foo.c' matches the target for the pattern 7938-rule `%.c : %.y' (the rule to run Yacc). Regardless of whether this 7939-rule is actually applicable (which happens only if there is a file 7940-`foo.y'), the fact that its target matches is enough to prevent 7941-consideration of any nonterminal match-anything rules for the file 7942-`foo.c'. Thus, `make' will not even consider trying to make `foo.c' as 7943-an executable file from `foo.c.o', `foo.c.c', `foo.c.p', etc. 7944- 7945- The motivation for this constraint is that nonterminal match-anything 7946-rules are used for making files containing specific types of data (such 7947-as executable files) and a file name with a recognized suffix indicates 7948-some other specific type of data (such as a C source file). 7949- 7950- Special built-in dummy pattern rules are provided solely to recognize 7951-certain file names so that nonterminal match-anything rules will not be 7952-considered. These dummy rules have no prerequisites and no commands, 7953-and they are ignored for all other purposes. For example, the built-in 7954-implicit rule 7955- 7956- %.p : 7957- 7958-exists to make sure that Pascal source files such as `foo.p' match a 7959-specific target pattern and thereby prevent time from being wasted 7960-looking for `foo.p.o' or `foo.p.c'. 7961- 7962- Dummy pattern rules such as the one for `%.p' are made for every 7963-suffix listed as valid for use in suffix rules (*note Old-Fashioned 7964-Suffix Rules: Suffix Rules.). 7965- 7966- 7967-File: make.info, Node: Canceling Rules, Prev: Match-Anything Rules, Up: Pattern Rules 7968- 7969-10.5.6 Canceling Implicit Rules 7970-------------------------------- 7971- 7972-You can override a built-in implicit rule (or one you have defined 7973-yourself) by defining a new pattern rule with the same target and 7974-prerequisites, but different commands. When the new rule is defined, 7975-the built-in one is replaced. The new rule's position in the sequence 7976-of implicit rules is determined by where you write the new rule. 7977- 7978- You can cancel a built-in implicit rule by defining a pattern rule 7979-with the same target and prerequisites, but no commands. For example, 7980-the following would cancel the rule that runs the assembler: 7981- 7982- %.o : %.s 7983- 7984- 7985-File: make.info, Node: Last Resort, Next: Suffix Rules, Prev: Pattern Rules, Up: Implicit Rules 7986- 7987-10.6 Defining Last-Resort Default Rules 7988-======================================= 7989- 7990-You can define a last-resort implicit rule by writing a terminal 7991-match-anything pattern rule with no prerequisites (*note Match-Anything 7992-Rules::). This is just like any other pattern rule; the only thing 7993-special about it is that it will match any target. So such a rule's 7994-commands are used for all targets and prerequisites that have no 7995-commands of their own and for which no other implicit rule applies. 7996- 7997- For example, when testing a makefile, you might not care if the 7998-source files contain real data, only that they exist. Then you might 7999-do this: 8000- 8001- %:: 8002- touch $@ 8003- 8004-to cause all the source files needed (as prerequisites) to be created 8005-automatically. 8006- 8007- You can instead define commands to be used for targets for which 8008-there are no rules at all, even ones which don't specify commands. You 8009-do this by writing a rule for the target `.DEFAULT'. Such a rule's 8010-commands are used for all prerequisites which do not appear as targets 8011-in any explicit rule, and for which no implicit rule applies. 8012-Naturally, there is no `.DEFAULT' rule unless you write one. 8013- 8014- If you use `.DEFAULT' with no commands or prerequisites: 8015- 8016- .DEFAULT: 8017- 8018-the commands previously stored for `.DEFAULT' are cleared. Then `make' 8019-acts as if you had never defined `.DEFAULT' at all. 8020- 8021- If you do not want a target to get the commands from a match-anything 8022-pattern rule or `.DEFAULT', but you also do not want any commands to be 8023-run for the target, you can give it empty commands (*note Defining 8024-Empty Commands: Empty Commands.). 8025- 8026- You can use a last-resort rule to override part of another makefile. 8027-*Note Overriding Part of Another Makefile: Overriding Makefiles. 8028- 8029- 8030-File: make.info, Node: Suffix Rules, Next: Implicit Rule Search, Prev: Last Resort, Up: Implicit Rules 8031- 8032-10.7 Old-Fashioned Suffix Rules 8033-=============================== 8034- 8035-"Suffix rules" are the old-fashioned way of defining implicit rules for 8036-`make'. Suffix rules are obsolete because pattern rules are more 8037-general and clearer. They are supported in GNU `make' for 8038-compatibility with old makefiles. They come in two kinds: 8039-"double-suffix" and "single-suffix". 8040- 8041- A double-suffix rule is defined by a pair of suffixes: the target 8042-suffix and the source suffix. It matches any file whose name ends with 8043-the target suffix. The corresponding implicit prerequisite is made by 8044-replacing the target suffix with the source suffix in the file name. A 8045-two-suffix rule whose target and source suffixes are `.o' and `.c' is 8046-equivalent to the pattern rule `%.o : %.c'. 8047- 8048- A single-suffix rule is defined by a single suffix, which is the 8049-source suffix. It matches any file name, and the corresponding implicit 8050-prerequisite name is made by appending the source suffix. A 8051-single-suffix rule whose source suffix is `.c' is equivalent to the 8052-pattern rule `% : %.c'. 8053- 8054- Suffix rule definitions are recognized by comparing each rule's 8055-target against a defined list of known suffixes. When `make' sees a 8056-rule whose target is a known suffix, this rule is considered a 8057-single-suffix rule. When `make' sees a rule whose target is two known 8058-suffixes concatenated, this rule is taken as a double-suffix rule. 8059- 8060- For example, `.c' and `.o' are both on the default list of known 8061-suffixes. Therefore, if you define a rule whose target is `.c.o', 8062-`make' takes it to be a double-suffix rule with source suffix `.c' and 8063-target suffix `.o'. Here is the old-fashioned way to define the rule 8064-for compiling a C source file: 8065- 8066- .c.o: 8067- $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 8068- 8069- Suffix rules cannot have any prerequisites of their own. If they 8070-have any, they are treated as normal files with funny names, not as 8071-suffix rules. Thus, the rule: 8072- 8073- .c.o: foo.h 8074- $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 8075- 8076-tells how to make the file `.c.o' from the prerequisite file `foo.h', 8077-and is not at all like the pattern rule: 8078- 8079- %.o: %.c foo.h 8080- $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 8081- 8082-which tells how to make `.o' files from `.c' files, and makes all `.o' 8083-files using this pattern rule also depend on `foo.h'. 8084- 8085- Suffix rules with no commands are also meaningless. They do not 8086-remove previous rules as do pattern rules with no commands (*note 8087-Canceling Implicit Rules: Canceling Rules.). They simply enter the 8088-suffix or pair of suffixes concatenated as a target in the data base. 8089- 8090- The known suffixes are simply the names of the prerequisites of the 8091-special target `.SUFFIXES'. You can add your own suffixes by writing a 8092-rule for `.SUFFIXES' that adds more prerequisites, as in: 8093- 8094- .SUFFIXES: .hack .win 8095- 8096-which adds `.hack' and `.win' to the end of the list of suffixes. 8097- 8098- If you wish to eliminate the default known suffixes instead of just 8099-adding to them, write a rule for `.SUFFIXES' with no prerequisites. By 8100-special dispensation, this eliminates all existing prerequisites of 8101-`.SUFFIXES'. You can then write another rule to add the suffixes you 8102-want. For example, 8103- 8104- .SUFFIXES: # Delete the default suffixes 8105- .SUFFIXES: .c .o .h # Define our suffix list 8106- 8107- The `-r' or `--no-builtin-rules' flag causes the default list of 8108-suffixes to be empty. 8109- 8110- The variable `SUFFIXES' is defined to the default list of suffixes 8111-before `make' reads any makefiles. You can change the list of suffixes 8112-with a rule for the special target `.SUFFIXES', but that does not alter 8113-this variable. 8114- 8115- 8116-File: make.info, Node: Implicit Rule Search, Prev: Suffix Rules, Up: Implicit Rules 8117- 8118-10.8 Implicit Rule Search Algorithm 8119-=================================== 8120- 8121-Here is the procedure `make' uses for searching for an implicit rule 8122-for a target T. This procedure is followed for each double-colon rule 8123-with no commands, for each target of ordinary rules none of which have 8124-commands, and for each prerequisite that is not the target of any rule. 8125-It is also followed recursively for prerequisites that come from 8126-implicit rules, in the search for a chain of rules. 8127- 8128- Suffix rules are not mentioned in this algorithm because suffix 8129-rules are converted to equivalent pattern rules once the makefiles have 8130-been read in. 8131- 8132- For an archive member target of the form `ARCHIVE(MEMBER)', the 8133-following algorithm is run twice, first using the entire target name T, 8134-and second using `(MEMBER)' as the target T if the first run found no 8135-rule. 8136- 8137- 1. Split T into a directory part, called D, and the rest, called N. 8138- For example, if T is `src/foo.o', then D is `src/' and N is 8139- `foo.o'. 8140- 8141- 2. Make a list of all the pattern rules one of whose targets matches 8142- T or N. If the target pattern contains a slash, it is matched 8143- against T; otherwise, against N. 8144- 8145- 3. If any rule in that list is _not_ a match-anything rule, then 8146- remove all nonterminal match-anything rules from the list. 8147- 8148- 4. Remove from the list all rules with no commands. 8149- 8150- 5. For each pattern rule in the list: 8151- 8152- a. Find the stem S, which is the nonempty part of T or N matched 8153- by the `%' in the target pattern. 8154- 8155- b. Compute the prerequisite names by substituting S for `%'; if 8156- the target pattern does not contain a slash, append D to the 8157- front of each prerequisite name. 8158- 8159- c. Test whether all the prerequisites exist or ought to exist. 8160- (If a file name is mentioned in the makefile as a target or 8161- as an explicit prerequisite, then we say it ought to exist.) 8162- 8163- If all prerequisites exist or ought to exist, or there are no 8164- prerequisites, then this rule applies. 8165- 8166- 6. If no pattern rule has been found so far, try harder. For each 8167- pattern rule in the list: 8168- 8169- a. If the rule is terminal, ignore it and go on to the next rule. 8170- 8171- b. Compute the prerequisite names as before. 8172- 8173- c. Test whether all the prerequisites exist or ought to exist. 8174- 8175- d. For each prerequisite that does not exist, follow this 8176- algorithm recursively to see if the prerequisite can be made 8177- by an implicit rule. 8178- 8179- e. If all prerequisites exist, ought to exist, or can be made by 8180- implicit rules, then this rule applies. 8181- 8182- 7. If no implicit rule applies, the rule for `.DEFAULT', if any, 8183- applies. In that case, give T the same commands that `.DEFAULT' 8184- has. Otherwise, there are no commands for T. 8185- 8186- Once a rule that applies has been found, for each target pattern of 8187-the rule other than the one that matched T or N, the `%' in the pattern 8188-is replaced with S and the resultant file name is stored until the 8189-commands to remake the target file T are executed. After these 8190-commands are executed, each of these stored file names are entered into 8191-the data base and marked as having been updated and having the same 8192-update status as the file T. 8193- 8194- When the commands of a pattern rule are executed for T, the automatic 8195-variables are set corresponding to the target and prerequisites. *Note 8196-Automatic Variables::. 8197- 8198- 8199-File: make.info, Node: Archives, Next: Features, Prev: Implicit Rules, Up: Top 8200- 8201-11 Using `make' to Update Archive Files 8202-*************************************** 8203- 8204-"Archive files" are files containing named subfiles called "members"; 8205-they are maintained with the program `ar' and their main use is as 8206-subroutine libraries for linking. 8207- 8208-* Menu: 8209- 8210-* Archive Members:: Archive members as targets. 8211-* Archive Update:: The implicit rule for archive member targets. 8212-* Archive Pitfalls:: Dangers to watch out for when using archives. 8213-* Archive Suffix Rules:: You can write a special kind of suffix rule 8214- for updating archives. 8215- 8216- 8217-File: make.info, Node: Archive Members, Next: Archive Update, Prev: Archives, Up: Archives 8218- 8219-11.1 Archive Members as Targets 8220-=============================== 8221- 8222-An individual member of an archive file can be used as a target or 8223-prerequisite in `make'. You specify the member named MEMBER in archive 8224-file ARCHIVE as follows: 8225- 8226- ARCHIVE(MEMBER) 8227- 8228-This construct is available only in targets and prerequisites, not in 8229-commands! Most programs that you might use in commands do not support 8230-this syntax and cannot act directly on archive members. Only `ar' and 8231-other programs specifically designed to operate on archives can do so. 8232-Therefore, valid commands to update an archive member target probably 8233-must use `ar'. For example, this rule says to create a member `hack.o' 8234-in archive `foolib' by copying the file `hack.o': 8235- 8236- foolib(hack.o) : hack.o 8237- ar cr foolib hack.o 8238- 8239- In fact, nearly all archive member targets are updated in just this 8240-way and there is an implicit rule to do it for you. *Please note:* The 8241-`c' flag to `ar' is required if the archive file does not already exist. 8242- 8243- To specify several members in the same archive, you can write all the 8244-member names together between the parentheses. For example: 8245- 8246- foolib(hack.o kludge.o) 8247- 8248-is equivalent to: 8249- 8250- foolib(hack.o) foolib(kludge.o) 8251- 8252- You can also use shell-style wildcards in an archive member 8253-reference. *Note Using Wildcard Characters in File Names: Wildcards. 8254-For example, `foolib(*.o)' expands to all existing members of the 8255-`foolib' archive whose names end in `.o'; perhaps `foolib(hack.o) 8256-foolib(kludge.o)'. 8257- 8258- 8259-File: make.info, Node: Archive Update, Next: Archive Pitfalls, Prev: Archive Members, Up: Archives 8260- 8261-11.2 Implicit Rule for Archive Member Targets 8262-============================================= 8263- 8264-Recall that a target that looks like `A(M)' stands for the member named 8265-M in the archive file A. 8266- 8267- When `make' looks for an implicit rule for such a target, as a 8268-special feature it considers implicit rules that match `(M)', as well as 8269-those that match the actual target `A(M)'. 8270- 8271- This causes one special rule whose target is `(%)' to match. This 8272-rule updates the target `A(M)' by copying the file M into the archive. 8273-For example, it will update the archive member target `foo.a(bar.o)' by 8274-copying the _file_ `bar.o' into the archive `foo.a' as a _member_ named 8275-`bar.o'. 8276- 8277- When this rule is chained with others, the result is very powerful. 8278-Thus, `make "foo.a(bar.o)"' (the quotes are needed to protect the `(' 8279-and `)' from being interpreted specially by the shell) in the presence 8280-of a file `bar.c' is enough to cause the following commands to be run, 8281-even without a makefile: 8282- 8283- cc -c bar.c -o bar.o 8284- ar r foo.a bar.o 8285- rm -f bar.o 8286- 8287-Here `make' has envisioned the file `bar.o' as an intermediate file. 8288-*Note Chains of Implicit Rules: Chained Rules. 8289- 8290- Implicit rules such as this one are written using the automatic 8291-variable `$%'. *Note Automatic Variables::. 8292- 8293- An archive member name in an archive cannot contain a directory 8294-name, but it may be useful in a makefile to pretend that it does. If 8295-you write an archive member target `foo.a(dir/file.o)', `make' will 8296-perform automatic updating with this command: 8297- 8298- ar r foo.a dir/file.o 8299- 8300-which has the effect of copying the file `dir/file.o' into a member 8301-named `file.o'. In connection with such usage, the automatic variables 8302-`%D' and `%F' may be useful. 8303- 8304-* Menu: 8305- 8306-* Archive Symbols:: How to update archive symbol directories. 8307- 8308- 8309-File: make.info, Node: Archive Symbols, Prev: Archive Update, Up: Archive Update 8310- 8311-11.2.1 Updating Archive Symbol Directories 8312------------------------------------------- 8313- 8314-An archive file that is used as a library usually contains a special 8315-member named `__.SYMDEF' that contains a directory of the external 8316-symbol names defined by all the other members. After you update any 8317-other members, you need to update `__.SYMDEF' so that it will summarize 8318-the other members properly. This is done by running the `ranlib' 8319-program: 8320- 8321- ranlib ARCHIVEFILE 8322- 8323- Normally you would put this command in the rule for the archive file, 8324-and make all the members of the archive file prerequisites of that rule. 8325-For example, 8326- 8327- libfoo.a: libfoo.a(x.o) libfoo.a(y.o) ... 8328- ranlib libfoo.a 8329- 8330-The effect of this is to update archive members `x.o', `y.o', etc., and 8331-then update the symbol directory member `__.SYMDEF' by running 8332-`ranlib'. The rules for updating the members are not shown here; most 8333-likely you can omit them and use the implicit rule which copies files 8334-into the archive, as described in the preceding section. 8335- 8336- This is not necessary when using the GNU `ar' program, which updates 8337-the `__.SYMDEF' member automatically. 8338- 8339- 8340-File: make.info, Node: Archive Pitfalls, Next: Archive Suffix Rules, Prev: Archive Update, Up: Archives 8341- 8342-11.3 Dangers When Using Archives 8343-================================ 8344- 8345-It is important to be careful when using parallel execution (the `-j' 8346-switch; *note Parallel Execution: Parallel.) and archives. If multiple 8347-`ar' commands run at the same time on the same archive file, they will 8348-not know about each other and can corrupt the file. 8349- 8350- Possibly a future version of `make' will provide a mechanism to 8351-circumvent this problem by serializing all commands that operate on the 8352-same archive file. But for the time being, you must either write your 8353-makefiles to avoid this problem in some other way, or not use `-j'. 8354- 8355- 8356-File: make.info, Node: Archive Suffix Rules, Prev: Archive Pitfalls, Up: Archives 8357- 8358-11.4 Suffix Rules for Archive Files 8359-=================================== 8360- 8361-You can write a special kind of suffix rule for dealing with archive 8362-files. *Note Suffix Rules::, for a full explanation of suffix rules. 8363-Archive suffix rules are obsolete in GNU `make', because pattern rules 8364-for archives are a more general mechanism (*note Archive Update::). 8365-But they are retained for compatibility with other `make's. 8366- 8367- To write a suffix rule for archives, you simply write a suffix rule 8368-using the target suffix `.a' (the usual suffix for archive files). For 8369-example, here is the old-fashioned suffix rule to update a library 8370-archive from C source files: 8371- 8372- .c.a: 8373- $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o 8374- $(AR) r $@ $*.o 8375- $(RM) $*.o 8376- 8377-This works just as if you had written the pattern rule: 8378- 8379- (%.o): %.c 8380- $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o 8381- $(AR) r $@ $*.o 8382- $(RM) $*.o 8383- 8384- In fact, this is just what `make' does when it sees a suffix rule 8385-with `.a' as the target suffix. Any double-suffix rule `.X.a' is 8386-converted to a pattern rule with the target pattern `(%.o)' and a 8387-prerequisite pattern of `%.X'. 8388- 8389- Since you might want to use `.a' as the suffix for some other kind 8390-of file, `make' also converts archive suffix rules to pattern rules in 8391-the normal way (*note Suffix Rules::). Thus a double-suffix rule 8392-`.X.a' produces two pattern rules: `(%.o): %.X' and `%.a: %.X'. 8393- 8394- 8395-File: make.info, Node: Features, Next: Missing, Prev: Archives, Up: Top 8396- 8397-12 Features of GNU `make' 8398-************************* 8399- 8400-Here is a summary of the features of GNU `make', for comparison with 8401-and credit to other versions of `make'. We consider the features of 8402-`make' in 4.2 BSD systems as a baseline. If you are concerned with 8403-writing portable makefiles, you should not use the features of `make' 8404-listed here, nor the ones in *Note Missing::. 8405- 8406- Many features come from the version of `make' in System V. 8407- 8408- * The `VPATH' variable and its special meaning. *Note Searching 8409- Directories for Prerequisites: Directory Search. This feature 8410- exists in System V `make', but is undocumented. It is documented 8411- in 4.3 BSD `make' (which says it mimics System V's `VPATH' 8412- feature). 8413- 8414- * Included makefiles. *Note Including Other Makefiles: Include. 8415- Allowing multiple files to be included with a single directive is 8416- a GNU extension. 8417- 8418- * Variables are read from and communicated via the environment. 8419- *Note Variables from the Environment: Environment. 8420- 8421- * Options passed through the variable `MAKEFLAGS' to recursive 8422- invocations of `make'. *Note Communicating Options to a 8423- Sub-`make': Options/Recursion. 8424- 8425- * The automatic variable `$%' is set to the member name in an 8426- archive reference. *Note Automatic Variables::. 8427- 8428- * The automatic variables `$@', `$*', `$<', `$%', and `$?' have 8429- corresponding forms like `$(@F)' and `$(@D)'. We have generalized 8430- this to `$^' as an obvious extension. *Note Automatic Variables::. 8431- 8432- * Substitution variable references. *Note Basics of Variable 8433- References: Reference. 8434- 8435- * The command-line options `-b' and `-m', accepted and ignored. In 8436- System V `make', these options actually do something. 8437- 8438- * Execution of recursive commands to run `make' via the variable 8439- `MAKE' even if `-n', `-q' or `-t' is specified. *Note Recursive 8440- Use of `make': Recursion. 8441- 8442- * Support for suffix `.a' in suffix rules. *Note Archive Suffix 8443- Rules::. This feature is obsolete in GNU `make', because the 8444- general feature of rule chaining (*note Chains of Implicit Rules: 8445- Chained Rules.) allows one pattern rule for installing members in 8446- an archive (*note Archive Update::) to be sufficient. 8447- 8448- * The arrangement of lines and backslash-newline combinations in 8449- commands is retained when the commands are printed, so they appear 8450- as they do in the makefile, except for the stripping of initial 8451- whitespace. 8452- 8453- The following features were inspired by various other versions of 8454-`make'. In some cases it is unclear exactly which versions inspired 8455-which others. 8456- 8457- * Pattern rules using `%'. This has been implemented in several 8458- versions of `make'. We're not sure who invented it first, but 8459- it's been spread around a bit. *Note Defining and Redefining 8460- Pattern Rules: Pattern Rules. 8461- 8462- * Rule chaining and implicit intermediate files. This was 8463- implemented by Stu Feldman in his version of `make' for AT&T 8464- Eighth Edition Research Unix, and later by Andrew Hume of AT&T 8465- Bell Labs in his `mk' program (where he terms it "transitive 8466- closure"). We do not really know if we got this from either of 8467- them or thought it up ourselves at the same time. *Note Chains of 8468- Implicit Rules: Chained Rules. 8469- 8470- * The automatic variable `$^' containing a list of all prerequisites 8471- of the current target. We did not invent this, but we have no 8472- idea who did. *Note Automatic Variables::. The automatic variable 8473- `$+' is a simple extension of `$^'. 8474- 8475- * The "what if" flag (`-W' in GNU `make') was (as far as we know) 8476- invented by Andrew Hume in `mk'. *Note Instead of Executing the 8477- Commands: Instead of Execution. 8478- 8479- * The concept of doing several things at once (parallelism) exists in 8480- many incarnations of `make' and similar programs, though not in the 8481- System V or BSD implementations. *Note Command Execution: 8482- Execution. 8483- 8484- * Modified variable references using pattern substitution come from 8485- SunOS 4. *Note Basics of Variable References: Reference. This 8486- functionality was provided in GNU `make' by the `patsubst' 8487- function before the alternate syntax was implemented for 8488- compatibility with SunOS 4. It is not altogether clear who 8489- inspired whom, since GNU `make' had `patsubst' before SunOS 4 was 8490- released. 8491- 8492- * The special significance of `+' characters preceding command lines 8493- (*note Instead of Executing the Commands: Instead of Execution.) is 8494- mandated by `IEEE Standard 1003.2-1992' (POSIX.2). 8495- 8496- * The `+=' syntax to append to the value of a variable comes from 8497- SunOS 4 `make'. *Note Appending More Text to Variables: Appending. 8498- 8499- * The syntax `ARCHIVE(MEM1 MEM2...)' to list multiple members in a 8500- single archive file comes from SunOS 4 `make'. *Note Archive 8501- Members::. 8502- 8503- * The `-include' directive to include makefiles with no error for a 8504- nonexistent file comes from SunOS 4 `make'. (But note that SunOS 4 8505- `make' does not allow multiple makefiles to be specified in one 8506- `-include' directive.) The same feature appears with the name 8507- `sinclude' in SGI `make' and perhaps others. 8508- 8509- The remaining features are inventions new in GNU `make': 8510- 8511- * Use the `-v' or `--version' option to print version and copyright 8512- information. 8513- 8514- * Use the `-h' or `--help' option to summarize the options to `make'. 8515- 8516- * Simply-expanded variables. *Note The Two Flavors of Variables: 8517- Flavors. 8518- 8519- * Pass command-line variable assignments automatically through the 8520- variable `MAKE' to recursive `make' invocations. *Note Recursive 8521- Use of `make': Recursion. 8522- 8523- * Use the `-C' or `--directory' command option to change directory. 8524- *Note Summary of Options: Options Summary. 8525- 8526- * Make verbatim variable definitions with `define'. *Note Defining 8527- Variables Verbatim: Defining. 8528- 8529- * Declare phony targets with the special target `.PHONY'. 8530- 8531- Andrew Hume of AT&T Bell Labs implemented a similar feature with a 8532- different syntax in his `mk' program. This seems to be a case of 8533- parallel discovery. *Note Phony Targets: Phony Targets. 8534- 8535- * Manipulate text by calling functions. *Note Functions for 8536- Transforming Text: Functions. 8537- 8538- * Use the `-o' or `--old-file' option to pretend a file's 8539- modification-time is old. *Note Avoiding Recompilation of Some 8540- Files: Avoiding Compilation. 8541- 8542- * Conditional execution. 8543- 8544- This feature has been implemented numerous times in various 8545- versions of `make'; it seems a natural extension derived from the 8546- features of the C preprocessor and similar macro languages and is 8547- not a revolutionary concept. *Note Conditional Parts of 8548- Makefiles: Conditionals. 8549- 8550- * Specify a search path for included makefiles. *Note Including 8551- Other Makefiles: Include. 8552- 8553- * Specify extra makefiles to read with an environment variable. 8554- *Note The Variable `MAKEFILES': MAKEFILES Variable. 8555- 8556- * Strip leading sequences of `./' from file names, so that `./FILE' 8557- and `FILE' are considered to be the same file. 8558- 8559- * Use a special search method for library prerequisites written in 8560- the form `-lNAME'. *Note Directory Search for Link Libraries: 8561- Libraries/Search. 8562- 8563- * Allow suffixes for suffix rules (*note Old-Fashioned Suffix Rules: 8564- Suffix Rules.) to contain any characters. In other versions of 8565- `make', they must begin with `.' and not contain any `/' 8566- characters. 8567- 8568- * Keep track of the current level of `make' recursion using the 8569- variable `MAKELEVEL'. *Note Recursive Use of `make': Recursion. 8570- 8571- * Provide any goals given on the command line in the variable 8572- `MAKECMDGOALS'. *Note Arguments to Specify the Goals: Goals. 8573- 8574- * Specify static pattern rules. *Note Static Pattern Rules: Static 8575- Pattern. 8576- 8577- * Provide selective `vpath' search. *Note Searching Directories for 8578- Prerequisites: Directory Search. 8579- 8580- * Provide computed variable references. *Note Basics of Variable 8581- References: Reference. 8582- 8583- * Update makefiles. *Note How Makefiles Are Remade: Remaking 8584- Makefiles. System V `make' has a very, very limited form of this 8585- functionality in that it will check out SCCS files for makefiles. 8586- 8587- * Various new built-in implicit rules. *Note Catalogue of Implicit 8588- Rules: Catalogue of Rules. 8589- 8590- * The built-in variable `MAKE_VERSION' gives the version number of 8591- `make'. 8592- 8593- 8594-File: make.info, Node: Missing, Next: Makefile Conventions, Prev: Features, Up: Top 8595- 8596-13 Incompatibilities and Missing Features 8597-***************************************** 8598- 8599-The `make' programs in various other systems support a few features 8600-that are not implemented in GNU `make'. The POSIX.2 standard (`IEEE 8601-Standard 1003.2-1992') which specifies `make' does not require any of 8602-these features. 8603- 8604- * A target of the form `FILE((ENTRY))' stands for a member of 8605- archive file FILE. The member is chosen, not by name, but by 8606- being an object file which defines the linker symbol ENTRY. 8607- 8608- This feature was not put into GNU `make' because of the 8609- nonmodularity of putting knowledge into `make' of the internal 8610- format of archive file symbol tables. *Note Updating Archive 8611- Symbol Directories: Archive Symbols. 8612- 8613- * Suffixes (used in suffix rules) that end with the character `~' 8614- have a special meaning to System V `make'; they refer to the SCCS 8615- file that corresponds to the file one would get without the `~'. 8616- For example, the suffix rule `.c~.o' would make the file `N.o' from 8617- the SCCS file `s.N.c'. For complete coverage, a whole series of 8618- such suffix rules is required. *Note Old-Fashioned Suffix Rules: 8619- Suffix Rules. 8620- 8621- In GNU `make', this entire series of cases is handled by two 8622- pattern rules for extraction from SCCS, in combination with the 8623- general feature of rule chaining. *Note Chains of Implicit Rules: 8624- Chained Rules. 8625- 8626- * In System V and 4.3 BSD `make', files found by `VPATH' search 8627- (*note Searching Directories for Prerequisites: Directory Search.) 8628- have their names changed inside command strings. We feel it is 8629- much cleaner to always use automatic variables and thus make this 8630- feature obsolete. 8631- 8632- * In some Unix `make's, the automatic variable `$*' appearing in the 8633- prerequisites of a rule has the amazingly strange "feature" of 8634- expanding to the full name of the _target of that rule_. We cannot 8635- imagine what went on in the minds of Unix `make' developers to do 8636- this; it is utterly inconsistent with the normal definition of 8637- `$*'. 8638- 8639- * In some Unix `make's, implicit rule search (*note Using Implicit 8640- Rules: Implicit Rules.) is apparently done for _all_ targets, not 8641- just those without commands. This means you can do: 8642- 8643- foo.o: 8644- cc -c foo.c 8645- 8646- and Unix `make' will intuit that `foo.o' depends on `foo.c'. 8647- 8648- We feel that such usage is broken. The prerequisite properties of 8649- `make' are well-defined (for GNU `make', at least), and doing such 8650- a thing simply does not fit the model. 8651- 8652- * GNU `make' does not include any built-in implicit rules for 8653- compiling or preprocessing EFL programs. If we hear of anyone who 8654- is using EFL, we will gladly add them. 8655- 8656- * It appears that in SVR4 `make', a suffix rule can be specified with 8657- no commands, and it is treated as if it had empty commands (*note 8658- Empty Commands::). For example: 8659- 8660- .c.a: 8661- 8662- will override the built-in `.c.a' suffix rule. 8663- 8664- We feel that it is cleaner for a rule without commands to always 8665- simply add to the prerequisite list for the target. The above 8666- example can be easily rewritten to get the desired behavior in GNU 8667- `make': 8668- 8669- .c.a: ; 8670- 8671- * Some versions of `make' invoke the shell with the `-e' flag, 8672- except under `-k' (*note Testing the Compilation of a Program: 8673- Testing.). The `-e' flag tells the shell to exit as soon as any 8674- program it runs returns a nonzero status. We feel it is cleaner to 8675- write each shell command line to stand on its own and not require 8676- this special treatment. 8677- 8678- 8679-File: make.info, Node: Makefile Conventions, Next: Quick Reference, Prev: Missing, Up: Top 8680- 8681-14 Makefile Conventions 8682-*********************** 8683- 8684-This node describes conventions for writing the Makefiles for GNU 8685-programs. Using Automake will help you write a Makefile that follows 8686-these conventions. 8687- 8688-* Menu: 8689- 8690-* Makefile Basics:: General Conventions for Makefiles 8691-* Utilities in Makefiles:: Utilities in Makefiles 8692-* Command Variables:: Variables for Specifying Commands 8693-* Directory Variables:: Variables for Installation Directories 8694-* Standard Targets:: Standard Targets for Users 8695-* Install Command Categories:: Three categories of commands in the `install' 8696- rule: normal, pre-install and post-install. 8697- 8698- 8699-File: make.info, Node: Makefile Basics, Next: Utilities in Makefiles, Up: Makefile Conventions 8700- 8701-14.1 General Conventions for Makefiles 8702-====================================== 8703- 8704-Every Makefile should contain this line: 8705- 8706- SHELL = /bin/sh 8707- 8708-to avoid trouble on systems where the `SHELL' variable might be 8709-inherited from the environment. (This is never a problem with GNU 8710-`make'.) 8711- 8712- Different `make' programs have incompatible suffix lists and 8713-implicit rules, and this sometimes creates confusion or misbehavior. So 8714-it is a good idea to set the suffix list explicitly using only the 8715-suffixes you need in the particular Makefile, like this: 8716- 8717- .SUFFIXES: 8718- .SUFFIXES: .c .o 8719- 8720-The first line clears out the suffix list, the second introduces all 8721-suffixes which may be subject to implicit rules in this Makefile. 8722- 8723- Don't assume that `.' is in the path for command execution. When 8724-you need to run programs that are a part of your package during the 8725-make, please make sure that it uses `./' if the program is built as 8726-part of the make or `$(srcdir)/' if the file is an unchanging part of 8727-the source code. Without one of these prefixes, the current search 8728-path is used. 8729- 8730- The distinction between `./' (the "build directory") and 8731-`$(srcdir)/' (the "source directory") is important because users can 8732-build in a separate directory using the `--srcdir' option to 8733-`configure'. A rule of the form: 8734- 8735- foo.1 : foo.man sedscript 8736- sed -e sedscript foo.man > foo.1 8737- 8738-will fail when the build directory is not the source directory, because 8739-`foo.man' and `sedscript' are in the source directory. 8740- 8741- When using GNU `make', relying on `VPATH' to find the source file 8742-will work in the case where there is a single dependency file, since 8743-the `make' automatic variable `$<' will represent the source file 8744-wherever it is. (Many versions of `make' set `$<' only in implicit 8745-rules.) A Makefile target like 8746- 8747- foo.o : bar.c 8748- $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o 8749- 8750-should instead be written as 8751- 8752- foo.o : bar.c 8753- $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@ 8754- 8755-in order to allow `VPATH' to work correctly. When the target has 8756-multiple dependencies, using an explicit `$(srcdir)' is the easiest way 8757-to make the rule work well. For example, the target above for `foo.1' 8758-is best written as: 8759- 8760- foo.1 : foo.man sedscript 8761- sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@ 8762- 8763- GNU distributions usually contain some files which are not source 8764-files--for example, Info files, and the output from Autoconf, Automake, 8765-Bison or Flex. Since these files normally appear in the source 8766-directory, they should always appear in the source directory, not in the 8767-build directory. So Makefile rules to update them should put the 8768-updated files in the source directory. 8769- 8770- However, if a file does not appear in the distribution, then the 8771-Makefile should not put it in the source directory, because building a 8772-program in ordinary circumstances should not modify the source directory 8773-in any way. 8774- 8775- Try to make the build and installation targets, at least (and all 8776-their subtargets) work correctly with a parallel `make'. 8777- 8778- 8779-File: make.info, Node: Utilities in Makefiles, Next: Command Variables, Prev: Makefile Basics, Up: Makefile Conventions 8780- 8781-14.2 Utilities in Makefiles 8782-=========================== 8783- 8784-Write the Makefile commands (and any shell scripts, such as 8785-`configure') to run in `sh', not in `csh'. Don't use any special 8786-features of `ksh' or `bash'. 8787- 8788- The `configure' script and the Makefile rules for building and 8789-installation should not use any utilities directly except these: 8790- 8791- cat cmp cp diff echo egrep expr false grep install-info 8792- ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true 8793- 8794- The compression program `gzip' can be used in the `dist' rule. 8795- 8796- Stick to the generally supported options for these programs. For 8797-example, don't use `mkdir -p', convenient as it may be, because most 8798-systems don't support it. 8799- 8800- It is a good idea to avoid creating symbolic links in makefiles, 8801-since a few systems don't support them. 8802- 8803- The Makefile rules for building and installation can also use 8804-compilers and related programs, but should do so via `make' variables 8805-so that the user can substitute alternatives. Here are some of the 8806-programs we mean: 8807- 8808- ar bison cc flex install ld ldconfig lex 8809- make makeinfo ranlib texi2dvi yacc 8810- 8811- Use the following `make' variables to run those programs: 8812- 8813- $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) 8814- $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) 8815- 8816- When you use `ranlib' or `ldconfig', you should make sure nothing 8817-bad happens if the system does not have the program in question. 8818-Arrange to ignore an error from that command, and print a message before 8819-the command to tell the user that failure of this command does not mean 8820-a problem. (The Autoconf `AC_PROG_RANLIB' macro can help with this.) 8821- 8822- If you use symbolic links, you should implement a fallback for 8823-systems that don't have symbolic links. 8824- 8825- Additional utilities that can be used via Make variables are: 8826- 8827- chgrp chmod chown mknod 8828- 8829- It is ok to use other utilities in Makefile portions (or scripts) 8830-intended only for particular systems where you know those utilities 8831-exist. 8832- 8833- 8834-File: make.info, Node: Command Variables, Next: Directory Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions 8835- 8836-14.3 Variables for Specifying Commands 8837-====================================== 8838- 8839-Makefiles should provide variables for overriding certain commands, 8840-options, and so on. 8841- 8842- In particular, you should run most utility programs via variables. 8843-Thus, if you use Bison, have a variable named `BISON' whose default 8844-value is set with `BISON = bison', and refer to it with `$(BISON)' 8845-whenever you need to use Bison. 8846- 8847- File management utilities such as `ln', `rm', `mv', and so on, need 8848-not be referred to through variables in this way, since users don't 8849-need to replace them with other programs. 8850- 8851- Each program-name variable should come with an options variable that 8852-is used to supply options to the program. Append `FLAGS' to the 8853-program-name variable name to get the options variable name--for 8854-example, `BISONFLAGS'. (The names `CFLAGS' for the C compiler, 8855-`YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule, 8856-but we keep them because they are standard.) Use `CPPFLAGS' in any 8857-compilation command that runs the preprocessor, and use `LDFLAGS' in 8858-any compilation command that does linking as well as in any direct use 8859-of `ld'. 8860- 8861- If there are C compiler options that _must_ be used for proper 8862-compilation of certain files, do not include them in `CFLAGS'. Users 8863-expect to be able to specify `CFLAGS' freely themselves. Instead, 8864-arrange to pass the necessary options to the C compiler independently 8865-of `CFLAGS', by writing them explicitly in the compilation commands or 8866-by defining an implicit rule, like this: 8867- 8868- CFLAGS = -g 8869- ALL_CFLAGS = -I. $(CFLAGS) 8870- .c.o: 8871- $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< 8872- 8873- Do include the `-g' option in `CFLAGS', because that is not 8874-_required_ for proper compilation. You can consider it a default that 8875-is only recommended. If the package is set up so that it is compiled 8876-with GCC by default, then you might as well include `-O' in the default 8877-value of `CFLAGS' as well. 8878- 8879- Put `CFLAGS' last in the compilation command, after other variables 8880-containing compiler options, so the user can use `CFLAGS' to override 8881-the others. 8882- 8883- `CFLAGS' should be used in every invocation of the C compiler, both 8884-those which do compilation and those which do linking. 8885- 8886- Every Makefile should define the variable `INSTALL', which is the 8887-basic command for installing a file into the system. 8888- 8889- Every Makefile should also define the variables `INSTALL_PROGRAM' 8890-and `INSTALL_DATA'. (The default for `INSTALL_PROGRAM' should be 8891-`$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m 8892-644'.) Then it should use those variables as the commands for actual 8893-installation, for executables and nonexecutables respectively. Use 8894-these variables as follows: 8895- 8896- $(INSTALL_PROGRAM) foo $(bindir)/foo 8897- $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a 8898- 8899- Optionally, you may prepend the value of `DESTDIR' to the target 8900-filename. Doing this allows the installer to create a snapshot of the 8901-installation to be copied onto the real target filesystem later. Do not 8902-set the value of `DESTDIR' in your Makefile, and do not include it in 8903-any installed files. With support for `DESTDIR', the above examples 8904-become: 8905- 8906- $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo 8907- $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a 8908- 8909-Always use a file name, not a directory name, as the second argument of 8910-the installation commands. Use a separate command for each file to be 8911-installed. 8912- 8913- 8914-File: make.info, Node: Directory Variables, Next: Standard Targets, Prev: Command Variables, Up: Makefile Conventions 8915- 8916-14.4 Variables for Installation Directories 8917-=========================================== 8918- 8919-Installation directories should always be named by variables, so it is 8920-easy to install in a nonstandard place. The standard names for these 8921-variables and the values they should have in GNU packages are described 8922-below. They are based on a standard filesystem layout; variants of it 8923-are used in GNU/Linux and other modern operating systems. 8924- 8925- Installers are expected to override these values when calling `make' 8926-(e.g., `make prefix=/usr install' or `configure' (e.g., `configure 8927---prefix=/usr'). GNU packages should not try to guess which value 8928-should be appropriate for these variables on the system they are being 8929-installed onto: use the default settings specified here so that all GNU 8930-packages behave identically, allowing the installer to achieve any 8931-desired layout. 8932- 8933- These two variables set the root for the installation. All the other 8934-installation directories should be subdirectories of one of these two, 8935-and nothing should be directly installed into these two directories. 8936- 8937-`prefix' 8938- A prefix used in constructing the default values of the variables 8939- listed below. The default value of `prefix' should be 8940- `/usr/local'. When building the complete GNU system, the prefix 8941- will be empty and `/usr' will be a symbolic link to `/'. (If you 8942- are using Autoconf, write it as `@prefix@'.) 8943- 8944- Running `make install' with a different value of `prefix' from the 8945- one used to build the program should _not_ recompile the program. 8946- 8947-`exec_prefix' 8948- A prefix used in constructing the default values of some of the 8949- variables listed below. The default value of `exec_prefix' should 8950- be `$(prefix)'. (If you are using Autoconf, write it as 8951- `@exec_prefix@'.) 8952- 8953- Generally, `$(exec_prefix)' is used for directories that contain 8954- machine-specific files (such as executables and subroutine 8955- libraries), while `$(prefix)' is used directly for other 8956- directories. 8957- 8958- Running `make install' with a different value of `exec_prefix' 8959- from the one used to build the program should _not_ recompile the 8960- program. 8961- 8962- Executable programs are installed in one of the following 8963-directories. 8964- 8965-`bindir' 8966- The directory for installing executable programs that users can 8967- run. This should normally be `/usr/local/bin', but write it as 8968- `$(exec_prefix)/bin'. (If you are using Autoconf, write it as 8969- `@bindir@'.) 8970- 8971-`sbindir' 8972- The directory for installing executable programs that can be run 8973- from the shell, but are only generally useful to system 8974- administrators. This should normally be `/usr/local/sbin', but 8975- write it as `$(exec_prefix)/sbin'. (If you are using Autoconf, 8976- write it as `@sbindir@'.) 8977- 8978-`libexecdir' 8979- The directory for installing executable programs to be run by other 8980- programs rather than by users. This directory should normally be 8981- `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'. 8982- (If you are using Autoconf, write it as `@libexecdir@'.) 8983- 8984- The definition of `libexecdir' is the same for all packages, so 8985- you should install your data in a subdirectory thereof. Most 8986- packages install their data under `$(libexecdir)/PACKAGE-NAME/', 8987- possibly within additional subdirectories thereof, such as 8988- `$(libexecdir)/PACKAGE-NAME/MACHINE/VERSION'. 8989- 8990- Data files used by the program during its execution are divided into 8991-categories in two ways. 8992- 8993- * Some files are normally modified by programs; others are never 8994- normally modified (though users may edit some of these). 8995- 8996- * Some files are architecture-independent and can be shared by all 8997- machines at a site; some are architecture-dependent and can be 8998- shared only by machines of the same kind and operating system; 8999- others may never be shared between two machines. 9000- 9001- This makes for six different possibilities. However, we want to 9002-discourage the use of architecture-dependent files, aside from object 9003-files and libraries. It is much cleaner to make other data files 9004-architecture-independent, and it is generally not hard. 9005- 9006- Here are the variables Makefiles should use to specify directories 9007-to put these various kinds of files in: 9008- 9009-`datarootdir' 9010- The root of the directory tree for read-only 9011- architecture-independent data files. This should normally be 9012- `/usr/local/share', but write it as `$(prefix)/share'. (If you 9013- are using Autoconf, write it as `@datarootdir@'.) `datadir''s 9014- default value is based on this variable; so are `infodir', 9015- `mandir', and others. 9016- 9017-`datadir' 9018- The directory for installing idiosyncratic read-only 9019- architecture-independent data files for this program. This is 9020- usually the same place as `datarootdir', but we use the two 9021- separate variables so that you can move these program-specific 9022- files without altering the location for Info files, man pages, etc. 9023- 9024- This should normally be `/usr/local/share', but write it as 9025- `$(datarootdir)'. (If you are using Autoconf, write it as 9026- `@datadir@'.) 9027- 9028- The definition of `datadir' is the same for all packages, so you 9029- should install your data in a subdirectory thereof. Most packages 9030- install their data under `$(datadir)/PACKAGE-NAME/'. 9031- 9032-`sysconfdir' 9033- The directory for installing read-only data files that pertain to a 9034- single machine-that is to say, files for configuring a host. 9035- Mailer and network configuration files, `/etc/passwd', and so 9036- forth belong here. All the files in this directory should be 9037- ordinary ASCII text files. This directory should normally be 9038- `/usr/local/etc', but write it as `$(prefix)/etc'. (If you are 9039- using Autoconf, write it as `@sysconfdir@'.) 9040- 9041- Do not install executables here in this directory (they probably 9042- belong in `$(libexecdir)' or `$(sbindir)'). Also do not install 9043- files that are modified in the normal course of their use (programs 9044- whose purpose is to change the configuration of the system 9045- excluded). Those probably belong in `$(localstatedir)'. 9046- 9047-`sharedstatedir' 9048- The directory for installing architecture-independent data files 9049- which the programs modify while they run. This should normally be 9050- `/usr/local/com', but write it as `$(prefix)/com'. (If you are 9051- using Autoconf, write it as `@sharedstatedir@'.) 9052- 9053-`localstatedir' 9054- The directory for installing data files which the programs modify 9055- while they run, and that pertain to one specific machine. Users 9056- should never need to modify files in this directory to configure 9057- the package's operation; put such configuration information in 9058- separate files that go in `$(datadir)' or `$(sysconfdir)'. 9059- `$(localstatedir)' should normally be `/usr/local/var', but write 9060- it as `$(prefix)/var'. (If you are using Autoconf, write it as 9061- `@localstatedir@'.) 9062- 9063- These variables specify the directory for installing certain specific 9064-types of files, if your program has them. Every GNU package should 9065-have Info files, so every program needs `infodir', but not all need 9066-`libdir' or `lispdir'. 9067- 9068-`includedir' 9069- The directory for installing header files to be included by user 9070- programs with the C `#include' preprocessor directive. This 9071- should normally be `/usr/local/include', but write it as 9072- `$(prefix)/include'. (If you are using Autoconf, write it as 9073- `@includedir@'.) 9074- 9075- Most compilers other than GCC do not look for header files in 9076- directory `/usr/local/include'. So installing the header files 9077- this way is only useful with GCC. Sometimes this is not a problem 9078- because some libraries are only really intended to work with GCC. 9079- But some libraries are intended to work with other compilers. 9080- They should install their header files in two places, one 9081- specified by `includedir' and one specified by `oldincludedir'. 9082- 9083-`oldincludedir' 9084- The directory for installing `#include' header files for use with 9085- compilers other than GCC. This should normally be `/usr/include'. 9086- (If you are using Autoconf, you can write it as `@oldincludedir@'.) 9087- 9088- The Makefile commands should check whether the value of 9089- `oldincludedir' is empty. If it is, they should not try to use 9090- it; they should cancel the second installation of the header files. 9091- 9092- A package should not replace an existing header in this directory 9093- unless the header came from the same package. Thus, if your Foo 9094- package provides a header file `foo.h', then it should install the 9095- header file in the `oldincludedir' directory if either (1) there 9096- is no `foo.h' there or (2) the `foo.h' that exists came from the 9097- Foo package. 9098- 9099- To tell whether `foo.h' came from the Foo package, put a magic 9100- string in the file--part of a comment--and `grep' for that string. 9101- 9102-`docdir' 9103- The directory for installing documentation files (other than Info) 9104- for this package. By default, it should be 9105- `/usr/local/share/doc/YOURPKG', but it should be written as 9106- `$(datarootdir)/doc/YOURPKG'. (If you are using Autoconf, write 9107- it as `@docdir@'.) The YOURPKG subdirectory, which may include a 9108- version number, prevents collisions among files with common names, 9109- such as `README'. 9110- 9111-`infodir' 9112- The directory for installing the Info files for this package. By 9113- default, it should be `/usr/local/share/info', but it should be 9114- written as `$(datarootdir)/info'. (If you are using Autoconf, 9115- write it as `@infodir@'.) `infodir' is separate from `docdir' for 9116- compatibility with existing practice. 9117- 9118-`htmldir' 9119-`dvidir' 9120-`pdfdir' 9121-`psdir' 9122- Directories for installing documentation files in the particular 9123- format. (It is not required to support documentation in all these 9124- formats.) They should all be set to `$(docdir)' by default. (If 9125- you are using Autoconf, write them as `@htmldir@', `@dvidir@', 9126- etc.) Packages which supply several translations of their 9127- documentation should install them in `$(htmldir)/'LL, 9128- `$(pdfdir)/'LL, etc. where LL is a locale abbreviation such as 9129- `en' or `pt_BR'. 9130- 9131-`libdir' 9132- The directory for object files and libraries of object code. Do 9133- not install executables here, they probably ought to go in 9134- `$(libexecdir)' instead. The value of `libdir' should normally be 9135- `/usr/local/lib', but write it as `$(exec_prefix)/lib'. (If you 9136- are using Autoconf, write it as `@libdir@'.) 9137- 9138-`lispdir' 9139- The directory for installing any Emacs Lisp files in this package. 9140- By default, it should be `/usr/local/share/emacs/site-lisp', but 9141- it should be written as `$(datarootdir)/emacs/site-lisp'. 9142- 9143- If you are using Autoconf, write the default as `@lispdir@'. In 9144- order to make `@lispdir@' work, you need the following lines in 9145- your `configure.in' file: 9146- 9147- lispdir='${datarootdir}/emacs/site-lisp' 9148- AC_SUBST(lispdir) 9149- 9150-`localedir' 9151- The directory for installing locale-specific message catalogs for 9152- this package. By default, it should be `/usr/local/share/locale', 9153- but it should be written as `$(datarootdir)/locale'. (If you are 9154- using Autoconf, write it as `@localedir@'.) This directory 9155- usually has a subdirectory per locale. 9156- 9157- Unix-style man pages are installed in one of the following: 9158- 9159-`mandir' 9160- The top-level directory for installing the man pages (if any) for 9161- this package. It will normally be `/usr/local/share/man', but you 9162- should write it as `$(datarootdir)/man'. (If you are using 9163- Autoconf, write it as `@mandir@'.) 9164- 9165-`man1dir' 9166- The directory for installing section 1 man pages. Write it as 9167- `$(mandir)/man1'. 9168- 9169-`man2dir' 9170- The directory for installing section 2 man pages. Write it as 9171- `$(mandir)/man2' 9172- 9173-`...' 9174- *Don't make the primary documentation for any GNU software be a 9175- man page. Write a manual in Texinfo instead. Man pages are just 9176- for the sake of people running GNU software on Unix, which is a 9177- secondary application only.* 9178- 9179-`manext' 9180- The file name extension for the installed man page. This should 9181- contain a period followed by the appropriate digit; it should 9182- normally be `.1'. 9183- 9184-`man1ext' 9185- The file name extension for installed section 1 man pages. 9186- 9187-`man2ext' 9188- The file name extension for installed section 2 man pages. 9189- 9190-`...' 9191- Use these names instead of `manext' if the package needs to 9192- install man pages in more than one section of the manual. 9193- 9194- And finally, you should set the following variable: 9195- 9196-`srcdir' 9197- The directory for the sources being compiled. The value of this 9198- variable is normally inserted by the `configure' shell script. 9199- (If you are using Autconf, use `srcdir = @srcdir@'.) 9200- 9201- For example: 9202- 9203- # Common prefix for installation directories. 9204- # NOTE: This directory must exist when you start the install. 9205- prefix = /usr/local 9206- datarootdir = $(prefix)/share 9207- datadir = $(datarootdir) 9208- exec_prefix = $(prefix) 9209- # Where to put the executable for the command `gcc'. 9210- bindir = $(exec_prefix)/bin 9211- # Where to put the directories used by the compiler. 9212- libexecdir = $(exec_prefix)/libexec 9213- # Where to put the Info files. 9214- infodir = $(datarootdir)/info 9215- 9216- If your program installs a large number of files into one of the 9217-standard user-specified directories, it might be useful to group them 9218-into a subdirectory particular to that program. If you do this, you 9219-should write the `install' rule to create these subdirectories. 9220- 9221- Do not expect the user to include the subdirectory name in the value 9222-of any of the variables listed above. The idea of having a uniform set 9223-of variable names for installation directories is to enable the user to 9224-specify the exact same values for several different GNU packages. In 9225-order for this to be useful, all the packages must be designed so that 9226-they will work sensibly when the user does so. 9227- 9228- 9229-File: make.info, Node: Standard Targets, Next: Install Command Categories, Prev: Directory Variables, Up: Makefile Conventions 9230- 9231-14.5 Standard Targets for Users 9232-=============================== 9233- 9234-All GNU programs should have the following targets in their Makefiles: 9235- 9236-`all' 9237- Compile the entire program. This should be the default target. 9238- This target need not rebuild any documentation files; Info files 9239- should normally be included in the distribution, and DVI files 9240- should be made only when explicitly asked for. 9241- 9242- By default, the Make rules should compile and link with `-g', so 9243- that executable programs have debugging symbols. Users who don't 9244- mind being helpless can strip the executables later if they wish. 9245- 9246-`install' 9247- Compile the program and copy the executables, libraries, and so on 9248- to the file names where they should reside for actual use. If 9249- there is a simple test to verify that a program is properly 9250- installed, this target should run that test. 9251- 9252- Do not strip executables when installing them. Devil-may-care 9253- users can use the `install-strip' target to do that. 9254- 9255- If possible, write the `install' target rule so that it does not 9256- modify anything in the directory where the program was built, 9257- provided `make all' has just been done. This is convenient for 9258- building the program under one user name and installing it under 9259- another. 9260- 9261- The commands should create all the directories in which files are 9262- to be installed, if they don't already exist. This includes the 9263- directories specified as the values of the variables `prefix' and 9264- `exec_prefix', as well as all subdirectories that are needed. One 9265- way to do this is by means of an `installdirs' target as described 9266- below. 9267- 9268- Use `-' before any command for installing a man page, so that 9269- `make' will ignore any errors. This is in case there are systems 9270- that don't have the Unix man page documentation system installed. 9271- 9272- The way to install Info files is to copy them into `$(infodir)' 9273- with `$(INSTALL_DATA)' (*note Command Variables::), and then run 9274- the `install-info' program if it is present. `install-info' is a 9275- program that edits the Info `dir' file to add or update the menu 9276- entry for the given Info file; it is part of the Texinfo package. 9277- Here is a sample rule to install an Info file: 9278- 9279- $(DESTDIR)$(infodir)/foo.info: foo.info 9280- $(POST_INSTALL) 9281- # There may be a newer info file in . than in srcdir. 9282- -if test -f foo.info; then d=.; \ 9283- else d=$(srcdir); fi; \ 9284- $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \ 9285- # Run install-info only if it exists. 9286- # Use `if' instead of just prepending `-' to the 9287- # line so we notice real errors from install-info. 9288- # We use `$(SHELL) -c' because some shells do not 9289- # fail gracefully when there is an unknown command. 9290- if $(SHELL) -c 'install-info --version' \ 9291- >/dev/null 2>&1; then \ 9292- install-info --dir-file=$(DESTDIR)$(infodir)/dir \ 9293- $(DESTDIR)$(infodir)/foo.info; \ 9294- else true; fi 9295- 9296- When writing the `install' target, you must classify all the 9297- commands into three categories: normal ones, "pre-installation" 9298- commands and "post-installation" commands. *Note Install Command 9299- Categories::. 9300- 9301-`install-html' 9302-`install-dvi' 9303-`install-pdf' 9304-`install-ps' 9305- These targets install documentation in formats other than Info; 9306- they're intended to be called explicitly by the person installing 9307- the package, if that format is desired. GNU prefers Info files, 9308- so these must be installed by the `install' target. 9309- 9310- When you have many documentation files to install, we recommend 9311- that you avoid collisions and clutter by arranging for these 9312- targets to install in subdirectories of the appropriate 9313- installation directory, such as `htmldir'. As one example, if 9314- your package has multiple manuals, and you wish to install HTML 9315- documentation with many files (such as the "split" mode output by 9316- `makeinfo --html'), you'll certainly want to use subdirectories, 9317- or two nodes with the same name in different manuals will 9318- overwrite each other. 9319- 9320-`uninstall' 9321- Delete all the installed files--the copies that the `install' and 9322- `install-*' targets create. 9323- 9324- This rule should not modify the directories where compilation is 9325- done, only the directories where files are installed. 9326- 9327- The uninstallation commands are divided into three categories, 9328- just like the installation commands. *Note Install Command 9329- Categories::. 9330- 9331-`install-strip' 9332- Like `install', but strip the executable files while installing 9333- them. In simple cases, this target can use the `install' target in 9334- a simple way: 9335- 9336- install-strip: 9337- $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ 9338- install 9339- 9340- But if the package installs scripts as well as real executables, 9341- the `install-strip' target can't just refer to the `install' 9342- target; it has to strip the executables but not the scripts. 9343- 9344- `install-strip' should not strip the executables in the build 9345- directory which are being copied for installation. It should only 9346- strip the copies that are installed. 9347- 9348- Normally we do not recommend stripping an executable unless you 9349- are sure the program has no bugs. However, it can be reasonable 9350- to install a stripped executable for actual execution while saving 9351- the unstripped executable elsewhere in case there is a bug. 9352- 9353-`clean' 9354- Delete all files in the current directory that are normally 9355- created by building the program. Also delete files in other 9356- directories if they are created by this makefile. However, don't 9357- delete the files that record the configuration. Also preserve 9358- files that could be made by building, but normally aren't because 9359- the distribution comes with them. There is no need to delete 9360- parent directories that were created with `mkdir -p', since they 9361- could have existed anyway. 9362- 9363- Delete `.dvi' files here if they are not part of the distribution. 9364- 9365-`distclean' 9366- Delete all files in the current directory (or created by this 9367- makefile) that are created by configuring or building the program. 9368- If you have unpacked the source and built the program without 9369- creating any other files, `make distclean' should leave only the 9370- files that were in the distribution. However, there is no need to 9371- delete parent directories that were created with `mkdir -p', since 9372- they could have existed anyway. 9373- 9374-`mostlyclean' 9375- Like `clean', but may refrain from deleting a few files that people 9376- normally don't want to recompile. For example, the `mostlyclean' 9377- target for GCC does not delete `libgcc.a', because recompiling it 9378- is rarely necessary and takes a lot of time. 9379- 9380-`maintainer-clean' 9381- Delete almost everything that can be reconstructed with this 9382- Makefile. This typically includes everything deleted by 9383- `distclean', plus more: C source files produced by Bison, tags 9384- tables, Info files, and so on. 9385- 9386- The reason we say "almost everything" is that running the command 9387- `make maintainer-clean' should not delete `configure' even if 9388- `configure' can be remade using a rule in the Makefile. More 9389- generally, `make maintainer-clean' should not delete anything that 9390- needs to exist in order to run `configure' and then begin to build 9391- the program. Also, there is no need to delete parent directories 9392- that were created with `mkdir -p', since they could have existed 9393- anyway. These are the only exceptions; `maintainer-clean' should 9394- delete everything else that can be rebuilt. 9395- 9396- The `maintainer-clean' target is intended to be used by a 9397- maintainer of the package, not by ordinary users. You may need 9398- special tools to reconstruct some of the files that `make 9399- maintainer-clean' deletes. Since these files are normally 9400- included in the distribution, we don't take care to make them easy 9401- to reconstruct. If you find you need to unpack the full 9402- distribution again, don't blame us. 9403- 9404- To help make users aware of this, the commands for the special 9405- `maintainer-clean' target should start with these two: 9406- 9407- @echo 'This command is intended for maintainers to use; it' 9408- @echo 'deletes files that may need special tools to rebuild.' 9409- 9410-`TAGS' 9411- Update a tags table for this program. 9412- 9413-`info' 9414- Generate any Info files needed. The best way to write the rules 9415- is as follows: 9416- 9417- info: foo.info 9418- 9419- foo.info: foo.texi chap1.texi chap2.texi 9420- $(MAKEINFO) $(srcdir)/foo.texi 9421- 9422- You must define the variable `MAKEINFO' in the Makefile. It should 9423- run the `makeinfo' program, which is part of the Texinfo 9424- distribution. 9425- 9426- Normally a GNU distribution comes with Info files, and that means 9427- the Info files are present in the source directory. Therefore, 9428- the Make rule for an info file should update it in the source 9429- directory. When users build the package, ordinarily Make will not 9430- update the Info files because they will already be up to date. 9431- 9432-`dvi' 9433-`html' 9434-`pdf' 9435-`ps' 9436- Generate documentation files in the given format, if possible. 9437- Here's an example rule for generating DVI files from Texinfo: 9438- 9439- dvi: foo.dvi 9440- 9441- foo.dvi: foo.texi chap1.texi chap2.texi 9442- $(TEXI2DVI) $(srcdir)/foo.texi 9443- 9444- You must define the variable `TEXI2DVI' in the Makefile. It should 9445- run the program `texi2dvi', which is part of the Texinfo 9446- distribution.(1) Alternatively, write just the dependencies, and 9447- allow GNU `make' to provide the command. 9448- 9449- Here's another example, this one for generating HTML from Texinfo: 9450- 9451- html: foo.html 9452- 9453- foo.html: foo.texi chap1.texi chap2.texi 9454- $(TEXI2HTML) $(srcdir)/foo.texi 9455- 9456- Again, you would define the variable `TEXI2HTML' in the Makefile; 9457- for example, it might run `makeinfo --no-split --html' (`makeinfo' 9458- is part of the Texinfo distribution). 9459- 9460-`dist' 9461- Create a distribution tar file for this program. The tar file 9462- should be set up so that the file names in the tar file start with 9463- a subdirectory name which is the name of the package it is a 9464- distribution for. This name can include the version number. 9465- 9466- For example, the distribution tar file of GCC version 1.40 unpacks 9467- into a subdirectory named `gcc-1.40'. 9468- 9469- The easiest way to do this is to create a subdirectory 9470- appropriately named, use `ln' or `cp' to install the proper files 9471- in it, and then `tar' that subdirectory. 9472- 9473- Compress the tar file with `gzip'. For example, the actual 9474- distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'. 9475- 9476- The `dist' target should explicitly depend on all non-source files 9477- that are in the distribution, to make sure they are up to date in 9478- the distribution. *Note Making Releases: (standards)Releases. 9479- 9480-`check' 9481- Perform self-tests (if any). The user must build the program 9482- before running the tests, but need not install the program; you 9483- should write the self-tests so that they work when the program is 9484- built but not installed. 9485- 9486- The following targets are suggested as conventional names, for 9487-programs in which they are useful. 9488- 9489-`installcheck' 9490- Perform installation tests (if any). The user must build and 9491- install the program before running the tests. You should not 9492- assume that `$(bindir)' is in the search path. 9493- 9494-`installdirs' 9495- It's useful to add a target named `installdirs' to create the 9496- directories where files are installed, and their parent 9497- directories. There is a script called `mkinstalldirs' which is 9498- convenient for this; you can find it in the Texinfo package. You 9499- can use a rule like this: 9500- 9501- # Make sure all installation directories (e.g. $(bindir)) 9502- # actually exist by making them if necessary. 9503- installdirs: mkinstalldirs 9504- $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ 9505- $(libdir) $(infodir) \ 9506- $(mandir) 9507- 9508- or, if you wish to support `DESTDIR', 9509- 9510- # Make sure all installation directories (e.g. $(bindir)) 9511- # actually exist by making them if necessary. 9512- installdirs: mkinstalldirs 9513- $(srcdir)/mkinstalldirs \ 9514- $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \ 9515- $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \ 9516- $(DESTDIR)$(mandir) 9517- 9518- This rule should not modify the directories where compilation is 9519- done. It should do nothing but create installation directories. 9520- 9521- ---------- Footnotes ---------- 9522- 9523- (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is 9524-not distributed with Texinfo. 9525- 9526- 9527-File: make.info, Node: Install Command Categories, Prev: Standard Targets, Up: Makefile Conventions 9528- 9529-14.6 Install Command Categories 9530-=============================== 9531- 9532-When writing the `install' target, you must classify all the commands 9533-into three categories: normal ones, "pre-installation" commands and 9534-"post-installation" commands. 9535- 9536- Normal commands move files into their proper places, and set their 9537-modes. They may not alter any files except the ones that come entirely 9538-from the package they belong to. 9539- 9540- Pre-installation and post-installation commands may alter other 9541-files; in particular, they can edit global configuration files or data 9542-bases. 9543- 9544- Pre-installation commands are typically executed before the normal 9545-commands, and post-installation commands are typically run after the 9546-normal commands. 9547- 9548- The most common use for a post-installation command is to run 9549-`install-info'. This cannot be done with a normal command, since it 9550-alters a file (the Info directory) which does not come entirely and 9551-solely from the package being installed. It is a post-installation 9552-command because it needs to be done after the normal command which 9553-installs the package's Info files. 9554- 9555- Most programs don't need any pre-installation commands, but we have 9556-the feature just in case it is needed. 9557- 9558- To classify the commands in the `install' rule into these three 9559-categories, insert "category lines" among them. A category line 9560-specifies the category for the commands that follow. 9561- 9562- A category line consists of a tab and a reference to a special Make 9563-variable, plus an optional comment at the end. There are three 9564-variables you can use, one for each category; the variable name 9565-specifies the category. Category lines are no-ops in ordinary execution 9566-because these three Make variables are normally undefined (and you 9567-_should not_ define them in the makefile). 9568- 9569- Here are the three possible category lines, each with a comment that 9570-explains what it means: 9571- 9572- $(PRE_INSTALL) # Pre-install commands follow. 9573- $(POST_INSTALL) # Post-install commands follow. 9574- $(NORMAL_INSTALL) # Normal commands follow. 9575- 9576- If you don't use a category line at the beginning of the `install' 9577-rule, all the commands are classified as normal until the first category 9578-line. If you don't use any category lines, all the commands are 9579-classified as normal. 9580- 9581- These are the category lines for `uninstall': 9582- 9583- $(PRE_UNINSTALL) # Pre-uninstall commands follow. 9584- $(POST_UNINSTALL) # Post-uninstall commands follow. 9585- $(NORMAL_UNINSTALL) # Normal commands follow. 9586- 9587- Typically, a pre-uninstall command would be used for deleting entries 9588-from the Info directory. 9589- 9590- If the `install' or `uninstall' target has any dependencies which 9591-act as subroutines of installation, then you should start _each_ 9592-dependency's commands with a category line, and start the main target's 9593-commands with a category line also. This way, you can ensure that each 9594-command is placed in the right category regardless of which of the 9595-dependencies actually run. 9596- 9597- Pre-installation and post-installation commands should not run any 9598-programs except for these: 9599- 9600- [ basename bash cat chgrp chmod chown cmp cp dd diff echo 9601- egrep expand expr false fgrep find getopt grep gunzip gzip 9602- hostname install install-info kill ldconfig ln ls md5sum 9603- mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee 9604- test touch true uname xargs yes 9605- 9606- The reason for distinguishing the commands in this way is for the 9607-sake of making binary packages. Typically a binary package contains 9608-all the executables and other files that need to be installed, and has 9609-its own method of installing them--so it does not need to run the normal 9610-installation commands. But installing the binary package does need to 9611-execute the pre-installation and post-installation commands. 9612- 9613- Programs to build binary packages work by extracting the 9614-pre-installation and post-installation commands. Here is one way of 9615-extracting the pre-installation commands (the `-s' option to `make' is 9616-needed to silence messages about entering subdirectories): 9617- 9618- make -s -n install -o all \ 9619- PRE_INSTALL=pre-install \ 9620- POST_INSTALL=post-install \ 9621- NORMAL_INSTALL=normal-install \ 9622- | gawk -f pre-install.awk 9623- 9624-where the file `pre-install.awk' could contain this: 9625- 9626- $0 ~ /^(normal-install|post-install)[ \t]*$/ {on = 0} 9627- on {print $0} 9628- $0 ~ /^pre-install[ \t]*$/ {on = 1} 9629- 9630- 9631-File: make.info, Node: Quick Reference, Next: Error Messages, Prev: Makefile Conventions, Up: Top 9632- 9633-Appendix A Quick Reference 9634-************************** 9635- 9636-This appendix summarizes the directives, text manipulation functions, 9637-and special variables which GNU `make' understands. *Note Special 9638-Targets::, *Note Catalogue of Implicit Rules: Catalogue of Rules, and 9639-*Note Summary of Options: Options Summary, for other summaries. 9640- 9641- Here is a summary of the directives GNU `make' recognizes: 9642- 9643-`define VARIABLE' 9644-`endef' 9645- Define a multi-line, recursively-expanded variable. 9646- *Note Sequences::. 9647- 9648-`ifdef VARIABLE' 9649-`ifndef VARIABLE' 9650-`ifeq (A,B)' 9651-`ifeq "A" "B"' 9652-`ifeq 'A' 'B'' 9653-`ifneq (A,B)' 9654-`ifneq "A" "B"' 9655-`ifneq 'A' 'B'' 9656-`else' 9657-`endif' 9658- Conditionally evaluate part of the makefile. 9659- *Note Conditionals::. 9660- 9661-`include FILE' 9662-`-include FILE' 9663-`sinclude FILE' 9664- Include another makefile. 9665- *Note Including Other Makefiles: Include. 9666- 9667-`override VARIABLE = VALUE' 9668-`override VARIABLE := VALUE' 9669-`override VARIABLE += VALUE' 9670-`override VARIABLE ?= VALUE' 9671-`override define VARIABLE' 9672-`endef' 9673- Define a variable, overriding any previous definition, even one 9674- from the command line. 9675- *Note The `override' Directive: Override Directive. 9676- 9677-`export' 9678- Tell `make' to export all variables to child processes by default. 9679- *Note Communicating Variables to a Sub-`make': Variables/Recursion. 9680- 9681-`export VARIABLE' 9682-`export VARIABLE = VALUE' 9683-`export VARIABLE := VALUE' 9684-`export VARIABLE += VALUE' 9685-`export VARIABLE ?= VALUE' 9686-`unexport VARIABLE' 9687- Tell `make' whether or not to export a particular variable to child 9688- processes. 9689- *Note Communicating Variables to a Sub-`make': Variables/Recursion. 9690- 9691-`vpath PATTERN PATH' 9692- Specify a search path for files matching a `%' pattern. 9693- *Note The `vpath' Directive: Selective Search. 9694- 9695-`vpath PATTERN' 9696- Remove all search paths previously specified for PATTERN. 9697- 9698-`vpath' 9699- Remove all search paths previously specified in any `vpath' 9700- directive. 9701- 9702- Here is a summary of the built-in functions (*note Functions::): 9703- 9704-`$(subst FROM,TO,TEXT)' 9705- Replace FROM with TO in TEXT. 9706- *Note Functions for String Substitution and Analysis: Text 9707- Functions. 9708- 9709-`$(patsubst PATTERN,REPLACEMENT,TEXT)' 9710- Replace words matching PATTERN with REPLACEMENT in TEXT. 9711- *Note Functions for String Substitution and Analysis: Text 9712- Functions. 9713- 9714-`$(strip STRING)' 9715- Remove excess whitespace characters from STRING. 9716- *Note Functions for String Substitution and Analysis: Text 9717- Functions. 9718- 9719-`$(findstring FIND,TEXT)' 9720- Locate FIND in TEXT. 9721- *Note Functions for String Substitution and Analysis: Text 9722- Functions. 9723- 9724-`$(filter PATTERN...,TEXT)' 9725- Select words in TEXT that match one of the PATTERN words. 9726- *Note Functions for String Substitution and Analysis: Text 9727- Functions. 9728- 9729-`$(filter-out PATTERN...,TEXT)' 9730- Select words in TEXT that _do not_ match any of the PATTERN words. 9731- *Note Functions for String Substitution and Analysis: Text 9732- Functions. 9733- 9734-`$(sort LIST)' 9735- Sort the words in LIST lexicographically, removing duplicates. 9736- *Note Functions for String Substitution and Analysis: Text 9737- Functions. 9738- 9739-`$(word N,TEXT)' 9740- Extract the Nth word (one-origin) of TEXT. 9741- *Note Functions for String Substitution and Analysis: Text 9742- Functions. 9743- 9744-`$(words TEXT)' 9745- Count the number of words in TEXT. 9746- *Note Functions for String Substitution and Analysis: Text 9747- Functions. 9748- 9749-`$(wordlist S,E,TEXT)' 9750- Returns the list of words in TEXT from S to E. 9751- *Note Functions for String Substitution and Analysis: Text 9752- Functions. 9753- 9754-`$(firstword NAMES...)' 9755- Extract the first word of NAMES. 9756- *Note Functions for String Substitution and Analysis: Text 9757- Functions. 9758- 9759-`$(lastword NAMES...)' 9760- Extract the last word of NAMES. 9761- *Note Functions for String Substitution and Analysis: Text 9762- Functions. 9763- 9764-`$(dir NAMES...)' 9765- Extract the directory part of each file name. 9766- *Note Functions for File Names: File Name Functions. 9767- 9768-`$(notdir NAMES...)' 9769- Extract the non-directory part of each file name. 9770- *Note Functions for File Names: File Name Functions. 9771- 9772-`$(suffix NAMES...)' 9773- Extract the suffix (the last `.' and following characters) of each 9774- file name. 9775- *Note Functions for File Names: File Name Functions. 9776- 9777-`$(basename NAMES...)' 9778- Extract the base name (name without suffix) of each file name. 9779- *Note Functions for File Names: File Name Functions. 9780- 9781-`$(addsuffix SUFFIX,NAMES...)' 9782- Append SUFFIX to each word in NAMES. 9783- *Note Functions for File Names: File Name Functions. 9784- 9785-`$(addprefix PREFIX,NAMES...)' 9786- Prepend PREFIX to each word in NAMES. 9787- *Note Functions for File Names: File Name Functions. 9788- 9789-`$(join LIST1,LIST2)' 9790- Join two parallel lists of words. 9791- *Note Functions for File Names: File Name Functions. 9792- 9793-`$(wildcard PATTERN...)' 9794- Find file names matching a shell file name pattern (_not_ a `%' 9795- pattern). 9796- *Note The Function `wildcard': Wildcard Function. 9797- 9798-`$(realpath NAMES...)' 9799- For each file name in NAMES, expand to an absolute name that does 9800- not contain any `.', `..', nor symlinks. 9801- *Note Functions for File Names: File Name Functions. 9802- 9803-`$(abspath NAMES...)' 9804- For each file name in NAMES, expand to an absolute name that does 9805- not contain any `.' or `..' components, but preserves symlinks. 9806- *Note Functions for File Names: File Name Functions. 9807- 9808-`$(error TEXT...)' 9809- When this function is evaluated, `make' generates a fatal error 9810- with the message TEXT. 9811- *Note Functions That Control Make: Make Control Functions. 9812- 9813-`$(warning TEXT...)' 9814- When this function is evaluated, `make' generates a warning with 9815- the message TEXT. 9816- *Note Functions That Control Make: Make Control Functions. 9817- 9818-`$(shell COMMAND)' 9819- Execute a shell command and return its output. 9820- *Note The `shell' Function: Shell Function. 9821- 9822-`$(origin VARIABLE)' 9823- Return a string describing how the `make' variable VARIABLE was 9824- defined. 9825- *Note The `origin' Function: Origin Function. 9826- 9827-`$(flavor VARIABLE)' 9828- Return a string describing the flavor of the `make' variable 9829- VARIABLE. 9830- *Note The `flavor' Function: Flavor Function. 9831- 9832-`$(foreach VAR,WORDS,TEXT)' 9833- Evaluate TEXT with VAR bound to each word in WORDS, and 9834- concatenate the results. 9835- *Note The `foreach' Function: Foreach Function. 9836- 9837-`$(call VAR,PARAM,...)' 9838- Evaluate the variable VAR replacing any references to `$(1)', 9839- `$(2)' with the first, second, etc. PARAM values. 9840- *Note The `call' Function: Call Function. 9841- 9842-`$(eval TEXT)' 9843- Evaluate TEXT then read the results as makefile commands. Expands 9844- to the empty string. 9845- *Note The `eval' Function: Eval Function. 9846- 9847-`$(value VAR)' 9848- Evaluates to the contents of the variable VAR, with no expansion 9849- performed on it. 9850- *Note The `value' Function: Value Function. 9851- 9852- Here is a summary of the automatic variables. *Note Automatic 9853-Variables::, for full information. 9854- 9855-`$@' 9856- The file name of the target. 9857- 9858-`$%' 9859- The target member name, when the target is an archive member. 9860- 9861-`$<' 9862- The name of the first prerequisite. 9863- 9864-`$?' 9865- The names of all the prerequisites that are newer than the target, 9866- with spaces between them. For prerequisites which are archive 9867- members, only the member named is used (*note Archives::). 9868- 9869-`$^' 9870-`$+' 9871- The names of all the prerequisites, with spaces between them. For 9872- prerequisites which are archive members, only the member named is 9873- used (*note Archives::). The value of `$^' omits duplicate 9874- prerequisites, while `$+' retains them and preserves their order. 9875- 9876-`$*' 9877- The stem with which an implicit rule matches (*note How Patterns 9878- Match: Pattern Match.). 9879- 9880-`$(@D)' 9881-`$(@F)' 9882- The directory part and the file-within-directory part of `$@'. 9883- 9884-`$(*D)' 9885-`$(*F)' 9886- The directory part and the file-within-directory part of `$*'. 9887- 9888-`$(%D)' 9889-`$(%F)' 9890- The directory part and the file-within-directory part of `$%'. 9891- 9892-`$(<D)' 9893-`$(<F)' 9894- The directory part and the file-within-directory part of `$<'. 9895- 9896-`$(^D)' 9897-`$(^F)' 9898- The directory part and the file-within-directory part of `$^'. 9899- 9900-`$(+D)' 9901-`$(+F)' 9902- The directory part and the file-within-directory part of `$+'. 9903- 9904-`$(?D)' 9905-`$(?F)' 9906- The directory part and the file-within-directory part of `$?'. 9907- 9908- These variables are used specially by GNU `make': 9909- 9910-`MAKEFILES' 9911- Makefiles to be read on every invocation of `make'. 9912- *Note The Variable `MAKEFILES': MAKEFILES Variable. 9913- 9914-`VPATH' 9915- Directory search path for files not found in the current directory. 9916- *Note `VPATH' Search Path for All Prerequisites: General Search. 9917- 9918-`SHELL' 9919- The name of the system default command interpreter, usually 9920- `/bin/sh'. You can set `SHELL' in the makefile to change the 9921- shell used to run commands. *Note Command Execution: Execution. 9922- The `SHELL' variable is handled specially when importing from and 9923- exporting to the environment. *Note Choosing the Shell::. 9924- 9925-`MAKESHELL' 9926- On MS-DOS only, the name of the command interpreter that is to be 9927- used by `make'. This value takes precedence over the value of 9928- `SHELL'. *Note MAKESHELL variable: Execution. 9929- 9930-`MAKE' 9931- The name with which `make' was invoked. Using this variable in 9932- commands has special meaning. *Note How the `MAKE' Variable 9933- Works: MAKE Variable. 9934- 9935-`MAKELEVEL' 9936- The number of levels of recursion (sub-`make's). 9937- *Note Variables/Recursion::. 9938- 9939-`MAKEFLAGS' 9940- The flags given to `make'. You can set this in the environment or 9941- a makefile to set flags. 9942- *Note Communicating Options to a Sub-`make': Options/Recursion. 9943- 9944- It is _never_ appropriate to use `MAKEFLAGS' directly on a command 9945- line: its contents may not be quoted correctly for use in the 9946- shell. Always allow recursive `make''s to obtain these values 9947- through the environment from its parent. 9948- 9949-`MAKECMDGOALS' 9950- The targets given to `make' on the command line. Setting this 9951- variable has no effect on the operation of `make'. 9952- *Note Arguments to Specify the Goals: Goals. 9953- 9954-`CURDIR' 9955- Set to the pathname of the current working directory (after all 9956- `-C' options are processed, if any). Setting this variable has no 9957- effect on the operation of `make'. 9958- *Note Recursive Use of `make': Recursion. 9959- 9960-`SUFFIXES' 9961- The default list of suffixes before `make' reads any makefiles. 9962- 9963-`.LIBPATTERNS' 9964- Defines the naming of the libraries `make' searches for, and their 9965- order. 9966- *Note Directory Search for Link Libraries: Libraries/Search. 9967- 9968- 9969-File: make.info, Node: Error Messages, Next: Complex Makefile, Prev: Quick Reference, Up: Top 9970- 9971-Appendix B Errors Generated by Make 9972-*********************************** 9973- 9974-Here is a list of the more common errors you might see generated by 9975-`make', and some information about what they mean and how to fix them. 9976- 9977- Sometimes `make' errors are not fatal, especially in the presence of 9978-a `-' prefix on a command script line, or the `-k' command line option. 9979-Errors that are fatal are prefixed with the string `***'. 9980- 9981- Error messages are all either prefixed with the name of the program 9982-(usually `make'), or, if the error is found in a makefile, the name of 9983-the file and linenumber containing the problem. 9984- 9985- In the table below, these common prefixes are left off. 9986- 9987-`[FOO] Error NN' 9988-`[FOO] SIGNAL DESCRIPTION' 9989- These errors are not really `make' errors at all. They mean that a 9990- program that `make' invoked as part of a command script returned a 9991- non-0 error code (`Error NN'), which `make' interprets as failure, 9992- or it exited in some other abnormal fashion (with a signal of some 9993- type). *Note Errors in Commands: Errors. 9994- 9995- If no `***' is attached to the message, then the subprocess failed 9996- but the rule in the makefile was prefixed with the `-' special 9997- character, so `make' ignored the error. 9998- 9999-`missing separator. Stop.' 10000-`missing separator (did you mean TAB instead of 8 spaces?). Stop.' 10001- This means that `make' could not understand much of anything about 10002- the command line it just read. GNU `make' looks for various kinds 10003- of separators (`:', `=', TAB characters, etc.) to help it decide 10004- what kind of commandline it's seeing. This means it couldn't find 10005- a valid one. 10006- 10007- One of the most common reasons for this message is that you (or 10008- perhaps your oh-so-helpful editor, as is the case with many 10009- MS-Windows editors) have attempted to indent your command scripts 10010- with spaces instead of a TAB character. In this case, `make' will 10011- use the second form of the error above. Remember that every line 10012- in the command script must begin with a TAB character. Eight 10013- spaces do not count. *Note Rule Syntax::. 10014- 10015-`commands commence before first target. Stop.' 10016-`missing rule before commands. Stop.' 10017- This means the first thing in the makefile seems to be part of a 10018- command script: it begins with a TAB character and doesn't appear 10019- to be a legal `make' command (such as a variable assignment). 10020- Command scripts must always be associated with a target. 10021- 10022- The second form is generated if the line has a semicolon as the 10023- first non-whitespace character; `make' interprets this to mean you 10024- left out the "target: prerequisite" section of a rule. *Note Rule 10025- Syntax::. 10026- 10027-`No rule to make target `XXX'.' 10028-`No rule to make target `XXX', needed by `YYY'.' 10029- This means that `make' decided it needed to build a target, but 10030- then couldn't find any instructions in the makefile on how to do 10031- that, either explicit or implicit (including in the default rules 10032- database). 10033- 10034- If you want that file to be built, you will need to add a rule to 10035- your makefile describing how that target can be built. Other 10036- possible sources of this problem are typos in the makefile (if 10037- that filename is wrong) or a corrupted source tree (if that file 10038- is not supposed to be built, but rather only a prerequisite). 10039- 10040-`No targets specified and no makefile found. Stop.' 10041-`No targets. Stop.' 10042- The former means that you didn't provide any targets to be built 10043- on the command line, and `make' couldn't find any makefiles to 10044- read in. The latter means that some makefile was found, but it 10045- didn't contain any default goal and none was given on the command 10046- line. GNU `make' has nothing to do in these situations. *Note 10047- Arguments to Specify the Makefile: Makefile Arguments. 10048- 10049-`Makefile `XXX' was not found.' 10050-`Included makefile `XXX' was not found.' 10051- A makefile specified on the command line (first form) or included 10052- (second form) was not found. 10053- 10054-`warning: overriding commands for target `XXX'' 10055-`warning: ignoring old commands for target `XXX'' 10056- GNU `make' allows commands to be specified only once per target 10057- (except for double-colon rules). If you give commands for a target 10058- which already has been defined to have commands, this warning is 10059- issued and the second set of commands will overwrite the first set. 10060- *Note Multiple Rules for One Target: Multiple Rules. 10061- 10062-`Circular XXX <- YYY dependency dropped.' 10063- This means that `make' detected a loop in the dependency graph: 10064- after tracing the prerequisite YYY of target XXX, and its 10065- prerequisites, etc., one of them depended on XXX again. 10066- 10067-`Recursive variable `XXX' references itself (eventually). Stop.' 10068- This means you've defined a normal (recursive) `make' variable XXX 10069- that, when it's expanded, will refer to itself (XXX). This is not 10070- allowed; either use simply-expanded variables (`:=') or use the 10071- append operator (`+='). *Note How to Use Variables: Using 10072- Variables. 10073- 10074-`Unterminated variable reference. Stop.' 10075- This means you forgot to provide the proper closing parenthesis or 10076- brace in your variable or function reference. 10077- 10078-`insufficient arguments to function `XXX'. Stop.' 10079- This means you haven't provided the requisite number of arguments 10080- for this function. See the documentation of the function for a 10081- description of its arguments. *Note Functions for Transforming 10082- Text: Functions. 10083- 10084-`missing target pattern. Stop.' 10085-`multiple target patterns. Stop.' 10086-`target pattern contains no `%'. Stop.' 10087-`mixed implicit and static pattern rules. Stop.' 10088- These are generated for malformed static pattern rules. The first 10089- means there's no pattern in the target section of the rule; the 10090- second means there are multiple patterns in the target section; 10091- the third means the target doesn't contain a pattern character 10092- (`%'); and the fourth means that all three parts of the static 10093- pattern rule contain pattern characters (`%')-only the first two 10094- parts should. *Note Syntax of Static Pattern Rules: Static Usage. 10095- 10096-`warning: -jN forced in submake: disabling jobserver mode.' 10097- This warning and the next are generated if `make' detects error 10098- conditions related to parallel processing on systems where 10099- sub-`make's can communicate (*note Communicating Options to a 10100- Sub-`make': Options/Recursion.). This warning is generated if a 10101- recursive invocation of a `make' process is forced to have `-jN' 10102- in its argument list (where N is greater than one). This could 10103- happen, for example, if you set the `MAKE' environment variable to 10104- `make -j2'. In this case, the sub-`make' doesn't communicate with 10105- other `make' processes and will simply pretend it has two jobs of 10106- its own. 10107- 10108-`warning: jobserver unavailable: using -j1. Add `+' to parent make rule.' 10109- In order for `make' processes to communicate, the parent will pass 10110- information to the child. Since this could result in problems if 10111- the child process isn't actually a `make', the parent will only do 10112- this if it thinks the child is a `make'. The parent uses the 10113- normal algorithms to determine this (*note How the `MAKE' Variable 10114- Works: MAKE Variable.). If the makefile is constructed such that 10115- the parent doesn't know the child is a `make' process, then the 10116- child will receive only part of the information necessary. In 10117- this case, the child will generate this warning message and 10118- proceed with its build in a sequential manner. 10119- 10120- 10121- 10122-File: make.info, Node: Complex Makefile, Next: GNU Free Documentation License, Prev: Error Messages, Up: Top 10123- 10124-Appendix C Complex Makefile Example 10125-*********************************** 10126- 10127-Here is the makefile for the GNU `tar' program. This is a moderately 10128-complex makefile. 10129- 10130- Because it is the first target, the default goal is `all'. An 10131-interesting feature of this makefile is that `testpad.h' is a source 10132-file automatically created by the `testpad' program, itself compiled 10133-from `testpad.c'. 10134- 10135- If you type `make' or `make all', then `make' creates the `tar' 10136-executable, the `rmt' daemon that provides remote tape access, and the 10137-`tar.info' Info file. 10138- 10139- If you type `make install', then `make' not only creates `tar', 10140-`rmt', and `tar.info', but also installs them. 10141- 10142- If you type `make clean', then `make' removes the `.o' files, and 10143-the `tar', `rmt', `testpad', `testpad.h', and `core' files. 10144- 10145- If you type `make distclean', then `make' not only removes the same 10146-files as does `make clean' but also the `TAGS', `Makefile', and 10147-`config.status' files. (Although it is not evident, this makefile (and 10148-`config.status') is generated by the user with the `configure' program, 10149-which is provided in the `tar' distribution, but is not shown here.) 10150- 10151- If you type `make realclean', then `make' removes the same files as 10152-does `make distclean' and also removes the Info files generated from 10153-`tar.texinfo'. 10154- 10155- In addition, there are targets `shar' and `dist' that create 10156-distribution kits. 10157- 10158- # Generated automatically from Makefile.in by configure. 10159- # Un*x Makefile for GNU tar program. 10160- # Copyright (C) 1991 Free Software Foundation, Inc. 10161- 10162- # This program is free software; you can redistribute 10163- # it and/or modify it under the terms of the GNU 10164- # General Public License ... 10165- ... 10166- ... 10167- 10168- SHELL = /bin/sh 10169- 10170- #### Start of system configuration section. #### 10171- 10172- srcdir = . 10173- 10174- # If you use gcc, you should either run the 10175- # fixincludes script that comes with it or else use 10176- # gcc with the -traditional option. Otherwise ioctl 10177- # calls will be compiled incorrectly on some systems. 10178- CC = gcc -O 10179- YACC = bison -y 10180- INSTALL = /usr/local/bin/install -c 10181- INSTALLDATA = /usr/local/bin/install -c -m 644 10182- 10183- # Things you might add to DEFS: 10184- # -DSTDC_HEADERS If you have ANSI C headers and 10185- # libraries. 10186- # -DPOSIX If you have POSIX.1 headers and 10187- # libraries. 10188- # -DBSD42 If you have sys/dir.h (unless 10189- # you use -DPOSIX), sys/file.h, 10190- # and st_blocks in `struct stat'. 10191- # -DUSG If you have System V/ANSI C 10192- # string and memory functions 10193- # and headers, sys/sysmacros.h, 10194- # fcntl.h, getcwd, no valloc, 10195- # and ndir.h (unless 10196- # you use -DDIRENT). 10197- # -DNO_MEMORY_H If USG or STDC_HEADERS but do not 10198- # include memory.h. 10199- # -DDIRENT If USG and you have dirent.h 10200- # instead of ndir.h. 10201- # -DSIGTYPE=int If your signal handlers 10202- # return int, not void. 10203- # -DNO_MTIO If you lack sys/mtio.h 10204- # (magtape ioctls). 10205- # -DNO_REMOTE If you do not have a remote shell 10206- # or rexec. 10207- # -DUSE_REXEC To use rexec for remote tape 10208- # operations instead of 10209- # forking rsh or remsh. 10210- # -DVPRINTF_MISSING If you lack vprintf function 10211- # (but have _doprnt). 10212- # -DDOPRNT_MISSING If you lack _doprnt function. 10213- # Also need to define 10214- # -DVPRINTF_MISSING. 10215- # -DFTIME_MISSING If you lack ftime system call. 10216- # -DSTRSTR_MISSING If you lack strstr function. 10217- # -DVALLOC_MISSING If you lack valloc function. 10218- # -DMKDIR_MISSING If you lack mkdir and 10219- # rmdir system calls. 10220- # -DRENAME_MISSING If you lack rename system call. 10221- # -DFTRUNCATE_MISSING If you lack ftruncate 10222- # system call. 10223- # -DV7 On Version 7 Unix (not 10224- # tested in a long time). 10225- # -DEMUL_OPEN3 If you lack a 3-argument version 10226- # of open, and want to emulate it 10227- # with system calls you do have. 10228- # -DNO_OPEN3 If you lack the 3-argument open 10229- # and want to disable the tar -k 10230- # option instead of emulating open. 10231- # -DXENIX If you have sys/inode.h 10232- # and need it 94 to be included. 10233- 10234- DEFS = -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \ 10235- -DVPRINTF_MISSING -DBSD42 10236- # Set this to rtapelib.o unless you defined NO_REMOTE, 10237- # in which case make it empty. 10238- RTAPELIB = rtapelib.o 10239- LIBS = 10240- DEF_AR_FILE = /dev/rmt8 10241- DEFBLOCKING = 20 10242- 10243- CDEBUG = -g 10244- CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \ 10245- -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \ 10246- -DDEFBLOCKING=$(DEFBLOCKING) 10247- LDFLAGS = -g 10248- 10249- prefix = /usr/local 10250- # Prefix for each installed program, 10251- # normally empty or `g'. 10252- binprefix = 10253- 10254- # The directory to install tar in. 10255- bindir = $(prefix)/bin 10256- 10257- # The directory to install the info files in. 10258- infodir = $(prefix)/info 10259- 10260- #### End of system configuration section. #### 10261- 10262- SRC1 = tar.c create.c extract.c buffer.c \ 10263- getoldopt.c update.c gnu.c mangle.c 10264- SRC2 = version.c list.c names.c diffarch.c \ 10265- port.c wildmat.c getopt.c 10266- SRC3 = getopt1.c regex.c getdate.y 10267- SRCS = $(SRC1) $(SRC2) $(SRC3) 10268- OBJ1 = tar.o create.o extract.o buffer.o \ 10269- getoldopt.o update.o gnu.o mangle.o 10270- OBJ2 = version.o list.o names.o diffarch.o \ 10271- port.o wildmat.o getopt.o 10272- OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB) 10273- OBJS = $(OBJ1) $(OBJ2) $(OBJ3) 10274- AUX = README COPYING ChangeLog Makefile.in \ 10275- makefile.pc configure configure.in \ 10276- tar.texinfo tar.info* texinfo.tex \ 10277- tar.h port.h open3.h getopt.h regex.h \ 10278- rmt.h rmt.c rtapelib.c alloca.c \ 10279- msd_dir.h msd_dir.c tcexparg.c \ 10280- level-0 level-1 backup-specs testpad.c 10281- 10282- .PHONY: all 10283- all: tar rmt tar.info 10284- 10285- .PHONY: tar 10286- tar: $(OBJS) 10287- $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 10288- 10289- rmt: rmt.c 10290- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c 10291- 10292- tar.info: tar.texinfo 10293- makeinfo tar.texinfo 10294- 10295- .PHONY: install 10296- install: all 10297- $(INSTALL) tar $(bindir)/$(binprefix)tar 10298- -test ! -f rmt || $(INSTALL) rmt /etc/rmt 10299- $(INSTALLDATA) $(srcdir)/tar.info* $(infodir) 10300- 10301- $(OBJS): tar.h port.h testpad.h 10302- regex.o buffer.o tar.o: regex.h 10303- # getdate.y has 8 shift/reduce conflicts. 10304- 10305- testpad.h: testpad 10306- ./testpad 10307- 10308- testpad: testpad.o 10309- $(CC) -o $@ testpad.o 10310- 10311- TAGS: $(SRCS) 10312- etags $(SRCS) 10313- 10314- .PHONY: clean 10315- clean: 10316- rm -f *.o tar rmt testpad testpad.h core 10317- 10318- .PHONY: distclean 10319- distclean: clean 10320- rm -f TAGS Makefile config.status 10321- 10322- .PHONY: realclean 10323- realclean: distclean 10324- rm -f tar.info* 10325- 10326- .PHONY: shar 10327- shar: $(SRCS) $(AUX) 10328- shar $(SRCS) $(AUX) | compress \ 10329- > tar-`sed -e '/version_string/!d' \ 10330- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ 10331- -e q 10332- version.c`.shar.Z 10333- 10334- .PHONY: dist 10335- dist: $(SRCS) $(AUX) 10336- echo tar-`sed \ 10337- -e '/version_string/!d' \ 10338- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ 10339- -e q 10340- version.c` > .fname 10341- -rm -rf `cat .fname` 10342- mkdir `cat .fname` 10343- ln $(SRCS) $(AUX) `cat .fname` 10344- tar chZf `cat .fname`.tar.Z `cat .fname` 10345- -rm -rf `cat .fname` .fname 10346- 10347- tar.zoo: $(SRCS) $(AUX) 10348- -rm -rf tmp.dir 10349- -mkdir tmp.dir 10350- -rm tar.zoo 10351- for X in $(SRCS) $(AUX) ; do \ 10352- echo $$X ; \ 10353- sed 's/$$/^M/' $$X \ 10354- > tmp.dir/$$X ; done 10355- cd tmp.dir ; zoo aM ../tar.zoo * 10356- -rm -rf tmp.dir 10357- 10358- 10359-File: make.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: Complex Makefile, Up: Top 10360- 10361-Appendix D GNU Free Documentation License 10362-***************************************** 10363- 10364- Version 1.2, November 2002 10365- 10366- Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 10367- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 10368- 10369- Everyone is permitted to copy and distribute verbatim copies 10370- of this license document, but changing it is not allowed. 10371- 10372- 0. PREAMBLE 10373- 10374- The purpose of this License is to make a manual, textbook, or other 10375- functional and useful document "free" in the sense of freedom: to 10376- assure everyone the effective freedom to copy and redistribute it, 10377- with or without modifying it, either commercially or 10378- noncommercially. Secondarily, this License preserves for the 10379- author and publisher a way to get credit for their work, while not 10380- being considered responsible for modifications made by others. 10381- 10382- This License is a kind of "copyleft", which means that derivative 10383- works of the document must themselves be free in the same sense. 10384- It complements the GNU General Public License, which is a copyleft 10385- license designed for free software. 10386- 10387- We have designed this License in order to use it for manuals for 10388- free software, because free software needs free documentation: a 10389- free program should come with manuals providing the same freedoms 10390- that the software does. But this License is not limited to 10391- software manuals; it can be used for any textual work, regardless 10392- of subject matter or whether it is published as a printed book. 10393- We recommend this License principally for works whose purpose is 10394- instruction or reference. 10395- 10396- 1. APPLICABILITY AND DEFINITIONS 10397- 10398- This License applies to any manual or other work, in any medium, 10399- that contains a notice placed by the copyright holder saying it 10400- can be distributed under the terms of this License. Such a notice 10401- grants a world-wide, royalty-free license, unlimited in duration, 10402- to use that work under the conditions stated herein. The 10403- "Document", below, refers to any such manual or work. Any member 10404- of the public is a licensee, and is addressed as "you". You 10405- accept the license if you copy, modify or distribute the work in a 10406- way requiring permission under copyright law. 10407- 10408- A "Modified Version" of the Document means any work containing the 10409- Document or a portion of it, either copied verbatim, or with 10410- modifications and/or translated into another language. 10411- 10412- A "Secondary Section" is a named appendix or a front-matter section 10413- of the Document that deals exclusively with the relationship of the 10414- publishers or authors of the Document to the Document's overall 10415- subject (or to related matters) and contains nothing that could 10416- fall directly within that overall subject. (Thus, if the Document 10417- is in part a textbook of mathematics, a Secondary Section may not 10418- explain any mathematics.) The relationship could be a matter of 10419- historical connection with the subject or with related matters, or 10420- of legal, commercial, philosophical, ethical or political position 10421- regarding them. 10422- 10423- The "Invariant Sections" are certain Secondary Sections whose 10424- titles are designated, as being those of Invariant Sections, in 10425- the notice that says that the Document is released under this 10426- License. If a section does not fit the above definition of 10427- Secondary then it is not allowed to be designated as Invariant. 10428- The Document may contain zero Invariant Sections. If the Document 10429- does not identify any Invariant Sections then there are none. 10430- 10431- The "Cover Texts" are certain short passages of text that are 10432- listed, as Front-Cover Texts or Back-Cover Texts, in the notice 10433- that says that the Document is released under this License. A 10434- Front-Cover Text may be at most 5 words, and a Back-Cover Text may 10435- be at most 25 words. 10436- 10437- A "Transparent" copy of the Document means a machine-readable copy, 10438- represented in a format whose specification is available to the 10439- general public, that is suitable for revising the document 10440- straightforwardly with generic text editors or (for images 10441- composed of pixels) generic paint programs or (for drawings) some 10442- widely available drawing editor, and that is suitable for input to 10443- text formatters or for automatic translation to a variety of 10444- formats suitable for input to text formatters. A copy made in an 10445- otherwise Transparent file format whose markup, or absence of 10446- markup, has been arranged to thwart or discourage subsequent 10447- modification by readers is not Transparent. An image format is 10448- not Transparent if used for any substantial amount of text. A 10449- copy that is not "Transparent" is called "Opaque". 10450- 10451- Examples of suitable formats for Transparent copies include plain 10452- ASCII without markup, Texinfo input format, LaTeX input format, 10453- SGML or XML using a publicly available DTD, and 10454- standard-conforming simple HTML, PostScript or PDF designed for 10455- human modification. Examples of transparent image formats include 10456- PNG, XCF and JPG. Opaque formats include proprietary formats that 10457- can be read and edited only by proprietary word processors, SGML or 10458- XML for which the DTD and/or processing tools are not generally 10459- available, and the machine-generated HTML, PostScript or PDF 10460- produced by some word processors for output purposes only. 10461- 10462- The "Title Page" means, for a printed book, the title page itself, 10463- plus such following pages as are needed to hold, legibly, the 10464- material this License requires to appear in the title page. For 10465- works in formats which do not have any title page as such, "Title 10466- Page" means the text near the most prominent appearance of the 10467- work's title, preceding the beginning of the body of the text. 10468- 10469- A section "Entitled XYZ" means a named subunit of the Document 10470- whose title either is precisely XYZ or contains XYZ in parentheses 10471- following text that translates XYZ in another language. (Here XYZ 10472- stands for a specific section name mentioned below, such as 10473- "Acknowledgements", "Dedications", "Endorsements", or "History".) 10474- To "Preserve the Title" of such a section when you modify the 10475- Document means that it remains a section "Entitled XYZ" according 10476- to this definition. 10477- 10478- The Document may include Warranty Disclaimers next to the notice 10479- which states that this License applies to the Document. These 10480- Warranty Disclaimers are considered to be included by reference in 10481- this License, but only as regards disclaiming warranties: any other 10482- implication that these Warranty Disclaimers may have is void and 10483- has no effect on the meaning of this License. 10484- 10485- 2. VERBATIM COPYING 10486- 10487- You may copy and distribute the Document in any medium, either 10488- commercially or noncommercially, provided that this License, the 10489- copyright notices, and the license notice saying this License 10490- applies to the Document are reproduced in all copies, and that you 10491- add no other conditions whatsoever to those of this License. You 10492- may not use technical measures to obstruct or control the reading 10493- or further copying of the copies you make or distribute. However, 10494- you may accept compensation in exchange for copies. If you 10495- distribute a large enough number of copies you must also follow 10496- the conditions in section 3. 10497- 10498- You may also lend copies, under the same conditions stated above, 10499- and you may publicly display copies. 10500- 10501- 3. COPYING IN QUANTITY 10502- 10503- If you publish printed copies (or copies in media that commonly 10504- have printed covers) of the Document, numbering more than 100, and 10505- the Document's license notice requires Cover Texts, you must 10506- enclose the copies in covers that carry, clearly and legibly, all 10507- these Cover Texts: Front-Cover Texts on the front cover, and 10508- Back-Cover Texts on the back cover. Both covers must also clearly 10509- and legibly identify you as the publisher of these copies. The 10510- front cover must present the full title with all words of the 10511- title equally prominent and visible. You may add other material 10512- on the covers in addition. Copying with changes limited to the 10513- covers, as long as they preserve the title of the Document and 10514- satisfy these conditions, can be treated as verbatim copying in 10515- other respects. 10516- 10517- If the required texts for either cover are too voluminous to fit 10518- legibly, you should put the first ones listed (as many as fit 10519- reasonably) on the actual cover, and continue the rest onto 10520- adjacent pages. 10521- 10522- If you publish or distribute Opaque copies of the Document 10523- numbering more than 100, you must either include a 10524- machine-readable Transparent copy along with each Opaque copy, or 10525- state in or with each Opaque copy a computer-network location from 10526- which the general network-using public has access to download 10527- using public-standard network protocols a complete Transparent 10528- copy of the Document, free of added material. If you use the 10529- latter option, you must take reasonably prudent steps, when you 10530- begin distribution of Opaque copies in quantity, to ensure that 10531- this Transparent copy will remain thus accessible at the stated 10532- location until at least one year after the last time you 10533- distribute an Opaque copy (directly or through your agents or 10534- retailers) of that edition to the public. 10535- 10536- It is requested, but not required, that you contact the authors of 10537- the Document well before redistributing any large number of 10538- copies, to give them a chance to provide you with an updated 10539- version of the Document. 10540- 10541- 4. MODIFICATIONS 10542- 10543- You may copy and distribute a Modified Version of the Document 10544- under the conditions of sections 2 and 3 above, provided that you 10545- release the Modified Version under precisely this License, with 10546- the Modified Version filling the role of the Document, thus 10547- licensing distribution and modification of the Modified Version to 10548- whoever possesses a copy of it. In addition, you must do these 10549- things in the Modified Version: 10550- 10551- A. Use in the Title Page (and on the covers, if any) a title 10552- distinct from that of the Document, and from those of 10553- previous versions (which should, if there were any, be listed 10554- in the History section of the Document). You may use the 10555- same title as a previous version if the original publisher of 10556- that version gives permission. 10557- 10558- B. List on the Title Page, as authors, one or more persons or 10559- entities responsible for authorship of the modifications in 10560- the Modified Version, together with at least five of the 10561- principal authors of the Document (all of its principal 10562- authors, if it has fewer than five), unless they release you 10563- from this requirement. 10564- 10565- C. State on the Title page the name of the publisher of the 10566- Modified Version, as the publisher. 10567- 10568- D. Preserve all the copyright notices of the Document. 10569- 10570- E. Add an appropriate copyright notice for your modifications 10571- adjacent to the other copyright notices. 10572- 10573- F. Include, immediately after the copyright notices, a license 10574- notice giving the public permission to use the Modified 10575- Version under the terms of this License, in the form shown in 10576- the Addendum below. 10577- 10578- G. Preserve in that license notice the full lists of Invariant 10579- Sections and required Cover Texts given in the Document's 10580- license notice. 10581- 10582- H. Include an unaltered copy of this License. 10583- 10584- I. Preserve the section Entitled "History", Preserve its Title, 10585- and add to it an item stating at least the title, year, new 10586- authors, and publisher of the Modified Version as given on 10587- the Title Page. If there is no section Entitled "History" in 10588- the Document, create one stating the title, year, authors, 10589- and publisher of the Document as given on its Title Page, 10590- then add an item describing the Modified Version as stated in 10591- the previous sentence. 10592- 10593- J. Preserve the network location, if any, given in the Document 10594- for public access to a Transparent copy of the Document, and 10595- likewise the network locations given in the Document for 10596- previous versions it was based on. These may be placed in 10597- the "History" section. You may omit a network location for a 10598- work that was published at least four years before the 10599- Document itself, or if the original publisher of the version 10600- it refers to gives permission. 10601- 10602- K. For any section Entitled "Acknowledgements" or "Dedications", 10603- Preserve the Title of the section, and preserve in the 10604- section all the substance and tone of each of the contributor 10605- acknowledgements and/or dedications given therein. 10606- 10607- L. Preserve all the Invariant Sections of the Document, 10608- unaltered in their text and in their titles. Section numbers 10609- or the equivalent are not considered part of the section 10610- titles. 10611- 10612- M. Delete any section Entitled "Endorsements". Such a section 10613- may not be included in the Modified Version. 10614- 10615- N. Do not retitle any existing section to be Entitled 10616- "Endorsements" or to conflict in title with any Invariant 10617- Section. 10618- 10619- O. Preserve any Warranty Disclaimers. 10620- 10621- If the Modified Version includes new front-matter sections or 10622- appendices that qualify as Secondary Sections and contain no 10623- material copied from the Document, you may at your option 10624- designate some or all of these sections as invariant. To do this, 10625- add their titles to the list of Invariant Sections in the Modified 10626- Version's license notice. These titles must be distinct from any 10627- other section titles. 10628- 10629- You may add a section Entitled "Endorsements", provided it contains 10630- nothing but endorsements of your Modified Version by various 10631- parties--for example, statements of peer review or that the text 10632- has been approved by an organization as the authoritative 10633- definition of a standard. 10634- 10635- You may add a passage of up to five words as a Front-Cover Text, 10636- and a passage of up to 25 words as a Back-Cover Text, to the end 10637- of the list of Cover Texts in the Modified Version. Only one 10638- passage of Front-Cover Text and one of Back-Cover Text may be 10639- added by (or through arrangements made by) any one entity. If the 10640- Document already includes a cover text for the same cover, 10641- previously added by you or by arrangement made by the same entity 10642- you are acting on behalf of, you may not add another; but you may 10643- replace the old one, on explicit permission from the previous 10644- publisher that added the old one. 10645- 10646- The author(s) and publisher(s) of the Document do not by this 10647- License give permission to use their names for publicity for or to 10648- assert or imply endorsement of any Modified Version. 10649- 10650- 5. COMBINING DOCUMENTS 10651- 10652- You may combine the Document with other documents released under 10653- this License, under the terms defined in section 4 above for 10654- modified versions, provided that you include in the combination 10655- all of the Invariant Sections of all of the original documents, 10656- unmodified, and list them all as Invariant Sections of your 10657- combined work in its license notice, and that you preserve all 10658- their Warranty Disclaimers. 10659- 10660- The combined work need only contain one copy of this License, and 10661- multiple identical Invariant Sections may be replaced with a single 10662- copy. If there are multiple Invariant Sections with the same name 10663- but different contents, make the title of each such section unique 10664- by adding at the end of it, in parentheses, the name of the 10665- original author or publisher of that section if known, or else a 10666- unique number. Make the same adjustment to the section titles in 10667- the list of Invariant Sections in the license notice of the 10668- combined work. 10669- 10670- In the combination, you must combine any sections Entitled 10671- "History" in the various original documents, forming one section 10672- Entitled "History"; likewise combine any sections Entitled 10673- "Acknowledgements", and any sections Entitled "Dedications". You 10674- must delete all sections Entitled "Endorsements." 10675- 10676- 6. COLLECTIONS OF DOCUMENTS 10677- 10678- You may make a collection consisting of the Document and other 10679- documents released under this License, and replace the individual 10680- copies of this License in the various documents with a single copy 10681- that is included in the collection, provided that you follow the 10682- rules of this License for verbatim copying of each of the 10683- documents in all other respects. 10684- 10685- You may extract a single document from such a collection, and 10686- distribute it individually under this License, provided you insert 10687- a copy of this License into the extracted document, and follow 10688- this License in all other respects regarding verbatim copying of 10689- that document. 10690- 10691- 7. AGGREGATION WITH INDEPENDENT WORKS 10692- 10693- A compilation of the Document or its derivatives with other 10694- separate and independent documents or works, in or on a volume of 10695- a storage or distribution medium, is called an "aggregate" if the 10696- copyright resulting from the compilation is not used to limit the 10697- legal rights of the compilation's users beyond what the individual 10698- works permit. When the Document is included in an aggregate, this 10699- License does not apply to the other works in the aggregate which 10700- are not themselves derivative works of the Document. 10701- 10702- If the Cover Text requirement of section 3 is applicable to these 10703- copies of the Document, then if the Document is less than one half 10704- of the entire aggregate, the Document's Cover Texts may be placed 10705- on covers that bracket the Document within the aggregate, or the 10706- electronic equivalent of covers if the Document is in electronic 10707- form. Otherwise they must appear on printed covers that bracket 10708- the whole aggregate. 10709- 10710- 8. TRANSLATION 10711- 10712- Translation is considered a kind of modification, so you may 10713- distribute translations of the Document under the terms of section 10714- 4. Replacing Invariant Sections with translations requires special 10715- permission from their copyright holders, but you may include 10716- translations of some or all Invariant Sections in addition to the 10717- original versions of these Invariant Sections. You may include a 10718- translation of this License, and all the license notices in the 10719- Document, and any Warranty Disclaimers, provided that you also 10720- include the original English version of this License and the 10721- original versions of those notices and disclaimers. In case of a 10722- disagreement between the translation and the original version of 10723- this License or a notice or disclaimer, the original version will 10724- prevail. 10725- 10726- If a section in the Document is Entitled "Acknowledgements", 10727- "Dedications", or "History", the requirement (section 4) to 10728- Preserve its Title (section 1) will typically require changing the 10729- actual title. 10730- 10731- 9. TERMINATION 10732- 10733- You may not copy, modify, sublicense, or distribute the Document 10734- except as expressly provided for under this License. Any other 10735- attempt to copy, modify, sublicense or distribute the Document is 10736- void, and will automatically terminate your rights under this 10737- License. However, parties who have received copies, or rights, 10738- from you under this License will not have their licenses 10739- terminated so long as such parties remain in full compliance. 10740- 10741- 10. FUTURE REVISIONS OF THIS LICENSE 10742- 10743- The Free Software Foundation may publish new, revised versions of 10744- the GNU Free Documentation License from time to time. Such new 10745- versions will be similar in spirit to the present version, but may 10746- differ in detail to address new problems or concerns. See 10747- `http://www.gnu.org/copyleft/'. 10748- 10749- Each version of the License is given a distinguishing version 10750- number. If the Document specifies that a particular numbered 10751- version of this License "or any later version" applies to it, you 10752- have the option of following the terms and conditions either of 10753- that specified version or of any later version that has been 10754- published (not as a draft) by the Free Software Foundation. If 10755- the Document does not specify a version number of this License, 10756- you may choose any version ever published (not as a draft) by the 10757- Free Software Foundation. 10758- 10759-D.1 ADDENDUM: How to use this License for your documents 10760-======================================================== 10761- 10762-To use this License in a document you have written, include a copy of 10763-the License in the document and put the following copyright and license 10764-notices just after the title page: 10765- 10766- Copyright (C) YEAR YOUR NAME. 10767- Permission is granted to copy, distribute and/or modify this document 10768- under the terms of the GNU Free Documentation License, Version 1.2 10769- or any later version published by the Free Software Foundation; 10770- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 10771- Texts. A copy of the license is included in the section entitled ``GNU 10772- Free Documentation License''. 10773- 10774- If you have Invariant Sections, Front-Cover Texts and Back-Cover 10775-Texts, replace the "with...Texts." line with this: 10776- 10777- with the Invariant Sections being LIST THEIR TITLES, with 10778- the Front-Cover Texts being LIST, and with the Back-Cover Texts 10779- being LIST. 10780- 10781- If you have Invariant Sections without Cover Texts, or some other 10782-combination of the three, merge those two alternatives to suit the 10783-situation. 10784- 10785- If your document contains nontrivial examples of program code, we 10786-recommend releasing these examples in parallel under your choice of 10787-free software license, such as the GNU General Public License, to 10788-permit their use in free software. 10789- 10790- 10791-File: make.info, Node: Concept Index, Next: Name Index, Prev: GNU Free Documentation License, Up: Top 10792- 10793-Index of Concepts 10794-***************** 10795- 10796-[index] 10797-* Menu: 10798- 10799-* # (comments), in commands: Command Syntax. (line 27) 10800-* # (comments), in makefile: Makefile Contents. (line 41) 10801-* #include: Automatic Prerequisites. 10802- (line 16) 10803-* $, in function call: Syntax of Functions. (line 6) 10804-* $, in rules: Rule Syntax. (line 32) 10805-* $, in variable name: Computed Names. (line 6) 10806-* $, in variable reference: Reference. (line 6) 10807-* %, in pattern rules: Pattern Intro. (line 9) 10808-* %, quoting in patsubst: Text Functions. (line 26) 10809-* %, quoting in static pattern: Static Usage. (line 37) 10810-* %, quoting in vpath: Selective Search. (line 38) 10811-* %, quoting with \ (backslash) <1>: Text Functions. (line 26) 10812-* %, quoting with \ (backslash) <2>: Static Usage. (line 37) 10813-* %, quoting with \ (backslash): Selective Search. (line 38) 10814-* * (wildcard character): Wildcards. (line 6) 10815-* +, and command execution: Instead of Execution. 10816- (line 58) 10817-* +, and commands: MAKE Variable. (line 18) 10818-* +, and define: Sequences. (line 50) 10819-* +=: Appending. (line 6) 10820-* +=, expansion: Reading Makefiles. (line 33) 10821-* ,v (RCS file extension): Catalogue of Rules. (line 164) 10822-* - (in commands): Errors. (line 19) 10823-* -, and define: Sequences. (line 50) 10824-* --always-make: Options Summary. (line 15) 10825-* --assume-new <1>: Options Summary. (line 242) 10826-* --assume-new: Instead of Execution. 10827- (line 33) 10828-* --assume-new, and recursion: Options/Recursion. (line 22) 10829-* --assume-old <1>: Options Summary. (line 147) 10830-* --assume-old: Avoiding Compilation. 10831- (line 6) 10832-* --assume-old, and recursion: Options/Recursion. (line 22) 10833-* --check-symlink-times: Options Summary. (line 130) 10834-* --debug: Options Summary. (line 42) 10835-* --directory <1>: Options Summary. (line 26) 10836-* --directory: Recursion. (line 20) 10837-* --directory, and --print-directory: -w Option. (line 20) 10838-* --directory, and recursion: Options/Recursion. (line 22) 10839-* --dry-run <1>: Options Summary. (line 140) 10840-* --dry-run <2>: Instead of Execution. 10841- (line 14) 10842-* --dry-run: Echoing. (line 18) 10843-* --environment-overrides: Options Summary. (line 78) 10844-* --file <1>: Options Summary. (line 84) 10845-* --file <2>: Makefile Arguments. (line 6) 10846-* --file: Makefile Names. (line 23) 10847-* --file, and recursion: Options/Recursion. (line 22) 10848-* --help: Options Summary. (line 90) 10849-* --ignore-errors <1>: Options Summary. (line 94) 10850-* --ignore-errors: Errors. (line 30) 10851-* --include-dir <1>: Options Summary. (line 99) 10852-* --include-dir: Include. (line 52) 10853-* --jobs <1>: Options Summary. (line 106) 10854-* --jobs: Parallel. (line 6) 10855-* --jobs, and recursion: Options/Recursion. (line 25) 10856-* --just-print <1>: Options Summary. (line 139) 10857-* --just-print <2>: Instead of Execution. 10858- (line 14) 10859-* --just-print: Echoing. (line 18) 10860-* --keep-going <1>: Options Summary. (line 115) 10861-* --keep-going <2>: Testing. (line 16) 10862-* --keep-going: Errors. (line 47) 10863-* --load-average <1>: Options Summary. (line 122) 10864-* --load-average: Parallel. (line 57) 10865-* --makefile <1>: Options Summary. (line 85) 10866-* --makefile <2>: Makefile Arguments. (line 6) 10867-* --makefile: Makefile Names. (line 23) 10868-* --max-load <1>: Options Summary. (line 123) 10869-* --max-load: Parallel. (line 57) 10870-* --new-file <1>: Options Summary. (line 241) 10871-* --new-file: Instead of Execution. 10872- (line 33) 10873-* --new-file, and recursion: Options/Recursion. (line 22) 10874-* --no-builtin-rules: Options Summary. (line 175) 10875-* --no-builtin-variables: Options Summary. (line 188) 10876-* --no-keep-going: Options Summary. (line 203) 10877-* --no-print-directory <1>: Options Summary. (line 233) 10878-* --no-print-directory: -w Option. (line 20) 10879-* --old-file <1>: Options Summary. (line 146) 10880-* --old-file: Avoiding Compilation. 10881- (line 6) 10882-* --old-file, and recursion: Options/Recursion. (line 22) 10883-* --print-data-base: Options Summary. (line 155) 10884-* --print-directory: Options Summary. (line 225) 10885-* --print-directory, and --directory: -w Option. (line 20) 10886-* --print-directory, and recursion: -w Option. (line 20) 10887-* --print-directory, disabling: -w Option. (line 20) 10888-* --question <1>: Options Summary. (line 167) 10889-* --question: Instead of Execution. 10890- (line 25) 10891-* --quiet <1>: Options Summary. (line 198) 10892-* --quiet: Echoing. (line 24) 10893-* --recon <1>: Options Summary. (line 141) 10894-* --recon <2>: Instead of Execution. 10895- (line 14) 10896-* --recon: Echoing. (line 18) 10897-* --silent <1>: Options Summary. (line 197) 10898-* --silent: Echoing. (line 24) 10899-* --stop: Options Summary. (line 204) 10900-* --touch <1>: Options Summary. (line 212) 10901-* --touch: Instead of Execution. 10902- (line 19) 10903-* --touch, and recursion: MAKE Variable. (line 34) 10904-* --version: Options Summary. (line 220) 10905-* --warn-undefined-variables: Options Summary. (line 251) 10906-* --what-if <1>: Options Summary. (line 240) 10907-* --what-if: Instead of Execution. 10908- (line 33) 10909-* -B: Options Summary. (line 14) 10910-* -b: Options Summary. (line 9) 10911-* -C <1>: Options Summary. (line 25) 10912-* -C: Recursion. (line 20) 10913-* -C, and -w: -w Option. (line 20) 10914-* -C, and recursion: Options/Recursion. (line 22) 10915-* -d: Options Summary. (line 33) 10916-* -e: Options Summary. (line 77) 10917-* -e (shell flag): Automatic Prerequisites. 10918- (line 66) 10919-* -f <1>: Options Summary. (line 83) 10920-* -f <2>: Makefile Arguments. (line 6) 10921-* -f: Makefile Names. (line 23) 10922-* -f, and recursion: Options/Recursion. (line 22) 10923-* -h: Options Summary. (line 89) 10924-* -I: Options Summary. (line 98) 10925-* -i <1>: Options Summary. (line 93) 10926-* -i: Errors. (line 30) 10927-* -I: Include. (line 52) 10928-* -j <1>: Options Summary. (line 105) 10929-* -j: Parallel. (line 6) 10930-* -j, and archive update: Archive Pitfalls. (line 6) 10931-* -j, and recursion: Options/Recursion. (line 25) 10932-* -k <1>: Options Summary. (line 114) 10933-* -k <2>: Testing. (line 16) 10934-* -k: Errors. (line 47) 10935-* -L: Options Summary. (line 129) 10936-* -l: Options Summary. (line 121) 10937-* -l (library search): Libraries/Search. (line 6) 10938-* -l (load average): Parallel. (line 57) 10939-* -m: Options Summary. (line 10) 10940-* -M (to compiler): Automatic Prerequisites. 10941- (line 18) 10942-* -MM (to GNU compiler): Automatic Prerequisites. 10943- (line 68) 10944-* -n <1>: Options Summary. (line 138) 10945-* -n <2>: Instead of Execution. 10946- (line 14) 10947-* -n: Echoing. (line 18) 10948-* -o <1>: Options Summary. (line 145) 10949-* -o: Avoiding Compilation. 10950- (line 6) 10951-* -o, and recursion: Options/Recursion. (line 22) 10952-* -p: Options Summary. (line 154) 10953-* -q <1>: Options Summary. (line 166) 10954-* -q: Instead of Execution. 10955- (line 25) 10956-* -R: Options Summary. (line 187) 10957-* -r: Options Summary. (line 174) 10958-* -S: Options Summary. (line 202) 10959-* -s <1>: Options Summary. (line 196) 10960-* -s: Echoing. (line 24) 10961-* -t <1>: Options Summary. (line 211) 10962-* -t: Instead of Execution. 10963- (line 19) 10964-* -t, and recursion: MAKE Variable. (line 34) 10965-* -v: Options Summary. (line 219) 10966-* -W: Options Summary. (line 239) 10967-* -w: Options Summary. (line 224) 10968-* -W: Instead of Execution. 10969- (line 33) 10970-* -w, and -C: -w Option. (line 20) 10971-* -w, and recursion: -w Option. (line 20) 10972-* -W, and recursion: Options/Recursion. (line 22) 10973-* -w, disabling: -w Option. (line 20) 10974-* .a (archives): Archive Suffix Rules. 10975- (line 6) 10976-* .C: Catalogue of Rules. (line 39) 10977-* .c: Catalogue of Rules. (line 35) 10978-* .cc: Catalogue of Rules. (line 39) 10979-* .ch: Catalogue of Rules. (line 151) 10980-* .cpp: Catalogue of Rules. (line 39) 10981-* .d: Automatic Prerequisites. 10982- (line 81) 10983-* .def: Catalogue of Rules. (line 74) 10984-* .dvi: Catalogue of Rules. (line 151) 10985-* .F: Catalogue of Rules. (line 49) 10986-* .f: Catalogue of Rules. (line 49) 10987-* .info: Catalogue of Rules. (line 158) 10988-* .l: Catalogue of Rules. (line 124) 10989-* .LIBPATTERNS, and link libraries: Libraries/Search. (line 6) 10990-* .ln: Catalogue of Rules. (line 146) 10991-* .mod: Catalogue of Rules. (line 74) 10992-* .o: Catalogue of Rules. (line 35) 10993-* .p: Catalogue of Rules. (line 45) 10994-* .PRECIOUS intermediate files: Chained Rules. (line 56) 10995-* .r: Catalogue of Rules. (line 49) 10996-* .S: Catalogue of Rules. (line 82) 10997-* .s: Catalogue of Rules. (line 79) 10998-* .sh: Catalogue of Rules. (line 180) 10999-* .sym: Catalogue of Rules. (line 74) 11000-* .tex: Catalogue of Rules. (line 151) 11001-* .texi: Catalogue of Rules. (line 158) 11002-* .texinfo: Catalogue of Rules. (line 158) 11003-* .txinfo: Catalogue of Rules. (line 158) 11004-* .w: Catalogue of Rules. (line 151) 11005-* .web: Catalogue of Rules. (line 151) 11006-* .y: Catalogue of Rules. (line 120) 11007-* :: rules (double-colon): Double-Colon. (line 6) 11008-* := <1>: Setting. (line 6) 11009-* :=: Flavors. (line 56) 11010-* = <1>: Setting. (line 6) 11011-* =: Flavors. (line 10) 11012-* =, expansion: Reading Makefiles. (line 33) 11013-* ? (wildcard character): Wildcards. (line 6) 11014-* ?= <1>: Setting. (line 6) 11015-* ?=: Flavors. (line 129) 11016-* ?=, expansion: Reading Makefiles. (line 33) 11017-* @ (in commands): Echoing. (line 6) 11018-* @, and define: Sequences. (line 50) 11019-* [...] (wildcard characters): Wildcards. (line 6) 11020-* \ (backslash), for continuation lines: Simple Makefile. (line 40) 11021-* \ (backslash), in commands: Splitting Lines. (line 6) 11022-* \ (backslash), to quote % <1>: Text Functions. (line 26) 11023-* \ (backslash), to quote % <2>: Static Usage. (line 37) 11024-* \ (backslash), to quote %: Selective Search. (line 38) 11025-* __.SYMDEF: Archive Symbols. (line 6) 11026-* abspath: File Name Functions. (line 121) 11027-* algorithm for directory search: Search Algorithm. (line 6) 11028-* all (standard target): Goals. (line 72) 11029-* appending to variables: Appending. (line 6) 11030-* ar: Implicit Variables. (line 41) 11031-* archive: Archives. (line 6) 11032-* archive member targets: Archive Members. (line 6) 11033-* archive symbol directory updating: Archive Symbols. (line 6) 11034-* archive, and -j: Archive Pitfalls. (line 6) 11035-* archive, and parallel execution: Archive Pitfalls. (line 6) 11036-* archive, suffix rule for: Archive Suffix Rules. 11037- (line 6) 11038-* Arg list too long: Options/Recursion. (line 57) 11039-* arguments of functions: Syntax of Functions. (line 6) 11040-* as <1>: Implicit Variables. (line 44) 11041-* as: Catalogue of Rules. (line 79) 11042-* assembly, rule to compile: Catalogue of Rules. (line 79) 11043-* automatic generation of prerequisites <1>: Automatic Prerequisites. 11044- (line 6) 11045-* automatic generation of prerequisites: Include. (line 50) 11046-* automatic variables: Automatic Variables. (line 6) 11047-* automatic variables in prerequisites: Automatic Variables. (line 17) 11048-* backquotes: Shell Function. (line 6) 11049-* backslash (\), for continuation lines: Simple Makefile. (line 40) 11050-* backslash (\), in commands: Splitting Lines. (line 6) 11051-* backslash (\), to quote % <1>: Text Functions. (line 26) 11052-* backslash (\), to quote % <2>: Static Usage. (line 37) 11053-* backslash (\), to quote %: Selective Search. (line 38) 11054-* backslashes in pathnames and wildcard expansion: Wildcard Pitfall. 11055- (line 31) 11056-* basename: File Name Functions. (line 57) 11057-* binary packages: Install Command Categories. 11058- (line 80) 11059-* broken pipe: Parallel. (line 30) 11060-* bugs, reporting: Bugs. (line 6) 11061-* built-in special targets: Special Targets. (line 6) 11062-* C++, rule to compile: Catalogue of Rules. (line 39) 11063-* C, rule to compile: Catalogue of Rules. (line 35) 11064-* cc <1>: Implicit Variables. (line 47) 11065-* cc: Catalogue of Rules. (line 35) 11066-* cd (shell command) <1>: MAKE Variable. (line 16) 11067-* cd (shell command): Execution. (line 10) 11068-* chains of rules: Chained Rules. (line 6) 11069-* check (standard target): Goals. (line 114) 11070-* clean (standard target): Goals. (line 75) 11071-* clean target <1>: Cleanup. (line 11) 11072-* clean target: Simple Makefile. (line 83) 11073-* cleaning up: Cleanup. (line 6) 11074-* clobber (standard target): Goals. (line 86) 11075-* co <1>: Implicit Variables. (line 56) 11076-* co: Catalogue of Rules. (line 164) 11077-* combining rules by prerequisite: Combine By Prerequisite. 11078- (line 6) 11079-* command line variable definitions, and recursion: Options/Recursion. 11080- (line 17) 11081-* command line variables: Overriding. (line 6) 11082-* command syntax: Command Syntax. (line 6) 11083-* commands: Rule Syntax. (line 26) 11084-* commands setting shell variables: Execution. (line 10) 11085-* commands, backslash (\) in: Splitting Lines. (line 6) 11086-* commands, comments in: Command Syntax. (line 27) 11087-* commands, echoing: Echoing. (line 6) 11088-* commands, empty: Empty Commands. (line 6) 11089-* commands, errors in: Errors. (line 6) 11090-* commands, execution: Execution. (line 6) 11091-* commands, execution in parallel: Parallel. (line 6) 11092-* commands, expansion: Shell Function. (line 6) 11093-* commands, how to write: Commands. (line 6) 11094-* commands, instead of executing: Instead of Execution. 11095- (line 6) 11096-* commands, introduction to: Rule Introduction. (line 8) 11097-* commands, quoting newlines in: Splitting Lines. (line 6) 11098-* commands, sequences of: Sequences. (line 6) 11099-* commands, splitting: Splitting Lines. (line 6) 11100-* commands, using variables in: Variables in Commands. 11101- (line 6) 11102-* comments, in commands: Command Syntax. (line 27) 11103-* comments, in makefile: Makefile Contents. (line 41) 11104-* compatibility: Features. (line 6) 11105-* compatibility in exporting: Variables/Recursion. (line 105) 11106-* compilation, testing: Testing. (line 6) 11107-* computed variable name: Computed Names. (line 6) 11108-* conditional expansion: Conditional Functions. 11109- (line 6) 11110-* conditional variable assignment: Flavors. (line 129) 11111-* conditionals: Conditionals. (line 6) 11112-* continuation lines: Simple Makefile. (line 40) 11113-* controlling make: Make Control Functions. 11114- (line 6) 11115-* conventions for makefiles: Makefile Conventions. 11116- (line 6) 11117-* ctangle <1>: Implicit Variables. (line 107) 11118-* ctangle: Catalogue of Rules. (line 151) 11119-* cweave <1>: Implicit Variables. (line 101) 11120-* cweave: Catalogue of Rules. (line 151) 11121-* data base of make rules: Options Summary. (line 155) 11122-* deducing commands (implicit rules): make Deduces. (line 6) 11123-* default directories for included makefiles: Include. (line 52) 11124-* default goal <1>: Rules. (line 11) 11125-* default goal: How Make Works. (line 11) 11126-* default makefile name: Makefile Names. (line 6) 11127-* default rules, last-resort: Last Resort. (line 6) 11128-* define, expansion: Reading Makefiles. (line 33) 11129-* defining variables verbatim: Defining. (line 6) 11130-* deletion of target files <1>: Interrupts. (line 6) 11131-* deletion of target files: Errors. (line 64) 11132-* directive: Makefile Contents. (line 28) 11133-* directories, printing them: -w Option. (line 6) 11134-* directories, updating archive symbol: Archive Symbols. (line 6) 11135-* directory part: File Name Functions. (line 17) 11136-* directory search (VPATH): Directory Search. (line 6) 11137-* directory search (VPATH), and implicit rules: Implicit/Search. 11138- (line 6) 11139-* directory search (VPATH), and link libraries: Libraries/Search. 11140- (line 6) 11141-* directory search (VPATH), and shell commands: Commands/Search. 11142- (line 6) 11143-* directory search algorithm: Search Algorithm. (line 6) 11144-* directory search, traditional (GPATH): Search Algorithm. (line 42) 11145-* dist (standard target): Goals. (line 106) 11146-* distclean (standard target): Goals. (line 84) 11147-* dollar sign ($), in function call: Syntax of Functions. (line 6) 11148-* dollar sign ($), in rules: Rule Syntax. (line 32) 11149-* dollar sign ($), in variable name: Computed Names. (line 6) 11150-* dollar sign ($), in variable reference: Reference. (line 6) 11151-* DOS, choosing a shell in: Choosing the Shell. (line 36) 11152-* double-colon rules: Double-Colon. (line 6) 11153-* duplicate words, removing: Text Functions. (line 155) 11154-* E2BIG: Options/Recursion. (line 57) 11155-* echoing of commands: Echoing. (line 6) 11156-* editor: Introduction. (line 22) 11157-* Emacs (M-x compile): Errors. (line 62) 11158-* empty commands: Empty Commands. (line 6) 11159-* empty targets: Empty Targets. (line 6) 11160-* environment: Environment. (line 6) 11161-* environment, and recursion: Variables/Recursion. (line 6) 11162-* environment, SHELL in: Choosing the Shell. (line 10) 11163-* error, stopping on: Make Control Functions. 11164- (line 11) 11165-* errors (in commands): Errors. (line 6) 11166-* errors with wildcards: Wildcard Pitfall. (line 6) 11167-* evaluating makefile syntax: Eval Function. (line 6) 11168-* execution, in parallel: Parallel. (line 6) 11169-* execution, instead of: Instead of Execution. 11170- (line 6) 11171-* execution, of commands: Execution. (line 6) 11172-* exit status (errors): Errors. (line 6) 11173-* exit status of make: Running. (line 18) 11174-* expansion, secondary: Secondary Expansion. (line 6) 11175-* explicit rule, definition of: Makefile Contents. (line 10) 11176-* explicit rule, expansion: Reading Makefiles. (line 62) 11177-* explicit rules, secondary expansion of: Secondary Expansion. 11178- (line 106) 11179-* exporting variables: Variables/Recursion. (line 6) 11180-* f77 <1>: Implicit Variables. (line 64) 11181-* f77: Catalogue of Rules. (line 49) 11182-* FDL, GNU Free Documentation License: GNU Free Documentation License. 11183- (line 6) 11184-* features of GNU make: Features. (line 6) 11185-* features, missing: Missing. (line 6) 11186-* file name functions: File Name Functions. (line 6) 11187-* file name of makefile: Makefile Names. (line 6) 11188-* file name of makefile, how to specify: Makefile Names. (line 30) 11189-* file name prefix, adding: File Name Functions. (line 79) 11190-* file name suffix: File Name Functions. (line 43) 11191-* file name suffix, adding: File Name Functions. (line 68) 11192-* file name with wildcards: Wildcards. (line 6) 11193-* file name, abspath of: File Name Functions. (line 121) 11194-* file name, basename of: File Name Functions. (line 57) 11195-* file name, directory part: File Name Functions. (line 17) 11196-* file name, nondirectory part: File Name Functions. (line 27) 11197-* file name, realpath of: File Name Functions. (line 114) 11198-* files, assuming new: Instead of Execution. 11199- (line 33) 11200-* files, assuming old: Avoiding Compilation. 11201- (line 6) 11202-* files, avoiding recompilation of: Avoiding Compilation. 11203- (line 6) 11204-* files, intermediate: Chained Rules. (line 16) 11205-* filtering out words: Text Functions. (line 132) 11206-* filtering words: Text Functions. (line 114) 11207-* finding strings: Text Functions. (line 103) 11208-* flags: Options Summary. (line 6) 11209-* flags for compilers: Implicit Variables. (line 6) 11210-* flavor of variable: Flavor Function. (line 6) 11211-* flavors of variables: Flavors. (line 6) 11212-* FORCE: Force Targets. (line 6) 11213-* force targets: Force Targets. (line 6) 11214-* Fortran, rule to compile: Catalogue of Rules. (line 49) 11215-* functions: Functions. (line 6) 11216-* functions, for controlling make: Make Control Functions. 11217- (line 6) 11218-* functions, for file names: File Name Functions. (line 6) 11219-* functions, for text: Text Functions. (line 6) 11220-* functions, syntax of: Syntax of Functions. (line 6) 11221-* functions, user defined: Call Function. (line 6) 11222-* g++ <1>: Implicit Variables. (line 53) 11223-* g++: Catalogue of Rules. (line 39) 11224-* gcc: Catalogue of Rules. (line 35) 11225-* generating prerequisites automatically <1>: Automatic Prerequisites. 11226- (line 6) 11227-* generating prerequisites automatically: Include. (line 50) 11228-* get <1>: Implicit Variables. (line 67) 11229-* get: Catalogue of Rules. (line 173) 11230-* globbing (wildcards): Wildcards. (line 6) 11231-* goal: How Make Works. (line 11) 11232-* goal, default <1>: Rules. (line 11) 11233-* goal, default: How Make Works. (line 11) 11234-* goal, how to specify: Goals. (line 6) 11235-* home directory: Wildcards. (line 11) 11236-* IEEE Standard 1003.2: Overview. (line 13) 11237-* ifdef, expansion: Reading Makefiles. (line 51) 11238-* ifeq, expansion: Reading Makefiles. (line 51) 11239-* ifndef, expansion: Reading Makefiles. (line 51) 11240-* ifneq, expansion: Reading Makefiles. (line 51) 11241-* implicit rule: Implicit Rules. (line 6) 11242-* implicit rule, and directory search: Implicit/Search. (line 6) 11243-* implicit rule, and VPATH: Implicit/Search. (line 6) 11244-* implicit rule, definition of: Makefile Contents. (line 16) 11245-* implicit rule, expansion: Reading Makefiles. (line 62) 11246-* implicit rule, how to use: Using Implicit. (line 6) 11247-* implicit rule, introduction to: make Deduces. (line 6) 11248-* implicit rule, predefined: Catalogue of Rules. (line 6) 11249-* implicit rule, search algorithm: Implicit Rule Search. 11250- (line 6) 11251-* implicit rules, secondary expansion of: Secondary Expansion. 11252- (line 146) 11253-* included makefiles, default directories: Include. (line 52) 11254-* including (MAKEFILE_LIST variable): MAKEFILE_LIST Variable. 11255- (line 6) 11256-* including (MAKEFILES variable): MAKEFILES Variable. (line 6) 11257-* including other makefiles: Include. (line 6) 11258-* incompatibilities: Missing. (line 6) 11259-* Info, rule to format: Catalogue of Rules. (line 158) 11260-* install (standard target): Goals. (line 92) 11261-* intermediate files: Chained Rules. (line 16) 11262-* intermediate files, preserving: Chained Rules. (line 46) 11263-* intermediate targets, explicit: Special Targets. (line 44) 11264-* interrupt: Interrupts. (line 6) 11265-* job slots: Parallel. (line 6) 11266-* job slots, and recursion: Options/Recursion. (line 25) 11267-* jobs, limiting based on load: Parallel. (line 57) 11268-* joining lists of words: File Name Functions. (line 90) 11269-* killing (interruption): Interrupts. (line 6) 11270-* last-resort default rules: Last Resort. (line 6) 11271-* ld: Catalogue of Rules. (line 86) 11272-* lex <1>: Implicit Variables. (line 71) 11273-* lex: Catalogue of Rules. (line 124) 11274-* Lex, rule to run: Catalogue of Rules. (line 124) 11275-* libraries for linking, directory search: Libraries/Search. (line 6) 11276-* library archive, suffix rule for: Archive Suffix Rules. 11277- (line 6) 11278-* limiting jobs based on load: Parallel. (line 57) 11279-* link libraries, and directory search: Libraries/Search. (line 6) 11280-* link libraries, patterns matching: Libraries/Search. (line 6) 11281-* linking, predefined rule for: Catalogue of Rules. (line 86) 11282-* lint <1>: Implicit Variables. (line 78) 11283-* lint: Catalogue of Rules. (line 146) 11284-* lint, rule to run: Catalogue of Rules. (line 146) 11285-* list of all prerequisites: Automatic Variables. (line 61) 11286-* list of changed prerequisites: Automatic Variables. (line 51) 11287-* load average: Parallel. (line 57) 11288-* loops in variable expansion: Flavors. (line 44) 11289-* lpr (shell command) <1>: Empty Targets. (line 25) 11290-* lpr (shell command): Wildcard Examples. (line 21) 11291-* m2c <1>: Implicit Variables. (line 81) 11292-* m2c: Catalogue of Rules. (line 74) 11293-* macro: Using Variables. (line 10) 11294-* make depend: Automatic Prerequisites. 11295- (line 37) 11296-* makefile: Introduction. (line 7) 11297-* makefile name: Makefile Names. (line 6) 11298-* makefile name, how to specify: Makefile Names. (line 30) 11299-* makefile rule parts: Rule Introduction. (line 6) 11300-* makefile syntax, evaluating: Eval Function. (line 6) 11301-* makefile, and MAKEFILES variable: MAKEFILES Variable. (line 6) 11302-* makefile, conventions for: Makefile Conventions. 11303- (line 6) 11304-* makefile, how make processes: How Make Works. (line 6) 11305-* makefile, how to write: Makefiles. (line 6) 11306-* makefile, including: Include. (line 6) 11307-* makefile, overriding: Overriding Makefiles. 11308- (line 6) 11309-* makefile, parsing: Reading Makefiles. (line 6) 11310-* makefile, remaking of: Remaking Makefiles. (line 6) 11311-* makefile, simple: Simple Makefile. (line 6) 11312-* makefiles, and MAKEFILE_LIST variable: MAKEFILE_LIST Variable. 11313- (line 6) 11314-* makefiles, and special variables: Special Variables. (line 6) 11315-* makeinfo <1>: Implicit Variables. (line 88) 11316-* makeinfo: Catalogue of Rules. (line 158) 11317-* match-anything rule: Match-Anything Rules. 11318- (line 6) 11319-* match-anything rule, used to override: Overriding Makefiles. 11320- (line 12) 11321-* missing features: Missing. (line 6) 11322-* mistakes with wildcards: Wildcard Pitfall. (line 6) 11323-* modified variable reference: Substitution Refs. (line 6) 11324-* Modula-2, rule to compile: Catalogue of Rules. (line 74) 11325-* mostlyclean (standard target): Goals. (line 78) 11326-* multiple rules for one target: Multiple Rules. (line 6) 11327-* multiple rules for one target (::): Double-Colon. (line 6) 11328-* multiple targets: Multiple Targets. (line 6) 11329-* multiple targets, in pattern rule: Pattern Intro. (line 49) 11330-* name of makefile: Makefile Names. (line 6) 11331-* name of makefile, how to specify: Makefile Names. (line 30) 11332-* nested variable reference: Computed Names. (line 6) 11333-* newline, quoting, in commands: Splitting Lines. (line 6) 11334-* newline, quoting, in makefile: Simple Makefile. (line 40) 11335-* nondirectory part: File Name Functions. (line 27) 11336-* normal prerequisites: Prerequisite Types. (line 6) 11337-* OBJ: Variables Simplify. (line 20) 11338-* obj: Variables Simplify. (line 20) 11339-* OBJECTS: Variables Simplify. (line 20) 11340-* objects: Variables Simplify. (line 14) 11341-* OBJS: Variables Simplify. (line 20) 11342-* objs: Variables Simplify. (line 20) 11343-* old-fashioned suffix rules: Suffix Rules. (line 6) 11344-* options: Options Summary. (line 6) 11345-* options, and recursion: Options/Recursion. (line 6) 11346-* options, setting from environment: Options/Recursion. (line 81) 11347-* options, setting in makefiles: Options/Recursion. (line 81) 11348-* order of pattern rules: Pattern Intro. (line 57) 11349-* order-only prerequisites: Prerequisite Types. (line 6) 11350-* origin of variable: Origin Function. (line 6) 11351-* overriding makefiles: Overriding Makefiles. 11352- (line 6) 11353-* overriding variables with arguments: Overriding. (line 6) 11354-* overriding with override: Override Directive. (line 6) 11355-* parallel execution: Parallel. (line 6) 11356-* parallel execution, and archive update: Archive Pitfalls. (line 6) 11357-* parallel execution, overriding: Special Targets. (line 135) 11358-* parts of makefile rule: Rule Introduction. (line 6) 11359-* Pascal, rule to compile: Catalogue of Rules. (line 45) 11360-* pattern rule: Pattern Intro. (line 6) 11361-* pattern rule, expansion: Reading Makefiles. (line 62) 11362-* pattern rules, order of: Pattern Intro. (line 57) 11363-* pattern rules, static (not implicit): Static Pattern. (line 6) 11364-* pattern rules, static, syntax of: Static Usage. (line 6) 11365-* pattern-specific variables: Pattern-specific. (line 6) 11366-* pc <1>: Implicit Variables. (line 84) 11367-* pc: Catalogue of Rules. (line 45) 11368-* phony targets: Phony Targets. (line 6) 11369-* pitfalls of wildcards: Wildcard Pitfall. (line 6) 11370-* portability: Features. (line 6) 11371-* POSIX: Overview. (line 13) 11372-* POSIX.2: Options/Recursion. (line 60) 11373-* post-installation commands: Install Command Categories. 11374- (line 6) 11375-* pre-installation commands: Install Command Categories. 11376- (line 6) 11377-* precious targets: Special Targets. (line 29) 11378-* predefined rules and variables, printing: Options Summary. (line 155) 11379-* prefix, adding: File Name Functions. (line 79) 11380-* prerequisite: Rules. (line 6) 11381-* prerequisite pattern, implicit: Pattern Intro. (line 22) 11382-* prerequisite pattern, static (not implicit): Static Usage. (line 30) 11383-* prerequisite types: Prerequisite Types. (line 6) 11384-* prerequisite, expansion: Reading Makefiles. (line 62) 11385-* prerequisites: Rule Syntax. (line 46) 11386-* prerequisites, and automatic variables: Automatic Variables. 11387- (line 17) 11388-* prerequisites, automatic generation <1>: Automatic Prerequisites. 11389- (line 6) 11390-* prerequisites, automatic generation: Include. (line 50) 11391-* prerequisites, introduction to: Rule Introduction. (line 8) 11392-* prerequisites, list of all: Automatic Variables. (line 61) 11393-* prerequisites, list of changed: Automatic Variables. (line 51) 11394-* prerequisites, normal: Prerequisite Types. (line 6) 11395-* prerequisites, order-only: Prerequisite Types. (line 6) 11396-* prerequisites, varying (static pattern): Static Pattern. (line 6) 11397-* preserving intermediate files: Chained Rules. (line 46) 11398-* preserving with .PRECIOUS <1>: Chained Rules. (line 56) 11399-* preserving with .PRECIOUS: Special Targets. (line 29) 11400-* preserving with .SECONDARY: Special Targets. (line 49) 11401-* print (standard target): Goals. (line 97) 11402-* print target <1>: Empty Targets. (line 25) 11403-* print target: Wildcard Examples. (line 21) 11404-* printing directories: -w Option. (line 6) 11405-* printing messages: Make Control Functions. 11406- (line 43) 11407-* printing of commands: Echoing. (line 6) 11408-* printing user warnings: Make Control Functions. 11409- (line 35) 11410-* problems and bugs, reporting: Bugs. (line 6) 11411-* problems with wildcards: Wildcard Pitfall. (line 6) 11412-* processing a makefile: How Make Works. (line 6) 11413-* question mode: Instead of Execution. 11414- (line 25) 11415-* quoting %, in patsubst: Text Functions. (line 26) 11416-* quoting %, in static pattern: Static Usage. (line 37) 11417-* quoting %, in vpath: Selective Search. (line 38) 11418-* quoting newline, in commands: Splitting Lines. (line 6) 11419-* quoting newline, in makefile: Simple Makefile. (line 40) 11420-* Ratfor, rule to compile: Catalogue of Rules. (line 49) 11421-* RCS, rule to extract from: Catalogue of Rules. (line 164) 11422-* reading makefiles: Reading Makefiles. (line 6) 11423-* README: Makefile Names. (line 9) 11424-* realclean (standard target): Goals. (line 85) 11425-* realpath: File Name Functions. (line 114) 11426-* recompilation: Introduction. (line 22) 11427-* recompilation, avoiding: Avoiding Compilation. 11428- (line 6) 11429-* recording events with empty targets: Empty Targets. (line 6) 11430-* recursion: Recursion. (line 6) 11431-* recursion, and -C: Options/Recursion. (line 22) 11432-* recursion, and -f: Options/Recursion. (line 22) 11433-* recursion, and -j: Options/Recursion. (line 25) 11434-* recursion, and -o: Options/Recursion. (line 22) 11435-* recursion, and -t: MAKE Variable. (line 34) 11436-* recursion, and -w: -w Option. (line 20) 11437-* recursion, and -W: Options/Recursion. (line 22) 11438-* recursion, and command line variable definitions: Options/Recursion. 11439- (line 17) 11440-* recursion, and environment: Variables/Recursion. (line 6) 11441-* recursion, and MAKE variable: MAKE Variable. (line 6) 11442-* recursion, and MAKEFILES variable: MAKEFILES Variable. (line 14) 11443-* recursion, and options: Options/Recursion. (line 6) 11444-* recursion, and printing directories: -w Option. (line 6) 11445-* recursion, and variables: Variables/Recursion. (line 6) 11446-* recursion, level of: Variables/Recursion. (line 115) 11447-* recursive variable expansion <1>: Flavors. (line 6) 11448-* recursive variable expansion: Using Variables. (line 6) 11449-* recursively expanded variables: Flavors. (line 6) 11450-* reference to variables <1>: Advanced. (line 6) 11451-* reference to variables: Reference. (line 6) 11452-* relinking: How Make Works. (line 46) 11453-* remaking makefiles: Remaking Makefiles. (line 6) 11454-* removal of target files <1>: Interrupts. (line 6) 11455-* removal of target files: Errors. (line 64) 11456-* removing duplicate words: Text Functions. (line 155) 11457-* removing targets on failure: Special Targets. (line 68) 11458-* removing, to clean up: Cleanup. (line 6) 11459-* reporting bugs: Bugs. (line 6) 11460-* rm: Implicit Variables. (line 110) 11461-* rm (shell command) <1>: Errors. (line 27) 11462-* rm (shell command) <2>: Phony Targets. (line 20) 11463-* rm (shell command) <3>: Wildcard Examples. (line 12) 11464-* rm (shell command): Simple Makefile. (line 83) 11465-* rule commands: Commands. (line 6) 11466-* rule prerequisites: Rule Syntax. (line 46) 11467-* rule syntax: Rule Syntax. (line 6) 11468-* rule targets: Rule Syntax. (line 18) 11469-* rule, double-colon (::): Double-Colon. (line 6) 11470-* rule, explicit, definition of: Makefile Contents. (line 10) 11471-* rule, how to write: Rules. (line 6) 11472-* rule, implicit: Implicit Rules. (line 6) 11473-* rule, implicit, and directory search: Implicit/Search. (line 6) 11474-* rule, implicit, and VPATH: Implicit/Search. (line 6) 11475-* rule, implicit, chains of: Chained Rules. (line 6) 11476-* rule, implicit, definition of: Makefile Contents. (line 16) 11477-* rule, implicit, how to use: Using Implicit. (line 6) 11478-* rule, implicit, introduction to: make Deduces. (line 6) 11479-* rule, implicit, predefined: Catalogue of Rules. (line 6) 11480-* rule, introduction to: Rule Introduction. (line 6) 11481-* rule, multiple for one target: Multiple Rules. (line 6) 11482-* rule, no commands or prerequisites: Force Targets. (line 6) 11483-* rule, pattern: Pattern Intro. (line 6) 11484-* rule, static pattern: Static Pattern. (line 6) 11485-* rule, static pattern versus implicit: Static versus Implicit. 11486- (line 6) 11487-* rule, with multiple targets: Multiple Targets. (line 6) 11488-* rules, and $: Rule Syntax. (line 32) 11489-* s. (SCCS file prefix): Catalogue of Rules. (line 173) 11490-* SCCS, rule to extract from: Catalogue of Rules. (line 173) 11491-* search algorithm, implicit rule: Implicit Rule Search. 11492- (line 6) 11493-* search path for prerequisites (VPATH): Directory Search. (line 6) 11494-* search path for prerequisites (VPATH), and implicit rules: Implicit/Search. 11495- (line 6) 11496-* search path for prerequisites (VPATH), and link libraries: Libraries/Search. 11497- (line 6) 11498-* searching for strings: Text Functions. (line 103) 11499-* secondary expansion: Secondary Expansion. (line 6) 11500-* secondary expansion and explicit rules: Secondary Expansion. 11501- (line 106) 11502-* secondary expansion and implicit rules: Secondary Expansion. 11503- (line 146) 11504-* secondary expansion and static pattern rules: Secondary Expansion. 11505- (line 138) 11506-* secondary files: Chained Rules. (line 46) 11507-* secondary targets: Special Targets. (line 49) 11508-* sed (shell command): Automatic Prerequisites. 11509- (line 73) 11510-* selecting a word: Text Functions. (line 159) 11511-* selecting word lists: Text Functions. (line 168) 11512-* sequences of commands: Sequences. (line 6) 11513-* setting options from environment: Options/Recursion. (line 81) 11514-* setting options in makefiles: Options/Recursion. (line 81) 11515-* setting variables: Setting. (line 6) 11516-* several rules for one target: Multiple Rules. (line 6) 11517-* several targets in a rule: Multiple Targets. (line 6) 11518-* shar (standard target): Goals. (line 103) 11519-* shell command: Simple Makefile. (line 72) 11520-* shell command, and directory search: Commands/Search. (line 6) 11521-* shell command, execution: Execution. (line 6) 11522-* shell command, function for: Shell Function. (line 6) 11523-* shell file name pattern (in include): Include. (line 13) 11524-* shell variables, setting in commands: Execution. (line 10) 11525-* shell wildcards (in include): Include. (line 13) 11526-* shell, choosing the: Choosing the Shell. (line 6) 11527-* SHELL, exported value: Variables/Recursion. (line 23) 11528-* SHELL, import from environment: Environment. (line 37) 11529-* shell, in DOS and Windows: Choosing the Shell. (line 36) 11530-* SHELL, MS-DOS specifics: Choosing the Shell. (line 42) 11531-* SHELL, value of: Choosing the Shell. (line 6) 11532-* signal: Interrupts. (line 6) 11533-* silent operation: Echoing. (line 6) 11534-* simple makefile: Simple Makefile. (line 6) 11535-* simple variable expansion: Using Variables. (line 6) 11536-* simplifying with variables: Variables Simplify. (line 6) 11537-* simply expanded variables: Flavors. (line 56) 11538-* sorting words: Text Functions. (line 146) 11539-* spaces, in variable values: Flavors. (line 103) 11540-* spaces, stripping: Text Functions. (line 80) 11541-* special targets: Special Targets. (line 6) 11542-* special variables: Special Variables. (line 6) 11543-* specifying makefile name: Makefile Names. (line 30) 11544-* splitting commands: Splitting Lines. (line 6) 11545-* standard input: Parallel. (line 30) 11546-* standards conformance: Overview. (line 13) 11547-* standards for makefiles: Makefile Conventions. 11548- (line 6) 11549-* static pattern rule: Static Pattern. (line 6) 11550-* static pattern rule, syntax of: Static Usage. (line 6) 11551-* static pattern rule, versus implicit: Static versus Implicit. 11552- (line 6) 11553-* static pattern rules, secondary expansion of: Secondary Expansion. 11554- (line 138) 11555-* stem <1>: Pattern Match. (line 6) 11556-* stem: Static Usage. (line 17) 11557-* stem, variable for: Automatic Variables. (line 77) 11558-* stopping make: Make Control Functions. 11559- (line 11) 11560-* strings, searching for: Text Functions. (line 103) 11561-* stripping whitespace: Text Functions. (line 80) 11562-* sub-make: Variables/Recursion. (line 6) 11563-* subdirectories, recursion for: Recursion. (line 6) 11564-* substitution variable reference: Substitution Refs. (line 6) 11565-* suffix rule: Suffix Rules. (line 6) 11566-* suffix rule, for archive: Archive Suffix Rules. 11567- (line 6) 11568-* suffix, adding: File Name Functions. (line 68) 11569-* suffix, function to find: File Name Functions. (line 43) 11570-* suffix, substituting in variables: Substitution Refs. (line 6) 11571-* switches: Options Summary. (line 6) 11572-* symbol directories, updating archive: Archive Symbols. (line 6) 11573-* syntax of commands: Command Syntax. (line 6) 11574-* syntax of rules: Rule Syntax. (line 6) 11575-* tab character (in commands): Rule Syntax. (line 26) 11576-* tabs in rules: Rule Introduction. (line 21) 11577-* TAGS (standard target): Goals. (line 111) 11578-* tangle <1>: Implicit Variables. (line 104) 11579-* tangle: Catalogue of Rules. (line 151) 11580-* tar (standard target): Goals. (line 100) 11581-* target: Rules. (line 6) 11582-* target pattern, implicit: Pattern Intro. (line 9) 11583-* target pattern, static (not implicit): Static Usage. (line 17) 11584-* target, deleting on error: Errors. (line 64) 11585-* target, deleting on interrupt: Interrupts. (line 6) 11586-* target, expansion: Reading Makefiles. (line 62) 11587-* target, multiple in pattern rule: Pattern Intro. (line 49) 11588-* target, multiple rules for one: Multiple Rules. (line 6) 11589-* target, touching: Instead of Execution. 11590- (line 19) 11591-* target-specific variables: Target-specific. (line 6) 11592-* targets: Rule Syntax. (line 18) 11593-* targets without a file: Phony Targets. (line 6) 11594-* targets, built-in special: Special Targets. (line 6) 11595-* targets, empty: Empty Targets. (line 6) 11596-* targets, force: Force Targets. (line 6) 11597-* targets, introduction to: Rule Introduction. (line 8) 11598-* targets, multiple: Multiple Targets. (line 6) 11599-* targets, phony: Phony Targets. (line 6) 11600-* terminal rule: Match-Anything Rules. 11601- (line 6) 11602-* test (standard target): Goals. (line 115) 11603-* testing compilation: Testing. (line 6) 11604-* tex <1>: Implicit Variables. (line 91) 11605-* tex: Catalogue of Rules. (line 151) 11606-* TeX, rule to run: Catalogue of Rules. (line 151) 11607-* texi2dvi <1>: Implicit Variables. (line 95) 11608-* texi2dvi: Catalogue of Rules. (line 158) 11609-* Texinfo, rule to format: Catalogue of Rules. (line 158) 11610-* tilde (~): Wildcards. (line 11) 11611-* touch (shell command) <1>: Empty Targets. (line 25) 11612-* touch (shell command): Wildcard Examples. (line 21) 11613-* touching files: Instead of Execution. 11614- (line 19) 11615-* traditional directory search (GPATH): Search Algorithm. (line 42) 11616-* types of prerequisites: Prerequisite Types. (line 6) 11617-* undefined variables, warning message: Options Summary. (line 251) 11618-* updating archive symbol directories: Archive Symbols. (line 6) 11619-* updating makefiles: Remaking Makefiles. (line 6) 11620-* user defined functions: Call Function. (line 6) 11621-* value: Using Variables. (line 6) 11622-* value, how a variable gets it: Values. (line 6) 11623-* variable: Using Variables. (line 6) 11624-* variable definition: Makefile Contents. (line 22) 11625-* variable references in commands: Variables in Commands. 11626- (line 6) 11627-* variables: Variables Simplify. (line 6) 11628-* variables, $ in name: Computed Names. (line 6) 11629-* variables, and implicit rule: Automatic Variables. (line 6) 11630-* variables, appending to: Appending. (line 6) 11631-* variables, automatic: Automatic Variables. (line 6) 11632-* variables, command line: Overriding. (line 6) 11633-* variables, command line, and recursion: Options/Recursion. (line 17) 11634-* variables, computed names: Computed Names. (line 6) 11635-* variables, conditional assignment: Flavors. (line 129) 11636-* variables, defining verbatim: Defining. (line 6) 11637-* variables, environment <1>: Environment. (line 6) 11638-* variables, environment: Variables/Recursion. (line 6) 11639-* variables, exporting: Variables/Recursion. (line 6) 11640-* variables, flavor of: Flavor Function. (line 6) 11641-* variables, flavors: Flavors. (line 6) 11642-* variables, how they get their values: Values. (line 6) 11643-* variables, how to reference: Reference. (line 6) 11644-* variables, loops in expansion: Flavors. (line 44) 11645-* variables, modified reference: Substitution Refs. (line 6) 11646-* variables, nested references: Computed Names. (line 6) 11647-* variables, origin of: Origin Function. (line 6) 11648-* variables, overriding: Override Directive. (line 6) 11649-* variables, overriding with arguments: Overriding. (line 6) 11650-* variables, pattern-specific: Pattern-specific. (line 6) 11651-* variables, recursively expanded: Flavors. (line 6) 11652-* variables, setting: Setting. (line 6) 11653-* variables, simply expanded: Flavors. (line 56) 11654-* variables, spaces in values: Flavors. (line 103) 11655-* variables, substituting suffix in: Substitution Refs. (line 6) 11656-* variables, substitution reference: Substitution Refs. (line 6) 11657-* variables, target-specific: Target-specific. (line 6) 11658-* variables, unexpanded value: Value Function. (line 6) 11659-* variables, warning for undefined: Options Summary. (line 251) 11660-* varying prerequisites: Static Pattern. (line 6) 11661-* verbatim variable definition: Defining. (line 6) 11662-* vpath: Directory Search. (line 6) 11663-* VPATH, and implicit rules: Implicit/Search. (line 6) 11664-* VPATH, and link libraries: Libraries/Search. (line 6) 11665-* warnings, printing: Make Control Functions. 11666- (line 35) 11667-* weave <1>: Implicit Variables. (line 98) 11668-* weave: Catalogue of Rules. (line 151) 11669-* Web, rule to run: Catalogue of Rules. (line 151) 11670-* what if: Instead of Execution. 11671- (line 33) 11672-* whitespace, in variable values: Flavors. (line 103) 11673-* whitespace, stripping: Text Functions. (line 80) 11674-* wildcard: Wildcards. (line 6) 11675-* wildcard pitfalls: Wildcard Pitfall. (line 6) 11676-* wildcard, function: File Name Functions. (line 107) 11677-* wildcard, in archive member: Archive Members. (line 36) 11678-* wildcard, in include: Include. (line 13) 11679-* wildcards and MS-DOS/MS-Windows backslashes: Wildcard Pitfall. 11680- (line 31) 11681-* Windows, choosing a shell in: Choosing the Shell. (line 36) 11682-* word, selecting a: Text Functions. (line 159) 11683-* words, extracting first: Text Functions. (line 184) 11684-* words, extracting last: Text Functions. (line 197) 11685-* words, filtering: Text Functions. (line 114) 11686-* words, filtering out: Text Functions. (line 132) 11687-* words, finding number: Text Functions. (line 180) 11688-* words, iterating over: Foreach Function. (line 6) 11689-* words, joining lists: File Name Functions. (line 90) 11690-* words, removing duplicates: Text Functions. (line 155) 11691-* words, selecting lists of: Text Functions. (line 168) 11692-* writing rule commands: Commands. (line 6) 11693-* writing rules: Rules. (line 6) 11694-* yacc <1>: Implicit Variables. (line 75) 11695-* yacc <2>: Catalogue of Rules. (line 120) 11696-* yacc: Sequences. (line 18) 11697-* Yacc, rule to run: Catalogue of Rules. (line 120) 11698-* ~ (tilde): Wildcards. (line 11) 11699- 11700- 11701-File: make.info, Node: Name Index, Prev: Concept Index, Up: Top 11702- 11703-Index of Functions, Variables, & Directives 11704-******************************************* 11705- 11706-[index] 11707-* Menu: 11708- 11709-* $%: Automatic Variables. (line 37) 11710-* $(%D): Automatic Variables. (line 129) 11711-* $(%F): Automatic Variables. (line 130) 11712-* $(*D): Automatic Variables. (line 124) 11713-* $(*F): Automatic Variables. (line 125) 11714-* $(+D): Automatic Variables. (line 147) 11715-* $(+F): Automatic Variables. (line 148) 11716-* $(<D): Automatic Variables. (line 137) 11717-* $(<F): Automatic Variables. (line 138) 11718-* $(?D): Automatic Variables. (line 153) 11719-* $(?F): Automatic Variables. (line 154) 11720-* $(@D): Automatic Variables. (line 113) 11721-* $(@F): Automatic Variables. (line 119) 11722-* $(^D): Automatic Variables. (line 142) 11723-* $(^F): Automatic Variables. (line 143) 11724-* $*: Automatic Variables. (line 73) 11725-* $*, and static pattern: Static Usage. (line 81) 11726-* $+: Automatic Variables. (line 63) 11727-* $<: Automatic Variables. (line 43) 11728-* $?: Automatic Variables. (line 48) 11729-* $@: Automatic Variables. (line 30) 11730-* $^: Automatic Variables. (line 53) 11731-* $|: Automatic Variables. (line 69) 11732-* % (automatic variable): Automatic Variables. (line 37) 11733-* %D (automatic variable): Automatic Variables. (line 129) 11734-* %F (automatic variable): Automatic Variables. (line 130) 11735-* * (automatic variable): Automatic Variables. (line 73) 11736-* * (automatic variable), unsupported bizarre usage: Missing. (line 44) 11737-* *D (automatic variable): Automatic Variables. (line 124) 11738-* *F (automatic variable): Automatic Variables. (line 125) 11739-* + (automatic variable): Automatic Variables. (line 63) 11740-* +D (automatic variable): Automatic Variables. (line 147) 11741-* +F (automatic variable): Automatic Variables. (line 148) 11742-* .DEFAULT <1>: Last Resort. (line 23) 11743-* .DEFAULT: Special Targets. (line 20) 11744-* .DEFAULT, and empty commands: Empty Commands. (line 16) 11745-* .DEFAULT_GOAL (define default goal): Special Variables. (line 10) 11746-* .DELETE_ON_ERROR <1>: Errors. (line 64) 11747-* .DELETE_ON_ERROR: Special Targets. (line 67) 11748-* .EXPORT_ALL_VARIABLES <1>: Variables/Recursion. (line 99) 11749-* .EXPORT_ALL_VARIABLES: Special Targets. (line 129) 11750-* .FEATURES (list of supported features): Special Variables. (line 65) 11751-* .IGNORE <1>: Errors. (line 30) 11752-* .IGNORE: Special Targets. (line 74) 11753-* .INCLUDE_DIRS (list of include directories): Special Variables. 11754- (line 98) 11755-* .INTERMEDIATE: Special Targets. (line 43) 11756-* .LIBPATTERNS: Libraries/Search. (line 6) 11757-* .LOW_RESOLUTION_TIME: Special Targets. (line 86) 11758-* .NOTPARALLEL: Special Targets. (line 134) 11759-* .PHONY <1>: Special Targets. (line 8) 11760-* .PHONY: Phony Targets. (line 22) 11761-* .POSIX: Options/Recursion. (line 60) 11762-* .PRECIOUS <1>: Interrupts. (line 22) 11763-* .PRECIOUS: Special Targets. (line 28) 11764-* .SECONDARY: Special Targets. (line 48) 11765-* .SECONDEXPANSION <1>: Special Targets. (line 57) 11766-* .SECONDEXPANSION: Secondary Expansion. (line 6) 11767-* .SILENT <1>: Echoing. (line 24) 11768-* .SILENT: Special Targets. (line 116) 11769-* .SUFFIXES <1>: Suffix Rules. (line 61) 11770-* .SUFFIXES: Special Targets. (line 15) 11771-* .VARIABLES (list of variables): Special Variables. (line 56) 11772-* /usr/gnu/include: Include. (line 52) 11773-* /usr/include: Include. (line 52) 11774-* /usr/local/include: Include. (line 52) 11775-* < (automatic variable): Automatic Variables. (line 43) 11776-* <D (automatic variable): Automatic Variables. (line 137) 11777-* <F (automatic variable): Automatic Variables. (line 138) 11778-* ? (automatic variable): Automatic Variables. (line 48) 11779-* ?D (automatic variable): Automatic Variables. (line 153) 11780-* ?F (automatic variable): Automatic Variables. (line 154) 11781-* @ (automatic variable): Automatic Variables. (line 30) 11782-* @D (automatic variable): Automatic Variables. (line 113) 11783-* @F (automatic variable): Automatic Variables. (line 119) 11784-* ^ (automatic variable): Automatic Variables. (line 53) 11785-* ^D (automatic variable): Automatic Variables. (line 142) 11786-* ^F (automatic variable): Automatic Variables. (line 143) 11787-* abspath: File Name Functions. (line 121) 11788-* addprefix: File Name Functions. (line 79) 11789-* addsuffix: File Name Functions. (line 68) 11790-* and: Conditional Functions. 11791- (line 45) 11792-* AR: Implicit Variables. (line 41) 11793-* ARFLAGS: Implicit Variables. (line 117) 11794-* AS: Implicit Variables. (line 44) 11795-* ASFLAGS: Implicit Variables. (line 120) 11796-* basename: File Name Functions. (line 57) 11797-* bindir: Directory Variables. (line 53) 11798-* call: Call Function. (line 6) 11799-* CC: Implicit Variables. (line 47) 11800-* CFLAGS: Implicit Variables. (line 124) 11801-* CO: Implicit Variables. (line 50) 11802-* COFLAGS: Implicit Variables. (line 130) 11803-* COMSPEC: Choosing the Shell. (line 39) 11804-* CPP: Implicit Variables. (line 59) 11805-* CPPFLAGS: Implicit Variables. (line 133) 11806-* CTANGLE: Implicit Variables. (line 107) 11807-* CURDIR: Recursion. (line 28) 11808-* CWEAVE: Implicit Variables. (line 101) 11809-* CXX: Implicit Variables. (line 53) 11810-* CXXFLAGS: Implicit Variables. (line 127) 11811-* define: Defining. (line 6) 11812-* dir: File Name Functions. (line 17) 11813-* else: Conditional Syntax. (line 6) 11814-* endef: Defining. (line 6) 11815-* endif: Conditional Syntax. (line 6) 11816-* error: Make Control Functions. 11817- (line 11) 11818-* eval: Eval Function. (line 6) 11819-* exec_prefix: Directory Variables. (line 35) 11820-* export: Variables/Recursion. (line 40) 11821-* FC: Implicit Variables. (line 63) 11822-* FFLAGS: Implicit Variables. (line 137) 11823-* filter: Text Functions. (line 114) 11824-* filter-out: Text Functions. (line 132) 11825-* findstring: Text Functions. (line 103) 11826-* firstword: Text Functions. (line 184) 11827-* flavor: Flavor Function. (line 6) 11828-* foreach: Foreach Function. (line 6) 11829-* GET: Implicit Variables. (line 67) 11830-* GFLAGS: Implicit Variables. (line 140) 11831-* GNUmakefile: Makefile Names. (line 7) 11832-* GPATH: Search Algorithm. (line 48) 11833-* if: Conditional Functions. 11834- (line 6) 11835-* ifdef: Conditional Syntax. (line 6) 11836-* ifeq: Conditional Syntax. (line 6) 11837-* ifndef: Conditional Syntax. (line 6) 11838-* ifneq: Conditional Syntax. (line 6) 11839-* include: Include. (line 6) 11840-* info: Make Control Functions. 11841- (line 43) 11842-* join: File Name Functions. (line 90) 11843-* lastword: Text Functions. (line 197) 11844-* LDFLAGS: Implicit Variables. (line 143) 11845-* LEX: Implicit Variables. (line 70) 11846-* LFLAGS: Implicit Variables. (line 147) 11847-* libexecdir: Directory Variables. (line 66) 11848-* LINT: Implicit Variables. (line 78) 11849-* LINTFLAGS: Implicit Variables. (line 159) 11850-* M2C: Implicit Variables. (line 81) 11851-* MAKE <1>: Flavors. (line 84) 11852-* MAKE: MAKE Variable. (line 6) 11853-* MAKE_RESTARTS (number of times make has restarted): Special Variables. 11854- (line 49) 11855-* MAKE_VERSION: Features. (line 197) 11856-* MAKECMDGOALS: Goals. (line 30) 11857-* makefile: Makefile Names. (line 7) 11858-* Makefile: Makefile Names. (line 7) 11859-* MAKEFILE_LIST: MAKEFILE_LIST Variable. 11860- (line 6) 11861-* MAKEFILES <1>: Variables/Recursion. (line 127) 11862-* MAKEFILES: MAKEFILES Variable. (line 6) 11863-* MAKEFLAGS: Options/Recursion. (line 6) 11864-* MAKEINFO: Implicit Variables. (line 87) 11865-* MAKELEVEL <1>: Flavors. (line 84) 11866-* MAKELEVEL: Variables/Recursion. (line 115) 11867-* MAKEOVERRIDES: Options/Recursion. (line 49) 11868-* MAKESHELL (MS-DOS alternative to SHELL): Choosing the Shell. 11869- (line 25) 11870-* MFLAGS: Options/Recursion. (line 65) 11871-* notdir: File Name Functions. (line 27) 11872-* or: Conditional Functions. 11873- (line 37) 11874-* origin: Origin Function. (line 6) 11875-* OUTPUT_OPTION: Catalogue of Rules. (line 202) 11876-* override: Override Directive. (line 6) 11877-* patsubst <1>: Text Functions. (line 18) 11878-* patsubst: Substitution Refs. (line 28) 11879-* PC: Implicit Variables. (line 84) 11880-* PFLAGS: Implicit Variables. (line 153) 11881-* prefix: Directory Variables. (line 25) 11882-* realpath: File Name Functions. (line 114) 11883-* RFLAGS: Implicit Variables. (line 156) 11884-* RM: Implicit Variables. (line 110) 11885-* sbindir: Directory Variables. (line 59) 11886-* shell: Shell Function. (line 6) 11887-* SHELL: Choosing the Shell. (line 6) 11888-* SHELL (command execution): Execution. (line 6) 11889-* sort: Text Functions. (line 146) 11890-* strip: Text Functions. (line 80) 11891-* subst <1>: Text Functions. (line 9) 11892-* subst: Multiple Targets. (line 28) 11893-* suffix: File Name Functions. (line 43) 11894-* SUFFIXES: Suffix Rules. (line 81) 11895-* TANGLE: Implicit Variables. (line 104) 11896-* TEX: Implicit Variables. (line 91) 11897-* TEXI2DVI: Implicit Variables. (line 94) 11898-* unexport: Variables/Recursion. (line 45) 11899-* value: Value Function. (line 6) 11900-* vpath: Selective Search. (line 6) 11901-* VPATH: General Search. (line 6) 11902-* vpath: Directory Search. (line 6) 11903-* VPATH: Directory Search. (line 6) 11904-* warning: Make Control Functions. 11905- (line 35) 11906-* WEAVE: Implicit Variables. (line 98) 11907-* wildcard <1>: File Name Functions. (line 107) 11908-* wildcard: Wildcard Function. (line 6) 11909-* word: Text Functions. (line 159) 11910-* wordlist: Text Functions. (line 168) 11911-* words: Text Functions. (line 180) 11912-* YACC: Implicit Variables. (line 74) 11913-* YFLAGS: Implicit Variables. (line 150) 11914-* | (automatic variable): Automatic Variables. (line 69) 11915- 11916- 11917diff -rNU3 dist.orig/doc/make.texi dist/doc/make.texi 11918--- dist.orig/doc/make.texi 2006-04-01 08:36:40.000000000 +0200 11919+++ dist/doc/make.texi 2014-08-18 08:47:47.000000000 +0200 11920@@ -4,7 +4,7 @@ 11921 11922 @include version.texi 11923 @set EDITION 0.70 11924-@set RCSID $Id: make.texi,v 1.45 2006/04/01 06:36:40 psmith Exp $ 11925+@set RCSID $Id: make.texi,v 1.1.1.1 2014/08/18 06:47:47 christos Exp $ 11926 11927 @settitle GNU @code{make} 11928 @setchapternewpage odd 11929diff -rNU3 dist.orig/po/Makefile.in.in dist/po/Makefile.in.in 11930--- dist.orig/po/Makefile.in.in 2006-04-01 08:39:51.000000000 +0200 11931+++ dist/po/Makefile.in.in 2014-08-18 08:57:25.000000000 +0200 11932@@ -13,7 +13,7 @@ 11933 PACKAGE = @PACKAGE@ 11934 VERSION = @VERSION@ 11935 11936-SHELL = /bin/sh 11937+SHELL = @SHELL@ 11938 @SET_MAKE@ 11939 11940 srcdir = @srcdir@ 11941diff -rNU3 dist.orig/tests/scripts/functions/foreach dist/tests/scripts/functions/foreach 11942--- dist.orig/tests/scripts/functions/foreach 2006-03-10 03:20:46.000000000 +0100 11943+++ dist/tests/scripts/functions/foreach 2014-08-18 08:47:57.000000000 +0200 11944@@ -1,5 +1,5 @@ 11945 # -*-perl-*- 11946-# $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $ 11947+# $Id: foreach,v 1.1.1.1 2014/08/18 06:47:57 christos Exp $ 11948 11949 $description = "Test the foreach function."; 11950 11951diff -rNU3 dist.orig/tests/test_driver.pl dist/tests/test_driver.pl 11952--- dist.orig/tests/test_driver.pl 2006-03-10 03:20:45.000000000 +0100 11953+++ dist/tests/test_driver.pl 2014-08-18 08:47:57.000000000 +0200 11954@@ -28,7 +28,7 @@ 11955 # this routine controls the whole mess; each test suite sets up a few 11956 # variables and then calls &toplevel, which does all the real work. 11957 11958-# $Id: test_driver.pl,v 1.19 2006/03/10 02:20:45 psmith Exp $ 11959+# $Id: test_driver.pl,v 1.1.1.1 2014/08/18 06:47:57 christos Exp $ 11960 11961 11962 # The number of test categories we've run 11963diff -rNU3 dist.orig/w32/include/sub_proc.h dist/w32/include/sub_proc.h 11964--- dist.orig/w32/include/sub_proc.h 2006-02-11 23:16:05.000000000 +0100 11965+++ dist/w32/include/sub_proc.h 2014-08-18 08:47:56.000000000 +0200 11966@@ -21,11 +21,11 @@ 11967 /* 11968 * Component Name: 11969 * 11970- * $Date: 2006/02/11 22:16:05 $ 11971+ * $Date: 2014/08/18 06:47:56 $ 11972 * 11973- * $Source: /sources/make/make/w32/include/sub_proc.h,v $ 11974+ * $Source: /cvsroot/src/external/gpl2/gmake/dist/w32/include/sub_proc.h,v $ 11975 * 11976- * $Id: sub_proc.h,v 1.8 2006/02/11 22:16:05 psmith Exp $ 11977+ * $Id: sub_proc.h,v 1.1.1.1 2014/08/18 06:47:56 christos Exp $ 11978 */ 11979 11980 #define EXTERN_DECL(entry, args) extern entry args 11981