|
|
| (En mellanliggande sidversion av samma användare visas inte) |
| Rad 2: |
Rad 2: |
|
| |
|
| == Namn == | | == Namn == |
| '''make''' – underhålla, uppdatera och återskapa grupper av program ('''UTVECKLING''') | | '''make''' – underhåller, uppdaterar och återskapar grupper av program ('''UTVECKLING''') |
| | |
|
| |
|
| == Prolog == | | == Prolog == |
|
| |
|
| <pre>
| | Denna manualsida är en del av POSIX Programmer's Manual. Linux-implementationen av detta gränssnitt kan skilja sig från POSIX-beskrivningen. Se motsvarande Linux-manualsida för detaljer om Linux-beteende. Gränssnittet kan också saknas helt på vissa Linux-system. |
| 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 == | | == Synopsis == |
|
| |
|
| <pre> | | <pre> |
| make [-einpqrst] [-f makefil]... [-k|-S] [makro=värde...]
| | make [-einpqrst] [-f makefile]... [-k|-S] [macro=value...] |
| [mål_name...]
| | [target_name...] |
| </pre> | | </pre> |
|
| |
|
| |
|
| == Beskrivning == | | == Beskrivning == |
|
| |
|
| <pre>
| | Verktyget '''make''' uppdaterar filer som härleds från andra filer. Ett typiskt fall är när objektfiler byggs från motsvarande källkodsfiler. '''make''' undersöker tidsstämplar och uppdaterar de härledda filer, kallade mål, vars ändringstid är äldre än ändringstiden för de filer de beror på, kallade förutsättningar eller beroenden. |
| 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
| | En beskrivningsfil, normalt kallad en makefil, beskriver relationerna mellan filer samt de kommandon som måste köras för att uppdatera mål när deras beroenden har ändrats. Varje specifikation, eller regel, består av ett mål, valfria beroenden och valfria kommandon som ska köras när ett beroende är nyare än målet. |
|
| |
|
| In addition, make ska have a collection of inbyggda makron and
| | Det finns två typer av regler: |
| inference regels that infer förutsättning relationships to simplify
| |
| maintenance of programs.
| |
|
| |
|
| To receive exactly the behavior described in this section, the
| | # '''Härledningsregler''' – regler med ett enda målnamn som innehåller minst en punkt (`.`) och inget snedstreck (`/`). |
| user ska ensure that a portable makefil ska:
| | # '''Målregler''' – regler som kan ha mer än ett målnamn. |
|
| |
|
| * Include the special mål .POSIX
| | Utöver regler i makefilen ska '''make''' ha en uppsättning inbyggda makron och härledningsregler som kan dra slutsatser om beroenden för att förenkla underhåll av program. |
|
| |
|
| * Omit any special mål reserved for implementations (a
| | För att få exakt det beteende som POSIX beskriver ska en portabel makefil: |
| 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
| | * innehålla det särskilda målet '''.POSIX''' |
| conditions are not met.
| | * inte använda särskilda mål som är reserverade för implementationer, det vill säga mål som börjar med punkt följt av versaler, om de inte uttryckligen anges i POSIX-avsnittet |
| </pre>
| |
|
| |
|
| | Om något av dessa villkor inte uppfylls är beteendet ospecificerat. |
|
| |
|
| == Flaggor == | | == Flaggor == |
|
| |
|
| <pre>
| | Verktyget '''make''' ska följa POSIX.1-2017, Base Definitions, avsnitt 12.2, Utility Syntax Guidelines, med undantag för riktlinje 9. |
| 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
| | Följande flaggor stöds: |
| värdes, to override makro assignments within makefils.
| |
|
| |
|
| -f makefil
| | '''-e''' |
| Specify a different makefil. The argument makefil is a
| | : Gör att miljövariabler, även sådana med tomma värden, åsidosätter makrotilldelningar i makefiler. |
| 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
| | '''-f''' ''makefile'' |
| mode is the same as if the special mål .IGNORE were
| | : Anger en annan makefil. Argumentet ''makefile'' är sökvägen till en beskrivningsfil. Sökvägen `-` betyder standard in. Flaggan kan förekomma flera gånger och behandlas då i den ordning den anges. Effekten av att ange samma argument flera gånger är ospecificerad. |
| angivet without förutsättningar.
| |
|
| |
|
| -k Continue to update other mål that do not depend on
| | '''-i''' |
| the current mål if a non-ignored error occurs while
| | : Ignorera felkoder från körda kommandon. Detta motsvarar att det särskilda målet '''.IGNORE''' anges utan beroenden. |
| executing the kommandon to bring a mål uppdaterat.
| |
|
| |
|
| -n Write kommandon that would be executed on standard
| | '''-k''' |
| output, but do not execute them. However, rads with a
| | : Fortsätt uppdatera andra mål som inte beror på det mål där ett fel inträffade. Detta gäller när ett icke ignorerat fel uppstår under körning av kommandon. |
| <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
| | '''-n''' |
| definitions and mål descriptions. The output format
| | : Skriv ut de kommandon som skulle ha körts, men kör dem inte. Kommandorader med prefixet `+` ska dock köras. I detta läge skrivs även rader med `@`-prefix ut. |
| is ospecificerat.
| |
|
| |
|
| -q Return a zero slutvärde if the mål fil is up-to-
| | '''-p''' |
| date; otherwise, return an slutvärde of 1. Targets
| | : Skriv ut den fullständiga uppsättningen makrodefinitioner och målbeskrivningar till standard ut. Utdataformatet är ospecificerat. |
| 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.
| | '''-q''' |
| | : Returnera noll om målet är uppdaterat, annars 1. Inga mål ska uppdateras. Kommandorader med `+`-prefix ska dock köras. |
|
| |
|
| -S Terminate make if an error occurs while executing the
| | '''-r''' |
| kommandon to bring a mål uppdaterat. This ska be the
| | : Töm suffixlistan och använd inte de inbyggda reglerna. |
| default and the opposite of -k.
| |
|
| |
|
| -s Do not skriv makefil kommando rads or touch messages
| | '''-S''' |
| (see -t) to standard ut before executing. This mode
| | : Avsluta '''make''' om ett fel inträffar när kommandon körs för att uppdatera ett mål. Detta är standardbeteendet och motsatsen till '''-k'''. |
| 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
| | '''-s''' |
| touch mål had been executed. Targets that have
| | : Skriv inte ut makefilens kommandorader eller meddelanden från '''-t''' innan de körs. Detta motsvarar att det särskilda målet '''.SILENT''' anges utan beroenden. |
| 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
| | '''-t''' |
| be evaluated before any flaggas angivet on verktyget make
| | : Uppdatera ändringstiden för varje mål som om kommandot `touch mål` hade körts. Mål som har beroenden men inga kommandon, eller som redan är uppdaterade, ska inte ändras på detta sätt. Ett meddelande ska skrivas för varje fil som rörs. Normalt körs inte kommandoraderna för målet, men kommandorader med `+`-prefix ska köras. |
| 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.
| |
| </pre>
| |
|
| |
|
| | Flaggor i miljövariabeln '''MAKEFLAGS''' ska behandlas före flaggor på kommandoraden. Om både '''-k''' och '''-S''' anges, antingen via kommandoraden eller '''MAKEFLAGS''', gäller den senast angivna flaggan. Om '''-f''' eller '''-p''' förekommer i '''MAKEFLAGS''' är resultatet odefinierat. |
|
| |
|
| == Operander == | | == Operander == |
|
| |
|
| <pre>
| | '''target_name''' |
| The following operander ska be supported:
| | : Namn på mål enligt den utökade beskrivningen. Om inget mål anges används det första mål som '''make''' hittar under läsningen av makefilerna och som inte är ett särskilt mål eller en härledningsregel. |
|
| |
|
| mål_name
| | '''macro=value''' |
| Target names, as defined in the EXTENDED DESCRIPTION
| | : Makrodefinition enligt avsnittet om makron. |
| 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.
| |
| </pre>
| |
|
| |
|
| | Om mål och makrodefinitioner blandas på kommandoraden är resultatet ospecificerat. |
|
| |
|
| == Standard in == | | == Standard in == |
|
| |
|
| <pre>
| | Standard in används endast om argumentet till '''-f''' är `-`. Se avsnittet om indatafiler. |
| The standard in ska be used only if the makefil flagga-
| |
| argument is '-'. See the INPUT FILES section.
| |
| </pre>
| |
| | |
|
| |
|
| == Indatafiler == | | == Indatafiler == |
|
| |
|
| <pre>
| | Indatafilen, även kallad makefilen, är en textfil som innehåller regler, makrodefinitioner, inkluderingsrader och kommentarer. Formatet beskrivs i den utökade beskrivningen. |
| Indatafiln, otherwise known as the makefil, is a textfil
| |
| som innehåller regels, makrodefinitioner, include rads, and kommentarer.
| |
| See the EXTENDED DESCRIPTION section.
| |
| </pre>
| |
| | |
|
| |
|
| == Miljövariabler == | | == Miljövariabler == |
|
| |
|
| <pre>
| | Följande miljövariabler påverkar körningen av '''make''': |
| 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
| | '''LANG''' |
| Determine the locale that bör be used to affect the
| | : Anger standardvärde för internationaliseringsvariabler som saknas eller är tomma. |
| format and contents of diagnostiska meddelanden skrivet to
| |
| standard fel.
| |
|
| |
|
| MAKEFLAGS
| | '''LC_ALL''' |
| This variable ska be interpreted as a tecken string
| | : Om denna är satt till ett icke-tomt värde åsidosätter den alla andra internationaliseringsvariabler. |
| 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
| | '''LC_CTYPE''' |
| leading <bindestreck-minus> tecken or <blank>
| | : Bestämmer hur byte-sekvenser i argument och indata tolkas som tecken. |
| separation used on a make verktyg kommando rad.
| |
|
| |
|
| * The tecken are formatted in a manner similar to
| | '''LC_MESSAGES''' |
| a portion of verktyget make kommando rad: flaggas
| | : Bestämmer språk och format för diagnostiska meddelanden till standard fel. |
| 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
| | '''MAKEFLAGS''' |
| bearbetning of LC_MESSAGES.
| | : Innehåller standardflaggor för '''make'''. Implementationer ska acceptera både format med enbart flaggbokstäver utan bindestreck och ett kommandoradsliknande format med bindestreck och blanksteg. Makrodefinitioner av formen `macro=value` kan också ingå. Innehållet i variabeln genomgår inte samma ordexpansion som kommandoraden. |
|
| |
|
| PROJECTDIR
| | '''NLSPATH''' |
| Provide a katalog to be used to search for SCCS fils
| | : Bestämmer var meddelandekataloger för '''LC_MESSAGES''' ska sökas. |
| 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
| | '''PROJECTDIR''' |
| for SCCS fils ska be made in the katalog SCCS in
| | : Anger katalog som används vid sökning efter SCCS-filer som inte finns i aktuell katalog. Sökningen sker i en katalog med namnet '''SCCS''' under den angivna katalogen. |
| the aktuell katalog.
| |
|
| |
|
| The setting of PROJECTDIR affects all fils listed in
| | Om '''PROJECTDIR''' börjar med `/` behandlas den som en absolut sökväg. Annars behandlas värdet som ett användarnamn vars hemkatalog undersöks efter underkatalogerna '''src''' eller '''source'''. Om dessa inte hittas används värdet som en relativ sökväg. Om '''PROJECTDIR''' saknas eller är tom sker sökning i '''SCCS''' under aktuell katalog. |
| 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.
| |
| </pre>
| |
|
| |
|
| | Variabeln '''SHELL''' i miljön ska inte användas som makro och ska inte ändras genom att definiera makrot '''SHELL''' i en makefil eller på kommandoraden. Alla andra miljövariabler, även tomma, ska användas som makron. |
|
| |
|
| == Asynkrona händelser == | | == Asynkrona händelser == |
|
| |
|
| <pre>
| | Om signalerna inte redan ignoreras ska '''make''' fånga SIGHUP, SIGTERM, SIGINT och SIGQUIT och ta bort det aktuella målet, om inte målet är en katalog, är ett beroende till det särskilda målet '''.PRECIOUS''', eller om någon av flaggorna '''-n''', '''-p''' eller '''-q''' angavs. |
| 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.
| |
| </pre>
| |
|
| |
|
| | Mål som tas bort på detta sätt ska rapporteras i diagnostiska meddelanden till standard fel. Efter denna städning ska '''make''' utföra standardåtgärden för övriga signaler. |
|
| |
|
| == Standard ut == | | == Standard ut == |
|
| |
|
| <pre>
| | '''make''' ska skriva de kommandon som ska köras till standard ut, utom när: |
| Verktyget make ska skriv all kommandon to be executed to
| | |
| standard ut unless the -s flagga was angivet, the kommando is
| | * flaggan '''-s''' har angetts |
| prefixed with an snabel-a, or the special mål .SILENT has either
| | * kommandot har prefixet `@` |
| the current mål as a förutsättning or has no förutsättningar. Om
| | * det särskilda målet '''.SILENT''' gäller för målet eller gäller globalt |
| 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.
| |
| </pre>
| |
|
| |
|
| | Om '''make''' körs utan att något behöver göras ska ett meddelande skrivas till standard ut om att ingen åtgärd vidtogs. Om '''-t''' används och en fil rörs ska ett meddelande med filnamnet skrivas. |
|
| |
|
| == Standard fel == | | == Standard fel == |
|
| |
|
| <pre>
| | Standard fel används endast för diagnostiska meddelanden. |
| The standard fel ska be used only for diagnostiska meddelanden.
| |
| </pre>
| |
| | |
|
| |
|
| == Utdatafiler == | | == Utdatafiler == |
|
| |
|
| <pre>
| | Filer kan skapas när flaggan '''-t''' används. Ytterligare filer kan också skapas av verktyg som körs från '''make'''. |
| Filer kan skapas when the -t flagga is present. Additional
| |
| fils kan also be created by the utilities invoked by make.
| |
| </pre>
| |
| | |
|
| |
|
| == Utökad beskrivning == | | == Utökad beskrivning == |
|
| |
|
| <pre>
| | '''make''' försöker utföra de åtgärder som krävs för att de angivna målen ska vara uppdaterade. Ett mål anses uppdaterat om det finns och är nyare än alla sina beroenden, eller om det redan har gjorts uppdaterat av den aktuella körningen av '''make'''. Ett mål kan också anses uppdaterat om det finns, har samma tidsstämpel som ett eller flera beroenden och är nyare än övriga beroenden. |
| 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
| | Alla beroenden behandlas som mål i sig och uppdateras rekursivt i den ordning de förekommer i regeln. Filernas ändringstider används för att avgöra om ett mål är föråldrat. |
| 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
| | För att uppdatera ett mål säkerställer '''make''' först att alla beroenden är uppdaterade. Därefter kontrolleras målet. Om målet inte är uppdaterat körs regelns kommandon. Om målet fortfarande inte finns efter en lyckad uppdatering ska det ändå behandlas som nyare än mål som beror på det. |
| 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 ===
| | Om ett mål finns men saknar både målregel och härledningsregel ska det betraktas som uppdaterat. Det är ett fel om '''make''' försöker uppdatera ett mål som inte finns och det saknas både målregel och härledningsregel. |
| 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:
| | === Makefilens syntax === |
| ./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
| | En makefil kan innehålla regler, makrodefinitioner, inkluderingsrader och kommentarer. Regler finns i två former: härledningsregler och målregler. '''make''' har en uppsättning inbyggda härledningsregler, men dessa används inte om flaggan '''-r''' anges. |
| 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
| | Regler och makron kan definieras flera gånger. För en regel gäller den senast angivna definitionen. För makron gäller de regler som beskrivs i avsnittet om makron. |
| user, whether in ./makefil or its variants, or angivet by the
| |
| -f flagga.
| |
|
| |
|
| The regels in makefils ska consist of the following types of
| | Kommentarer är tomma rader, blanka rader och rader där `#` inleder kommentaren. En kommentar fortsätter till nästa icke-escapade radslut. |
| 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
| | Som standard ska följande filer prövas i ordning: |
| 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
| | <pre> |
| anywhere in the makefil except in a kommando rad, an include
| | ./makefile |
| rad, or a rad immediately preceding an include rad, it ska be
| | ./Makefile |
| replaced, along with any leading blanktecken on the following
| | </pre> |
| 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 ingen hittas får implementationen pröva andra filer. På XSI-system ska även följande prövas: |
| 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
| | <pre> |
| preceding a kommentar, and any kommentar ska be discarded. Om
| | ./s.makefile |
| the resulting string contains any double-quote tecken
| | SCCS/s.makefile |
| ('"') the behavior is ospecificerat.
| | ./s.Makefile |
| | SCCS/s.Makefile |
| | </pre> |
|
| |
|
| * The resulting string ska be bearbetas for makroexpansion
| | Flaggan '''-f''' gör att dessa standardfiler ignoreras och den angivna filen används i stället. Om argumentet är `-` används standard in. |
| (see Makron).
| |
|
| |
|
| * Any <blank> tecken that appear after the first non-<blank>
| | Termen makefil avser alla regler som användaren tillhandahåller, oavsett om de kommer från standardnamnen eller från '''-f'''. |
| 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
| | En omvänt snedstreck-escapad radbrytning utanför kommandorader och inkluderingsrader ersätts, tillsammans med inledande blanktecken på följande rad, med ett enda blanksteg. I kommandorader bevaras det omvända snedstrecket och radbrytningen, men ett inledande tab-tecken på nästa rad tas bort. |
| 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
| | === Inkluderingsrader === |
| 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
| | Om ordet '''include''' står i början av en rad och följs av ett eller flera blanktecken ska resten av raden tolkas som ett filnamn som ska inkluderas. |
| 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
| | Behandlingen sker i huvudsak så här: |
| ska support nesting of include fils up to a depth of at least
| |
| 16.
| |
|
| |
|
| === Makefilkörning ===
| | # Avslutande radbrytning, blanktecken före en kommentar samt själva kommentaren tas bort. |
| Makefil kommando rads ska be bearbetas one at a time.
| | # Strängen expanderas med makron. |
| | # Blanktecken efter det första icke-blanka tecknet används för att dela upp strängen i fält. |
| | # Om resultatet inte blir exakt ett icke-tomt fält är beteendet ospecificerat. |
|
| |
|
| Makefil kommando rads kan have one or more of the following
| | Om sökvägen inte börjar med `/` behandlas den relativt processens aktuella katalog, inte relativt katalogen där makefilen finns. Filens innehåll läses och behandlas som om det stod i makefilen i stället för inkluderingsraden. Inkluderade filer kan själva innehålla inkluderingsrader. Implementationer ska stödja minst 16 nivåers nästling. |
| 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
| | === Körning av makefilen === |
| 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
| | Kommandorader i makefilen behandlas en i taget. En kommandorad kan ha följande prefix: |
| 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,
| | : Fel från kommandot ignoreras. Detta gäller också om '''-i''' används eller om '''.IGNORE''' gäller. |
| -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,
| | : Kommandot skrivs inte ut innan körning, om inte '''-n''' används. Detta gäller också om '''-s''' används eller om '''.SILENT''' gäller. |
| 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
| | : Kommandot körs även om '''-n''', '''-q''' eller '''-t''' används. |
| to standard fel.
| |
|
| |
|
| Target Rules
| | En körningsrad skapas genom att prefixtecknen tas bort. Om raden inte tystas skrivs den till standard ut. Därefter körs den av ett skal som om den skickades till systemgränssnittet `system()`. Om fel inte ignoreras ska skalets `-e`-läge vara aktivt. Miljön för kommandot ska innehålla alla variabler i '''make'''-processens miljö. |
| Target regels are formatted as follows:
| |
|
| |
|
| mål [mål...]: [förutsättning...][;kommando]
| | Som standard avslutas '''make''' med felmeddelande om ett kommando returnerar en status skild från noll. |
| [<tab>kommando
| |
| <tab>kommando
| |
| ...]
| |
|
| |
|
| rad that does not begin with <tab>
| | === Målregler === |
|
| |
|
| Target entries are angivet by a <blank>-separated, non-null list
| | Målregler har formatet: |
| 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
| | <pre> |
| consisting solely of punkts, underscores, digits, and alphabetics
| | target [target...]: [prerequisite...][;command] |
| from the portable tecken set (see the Base Definitions volume
| | <TAB>command |
| of POSIX.1‐2017, Avsnitt 6.1, portabel teckenuppsättning).
| | <TAB>command |
| Implementations kan allow other tecken in mål names as
| | ... |
| extensions. The interpretation of mål som innehåller the
| | </pre> |
| tecken '%' and '"' is implementationsdefinierad.
| |
|
| |
|
| A mål that has förutsättningar, but does not have any kommandon,
| | En målrad består av en eller flera mål, följt av kolon, följt av noll eller flera beroenden. Text efter semikolon och efterföljande rader som börjar med tab är kommandorader. |
| 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
| | Applikationer bör välja målnamn som endast består av punkt, understreck, siffror och bokstäver ur den portabla teckenuppsättningen. Implementationer kan tillåta fler tecken. Tolkningen av mål med `%` eller `"` är implementationsberoende. |
| mål and control the operation of make:
| |
|
| |
|
| .DEFAULT Om the makefil uses this special mål, the
| | Ett mål med beroenden men utan kommandon kan användas för att lägga till beroenden för målet. Endast en målregel för ett visst mål får innehålla kommandon. |
| 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
| | Följande särskilda mål styr '''make''': |
| 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
| | '''.DEFAULT''' |
| angivet without förutsättningar or kommandon. Om it
| | : Om detta mål används ska det ha kommandon men inga beroenden. Kommandona används när inga andra regler finns för att bygga ett mål. |
| 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
| | '''.IGNORE''' |
| borttaget if make receives one of the asynchronous events
| | : Beroenden till detta mål får sina kommandofel ignorerade. Om inga beroenden anges ignoreras fel för alla mål. |
| 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
| | '''.POSIX''' |
| angivet without förutsättningar. Om this special mål
| | : Ska anges utan beroenden och kommandon. Om det förekommer som första icke-kommenterade rad ska makefilen behandlas enligt POSIX. Annars är beteendet ospecificerat. |
| 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
| | '''.PRECIOUS''' |
| ska treat them just like any other mål. Because the
| | : Beroenden till detta mål ska inte tas bort vid de asynkrona händelser som beskrivs ovan. Om inga beroenden anges behandlas alla mål som värdefulla. |
| 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
| | '''.SCCS_GET''' |
| themselves; this ska cause kommandon associated with
| | : Ska anges utan beroenden. Om det förekommer ersätter dess kommandon standardkommandona för hämtning av SCCS-filer. |
| 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
| | '''.SILENT''' |
| of known suffix and are used in conjunction with the
| | : Beroenden till detta mål får sina kommandon tystade. Om inga beroenden anges skrivs inga kommandon eller touch-meddelanden för några mål. |
| 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''' |
| .SUFFIXES ska be angivet without kommandon.
| | : Beroenden till detta mål läggs till suffixlistan och används tillsammans med härledningsregler. Om inga beroenden anges töms suffixlistan. |
|
| |
|
| Targets with names consisting of a leading <punkt> followed by
| | Målen '''.IGNORE''', '''.POSIX''', '''.PRECIOUS''', '''.SILENT''' och '''.SUFFIXES''' ska anges utan kommandon. |
| the uppercase letters "POSIX" and then any other tecken are
| | |
| reserved for future standardisering. Targets with names
| | Mål som börjar med punkt följt av `POSIX` och andra tecken är reserverade för framtida standardisering. Mål som börjar med punkt följt av en eller flera versaler är reserverade för implementationstillägg. |
| consisting of a leading <punkt> followed by one or more uppercase
| |
| letters are reserved for implementeringstillägg.
| |
|
| |
|
| === Makron === | | === Makron === |
| Makrodefinitioner are in the form:
| |
|
| |
|
| string1 = [string2]
| | Makrodefinitioner har formen: |
|
| |
|
| The makro named string1 is defined as having the värde of string2,
| | <pre> |
| where string2 is defined as all tecken, if any, after the
| | string1 = [string2] |
| <equals-sign>, up to a kommentar tecken ('#') or an unescaped
| | </pre> |
| <newrad>. Any <blank> tecken immediately before or after the
| |
| <equals-sign> ska be ignored.
| |
|
| |
|
| Applications ska select makro names from the set of tecken
| | Makrot med namnet ''string1'' får värdet ''string2''. Värdet består av tecknen efter likhetstecknet fram till kommentar eller oescapad radbrytning. Blanktecken omedelbart före och efter likhetstecknet ignoreras. |
| 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
| | Makron expanderas med formerna: |
| 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
| | <pre> |
| is läsas.
| | $(namn) |
| | ${namn} |
| | </pre> |
|
| |
|
| * Makron in makefil kommando rads ska be evaluated when the
| | Parenteser eller klamrar är valfria om namnet är ett enda tecken. `$$` ersätts av ett enda `$`. |
| kommando is executed.
| |
|
| |
|
| * Makron in the string before the <equals-sign> in a makro
| | Makroexpansion sker enligt följande: |
| definition ska be evaluated when the makro assignment is
| |
| made.
| |
|
| |
|
| * Makron after the <equals-sign> in a makro definition ska not
| | * Makron i målrader expanderas när raden läses. |
| be evaluated until the defined makro is used in a regel or
| | * Makron i kommandorader expanderas när kommandot körs. |
| kommando, or before the <equals-sign> in a makro definition.
| | * Makron före likhetstecknet i en makrodefinition expanderas när tilldelningen görs. |
| | * Makron efter likhetstecknet i en makrodefinition expanderas först när makrot används. |
|
| |
|
| The parentheses or braces are flaggaal if string1 is a single
| | Ersättningsformen: |
| 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
| | <pre> |
| ${string1[:subst1=[subst2]]} kan be used to replace all
| | $(namn:från=till) |
| occurrences of subst1 with subst2 when the makro substitution is
| | ${namn:från=till} |
| performed. The subst1 to be replaced ska be recognized when it
| | </pre> |
| 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
| | kan användas för att ersätta förekomster av ett suffix i varje ord i makrovärdet. |
| 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
| | Makrodefinitioner hämtas i denna logiska ordning innan makefilerna läses: |
| the following logical order, before the makefil(s) are läsas.
| |
|
| |
|
| 1. Makron angivet on verktyget make kommando rad, in the
| | # Makron från kommandoraden. |
| order angivet on the kommando rad. It is ospecificerat whether
| | # Makron från '''MAKEFLAGS'''. |
| the internal makros defined in Internal Makron are accepted
| | # Miljövariabler, utom '''MAKEFLAGS''' och '''SHELL'''. |
| from this source.
| | # Inbyggda makron från härledningsregler. |
|
| |
|
| 2. Makron defined by the MAKEFLAGS miljövariabel, in the
| | Makron från en högre prioriterad källa åsidosätter inte lägre numrerade källor enligt POSIX-reglerna. Makron i makefilen åsidosätter tidigare definitioner i makefilen och inbyggda makron. Om '''-e''' inte anges åsidosätter makefilens makron också miljön. Makron i makefilen åsidosätter inte makron från kommandoraden eller '''MAKEFLAGS'''. |
| 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
| | Makrot '''SHELL''' behandlas särskilt. Det tillhandahålls av '''make''' och ska ange sökvägen till skalets kommandotolk. Miljövariabeln '''SHELL''' påverkar inte makrot. Om '''SHELL''' definieras i makefilen eller på kommandoraden ersätter det makrot, men påverkar inte miljövariabeln '''SHELL'''. |
| SHELL variables and inklusive the variables with null värdes.
| |
|
| |
|
| 4. Makron defined in the inference regels built into make.
| | === Härledningsregler === |
|
| |
|
| Makrodefinitioner from these sources ska not override makro
| | Härledningsregler har formatet: |
| 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
| | <pre> |
| that occur before them in the makefil(s) and makrodefinitioner
| | target: |
| from source 4. Om the -e flagga is not angivet, makros defined
| | <TAB>command |
| in the makefil(s) ska override makrodefinitioner from source 3.
| | <TAB>command |
| === Makron === defined in the makefil(s) ska not override makro
| | ... |
| definitions from source 1 or source 2.
| | </pre> |
|
| |
|
| Before the makefil(s) are läsas, all of verktyget make kommando
| | Måldelen ska ha formen `.s2` eller `.s1.s2`, där suffixen finns i '''.SUFFIXES''' och inte innehåller snedstreck eller punkt. En regel med ett suffix är en enkel suffixregel. En regel med två suffix är en dubbel suffixregel. |
| 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
| | Härledningsregler får inte ha beroenden. De kan omdefinieras. En tom regel kan skapas med enbart semikolon: |
| 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
| | <pre> |
| by make and set to the sökväg of the skal kommando language
| | regel: ; |
| interpreter (see [[sh(1p)]]). The SHELL miljövariabel ska
| | </pre> |
| 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
| | '''make''' använder suffixen för mål och beroenden för att avgöra hur ett mål kan göras uppdaterat. Om ingen målregel finns undersöks härledningsreglerna. Suffixet för målet jämförs med suffixlistan i '''.SUFFIXES'''. Den första regel som matchar och där motsvarande beroendefil finns används. |
| Inference regels are formatted as follows:
| |
|
| |
|
| mål:
| | Om ett mål saknar suffix och ingen målregel finns prövas enkla suffixregler. Regeln `.s2` beskriver hur mål kan byggas från `mål.s2`. |
| <tab>kommando
| |
| [<tab>kommando]
| |
| ...
| |
|
| |
|
| rad that does not begin with <tab> or #
| | Tilde (`~`) i dessa regler avser en SCCS-fil i aktuell katalog. Exempelvis betyder `.c~.o` att ett SCCS-lagrat C-källfilsmål kan transformeras till en objektfil. |
|
| |
|
| The application ska ensure that the mål portion is a valid
| | === Bibliotek === |
| 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
| | Om ett mål eller beroende innehåller parenteser behandlas det som en medlem i ett arkivbibliotek. Formen: |
| 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
| | <pre> |
| finnsing inference regel ska overskriv the old inference regel. An
| | lib(member.o) |
| empty regel kan be created with a kommando consisting of simply a
| | </pre> |
| <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: ;
| | betyder att ''lib'' är arkivbiblioteket och ''member.o'' är medlemmen. Medlemmen ska vara en objektfil med suffixet `.o`. Ändringstiden för uttrycket är ändringstiden för medlemmen i arkivet. Suffixet `.a` avser arkivbibliotek. Regeln `.s2.a` används för att uppdatera en medlem i biblioteket från en fil med suffixet `.s2`. |
|
| |
|
| where zero or more <blank> tecken separate the <kolon> and
| | === Interna makron === |
| <semikolon>.
| |
|
| |
|
| Verktyget make uses the suffix of mål and their
| | '''make''' tillhandahåller fem interna makron som kan användas i mål- och härledningsregler: |
| 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
| | : Det fullständiga namnet på aktuellt mål, eller arkivfilens namn när målet är en biblioteksmedlem. |
| 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
| | : Utvärderas endast när aktuellt mål är en biblioteksmedlem av formen `libname(member.o)`. Då är `$@` biblioteket och `$%` medlemmen. |
| 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
| | : Listan över beroenden som är nyare än det aktuella målet. |
| 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
| | : I en härledningsregel: filnamnet vars existens gjorde att regeln valdes. I `.DEFAULT`: aktuellt målnamn. I andra sammanhang är betydelsen ospecificerad. |
| 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
| | : Aktuellt målnamn med suffixet borttaget. Ska åtminstone utvärderas för härledningsregler. |
| 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 ===
| | Varje internt makro har också former med '''D''' och '''F''' tillagda, till exempel `$(<D)` och `$(<F)`. '''D''' ger katalogdelen och '''F''' ger filnamnsdelen. För aktuell katalog är katalogdelen `.`. |
| 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
| | För ett mål av formen `lib(member.o)` och regeln `.s2.a` gäller: |
| 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
| | <pre> |
| particular mål. Inference regels are user-angivet or make-
| | $< member.s2 |
| angivet regels for a particular class of mål name. Explicit
| | $* member |
| förutsättningar are those förutsättningar angivet in a makefil on
| | $@ lib |
| mål rads. Implicit förutsättningar are those förutsättningar that
| | $? member.s2 |
| are generated when inference regels are used. Inference regels are
| | $% member.o |
| applied to implicit förutsättningar or to explicit förutsättningar
| | </pre> |
| 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
| | === Standardregler === |
| 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:
| | Standardreglerna för '''make''' ska ge samma resultat som följande principer. Implementationer som saknar vissa utvecklingsverktyg kan utelämna motsvarande makron och regler. |
|
| |
|
| * A mål angivet in the makefil
| | Särskilda mål: |
|
| |
|
| * An explicit förutsättning angivet in the makefil that
| | <pre> |
| becomes the mål when make processes it during recursion
| | .SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ |
| | .SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~ |
| | </pre> |
|
| |
|
| * An implicit förutsättning that becomes a mål when make
| | Standardmakron: |
| processes it during recursion
| |
|
| |
|
| In the definitions that follow, the word förutsättning refers to
| | <pre> |
| one of the following:
| | 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 |
| | </pre> |
|
| |
|
| * An explicit förutsättning angivet in the makefil for a
| | Exempel på enkla suffixregler: |
| particular mål
| |
|
| |
|
| * An implicit förutsättning generated as a result of locating an
| | <pre> |
| appropriate inference regel and corresponding fil that matches
| | .c: |
| the suffix of the mål
| | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< |
|
| |
|
| The five internal makros are:
| | .f: |
| | $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $< |
|
| |
|
| $@ The $@ ska evaluate to the full mål name of the
| | .sh: |
| current mål, or the archive filname part of a library
| | cp $< $@ |
| archive mål. It ska be evaluated for both mål and
| | chmod a+x $@ |
| inference regels.
| | </pre> |
|
| |
|
| For example, in the .c.a inference regel, $@ represents the
| | Exempel på dubbla suffixregler: |
| 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
| | <pre> |
| mål is an arkivbibliotek medlem of the form
| | .c.o: |
| libname(medlem.o). In these cases, $@ ska evaluate to
| | $(CC) $(CFLAGS) -c $< |
| 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
| | .f.o: |
| lib.a(fil.o), $% represents fil.o, as opposed to $@,
| | $(FC) $(FFLAGS) -c $< |
| which represents lib.a.
| |
|
| |
|
| $? The $? makro ska evaluate to the list of förutsättningar
| | .y.o: |
| that are nyare än the current mål. It ska be
| | $(YACC) $(YFLAGS) $< |
| evaluated for both mål and inference regels.
| | $(CC) $(CFLAGS) -c y.tab.c |
| | rm -f y.tab.c |
| | mv y.tab.o $@ |
|
| |
|
| For example, in a makefil mål regel to build prog from
| | .l.o: |
| fil1.o, fil2.o, and fil3.o, and where prog is not out-
| | $(LEX) $(LFLAGS) $< |
| of-date with respect to fil1.o, but is föråldrat with
| | $(CC) $(CFLAGS) -c lex.yy.c |
| respect to fil2.o and fil3.o, $? represents fil2.o and
| | rm -f lex.yy.c |
| fil3.o.
| | mv lex.yy.o $@ |
|
| |
|
| $< In an inference regel, the $< makro ska evaluate to the
| | .y.c: |
| filname whose finnsence allowed the inference regel to be
| | $(YACC) $(YFLAGS) $< |
| chosen for the mål. In the .DEFAULT regel, the $< makro
| | mv y.tab.c $@ |
| 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
| | .l.c: |
| förutsättning .c fil.
| | $(LEX) $(LFLAGS) $< |
| | mv lex.yy.c $@ |
| | </pre> |
|
| |
|
| $* The $* makro ska evaluate to the current mål name
| | Standardregler för SCCS-varianter använder '''get''' för att hämta källfilen innan kompilering. |
| with its suffix deleted. It ska be evaluated at least
| |
| for inference regels.
| |
|
| |
|
| For example, in the .c.a inference regel, $*.o represents
| | == Slutstatus == |
| 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
| | När flaggan '''-q''' används ska '''make''' avsluta med: |
| 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
| | '''0''' |
| makros ska be defined as:
| | : Lyckad körning. Målet är uppdaterat. |
|
| |
|
| $< medlem.s2
| | '''1''' |
| | : Målet var inte uppdaterat. |
|
| |
|
| $* medlem
| | '''>1''' |
| | : Ett fel inträffade. |
|
| |
|
| $@ lib
| | När '''-q''' inte används ska '''make''' avsluta med: |
|
| |
|
| $? medlem.s2
| | '''0''' |
| | : Lyckad körning. |
|
| |
|
| $% medlem.o
| | '''>0''' |
| | : Ett fel inträffade. |
|
| |
|
| === Standardregler === | | == Följder av fel == |
| 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
| | Standardbeteende enligt POSIX. Följande avsnitt är informativa. |
|
| |
|
| .SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
| | == Användning i program == |
|
| |
|
| .SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~
| | Om det finns en källfil, till exempel `./source.c`, och två SCCS-filer som motsvarar den, exempelvis `./s.source.c` och `./SCCS/s.source.c`, använder '''make''' på XSI-system SCCS-filen i aktuell katalog. Användare rekommenderas ändå att använda de underliggande SCCS-verktygen eller kommandot '''sccs''' konsekvent för alla källfiler i en katalog. |
|
| |
|
| MACROS
| | Portabla makefiler bör alltid ange det särskilda målet '''.POSIX''' för att undvika påverkan från lokala tillägg. |
|
| |
|
| MAKE=make
| | Flaggorna '''-k''' och '''-S''' finns båda för att relationen mellan kommandoraden, '''MAKEFLAGS''' och makefilen ska kunna styras exakt. |
| 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
| | När '''-n''' används läggs den alltid till i '''MAKEFLAGS'''. Detta gör att rekursiv körning med `make -n mål` visar hela den åtgärdssekvens som skulle köras. |
|
| |
|
| .c:
| | Historisk praxis gör att `#` inuti en variabel tolkas som början på en kommentar. Detta gör det svårt att lägga ett `#`-tecken i en variabel, exempelvis: |
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
| |
|
| |
|
| .f:
| | <pre> |
| $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<
| | CFLAGS = "-D COMMENT_CHAR='#'" |
| | </pre> |
|
| |
|
| .sh:
| | Många historiska implementationer slutar kedja härledningsregler när ett mellanliggande mål saknas. Exempelvis kan `.y.c` och `.c.o` teoretiskt bygga `.o` från `.y`, men '''make''' kan i stället kräva en direkt `.y.o`-regel. |
| cp $< $@
| |
| chmod a+x $@
| |
|
| |
|
| .c~:
| | Det bästa sättet att skriva portabla makefiler är att själv ange alla regler som behövs i makefilen. |
| $(GET) $(GFLAGS) -p $< > $*.c
| |
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c
| |
|
| |
|
| .f~:
| | Makron inuti andra makron expanderas när det nya makrot används, inte när det definieras. Exempel: |
| $(GET) $(GFLAGS) -p $< > $*.f
| |
| $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f
| |
|
| |
|
| .sh~:
| | <pre> |
| $(GET) $(GFLAGS) -p $< > $*.sh
| | MACRO = value1 |
| cp $*.sh $@
| | NEW = $(MACRO) |
| chmod a+x $@
| | MACRO = value2 |
|
| |
|
| DOUBLE SUFFIX RULES
| | target: |
| | echo $(NEW) |
| | </pre> |
|
| |
|
| .c.o:
| | Detta skriver `value2`, inte `value1`. |
| $(CC) $(CFLAGS) -c $<
| |
|
| |
|
| .f.o:
| | Vissa historiska program har blandat mål och makrodefinitioner på kommandoraden och förväntat sig att alla makron behandlas före mål. Portabla program ska inte göra så. |
| $(FC) $(FFLAGS) -c $<
| |
|
| |
|
| .y.o:
| | Följande tecken i filnamn kan orsaka problem: |
| $(YACC) $(YFLAGS) $<
| |
| $(CC) $(CFLAGS) -c y.tab.c
| |
| rm -f y.tab.c
| |
| mv y.tab.o $@
| |
|
| |
|
| .l.o:
| | <pre> |
| $(LEX) $(LFLAGS) $<
| | = : ` ' @ |
| $(CC) $(CFLAGS) -c lex.yy.c
| | </pre> |
| rm -f lex.yy.c
| |
| mv lex.yy.o $@
| |
|
| |
|
| .y.c:
| | I inkluderingsfilnamn bör även mönstertecken och citattecken undvikas. |
| $(YACC) $(YFLAGS) $<
| |
| mv y.tab.c $@
| |
|
| |
|
| .l.c:
| | För härledningsregler kan `$<` och `$?` verka lika, men de skiljer sig. Om en makefil innehåller: |
| $(LEX) $(LFLAGS) $<
| |
| mv lex.yy.c $@
| |
|
| |
|
| .c~.o:
| | <pre> |
| $(GET) $(GFLAGS) -p $< > $*.c
| | foo.o: foo.h |
| $(CC) $(CFLAGS) -c $*.c
| | </pre> |
|
| |
|
| .f~.o:
| | och `foo.h` är nyare än `foo.o`, men `foo.c` är äldre än `foo.o`, används den inbyggda regeln från `foo.c`, med `$<` lika med `foo.c` och `$?` lika med `foo.h`. Om även `foo.c` är nyare än `foo.o`, blir `$?` lika med `foo.h foo.c`. |
| $(GET) $(GFLAGS) -p $< > $*.f
| |
| $(FC) $(FFLAGS) -c $*.f
| |
|
| |
|
| .y~.o:
| | Ett mål utan beroenden och utan kommandon, där målfilen inte finns, behandlas som uppdaterat när regeln körs. Detta innebär att alla mål som beror på detta mål alltid får sina kommandon körda. |
| $(GET) $(GFLAGS) -p $< > $*.y
| |
| $(YACC) $(YFLAGS) $*.y
| |
| $(CC) $(CFLAGS) -c y.tab.c
| |
| rm -f y.tab.c
| |
| mv y.tab.o $@
| |
|
| |
|
| .l~.o:
| | På filsystem med låg tidsupplösning kan sekvenser som: |
| $(GET) $(GFLAGS) -p $< > $*.l
| |
| $(LEX) $(LFLAGS) $*.l
| |
| $(CC) $(CFLAGS) -c lex.yy.c
| |
| rm -f lex.yy.c
| |
| mv lex.yy.o $@
| |
|
| |
|
| .y~.c:
| | <pre> |
| $(GET) $(GFLAGS) -p $< > $*.y
| | make; cp original copy; make |
| $(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
| |
| </pre> | | </pre> |
|
| |
|
| | ge problem, beroende på om implementationen betraktar identiska tidsstämplar som uppdaterade eller föråldrade. |
|
| |
|
| == Slutstatus ==
| | Standarden anger inte prioritet mellan makrodefinitioner och inkluderingsdirektiv. Därför är beteendet för: |
|
| |
|
| <pre> | | <pre> |
| När the -q flagga is angivet, verktyget make ska exit with
| | include =foo.mk |
| one of the following värdes:
| | </pre> |
|
| |
|
| 0 Lyckad avslutning.
| | ospecificerat. Om syftet är att definiera en variabel med namnet `include` bör blanktecknet före likhetstecknet tas bort eller ett annat makro användas. |
|
| |
|
| 1 The mål was not uppdaterat.
| | == Exempel == |
|
| |
|
| >1 Ett fel inträffade.
| | Följande kommando bygger standardmålet i aktuell katalog: |
|
| |
|
| När the -q flagga is not angivet, verktyget make ska exit
| | <pre> |
| with one of the following värdes:
| | make |
| | |
| 0 Lyckad avslutning.
| |
| | |
| >0 Ett fel inträffade.
| |
| </pre> | | </pre> |
|
| |
|
| | | Följande kommando använder en särskild makefil: |
| == Följder av fel ==
| |
|
| |
|
| <pre> | | <pre> |
| Standard.
| | make -f projekt.mk |
| | |
| Följande avsnitt är informativa.
| |
| </pre> | | </pre> |
|
| |
|
| | | Följande kommando visar vad som skulle köras utan att köra kommandona: |
| == Användning i program ==
| |
|
| |
|
| <pre> | | <pre> |
| Om there is a source fil (such as ./source.c) and there are two
| | make -n |
| 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)
| |
| </pre> | | </pre> |
|
| |
|
| | | Följande kommando bygger ett specifikt mål: |
| == Exempel ==
| |
|
| |
|
| <pre> | | <pre> |
| 1. The following kommando:
| | make install |
| | |
| 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
| |
| </pre> | | </pre> |
|
| |
|
| | | Följande är ett enkelt exempel på en makefil: |
| == Motivering ==
| |
|
| |
|
| <pre> | | <pre> |
| Verktyget make described in this volume of POSIX.1‐2017 is
| | .POSIX: |
| 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
| | prog: main.o util.o |
| ground for vendor and research organization-specific syntax
| | c99 -o prog main.o util.o |
| modifications and extensions. Exempel include:
| |
|
| |
|
| * Syntax supporting parallel execution (such as from various | | main.o: main.c util.h |
| multi-processor vendors, GNU, and others)
| | c99 -c main.c |
|
| |
|
| * Additional ``operators'' separating mål and their
| | util.o: util.c util.h |
| förutsättningar (System V, BSD, and others)
| | c99 -c util.c |
| | | </pre> |
| * 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
| | Om `main.c` eller `util.h` är nyare än `main.o` byggs `main.o` om. Om `main.o` eller `util.o` är nyare än `prog` länkas programmet om. |
| 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
| | == Bakgrund och motivering == |
| 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
| | POSIX-beskrivningen av '''make''' är avsedd att ange ett portabelt kärnbeteende, trots att historiska implementationer av '''make''' har haft många lokala tillägg. Kravet på målet '''.POSIX''' gör det möjligt för en makefil att uttryckligen begära POSIX-beteende. |
| 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
| | Flaggorna '''-k''' och '''-S''' finns för att både fortsätt-efter-fel och stoppa-vid-fel ska kunna styras tydligt, även vid rekursiva körningar. |
| 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
| | Reglerna kring '''MAKEFLAGS''' gör att rekursiva '''make'''-körningar kan ärva relevanta flaggor från föräldraprocessen. |
| 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.
| |
| </pre>
| |
|
| |
|
| | POSIX specificerar inte alla historiska specialfall. Därför bör portabla makefiler undvika implementationsegna mål, ovanliga tecken i filnamn och antaganden om hur långt kedjade härledningsregler följs. |
|
| |
|
| == Framtida riktning == | | == Framtida riktning == |
|
| |
|
| <pre>
| | Inga framtida ändringar anges. |
| 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
| | == Se även == |
| expansions using the forms $(string1:[op]%[os]=[np][%][ns]) or
| |
| ${string1:[op]%[os]=[np][%][ns]} are treated as pattern makro
| |
| expansions.
| |
| </pre>
| |
|
| |
|
| | [[ar(1p)]], [[c99(1p)]], [[get(1p)]], [[sh(1p)]], [[touch(1p)]] |
|
| |
|
| == Se även ==
| | POSIX.1-2017, Base Definitions, avsnitt 12.2, Utility Syntax Guidelines. |
|
| |
|
| <pre>
| | == Upphovsrätt == |
| 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
| | Delar av denna text återges och reproduceras elektroniskt från IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright © 2018 Institute of Electrical and Electronics Engineers, Inc. och The Open Group. |
| Character Set, Kapitel 8, miljövariabler, Avsnitt 12.2,
| |
| Utility Syntax Guiderads
| |
|
| |
|
| The System Interfaces volume of POSIX.1‐2017, [[exec(1p)]], [[system(3p)]]
| | Vid skillnader mellan denna version och den ursprungliga IEEE/The Open Group-standarden är originalstandarden den avgörande referensen. Originalstandarden finns tillgänglig online från The Open Group. |
| </pre>
| |
|
| |
|
| | Eventuella typografiska fel eller formateringsfel i denna manualsida har sannolikt uppstått vid konverteringen till manualsidesformat. |
|
| |
|
| == Copyright == | | = Sidslut = |
|
| |
|
| <pre>
| | Orginalhemsidan på Engelska https://man7.org/linux/man-pages/man1/make.1p.html |
| Portions of this text are reprinted and reproduced in electronic
| | Det här är en maskinöversättning av Linux man sidor till svenska. Om du hittar fel är vi tacksamma om du rapporterar dem via formuläret som finns på |
| form from IEEE Std 1003.1-2017, Standard for Information
| | https://www.linux.se/kontaka-linux-se/ |
| Technology -- Portable Operating System Interface (POSIX), The
| | <BR><BR>Tack till [https://datorhjalp.se/web/datorhjalp-hemma// Datorhjälp hemma] som har sponsrat [https://www.linux.se Linux.se] med webbhotell. |
| 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
| | [[Kategori:Linuxmanual grupp 1]] |
| are most likely to have been introduced during the conversion of
| | [[Kategori:Linuxmanual]] |
| the källfilr to man page format. To report such errors, see
| |
| https://www.kernel.org/doc/man-pages/reporting_bugs.html .
| |
| </pre>
| |
Namn
make – underhåller, uppdaterar och återskapar grupper av program (UTVECKLING)
Prolog
Denna manualsida är en del av POSIX Programmer's Manual. Linux-implementationen av detta gränssnitt kan skilja sig från POSIX-beskrivningen. Se motsvarande Linux-manualsida för detaljer om Linux-beteende. Gränssnittet kan också saknas helt på vissa Linux-system.
Synopsis
make [-einpqrst] [-f makefile]... [-k|-S] [macro=value...]
[target_name...]
Beskrivning
Verktyget make uppdaterar filer som härleds från andra filer. Ett typiskt fall är när objektfiler byggs från motsvarande källkodsfiler. make undersöker tidsstämplar och uppdaterar de härledda filer, kallade mål, vars ändringstid är äldre än ändringstiden för de filer de beror på, kallade förutsättningar eller beroenden.
En beskrivningsfil, normalt kallad en makefil, beskriver relationerna mellan filer samt de kommandon som måste köras för att uppdatera mål när deras beroenden har ändrats. Varje specifikation, eller regel, består av ett mål, valfria beroenden och valfria kommandon som ska köras när ett beroende är nyare än målet.
Det finns två typer av regler:
- Härledningsregler – regler med ett enda målnamn som innehåller minst en punkt (`.`) och inget snedstreck (`/`).
- Målregler – regler som kan ha mer än ett målnamn.
Utöver regler i makefilen ska make ha en uppsättning inbyggda makron och härledningsregler som kan dra slutsatser om beroenden för att förenkla underhåll av program.
För att få exakt det beteende som POSIX beskriver ska en portabel makefil:
- innehålla det särskilda målet .POSIX
- inte använda särskilda mål som är reserverade för implementationer, det vill säga mål som börjar med punkt följt av versaler, om de inte uttryckligen anges i POSIX-avsnittet
Om något av dessa villkor inte uppfylls är beteendet ospecificerat.
Flaggor
Verktyget make ska följa POSIX.1-2017, Base Definitions, avsnitt 12.2, Utility Syntax Guidelines, med undantag för riktlinje 9.
Följande flaggor stöds:
-e
- Gör att miljövariabler, även sådana med tomma värden, åsidosätter makrotilldelningar i makefiler.
-f makefile
- Anger en annan makefil. Argumentet makefile är sökvägen till en beskrivningsfil. Sökvägen `-` betyder standard in. Flaggan kan förekomma flera gånger och behandlas då i den ordning den anges. Effekten av att ange samma argument flera gånger är ospecificerad.
-i
- Ignorera felkoder från körda kommandon. Detta motsvarar att det särskilda målet .IGNORE anges utan beroenden.
-k
- Fortsätt uppdatera andra mål som inte beror på det mål där ett fel inträffade. Detta gäller när ett icke ignorerat fel uppstår under körning av kommandon.
-n
- Skriv ut de kommandon som skulle ha körts, men kör dem inte. Kommandorader med prefixet `+` ska dock köras. I detta läge skrivs även rader med `@`-prefix ut.
-p
- Skriv ut den fullständiga uppsättningen makrodefinitioner och målbeskrivningar till standard ut. Utdataformatet är ospecificerat.
-q
- Returnera noll om målet är uppdaterat, annars 1. Inga mål ska uppdateras. Kommandorader med `+`-prefix ska dock köras.
-r
- Töm suffixlistan och använd inte de inbyggda reglerna.
-S
- Avsluta make om ett fel inträffar när kommandon körs för att uppdatera ett mål. Detta är standardbeteendet och motsatsen till -k.
-s
- Skriv inte ut makefilens kommandorader eller meddelanden från -t innan de körs. Detta motsvarar att det särskilda målet .SILENT anges utan beroenden.
-t
- Uppdatera ändringstiden för varje mål som om kommandot `touch mål` hade körts. Mål som har beroenden men inga kommandon, eller som redan är uppdaterade, ska inte ändras på detta sätt. Ett meddelande ska skrivas för varje fil som rörs. Normalt körs inte kommandoraderna för målet, men kommandorader med `+`-prefix ska köras.
Flaggor i miljövariabeln MAKEFLAGS ska behandlas före flaggor på kommandoraden. Om både -k och -S anges, antingen via kommandoraden eller MAKEFLAGS, gäller den senast angivna flaggan. Om -f eller -p förekommer i MAKEFLAGS är resultatet odefinierat.
Operander
target_name
- Namn på mål enligt den utökade beskrivningen. Om inget mål anges används det första mål som make hittar under läsningen av makefilerna och som inte är ett särskilt mål eller en härledningsregel.
macro=value
- Makrodefinition enligt avsnittet om makron.
Om mål och makrodefinitioner blandas på kommandoraden är resultatet ospecificerat.
Standard in
Standard in används endast om argumentet till -f är `-`. Se avsnittet om indatafiler.
Indatafiler
Indatafilen, även kallad makefilen, är en textfil som innehåller regler, makrodefinitioner, inkluderingsrader och kommentarer. Formatet beskrivs i den utökade beskrivningen.
Miljövariabler
Följande miljövariabler påverkar körningen av make:
LANG
- Anger standardvärde för internationaliseringsvariabler som saknas eller är tomma.
LC_ALL
- Om denna är satt till ett icke-tomt värde åsidosätter den alla andra internationaliseringsvariabler.
LC_CTYPE
- Bestämmer hur byte-sekvenser i argument och indata tolkas som tecken.
LC_MESSAGES
- Bestämmer språk och format för diagnostiska meddelanden till standard fel.
MAKEFLAGS
- Innehåller standardflaggor för make. Implementationer ska acceptera både format med enbart flaggbokstäver utan bindestreck och ett kommandoradsliknande format med bindestreck och blanksteg. Makrodefinitioner av formen `macro=value` kan också ingå. Innehållet i variabeln genomgår inte samma ordexpansion som kommandoraden.
NLSPATH
- Bestämmer var meddelandekataloger för LC_MESSAGES ska sökas.
PROJECTDIR
- Anger katalog som används vid sökning efter SCCS-filer som inte finns i aktuell katalog. Sökningen sker i en katalog med namnet SCCS under den angivna katalogen.
Om PROJECTDIR börjar med `/` behandlas den som en absolut sökväg. Annars behandlas värdet som ett användarnamn vars hemkatalog undersöks efter underkatalogerna src eller source. Om dessa inte hittas används värdet som en relativ sökväg. Om PROJECTDIR saknas eller är tom sker sökning i SCCS under aktuell katalog.
Variabeln SHELL i miljön ska inte användas som makro och ska inte ändras genom att definiera makrot SHELL i en makefil eller på kommandoraden. Alla andra miljövariabler, även tomma, ska användas som makron.
Asynkrona händelser
Om signalerna inte redan ignoreras ska make fånga SIGHUP, SIGTERM, SIGINT och SIGQUIT och ta bort det aktuella målet, om inte målet är en katalog, är ett beroende till det särskilda målet .PRECIOUS, eller om någon av flaggorna -n, -p eller -q angavs.
Mål som tas bort på detta sätt ska rapporteras i diagnostiska meddelanden till standard fel. Efter denna städning ska make utföra standardåtgärden för övriga signaler.
Standard ut
make ska skriva de kommandon som ska köras till standard ut, utom när:
- flaggan -s har angetts
- kommandot har prefixet `@`
- det särskilda målet .SILENT gäller för målet eller gäller globalt
Om make körs utan att något behöver göras ska ett meddelande skrivas till standard ut om att ingen åtgärd vidtogs. Om -t används och en fil rörs ska ett meddelande med filnamnet skrivas.
Standard fel
Standard fel används endast för diagnostiska meddelanden.
Utdatafiler
Filer kan skapas när flaggan -t används. Ytterligare filer kan också skapas av verktyg som körs från make.
Utökad beskrivning
make försöker utföra de åtgärder som krävs för att de angivna målen ska vara uppdaterade. Ett mål anses uppdaterat om det finns och är nyare än alla sina beroenden, eller om det redan har gjorts uppdaterat av den aktuella körningen av make. Ett mål kan också anses uppdaterat om det finns, har samma tidsstämpel som ett eller flera beroenden och är nyare än övriga beroenden.
Alla beroenden behandlas som mål i sig och uppdateras rekursivt i den ordning de förekommer i regeln. Filernas ändringstider används för att avgöra om ett mål är föråldrat.
För att uppdatera ett mål säkerställer make först att alla beroenden är uppdaterade. Därefter kontrolleras målet. Om målet inte är uppdaterat körs regelns kommandon. Om målet fortfarande inte finns efter en lyckad uppdatering ska det ändå behandlas som nyare än mål som beror på det.
Om ett mål finns men saknar både målregel och härledningsregel ska det betraktas som uppdaterat. Det är ett fel om make försöker uppdatera ett mål som inte finns och det saknas både målregel och härledningsregel.
Makefilens syntax
En makefil kan innehålla regler, makrodefinitioner, inkluderingsrader och kommentarer. Regler finns i två former: härledningsregler och målregler. make har en uppsättning inbyggda härledningsregler, men dessa används inte om flaggan -r anges.
Regler och makron kan definieras flera gånger. För en regel gäller den senast angivna definitionen. För makron gäller de regler som beskrivs i avsnittet om makron.
Kommentarer är tomma rader, blanka rader och rader där `#` inleder kommentaren. En kommentar fortsätter till nästa icke-escapade radslut.
Som standard ska följande filer prövas i ordning:
./makefile
./Makefile
Om ingen hittas får implementationen pröva andra filer. På XSI-system ska även följande prövas:
./s.makefile
SCCS/s.makefile
./s.Makefile
SCCS/s.Makefile
Flaggan -f gör att dessa standardfiler ignoreras och den angivna filen används i stället. Om argumentet är `-` används standard in.
Termen makefil avser alla regler som användaren tillhandahåller, oavsett om de kommer från standardnamnen eller från -f.
En omvänt snedstreck-escapad radbrytning utanför kommandorader och inkluderingsrader ersätts, tillsammans med inledande blanktecken på följande rad, med ett enda blanksteg. I kommandorader bevaras det omvända snedstrecket och radbrytningen, men ett inledande tab-tecken på nästa rad tas bort.
Inkluderingsrader
Om ordet include står i början av en rad och följs av ett eller flera blanktecken ska resten av raden tolkas som ett filnamn som ska inkluderas.
Behandlingen sker i huvudsak så här:
- Avslutande radbrytning, blanktecken före en kommentar samt själva kommentaren tas bort.
- Strängen expanderas med makron.
- Blanktecken efter det första icke-blanka tecknet används för att dela upp strängen i fält.
- Om resultatet inte blir exakt ett icke-tomt fält är beteendet ospecificerat.
Om sökvägen inte börjar med `/` behandlas den relativt processens aktuella katalog, inte relativt katalogen där makefilen finns. Filens innehåll läses och behandlas som om det stod i makefilen i stället för inkluderingsraden. Inkluderade filer kan själva innehålla inkluderingsrader. Implementationer ska stödja minst 16 nivåers nästling.
Körning av makefilen
Kommandorader i makefilen behandlas en i taget. En kommandorad kan ha följande prefix:
-
- Fel från kommandot ignoreras. Detta gäller också om -i används eller om .IGNORE gäller.
@
- Kommandot skrivs inte ut innan körning, om inte -n används. Detta gäller också om -s används eller om .SILENT gäller.
+
- Kommandot körs även om -n, -q eller -t används.
En körningsrad skapas genom att prefixtecknen tas bort. Om raden inte tystas skrivs den till standard ut. Därefter körs den av ett skal som om den skickades till systemgränssnittet `system()`. Om fel inte ignoreras ska skalets `-e`-läge vara aktivt. Miljön för kommandot ska innehålla alla variabler i make-processens miljö.
Som standard avslutas make med felmeddelande om ett kommando returnerar en status skild från noll.
Målregler
Målregler har formatet:
target [target...]: [prerequisite...][;command]
<TAB>command
<TAB>command
...
En målrad består av en eller flera mål, följt av kolon, följt av noll eller flera beroenden. Text efter semikolon och efterföljande rader som börjar med tab är kommandorader.
Applikationer bör välja målnamn som endast består av punkt, understreck, siffror och bokstäver ur den portabla teckenuppsättningen. Implementationer kan tillåta fler tecken. Tolkningen av mål med `%` eller `"` är implementationsberoende.
Ett mål med beroenden men utan kommandon kan användas för att lägga till beroenden för målet. Endast en målregel för ett visst mål får innehålla kommandon.
Följande särskilda mål styr make:
.DEFAULT
- Om detta mål används ska det ha kommandon men inga beroenden. Kommandona används när inga andra regler finns för att bygga ett mål.
.IGNORE
- Beroenden till detta mål får sina kommandofel ignorerade. Om inga beroenden anges ignoreras fel för alla mål.
.POSIX
- Ska anges utan beroenden och kommandon. Om det förekommer som första icke-kommenterade rad ska makefilen behandlas enligt POSIX. Annars är beteendet ospecificerat.
.PRECIOUS
- Beroenden till detta mål ska inte tas bort vid de asynkrona händelser som beskrivs ovan. Om inga beroenden anges behandlas alla mål som värdefulla.
.SCCS_GET
- Ska anges utan beroenden. Om det förekommer ersätter dess kommandon standardkommandona för hämtning av SCCS-filer.
.SILENT
- Beroenden till detta mål får sina kommandon tystade. Om inga beroenden anges skrivs inga kommandon eller touch-meddelanden för några mål.
.SUFFIXES
- Beroenden till detta mål läggs till suffixlistan och används tillsammans med härledningsregler. Om inga beroenden anges töms suffixlistan.
Målen .IGNORE, .POSIX, .PRECIOUS, .SILENT och .SUFFIXES ska anges utan kommandon.
Mål som börjar med punkt följt av `POSIX` och andra tecken är reserverade för framtida standardisering. Mål som börjar med punkt följt av en eller flera versaler är reserverade för implementationstillägg.
Makron
Makrodefinitioner har formen:
string1 = [string2]
Makrot med namnet string1 får värdet string2. Värdet består av tecknen efter likhetstecknet fram till kommentar eller oescapad radbrytning. Blanktecken omedelbart före och efter likhetstecknet ignoreras.
Makron expanderas med formerna:
$(namn)
${namn}
Parenteser eller klamrar är valfria om namnet är ett enda tecken. `$$` ersätts av ett enda `$`.
Makroexpansion sker enligt följande:
- Makron i målrader expanderas när raden läses.
- Makron i kommandorader expanderas när kommandot körs.
- Makron före likhetstecknet i en makrodefinition expanderas när tilldelningen görs.
- Makron efter likhetstecknet i en makrodefinition expanderas först när makrot används.
Ersättningsformen:
$(namn:från=till)
${namn:från=till}
kan användas för att ersätta förekomster av ett suffix i varje ord i makrovärdet.
Makrodefinitioner hämtas i denna logiska ordning innan makefilerna läses:
- Makron från kommandoraden.
- Makron från MAKEFLAGS.
- Miljövariabler, utom MAKEFLAGS och SHELL.
- Inbyggda makron från härledningsregler.
Makron från en högre prioriterad källa åsidosätter inte lägre numrerade källor enligt POSIX-reglerna. Makron i makefilen åsidosätter tidigare definitioner i makefilen och inbyggda makron. Om -e inte anges åsidosätter makefilens makron också miljön. Makron i makefilen åsidosätter inte makron från kommandoraden eller MAKEFLAGS.
Makrot SHELL behandlas särskilt. Det tillhandahålls av make och ska ange sökvägen till skalets kommandotolk. Miljövariabeln SHELL påverkar inte makrot. Om SHELL definieras i makefilen eller på kommandoraden ersätter det makrot, men påverkar inte miljövariabeln SHELL.
Härledningsregler
Härledningsregler har formatet:
target:
<TAB>command
<TAB>command
...
Måldelen ska ha formen `.s2` eller `.s1.s2`, där suffixen finns i .SUFFIXES och inte innehåller snedstreck eller punkt. En regel med ett suffix är en enkel suffixregel. En regel med två suffix är en dubbel suffixregel.
Härledningsregler får inte ha beroenden. De kan omdefinieras. En tom regel kan skapas med enbart semikolon:
regel: ;
make använder suffixen för mål och beroenden för att avgöra hur ett mål kan göras uppdaterat. Om ingen målregel finns undersöks härledningsreglerna. Suffixet för målet jämförs med suffixlistan i .SUFFIXES. Den första regel som matchar och där motsvarande beroendefil finns används.
Om ett mål saknar suffix och ingen målregel finns prövas enkla suffixregler. Regeln `.s2` beskriver hur mål kan byggas från `mål.s2`.
Tilde (`~`) i dessa regler avser en SCCS-fil i aktuell katalog. Exempelvis betyder `.c~.o` att ett SCCS-lagrat C-källfilsmål kan transformeras till en objektfil.
Bibliotek
Om ett mål eller beroende innehåller parenteser behandlas det som en medlem i ett arkivbibliotek. Formen:
lib(member.o)
betyder att lib är arkivbiblioteket och member.o är medlemmen. Medlemmen ska vara en objektfil med suffixet `.o`. Ändringstiden för uttrycket är ändringstiden för medlemmen i arkivet. Suffixet `.a` avser arkivbibliotek. Regeln `.s2.a` används för att uppdatera en medlem i biblioteket från en fil med suffixet `.s2`.
Interna makron
make tillhandahåller fem interna makron som kan användas i mål- och härledningsregler:
$@
- Det fullständiga namnet på aktuellt mål, eller arkivfilens namn när målet är en biblioteksmedlem.
$%
- Utvärderas endast när aktuellt mål är en biblioteksmedlem av formen `libname(member.o)`. Då är `$@` biblioteket och `$%` medlemmen.
$?
- Listan över beroenden som är nyare än det aktuella målet.
$<
- I en härledningsregel: filnamnet vars existens gjorde att regeln valdes. I `.DEFAULT`: aktuellt målnamn. I andra sammanhang är betydelsen ospecificerad.
$*
- Aktuellt målnamn med suffixet borttaget. Ska åtminstone utvärderas för härledningsregler.
Varje internt makro har också former med D och F tillagda, till exempel `$(<D)` och `$(<F)`. D ger katalogdelen och F ger filnamnsdelen. För aktuell katalog är katalogdelen `.`.
För ett mål av formen `lib(member.o)` och regeln `.s2.a` gäller:
$< member.s2
$* member
$@ lib
$? member.s2
$% member.o
Standardregler
Standardreglerna för make ska ge samma resultat som följande principer. Implementationer som saknar vissa utvecklingsverktyg kan utelämna motsvarande makron och regler.
Särskilda mål:
.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
.SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~
Standardmakron:
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
Exempel på enkla suffixregler:
.c:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
.f:
$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<
.sh:
cp $< $@
chmod a+x $@
Exempel på dubbla suffixregler:
.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 $@
Standardregler för SCCS-varianter använder get för att hämta källfilen innan kompilering.
Slutstatus
När flaggan -q används ska make avsluta med:
0
- Lyckad körning. Målet är uppdaterat.
1
- Målet var inte uppdaterat.
>1
- Ett fel inträffade.
När -q inte används ska make avsluta med:
0
- Lyckad körning.
>0
- Ett fel inträffade.
Följder av fel
Standardbeteende enligt POSIX. Följande avsnitt är informativa.
Användning i program
Om det finns en källfil, till exempel `./source.c`, och två SCCS-filer som motsvarar den, exempelvis `./s.source.c` och `./SCCS/s.source.c`, använder make på XSI-system SCCS-filen i aktuell katalog. Användare rekommenderas ändå att använda de underliggande SCCS-verktygen eller kommandot sccs konsekvent för alla källfiler i en katalog.
Portabla makefiler bör alltid ange det särskilda målet .POSIX för att undvika påverkan från lokala tillägg.
Flaggorna -k och -S finns båda för att relationen mellan kommandoraden, MAKEFLAGS och makefilen ska kunna styras exakt.
När -n används läggs den alltid till i MAKEFLAGS. Detta gör att rekursiv körning med `make -n mål` visar hela den åtgärdssekvens som skulle köras.
Historisk praxis gör att `#` inuti en variabel tolkas som början på en kommentar. Detta gör det svårt att lägga ett `#`-tecken i en variabel, exempelvis:
CFLAGS = "-D COMMENT_CHAR='#'"
Många historiska implementationer slutar kedja härledningsregler när ett mellanliggande mål saknas. Exempelvis kan `.y.c` och `.c.o` teoretiskt bygga `.o` från `.y`, men make kan i stället kräva en direkt `.y.o`-regel.
Det bästa sättet att skriva portabla makefiler är att själv ange alla regler som behövs i makefilen.
Makron inuti andra makron expanderas när det nya makrot används, inte när det definieras. Exempel:
MACRO = value1
NEW = $(MACRO)
MACRO = value2
target:
echo $(NEW)
Detta skriver `value2`, inte `value1`.
Vissa historiska program har blandat mål och makrodefinitioner på kommandoraden och förväntat sig att alla makron behandlas före mål. Portabla program ska inte göra så.
Följande tecken i filnamn kan orsaka problem:
= : ` ' @
I inkluderingsfilnamn bör även mönstertecken och citattecken undvikas.
För härledningsregler kan `$<` och `$?` verka lika, men de skiljer sig. Om en makefil innehåller:
foo.o: foo.h
och `foo.h` är nyare än `foo.o`, men `foo.c` är äldre än `foo.o`, används den inbyggda regeln från `foo.c`, med `$<` lika med `foo.c` och `$?` lika med `foo.h`. Om även `foo.c` är nyare än `foo.o`, blir `$?` lika med `foo.h foo.c`.
Ett mål utan beroenden och utan kommandon, där målfilen inte finns, behandlas som uppdaterat när regeln körs. Detta innebär att alla mål som beror på detta mål alltid får sina kommandon körda.
På filsystem med låg tidsupplösning kan sekvenser som:
make; cp original copy; make
ge problem, beroende på om implementationen betraktar identiska tidsstämplar som uppdaterade eller föråldrade.
Standarden anger inte prioritet mellan makrodefinitioner och inkluderingsdirektiv. Därför är beteendet för:
include =foo.mk
ospecificerat. Om syftet är att definiera en variabel med namnet `include` bör blanktecknet före likhetstecknet tas bort eller ett annat makro användas.
Exempel
Följande kommando bygger standardmålet i aktuell katalog:
make
Följande kommando använder en särskild makefil:
make -f projekt.mk
Följande kommando visar vad som skulle köras utan att köra kommandona:
make -n
Följande kommando bygger ett specifikt mål:
make install
Följande är ett enkelt exempel på en makefil:
.POSIX:
prog: main.o util.o
c99 -o prog main.o util.o
main.o: main.c util.h
c99 -c main.c
util.o: util.c util.h
c99 -c util.c
Om `main.c` eller `util.h` är nyare än `main.o` byggs `main.o` om. Om `main.o` eller `util.o` är nyare än `prog` länkas programmet om.
Bakgrund och motivering
POSIX-beskrivningen av make är avsedd att ange ett portabelt kärnbeteende, trots att historiska implementationer av make har haft många lokala tillägg. Kravet på målet .POSIX gör det möjligt för en makefil att uttryckligen begära POSIX-beteende.
Flaggorna -k och -S finns för att både fortsätt-efter-fel och stoppa-vid-fel ska kunna styras tydligt, även vid rekursiva körningar.
Reglerna kring MAKEFLAGS gör att rekursiva make-körningar kan ärva relevanta flaggor från föräldraprocessen.
POSIX specificerar inte alla historiska specialfall. Därför bör portabla makefiler undvika implementationsegna mål, ovanliga tecken i filnamn och antaganden om hur långt kedjade härledningsregler följs.
Framtida riktning
Inga framtida ändringar anges.
Se även
ar(1p), c99(1p), get(1p), sh(1p), touch(1p)
POSIX.1-2017, Base Definitions, avsnitt 12.2, Utility Syntax Guidelines.
Upphovsrätt
Delar av denna text återges och reproduceras elektroniskt från IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright © 2018 Institute of Electrical and Electronics Engineers, Inc. och The Open Group.
Vid skillnader mellan denna version och den ursprungliga IEEE/The Open Group-standarden är originalstandarden den avgörande referensen. Originalstandarden finns tillgänglig online från The Open Group.
Eventuella typografiska fel eller formateringsfel i denna manualsida har sannolikt uppstått vid konverteringen till manualsidesformat.
Sidslut
Orginalhemsidan på Engelska https://man7.org/linux/man-pages/man1/make.1p.html
Det här är en maskinöversättning av Linux man sidor till svenska. Om du hittar fel är vi tacksamma om du rapporterar dem via formuläret som finns på
https://www.linux.se/kontaka-linux-se/
Tack till Datorhjälp hemma som har sponsrat Linux.se med webbhotell.