Changeset 2591 for trunk/src/kmk/doc/make.texi
- Timestamp:
- Jun 17, 2012, 10:45:31 PM (13 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
- Property svn:ignore
-
old new 13 13 stamp-* 14 14 makebook* 15 15 16 .*gdbinit 17 .gdb_history 18 16 19 *.dep 17 20 *.dvi … … 31 34 *.pg 32 35 *.pgs 36 33 37 README 34 38 README.DOS 35 39 README.W32 40 README.OS2 36 41 aclocal.m4 37 42 autom4te.cache … … 52 57 config.h.W32 53 58 config.h-vms 59 54 60 loadavg 55 61 loadavg.c 56 62 make 63 57 64 .deps 58 65 .dep_segment 66 ID 67 TAGS 68 59 69 _* 60 70 sun4 … … 72 82 sol2 73 83 i486-linux 84 74 85 customs 86 75 87 install-sh 76 88 mkinstalldirs 89 90 .directive.asc
-
- Property svn:ignore
-
trunk/src/kmk/doc
- Property svn:ignore
-
trunk/src/kmk/doc/make.texi
r1993 r2591 4 4 5 5 @include version.texi 6 @set EDITION 0.7 07 @set RCSID $Id: make.texi,v 1. 52 2008/05/18 15:11:40psmith Exp $6 @set EDITION 0.71 7 @set RCSID $Id: make.texi,v 1.66 2010/07/19 07:10:54 psmith Exp $ 8 8 9 9 @settitle GNU @code{make} … … 14 14 @syncodeindex pg cp 15 15 @c FSF publishers: format makebook.texi instead of using this file directly. 16 @c ISBN provided by Lisa M. Opus Goldstein <opus@gnu.org>, 5 May 200417 @set ISBN 1-882114-83- 516 @c ISBN confirmed by Jasimin Huang <jasimin@fsf.org> on 25 Mar 2009 17 @set ISBN 1-882114-83-3 18 18 @c %**end of header 19 19 … … 27 27 28 28 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 29 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 30 Free Software Foundation, Inc.29 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 30 2008, 2009, 2010 Free Software Foundation, Inc. 31 31 32 32 @quotation … … 39 39 License.'' 40 40 41 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify42 this GNU Manual. Buying copies from GNU Press supports the FSFin41 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and 42 modify this GNU manual. Buying copies from the FSF supports it in 43 43 developing GNU and promoting software freedom.'' 44 44 @end quotation … … 202 202 * Interrupts:: What happens when a recipe is interrupted. 203 203 * Recursion:: Invoking @code{make} from makefiles. 204 * Sequences::Defining canned recipes.204 * Canned Recipes:: Defining canned recipes. 205 205 * Empty Recipes:: Defining useful, do-nothing recipes. 206 206 … … 234 234 * Override Directive:: How to set a variable in the makefile even if 235 235 the user has set it with a command argument. 236 * Defining::An alternate way to set a variable237 to a verbatimstring.236 * Multi-Line:: An alternate way to set a variable 237 to a multi-line string. 238 238 * Environment:: Variable values can come from the environment. 239 239 * Target-specific:: Variable values can be defined on a per-target … … 241 241 * Pattern-specific:: Target-specific variable values can be applied 242 242 to a group of targets that match a pattern. 243 * Suppressing Inheritance:: Suppress inheritance of variables. 243 244 * Special Variables:: Variables with special meaning or behavior. 244 245 … … 524 525 525 526 @cindex tabs in rules 526 A @dfn{recipe} is an action that @code{make} carries out. 527 A recipe may have more than one command, each on its own line. 528 @strong{Please note:} you need to put a tab character at the beginning of 529 every command line! This is an obscurity that catches the unwary. If 530 you prefer to prefix your recipes with a character other than tab, 531 you can set the @code{.CMDPREFIX} variable to an alternate character 532 (@pxref{Special Variables}).527 A @dfn{recipe} is an action that @code{make} carries out. A recipe 528 may have more than one command, either on the same line or each on its 529 own line. @strong{Please note:} you need to put a tab character at 530 the beginning of every recipe line! This is an obscurity that catches 531 the unwary. If you prefer to prefix your recipes with a character 532 other than tab, you can set the @code{.RECIPEPREFIX} variable to an 533 alternate character (@pxref{Special Variables}). 533 534 534 535 Usually a recipe is in a rule with prerequisites and serves to create a … … 629 630 prerequisites. These recipes say how to update the target file. A 630 631 tab character (or whatever character is specified by the 631 @code{. CMDPREFIX} variable; @pxref{Special Variables}) must come at632 @code{.RECIPEPREFIX} variable; @pxref{Special Variables}) must come at 632 633 the beginning of every line in the recipe to distinguish recipes from 633 634 other lines in the makefile. (Bear in mind that @code{make} does not 634 635 know anything about how the recipes work. It is up to you to supply 635 636 recipes that will update the target file properly. All @code{make} 636 does is execute the commands in the recipe you have specified when the637 target fileneeds to be updated.)@refill637 does is execute the recipe you have specified when the target file 638 needs to be updated.)@refill 638 639 @cindex recipe 639 640 … … 996 997 @item 997 998 Defining a variable from a verbatim string containing multiple lines 998 (@pxref{ Defining, ,Defining Variables Verbatim}).999 (@pxref{Multi-Line, ,Defining Multi-Line Variables}). 999 1000 @end itemize 1000 1001 … … 1097 1098 Extra spaces are allowed and ignored at the beginning of the line, but 1098 1099 the first character must not be a tab (or the value of 1099 @code{. CMDPREFIX})---if the line begins with a tab, it will be1100 @code{.RECIPEPREFIX})---if the line begins with a tab, it will be 1100 1101 considered a recipe line. Whitespace is required between 1101 1102 @code{include} and the file names, and between file names; extra … … 1171 1172 1172 1173 If you want @code{make} to simply ignore a makefile which does not exist 1173 andcannot be remade, with no error message, use the @w{@code{-include}}1174 or cannot be remade, with no error message, use the @w{@code{-include}} 1174 1175 directive instead of @code{include}, like this: 1175 1176 … … 1179 1180 1180 1181 This acts like @code{include} in every way except that there is no 1181 error (not even a warning) if any of the @var{filenames} do not exist. 1182 error (not even a warning) if any of the @var{filenames} (or any 1183 prerequisites of any of the @var{filenames}) do not exist or cannot be 1184 remade. 1185 1182 1186 For compatibility with some other @code{make} implementations, 1183 1187 @code{sinclude} is another name for @w{@code{-include}}. … … 1191 1195 If the environment variable @code{MAKEFILES} is defined, @code{make} 1192 1196 considers its value as a list of names (separated by whitespace) of 1193 additional makefiles to be read before the others. This works much like 1194 the @code{include} directive: various directories are searched for those 1195 files (@pxref{Include, ,Including Other Makefiles}). In addition, the 1196 default goal is never taken from one of these makefiles and it is not an 1197 error if the files listed in @code{MAKEFILES} are not found.@refill 1197 additional makefiles to be read before the others. This works much 1198 like the @code{include} directive: various directories are searched 1199 for those files (@pxref{Include, ,Including Other Makefiles}). In 1200 addition, the default goal is never taken from one of these makefiles 1201 (or any makefile included by them) and it is not an error if the files 1202 listed in @code{MAKEFILES} are not found.@refill 1198 1203 1199 1204 @cindex recursion, and @code{MAKEFILES} variable … … 1269 1274 1270 1275 When you use the @samp{-t} or @samp{--touch} option 1271 (@pxref{Instead of Execution, ,Instead of Executing the Recipe}),1276 (@pxref{Instead of Execution, ,Instead of Executing Recipes}), 1272 1277 you would not want to use an out-of-date makefile to decide which 1273 1278 targets to touch. So the @samp{-t} option has no effect on updating … … 1387 1392 define @var{immediate} 1388 1393 @var{deferred} 1394 endef 1395 1396 define @var{immediate} = 1397 @var{deferred} 1398 endef 1399 1400 define @var{immediate} ?= 1401 @var{deferred} 1402 endef 1403 1404 define @var{immediate} := 1405 @var{immediate} 1406 endef 1407 1408 define @var{immediate} += 1409 @var{deferred} or @var{immediate} 1389 1410 endef 1390 1411 @end example … … 1748 1769 @cindex tab character (in commands) 1749 1770 The @var{recipe} lines start with a tab character (or the first 1750 character in the value of the @code{. CMDPREFIX} variable;1771 character in the value of the @code{.RECIPEPREFIX} variable; 1751 1772 @pxref{Special Variables}). The first recipe line may appear on the line 1752 1773 after the prerequisites, with a tab character, or may appear on the … … 1802 1823 GNU @code{make}: normal prerequisites such as described in the 1803 1824 previous section, and @dfn{order-only} prerequisites. A normal 1804 prerequisite makes two statements: first, it imposes an order of1805 execution of recipes: any recipes necessary to build any of a 1806 target's prerequisites will be fully executed before any recipe 1807 necessary to build the target. Second, it imposes a dependency 1808 relationship: if any prerequisite is newer than the target, then the1809 target is considered out-of-date and must berebuilt.1825 prerequisite makes two statements: first, it imposes an order in which 1826 recipes will be invoked: the recipes for all prerequisites of a target 1827 will be completed before the recipe for the target is run. Second, it 1828 imposes a dependency relationship: if any prerequisite is newer than 1829 the target, then the target is considered out-of-date and must be 1830 rebuilt. 1810 1831 1811 1832 Normally, this is exactly what you want: if a target's prerequisite is … … 1949 1970 @noindent 1950 1971 then the value of the variable @code{objects} is the actual string 1951 @samp{*.o}. However, if you use the value of @code{objects} in a target, 1952 prerequisite, or recipe, wildcard expansion will take place at that time. 1953 To set @code{objects} to the expansion, instead use: 1972 @samp{*.o}. However, if you use the value of @code{objects} in a 1973 target or prerequisite, wildcard expansion will take place there. If 1974 you use the value of @code{objects} in a recipe, the shell may perform 1975 wildcard expansion when the recipe runs. To set @code{objects} to the 1976 expansion, instead use: 1954 1977 1955 1978 @example … … 2403 2426 2404 2427 When a prerequisite's name has the form @samp{-l@var{name}}, @code{make} 2405 handles it specially by searching for the file @file{lib@var{name}.so} in 2406 the current directory, in directories specified by matching @code{vpath} 2428 handles it specially by searching for the file @file{lib@var{name}.so}, 2429 and, if it is not found, for the file @file{lib@var{name}.a} in the current 2430 directory, in directories specified by matching @code{vpath} 2407 2431 search paths and the @code{VPATH} search path, and then in the 2408 2432 directories @file{/lib}, @file{/usr/lib}, and @file{@var{prefix}/lib} … … 2410 2434 @code{make} behave as if @var{prefix} is defined to be the root of the 2411 2435 DJGPP installation tree). 2412 2413 If that file is not found, then the file @file{lib@var{name}.a} is2414 searched for, in the same directories as above.2415 2436 2416 2437 For example, if there is a @file{/usr/lib/libcurses.a} library on your … … 2435 2456 @samp{-l@var{name}} is seen, @code{make} will replace the percent in 2436 2457 each pattern in the list with @var{name} and perform the above directory 2437 searches using that library filename. If no library is found, the next 2438 word in the list will be used. 2458 searches using each library filename. 2439 2459 2440 2460 The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a}, … … 2854 2874 recipes in parallel (unless its makefile also contains this target). 2855 2875 Any prerequisites on this target are ignored. 2876 2877 @findex .ONESHELL 2878 @item .ONESHELL 2879 @cindex recipe execution, single invocation 2880 2881 If @code{.ONESHELL} is mentioned as a target, then when a target is 2882 built all lines of the recipe will be given to a single invocation of 2883 the shell rather than each line being invoked separately 2884 (@pxref{Execution, ,Recipe Execution}). 2885 2886 @findex .POSIX 2887 @item .POSIX 2888 @cindex POSIX-conforming mode, setting 2889 2890 If @code{.POSIX} is mentioned as a target, then the makefile will be 2891 parsed and run in POSIX-conforming mode. This does @emph{not} mean 2892 that only POSIX-conforming makefiles will be accepted: all advanced 2893 GNU @code{make} features are still available. Rather, this target 2894 causes @code{make} to behave as required by POSIX in those areas 2895 where @code{make}'s default behavior differs. 2896 2897 In particular, if this target is mentioned then recipes will be 2898 invoked as if the shell had been passed the @code{-e} flag: the first 2899 failing command in a recipe will cause the recipe to fail immediately. 2856 2900 @end table 2857 2901 … … 3168 3212 @cindex @code{::} rules (double-colon) 3169 3213 3170 @dfn{Double-colon} rules are rules written with @samp{::} instead of 3171 @samp{:} after the target names. They are handled differently from 3172 ordinary rules when the same target appears in more than one rule. 3214 @dfn{Double-colon} rules are explicit rules written with @samp{::} 3215 instead of @samp{:} after the target names. They are handled 3216 differently from ordinary rules when the same target appears in more 3217 than one rule. Pattern rules with double-colons have an entirely 3218 different meaning (@pxref{Match-Anything Rules}). 3173 3219 3174 3220 When a target appears in multiple rules, all the rules must be the same … … 3351 3397 Users use many different shell programs, but recipes in makefiles are 3352 3398 always interpreted by @file{/bin/sh} unless the makefile specifies 3353 otherwise. @xref{Execution, , CommandExecution}.3399 otherwise. @xref{Execution, ,Recipe Execution}. 3354 3400 3355 3401 @menu … … 3361 3407 * Interrupts:: What happens when a recipe is interrupted. 3362 3408 * Recursion:: Invoking @code{make} from makefiles. 3363 * Sequences::Defining canned recipes.3409 * Canned Recipes:: Defining canned recipes. 3364 3410 * Empty Recipes:: Defining useful, do-nothing recipes. 3365 3411 @end menu … … 3379 3425 3380 3426 Each line in the recipe must start with a tab (or the first character 3381 in the value of the @code{. CMDPREFIX} variable; @pxref{Special3427 in the value of the @code{.RECIPEPREFIX} variable; @pxref{Special 3382 3428 Variables}), except that the first recipe line may be attached to the 3383 3429 target-and-prerequisites line with a semicolon in between. @emph{Any} … … 3629 3675 @cindex @code{--dry-run} 3630 3676 @cindex @code{--recon} 3631 When @code{make} is given the flag @samp{-n} or @samp{--just-print} 3632 it only echoes recipes, it won't execute them. @xref{Options Summary, 3633 ,Summary of Options}. In this case and only this case, even the 3634 recipe lines starting with @samp{@@} are printed. This flag is useful for 3635 finding out which recipes @code{make} thinks are necessary without 3636 actuallydoing them.3677 When @code{make} is given the flag @samp{-n} or @samp{--just-print} it 3678 only echoes most recipes, without executing them. @xref{Options 3679 Summary, ,Summary of Options}. In this case even the recipe lines 3680 starting with @samp{@@} are printed. This flag is useful for finding 3681 out which recipes @code{make} thinks are necessary without actually 3682 doing them. 3637 3683 3638 3684 @cindex @code{-s} … … 3654 3700 3655 3701 When it is time to execute recipes to update a target, they are 3656 executed by invoking a new subshell for each line of the recipe. (In 3657 practice, @code{make} may take shortcuts that do not affect the 3658 results.) 3702 executed by invoking a new subshell for each line of the recipe, 3703 unless the @code{.ONESHELL} special target is in effect 3704 (@pxref{One Shell, ,Using One Shell}) (In practice, @code{make} may 3705 take shortcuts that do not affect the results.) 3659 3706 3660 3707 @cindex @code{cd} (shell command) … … 3684 3731 3685 3732 @menu 3733 * One Shell:: One shell for all lines in a recipe 3686 3734 * Choosing the Shell:: How @code{make} chooses the shell used 3687 3735 to run recipes. 3688 3736 @end menu 3689 3737 3690 @node Choosing the Shell, , Execution, Execution 3738 @node One Shell, Choosing the Shell, Execution, Execution 3739 @subsection Using One Shell 3740 @cindex recipe lines, single shell 3741 @cindex @code{.ONESHELL}, use of 3742 @findex .ONESHELL 3743 3744 Sometimes you would prefer that all the lines in the recipe be passed 3745 to a single invocation of the shell. There are generally two 3746 situations where this is useful: first, it can improve performance in 3747 makefiles where recipes consist of many command lines, by avoiding 3748 extra processes. Second, you might want newlines to be included in 3749 your recipe command (for example perhaps you are using a very 3750 different interpreter as your @code{SHELL}). If the @code{.ONESHELL} 3751 special target appears anywhere in the makefile then @emph{all} 3752 recipe lines for each target will be provided to a single invocation 3753 of the shell. Newlines between recipe lines will be preserved. For 3754 example: 3755 3756 @example 3757 .ONESHELL: 3758 foo : bar/lose 3759 cd $(@@D) 3760 gobble $(@@F) > ../$@@ 3761 @end example 3762 3763 @noindent 3764 would now work as expected even though the commands are on different 3765 recipe lines. 3766 3767 If @code{.ONESHELL} is provided, then only the first line of the 3768 recipe will be checked for the special prefix characters (@samp{@@}, 3769 @samp{-}, and @samp{+}). Subsequent lines will include the special 3770 characters in the recipe line when the @code{SHELL} is invoked. If 3771 you want your recipe to start with one of these special characters 3772 you'll need to arrange for them to not be the first characters on the 3773 first line, perhaps by adding a comment or similar. For example, this 3774 would be a syntax error in Perl because the first @samp{@@} is removed 3775 by make: 3776 3777 @example 3778 .ONESHELL: 3779 SHELL = /usr/bin/perl 3780 .SHELLFLAGS = -e 3781 show : 3782 @@f = qw(a b c); 3783 print "@@f\n"; 3784 @end example 3785 3786 @noindent 3787 However, either of these alternatives would work properly: 3788 3789 @example 3790 .ONESHELL: 3791 SHELL = /usr/bin/perl 3792 .SHELLFLAGS = -e 3793 show : 3794 # Make sure "@@" is not the first character on the first line 3795 @@f = qw(a b c); 3796 print "@@f\n"; 3797 @end example 3798 3799 @noindent 3800 or 3801 3802 @example 3803 .ONESHELL: 3804 SHELL = /usr/bin/perl 3805 .SHELLFLAGS = -e 3806 show : 3807 my @@f = qw(a b c); 3808 print "@@f\n"; 3809 @end example 3810 3811 As a special feature, if @code{SHELL} is determined to be a 3812 POSIX-style shell, the special prefix characters in ``internal'' 3813 recipe lines will @emph{removed} before the recipe is processed. This 3814 feature is intended to allow existing makefiles to add the 3815 @code{.ONESHELL} special target and still run properly without 3816 extensive modifications. Since the special prefix characters are not 3817 legal at the beginning of a line in a POSIX shell script this is not a 3818 loss in functionality. For example, this works as expected: 3819 3820 @example 3821 .ONESHELL: 3822 foo : bar/lose 3823 @@cd $(@@D) 3824 @@gobble $(@@F) > ../$@@ 3825 @end example 3826 3827 Even with this special feature, however, makefiles with 3828 @code{.ONESHELL} will behave differently in ways that could be 3829 noticeable. For example, normally if any line in the recipe fails, 3830 that causes the rule to fail and no more recipe lines are processed. 3831 Under @code{.ONESHELL} a failure of any but the final recipe line will 3832 not be noticed by @code{make}. You can modify @code{.SHELLFLAGS} to 3833 add the @code{-e} option to the shell which will cause any failure 3834 anywhere in the command line to cause the shell to fail, but this 3835 could itself cause your recipe to behave differently. Ultimately you 3836 may need to harden your recipe lines to allow them to work with 3837 @code{.ONESHELL}. 3838 3839 @node Choosing the Shell, , One Shell, Execution 3691 3840 @subsection Choosing the Shell 3692 3841 @cindex shell, choosing the 3693 3842 @cindex @code{SHELL}, value of 3843 @cindex @code{.SHELLFLAGS}, value of 3694 3844 3695 3845 @vindex SHELL 3846 @vindex .SHELLFLAGS 3696 3847 The program used as the shell is taken from the variable @code{SHELL}. 3697 3848 If this variable is not set in your makefile, the program 3698 @file{/bin/sh} is used as the shell. 3849 @file{/bin/sh} is used as the shell. The argument(s) passed to the 3850 shell are taken from the variable @code{.SHELLFLAGS}. The default 3851 value of @code{.SHELLFLAGS} is @code{-c} normally, or @code{-ec} in 3852 POSIX-conforming mode. 3699 3853 3700 3854 @cindex environment, @code{SHELL} in … … 3786 3940 on MS-DOS unaltered if you have e.g.@: @file{sh.exe} installed in some 3787 3941 directory along your @code{PATH}. 3942 3943 @vindex SHELL 3944 @vindex .SHELLFLAGS 3788 3945 3789 3946 @node Parallel, Errors, Execution, Recipes … … 4014 4171 times to prevent other sorts of trouble. 4015 4172 4016 @node Recursion, Sequences, Interrupts, Recipes4173 @node Recursion, Canned Recipes, Interrupts, Recipes 4017 4174 @section Recursive Use of @code{make} 4018 4175 @cindex recursion … … 4360 4517 ensure that there are only @samp{N} jobs running at the same time 4361 4518 between them all. Note that any job that is marked recursive 4362 (@pxref{Instead of Execution, ,Instead of Executing theRecipes})4519 (@pxref{Instead of Execution, ,Instead of Executing Recipes}) 4363 4520 doesn't count against the total jobs (otherwise we could get @samp{N} 4364 4521 sub-@code{make}s running and have no slots left over for any real work!) … … 4496 4653 disable it. 4497 4654 4498 @node Sequences, Empty Recipes, Recursion, Recipes4655 @node Canned Recipes, Empty Recipes, Recursion, Recipes 4499 4656 @section Defining Canned Recipes 4500 4657 @cindex canned recipes … … 4509 4666 not conflict with other variable names. 4510 4667 4511 Here is an example of defining a canned recipe s:4512 4513 @example 4514 define run-yacc 4668 Here is an example of defining a canned recipe: 4669 4670 @example 4671 define run-yacc = 4515 4672 yacc $(firstword $^) 4516 4673 mv y.tab.c $@@ … … 4526 4683 parentheses, variable names, and so on, all become part of the value of the 4527 4684 variable you are defining. 4528 @xref{ Defining, ,Defining Variables Verbatim},4685 @xref{Multi-Line, ,Defining Multi-Line Variables}, 4529 4686 for a complete explanation of @code{define}. 4530 4687 … … 4567 4724 4568 4725 @example 4569 define frobnicate 4726 define frobnicate = 4570 4727 @@echo "frobnicating target $@@" 4571 4728 frob-step-1 $< -o $@@-step-1 … … 4590 4747 (@xref{Echoing, ,Recipe Echoing}, for a full explanation of @samp{@@}.) 4591 4748 4592 @node Empty Recipes, , Sequences, Recipes4749 @node Empty Recipes, , Canned Recipes, Recipes 4593 4750 @section Using Empty Recipes 4594 4751 @cindex empty recipes … … 4685 4842 * Override Directive:: How to set a variable in the makefile even if 4686 4843 the user has set it with a command argument. 4687 * Defining:: An alternate way to set a variable 4688 to a verbatim string. 4844 * Multi-Line:: An alternate way to set a variable 4845 to a multi-line string. 4846 * Undefine Directive:: How to undefine a variable so that it appears 4847 as if it was never set. 4689 4848 * Environment:: Variable values can come from the environment. 4690 4849 * Target-specific:: Variable values can be defined on a per-target … … 4692 4851 * Pattern-specific:: Target-specific variable values can be applied 4693 4852 to a group of targets that match a pattern. 4853 * Suppressing Inheritance:: Suppress inheritance of variables. 4694 4854 * Special Variables:: Variables with special meaning or behavior. 4695 4855 @end menu … … 4761 4921 Variables of this sort are defined by lines using @samp{=} 4762 4922 (@pxref{Setting, ,Setting Variables}) or by the @code{define} directive 4763 (@pxref{ Defining, ,Defining Variables Verbatim}). The value you specify4923 (@pxref{Multi-Line, ,Defining Multi-Line Variables}). The value you specify 4764 4924 is installed verbatim; if it contains references to other variables, 4765 4925 these references are expanded whenever this variable is substituted (in … … 5188 5348 dir = foo 5189 5349 $(dir)_sources := $(wildcard $(dir)/*.c) 5190 define $(dir)_print 5350 define $(dir)_print = 5191 5351 lpr $($(dir)_sources) 5192 5352 endef … … 5217 5377 You can specify a value in the makefile, either 5218 5378 with an assignment (@pxref{Setting, ,Setting Variables}) or with a 5219 verbatim definition (@pxref{ Defining, ,Defining Variables Verbatim}).@refill5379 verbatim definition (@pxref{Multi-Line, ,Defining Multi-Line Variables}).@refill 5220 5380 5221 5381 @item … … 5425 5585 value. 5426 5586 5427 @node Override Directive, Defining, Appending, Using Variables5587 @node Override Directive, Multi-Line, Appending, Using Variables 5428 5588 @section The @code{override} Directive 5429 5589 @findex override … … 5458 5618 @xref{Appending, ,Appending More Text to Variables}. 5459 5619 5620 Variable assignments marked with the @code{override} flag have a 5621 higher priority than all other assignments, except another 5622 @code{override}. Subsequent assignments or appends to this variable 5623 which are not marked @code{override} will be ignored. 5624 5460 5625 The @code{override} directive was not invented for escalation in the war 5461 5626 between makefiles and command arguments. It was invented so you can alter … … 5475 5640 5476 5641 @example 5477 override define foo 5642 override define foo = 5478 5643 bar 5479 5644 endef … … 5485 5650 @end iftex 5486 5651 @ifnottex 5487 @xref{ Defining, ,Defining Variables Verbatim}.5652 @xref{Multi-Line, ,Defining Multi-Line Variables}. 5488 5653 @end ifnottex 5489 5654 5490 @node Defining, Environment, Override Directive, Using Variables5491 @section Defining Variables Verbatim5655 @node Multi-Line, Undefine Directive, Override Directive, Using Variables 5656 @section Defining Multi-Line Variables 5492 5657 @findex define 5493 5658 @findex endef 5659 @cindex multi-line variable definition 5660 @cindex variables, multi-line 5494 5661 @cindex verbatim variable definition 5495 5662 @cindex defining variables verbatim … … 5498 5665 Another way to set the value of a variable is to use the @code{define} 5499 5666 directive. This directive has an unusual syntax which allows newline 5500 characters to be included in the value, which is convenient for defining5501 both canned sequences of commands 5502 (@pxref{Sequences, ,Defining Canned Command Sequences}), and also5503 sections of makefile syntax to use with @code{eval} (@pxref{Eval Function}). 5504 5505 The @code{define} directive is followed on the same line by the name of the5506 variable and nothing more. The value to give the variable appears on the 5507 following lines. The end of the value is marked by a line containing just 5508 the word @code{endef}. Aside from this difference in syntax, @code{define} 5509 works just like @samp{=}: it creates a recursively-expanded variable 5510 (@pxref{Flavors, ,The Two Flavors of Variables}). 5511 The variable name may contain function and variable references, which 5512 areexpanded when the directive is read to find the actual variable name5667 characters to be included in the value, which is convenient for 5668 defining both canned sequences of commands (@pxref{Canned Recipes, 5669 ,Defining Canned Recipes}), and also sections of makefile syntax to 5670 use with @code{eval} (@pxref{Eval Function}).@refill 5671 5672 The @code{define} directive is followed on the same line by the name 5673 of the variable being defined and an (optional) assignment operator, 5674 and nothing more. The value to give the variable appears on the 5675 following lines. The end of the value is marked by a line containing 5676 just the word @code{endef}. Aside from this difference in syntax, 5677 @code{define} works just like any other variable definition. The 5678 variable name may contain function and variable references, which are 5679 expanded when the directive is read to find the actual variable name 5513 5680 to use. 5681 5682 You may omit the variable assignment operator if you prefer. If 5683 omitted, @code{make} assumes it to be @samp{=} and creates a 5684 recursively-expanded variable (@pxref{Flavors, ,The Two Flavors of Variables}). 5685 When using a @samp{+=} operator, the value is appended to the previous 5686 value as with any other append operation: with a single space 5687 separating the old and new values. 5514 5688 5515 5689 You may nest @code{define} directives: @code{make} will keep track of … … 5518 5692 prefix character are considered part of a recipe, so any @code{define} 5519 5693 or @code{endef} strings appearing on such a line will not be 5520 considered @code{make} operators.5521 5522 @example 5523 define two-lines 5694 considered @code{make} directives. 5695 5696 @example 5697 define two-lines = 5524 5698 echo foo 5525 5699 echo $(bar) … … 5551 5725 5552 5726 @example 5553 override define two-lines 5727 override define two-lines = 5554 5728 foo 5555 5729 $(bar) … … 5560 5734 @xref{Override Directive, ,The @code{override} Directive}. 5561 5735 5562 @node Environment, Target-specific, Defining, Using Variables 5736 @node Undefine Directive, Environment, Multi-Line, Using Variables 5737 @section Undefining Variables 5738 @findex undefine 5739 @cindex undefining variable 5740 5741 If you want to clear a variable, setting its value to empty is usually 5742 sufficient. Expanding such a variable will yield the same result (empty 5743 string) regardless of whether it was set or not. However, if you are 5744 using the @code{flavor} (@pxref{Flavor Function}) and 5745 @code{origin} (@pxref{Origin Function}) functions, there is a difference 5746 between a variable that was never set and a variable with an empty value. 5747 In such situations you may want to use the @code{undefine} directive to 5748 make a variable appear as if it was never set. For example: 5749 5750 @example 5751 foo := foo 5752 bar = bar 5753 5754 undefine foo 5755 undefine bar 5756 5757 $(info $(origin foo)) 5758 $(info $(flavor bar)) 5759 @end example 5760 5761 This example will print ``undefined'' for both variables. 5762 5763 If you want to undefine a command-line variable definition, you can use 5764 the @code{override} directive together with @code{undefine}, similar to 5765 how this is done for variable definitions: 5766 5767 @example 5768 override undefine CFLAGS 5769 @end example 5770 5771 @node Environment, Target-specific, Undefine Directive, Using Variables 5563 5772 @section Variables from the Environment 5564 5773 … … 5626 5835 @end example 5627 5836 5628 @noindent 5629 or like this: 5630 5631 @example 5632 @var{target} @dots{} : override @var{variable-assignment} 5633 @end example 5634 5635 @noindent 5636 or like this: 5637 5638 @example 5639 @var{target} @dots{} : export @var{variable-assignment} 5640 @end example 5837 Target-specific variable assignments can be prefixed with any or all of the 5838 special keywords @code{export}, @code{override}, or @code{private}; 5839 these apply their normal behavior to this instance of the variable only. 5641 5840 5642 5841 Multiple @var{target} values create a target-specific variable value for … … 5684 5883 ignore the target-specific values from any other targets. 5685 5884 5686 @node Pattern-specific, S pecial Variables, Target-specific, Using Variables5885 @node Pattern-specific, Suppressing Inheritance, Target-specific, Using Variables 5687 5886 @section Pattern-specific Variable Values 5688 5887 @cindex pattern-specific variables … … 5693 5892 @code{make} supports pattern-specific variable values. In this form, 5694 5893 the variable is defined for any target that matches the pattern 5695 specified. If a target matches more than one pattern, all the 5696 matching pattern-specific variables are interpreted in the order in 5697 which they were defined in the makefile, and collected together into 5698 one set. Variables defined in this way are searched after any 5699 target-specific variables defined explicitly for that target, and 5700 before target-specific variables defined for the parent target. 5894 specified. 5701 5895 5702 5896 Set a pattern-specific variable value like this: … … 5705 5899 @var{pattern} @dots{} : @var{variable-assignment} 5706 5900 @end example 5707 5708 @noindent5709 or like this:5710 5711 @example5712 @var{pattern} @dots{} : override @var{variable-assignment}5713 @end example5714 5715 @noindent5716 5901 where @var{pattern} is a %-pattern. As with target-specific variable 5717 5902 values, multiple @var{pattern} values create a pattern-specific variable … … 5730 5915 matching the pattern @code{%.o}. 5731 5916 5732 @node Special Variables, , Pattern-specific, Using Variables 5917 If a target matches more than one pattern, the matching pattern-specific 5918 variables with longer stems are interpreted first. This results in more 5919 specific variables taking precedence over the more generic ones, for 5920 example: 5921 5922 @example 5923 %.o: %.c 5924 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 5925 5926 lib/%.o: CFLAGS := -fPIC -g 5927 %.o: CFLAGS := -g 5928 5929 all: foo.o lib/bar.o 5930 @end example 5931 5932 In this example the first definition of the @code{CFLAGS} variable 5933 will be used to update @file{lib/bar.o} even though the second one 5934 also applies to this target. Pattern-specific variables which result 5935 in the same stem length are considered in the order in which they 5936 were defined in the makefile. 5937 5938 Pattern-specific variables are searched after any target-specific 5939 variables defined explicitly for that target, and before target-specific 5940 variables defined for the parent target. 5941 5942 @node Suppressing Inheritance, Special Variables, Pattern-specific, Using Variables 5943 @section Suppressing Inheritance 5944 @findex private 5945 @cindex suppressing inheritance 5946 @cindex inheritance, suppressing 5947 5948 As described in previous sections, @code{make} variables are inherited 5949 by prerequisites. This capability allows you to modify the behavior 5950 of a prerequisite based on which targets caused it to be rebuilt. For 5951 example, you might set a target-specific variable on a @code{debug} 5952 target, then running @samp{make debug} will cause that variable to be 5953 inherited by all prerequisites of @code{debug}, while just running 5954 @samp{make all} (for example) would not have that assignment. 5955 5956 Sometimes, however, you may not want a variable to be inherited. For 5957 these situations, @code{make} provides the @code{private} modifier. 5958 Although this modifier can be used with any variable assignment, it 5959 makes the most sense with target- and pattern-specific variables. Any 5960 variable marked @code{private} will be visible to its local target but 5961 will not be inherited by prerequisites of that target. A global 5962 variable marked @code{private} will be visible in the global scope but 5963 will not be inherited by any target, and hence will not be visible 5964 in any recipe. 5965 5966 As an example, consider this makefile: 5967 @example 5968 EXTRA_CFLAGS = 5969 5970 prog: private EXTRA_CFLAGS = -L/usr/local/lib 5971 prog: a.o b.o 5972 @end example 5973 5974 Due to the @code{private} modifier, @code{a.o} and @code{b.o} will not 5975 inherit the @code{EXTRA_CFLAGS} variable assignment from the 5976 @code{progs} target. 5977 5978 @node Special Variables, , Suppressing Inheritance, Using Variables 5733 5979 @comment node-name, next, previous, up 5734 5980 @section Other Special Variables … … 5834 6080 variable). You should not set, modify, or export this variable. 5835 6081 5836 @vindex . CMDPREFIX @r{(change the recipe prefix character)}5837 @item . CMDPREFIX6082 @vindex .RECIPEPREFIX @r{(change the recipe prefix character)} 6083 @item .RECIPEPREFIX 5838 6084 The first character of the value of this variable is used as the 5839 6085 character make assumes is introducing a recipe line. If the variable … … 5843 6089 @example 5844 6090 @group 5845 . CMDPREFIX = >6091 .RECIPEPREFIX = > 5846 6092 all: 5847 6093 > @@echo Hello, world … … 5849 6095 @end example 5850 6096 5851 The value of @code{. CMDPREFIX} can be changed multiple times; once set6097 The value of @code{.RECIPEPREFIX} can be changed multiple times; once set 5852 6098 it stays in effect for all rules parsed until it is modified. 5853 6099 … … 7175 7421 all: $(PROGRAMS) 7176 7422 7177 define PROGRAM_template 7423 define PROGRAM_template = 7178 7424 $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) 7179 7425 ALL_OBJS += $$($(1)_OBJS) … … 7228 7474 @item environment 7229 7475 7230 if @var{variable} was defined as an environment variable and the7231 @ samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}).7476 if @var{variable} was inherited from the environment provided to 7477 @code{make}. 7232 7478 7233 7479 @item environment override 7234 7480 7235 if @var{variable} was defined as an environment variable and the 7236 @w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary, 7237 ,Summary of Options}).@refill 7481 if @var{variable} was inherited from the environment provided to 7482 @code{make}, and is overriding a setting for @var{variable} in the 7483 makefile as a result of the @w{@samp{-e}} option (@pxref{Options 7484 Summary, ,Summary of Options}).@refill 7238 7485 7239 7486 @item file … … 7476 7723 The exit status is one if you use the @samp{-q} flag and @code{make} 7477 7724 determines that some target is not already up to date. 7478 @xref{Instead of Execution, ,Instead of Executing theRecipes}.7725 @xref{Instead of Execution, ,Instead of Executing Recipes}. 7479 7726 @end table 7480 7727 … … 7653 7900 7654 7901 @node Instead of Execution, Avoiding Compilation, Goals, Running 7655 @section Instead of Executing theRecipes7902 @section Instead of Executing Recipes 7656 7903 @cindex execution, instead of 7657 7904 @cindex recipes, instead of executing … … 7673 7920 7674 7921 ``No-op''. The activity is to print what recipe would be used to make 7675 the targets up to date, but not actually execute it. 7922 the targets up to date, but not actually execute it. Some recipes are 7923 still executed, even with this flag (@pxref{MAKE Variable, ,How the @code{MAKE} Variable Works}). 7676 7924 7677 7925 @item -t … … 7715 7963 7716 7964 With the @samp{-n} flag, @code{make} prints the recipe that it would 7717 normally execute but does not execute it.7965 normally execute but usually does not execute it. 7718 7966 7719 7967 With the @samp{-t} flag, @code{make} ignores the recipes in the rules … … 7741 7989 not run unless they too begin with @samp{+} or contain @samp{$(MAKE)} or 7742 7990 @samp{$@{MAKE@}} (@xref{MAKE Variable, ,How the @code{MAKE} Variable Works}.) 7991 7992 @cindex phony targets and recipe execution 7993 The @samp{-t} flag prevents phony targets (@pxref{Phony Targets}) from 7994 being updated, unless there are recipe lines beginning with @samp{+} 7995 or containing @samp{$(MAKE)} or @samp{$@{MAKE@}}. 7743 7996 7744 7997 The @samp{-W} flag provides two features: … … 8007 8260 @xref{Environment, ,Variables from the Environment}. 8008 8261 8262 @item --eval=@var{string} 8263 @cindex @code{--eval} 8264 @c Extra blank line here makes the table look better. 8265 8266 Evaluate @var{string} as makefile syntax. This is a command-line 8267 version of the @code{eval} function (@pxref{Eval Function}). The 8268 evaluation is performed after the default rules and variables have 8269 been defined, but before any makefiles are read. 8270 8009 8271 @item -f @var{file} 8010 8272 @cindex @code{-f} … … 8090 8352 @c Extra blank line here makes the table look better. 8091 8353 8092 Print the recipe that would be executed, but do not execute it. 8093 @xref{Instead of Execution, ,Instead of Executing the Recipes}. 8354 Print the recipe that would be executed, but do not execute it (except 8355 in certain circumstances). 8356 @xref{Instead of Execution, ,Instead of Executing Recipes}. 8094 8357 8095 8358 @item -o @var{file} … … 8128 8391 return an exit status that is zero if the specified targets are already 8129 8392 up to date, one if any remaking is required, or two if an error is 8130 encountered. @xref{Instead of Execution, ,Instead of Executing the8393 encountered. @xref{Instead of Execution, ,Instead of Executing 8131 8394 Recipes}.@refill 8132 8395 … … 8190 8453 instead of running their recipes. This is used to pretend that the 8191 8454 recipes were done, in order to fool future invocations of 8192 @code{make}. @xref{Instead of Execution, ,Instead of Executing theRecipes}.8455 @code{make}. @xref{Instead of Execution, ,Instead of Executing Recipes}. 8193 8456 8194 8457 @item -v … … 8231 8494 @code{make}, except that the modification time is changed only in the 8232 8495 imagination of @code{make}. 8233 @xref{Instead of Execution, ,Instead of Executing theRecipes}.8496 @xref{Instead of Execution, ,Instead of Executing Recipes}. 8234 8497 8235 8498 @item --warn-undefined-variables … … 8421 8684 @pindex .c 8422 8685 @file{@var{n}.o} is made automatically from @file{@var{n}.c} with 8423 a recipe of the form @samp{$(CC) -c $(CPPFLAGS) $(CFLAGS)}.@refill8686 a recipe of the form @samp{$(CC) $(CPPFLAGS) $(CFLAGS) -c}.@refill 8424 8687 8425 8688 @item Compiling C++ programs … … 8431 8694 @file{@var{n}.o} is made automatically from @file{@var{n}.cc}, 8432 8695 @file{@var{n}.cpp}, or @file{@var{n}.C} with a recipe of the form 8433 @samp{$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)}. We encourage you to use the8696 @samp{$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c}. We encourage you to use the 8434 8697 suffix @samp{.cc} for C++ source files instead of @samp{.C}.@refill 8435 8698 … … 8439 8702 @pindex .p 8440 8703 @file{@var{n}.o} is made automatically from @file{@var{n}.p} 8441 with the recipe @samp{$(PC) -c $(PFLAGS)}.@refill8704 with the recipe @samp{$(PC) $(PFLAGS) -c}.@refill 8442 8705 8443 8706 @item Compiling Fortran and Ratfor programs … … 8454 8717 @table @samp 8455 8718 @item .f 8456 @samp{$(FC) -c $(FFLAGS)}.8719 @samp{$(FC) $(FFLAGS) -c}. 8457 8720 @item .F 8458 @samp{$(FC) -c $(FFLAGS) $(CPPFLAGS)}.8721 @samp{$(FC) $(FFLAGS) $(CPPFLAGS) -c}. 8459 8722 @item .r 8460 @samp{$(FC) -c $(FFLAGS) $(RFLAGS)}.8723 @samp{$(FC) $(FFLAGS) $(RFLAGS) -c}. 8461 8724 @end table 8462 8725 … … 8469 8732 @table @samp 8470 8733 @item .F 8471 @samp{$(FC) -F $(CPPFLAGS) $(FFLAGS)}.8734 @samp{$(FC) $(CPPFLAGS) $(FFLAGS) -F}. 8472 8735 @item .r 8473 @samp{$(FC) -F $(FFLAGS) $(RFLAGS)}.8736 @samp{$(FC) $(FFLAGS) $(RFLAGS) -F}. 8474 8737 @end table 8475 8738 … … 9066 9329 pattern. @xref{Last Resort}. 9067 9330 9331 More than one pattern rule may match a target. In this case 9332 @code{make} will choose the ``best fit'' rule. @xref{Pattern Match, 9333 ,How Patterns Match}. 9334 9068 9335 @c !!! The end of of this paragraph should be rewritten. --bob 9069 9336 Pattern rules may have more than one target. Unlike normal rules, … … 9081 9348 @cindex target, multiple in pattern rule 9082 9349 9083 The order in which pattern rules appear in the makefile is important9084 since this is the order in which they are considered.9085 Of equally applicable9086 rules, only the first one found is used. The rules you write take precedence9087 over those that are built in. Note however, that a rule whose9088 prerequisites actually exist or are mentioned always takes priority over a9089 rule with prerequisites that must be made by chaining other implicit rules.9090 @cindex pattern rules, order of9091 @cindex order of pattern rules9092 9093 9350 @node Pattern Examples, Automatic Variables, Pattern Intro, Pattern Rules 9094 9351 @subsection Pattern Rule Examples … … 9403 9660 @file{src/car}.@refill 9404 9661 9662 @cindex pattern rules, order of 9663 @cindex order of pattern rules 9664 A pattern rule can be used to build a given file only if there is a 9665 target pattern that matches the file name, @emph{and} all 9666 prerequisites in that rule either exist or can be built. The rules 9667 you write take precedence over those that are built in. Note however, 9668 that a rule whose prerequisites actually exist or are mentioned always 9669 takes priority over a rule with prerequisites that must be made by 9670 chaining other implicit rules. 9671 9672 @cindex stem, shortest 9673 It is possible that more than one pattern rule will meet these 9674 criteria. In that case, @code{make} will choose the rule with the 9675 shortest stem (that is, the pattern that matches most specifically). 9676 If more than one pattern rule has the shortest stem, @code{make} will 9677 choose the first one found in the makefile. 9678 9679 This algorithm results in more specific rules being preferred over 9680 more generic ones; for example: 9681 9682 @example 9683 %.o: %.c 9684 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 9685 9686 %.o : %.f 9687 $(COMPILE.F) $(OUTPUT_OPTION) $< 9688 9689 lib/%.o: lib/%.c 9690 $(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 9691 @end example 9692 9693 Given these rules and asked to build @file{bar.o} where both 9694 @file{bar.c} and @file{bar.f} exist, @code{make} will choose the first 9695 rule and compile @file{bar.c} into @file{bar.o}. In the same 9696 situation where @file{bar.c} does not exist, then @code{make} will 9697 choose the second rule and compile @file{bar.f} into @file{bar.o}. 9698 9699 If @code{make} is asked to build @file{lib/bar.o} and both 9700 @file{lib/bar.c} and @file{lib/bar.f} exist, then the third rule will 9701 be chosen since the stem for this rule (@samp{bar}) is shorter than 9702 the stem for the first rule (@samp{lib/bar}). If @file{lib/bar.c} 9703 does not exist then the third rule is not eligible and the second rule 9704 will be used, even though the stem is longer. 9705 9405 9706 @node Match-Anything Rules, Canceling Rules, Pattern Match, Pattern Rules 9406 9707 @subsection Match-Anything Pattern Rules … … 10084 10385 The ``what if'' flag (@samp{-W} in GNU @code{make}) was (as far as we know) 10085 10386 invented by Andrew Hume in @code{mk}. 10086 @xref{Instead of Execution, ,Instead of Executing theRecipes}.10387 @xref{Instead of Execution, ,Instead of Executing Recipes}. 10087 10388 10088 10389 @item … … 10102 10403 @item 10103 10404 The special significance of @samp{+} characters preceding recipe lines 10104 (@pxref{Instead of Execution, ,Instead of Executing theRecipes}) is10405 (@pxref{Instead of Execution, ,Instead of Executing Recipes}) is 10105 10406 mandated by @cite{IEEE Standard 1003.2-1992} (POSIX.2). 10106 10407 … … 10147 10448 @item 10148 10449 Make verbatim variable definitions with @code{define}. 10149 @xref{ Defining, ,Defining Variables Verbatim}.10450 @xref{Multi-Line, ,Defining Multi-Line Variables}. 10150 10451 10151 10452 @item … … 10355 10656 @table @code 10356 10657 @item define @var{variable} 10658 @itemx define @var{variable} = 10659 @itemx define @var{variable} := 10660 @itemx define @var{variable} += 10661 @itemx define @var{variable} ?= 10357 10662 @itemx endef 10358 10359 Define a multi-line, recursively-expanded variable.@* 10360 @xref{Sequences}. 10663 Define multi-line variables.@* 10664 @xref{Multi-Line}. 10665 10666 @item undefine @var{variable} 10667 Undefining variables.@* 10668 @xref{Undefine Directive}. 10361 10669 10362 10670 @item ifdef @var{variable} … … 10370 10678 @itemx else 10371 10679 @itemx endif 10372 10373 10680 Conditionally evaluate part of the makefile.@* 10374 10681 @xref{Conditionals}. … … 10377 10684 @itemx -include @var{file} 10378 10685 @itemx sinclude @var{file} 10379 10380 10686 Include another makefile.@* 10381 10687 @xref{Include, ,Including Other Makefiles}. 10382 10688 10383 @item override @var{variable} = @var{value} 10384 @itemx override @var{variable} := @var{value} 10385 @itemx override @var{variable} += @var{value} 10386 @itemx override @var{variable} ?= @var{value} 10387 @itemx override define @var{variable} 10388 @itemx endef 10389 10689 @item override @var{variable-assignment} 10390 10690 Define a variable, overriding any previous definition, even one from 10391 10691 the command line.@* … … 10393 10693 10394 10694 @item export 10395 10396 10695 Tell @code{make} to export all variables to child processes by default.@* 10397 10696 @xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}. 10398 10697 10399 10698 @item export @var{variable} 10400 @itemx export @var{variable} = @var{value} 10401 @itemx export @var{variable} := @var{value} 10402 @itemx export @var{variable} += @var{value} 10403 @itemx export @var{variable} ?= @var{value} 10699 @itemx export @var{variable-assignment} 10404 10700 @itemx unexport @var{variable} 10405 10701 Tell @code{make} whether or not to export a particular variable to child 10406 10702 processes.@* 10407 10703 @xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}. 10704 10705 @item private @var{variable-assignment} 10706 Do not allow this variable assignment to be inherited by prerequisites.@* 10707 @xref{Suppressing Inheritance}. 10408 10708 10409 10709 @item vpath @var{pattern} @var{path} … … 10515 10815 10516 10816 @item $(error @var{text}@dots{}) 10517 10518 10817 When this function is evaluated, @code{make} generates a fatal error 10519 10818 with the message @var{text}.@* … … 10521 10820 10522 10821 @item $(warning @var{text}@dots{}) 10523 10524 10822 When this function is evaluated, @code{make} generates a warning with 10525 10823 the message @var{text}.@* … … 10527 10825 10528 10826 @item $(shell @var{command}) 10529 10530 10827 Execute a shell command and return its output.@* 10531 10828 @xref{Shell Function, , The @code{shell} Function}. 10532 10829 10533 10830 @item $(origin @var{variable}) 10534 10535 10831 Return a string describing how the @code{make} variable @var{variable} was 10536 10832 defined.@* … … 10538 10834 10539 10835 @item $(flavor @var{variable}) 10540 10541 10836 Return a string describing the flavor of the @code{make} variable 10542 10837 @var{variable}.@* … … 10544 10839 10545 10840 @item $(foreach @var{var},@var{words},@var{text}) 10546 10547 10841 Evaluate @var{text} with @var{var} bound to each word in @var{words}, 10548 10842 and concatenate the results.@* 10549 10843 @xref{Foreach Function, ,The @code{foreach} Function}. 10550 10844 10845 @item $(if @var{condition},@var{then-part}[,@var{else-part}]) 10846 Evaluate the condition @var{condition}; if it's non-empty substitute 10847 the expansion of the @var{then-part} otherwise substitute the 10848 expansion of the @var{else-part}.@* 10849 @xref{Conditional Functions, ,Functions for Conditionals}. 10850 10851 @item $(or @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]]) 10852 Evaluate each condition @var{conditionN} one at a time; substitute the 10853 first non-empty expansion. If all expansions are empty, substitute 10854 the empty string.@* 10855 @xref{Conditional Functions, ,Functions for Conditionals}. 10856 10857 @item $(and @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]]) 10858 Evaluate each condition @var{conditionN} one at a time; if any 10859 expansion results in the empty string substitute the empty string. If 10860 all expansions result in a non-empty string, substitute the expansion 10861 of the last @var{condition}.@* 10862 @xref{Conditional Functions, ,Functions for Conditionals}. 10863 10551 10864 @item $(call @var{var},@var{param},@dots{}) 10552 10553 10865 Evaluate the variable @var{var} replacing any references to @code{$(1)}, 10554 10866 @code{$(2)} with the first, second, etc.@: @var{param} values.@* … … 10556 10868 10557 10869 @item $(eval @var{text}) 10558 10559 10870 Evaluate @var{text} then read the results as makefile commands. 10560 10871 Expands to the empty string.@* … … 10562 10873 10563 10874 @item $(value @var{var}) 10564 10565 10875 Evaluates to the contents of the variable @var{var}, with no expansion 10566 10876 performed on it.@* … … 10747 11057 second form of the error above. Remember that every line in the 10748 11058 recipe must begin with a tab character (unless you set 10749 @code{. CMDPREFIX}; @pxref{Special Variables}). Eight spaces do not11059 @code{.RECIPEPREFIX}; @pxref{Special Variables}). Eight spaces do not 10750 11060 count. @xref{Rule Syntax}. 10751 11061 … … 11007 11317 #### End of system configuration section. #### 11008 11318 11009 SRC1 = tar.c create.c extract.c buffer.c \ 11010 getoldopt.c update.c gnu.c mangle.c 11011 SRC2 = version.c list.c names.c diffarch.c \ 11012 port.c wildmat.c getopt.c 11013 SRC3 = getopt1.c regex.c getdate.y 11014 SRCS = $(SRC1) $(SRC2) $(SRC3) 11015 OBJ1 = tar.o create.o extract.o buffer.o \ 11016 getoldopt.o update.o gnu.o mangle.o 11017 OBJ2 = version.o list.o names.o diffarch.o \ 11018 port.o wildmat.o getopt.o 11019 OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB) 11020 OBJS = $(OBJ1) $(OBJ2) $(OBJ3) 11319 @group 11320 SRCS_C = tar.c create.c extract.c buffer.c \ 11321 getoldopt.c update.c gnu.c mangle.c \ 11322 version.c list.c names.c diffarch.c \ 11323 port.c wildmat.c getopt.c getopt1.c \ 11324 regex.c 11325 SRCS_Y = getdate.y 11326 SRCS = $(SRCS_C) $(SRCS_Y) 11327 OBJS = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB) 11328 @end group 11021 11329 @group 11022 11330 AUX = README COPYING ChangeLog Makefile.in \
Note:
See TracChangeset
for help on using the changeset viewer.