Lines Matching full:makefile
71 * Conditionals:: Use or ignore parts of the makefile based
80 * Makefile Conventions:: Conventions for writing makefiles for
84 * Complex Makefile:: A real example of a straightforward,
85 but nontrivial, makefile.
102 * Simple Makefile:: A Simple Makefile
103 * How Make Works:: How `make' Processes This Makefile
106 * Combine By Prerequisite:: Another Style of Makefile
111 * Makefile Contents:: What makefiles contain.
112 * Makefile Names:: How to name your makefile.
113 * Include:: How one makefile can use another makefile.
118 * Overriding Makefiles:: How to override part of one makefile
119 with another makefile.
207 * Setting:: How to set a variable in the makefile.
210 * Override Directive:: How to set a variable in the makefile even if
241 * Eval Function:: Evaluate the arguments as makefile syntax.
249 * Makefile Arguments:: How to specify which makefile to use.
251 parts of the makefile to use.
254 in the makefile other than simply
335 "makefile" that describes the relationships among files in your program
340 Once a suitable makefile
346 uses the makefile data base and the last-modification times of the
391 it to the smallest possible makefile that reproduces the problem. Then
392 send us the makefile and the exact results `make' gave you, including
395 small makefile, be sure to not use any non-free or unusual tools in
423 You need a file called a "makefile" to tell `make' what to do. Most
424 often, the makefile tells `make' how to compile and link a program.
426 In this chapter, we will discuss a simple makefile that describes
428 files and three header files. The makefile can also tell `make' how to
431 of a makefile, see *note Complex Makefile::.
444 * Simple Makefile:: A Simple Makefile
445 * How Make Works:: How `make' Processes This Makefile
448 * Combine By Prerequisite:: Another Style of Makefile
452 File: make.info, Node: Rule Introduction, Next: Simple Makefile, Prev: Introduction, Up: Introduction
457 A simple makefile consists of "rules" with the following shape:
489 A makefile may contain other text besides rules, but a simple
490 makefile need only contain rules. Rules may look somewhat more
495 File: make.info, Node: Simple Makefile, Next: How Make Works, Prev: Rule Introduction, Up: Introduction
497 2.2 A Simple Makefile
500 Here is a straightforward makefile that describes the way an executable
536 To use this makefile to create the executable file called `edit',
541 To use this makefile to delete the executable file and all the object
546 In the example makefile, the targets include the executable file
562 distinguish command lines from other lines in the makefile. (Bear in
580 File: make.info, Node: How Make Works, Next: Variables Simplify, Prev: Simple Makefile, Up: Introduction
582 2.3 How `make' Processes a Makefile
599 `make' reads the makefile in the current directory and begins by
615 prerequisites, the source file and header files. This makefile does not
649 eliminate the risk and simplify the makefile by using a variable.
653 It is standard practice for every makefile to have a variable named
656 with a line like this in the makefile:
665 Here is how the complete simple makefile looks when you use a
732 This is how we would write the makefile in actual practice. (The
742 2.6 Another Style of Makefile
745 When the objects of a makefile are created only by implicit rules, an
746 alternative style of makefile is possible. In this style of makefile,
798 makefile, because we do not want it to run by default! Thus, in the
799 example makefile, we want the rule for `edit', which recompiles the
814 reading a data base called the "makefile".
818 * Makefile Contents:: What makefiles contain.
819 * Makefile Names:: How to name your makefile.
820 * Include:: How one makefile can use another makefile.
825 * Overriding Makefiles:: How to override part of one makefile
826 with another makefile.
831 File: make.info, Node: Makefile Contents, Next: Makefile Names, Prev: Makefiles, Up: Makefiles
854 The simple makefile example shows a variable definition for
859 reading the makefile. These include:
861 * Reading another makefile (*note Including Other Makefiles:
865 ignore a part of the makefile (*note Conditional Parts of
871 * `#' in a line of a makefile starts a "comment". It and the rest
877 Comments may appear on any line in the makefile, although they are
892 File: make.info, Node: Makefile Names, Next: Include, Prev: Makefile Contents, Up: Makefiles
894 3.2 What Name to Give Your Makefile
897 By default, when `make' looks for the makefile, it tries the following
898 names, in order: `GNUmakefile', `makefile' and `Makefile'.
900 Normally you should call your makefile either `makefile' or
901 `Makefile'. (We recommend `Makefile' because it appears prominently
905 makefile that is specific to GNU `make', and will not be understood by
906 other versions of `make'. Other `make' programs look for `makefile' and
907 `Makefile', but not `GNUmakefile'.
909 If `make' finds none of these names, it does not use any makefile.
914 If you want to use a nonstandard name for your makefile, you can
915 specify the makefile name with the `-f' or `--file' option. The
917 as the makefile. If you use more than one `-f' or `--file' option, you
919 concatenated in the order specified. The default makefile names
920 `GNUmakefile', `makefile' and `Makefile' are not checked automatically
924 File: make.info, Node: Include, Next: MAKEFILES Variable, Prev: Makefile Names, Up: Makefiles
930 makefile and read one or more other makefiles before continuing. The
931 directive is a line in the makefile that looks like this:
958 the containing makefile and reads from each listed file in turn. When
959 that is finished, `make' resumes reading the makefile in which the
970 is included by the main makefile. This practice is generally cleaner
972 makefile as has been traditionally done with other versions of `make'.
983 If an included makefile cannot be found in any of these directories,
985 error; processing of the makefile containing the `include' continues.
989 makefile and failed, will `make' diagnose the missing makefile as a
992 If you want `make' to simply ignore a makefile which does not exist
1026 mess with a makefile from outside. However, if you are running `make'
1027 without a specific makefile, a makefile in `MAKEFILES' can do useful
1049 This means that if the first thing a makefile does is examine the
1050 last word in this variable, it will be the name of the current makefile.
1051 Once the current makefile has used `include', however, the last word
1052 will be the just-included makefile.
1054 If a makefile named `Makefile' has this content:
1068 name1 = Makefile
1084 set by a makefile or on the command line.
1115 This makefile prints:
1186 files. If a makefile can be remade from other files, you probably want
1187 `make' to get an up-to-date version of the makefile to read in.
1190 each as a goal target and attempt to update it. If a makefile has a
1191 rule which says how to update it (found either in that very makefile or
1204 explicit rule with the makefile as the target, and an empty command
1209 Double-Colon::). In the case of makefiles, a makefile that has a
1213 `make' would constantly remake the makefile, and never do anything
1219 options, `make' will try the default makefile names; *note What Name to
1220 Give Your Makefile: Makefile Names. Unlike makefiles explicitly
1222 these makefiles should exist. However, if a default makefile does not
1224 rules to be run so that the makefile can be used.
1228 (*note What Name to Give Your Makefile: Makefile Names.) until it
1230 is not an error if `make' cannot find or make any makefile; a makefile
1235 use an out-of-date makefile to decide which targets to touch. So the
1239 because an out-of-date makefile would result in the wrong output for
1248 When the makefile name is specified explicitly as a goal, the options
1251 Thus, `make -f mfile -n mfile foo' would read the makefile `mfile',
1260 3.8 Overriding Part of Another Makefile
1263 Sometimes it is useful to have a makefile that is mostly just like
1264 another makefile. You can often use the `include' directive to include
1269 In the containing makefile (the one that wants to include the other),
1272 makefile, `make' should look in another makefile. *Note Pattern
1275 For example, if you have a makefile called `Makefile' that says how
1276 to make the target `foo' (and other targets), you can write a makefile
1283 @$(MAKE) -f Makefile $@
1290 -f Makefile bar'. If `Makefile' provides a rule for updating `bar',
1305 3.9 How `make' Reads a Makefile
1320 constructs within the makefile. We say that expansion is "immediate"
1323 makefile is parsed. We say that expansion is "deferred" if expansion
1382 `make' Reads a Makefile: Reading Makefiles.). GNU make also has the
1384 some or all targets defined in the makefile. In order for this second
1397 function reference in the makefile. In this case the first expansion
1400 makefile:
1503 Rules undergo secondary expansion in makefile order, except that the
1559 A "rule" appears in the makefile and says when and how to remake
1567 rule in the first makefile. If the first rule has multiple targets,
1574 Therefore, we usually write the makefile so that the first rule is
1576 by the makefile (often with a target called `all'). *Note Arguments to
1670 length of a line in a makefile.
1775 following rule in the makefile, `make print' will print all the `.c'
1858 This string, used anywhere in a makefile, is replaced by a
1879 Thus, a makefile to compile all C source files in the directory and
2022 makefile; multiple directives with the same pattern are independent of
2054 makefile, directory search is performed.
2074 makefile. In short, if `make' must rebuild, then the target
2145 exists (or is mentioned in the makefile) in any of the directories, the
2250 Recursive Use of `make': Recursion.). In this case the makefile will
2300 programs in one makefile `./Makefile'. Since the target remade by
2301 default will be the first one in the makefile, it is common to make
2456 makefile, then all prerequisite lists defined _after_ it appears
2466 makefile, then `make' will delete the target of a rule if it has
2479 this affects every command in the makefile, it is not very useful;
2535 parallel (unless its makefile contains this target). Any
2612 different parts of your makefile; you can use "double-colon rules"
2812 appear in the makefile. However, the cases where double-colon rules
2831 In the makefile for a program, many of the rules you need to write often
2839 would have to write dozens of such rules in your makefile. And, you
2840 must always be very careful to update the makefile every time you add
2858 makefile, so it can never be considered an intermediate file by implicit
2865 all the automatically-generated prerequisites; then the makefile could
2870 prerequisites, because it always regenerates any makefile that is out
2874 to have one makefile corresponding to each source file. For each
2875 source file `NAME.c' there is a makefile `NAME.d' which lists what
2881 a makefile) called `NAME.d' from a C source file called `NAME.c':
2943 are always interpreted by `/bin/sh' unless the makefile specifies
2965 syntaxes in one file. Most of the makefile uses `make' syntax (*note
2974 semicolon in between. _Any_ line in the makefile that begins with a
3013 makefile syntax, a single command can be split into multiple lines in
3014 the makefile by placing a backslash before each newline. A sequence of
3019 makefile, backslash-newline pairs are _not_ removed from the command.
3026 For example, this makefile:
3045 As a more complex example, this makefile:
3106 and semantics to references elsewhere in the makefile. They also have
3146 makefile:
3157 all commands started with `@'. A rule in the makefile for the special
3205 this variable is not set in your makefile, the program `/bin/sh' is
3215 Furthermore, when you do set `SHELL' in your makefile that value is
3254 example, if the makefile specifies `SHELL = /bin/sh', `make' will
3276 where `SHELL' is set from the Makefile; if it is set in the environment
3280 The effect of the above DOS-specific processing is that a Makefile
3392 are ignored in all commands of all rules. A rule in the makefile for
3474 Recursive use of `make' means using `make' as a command in a makefile.
3477 a subdirectory `subdir' which has its own makefile, and you would like
3478 the containing directory's makefile to run `make' on the subdirectory.
3501 same precedence it would have if it were set in the makefile (by
3530 run the top-level makefile, the same special version will be executed
3569 specified in the makefile used by the sub-`make' makefile unless you
3670 (in an included makefile, perhaps). You *cannot* use `export' and
3684 write a makefile that behaves one way if run recursively and another
3690 the outer-level makefile, is passed down through the environment; then
3758 makefile. You probably do not care about this.)
3780 makefile, to specify additional flags that should also be in effect for
3781 that makefile. (Note that you cannot use `MFLAGS' this way. That
3786 environment or from a makefile), it first prepends a hyphen if the value
3936 A "variable" is a name defined in a makefile to represent a string of
3939 of the makefile. (In some other versions of `make', variables are
3942 Variables and functions in all parts of a makefile are expanded when
3964 internal purposes in the makefile, and reserving upper case for
3979 * Setting:: How to set a variable in the makefile.
3982 * Override Directive:: How to set a variable in the makefile even if
4128 Simply expanded variables generally make complicated makefile
4241 sophisticated makefile programming. For most purposes you need not
4375 makefile programming.
4388 * You can specify a value in the makefile, either with an assignment
4408 To set a variable from the makefile, write a line starting with the
4431 affect the functioning of `make', but it will make the makefile easier
4560 Variables: Overriding.), then ordinary assignments in the makefile are
4561 ignored. If you want to set the variable in the makefile even though
4607 Sequences: Sequences.), and also sections of makefile syntax to use
4665 However, an explicit assignment in the makefile, or with a command
4667 then values from the environment override assignments in the makefile.
4674 meanings because you know that no makefile will use them for other
4679 When `make' runs a command script, variables defined in the makefile
4690 cause different users to get different results from the same makefile.
4741 makefile variable. Variables provided on the command-line (and in the
4781 the makefile, and collected together into one set. Variables defined
4813 A "conditional" causes part of a makefile to be obeyed or ignored
4817 the makefile, so they _cannot_ be used to control shell commands at the
4855 arguments and then they are compared. The lines of the makefile
4866 end with an `endif'. Unconditional makefile text follows.
4869 the lines of the conditional are treated as part of the makefile, or
4871 units of the makefile, such as rules, may cross the beginning or the
4914 the makefile if the condition is true. If the condition is false, no
5043 Conditionals affect which lines of the makefile `make' uses. If the
5045 of the makefile; if the condition is false, `make' ignores those lines
5046 completely. It follows that syntactic units of the makefile, such as
5050 `make' evaluates conditionals when it reads a makefile.
5056 conditional in one makefile and end it in another. However, you may
5097 "Functions" allow you to do text processing in the makefile to compute
5101 function's processing is substituted into the makefile at the point of
5113 * Eval Function:: Evaluate the arguments as makefile syntax.
5382 Suppose that a makefile uses the `VPATH' variable to specify a list of
5548 functional context (as opposed to the GNU `make' makefile
5764 makefile:
5787 makefile constructs that are not constant; which are the result of
5790 makefile syntax. The expanded results can define new `make' variables,
5794 it can be placed virtually anywhere in a makefile without causing
5799 expansion are expanded again when they are parsed as makefile syntax.
5811 into another makefile, then include it in all the individual makefiles.
5881 if VARIABLE was defined in a makefile.
5887 if VARIABLE was defined with an `override' directive in a makefile
5896 example, suppose you have a makefile `foo' that includes another
5897 makefile `bar'. You want a variable `bletch' to be defined in `bar' if
5978 function calls are expanded (*note How `make' Reads a Makefile: Reading
6004 provide information to the user of the makefile or to cause make to stop
6020 will generate a fatal error during the read of the makefile if the
6034 the resulting message is displayed, but processing of the makefile
6041 argument(s) to standard output. No makefile name or line number
6051 A makefile that says how to recompile a program can be used in more
6078 * Makefile Arguments:: How to specify which makefile to use.
6080 parts of the makefile to use.
6083 in the makefile other than simply
6093 File: make.info, Node: Makefile Arguments, Next: Goals, Prev: Running, Up: Running
6095 9.1 Arguments to Specify the Makefile
6098 The way to specify the name of the makefile is with the `-f' or
6099 `--file' option (`--makefile' also works). For example, `-f altmake'
6100 says to use the file `altmake' as the makefile.
6106 `GNUmakefile', `makefile', and `Makefile', in that order, and use the
6111 File: make.info, Node: Goals, Next: Instead of Execution, Prev: Makefile Arguments, Up: Running
6120 By default, the goal is the first target in the makefile (not
6123 program or programs they describe. If the first rule in the makefile
6126 default goal from within your makefile using the `.DEFAULT_GOAL'
6134 Any target in the makefile may be specified as a goal (unless it
6137 the makefile may be specified, if `make' can find implicit rules that
6158 containing several programs, with a makefile that starts like this:
6169 which has a rule in the makefile but is not a prerequisite of the
6182 Make all the top-level targets the makefile knows about.
6199 compilation, even if the makefile itself cannot create these files.
6225 Perform self tests on the program this makefile builds.
6233 The makefile tells `make' how to tell whether a target is up to date,
6357 way, all ordinary assignments of the same variable in the makefile are
6362 compilers. For example, in a properly written makefile, the variable
6369 that occurs. The makefile probably specifies the usual value for
6384 You can also program the makefile to look at additional variables of
6386 the makefile works by changing the variables.
6396 There is one way that the makefile can change a variable that you
6506 `m (makefile)'
6521 `--makefile=FILE'
6522 Read the file named FILE as a makefile. *Note Writing Makefiles:
6663 after executing the makefile. This may be useful for tracking
6751 For example, suppose the makefile looks like this:
6775 Of course, when you write the makefile, you know which implicit rule
6783 mentioned explicitly in the makefile as a target or a prerequisite, or
6820 available unless the makefile explicitly overrides or cancels them.
6829 `make', run `make -p' in a directory with no makefile.
6951 knows this by mentioning `N.r' in the makefile. Or, if you are
7034 the makefile, with arguments to `make', or in the environment to alter
7197 If the file `N.c' exists, or is mentioned in the makefile, no
7207 if it had been mentioned in the makefile, along with the implicit rule
7228 makefile as a target or prerequisite. However, you can explicitly mark