make: Goals
1
1 9.2 Arguments to Specify the Goals
1 ==================================
1
1 The "goals" are the targets that 'make' should strive ultimately to
1 update. Other targets are updated as well if they appear as
1 prerequisites of goals, or prerequisites of prerequisites of goals, etc.
1
1 By default, the goal is the first target in the makefile (not
1 counting targets that start with a period). Therefore, makefiles are
1 usually written so that the first target is for compiling the entire
1 program or programs they describe. If the first rule in the makefile
1 has several targets, only the first target in the rule becomes the
1 default goal, not the whole list. You can manage the selection of the
1 default goal from within your makefile using the '.DEFAULT_GOAL'
1 variable (⇒Other Special Variables Special Variables.).
1
1 You can also specify a different goal or goals with command line
1 arguments to 'make'. Use the name of the goal as an argument. If you
1 specify several goals, 'make' processes each of them in turn, in the
1 order you name them.
1
1 Any target in the makefile may be specified as a goal (unless it
1 starts with '-' or contains an '=', in which case it will be parsed as a
1 switch or variable definition, respectively). Even targets not in the
1 makefile may be specified, if 'make' can find implicit rules that say
1 how to make them.
1
1 'Make' will set the special variable 'MAKECMDGOALS' to the list of
1 goals you specified on the command line. If no goals were given on the
1 command line, this variable is empty. Note that this variable should be
1 used only in special circumstances.
1
1 An example of appropriate use is to avoid including '.d' files during
1 'clean' rules (⇒Automatic Prerequisites), so 'make' won't create
1 them only to immediately remove them again:
1
1 sources = foo.c bar.c
1
1 ifneq ($(MAKECMDGOALS),clean)
1 include $(sources:.c=.d)
1 endif
1
1 One use of specifying a goal is if you want to compile only a part of
1 the program, or only one of several programs. Specify as a goal each
1 file that you wish to remake. For example, consider a directory
1 containing several programs, with a makefile that starts like this:
1
1 .PHONY: all
1 all: size nm ld ar as
1
1 If you are working on the program 'size', you might want to say
1 'make size' so that only the files of that program are recompiled.
1
1 Another use of specifying a goal is to make files that are not
1 normally made. For example, there may be a file of debugging output, or
1 a version of the program that is compiled specially for testing, which
1 has a rule in the makefile but is not a prerequisite of the default
1 goal.
1
1 Another use of specifying a goal is to run the recipe associated with
DONTPRINTYET 1 a phony target (⇒Phony Targets) or empty target (*noteEmpty
1DONTPRINTYET 1 a phony target (⇒Phony Targets) or empty target (⇒Empty
Target Files to Record Events Empty Targets.). Many makefiles contain
1 a phony target named 'clean' which deletes everything except source
1 files. Naturally, this is done only if you request it explicitly with
1 'make clean'. Following is a list of typical phony and empty target
1 names. ⇒Standard Targets, for a detailed list of all the
1 standard target names which GNU software packages use.
1
1 'all'
1 Make all the top-level targets the makefile knows about.
1
1 'clean'
1 Delete all files that are normally created by running 'make'.
1
1 'mostlyclean'
1 Like 'clean', but may refrain from deleting a few files that people
1 normally don't want to recompile. For example, the 'mostlyclean'
1 target for GCC does not delete 'libgcc.a', because recompiling it
1 is rarely necessary and takes a lot of time.
1
1 'distclean'
1 'realclean'
1 'clobber'
1 Any of these targets might be defined to delete _more_ files than
1 'clean' does. For example, this would delete configuration files
1 or links that you would normally create as preparation for
1 compilation, even if the makefile itself cannot create these files.
1
1 'install'
1 Copy the executable file into a directory that users typically
1 search for commands; copy any auxiliary files that the executable
1 uses into the directories where it will look for them.
1
1 'print'
1 Print listings of the source files that have changed.
1
1 'tar'
1 Create a tar file of the source files.
1
1 'shar'
1 Create a shell archive (shar file) of the source files.
1
1 'dist'
1 Create a distribution file of the source files. This might be a
1 tar file, or a shar file, or a compressed version of one of the
1 above, or even more than one of the above.
1
1 'TAGS'
1 Update a tags table for this program.
1
1 'check'
1 'test'
1 Perform self tests on the program this makefile builds.
1