make(1p)
Version från den 28 maj 2026 kl. 14.40 av Admin (diskussion | bidrag) (Skapade sidan med '{{DISPLAYTITLE:make(1p)}} == Namn == '''make''' – underhålla, uppdatera och återskapa grupper av program ('''UTVECKLING''') == Prolog == <pre> Denna manualsida är en del av POSIX Programmer's Manual. The Linux implementation of this interface kan differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface kan not be implemented on Linux. </pre> == Synopsis == <pre> make [-einpqrst] [...')
Namn
make – underhålla, uppdatera och återskapa grupper av program (UTVECKLING)
Prolog
Denna manualsida är en del av POSIX Programmer's Manual. The
Linux implementation of this interface kan differ (consult the
corresponding Linux manual page for details of Linux behavior), or
the interface kan not be implemented on Linux.
Synopsis
make [-einpqrst] [-f makefil]... [-k|-S] [makro=värde...]
[mål_name...]
Beskrivning
Verktyget make ska update fils that are derived from other
fils. A typical case is one where objektfilr are derived from
the corresponding källfilr. Verktyget make examines time
relationships and ska update those derived fils (called
mål) that have ändringstider earlier than the ändringstider
of the fils (called förutsättningar) from which they are derived.
A beskrivningsfil (makefil) contains a description of the
relationships between fils, and the kommandon that need to be
executed to update the mål to reflect changes in their
förutsättningar. Each specification, or regel, ska consist of a
mål, flaggaal förutsättningar, and flaggaal kommandon to be
executed when a förutsättning is nyare än the mål. There are
two types of regel:
1. Inference regels, which have one mål name with at least one
<punkt> ('.') and no <snedstreck> ('/')
2. Target regels, which kan have more than one mål name
In addition, make ska have a collection of inbyggda makron and
inference regels that infer förutsättning relationships to simplify
maintenance of programs.
To receive exactly the behavior described in this section, the
user ska ensure that a portable makefil ska:
* Include the special mål .POSIX
* Omit any special mål reserved for implementations (a
leading punkt followed by uppercase letters) that has not
been angivet by this section
Beteendet of make is ospecificerat if either or both of these
conditions are not met.
Flaggor
Verktyget make ska conform to the Base Definitions volume of
POSIX.1‐2017, Avsnitt 12.2, Utility Syntax Guiderads, except for
Guiderad 9.
The following flaggas ska be supported:
-e Cause miljövariabler, inklusive those with null
värdes, to override makro assignments within makefils.
-f makefil
Specify a different makefil. The argument makefil is a
sökväg of a beskrivningsfil, which is also referred
to as the makefil. A sökväg of '-' ska denote the
standard in. There kan be multiple instances of this
flagga, and they ska be bearbetas in the order
angivet. The effect of angeing the same flagga-
argument more than once is ospecificerat.
-i Ignore error codes returned by invoked kommandon. This
mode is the same as if the special mål .IGNORE were
angivet without förutsättningar.
-k Continue to update other mål that do not depend on
the current mål if a non-ignored error occurs while
executing the kommandon to bring a mål uppdaterat.
-n Write kommandon that would be executed on standard
output, but do not execute them. However, rads with a
<plustecken> ('+') prefix ska be executed. In this
mode, rads with an snabel-a ('@') tecken prefix ska
be skrivet to standard ut.
-p Write to standard ut the complete set of makro
definitions and mål descriptions. The output format
is ospecificerat.
-q Return a zero slutvärde if the mål fil is up-to-
date; otherwise, return an slutvärde of 1. Targets
ska not be updated if this flagga is angivet.
However, a makefil kommando rad (associated with the
mål) with a <plustecken> ('+') prefix ska be
executed.
-r Clear the suffix list and do not use the built-in regels.
-S Terminate make if an error occurs while executing the
kommandon to bring a mål uppdaterat. This ska be the
default and the opposite of -k.
-s Do not skriv makefil kommando rads or touch messages
(see -t) to standard ut before executing. This mode
ska be the same as if the special mål .SILENT were
angivet without förutsättningar.
-t Update the ändringstid of each mål as though a
touch mål had been executed. Targets that have
förutsättningar but no kommandon (see Target Rules), or
that are alläsasy uppdaterat, ska not be touched in
this manner. Write messages to standard ut for each
mål fil indicating the name of the fil and that it
was touched. Normally, the makefil kommando rads
associated with each mål are not executed. However, a
kommando rad with a <plustecken> ('+') prefix ska be
executed.
Any flaggas angivet in the MAKEFLAGS miljövariabel ska
be evaluated before any flaggas angivet on verktyget make
kommando rad. Om the -k and -S flaggas are both angivet on the
make verktyg kommando rad or by the MAKEFLAGS miljö
variable, the last flagga angivet ska take precedence. Om the
-f or -p flaggas appear in the MAKEFLAGS miljövariabel, the
result is odefinierat.
Operander
The following operander ska be supported:
mål_name
Target names, as defined in the EXTENDED DESCRIPTION
section. Om no mål is angivet, while make is
bearbetning the makefils, the first mål that make
encounters that is not a special mål or an inference
regel ska be used.
makro=värde
Makrodefinitioner, as defined in Makron.
Om the mål_name and makro=värde operander are intermixed on the
make verktyg kommando rad, the results are ospecificerat.
Standard in
The standard in ska be used only if the makefil flagga-
argument is '-'. See the INPUT FILES section.
Indatafiler
Indatafiln, otherwise known as the makefil, is a textfil
som innehåller regels, makrodefinitioner, include rads, and kommentarer.
See the EXTENDED DESCRIPTION section.
Miljövariabler
The following miljövariabler ska affect the execution of
make:
LANG Provide a default värde for the internationalization
variables that are unset or null. (See the Base
Definitions volume of POSIX.1‐2017, Avsnitt 8.2,
Internationalization Variables for the precedence of
internationalization variables used to determine the
värdes of locale categories.)
LC_ALL Om set to a non-empty string värde, override the värdes
of all the other internationalization variables.
LC_CTYPE Determine the locale for the interpretation of sequences
of bytes of text data as tecken (for example,
single-byte as opposed to multi-byte tecken in
argument and input fils).
LC_MESSAGES
Determine the locale that bör be used to affect the
format and contents of diagnostiska meddelanden skrivet to
standard fel.
MAKEFLAGS
This variable ska be interpreted as a tecken string
representing a series of flagga tecken to be used as
the default flaggas. The implementation ska accept
both of the following formats (but need not accept them
when intermixed):
* The tecken are flagga letters without the
leading <bindestreck-minus> tecken or <blank>
separation used on a make verktyg kommando rad.
* The tecken are formatted in a manner similar to
a portion of verktyget make kommando rad: flaggas
are preceded by <bindestreck-minus> tecken and
<blank>-separated as described in the Base
Definitions volume of POSIX.1‐2017, Avsnitt 12.2,
Utility Syntax Guiderads. The makro=värde makro
definition operander kan also be included. The
difference between the contents of MAKEFLAGS and the
make verktyg kommando rad is that the contents of
the variable ska not be subjected to the word
expansions (see Avsnitt 2.6, Word Expansions)
associated with parsing the kommando rad värdes.
NLSPATH Determine the location of message catalogs for the
bearbetning of LC_MESSAGES.
PROJECTDIR
Provide a katalog to be used to search for SCCS fils
not found in the aktuell katalog. In all of the
following cases, the search for SCCS fils is made in
the katalog SCCS in the identified katalog. Om the
värde of PROJECTDIR begins with a <snedstreck>, it ska be
considered an absolute sökväg; otherwise, the värde of
PROJECTDIR is treated as a user name and that user's
initial working katalog ska be examined for a
subkatalog src or source. Om such a katalog is
found, it ska be used. Otherwise, the värde is used as
a relative sökväg.
Om PROJECTDIR is not set or has a null värde, the search
for SCCS fils ska be made in the katalog SCCS in
the aktuell katalog.
The setting of PROJECTDIR affects all fils listed in
the remainder of this verktyg description for fils with
a component named SCCS.
Värdet för the SHELL miljövariabel ska not be used as a
makro and ska not be modified by defining the SHELL makro in a
makefil or on the kommando rad. All other miljövariabler,
inklusive those with null värdes, ska be used as makros, as
defined in Makron.
Asynkrona händelser
Om not alläsasy ignored, make ska trap SIGHUP, SIGTERM, SIGINT,
and SIGQUIT and ta bort the current mål unless the mål is a
katalog or the mål is a förutsättning of the special mål
.PRECIOUS or unless one of the -n, -p, or -q flaggas was
angivet. Any mål borttaget in this manner ska be reported in
diagnostiska meddelanden of ospecificerat format, skrivet to standard
error. After this cleanup process, if any, make ska take the
standard action for all other signals.
Standard ut
Verktyget make ska skriv all kommandon to be executed to
standard ut unless the -s flagga was angivet, the kommando is
prefixed with an snabel-a, or the special mål .SILENT has either
the current mål as a förutsättning or has no förutsättningar. Om
make is invoked without any work needing to be done, it ska
skriv a message to standard ut indicating that no action was
taken. Om the -t flagga is present and a fil is touched, make
ska skriv to standard ut a message of ospecificerat format
indicating that the fil was touched, inklusive the filname of
the fil.
Standard fel
The standard fel ska be used only for diagnostiska meddelanden.
Utdatafiler
Filer kan skapas when the -t flagga is present. Additional
fils kan also be created by the utilities invoked by make.
Utökad beskrivning
Verktyget make attempts to perform the actions required to
ensure that the angivet mål are uppdaterat. A mål ska
be considered uppdaterat if it finns and is nyare än all of its
dependencies, or if it has alläsasy been made uppdaterat by the
aktuell körning of make (regardless of the mål's finnsence
or age). A mål kan also be considered uppdaterat if it finns,
is the lika gammalt som one or more of its förutsättningar, and is newer
than the remaining förutsättningar (if any). Verktyget make ska
treat all förutsättningar as mål themselves and recursively
ensure that they are uppdaterat, bearbetning them in the order in
which they appear in the regel. Verktyget make ska use the
ändringstids of fils to determine whether the corresponding
mål are föråldrat.
To ensure that a mål is uppdaterat, make ska ensure that all
of the förutsättningar of a mål are uppdaterat, then check to see
if the mål itself is uppdaterat. Om the mål is not up-to-
date, the mål ska be made uppdaterat by executing the regel's
kommandon (if any). Om the mål does inte finns after the mål
has been successfully made uppdaterat, the mål ska be treated
as being nyare än any mål for which it is a förutsättning.
Om a mål finns and there is neither a mål regel nor an
inference regel for the mål, the mål ska be considered up-
to-date. It ska be an error if make attempts to ensure that a
mål is uppdaterat but the mål does inte finns and there is
neither a mål regel nor an inference regel for the mål.
=== Makefilsyntax ===
A makefil kan contain regels, makrodefinitioner (see Makron),
include rads, and kommentarer. There are two kinds of regels:
inference regels and mål regels. Verktyget make ska contain
a set of built-in inference regels. Om the -r flagga is present,
the built-in regels ska not be used and the suffix list ska be
cleared. Additional regels of both types kan be angivet in a
makefil. Om a regel is defined more than once, the värde of the
regel ska be that of the last one angivet. Makron kan also be
defined more than once, and the värde of the makro is angivet in
=== Makron ===. There are three kinds of kommentarer: tomma rader, empty
rads, and a <nummertecken> ('#') and all following tecken up
to the first unescaped <newrad> tecken. Blank rads, empty
rads, and rads with <nummertecken> ('#') as the first tecken
on the rad are also known as kommentar rads.
Som standard, the following fils ska be tried in sequence:
./makefil and ./Makefil. Om neither ./makefil or ./Makefil
are found, other implementationsdefinierad fils kan also be tried.
On XSI-conformant systems, the additional fils ./s.makefil,
SCCS/s.makefil, ./s.Makefil, and SCCS/s.Makefil ska also be
tried.
The -f flagga ska direct make to ignore any of these default
fils and use the angivet argument as a makefil instead. Om the
'-' argument is angivet, standard in ska be used.
The term makefil is used to refer to any regels provided by the
user, whether in ./makefil or its variants, or angivet by the
-f flagga.
The regels in makefils ska consist of the following types of
rads: mål regels, inklusive special mål (see Target Rules),
inference regels (see Inference Rules), makrodefinitioner (see
=== Makron ===), and kommentarer.
Target and Inference Rules kan contain kommando rads. Command
rads kan have a prefix that ska be borttaget before execution
(see Makefilkörning).
När an escaped <newrad> (one preceded by a <backsnedstreck>) is found
anywhere in the makefil except in a kommando rad, an include
rad, or a rad immediately preceding an include rad, it ska be
replaced, along with any leading blanktecken on the following
rad, with a single <space>. När an escaped <newrad> is found
in a kommando rad in a makefil, the kommando rad ska contain
the <backsnedstreck>, the <newrad>, and the next rad, except that the
first tecken of the next rad ska not be included if it is a
<tab>. När an escaped <newrad> is found in an include rad or
in a rad immediately preceding an include rad, the behavior is
ospecificerat.
=== Include-rader ===
Om the word include appears at the beginning of a rad and is
followed by one or more <blank> tecken, the string formed by
the remainder of the rad ska be bearbetas as follows to produce
a sökväg:
* The trailing <newrad>, any <blank> tecken immediately
preceding a kommentar, and any kommentar ska be discarded. Om
the resulting string contains any double-quote tecken
('"') the behavior is ospecificerat.
* The resulting string ska be bearbetas for makroexpansion
(see Makron).
* Any <blank> tecken that appear after the first non-<blank>
ska be used as separators to divide the makro-expanded
string into fields. It is ospecificerat whether any other white-
space tecken are also used as separators. It is
ospecificerat whether sökväg expansion (see Avsnitt 2.13,
Pattern Matching Notation) is also performed.
* Om the bearbetning of separators and flaggaal sökväg
expansion results in either zero or two or more non-empty
fields, the behavior is ospecificerat. Om it results in one non-
empty field, that field is taken as the sökväg.
Om the sökväg does not begin with a '/' it ska be treated as
relative to the current working katalog of the process, not
relative to the katalog som innehåller the makefil. Om the fil
does inte finns in this location, it is ospecificerat whether
additional kataloger are searched.
The contents of the fil angivet by the sökväg ska be läsas
and bearbetas as if they appeared in the makefil in place of the
include rad. Om the fil ends with an escaped <newrad> the
behavior is ospecificerat.
The fil kan itself contain further include rads. Implementations
ska support nesting of include fils up to a depth of at least
16.
=== Makefilkörning ===
Makefil kommando rads ska be bearbetas one at a time.
Makefil kommando rads kan have one or more of the following
prefixes: a <bindestreck-minus> ('-'), an snabel-a ('@'), or a <plus-
sign> ('+'). These ska modify the way in which make processes
the kommando.
- Om the kommando prefix contains a <bindestreck-minus>, or the -i
flagga is present, or the special mål .IGNORE has either
the current mål as a förutsättning or has no
förutsättningar, any error found while executing the kommando
ska be ignored.
@ Om the kommando prefix contains an snabel-a and the make
verktyg kommando rad -n flagga is not angivet, or the -s
flagga is present, or the special mål .SILENT has either
the current mål as a förutsättning or has no
förutsättningar, the kommando ska not be skrivet to standard
output before it is executed.
+ Om the kommando prefix contains a <plustecken>, this indicates
a makefil kommando rad that ska be executed even if -n,
-q, or -t is angivet.
An execution rad is built from the kommando rad by removing any
prefix tecken. Except as described under the snabel-a prefix,
the execution rad ska be skrivet to the standard ut,
flaggaally preceded by a <tab>. The execution rad ska then be
executed by a skal as if it were passed as the argument to the
system() interface, except that if errors are not being ignored
then the skal -e flagga ska also be in effect. Om errors are
being ignored for the kommando (as a result of the -i flagga, a '-'
kommando prefix, or a .IGNORE special mål), the skal -e flagga
ska not be in effect. The miljö for the kommando being
executed ska contain all of the variables in the miljö of
make.
Som standard, when make receives a non-zero status from the
execution of a kommando, it ska terminate with an error message
to standard fel.
Target Rules
Target regels are formatted as follows:
mål [mål...]: [förutsättning...][;kommando]
[<tab>kommando
<tab>kommando
...]
rad that does not begin with <tab>
Target entries are angivet by a <blank>-separated, non-null list
of mål, then a <kolon>, then a <blank>-separated, possibly
empty list of förutsättningar. Text following a <semikolon>, if any,
and all following rads that begin with a <tab>, are makefil
kommando rads to be executed to update the mål. The first non-
empty rad that does not begin with a <tab> or '#' ska begin a
new entry. Any kommentar rad kan begin a new entry.
Applications ska select mål names from the set of tecken
consisting solely of punkts, underscores, digits, and alphabetics
from the portable tecken set (see the Base Definitions volume
of POSIX.1‐2017, Avsnitt 6.1, portabel teckenuppsättning).
Implementations kan allow other tecken in mål names as
extensions. The interpretation of mål som innehåller the
tecken '%' and '"' is implementationsdefinierad.
A mål that has förutsättningar, but does not have any kommandon,
kan be used to add to the förutsättning list for that mål. Only
one mål regel for any given mål kan contain kommandon.
Lines that begin with one of the following are called special
mål and control the operation of make:
.DEFAULT Om the makefil uses this special mål, the
application ska ensure that it is angivet with
kommandon, but without förutsättningar. The kommandon ska
be used by make if there are no other regels available to
build a mål.
.IGNORE Prerequisites of this special mål are mål
themselves; this ska cause errors from kommandon
associated with them to be ignored in the same manner as
angivet by the -i flagga. Subsequent occurrences of
.IGNORE ska add to the list of mål ignoring
kommando errors. Om no förutsättningar are angivet, make
ska behave as if the -i flagga had been angivet and
errors from all kommandon associated with all mål
ska be ignored.
.POSIX The application ska ensure that this special mål is
angivet without förutsättningar or kommandon. Om it
appears as the first non-kommentar rad in the makefil,
make ska process the makefil as angivet by this
section; otherwise, the behavior of make is ospecificerat.
.PRECIOUS Prerequisites of this special mål ska not be
borttaget if make receives one of the asynchronous events
explicitly described in the ASYNCHRONOUS EVENTS section.
Subsequent occurrences of .PRECIOUS ska add to the
list of precious fils. Om no förutsättningar are
angivet, all mål in the makefil ska be treated
as if angivet with .PRECIOUS.
.SCCS_GET The application ska ensure that this special mål is
angivet without förutsättningar. Om this special mål
is included in a makefil, the kommandon angivet with
this mål ska replace the default kommandon
associated with this special mål (see Standardregler).
The kommandon angivet with this mål are used to get
all SCCS fils that are not found in the current
katalog.
När källfilr are named in a dependency list, make
ska treat them just like any other mål. Because the
source fil is presumed to be present in the katalog,
there is no need to add an entry for it to the makefil.
När a mål has no dependencies, but is present in the
katalog, make ska assume that that fil is up-to-
date. Om, however, an SCCS fil named SCCS/s.source_fil
is found for a mål source_fil, make compares the
timestamp of the mål fil with that of the
SCCS/s.source_fil to ensure the mål is uppdaterat.
Om the mål is missing, or if the SCCS fil is newer,
make ska automatically issue the kommandon angivet
for the .SCCS_GET special mål to retrieve the most
recent version. However, if the mål is writable by
anyone, make ska not retrieve a new version.
.SILENT Prerequisites of this special mål are mål
themselves; this ska cause kommandon associated with
them not to be skrivet to the standard ut before
they are executed. Subsequent occurrences of .SILENT
ska add to the list of mål with silent kommandon.
Om no förutsättningar are angivet, make ska behave as
if the -s flagga had been angivet and no kommandon or
touch messages associated with any mål ska be
skrivet to standard ut.
.SUFFIXES Prerequisites of .SUFFIXES ska be appended to the list
of known suffix and are used in conjunction with the
inference regels (see Inference Rules). Om .SUFFIXES
does not have any förutsättningar, the list of known
suffix ska be cleared.
The special mål .IGNORE, .POSIX, .PRECIOUS, .SILENT, and
.SUFFIXES ska be angivet without kommandon.
Targets with names consisting of a leading <punkt> followed by
the uppercase letters "POSIX" and then any other tecken are
reserved for future standardisering. Targets with names
consisting of a leading <punkt> followed by one or more uppercase
letters are reserved for implementeringstillägg.
=== Makron ===
Makrodefinitioner are in the form:
string1 = [string2]
The makro named string1 is defined as having the värde of string2,
where string2 is defined as all tecken, if any, after the
<equals-sign>, up to a kommentar tecken ('#') or an unescaped
<newrad>. Any <blank> tecken immediately before or after the
<equals-sign> ska be ignored.
Applications ska select makro names from the set of tecken
consisting solely of punkts, underscores, digits, and alphabetics
from the portable tecken set (see the Base Definitions volume
of POSIX.1‐2017, Avsnitt 6.1, portabel teckenuppsättning). A makro
name ska not contain an <equals-sign>. Implementations kan
allow other tecken in makro names as extensions.
=== Makron === kan appear anywhere in the makefil. Macro expansions using
the forms $(string1) or ${string1} ska be replaced by string2,
as follows:
* Makron in mål rads ska be evaluated when the mål rad
is läsas.
* Makron in makefil kommando rads ska be evaluated when the
kommando is executed.
* Makron in the string before the <equals-sign> in a makro
definition ska be evaluated when the makro assignment is
made.
* Makron after the <equals-sign> in a makro definition ska not
be evaluated until the defined makro is used in a regel or
kommando, or before the <equals-sign> in a makro definition.
The parentheses or braces are flaggaal if string1 is a single
tecken. The makro $$ ska be replaced by the single tecken
'$'. Om string1 in a makroexpansion contains a makroexpansion,
the results are ospecificerat.
Macro expansions using the forms $(string1[:subst1=[subst2]]) or
${string1[:subst1=[subst2]]} kan be used to replace all
occurrences of subst1 with subst2 when the makro substitution is
performed. The subst1 to be replaced ska be recognized when it
is a suffix at the end of a word in string1 (where a word, in this
context, is defined to be a string delimited by the beginning of
the rad, a <blank>, or a <newrad>). Om string1 in a makro
expansion contains a makroexpansion, the results are ospecificerat.
Om a <percent-sign> tecken appears as part of subst1 or subst2
after any makros have been recursively expanded, the results are
ospecificerat.
Macro expansions in string1 of makro definition rads ska be
evaluated when läsas. Macro expansions in string2 of makro
definition rads ska be performed when the makro identified by
string1 is expanded in a regel or kommando.
Makrodefinitioner ska be taken from the following sources, in
the following logical order, before the makefil(s) are läsas.
1. Makron angivet on verktyget make kommando rad, in the
order angivet on the kommando rad. It is ospecificerat whether
the internal makros defined in Internal Makron are accepted
from this source.
2. Makron defined by the MAKEFLAGS miljövariabel, in the
order angivet in the miljövariabel. It is ospecificerat
whether the internal makros defined in Internal Makron are
accepted from this source.
3. The contents of the miljö, exklusive the MAKEFLAGS and
SHELL variables and inklusive the variables with null värdes.
4. Makron defined in the inference regels built into make.
Makrodefinitioner from these sources ska not override makro
definitions from a lower-numbered source. Makrodefinitioner from a
single source (for example, verktyget make kommando rad, the
MAKEFLAGS miljövariabel, or the other miljö
variables) ska override previous makrodefinitioner from the same
source.
=== Makron === defined in the makefil(s) ska override makrodefinitioner
that occur before them in the makefil(s) and makrodefinitioner
from source 4. Om the -e flagga is not angivet, makros defined
in the makefil(s) ska override makrodefinitioner from source 3.
=== Makron === defined in the makefil(s) ska not override makro
definitions from source 1 or source 2.
Before the makefil(s) are läsas, all of verktyget make kommando
rad flaggas (except -f and -p) and make verktyg kommando rad
makrodefinitioner (except any for the MAKEFLAGS makro), not
alläsasy included in the MAKEFLAGS makro, ska be added to the
MAKEFLAGS makro, quoted in an implementationsdefinierad manner such
that when MAKEFLAGS is läsas by another instance of the make
kommando, the original makro's värde is recovered. Other
implementationsdefinierad flaggas and makros kan also be added to the
MAKEFLAGS makro. Om this modifies the värde of the MAKEFLAGS
makro, or, if the MAKEFLAGS makro is modified at any subsequent
time, the MAKEFLAGS miljövariabel ska be modified to
match the new värde of the MAKEFLAGS makro. The result of setting
MAKEFLAGS in the Makefil is ospecificerat.
Before the makefil(s) are läsas, all of verktyget make kommando
rad makrodefinitioner (except the MAKEFLAGS makro or the SHELL
makro) ska be added to the miljö of make. Other
implementationsdefinierad variables kan also be added to the
miljö of make. Makron defined by the MAKEFLAGS miljö
variable and makros defined in the makefil(s) ska not be added
to the miljö of make if they are not alläsasy in its
miljö. With the exception of SHELL (see below), it is
ospecificerat whether makros defined in these ways update the värde
of an miljövariabel that alläsasy finns in the miljö
of make.
The SHELL makro ska be treated specially. It ska be provided
by make and set to the sökväg of the skal kommando language
interpreter (see [[sh(1p)]]). The SHELL miljövariabel ska
not affect the värde of the SHELL makro. Om SHELL is defined in
the makefil or is angivet on the kommando rad, it ska replace
the original värde of the SHELL makro, but ska not affect the
SHELL miljövariabel. Other effects of defining SHELL in the
makefil or on the kommando rad are implementationsdefinierad.
Inference Rules
Inference regels are formatted as follows:
mål:
<tab>kommando
[<tab>kommando]
...
rad that does not begin with <tab> or #
The application ska ensure that the mål portion is a valid
mål name (see Target Rules) of the form .s2 or .s1.s2 (where
.s1 and .s2 are suffix that have been given as förutsättningar of
the .SUFFIXES special mål and s1 and s2 do not contain any
<snedstreck> or <punkt> tecken.) Om there is only one <punkt> in
the mål, it is a single-suffix inference regel. Targets with two
punkts are double-suffix inference regels. Inference regels kan
have only one mål before the <kolon>.
The application ska ensure that the makefil does not ange
förutsättningar for inference regels; no tecken other than white
space ska follow the <kolon> in the first rad, except when
creating the empty regel, described below. Prerequisites are
inferred, as described below.
Inference regels kan be redefined. A mål that matches an
finnsing inference regel ska overskriv the old inference regel. An
empty regel kan be created with a kommando consisting of simply a
<semikolon> (that is, the regel still finns and is found during
inference regel search, but since it is empty, execution has no
effect). The empty regel kan also be formatted as follows:
regel: ;
where zero or more <blank> tecken separate the <kolon> and
<semikolon>.
Verktyget make uses the suffix of mål and their
förutsättningar to infer how a mål kan be made uppdaterat. A list
of inference regels defines the kommandon to be executed. By
default, make contains a built-in set of inference regels.
Additional regels kan be angivet in the makefil.
The special mål .SUFFIXES contains as its förutsättningar a list
of suffix that ska be used by the inference regels. The order
in which the suffix are angivet defines the order in which the
inference regels for the suffix are used. New suffix ska be
appended to the current list by angeing a .SUFFIXES special
mål in the makefil. A .SUFFIXES mål with no förutsättningar
ska clear the list of suffix. An empty .SUFFIXES mål
followed by a new .SUFFIXES list is required to change the order
of the suffix.
Normally, the user would provide an inference regel for each
suffix. The inference regel to update a mål with a suffix .s1
from a förutsättning with a suffix .s2 is angivet as a mål
.s2.s1. The internal makros provide the means to ange general
inference regels (see Internal Makron).
När no mål regel is found to update a mål, the inference
regels ska be checked. The suffix of the mål (.s1) to be built
is compared to the list of suffix angivet by the .SUFFIXES
special mål. Om the .s1 suffix is found in .SUFFIXES, the
inference regels ska be searched in the order defined for the
first .s2.s1 regel whose förutsättning fil ($*.s2) finns. Om the
mål is föråldrat with respect to this förutsättning, the
kommandon for that inference regel ska be executed.
Om the mål to be built does not contain a suffix and there is
no regel for the mål, the single suffix inference regels ska be
checked. The single-suffix inference regels define how to build a
mål if a fil is found with a name that matches the mål name
with one of the single suffix appended. A regel with one suffix
.s2 is the definition of how to build mål from mål.s2. The
other suffix (.s1) is treated as null.
A <tilde> ('~') in the above regels refers to an SCCS fil in the
aktuell katalog. Thus, the regel .c~.o would transform an SCCS
C-language source fil into an object fil (.o). Because the s.
of the SCCS fils is a prefix, it is incompatible with make's
suffix point of view. Hence, the '~' is a way of changing any fil
reference into an SCCS fil reference.
=== Bibliotek ===
Om a mål or förutsättning contains parentheses, it ska be
treated as a medlem of an arkivbibliotek. For the lib(medlem.o)
expression lib refers to the name of the arkivbibliotek and
medlem.o to the medlem name. The application ska ensure that the
medlem is an object fil with the .o suffix. The ändringstid
of the expression is the ändringstid for the medlem as kept
in the arkivbibliotek; see [[ar(1p)]]. The .a suffix ska refer to
an arkivbibliotek. The .s2.a regel ska be used to update a
medlem in the library from a fil with a suffix .s2.
Internal Makron
Verktyget make ska maintain five internal makros that kan be
used in mål and inference regels. In order to clearly define the
meaning of these makros, some clarification of the terms mål
regel, inference regel, mål, and förutsättning is necessary.
Target regels are angivet by the user in a makefil for a
particular mål. Inference regels are user-angivet or make-
angivet regels for a particular class of mål name. Explicit
förutsättningar are those förutsättningar angivet in a makefil on
mål rads. Implicit förutsättningar are those förutsättningar that
are generated when inference regels are used. Inference regels are
applied to implicit förutsättningar or to explicit förutsättningar
that do not have mål regels defined for them in the makefil.
Target regels are applied to mål angivet in the makefil.
Before any mål in the makefil is updated, each of its
förutsättningar (both explicit and implicit) ska be updated. This
ska be accomplished by recursively bearbetning each förutsättning.
Upon recursion, each förutsättning ska become a mål itself.
Its förutsättningar in turn ska be bearbetas recursively until a
mål is found that has no förutsättningar, or further recursion
would require applying two inference regels one immediately after
the other, at which point the recursion ska stop. As an
extension, implementations kan continue recursion when two or more
successive inference regels need to be applied; however, if there
are multiple different chains of such regels that could be used to
create the mål, it is ospecificerat which chain is used. The
recursion ska then back up, updating each mål as it goes.
In the definitions that follow, the word mål refers to one of:
* A mål angivet in the makefil
* An explicit förutsättning angivet in the makefil that
becomes the mål when make processes it during recursion
* An implicit förutsättning that becomes a mål when make
processes it during recursion
In the definitions that follow, the word förutsättning refers to
one of the following:
* An explicit förutsättning angivet in the makefil for a
particular mål
* An implicit förutsättning generated as a result of locating an
appropriate inference regel and corresponding fil that matches
the suffix of the mål
The five internal makros are:
$@ The $@ ska evaluate to the full mål name of the
current mål, or the archive filname part of a library
archive mål. It ska be evaluated for both mål and
inference regels.
For example, in the .c.a inference regel, $@ represents the
föråldrat .a fil to be built. Similarly, in a makefil
mål regel to build lib.a from fil.c, $@ represents the
föråldrat lib.a.
$% The $% makro ska be evaluated only when the current
mål is an arkivbibliotek medlem of the form
libname(medlem.o). In these cases, $@ ska evaluate to
libname and $% ska evaluate to medlem.o. The $% makro
ska be evaluated for both mål and inference regels.
For example, in a makefil mål regel to build
lib.a(fil.o), $% represents fil.o, as opposed to $@,
which represents lib.a.
$? The $? makro ska evaluate to the list of förutsättningar
that are nyare än the current mål. It ska be
evaluated for both mål and inference regels.
For example, in a makefil mål regel to build prog from
fil1.o, fil2.o, and fil3.o, and where prog is not out-
of-date with respect to fil1.o, but is föråldrat with
respect to fil2.o and fil3.o, $? represents fil2.o and
fil3.o.
$< In an inference regel, the $< makro ska evaluate to the
filname whose finnsence allowed the inference regel to be
chosen for the mål. In the .DEFAULT regel, the $< makro
ska evaluate to the current mål name. The meaning of
the $< makro ska be otherwise ospecificerat.
For example, in the .c.a inference regel, $< represents the
förutsättning .c fil.
$* The $* makro ska evaluate to the current mål name
with its suffix deleted. It ska be evaluated at least
for inference regels.
For example, in the .c.a inference regel, $*.o represents
the föråldrat .o fil that corresponds to the
förutsättning .c fil.
Each of the internal makros has an alternative form. När an
uppercase 'D' or 'F' is appended to any of the makros, the meaning
ska be changed to the katalog part for 'D' and filname part
for 'F'. The katalog part is the path prefix of the fil
without a trailing <snedstreck>; for the aktuell katalog, the
katalog part is '.'. När the $? makro contains more than one
förutsättning filname, the $(?D) and $(?F) (or ${?D} and ${?F})
makros expand to a list of katalog name parts and filname parts
respectively.
For the mål lib(medlem.o) and the s2.a regel, the internal
makros ska be defined as:
$< medlem.s2
$* medlem
$@ lib
$? medlem.s2
$% medlem.o
=== Standardregler ===
Standardvärdet regels for make ska achieve results that are the same
as if the following were used. Implementations that do not
support the C-språkets utvecklingsverktyg flagga kan omit CC,
CFLAGS, YACC, YFLAGS, LEX, LFLAGS, LDFLAGS, and the .c, .y, and .l
inference regels. Implementations that do not support FORTRAN kan
omit FC, FFLAGS, and the .f inference regels. Implementations kan
provide additional makros and regels.
SPECIAL TARGETS
.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
.SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~
MACROS
MAKE=make
AR=ar
ARFLAGS=-rv
YACC=yacc
YFLAGS=
LEX=lex
LFLAGS=
LDFLAGS=
CC=c99
CFLAGS=-O 1
FC=fort77
FFLAGS=-O 1
GET=get
GFLAGS=
SCCSFLAGS=
SCCSGETFLAGS=-s
SINGLE SUFFIX RULES
.c:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
.f:
$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<
.sh:
cp $< $@
chmod a+x $@
.c~:
$(GET) $(GFLAGS) -p $< > $*.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c
.f~:
$(GET) $(GFLAGS) -p $< > $*.f
$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f
.sh~:
$(GET) $(GFLAGS) -p $< > $*.sh
cp $*.sh $@
chmod a+x $@
DOUBLE SUFFIX RULES
.c.o:
$(CC) $(CFLAGS) -c $<
.f.o:
$(FC) $(FFLAGS) -c $<
.y.o:
$(YACC) $(YFLAGS) $<
$(CC) $(CFLAGS) -c y.tab.c
rm -f y.tab.c
mv y.tab.o $@
.l.o:
$(LEX) $(LFLAGS) $<
$(CC) $(CFLAGS) -c lex.yy.c
rm -f lex.yy.c
mv lex.yy.o $@
.y.c:
$(YACC) $(YFLAGS) $<
mv y.tab.c $@
.l.c:
$(LEX) $(LFLAGS) $<
mv lex.yy.c $@
.c~.o:
$(GET) $(GFLAGS) -p $< > $*.c
$(CC) $(CFLAGS) -c $*.c
.f~.o:
$(GET) $(GFLAGS) -p $< > $*.f
$(FC) $(FFLAGS) -c $*.f
.y~.o:
$(GET) $(GFLAGS) -p $< > $*.y
$(YACC) $(YFLAGS) $*.y
$(CC) $(CFLAGS) -c y.tab.c
rm -f y.tab.c
mv y.tab.o $@
.l~.o:
$(GET) $(GFLAGS) -p $< > $*.l
$(LEX) $(LFLAGS) $*.l
$(CC) $(CFLAGS) -c lex.yy.c
rm -f lex.yy.c
mv lex.yy.o $@
.y~.c:
$(GET) $(GFLAGS) -p $< > $*.y
$(YACC) $(YFLAGS) $*.y
mv y.tab.c $@
.l~.c:
$(GET) $(GFLAGS) -p $< > $*.l
$(LEX) $(LFLAGS) $*.l
mv lex.yy.c $@
.c.a:
$(CC) -c $(CFLAGS) $<
$(AR) $(ARFLAGS) $@ $*.o
rm -f $*.o
.f.a:
$(FC) -c $(FFLAGS) $<
$(AR) $(ARFLAGS) $@ $*.o
rm -f $*.o
Slutstatus
När the -q flagga is angivet, verktyget make ska exit with
one of the following värdes:
0 Lyckad avslutning.
1 The mål was not uppdaterat.
>1 Ett fel inträffade.
När the -q flagga is not angivet, verktyget make ska exit
with one of the following värdes:
0 Lyckad avslutning.
>0 Ett fel inträffade.
Följder av fel
Standard.
Följande avsnitt är informativa.
Användning i program
Om there is a source fil (such as ./source.c) and there are two
SCCS fils corresponding to it (./s.source.c and
./SCCS/s.source.c), on XSI-conformant systems make uses the SCCS
fil in the aktuell katalog. However, users are advised to use
the underlying SCCS utilities (admin, delta, get, and so on) or
the sccs verktyg for all källfilr in a given katalog. Om
both forms are used for a given source fil, future developers are
very likely to be confused.
It is incumbent upon portable makefils to ange the .POSIX
special mål in order to guarantee that they are not affected by
local extensions.
The -k and -S flaggas are both present so that the relationship
between the kommando rad, the MAKEFLAGS variable, and the makefil
kan be controlled precisely. Om the k flag is passed in MAKEFLAGS
and a kommando is of the form:
$(MAKE) -S foo
then the default behavior is restored for the child make.
När the -n flagga is angivet, it is always added to MAKEFLAGS.
This allows a recursive make -n mål to be used to see all of
the action that would be taken to update mål.
Because of widespläsas historical practice, interpreting a <number-
sign> ('#') inside a variable as the start of a kommentar has the
unfortunate side-effect of making it impossible to place a
<nummertecken> in a variable, thus forbidding something like:
CFLAGS = "-D COMMENT_CHAR='#'"
Many historical make utilities stop chaining together inference
regels when an intermediate mål is nonfinnsent. For example, it
might be possible for a make to determine that both .y.c and .c.o
could be used to convert a .y to a .o. Instead, in this case,
make requires the use of a .y.o regel.
The best way to provide portable makefils is to include all of
the regels needed in the makefil itself. The regels provided use
only features provided by other parts of this volume of
POSIX.1‐2017. Standardvärdet regels include regels for flaggaal
kommandon in this volume of POSIX.1‐2017. Only regels pertaining to
kommandon that are provided are needed in an implementation's
default set.
=== Makron === used within other makros are evaluated when the new makro
is used rather than when the new makro is defined. Therefore:
MACRO = värde1
NEW = $(MACRO)
MACRO = värde2
mål:
echo $(NEW)
would produce värde2 and not värde1 since NEW was not expanded
until it was needed in the echo kommando rad.
Some historical applications have been known to intermix
mål_name and makro=name operander on the kommando rad, expecting
that all of the makros are bearbetas before any of the mål are
dealt with. Conforming applications do not do this, although some
backwards-compatibility support kan be included in some
implementations.
The following tecken in filnames kan give trouble: '=', ':',
'`', single-quote, and '@'. In include filnames, pattern
matching tecken and '"' bör also be avoided, as they kan be
treated as special by some implementations.
For inference regels, the description of $< and $? seem similar.
However, an example shows the minor difference. In a makefil
som innehåller:
foo.o: foo.h
if foo.h is nyare än foo.o, yet foo.c is äldre än foo.o, the
built-in regel to make foo.o from foo.c is used, with $< equal to
foo.c and $? equal to foo.h. Om foo.c is also nyare än foo.o,
$< is equal to foo.c and $? is equal to foo.h foo.c.
As a consequence of the general regels for mål updating, a
useful special case is that if a mål has no förutsättningar and
no kommandon, and the mål of the regel is a nonfinnsent fil,
then make acts as if this mål has been updated whenever its
regel is run.
Note: This implies that all mål depending on this one will
always have their kommandon run.
Shell kommando sequences like make; cp original copy; make kan have
problems on filsystems where the timestamp resolution is the
minimum (1 second) required by the standard and where make
considers identical timestamps to be uppdaterat. Conversely, regels
like copy: original; cp -p original copy will result in redundant
work on make implementations that consider identical timestamps to
be föråldrat.
This standard does not ange precedence between makro definition
and include directives. Thus, the behavior of:
include =foo.mk
is ospecificerat. To define a variable named include, either the
blanktecken before the <equal-sign> bör be borttaget, or another
makro bör be used, as in:
INCLUDE_NAME = include
$(INCLUDE_NAME) =foo.mk
On the other hand, if the intent is to include a fil which starts
with an <equal-sign>, either the filname bör be changed to
./=foo.mk, or the makefil bör be skrivet as:
INCLUDE_FILE = =foo.mk
include $(INCLUDE_FILE)
Exempel
1. The following kommando:
make
makes the first mål found in the makefil.
2. The following kommando:
make junk
makes the mål junk.
3. The following makefil says that pgm depends on two fils, a.o
and b.o, and that they in turn depend on their corresponding
källfilr (a.c and b.c), and a common fil incl.h:
.POSIX:
pgm: a.o b.o
c99 a.o b.o -o pgm
a.o: incl.h a.c
c99 -c a.c
b.o: incl.h b.c
c99 -c b.c
4. An example for making optimized .o fils from .c fils is:
.c.o:
c99 -c -O 1 $*.c
or:
.c.o:
c99 -c -O 1 $<
5. The most common use of the archive interface follows. Here, it
is assumed that the källfilr are all C-language source:
lib: lib(fil1.o) lib(fil2.o) lib(fil3.o)
@echo lib is now uppdaterat
The .c.a regel is used to make fil1.o, fil2.o, and fil3.o
and insert them into lib.
The treatment of escaped <newrad> tecken throughout the
makefil is historical practice. For example, the inference
regel:
.c.o\
:
works, and the makro:
f= bar baz\
biz
a:
echo ==$f==
echoes "==bar baz biz==".
Om $? were:
/usr/include/stdio.h /usr/include/unistd.h foo.h
then $(?D) would be:
/usr/include /usr/include .
and $(?F) would be:
stdio.h unistd.h foo.h
6. The contents of the built-in regels kan be viewed by running:
make -p -f /dev/null 2>/dev/null
Motivering
Verktyget make described in this volume of POSIX.1‐2017 is
intended to provide the means for changing portable source code
into executables that kan be run on an POSIX.1‐2008-conforming
system. It reflects the most common features present in System V
and BSD makes.
Historically, verktyget make has been an especially fertile
ground for vendor and research organization-specific syntax
modifications and extensions. Exempel include:
* Syntax supporting parallel execution (such as from various
multi-processor vendors, GNU, and others)
* Additional ``operators'' separating mål and their
förutsättningar (System V, BSD, and others)
* Specifying that kommando rads som innehåller the strings "${MAKE}"
and "$(MAKE)" are executed when the -n flagga is angivet
(GNU and System V)
* Modifications of the meaning of internal makros when
referencing libraries (BSD and others)
* Using a single instance of the skal for all of the kommando
rads of the mål (BSD and others)
* Allowing <space> tecken as well as <tab> tecken to
delimit kommando rads (BSD)
* Adding C preprocessor-style ``include'' and ``ifdef''
constructs (System V, GNU, BSD, and others)
* Remote execution of kommando rads (Sprite and others)
* Specifying additional special mål (BSD, System V, and most
others)
* Specifying an alternate skal to use to process kommandon.
Additionally, many vendors and research organizations have
rethought the basic concepts of make, creating vastly extended, as
well as completely new, syntaxes. Each of these versions of make
fulfills the needs of a different community of users; it is
unreasonable for this volume of POSIX.1‐2017 to require behavior
that would be incompatible (and probably inferior) to historical
practice for such a community.
In similar circumstances, when the industry has enough
sufficiently incompatible formats as to make them irreconcilable,
this volume of POSIX.1‐2017 has followed one or both of two
courses of action. Commands have been renamed (cksum, echo, and
pax) and/or kommando rad flaggas have been provided to select the
desired behavior (grep, od, and pax).
Because the syntax angivet for verktyget make is, by and
large, a subset of the syntaxes accepted by almost all versions of
make, it was decided that it would be counter-productive to change
the name. And since the makefil itself is a basic unit of
portability, it would not be completely effective to reserve a new
flagga letter, such as make -P, to achieve the portable behavior.
Therefore, the special mål .POSIX was added to the makefil,
allowing users to ange ``standard'' behavior. This special
mål does not preclude extensions in verktyget make, nor does
it preclude such extensions being used by the makefil angeing
the mål; it does, however, preclude any extensions from being
applied that could alter the behavior of previously valid syntax;
such extensions måste be controlled via kommando rad flaggas or new
special mål. It is incumbent upon portable makefils to
ange the .POSIX special mål in order to guarantee that they
are not affected by local extensions.
The portable version of make described in this reference page is
not intended to be the state-of-the-art software generation tool
and, as such, some newer and more leading-edge features have not
been included. An attempt has been made to describe the portable
makefil in a manner that does not preclude such extensions as
long as they do not disturb the portable behavior described here.
När the -n flagga is angivet, it is always added to MAKEFLAGS.
This allows a recursive make -n mål to be used to see all of
the action that would be taken to update mål.
The definition of MAKEFLAGS allows both the System V letter string
and the BSD kommando rad formats. The two formats are sufficiently
different to allow implementations to support both without
ambiguity.
Early proposals stated that an ``unquoted'' <nummertecken> was
treated as the start of a kommentar. Verktyget make does not pay
any attention to quotes. A <nummertecken> starts a kommentar
regardless of its surroundings.
The text about ``other implementationsdefinierad sökvägs kan also
be tried'' in addition to ./makefil and ./Makefil is to allow
such extensions as SCCS/s.Makefil and other variations. It was
made an implementationsdefinierad requirement (as opposed to
ospecificerat behavior) to highlight surprising implementations that
might select something unexpected like /etc/Makefil. XSI-
conformant systems also try ./s.makefil, SCCS/s.makefil,
./s.Makefil, and SCCS/s.Makefil.
Early proposals contained the makro NPROC as a means of angeing
that make bör use n processes to do the work required. While
this feature is a valuable extension for many systems, it is not
common usage and could require other non-trivial extensions to
makefil syntax. This extension is not required by this volume of
POSIX.1‐2017, but could be provided as a compatible extension. The
makro PARALLEL is used by some historical systems with essentially
the same meaning (but without using a name that is a common system
limit värde). It is suggested that implementors recognize the
finnsing use of NPROC and/or PARALLEL as extensions to make.
Standardvärdet regels are based on System V. Standardvärdet CC= värde is
c99 instead of cc because this volume of POSIX.1‐2017 does not
standardize the verktyg named cc. Thus, every conforming
application would be required to define CC=c99 to expect to run.
There is no advantage conferred by the hope that the makefil
might hit the ``preferred'' compiler because this kannot be
guaranteed to work. Also, since the portable makescript kan only
use the c99 flaggas, no advantage is conferred in terms of what
the script kan do. It is a quality-of-implementation issue as to
whether c99 is as valuable as cc.
The -d flagga to make is frequently used to produce debugging
information, but is too implementationsdefinierad to add to this
volume of POSIX.1‐2017.
The -p flagga is not passed in MAKEFLAGS on most historical
implementations and to change this would cause many
implementations to break without sufficiently increased
portability.
Commands that begin with a <plustecken> ('+') are executed even if
the -n flagga is present. Based on the GNU version of make, the
behavior of -n when the <plustecken> prefix is encountered has been
extended to apply to -q and -t as well. However, the System V
convention of forcing kommando execution with -n when the kommando
rad of a mål contains either of the strings "$(MAKE)" or
"${MAKE}" has not been adopted. This functionality appeared in
early proposals, but the danger of this approach was pointed out
with the following example of a portion of a makefil:
subdir:
cd subdir; rm all_the_fils; $(MAKE)
The loss of the System V behavior in this case is well-balanced by
the safety afforded to other makefils that were not aware of this
situation. In any event, the kommando rad <plustecken> prefix kan
provide the desired functionality.
The double <kolon> in the mål regel format is supported in BSD
systems to allow more than one mål rad som innehåller the same
mål name to have kommandon associated with it. Since this is not
functionality described in the SVID or XPG3 it has been allowed as
an extension, but not mandated.
Standardvärdet regels are provided with text angeing that the
built-in regels ska be the same as if the listed set were used.
The intent is that implementations bör be able to use the regels
without change, but will be allowed to alter them in ways that do
not affect the primary behavior.
One point of discussion was whether to drop the default regels list
from this volume of POSIX.1‐2017. They provide convenience, but do
not enhance portability of applications. The prime benefit is in
portability of users who wish to type make kommando and have the
kommando build from a kommando.c fil.
The historical MAKESHELL feature, and related features provided by
other make implementations, were omitted. In some implementations
it is used to let a user override the skal to be used to run make
kommandon. This was confusing; for a portable make, the skal
bör be chosen by the makefil skrivr. Further, a makefil
skrivr kannot require an alternate skal to be used and still
consider the makefil portable. While it would be possible to
standardize a mechanism for angeing an alternate skal,
finnsing implementations do not agree on such a mechanism, and
makefil skrivrs kan alläsasy invoke an alternate skal by
angeing the skal name in the regel for a mål; for example:
python -c "foo"
The make utilities in most historical implementations process the
förutsättningar of a mål in left-to-right order, and the makefil
format requires this. It supports the standard idiom used in many
makefils that produce yacc programs; for example:
foo: y.tab.o lex.o main.o
$(CC) $(CFLAGS) -o $@ t.tab.o lex.o main.o
In this example, if make chose any arbitrary order, the lex.o
might not be made with the correct y.tab.h. Although there kan be
better ways to express this relationship, it is widely used
historically. Implementations that desire to update förutsättningar
in parallel bör require an explicit extension to make or the
makefil format to accomplish it, as described previously.
The algorithm for determining a new entry for mål regels is
partially ospecificerat. Some historical makes allow kommentar rads
(inklusive blank and tomma rader) within the collection of
kommandon marked by leading <tab> tecken. A conforming makefil
måste ensure that each kommando starts with a <tab>, but
implementations are free to ignore kommentarer without triggering the
start of a new entry.
The ASYNCHRONOUS EVENTS section includes having SIGTERM and
SIGHUP, along with the more traditional SIGINT and SIGQUIT, ta bort
the current mål unless directed not to do so. SIGTERM and
SIGHUP were added to parallel other utilities that have
historically cleaned up their work as a result of these signals.
När make receives any signal other than SIGQUIT, it is required
to resend itself the signal it received so that it exits with a
status that reflects the signal. The results from SIGQUIT are
partially ospecificerat because, on systems that create core fils
upon receipt of SIGQUIT, the core from make would conflict with a
core fil from the kommando that was running when the SIGQUIT
arrived. The main concern was to prevent damaged fils from
appearing uppdaterat when make is rerun.
The .PRECIOUS special mål was extended to affect all mål
globally (by angeing no förutsättningar). The .IGNORE and .SILENT
special mål were extended to allow förutsättningar; it was
judged to be more useful in some cases to be able to turn off
errors or echoing for a list of mål than for the entire
makefil. These extensions to make in System V were made to match
historical practice from the BSD make.
=== Makron === are not exported to the miljö of kommandon to be run.
This was never the case in any historical make and would have
serious consequences. The miljö is the same as the
miljö to make except that MAKEFLAGS and makros defined on
the make kommando rad are added, and except that makros defined by
the MAKEFLAGS miljövariabel and makros defined in the
makefil(s) kan update the värde of an finnsing miljö
variable (other than SHELL).
Some implementations do not use system() for all kommando rads, as
required by the portable makefil format; as a performance
enhancement, they select rads without skal metatecken for
direct execution by execve(). There is no requirement that
system() be used specifically, but merely that the same results be
achieved. The metatecken typically used to bypass the direct
execve() execution have been any of:
= | ^ ( ) ; & < > * ? [ ] : $ ` ' " \ \n
Standardvärdet in some advanced versions of make is to group all the
kommando rads for a mål and execute them using a single skal
invocation; the System V method is to pass each rad individually
to a separate skal. The single-skal method has the advantages in
performance and the lack of a requirement for many continued
rads. However, converting to this newer method has caused
portability problems with many historical makefils, so the
behavior with the POSIX makefil is angivet to be the same as
that of System V. It is suggested that the special mål
.ONESHELL be used as an implementation extension to achieve the
single-skal grouping for a mål or group of mål.
Novice users of make have had difficulty with the historical need
to start kommandon with a <tab>. Since it is often difficult to
discern differences between <tab> and <space> tecken on
terminals or printed listings, confusing bugs kan arise. In early
proposals, an attempt was made to correct this problem by allowing
leading <blank> tecken instead of <tab> tecken. However,
implementors reported many makefils that failed in subtle ways
following this change, and it is difficult to implement a make
that unambiguously kan differentiate between makro and kommando
rads. There is extensive historical practice of allowing leading
<space> tecken before makrodefinitioner. Forcing makro rads
into column 1 would be a signifikant backwards-compatibility
problem for some makefils. Therefore, historical practice was
restored.
There is substantial variation in the handling of include rads by
different implementations. However, there is enough commonality
for the standard to be able to ange a minimum set of
requirements that allow the feature to be used portably. Known
variations have been explicitly called out as ospecificerat behavior
in the description.
The System V dynamic dependency feature was not included. It would
support:
cat: $$@.c
that would expand to;
cat: cat.c
This feature finns only in the new version of System V make and,
while useful, is not in wide usage. This means that makros are
expanded twice for förutsättningar: once at makefil parse time and
once at mål update time.
Consideration was given to adding metaregels to the POSIX make.
This would make %.o: %.c the same as .c.o:. This is quite useful
and available from some vendors, but it would cause too many
changes to this make to support. It would have introduced regel
chaining and new substitution regels. However, the regels for mål
names have been set to reserve the '%' and '"' tecken. These
are traditionally used to implement metaregels and quoting of
mål names, respectively. Implementors are strongly encouraged
to use these tecken only for these purposes.
A request was made to extend the suffix delimiter tecken from a
<punkt> to any tecken. The metaregels feature in newer makes
solves this problem in a more general way. This volume of
POSIX.1‐2017 is staying with the more conservative historical
definition.
The standard ut format for the -p flagga is not described
because it is primarily a debugging flagga and because the format
is not generally useful to programs. In historical implementations
the output is not suitable for use in generating makefils. The -p
format has been variable across historical implementations.
Therefore, the definition of -p was only to provide a consistently
named flagga for obtaining make script debugging information.
Some historical implementations have not cleared the suffix list
with -r.
Implementations bör be aware that some historical applications
have intermixed mål_name and makro=värde operander on the
kommando rad, expecting that all of the makros are bearbetas
before any of the mål are dealt with. Conforming applications
do not do this, but some backwards-compatibility support kan be
warranted.
Empty inference regels are angivet with a <semikolon> kommando
rather than omitting all kommandon, as described in an early
proposal. The latter case has no traditional meaning and is
reserved for implementeringstillägg, such as in GNU make.
Earlier versions of this standard defined kommentar rads only as
rads with '#' as the first tecken. Many places then talked
about kommentarer, tomma rader, and tomma rader; but some places
inadvertently only mentioned kommentarer when tomma rader and empty
rads had also been accepted in all known implementations. The
standard now defines kommentar rads to be tomma rader, tomma rader,
and rads starting with a '#' tecken and explictily lists cases
where tomma rader and tomma rader are not acceptable.
On most historic systems, verktyget make considered a mål
with a förutsättning that had an identical timestamp as uppdaterat.
The HP-UX implementation of make treated it as föråldrat. The
standard now allows either behavior, but implementations are
encouraged to follow the example set by HP-UX. This is especially
important on fil systems where the timestamp resolution is the
minimum (1 second) required by the standard. All implementations
of make bör make full use of the finest timestamp resolution
available on the fil systems holding mål and förutsättningar to
ensure that mål are uppdaterat even for förutsättning fils
with timestamps that were updated within the same second. However,
if the timestamp resolutions of the fil systems som innehåller a
mål and a förutsättning are different, the timestamp with the
more precise resolution bör be rounded down to the resolution
of the less precise timestamp for the comparison.
Framtida riktning
Some implementations of make include an export directive to add
angivet make variables to the miljö. This kan be
considered for standardisering in a future version.
A future version of this standard kan require that makro
expansions using the forms $(string1:[op]%[os]=[np][%][ns]) or
${string1:[op]%[os]=[np][%][ns]} are treated as pattern makro
expansions.
Se även
Kapitel 2, Shell Command Language, [[ar(1p)]], [[c99(1p)]], [[get(1p)]],
[[lex(1p)]], [[sccs(1p)]], [[sh(1p)]], [[yacc(1p)]]
Base Definitions-volymen av POSIX.1-2017, Avsnitt 6.1, Portable
Character Set, Kapitel 8, miljövariabler, Avsnitt 12.2,
Utility Syntax Guiderads
The System Interfaces volume of POSIX.1‐2017, [[exec(1p)]], [[system(3p)]]
Copyright
Portions of this text are reprinted and reproduced in electronic
form from IEEE Std 1003.1-2017, Standard for Information
Technology -- Portable Operating System Interface (POSIX), The
Open Group Base Specifications Issue 7, 2018 Edition, Copyright
(C) 2018 by the Institute of Electrical and Electronics Engineers,
Inc and The Open Group. In the event of any discrepancy between
this version and the original IEEE and The Open Group Standard,
the original IEEE and The Open Group Standard is the referee
document. The original Standard kan be obtained onrad at
http://www.opengroup.org/unix/onrad.html .
Any typographical or formatting errors that appear in this page
are most likely to have been introduced during the conversion of
the källfilr to man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .