make(1S) make(1S) NAME make−maintain,update,andregeneraterelatedprogramsandfiles SYNOPSIS /usr/ccs/bin/make[−d][−dd][−D][−DD][−e][−i][−k][−n][−p] [−P][−q][−r][−s][−S][−t][−V][−fmakefile]...[−Kstatefile]... [target...][macro=value...] /usr/xpg4/bin/make[−d][−dd][−D][−DD][−e][−i][−k][−n][−p] [−P][−q][−r][−s][−S][−t][−V][−fmakefile]...[target...] [macro=value...] DESCRIPTION Themakeutilityexecutesalistofshellcommandsassociatedwitheachtarget,typicallytocreate orupdateafileofthesamename.makefilecontainsentriesthatdescribehowtobringatarget uptodatewithrespecttothoseonwhichitdepends,whicharecalleddependencies.Sinceeach dependencyisatarget,itmayhavedependenciesofitsown.Targets,dependencies,andsubdependenciescompriseatreestructurethatmaketraceswhendecidingwhetherornottorebuild atarget. Themakeutilityrecursivelycheckseachtargetagainstitsdependencies,beginningwiththefirst targetentryinmakefileifnotargetargumentissuppliedonthecommandline.If,afterprocessingallofitsdependencies,atargetfileisfoundeithertobemissing,ortobeolderthananyofits dependencies,makerebuildsit.Optionallywiththisversionofmake,atargetcanbetreatedas out-of-datewhenthecommandsusedtogenerateithavechangedsincethelasttimethetarget wasbuilt. Tobuildagiventarget,makeexecutesthelistofcommands,calledarule.Thisrulemaybe listedexplicitlyinthetarget’smakefileentry,oritmaybesuppliedimplicitlybymake. Ifnotargetisspecifiedonthecommandline,makeusesthefirsttargetdefinedinmakefile. Ifatargethasnomakefileentry,orifitsentryhasnorule,makeattemptstoderivearuleby eachofthefollowingmethods,inturn,untilasuitableruleisfound.Eachmethodisdescribed underUSAGEbelow. •Patternmatchingrules. •Implicitrules,readinfromauser-suppliedmakefile. •Standardimplicitrules(alsoknownassuffixrules),typicallyreadinfromthefile /usr/share/lib/make/make.rules. •SCCSretrieval.makeretrievesthemostrecentversionfromtheSCCShistoryfile(if any).Seethedescriptionofthe.SCCSGET:special-functiontargetfordetails. •Therulefromthe.DEFAULT:targetentry,ifthereissuchanentryinthemakefile. Ifthereisnomakefileentryforatarget,ifnorulecanbederivedforbuildingit,andifnofileby thatnameispresent,makeissuesanerrormessageandhalts. OPTIONS Thefollowingoptionsaresupported: −dDisplaythereasonswhymakechoosestorebuildatarget;makedisplaysany andalldependenciesthatarenewer.Inaddition,makedisplaysoptionsreadin fromtheMAKEFLAGSenvironmentvariable. −ddDisplaythedependencycheckandprocessinginvastdetail. −DDisplaythetextofthemakefilesreadin. −DDDisplaythetextofthemakefiles,make.rulesfile,thestatefile,andallhiddendependencyreports. 18Mar1997 1 make(1S) make(1S) −eEnvironmentvariablesoverrideassignmentswithinmakefiles. −fmakefileUsethedescriptionfilemakefile.A‘−’asthemakefileargumentdenotesthe standardinput.Thecontentsofmakefile,whenpresent,overridethestandard setofimplicitrulesandpredefinedmacros.Whenmorethanone‘−fmakefile’ argumentpairappears,makeusestheconcatenationofthosefiles,inorderof appearance. Whennomakefileisspecified,/usr/ccs/bin/maketriesthefollowingin sequence,exceptwheninPOSIXmode(seethe.POSIXSpecial-Function TargetintheUSAGEsectionbelow): •Ifthereisafilenamedmakefileintheworkingdirectory,makeusesthat file.If,however,thereisanSCCShistoryfile(SCCS/s.makefile)which isnewer,makeattemptstoretrieveandusethemostrecentversion. •Intheabsenceoftheabovefile(s),ifafilenamedMakefileispresentin theworkingdirectory,makeattemptstouseit.IfthereisanSCCShistoryfile(SCCS/s.Makefile)thatisnewer,makeattemptstoretrieve andusethemostrecentversion. Whennomakefileisspecified,/usr/ccs/bin/makeinPOSIXmodeand /usr/xpg4/bin/maketrythefollowingfilesinsequence: •./makefile,./Makefile •s.makefile,SCCS/s.makefile •s.Makefile,SCCS/s.Makefile −iIgnoreerrorcodesreturnedbycommands.Equivalenttothespecial-function target‘.IGNORE:’. −kWhenanonzeroerrorstatusisreturnedbyarule,orwhenmakecannotfinda rule,abandonworkonthecurrenttarget,butcontinuewithotherdependency branchesthatdonotdependonit. −KstatefileUsethestatefilestatefile.A‘−’asthestatefileargumentdenotesthestandard input.Thecontentsofstatefile,whenpresent,overridethestandardsetof implicitrulesandpredefinedmacros.Whenmorethanone‘−Kstatefile’argumentpairappears,makeusestheconcatenationofthosefiles,inorderof appearance.(Seealso.KEEPSTATE and.KEEPSTATEFILEintheSpecial-FunctionsTargetssection). −nNoexecutionmode.Printcommands,butdonotexecutethem.Evenlines beginningwithan@areprinted.However,ifacommandlinecontainsareferencetothe$(MAKE)macro,thatlineisalwaysexecuted(seethediscussionof MAKEFLAGSinReadingMakefilesandtheEnvironment).Whenin POSIXmode,linesbeginningwitha“+”areexecuted. −pPrintoutthecompletesetofmacrodefinitionsandtargetdescriptions. −PMerelyreportdependencies,ratherthanbuildingthem. −qQuestionmode.makereturnsazeroornonzerostatuscodedependingon whetherornotthetargetfileisuptodate.WheninPOSIXmode,linesbeginningwitha“+”areexecuted. −rDonotreadinthedefaultmakefile/usr/share/lib/make/make.rules. −sSilentmode.Donotprintcommandlinesbeforeexecutingthem.Equivalentto thespecial-functiontarget.SILENT:. −SUndotheeffectofthe−koption.Stopprocessingwhenanon-zeroexitstatusis returnedbyacommand. −tTouchthetargetfiles(bringingthemuptodate)ratherthanperformingtheir rules.Thiscanbedangerouswhenfilesaremaintainedbymorethanoneperson. 18Mar1997 2 make(1S) make(1S) Whenthe.KEEPSTATE:targetappearsinthemakefile,thisoptionupdates thestatefilejustasiftheruleshadbeenperformed.WheninPOSIXmode, linesbeginningwitha“+”areexecuted. −VPutsmakeintoSysVmode.RefertosysV-make(1)forrespectivedetails. OPERANDS Thefollowingoperandsaresupported: targetTargetnames,asdefinedinUSAGE. macro=value Macrodefinition.Thisdefinitionoverridesanyregulardefinitionforthespecified macrowithinthemakefileitself,orintheenvironment.However,thisdefinitioncan stillbeoverriddenbyconditionalmacroassignments. USAGE Refertomakeinfortutorialinformation. ReadingMakefilesandtheEnvironment Whenmakefirststarts,itreadstheMAKEFLAGSenvironmentvariabletoobtainanyofthe followingoptionsspecifiedpresentinitsvalue:−d,−D,−e,−i,−k,−n,−p,−q,−r,−s,−S,or −t.DuetotheimplementationofPOSIX.2(seePOSIX.2(5),theMAKEFLAGSvalueswill containaleading‘−’character.Themakeutilitythenreadsthecommandlineforadditional options,whichalsotakeeffect. Next,makereadsinadefaultmakefilethattypicallycontainspredefinedmacrodefinitions,target entriesforimplicitrules,andadditionalrules,suchastheruleforretrievingSCCSfiles.Ifpresent, makeusesthefilemake.rulesinthecurrentdirectory;otherwiseitreadsthefile /usr/share/lib/make/make.rules,whichcontainsthestandarddefinitionsandrules. Usethedirective: include/usr/share/lib/make/make.rules inyourlocalmake.rulesfiletoincludethem. Next,makeimportsvariablesfromtheenvironment(unlessthe−eoptionisineffect),andtreats themasdefinedmacros.Becausemakeusesthemostrecentdefinitionitencounters,amacro definitioninthemakefilenormallyoverridesanenvironmentvariableofthesamename.When −eisineffect,however,environmentvariablesarereadinafterallmakefileshavebeenread.In thatcase,theenvironmentvariablestakeprecedenceoverdefinitionsinthemakefile. Next,makereadsanymakefilesyouspecifywith−f,oroneofmakefileorMakefileas describedaboveandthenthestatefile,inthelocaldirectoryifitexists.Ifthemakefilecontains a.KEEPSTATEFILEtarget,thenitreadsthestatefilethatfollowsthetarget.Refertospecial target.KEEPSTATEFILEfordetails. Next,(afterreadingtheenvironmentif−eisineffect),makereadsinanymacrodefinitionssuppliedascommandlinearguments.Theseoverridemacrodefinitionsinthemakefileandtheenvironmentboth,butonlyforthemakecommanditself. makeexportsenvironmentvariables,usingthemostrecentlydefinedvalue.Macrodefinitions suppliedonthecommandlinearenotnormallyexported,unlessthemacroisalsoanenvironment variable. makedoesnotexportmacrosdefinedinthemakefile.Ifanenvironmentvariableisset,anda macrowiththesamenameisdefinedonthecommandline,makeexportsitsvalueasdefinedon thecommandline.Unless−eisineffect,macrodefinitionswithinthemakefiletakeprecedence overthoseimportedfromtheenvironment. ThemacrosMAKEFLAGS,MAKE,SHELL,HOSTARCH,HOSTMACH,andTAR-GETMACHarespecialcases.SeeSpecial-PurposeMacros,belowfordetails. 18Mar1997 3 make(1S) make(1S) MakefileTargetEntries Atargetentryhasthefollowingformat: target...[:|::][dependency]...[;command]... [command] ... Thefirstlinecontainsthenameofatarget,oraspace-separatedlistoftargetnames,terminated withacolonordoublecolon.Ifalistoftargetsisgiven,thisisequivalenttohavingaseparate entryofthesameformforeachtarget.Thecolon(s)maybefollowedbyadependency,ora dependencylist.makechecksthislistbeforebuildingthetarget.Thedependencylistmaybe terminatedwithasemicolon(;),whichinturncanbefollowedbyasingleBourneshellcommand. SubsequentlinesinthetargetentrybeginwithaTAB,andcontainBourneshellcommands. Thesecommandscomprisetheruleforbuildingthetarget. ShellcommandsmaybecontinuedacrossinputlinesbyescapingtheNEWLINEwithabackslash (\).ThecontinuinglinemustalsostartwithaTAB. Torebuildatarget,makeexpandsmacros,stripsoffinitialTABcharactersandeitherexecutes thecommanddirectly(ifitcontainsnoshellmetacharacters),orpasseseachcommandlinetoa Bourneshellforexecution. ThefirstlinethatdoesnotbeginwithaTABor’#’beginsanothertargetormacrodefinition. SpecialCharacters Global #Startacomment.ThecommentendsatthenextNEWLINE.Ifthe‘#’follows theTABinacommandline,thatlineispassedtotheshell(whichalsotreats‘#’ asthestartofacomment). includefilename Ifthewordincludeappearsasthefirstsevenlettersofalineandisfollowedby aSPACEorTAB,thestringthatfollowsistakenasafilenametointerpolateat thatline.includefilescanbenestedtoadepthofnomorethanabout16.If filenameisamacroreference,itisexpanded. TargetsandDependencies :Targetlistterminator.Wordsfollowingthecolonareaddedtothedependency listforthetargetortargets.Ifatargetisnamedinmorethanonecolonterminatedtargetentry,thedependenciesforallitsentriesareaddedtoform thattarget’scompletedependencylist. ::Targetterminatorforalternatedependencies.Whenusedinplaceofa‘:’the double-colonallowsatargettobecheckedandupdatedwithrespecttoalternate dependencylists.Whenthetargetisout-of-datewithrespecttodependencies listedinthefirstalternate,itisbuiltaccordingtotheruleforthatentry.When out-of-datewithrespecttodependenciesinanotheralternate,itisbuiltaccord-ingtheruleinthatotherentry.Implicitrulesdonotapplytodouble-colontar-gets;youmustsupplyaruleforeachentry.Ifnodependenciesarespecified,the ruleisalwaysperformed. target[+target...]: Targetgroup.Theruleinthetargetentrybuildsalltheindicatedtargetsasa group.Itisnormallyperformedonlyoncepermakerun,butischeckedfor commanddependencieseverytimeatargetinthegroupisencounteredinthe dependencyscan. %Patternmatchingwildcardmetacharacter.Likethe‘*’shellwildcard,‘%’ matchesanystringofzeroormorecharactersinatargetnameordependency,in thetargetportionofaconditionalmacrodefinition,orwithinapatternreplacementmacroreference.Notethatonlyone‘%’canappearinatarget, 18Mar1997 4 make(1S) make(1S) dependency-name,orpattern-replacementmacroreference. ./pathnamemakeignorestheleading‘./’charactersfromtargetswithnamesgivenaspathnamesrelativeto“dot,”theworkingdirectory. Macros =Macrodefinition.Thewordtotheleftofthischaracteristhemacroname; wordstotherightcompriseitsvalue.Leadingandtrailingwhitespacecharactersarestrippedfromthevalue.Awordbreakfollowingthe=isimplied. $Macroreference.Thefollowingcharacter,ortheparenthesizedorbracketed string,isinterpretedasamacroreference:makeexpandsthereference(includingthe$)byreplacingitwiththemacro’svalue. () {}Macro-referencenamedelimiters.Aparenthesizedorbracketedwordappended toa$istakenasthenameofthemacrobeingreferredto.Withoutthedelimiters,makerecognizesonlythefirstcharacterasthemacroname. $$Areferencetothedollar-signmacro,thevalueofwhichisthecharacter‘$’. Usedtopassvariableexpressionsbeginningwith$totheshell,torefertoenvironmentvariableswhichareexpandedbytheshell,ortodelayprocessingof dynamicmacroswithinthedependencylistofatarget,untilthattargetisactuallyprocessed. \$Escapeddollar-signcharacter.Interpretedasaliteraldollarsignwithinarule. +=Whenusedinplaceof‘=’,appendsastringtoamacrodefinition(mustbesurroundedbywhitespace,unlike‘=’). :=Conditionalmacroassignment.Whenprecededbyalistoftargetswithexplicit targetentries,themacrodefinitionthatfollowstakeseffectwhenprocessingonly thosetargets,andtheirdependencies. :sh=Definethevalueofamacrotobetheoutputofacommand(seeCommand Substitutions,below). :shInamacroreference,executethecommandstoredinthemacro,andreplacethe referencewiththeoutputofthatcommand(seeCommandSubstitutions). Rules +makewillalwaysexecutethecommandsprecededbya“+”,evenwhen−nis specified. −makeignoresanynonzeroerrorcodereturnedbyacommandlineforwhichthe firstnon-TABcharacterisa‘−’.Thischaracterisnotpassedtotheshellaspart ofthecommandline.makenormallyterminateswhenacommandreturns nonzerostatus,unlessthe−ior−koptions,orthe.IGNORE:special-function targetisineffect. @Ifthefirstnon-TABcharacterisa@,makedoesnotprintthecommandline beforeexecutingit.Thischaracterisnotpassedtotheshell. ?Escapecommand-dependencychecking.Commandlinesstartingwiththischar-acterarenotsubjecttocommanddependencychecking. !Forcecommand-dependencychecking.Command-dependencycheckingisapplied tocommandlinesforwhichitwouldotherwisebesuppressed.Thischeckingis normallysuppressedforlinesthatcontainreferencestothe‘?’dynamicmacro (forexample,‘$?’). Whenanycombinationof‘+’,‘−’,‘@’,‘?’,or‘!’appearasthefirstcharacters aftertheTAB,allthatarepresentapply.Nonearepassedtotheshell. 18Mar1997 5 make(1S) make(1S) Special-FunctionTargets Whenincorporatedinamakefile,thefollowingtargetnamesperformspecial-functions: .DEFAULT:Ifithasanentryinthemakefile,theruleforthistargetisusedtoprocessatargetwhenthereisnootherentryforit,noruleforbuildingit,andnoSCCShistoryfilefromwhichtoretrieveacurrentversion.makeignoresanydependenciesforthistarget. .DONE:Ifdefinedinthemakefile,makeprocessesthistargetanditsdependenciesafter allothertargetsarebuilt.Thistargetisalsoperformedwhenmakehaltswith anerror,unlessthe.FAILEDtargetisdefined. .FAILED:Thistarget,alongwithitsdependencies,isperformedinsteadof.DONEwhen definedinthemakefileandmakehaltswithanerror. .GETPOSIX:ThistargetcontainstheruleforretrievingthecurrentversionofanSCCSfile fromitshistoryfileinthecurrentworkingdirectory.makeusesthisrulewhen itisrunninginPOSIXmode. .IGNORE:Ignoreerrors.Whenthistargetappearsinthemakefile,makeignoresnon-zero errorcodesreturnedfromcommands.WhenusedinPOSIXmode,.IGNORE couldbefollowedbytargetnamesonly,forwhichtheerrorswillbeignored. .INIT:Ifdefinedinthemakefile,thistargetanditsdependenciesarebuiltbeforeany othertargetsareprocessed. .KEEPSTATE: Ifthistargetisineffect,makeupdatesthestatefile,.make.state,inthecurrentdirectory.Thistargetalsoactivatescommanddependencies,andhidden dependencychecks.Ifeitherthe.KEEPSTATE:targetappearsinthemakefile, ortheenvironmentvariableKEEPSTATEisset("setenvKEEPSTATE"), makewillrebuildeverythinginordertocollectdependencyinformation,evenif allthetargetswereuptodateduetopreviousmakeruns.SeealsotheENVI-RONMENTsection.ThistargethasnoeffectifusedinPOSIXmode. .KEEPSTATEFILE: ThistargethasnoeffectifusedinPOSIXmode.Thistargetimplies .KEEPSTATE.Ifthetargetisfollowedbyafilename,makeusesitasthe statefile.Ifthetargetisfollowedbyadirectoryname,makelooksfora .make.statefileinthatdirectory.Ifthetargetisnotfollowedbyanyname, makelooksfor.make.statefileinthecurrentworkingdirectory. .MAKEVERSION: Atarget-entryoftheform: .MAKEVERSION:VERSION−number enablesversionchecking.Iftheversionofmakediffersfromtheversionindicated,makeissuesawarningmessage. .NOPARALLEL: Currently,thistargethasnoeffect,itis,however,reservedforfutureuse. .PARALLEL:Currentlyofnoeffect,butreservedforfutureuse. .POSIX:ThistargetenablesPOSIXmode. .PRECIOUS:Listoffilesnottodelete.makedoesnotremoveanyofthefileslistedasdependenciesforthistargetwheninterrupted.makenormallyremovesthecurrent targetwhenitreceivesaninterrupt.WhenusedinPOSIXmode,ifthetargetis notfollowedbyalistoffiles,allthefileareassumedprecious. 18Mar1997 6 make(1S) make(1S) .SCCSGET:ThistargetcontainstheruleforretrievingthecurrentversionofanSCCSfile fromitshistoryfile.Tosuppressautomaticretrieval,addanentryforthistarget withanemptyruletoyourmakefile. .SCCSGETPOSIX: ThistargetcontainstheruleforretrievingthecurrentversionofanSCCSfile fromitshistoryfile.makeusesthisrulewhenitisrunninginPOSIXmode. .SILENT:Runsilently.Whenthistargetappearsinthemakefile,makedoesnotecho commandsbeforeexecutingthem.WhenusedinPOSIXmode,itcouldbefollowedbytargetnames,andonlythosewillbeexecutedsilently. .SUFFIXES:Thesuffixeslistforselectingimplicitrules(seeTheSuffixesList). .WAIT:Currentlyofnoeffect,butreservedforfutureuse. ClearingSpecialTargets Inthisversionofmake,youcanclearthedefinitionofthefollowingspecialtargetsbysupplying entriesforthemwithnodependenciesandnorule: .DEFAULT,.SCCSGET,and.SUFFIXES CommandDependencies Whenthe.KEEPSTATE:targetiseffective,makechecksthecommandforbuildingatarget againstthestatefile.Ifthecommandhaschangedsincethelastmakerun,makerebuildsthe target. HiddenDependencies Whenthe.KEEPSTATE:targetiseffective,makereadsreportsfromcpp(1)andothercompilationprocessorsforany“hidden”files,suchas#includefiles.Ifthetargetisoutofdatewith respecttoanyofthesefiles,makerebuildsit. Macros Entriesoftheform macro=value definemacros.macroisthenameofthemacro,andvalue,whichconsistsofallcharactersuptoa commentcharacterorunescapedNEWLINE,isthevalue.makestripsbothleadingandtrailing whitespaceinacceptingthevalue. Subsequentreferencestothemacro,oftheforms:$(name)or${name}arereplacedbyvalue. Theparenthesesorbracketscanbeomittedinareferencetoamacrowithasingle-character name. Macroreferencescancontainreferencestoothermacros,inwhichcasenestedreferencesare expandedfirst. SuffixReplacementMacroReferences Substitutionswithinmacroscanbemadeasfollows: $(name:string1=string2) wherestring1iseitherasuffix,orawordtobereplacedinthemacrodefinition,andstring2isthe replacementsuffixorword.WordsinamacrovalueareseparatedbySPACE,TAB,andescaped NEWLINEcharacters. 18Mar1997 7 make(1S) make(1S) PatternReplacementMacroReferences Patternmatchingreplacementscanalsobeappliedtomacros,withareferenceoftheform: $(name:op%os=np%ns) whereopistheexisting(old)prefixandosistheexisting(old)suffix,npandnsarethenewprefixandnewsuffix,respectively,andthepatternmatchedby%(astringofzeroormorecharacters),iscarriedforwardfromthevaluebeingreplaced.Forexample: PROGRAM=fabricate DEBUG=$(PROGRAM:%=tmp/%−g) setsthevalueofDEBUGtotmp/fabricate−g. Notethatpatternreplacementmacroreferencescannotbeusedinthedependencylistofapatternmatchingrule;the%charactersarenotevaluatedindependently.Also,anynumberof% metacharacterscanappearaftertheequal-sign. AppendingtoaMacro Wordscanbeappendedtomacrovaluesasfollows: macro+=word... Special-PurposeMacros WhentheMAKEFLAGSvariableispresentintheenvironment,maketakesoptionsfromit,in combinationwithoptionsenteredonthecommandline.makeretainsthiscombinedvalueasthe MAKEFLAGSmacro,andexportsitautomaticallytoeachcommandorshellitinvokes. NotethatflagspassedbywayofMAKEFLAGSareonlydisplayedwhenthe−d,or−ddoptions areineffect. TheMAKEmacroisanotherspecialcase.Ithasthevaluemakebydefault,andtemporarily overridesthe−noptionforanylineinwhichitisreferredto.Thisallowsnestedinvocationsof makewrittenas: $(MAKE)... torunrecursively,withthe−nflagineffectforallcommandsbutmake.Thisletsyouuse ‘make−n’totestanentirehierarchyofmakefiles. Forcompatibilitywiththe4.2BSDmake,theMFLAGSmacroissetfromtheMAKEFLAGS variablebyprependinga‘−’.MFLAGSisnotexportedautomatically. TheSHELLmacro,whensettoasingle-wordvaluesuchas/usr/bin/csh,indicatesthenameof analternateshelltouse.Thedefaultis/bin/sh.Notethatmakeexecutescommandsthatcontainnoshellmetacharactersitself.Built-incommands,suchasdirsintheCshell,arenotrecog-nizedunlessthecommandlineincludesametacharacter(forinstance,asemicolon).Thismacro isneitherimportedfrom,norexportedtotheenvironment,regardlessof−e.Tobesureitisset properly,youmustdefinethismacrowithineverymakefilethatrequiresit. Thefollowingmacrosareprovidedforusewithcross-compilation: HOSTARCHThemachinearchitectureofthehostsystem.Bydefault,thisistheoutputof thearch(1)commandprependedwith‘−’.Undernormalcircumstances,this valueshouldneverbealteredbytheuser. HOSTMACHThemachinearchitectureofthehostsystem.Bydefault,thisistheoutputof themach(1),prependedwith‘−’.Undernormalcircumstances,thisvalue shouldneverbealteredbytheuser. TARGETARCH Themachinearchitectureofthetargetsystem.Bydefault,theoutputofmach, prependedwith‘−’. 18Mar1997 8 make(1S) make(1S) DynamicMacros Thereareseveraldynamicallymaintainedmacrosthatareusefulasabbreviationswithinrules. Theyareshownhereasreferences;ifyouweretodefinethem,makewouldsimplyoverridethe definition. $*Thebasenameofthecurrenttarget,derivedasifselectedforusewithanimplicit rule. $<Thenameofadependencyfile,derivedasifselectedforusewithanimplicit rule. $@Thenameofthecurrenttarget.Thisistheonlydynamicmacrowhosevalueis strictlydeterminedwhenusedinadependencylist.(Inwhichcaseittakesthe form‘$$@’.) $?Thelistofdependenciesthatarenewerthanthetarget.Command-dependency checkingisautomaticallysuppressedforlinesthatcontainthismacro,justasif thecommandhadbeenprefixedwitha‘?’.Seethedescriptionof‘?’,under MakefileSpecialTokens,above.Youcanforcethischeckwiththe!command-lineprefix. $%Thenameofthelibrarymemberbeingprocessed.(SeeLibraryMaintenance, below.) Torefertothe$@dynamicmacrowithinadependencylist,precedethereferencewithanadditional‘$’character(asin,‘$$@’).Becausemakeassigns$<and$*asitwouldforimplicit rules(accordingtothesuffixeslistandthedirectorycontents),theymaybeunreliablewhenused withinexplicittargetentries. Thesemacroscanbemodifiedtoapplyeithertothefilenamepart,orthedirectorypartofthe stringstheystandfor,byaddinganuppercaseForD,respectively(andenclosingtheresulting nameinparenthesesorbraces).Thus,‘$(@D)’referstothedirectorypartofthestring‘$@’;if thereisnodirectorypart,‘.’isassigned.$(@F)referstothefilenamepart. ConditionalMacroDefinitions Amacrodefinitionoftheform: target-list:=macro=value indicatesthatwhenprocessinganyofthetargetslistedandtheirdependencies,macroistobeset tothevaluesupplied.Notethatifaconditionalmacroisreferredtoinadependencylist,the$ mustbedelayed(use$$instead).Also,target-listmaycontaina%pattern,inwhichcasethe macrowillbeconditionallydefinedforalltargetsencounteredthatmatchthepattern.Apattern replacementreferencecanbeusedwithinthevalue. Youcantemporarilyappendtoamacro’svaluewithaconditionaldefinitionoftheform: target-list:=macro+=value PredefinedMacros makesuppliesthemacrosshowninthetablethatfollowsforcompilersandtheiroptions,host architectures,andothercommands.Unlessthesemacrosarereadinasenvironmentvariables, theirvaluesarenotexportedbymake.Ifyourunmakewithanyofthesesetintheenvironment,itisagoodideatoaddcommentarytothemakefiletoindicatewhatvalueeachisexpected totake.If−risineffect,makedoesnotreadthedefaultmakefile(./make.rulesor /usr/share/lib/make/make.rules)inwhichthesemacrodefinitionsaresupplied. 18Mar1997 9 make(1S) make(1S) TableofPredefinedMacros UseMacro DefaultValue LibraryARar ArchivesARFLAGSrv AssemblerASas CommandsASFLAGS COMPILE.s$(AS)$(ASFLAGS) COMPILE.S$(CC)$(ASFLAGS)$(CPPFLAGS)−c CCompilerCCcc CommandsCFLAGS CPPFLAGS COMPILE.c$(CC)$(CFLAGS)$(CPPFLAGS)−c LINK.c$(CC)$(CFLAGS)$(CPPFLAGS)$(LDFLAGS) C++CCCCC CompilerCCFLAGSCFLAGS CommandsCPPFLAGS COMPILE.cc$(CCC)$(CCFLAGS)$(CPPFLAGS)−c LINK.cc$(CCC)$(CCFLAGS)$(CPPFLAGS)$(LDFLAGS) COMPILE.C$(CCC)$(CCFLAGS)$(CPPFLAGS)−c LINK.C$(CCC)$(CCFLAGS)$(CPPFLAGS)$(LDFLAGS) FORTRAN77FCf77 CompilerFFLAGS CommandsCOMPILE.f$(FC)$(FFLAGS)−c LINK.f$(FC)$(FFLAGS)$(LDFLAGS) COMPILE.F$(FC)$(FFLAGS)$(CPPFLAGS)−c LINK.F$(FC)$(FFLAGS)$(CPPFLAGS)$(LDFLAGS) FORTRAN90FCf90 CompilerF90FLAGS CommandsCOMPILE.f90$(F90C)$(F90FLAGS)−c LINK.f90$(F90C) COMPILE.ftn$(F90C)$(F90FLAGS)$(CPPFLAGS)−c LINK.ftn$(F90C)$(F90FLAGS)$(CPPFLAGS)$(LDFLAGS) LinkEditorLDld CommandLDFLAGS lexLEXlex CommandLFLAGS LEX.l$(LEX)$(LFLAGS)−t lintLINTlint CommandLINTFLAGS LINT.c$(LINT)$(LINTFLAGS)$(CPPFLAGS) Modula2M2Cm2c CommandsM2FLAGS MODFLAGS DEFFLAGS COMPILE.def$(M2C)$(M2FLAGS)$(DEFFLAGS) COMPILE.mod$(M2C)$(M2FLAGS)$(MODFLAGS) 18Mar1997 10 make(1S) make(1S) TableofPredefinedMacros UseMacro DefaultValue PascalPCpc CompilerPFLAGS CommandsCOMPILE.p$(PC)$(PFLAGS)$(CPPFLAGS)−c LINK.p$(PC)$(PFLAGS)$(CPPFLAGS)$(LDFLAGS) RatforRFLAGS CompilationCOMPILE.r$(FC)$(FFLAGS)$(RFLAGS)−c CommandsLINK.r$(FC)$(FFLAGS)$(RFLAGS)$(LDFLAGS) rmCommandRMrm−f sccsCommandSCCSFLAGS SCCSGETFLAGS−s yaccCommandYACCyacc YFLAGS YACC.y$(YACC)$(YFLAGS) SuffixesListSUFFIXES .o.c.c˜ .cc.cc˜ .y.y˜ .l.l˜ .s.s˜ .sh.sh˜ .S.S˜ .ln.h.h˜ .f.f˜ .F.F˜ .mod.mod˜ .sym.def.def˜ .p.p˜ .r.r˜ .cps.cps˜ .C.C˜ .Y.Y˜ .L.L.f90.f90˜ .ftn.ftn˜ ImplicitRules Whenatargethasnoentryinthemakefile,makeattemptstodetermineitsclass(ifany)and applytheruleforthatclass.Animplicitruledescribeshowtobuildanytargetofagivenclass, fromanassociateddependencyfile.Theclassofatargetcanbedeterminedeitherbyapattern, orbyasuffix;thecorrespondingdependencyfile(withthesamebasename)fromwhichsuchatargetmightbebuilt.Inadditiontoapredefinedsetofimplicitrules,makeallowsyoutodefine yourown,eitherbypattern,orbysuffix. PatternMatchingRules Atargetentryoftheform: tp%ts:dp%ds rule isapatternmatchingrule,inwhichtpisatargetprefix,tsisatargetsuffix,dpisadependency prefix,anddsisadependencysuffix(anyofwhichmaybenull).The‘%’standsforabasename ofzeroormorecharactersthatismatchedinthetarget,andisusedtoconstructthenameofa dependency.Whenmakeencountersamatchinitssearchforanimplicitrule,itusestherulein thattargetentrytobuildthetargetfromthedependencyfile.Pattern-matchingimplicitrules typicallymakeuseofthe$@and$<dynamicmacrosasplaceholdersforthetargetanddependencynames.Other,regulardependenciesmayoccurinthedependencylist;however,noneofthe regulardependenciesmaycontain‘%’.Anentryoftheform: tp%ts:[dependency...]dp%ds[dependency...] rule isavalidpatternmatchingrule. SuffixRules Whennopatternmatchingruleapplies,makechecksthetargetnametoseeifitendswithasuffixintheknownsuffixeslist.Ifso,makechecksforanysuffixrules,aswellasadependencyfile withsamerootandanotherrecognizedsuffix,fromwhichtobuildit. Thetargetentryforasuffixruletakestheform: DsTs:rule whereTsisthesuffixofthetarget,Dsisthesuffixofthedependencyfile,andruleistherulefor buildingatargetintheclass.BothDsandTsmustappearinthesuffixeslist.(Asuffixneednot beginwitha‘.’toberecognized.) 18Mar1997 11 make(1S) make(1S) Asuffixrulewithonlyonesuffixdescribeshowtobuildatargethavinganull(orno)suffixfrom adependencyfilewiththeindicatedsuffix.Forinstance,the.crulecouldbeusedtobuildan executableprogramnamedfilefromaCsourcefilenamed‘file.c’.Ifatargetwithanullsuffix hasanexplicitdependency,makeomitsthesearchforasuffixrule. TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine Assembly.s.o$(COMPILE.s)−o$@$< Files.s.a$(COMPILE.s)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .s˜ .o$(−s1GET)$(−s1GFLAGS)−p$<>$*.s $(−s1COMPILE.s)−o$@$*.s .S.o$(COMPILE.S)−o$@$< .S.a$(COMPILE.S)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .S˜ .o$(GET)$(GFLAGS)−p$<>$*.S $(COMPILE.S)−o$@$*.S .S˜ .a$(GET)$(GFLAGS)−p$<>$*.S $(COMPILE.S)−o$%$*.S $(AR)$(ARFLAGS)$@$% $(RM)$% TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine C.c$(LINK.c)−o$@$<$(LDLIBS) Files.c.ln$(LINT.c)$(OUTPUTOPTION)−i$< .c.o$(COMPILE.c)$(OUTPUTOPTION)$< .c.a$(COMPILE.c)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .c˜ $(GET)$(GFLAGS)−p$<>$*.c $(CC)$(CFLAGS)$(LDFLAGS)−o$@$*.c .c˜ .o$(GET)$(GFLAGS)−p$<>$*.c $(CC)$(CFLAGS)−c$*.c .c˜ .ln$(GET)$(GFLAGS)−p$<>$*.c $(LINT.c)$(OUTPUTOPTION)−c$*.c .c˜ .a$(GET)$(GFLAGS)−p$<>$*.c $(COMPILE.c)−o$%$*.c $(AR)$(ARFLAGS)$@$% $(RM)$% 18Mar1997 12 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine C++.cc$(LINK.cc)−o$@$<$(LDLIBS) Files.cc.o$(COMPILE.cc)$(OUTPUTOPTION)$< .cc.a$(COMPILE.cc)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .cc˜ $(GET)$(GFLAGS)−p$<>$*.cc $(LINK.cc)−o$@$*.cc$(LDLIBS) .cc.o$(COMPILE.cc)$(OUTPUTOPTION)$< .cc˜ .o$(GET)$(GFLAGS)−p$<>$*.cc $(COMPILE.cc)$(OUTPUTOPTION)$*.cc .cc.a$(COMPILE.cc)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .cc˜ .a$(GET)$(GFLAGS)−p$<>$*.cc $(COMPILE.cc)−o$%$*.cc $(AR)$(ARFLAGS)$@$% $(RM)$% .C$(LINK.C)−o$@$<$(LDLIBS) .C˜ $(GET)$(GFLAGS)−p$<>$*.C $(LINK.C)−o$@$*.C$(LDLIBS) .C.o$(COMPILE.C)$(OUTPUTOPTION)$< .C˜ .o$(GET)$(GFLAGS)−p$<>$*.C $(COMPILE.C)$(OUTPUTOPTION)$*.C .C.a$(COMPILE.C)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .C˜ .a$(GET)$(GFLAGS)−p$<>$*.C $(COMPILE.C)−o$%$*.C $(AR)$(ARFLAGS)$@$% $(RM)$% 18Mar1997 13 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine FORTRAN77.f$(LINK.f)−o$@$<$(LDLIBS) Files.f.o$(COMPILE.f)$(OUTPUTOPTION)$< .f.a$(COMPILE.f)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .f$(LINK.f)−o$@$<$(LDLIBS) .f˜ $(GET)$(GFLAGS)−p$<>$*.f $(FC)$(FFLAGS)$(LDFLAGS)−o$@$*.f .f˜ .o$(GET)$(GFLAGS)−p$<>$*.f $(FC)$(FFLAGS)−c$*.f .f˜ .a$(GET)$(GFLAGS)−p$<>$*.f $(COMPILE.f)−o$%$*.f $(AR)$(ARFLAGS)$@$% $(RM)$% .F$(LINK.F)−o$@$<$(LDLIBS) .F.o$(COMPILE.F)$(OUTPUTOPTION)$< .F.a$(COMPILE.F)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .F˜ $(GET)$(GFLAGS)−p$<>$*.F $(FC)$(FFLAGS)$(LDFLAGS)−o$@$*.F .F˜ .o$(GET)$(GFLAGS)−p$<>$*.F $(FC)$(FFLAGS)−c$*.F .F˜ .a$(GET)$(GFLAGS)−p$<>$*.F $(COMPILE.F)−o$%$*.F $(AR)$(ARFLAGS)$@$% $(RM)$% 18Mar1997 14 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine FORTRAN90.f90$(LINK.f90)−o$@$<$(LDLIBS) Files.f90˜ $(GET)$(GFLAGS)−p$<>$*.f90 $(LINK.f90)−o$@$*.f90$(LDLIBS) .f90.o$(COMPILE.f90)$(OUTPUTOPTION)$< .f90˜ .o$(GET)$(GFLAGS)−p$<>$*.f90 $(COMPILE.f90)$(OUTPUTOPTION)$*.f90 .f90.a$(COMPILE.f90)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .f90˜ .a$(GET)$(GFLAGS)−p$<>$*.f90 $(COMPILE.f90)−o$%$*.f90 $(AR)$(ARFLAGS)$@$% $(RM)$% .ftn$(LINK.ftn)−o$@$<$(LDLIBS) .ftn˜ $(GET)$(GFLAGS)−p$<>$*.ftn $(LINK.ftn)−o$@$*.ftn$(LDLIBS) .ftn.o$(COMPILE.ftn)$(OUTPUTOPTION)$< .ftn˜ .o$(GET)$(GFLAGS)−p$<>$*.ftn $(COMPILE.ftn)$(OUTPUTOPTION)$*.ftn .ftn.a$(COMPILE.ftn)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .ftn˜ .a$(GET)$(GFLAGS)−p$<>$*.ftn $(COMPILE.ftn)−o$%$*.ftn $(AR)$(ARFLAGS)$@$% $(RM)$% 18Mar1997 15 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine lex.l$(RM)$*.c Files$(LEX.l)$<>$*.c $(LINK.c)−o$@$*.c$(LDLIBS) $(RM)$*.c .l.c$(RM)$@ $(LEX.l)$<>$@ .l.ln$(RM)$*.c $(LEX.l)$<>$*.c $(LINT.c)−o$@−i$*.c $(RM)$*.c .l.o$(RM)$*.c $(LEX.l)$<>$*.c $(COMPILE.c)−o$@$*.c $(RM)$*.c .l˜ $(GET)$(GFLAGS)−p$<>$*.l $(LEX)$(LFLAGS)$*.l $(CC)$(CFLAGS)−clex.yy.c rm−flex.yy.c mvlex.yy.c$@ .l˜ .c$(GET)$(GFLAGS)−p$<>$*.l $(LEX)$(LFLAGS)$*.l mvlex.yy.c$@ .l˜ .ln$(GET)$(GFLAGS)−p$<>$*.l $(RM)$*.c $(LEX.l)$*.l>$*.c $(LINT.c)−o$@−i$*.c $(RM)$*.c .l˜ .o$(GET)$(GFLAGS)−p$<>$*.l $(LEX)$(LFLAGS)$*.l $(CC)$(CFLAGS)−clex.yy.c rm−flex.yy.c mvlex.yy.c$@ 18Mar1997 16 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleNameCommandLine Modula2.mod$(COMPILE.mod)−o$@−e$@$< Files.mod.o$(COMPILE.mod)−o$@$< .def.sym$(COMPILE.def)−o$@$< .def˜ .sym$(GET)$(GFLAGS)−p$<>$*.def $(COMPILE.def)−o$@$*.def .mod˜ $(GET)$(GFLAGS)−p$<>$*.mod $(COMPILE.mod)−o$@−e$@$*.mod .mod˜ .o$(GET)$(GFLAGS)−p$<>$*.mod $(COMPILE.mod)−o$@$*.mod .mod˜ .a$(GET)$(GFLAGS)−p$<>$*.mod $(COMPILE.mod)−o$%$*.mod $(AR)$(ARFLAGS)$@$% $(RM)$% NeWS.cps.hcps$*.cps Files.cps˜ .h$(GET)$(GFLAGS)−p$<>$*.cps $(CPS)$(CPSFLAGS)$*.cps Pascal.p$(LINK.p)−o$@$<$(LDLIBS) Files.p.o$(COMPILE.p)$(OUTPUTOPTION)$< .p˜ $(GET)$(GFLAGS)−p$<>$*.p $(LINK.p)−o$@$*.p$(LDLIBS) .p˜ .o$(GET)$(GFLAGS)−p$<>$*.p $(COMPILE.p)$(OUTPUTOPTION)$*.p .p˜ .a$(GET)$(GFLAGS)−p$<>$*.p $(COMPILE.p)−o$%$*.p $(AR)$(ARFLAGS)$@$% $(RM)$% Ratfor.r$(LINK.r)−o$@$<$(LDLIBS) Files.r.o$(COMPILE.r)$(OUTPUTOPTION)$< .r.a$(COMPILE.r)−o$%$< $(AR)$(ARFLAGS)$@$% $(RM)$% .r˜ $(GET)$(GFLAGS)−p$<>$*.r $(LINK.r)−o$@$*.r$(LDLIBS) .r˜ .o$(GET)$(GFLAGS)−p$<>$*.r $(COMPILE.r)$(OUTPUTOPTION)$*.r .r˜ .a$(GET)$(GFLAGS)−p$<>$*.r $(COMPILE.r)−o$%$*.r $(AR)$(ARFLAGS)$@$% $(RM)$% 18Mar1997 17 make(1S) make(1S) TableofStandardImplicit(Suffix)Rules UseImplicitRuleName CommandLine SCCS.SCCSGETsccs$(SCCSFLAGS)get$(SCCSGETFLAGS)$@−G$@ Files .SCCSGETPOSIXsccs$(SCCSFLAGS)get$(SCCSGETFLAGS)$@ .GETPOSIX$(GET)$(GFLAGS)s.$@ Shell.shcat$<>$@ Scripts chmod+x$@ .sh˜ $(GET)$(GFLAGS)−p$<>$*.sh cp$*.sh$@ chmoda+x$@ yacc.y$(YACC.y)$< Files $(LINK.c)−o$@y.tab.c$(LDLIBS) $(RM)y.tab.c .y.c$(YACC.y)$< mvy.tab.c$@ .y.ln$(YACC.y)$< $(LINT.c)−o$@−iy.tab.c $(RM)y.tab.c .y.o$(YACC.y)$< $(COMPILE.c)−o$@y.tab.c $(RM)y.tab.c .y˜ $(GET)$(GFLAGS)−p$<>$*.y $(YACC)$(YFLAGS)$*.y $(COMPILE.c)−o$@y.tab.c $(RM)y.tab.c .y˜ .c$(GET)$(GFLAGS)−p$<>$*.y $(YACC)$(YFLAGS)$*.y mvy.tab.c$@ .y˜ .ln$(GET)$(GFLAGS)−p$<>$*.y $(YACC.y)$*.y $(LINT.c)−o$@−iy.tab.c $(RM)y.tab.c .y˜ .o$(GET)$(GFLAGS)−p$<>$*.y $(YACC)$(YFLAGS)$*.y $(CC)$(CFLAGS)−cy.tab.c rm−fy.tab.c mvy.tab.o$@ makereadsinthestandardsetofimplicitrulesfromthefile /usr/share/lib/make/make.rules,unless−risineffect,orthereisamake.rulesfileinthe localdirectorythatdoesnotincludethatfile. TheSuffixesList Thesuffixeslistisgivenasthelistofdependenciesforthe‘.SUFFIXES:’special-functiontarget. ThedefaultlistiscontainedintheSUFFIXESmacro(SeeTableofPredefinedMacrosforthe standardlistofsuffixes).Youcandefineadditional.SUFFIXES:targets;a.SUFFIXEStarget withnodependenciesclearsthelistofsuffixes.Orderissignificantwithinthelist;makeselectsa rulethatcorrespondstothetarget’ssuffixandthefirstdependency-filesuffixfoundinthelist. Toplacesuffixesattheheadofthelist,clearthelistandreplaceitwiththenewsuffixes,followed bythedefaultlist: .SUFFIXES: .SUFFIXES:suffixes$(SUFFIXES) Atilde(˜ )indicatesthatifadependencyfilewiththeindicatedsuffix(minusthe˜ )isunder SCCSitsmostrecentversionshouldberetrieved,ifnecessary,beforethetargetisprocessed. 18Mar1997 18 make(1S) make(1S) LibraryMaintenance Atargetnameoftheform: lib(member...) referstoamember,oraspace-separatedlistofmembers,inanar(1)library. Thedependencyofthelibrarymemberonthecorrespondingfilemustbegivenasanexplicit entryinthemakefile.Thiscanbehandledbyapatternmatchingruleoftheform: lib(%.s):%.s where.sisthesuffixofthemember;thissuffixistypically.oforobjectlibraries. Atargetnameoftheform lib((symbol)) referstothememberofarandomizedobjectlibrarythatdefinestheentrypointnamedsymbol. CommandExecution Commandlinesareexecutedoneatatime,eachbyitsownprocessorshell.Shellcommands, notablycd,areineffectualacrossanunescapedNEWLINEinthemakefile.Alineisprinted(after macroexpansion)justbeforebeingexecuted.Thisissuppressedifitstartswitha‘@’,ifthereis a‘.SILENT:’entryinthemakefile,orifmakeisrunwiththe−soption.Althoughthe−n optionspecifiesprintingwithoutexecution,linescontainingthemacro$(MAKE)areexecuted regardless,andlinescontainingthe@specialcharacterareprinted.The−t(touch)option updatesthemodificationdateofafilewithoutexecutinganyrules.Thiscanbedangerouswhen sourcesaremaintainedbymorethanoneperson. makeinvokestheshellwiththe−e(exit-on-errors)argument.Thus,withsemicolon-separated commandsequences,executionofthelatercommandsdependsonthesuccessoftheformer.This behaviorcanbeoverriddenbystartingthecommandlinewitha‘-’,orbywritingashellscript thatreturnsanon-zerostatusonlyasitfindsappropriate. BourneShellConstructs TousetheBourneshellifcontrolstructureforbranching,useacommandlineoftheform: ifexpression;\ thencommand;\ ...;\ elsecommand;\ ...;\ fi Althoughcomposedofseveralinputlines,theescapedNEWLINEcharactersinsurethatmake treatsthemallasone(shell)commandline. TousetheBourneshellforcontrolstructureforloops,useacommandlineoftheform: forvarinlist;\ docommand;\ ...;\ done Torefertoashellvariable,useadouble-dollar-sign($$).Thispreventsexpansionofthedollar-signbymake. CommandSubstitutions Toincorporatethestandardoutputofashellcommandinamacro,useadefinitionoftheform: MACRO:sh=command Thecommandisexecutedonlyonce,standarderroroutputisdiscarded,andNEWLINEcharacters arereplacedwithSPACEs.Ifthecommandhasanon-zeroexitstatus,makehaltswithanerror. 18Mar1997 19 make(1S) make(1S) Tocapturetheoutputofashellcommandinamacroreference,useareferenceoftheform: $(MACRO:sh) whereMACROisthenameofamacrocontainingavalidBourneshellcommandline.Inthiscase, thecommandisexecutedwheneverthereferenceisevaluated.Aswithshellcommandsubstitutions,thereferenceisreplacedwiththestandardoutputofthecommand.Ifthecommandhasa non-zeroexitstatus,makehaltswithanerror. Incontrasttocommandsinrules,thecommandisnotsubjectformacrosubstitution;therefore,a dollarsign($)neednotbereplacedwithadoubledollarsign($$). Signals INT,SIGTERM,andQUITsignalsreceivedfromthekeyboardhaltmakeandremovethetarget filebeingprocessedunlessthattargetisinthedependencylistfor.PRECIOUS:. EXAMPLES Thismakefilesaysthatpgmdependsontwofilesa.oandb.o,andthattheyinturndependon theircorrespondingsourcefiles(a.candb.c)alongwithacommonfileincl.h: pgm:a.ob.o $(LINK.c)−o$@a.ob.o a.o:incl.ha.c cc−ca.c b.o:incl.hb.c cc−cb.c Thefollowingmakefileusesimplicitrulestoexpressthesamedependencies: pgm:a.ob.o cca.ob.o−opgm a.ob.o:incl.h ENVIRONMENT Seeenviron(5)fordescriptionsofthefollowingenvironmentvariablesthataffecttheexecutionof make:LCCTYPE,LCMESSAGES,andNLSPATH. KEEPSTATE Thisenvironmentvariablehasthesameeffectasthe.KEEPSTATE:special-function target.Itenablescommanddependencies,hiddendependenciesandwritingofthe statefile. USESVR4MAKE ThisenvironmentvariablecausesmaketoinvokethegenericSystemVversionof make(/usr/ccs/lib/svr4.make).SeesysV-make(1). MAKEFLAGS Thisvariableisinterpretedasacharacterstringrepresentingaseriesofoptioncharacterstobeusedasthedefaultoptions.Theimplementationwillacceptbothofthefollowingformats(butneednotacceptthemwhenintermixed): 1.Thecharactersareoptionletterswithouttheleadinghyphensorblankcharacterseparationusedonacommandline. 2.Thecharactersareformattedinamannersimilartoaportionofthemake commandline:optionsareprecededbyhyphensandblank-character-separated.Themacro=namemacrodefinitionoperandscanalsobeincluded. ThedifferencebetweenthecontentsofMAKEFLAGSandthecommandline isthatthecontentsofthevariablewillnotbesubjectedtothewordexpansions(seewordexp(3C))associatedwithparsingthecommandlinevalues. Whenthecommand-lineoptions−for−pareused,theywilltakeeffectregardlessof whethertheyalsoappearinMAKEFLAGS.Iftheyotherwiseappearin 18Mar1997 20 make(1S) make(1S) MAKEFLAGS,theresultisundefined. TheMAKEFLAGSvariablewillbeaccessedfromtheenvironmentbeforethemakefileisread. Atthattime,alloftheoptions(except−fand−p)andcommand-linemacrosnotalready includedinMAKEFLAGSareaddedtotheMAKEFLAGSmacro.TheMAKEFLAGSmacro willbepassedintotheenvironmentasanenvironmentvariableforallchildprocesses.Ifthe MAKEFLAGSmacroissubsequentlysetbythemakefile,itreplacestheMAKEFLAGSvariable currentlyfoundintheenvironment. EXITSTATUS Whenthe−qoptionisspecified,themakeutilitywillexitwithoneofthefollowingvalues: 0Successfulcompletion. 1Thetargetwasnotup-to-date. >1Anerroroccurred. Whenthe−qoptionisnotspecified,themakeutilitywillexitwithoneofthefollowingvalues: 0successfulcompletion >0anerroroccurred FILES makefile Makefilecurrentversion(s)ofmakedescriptionfile s.makefile s.MakefileSCCShistoryfilesfortheabovemakefile(s)inthecurrentdirectory SCCS/s.makefile SCCS/s.MakefileSCCShistoryfilesfortheabovemakefile(s) make.rulesdefaultfileforuser-definedtargets,macros,andimplicitrules /usr/share/lib/make/make.rules makefileforstandardimplicitrulesandmacros(notreadifmake.rulesis) .make.statestatefileinthelocaldirectory ATTRIBUTES Seeattributes(5)fordescriptionsofthefollowingattributes: /usr/ccs/bin/make ATTRIBUTETYPEATTRIBUTEVALUE AvailabilitySUNWsprot /usr/xpg4/bin/make ATTRIBUTETYPEATTRIBUTEVALUE AvailabilitySUNWxcu4t SEEALSO ar(1),cd(1),lex(1),sh(1),sccs-get(1),sysV-make(1)yacc(1),passwd(4),attributes(5), POSIX.2(5) DIAGNOSTICS Don’tknowhowtomaketarget’target’ Thereisnomakefileentryfortarget,andnoneofmake’simplicitrulesapply(thereisno dependencyfilewithasuffixinthesuffixeslist,orthetarget’ssuffixisnotinthelist). ***targetremoved. makewasinterruptedwhilebuildingtarget.Ratherthanleavingapartially-completed versionthatisnewerthanitsdependencies,makeremovesthefilenamedtarget. 18Mar1997 21 make(1S) make(1S) ***targetnotremoved. makewasinterruptedwhilebuildingtargetandtargetwasnotpresentinthedirectory. ***targetcouldnotberemoved,reason makewasinterruptedwhilebuildingtarget,whichwasnotremovedfortheindicatedreason. Readofincludefile‘file’failed Themakefileindicatedinanincludedirectivewasnotfound,orwasinaccessible. Loopdetectedwhenexpandingmacrovalue‘macro’ Areferencetothemacrobeingdefinedwasfoundinthedefinition. Couldnotwritestatefile‘file’ Youusedthe.KEEPSTATE:target,butdonothavewritepermissiononthestatefile. ***Errorcoden Thepreviousshellcommandreturnedanonzeroerrorcode. ***signalmessage Thepreviousshellcommandwasabortedduetoasignal.If‘−coredumped’appears afterthemessage,acorefilewascreated. Conditionalmacroconflictencountered Displayedonlywhen−disineffect,thismessageindicatesthattwoormoreparalleltargetscurrentlybeingprocesseddependonatargetwhichisbuiltdifferentlyforeachby virtueofconditionalmacros.Sincethetargetcannotsimultaneouslysatisfybothdependencyrelationships,itisconflicted. BUGS Somecommandsreturnnonzerostatusinappropriately;toovercomethisdifficulty,prefixthe offendingcommandlineintherulewitha‘−’. Filenameswiththecharacters‘=’,‘:’,or‘@’,donotwork. Youcannotbuildfile.ofromlib(file.o). OptionssuppliedbyMAKEFLAGSshouldbereportedfornestedmakecommands.Usethe−d optiontofindoutwhatoptionsthenestedcommandpicksupfromMAKEFLAGS. Thisversionofmakeisincompatibleincertainrespectswithpreviousversions: •The−doptionoutputismuchbrieferinthisversion.−ddnowproducestheequivalentvoluminousoutput. •makeattemptstoderivevaluesforthedynamicmacros‘$*’,‘$<’,and‘$?’,while processingexplicittargets.Itusesthesamemethodasforimplicitrules;insome casesthiscanleadeithertounexpectedvalues,ortoanemptyvaluebeingassigned. (Actually,thiswastrueforearlierversionsaswell,eventhoughthedocumentation statedotherwise.) •makenolongersearchesforSCCShistory"(s.)"files. •Suffixreplacementinmacroreferencesarenowappliedafterthemacroisexpanded. Thereisnoguaranteethatmakefilescreatedforthisversionofmakewillworkwithearlierversions. Ifthereisnomake.rulesfileinthecurrentdirectory,andthefile /usr/share/lib/make/make.rulesismissing,makestopsbeforeprocessinganytargets.To forcemaketorunanyway,createanemptymake.rulesfileinthecurrentdirectory. Onceadependencyismade,makeassumesthedependencyfileispresentfortheremainderof therun.Ifarulesubsequentlyremovesthatfileandfuturetargetsdependonitsexistence,unexpectederrorsmayresult. Whenhiddendependencycheckingisineffect,the$?macro’svalueincludesthenamesofhidden 18Mar1997 22 make(1S) make(1S) dependencies.Thiscanleadtoimproperfilenameargumentstocommandswhen$?isusedina rule. Patternreplacementmacroreferencescannotbeusedinthedependencylistofapatternmatching rule. Unlikepreviousversions,thisversionofmakestripsaleading‘./’fromthevalueofthe‘$@’ dynamicmacro. WithautomaticSCCSretrieval,thisversionofmakedoesnotsupporttildesuffixrules. Theonlydynamicmacrowhosevalueisstrictlydeterminedwhenusedinadependencylistis$@ (takestheform‘$$@’). makeinvokestheshellwiththe−eargument.Thiscannotbeinferredfromthesyntaxofthe rulealone. 18Mar1997 23