asp.net mvc create pdf from view : Change font size in pdf form SDK control service wpf azure windows dnn make5-part1270

Chapter5:WritingRecipesinRules
41
5 WritingRecipesinRules
Therecipeofaruleconsistsofoneormoreshellcommandlinestobeexecuted,oneata
time,intheordertheyappear. Typically,theresultofexecutingthesecommandsisthat
thetargetoftheruleisbroughtuptodate.
Usersusemanydifferentshellprograms,butrecipesinmakefilesarealwaysinterpreted
by /bin/sh unless s the e makefile specifies s otherwise. . See Section 5.3 [Recipe Execution],
page44.
5.1 RecipeSyntax
Makefiles have the unusual property that t there e are really two distinct t syntaxes s in n one
file. Mostofthe e makefileuses makesyntax(see Chapter3[WritingMakefiles],page 11).
However,recipes are meanttobeinterpretedby the shellandso they arewrittenusing
shellsyntax. Themakeprogramdoesnottrytounderstandshellsyntax: itperformsonly
averyfewspecifictranslationsonthecontentoftherecipebeforehandingittotheshell.
Eachlineintherecipemuststartwithatab(orthefirstcharacterinthevalueofthe
.RECIPEPREFIXvariable;seeSection6.14[SpecialVariables],page73),exceptthatthefirst
recipelinemaybeattachedtothetarget-and-prerequisiteslinewithasemicoloninbetween.
Any lineinthemakefile thatbeginswithatabandappearsina“rulecontext”(that t is,
after arulehasbeenstarted d untilanother r ruleor variable definition)willbeconsidered
partofarecipeforthatrule. Blanklinesandlinesofjust t comments mayappear among
therecipelines;theyareignored.
Someconsequencesoftheserulesinclude:
 Ablanklinethatbeginswithatabisnotblank: : it’sanemptyrecipe(seeSection5.9
[EmptyRecipes],page57).
 Acomment t in n arecipe is s not a make comment; ; it willbe passed to theshellas-is.
Whethertheshelltreatsitasacommentornotdependsonyourshell.
 Avariabledefinitionina“rulecontext”whichisindentedbyatabasthefirstcharacter
ontheline,willbeconsideredpartofarecipe,notamakevariabledefinition,andpassed
totheshell.
 Aconditionalexpression(ifdef,ifeq,etc. . seeSection7.2[SyntaxofConditionals],
page78)ina“rulecontext”whichisindentedby atabas thefirstcharacteronthe
line,willbeconsideredpartofarecipeandbepassedtotheshell.
5.1.1 SplittingRecipeLines
Oneofthefewwaysinwhichmakedoes interpretrecipesischeckingfor abackslashjust
beforethenewline. As s innormalmakefilesyntax,asinglelogicalrecipelinecanbesplit
intomultiplephysicallines inthemakefileby placingabackslashbeforeeachnewline. . A
sequenceoflineslikethisisconsideredasinglerecipeline,andoneinstanceoftheshellwill
beinvokedtorunit.
However, in n contrast to how w they y are e treated d in other places in a makefile (see
Section 3.1.1 [Splitting Long Lines], page e 12), backslash/newline pairs s are e not t removed
fromtherecipe. Boththebackslashandthenewlinecharactersarepreservedandpassed
totheshell. Howthebackslash/newlineis s interpreteddependsonyourshell. . If f thefirst
Change font size in pdf form - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
compress pdf; best pdf compression
Change font size in pdf form - VB.NET PDF File Compress Library: Compress reduce PDF size in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Compression and Decompression Control SDK
change paper size in pdf document; pdf compression
42
GNUmake
characterofthenextlineafterthebackslash/newlineistherecipeprefixcharacter(atab
by default; ; see Section6.14[SpecialVariables],page 73), thenthat t character (and d only
thatcharacter)isremoved. Whitespaceisneveraddedtotherecipe.
Forexample,therecipeforthealltargetinthismakefile:
all :
@echo no\
space
@echo no\
space
@echo one \
space
@echo one\
space
consistsoffourseparateshellcommandswheretheoutputis:
nospace
nospace
one space
one space
Asamorecomplexexample,thismakefile:
all : ; @echo ’hello o \
world’ ; echo "hello \
world"
willinvokeoneshellwithacommandof:
echo ’hello o \
world’ ; echo "hello o \
world"
which,accordingtoshellquotingrules,willyieldthefollowingoutput:
hello \
world
hello
world
Noticehowthebackslash/newlinepairwas removedinsidethestringquotedwithdouble
quotes("..."),butnotfromthestringquotedwithsinglequotes(’...’). Thisistheway
thedefaultshell(/bin/sh)handlesbackslash/newlinepairs. Ifyouspecifyadifferentshell
inyourmakefilesitmaytreatthemdifferently.
Sometimesyouwanttosplitalonglineinsideofsinglequotes,butyoudon’twantthe
backslash/newline toappear inthe quotedcontent. . This s is oftenthecasewhenpassing
scriptstolanguagessuchasPerl,whereextraneousbackslashesinsidethescriptcanchange
its meaningor evenbe a syntax error. . One e simple way of handling this is to placethe
quotedstring,oreventheentire command,intoa makevariablethenusethevariable in
therecipe. Inthissituationthenewlinequotingrulesformakefileswillbeused,andthe
backslash/newlinewillberemoved.Ifwerewriteourexampleaboveusingthismethod:
HELLO = ’hello \
world’
all : ; @echo $(HELLO)
C# PDF Field Edit Library: insert, delete, update pdf form field
Able to add text field to specified PDF file position in C#.NET class. Support to change font size in PDF form. Able to delete form fields from adobe PDF file.
pdf reduce file size; change font size in fillable pdf
C# PDF Sticky Note Library: add, delete, update PDF note in C#.net
Allow users to add comments online in ASPX webpage. Able to change font size in PDF comment box. Able to save and print sticky notes in PDF file.
adjust size of pdf in preview; pdf page size dimensions
Chapter5:WritingRecipesinRules
43
wewillgetoutputlikethis:
hello world
If youlike,youcanalsousetarget-specific variables (see Section6.11 [Target-specific
VariableValues],page71)toobtainatightercorrespondencebetweenthevariableandthe
recipethatusesit.
5.1.2 UsingVariablesinRecipes
Theotherwayinwhichmakeprocessesrecipesisbyexpandinganyvariablereferences in
them(seeSection6.1[Reference],page59). Thisoccursafter r make hasfinishedreading
allthemakefilesandthetargetisdeterminedtobeoutofdate;so,therecipesfortargets
whicharenotrebuiltareneverexpanded.
Variableandfunctionreferencesinrecipeshaveidenticalsyntax andsemanticstoref-
erenceselsewhereinthemakefile. They y alsohavethesame quotingrules: : ifyouwanta
dollarsigntoappearinyourrecipe,youmustdoubleit(‘$$’). Forshellslikethedefault
shell,thatusedollarsignstointroducevariables,it’simportanttokeepclearinyourmind
whetherthevariableyouwanttoreferenceisamakevariable(useasingledollarsign)ora
shellvariable(usetwodollarsigns).Forexample:
LIST = = one two three
all:
for i in $(LIST); do \
echo $$i; \
done
resultsinthefollowingcommandbeingpassedtotheshell:
for i in one e two o three; ; do \
echo $i; ; \
done
whichgeneratestheexpectedresult:
one
two
three
5.2 RecipeEchoing
Normally make prints eachlineofthe recipe before it is executed. . Wecall l this echoing
becauseitgivestheappearancethatyouaretypingthelinesyourself.
Whenalinestartswith‘@’,theechoingofthatlineissuppressed. The‘@’isdiscarded
beforethelineispassedtotheshell. Typicallyyouwouldusethisforacommandwhose
only effectistoprint something,suchasanechocommandtoindicateprogress through
themakefile:
@echo About to make distribution files
Whenmakeisgiventheflag‘-n’or‘--just-print’itonlyechoesmostrecipes,without
executingthem. See Section9.7[SummaryofOptions],page 104. Inthiscaseeventhe
recipelinesstartingwith‘@’are printed. . Thisflagis s usefulforfindingoutwhichrecipes
makethinksarenecessarywithoutactuallydoingthem.
C# PDF insert text Library: insert text into PDF content in C#.net
Powerful .NET PDF edit control allows modify existing scanned PDF text. Ability to change text font, color, size and location and output a new PDF document.
best pdf compression tool; pdf page size may not be reduced
C# PDF Text Box Edit Library: add, delete, update PDF text box in
Support to change font color in PDF text box. Ability to change text size in PDF text box. Adding text box is another way to add text to PDF page.
can a pdf file be compressed; pdf page size
44
GNUmake
The ‘-s’or ‘--silent’flagtomakeprevents allechoing,as ifallrecipesstartedwith
‘@’.Aruleinthemakefileforthespecialtarget.SILENTwithoutprerequisiteshasthesame
effect (see Section4.8 [SpecialBuilt-in Target Names], page 32). . .SILENT T is essentially
obsoletesince‘@’ismoreflexible.
5.3 RecipeExecution
Whenitistimetoexecuterecipestoupdateatarget,theyareexecutedbyinvokinganew
sub-shellfor each h lineoftherecipe,unless s the .ONESHELL specialtarget is ineffect (see
Section5.3.1[UsingOneShell],page44)(Inpractice,makemaytakeshortcutsthatdonot
affecttheresults.)
Pleasenote: thisimpliesthatsettingshellvariablesandinvokingshellcommandssuch
ascdthatsetacontextlocaltoeachprocesswillnotaffectthefollowinglinesintherecipe.
1
Ifyouwanttousecdtoaffectthenextstatement,putbothstatementsinasinglerecipe
line. Thenmakewillinvokeoneshelltoruntheentireline,andtheshellwillexecutethe
statementsinsequence.Forexample:
foo : bar/lose
cd $(@D) && gobble e $(@F) ) > > ../$@
HereweusetheshellANDoperator(&&)sothatifthecdcommandfails,thescriptwillfail
withouttryingtoinvokethe gobblecommandinthewrongdirectory,whichcouldcause
problems(inthiscaseitwouldcertainlycause../footobetruncated,atleast).
5.3.1 UsingOneShell
Sometimesyouwouldpreferthatallthelinesintherecipebepassedtoasingleinvocation
oftheshell. Thereare e generallytwosituations wherethis isuseful: : first,itcanimprove
performanceinmakefileswhererecipesconsistofmanycommandlines,byavoidingextra
processes. Second,youmightwant t newlines to beincludedinyourrecipecommand(for
exampleperhapsyouareusingaverydifferentinterpreterasyourSHELL). Ifthe.ONESHELL
specialtargetappearsanywhereinthemakefilethenall recipelinesforeachtargetwillbe
providedtoasingleinvocationoftheshell. Newlinesbetweenrecipelineswillbepreserved.
Forexample:
.ONESHELL:
foo : bar/lose
cd $(@D)
gobble $(@F) ) > > ../$@
wouldnowworkasexpectedeventhoughthecommandsareondifferentrecipelines.
If.ONESHELL isprovided,thenonlythefirstlineofthe recipewillbecheckedforthe
specialprefix characters (‘@’,‘-’,and‘+’). . Subsequentlineswillincludethespecialchar-
actersintherecipelinewhentheSHELLisinvoked. Ifyouwantyourrecipetostartwith
oneofthesespecialcharactersyou’llneedtoarrangeforthemtonotbethefirstcharacters
onthefirst line,perhaps by addingacomment orsimilar. . Forexample,thiswouldbea
syntaxerrorinPerlbecausethefirst‘@’isremovedbymake:
1
On MS-DOS, the value of current working g directory is s global, sochanging g it t will l affect t thefollowing
recipelinesonthosesystems.
C# PDF Annotate Library: Draw, edit PDF annotation, markups in C#.
Able to edit and change PDF annotation properties such as font size or color. Abilities to draw markups on PDF document or stamp on PDF file.
pdf file size; best compression pdf
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
PDF document, keeps the elements (like images, tables and chats) of original PDF file and maintains the original text style (including font, size, color, links
best way to compress pdf file; change file size of pdf
Chapter5:WritingRecipesinRules
45
.ONESHELL:
SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show :
@f = = qw(a a b c);
print "@f\n";
However,eitherofthesealternativeswouldworkproperly:
.ONESHELL:
SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show :
# Make e sure "@" " is not t the e first t character on n the e first line
@f = = qw(a a b c);
print "@f\n";
or
.ONESHELL:
SHELL = /usr/bin/perl
.SHELLFLAGS = -e
show :
my @f = = qw(a b b c);
print "@f\n";
Asaspecialfeature,ifSHELLisdeterminedtobeaPOSIX-styleshell,thespecialprefix
charactersin“internal”recipelineswillremovedbeforetherecipeisprocessed. Thisfeature
is intendedtoallowexistingmakefiles to addthe .ONESHELLspecialtarget andstillrun
properlywithoutextensivemodifications. Sincethespecialprefixcharactersarenotlegal
at thebeginningofaline inaPOSIXshellscript thisis not aloss infunctionality. . For
example,thisworksasexpected:
.ONESHELL:
foo : bar/lose
@cd $(@D)
@gobble $(@F) ) > > ../$@
Evenwiththisspecialfeature,however,makefileswith.ONESHELLwillbehavedifferently
inwaysthatcouldbenoticeable.Forexample,normallyifanylineintherecipefails,that
causestheruletofailandnomorerecipelinesareprocessed. Under.ONESHELLafailure
ofanybutthefinalrecipelinewillnotbenoticedbymake. Youcanmodify.SHELLFLAGS
toaddthe-eoptiontotheshellwhichwillcause anyfailureanywhereinthecommand
linetocausetheshelltofail,butthiscoulditselfcauseyourrecipetobehavedifferently.
Ultimatelyyoumayneedtohardenyourrecipelinestoallowthemtoworkwith.ONESHELL.
5.3.2 ChoosingtheShell
TheprogramusedastheshellistakenfromthevariableSHELL. Ifthisvariableisnotset
inyourmakefile,theprogram/bin/shisusedastheshell.Theargument(s)passedtothe
shellare takenfromthe variable .SHELLFLAGS. . The e default value of .SHELLFLAGS is -c
normally,or-ecinPOSIX-conformingmode.
Generate Barcodes in Web Image Viewer| Online Tutorials
Select "Generate" to process barcode generation; Change Barcode Properties. Select "Font" to choose human-readable text font style, color, size and effects;
pdf files optimized; change file size of pdf document
VB.NET Image: Visual Basic .NET Guide to Draw Text on Image in .
Please note that you can change some of the example, you can adjust the text font, font size, font type (regular LoadImage) Dim DrawFont As New Font("Arial", 16
pdf compressor; change font size in pdf text box
46
GNUmake
Unlike most variables, the variable SHELLis neversetfromtheenvironment. . This s is
because the e SHELL environment t variable e is used to specify your personal choice of shell
programforinteractiveuse.Itwouldbeverybadforpersonalchoiceslikethistoaffectthe
functioningofmakefiles. SeeSection6.10[VariablesfromtheEnvironment],page70.
Furthermore,whenyoudosetSHELLinyourmakefilethatvalueisnot exportedinthe
environmenttorecipelinesthatmakeinvokes. Instead,thevalueinheritedfromtheuser’s
environment,if any, is exported. . You u can overridethis s behavior byexplicitly exporting
SHELL(seeSection5.7.2[CommunicatingVariablestoaSub-make],page52),forcingitto
bepassedintheenvironmenttorecipelines.
However,onMS-DOSandMS-WindowsthevalueofSHELLintheenvironmentisused,
sinceonthosesystems mostusersdonotsetthis variable,andthereforeitis mostlikely
setspecificallytobeusedbymake.OnMS-DOS,ifthesettingofSHELLisnotsuitablefor
make,youcansetthevariableMAKESHELLtotheshellthatmakeshoulduse;ifsetitwillbe
usedastheshellinsteadofthevalueofSHELL.
ChoosingaShellinDOSandWindows
ChoosingashellinMS-DOSandMS-Windowsismuchmorecomplexthanonothersystems.
OnMS-DOS,ifSHELLisnotset,thevalueofthevariableCOMSPEC(whichisalwaysset)
isusedinstead.
TheprocessingoflinesthatsetthevariableSHELLinMakefilesisdifferentonMS-DOS.
Thestockshell,command.com,isridiculouslylimitedinitsfunctionalityandmanyusersof
maketendtoinstallareplacementshell. Therefore,onMS-DOS,makeexaminesthevalue
ofSHELL,andchangesitsbehaviorbasedonwhetheritpointstoaUnix-styleorDOS-style
shell. ThisallowsreasonablefunctionalityevenifSHELLpointstocommand.com.
IfSHELLpointstoaUnix-styleshell,makeonMS-DOSadditionallycheckswhetherthat
shellcanindeedbe found;if not,itignores thelinethat sets SHELL. . InMS-DOS,GNU
makesearchesfortheshellinthefollowingplaces:
1. Inthe e precise placepointedtoby the value of SHELL. . Forexample,if f the makefile
specifies‘SHELL=/bin/sh’,makewilllookinthedirectory/binonthecurrentdrive.
2. Inthecurrentdirectory.
3. IneachofthedirectoriesinthePATHvariable,inorder.
Ineverydirectoryitexamines,makewillfirstlookforthespecificfile(shintheexample
above). Ifthisisnotfound,itwillalsolookinthatdirectoryforthatfilewithoneofthe
knownextensionswhichidentifyexecutablefiles.Forexample.exe,.com,.bat,.btm,.sh,
andsomeothers.
Ifanyoftheseattemptsissuccessful,thevalueofSHELLwillbesettothefullpathname
of the shellas found. . However, , ifnone ofthese isfound, the valueofSHELL L willnot be
changed,andthusthelinethatsetsitwillbeeffectivelyignored. Thisissomakewillonly
support features s specific c to a Unix-style shell if sucha shell is actually installedonthe
systemwheremakeruns.
Notethatthisextendedsearchfortheshellislimitedtothecaseswhere SHELL isset
fromtheMakefile;ifitissetintheenvironmentorcommandline,youareexpectedtoset
ittothefullpathnameoftheshell,exactlyasthingsareonUnix.
Chapter5:WritingRecipesinRules
47
TheeffectoftheaboveDOS-specificprocessingisthataMakefilethatcontains‘SHELL
=/bin/sh’(asmanyUnixmakefilesdo),willworkonMS-DOSunalteredifyouhavee.g.
sh.exeinstalledinsomedirectoryalongyourPATH.
5.4 ParallelExecution
GNU make e knows s how w to execute severalrecipes at once. . Normally, , make e will l execute
onlyonerecipeatatime,waitingforittofinishbeforeexecutingthenext. However,the
‘-j’or‘--jobs’optiontellsmaketoexecutemanyrecipessimultaneously.Youcaninhibit
parallelisminaparticularmakefilewiththe.NOTPARALLELpseudo-target(seeSection4.8
[SpecialTargets],page32).
On MS-DOS, the‘-j’optionhas noeffect, since that t system m doesn’t t support multi-
processing.
Ifthe‘-j’optionisfollowedbyaninteger,thisisthenumberofrecipestoexecuteat
once;thisiscalledthenumberofjobslots.Ifthereisnothinglookinglikeanintegerafter
the‘-j’option,thereis nolimit onthenumber of jobslots. . Thedefaultnumberof f job
slotsisone,whichmeansserialexecution(onethingatatime).
Handlingrecursivemakeinvocationsraisesissuesforparallelexecution. Formoreinfor-
mationonthis,seeSection5.7.3[CommunicatingOptionstoaSub-make],page54.
If a recipe fails (is killed by a signal or exits s witha a nonzero status), and errors are
not ignoredfor that recipe (seeSection 5.5 [Errors s inRecipes], , page49),the remaining
recipe lines to remake the sametarget will not be run. . If f arecipe fails andthe ‘-k’or
‘--keep-going’optionwas not given(see Section 9.7[Summary y ofOptions],page104),
makeabortsexecution. Ifmaketerminates s foranyreason(includingasignal)withchild
processesrunning,itwaitsforthemtofinishbeforeactuallyexiting.
Whenthesystemisheavilyloaded,youwillprobablywanttorunfewerjobsthanwhen
itislightlyloaded.Youcanusethe‘-l’optiontotellmaketolimitthenumberofjobsto
runatonce,basedontheloadaverage. The‘-l’or‘--max-load’optionisfollowedby y a
floating-pointnumber. Forexample,
-l 2.5
willnotletmakestartmorethanonejobiftheloadaverageisabove2.5. The‘-l’option
with no following number r removes the load d limit, if one was givenwith a previous s ‘-l’
option.
More precisely,whenmake goes tostartupajob,anditalready hasatleastonejob
running,itchecksthecurrentloadaverage;ifitisnotlowerthanthelimitgivenwith‘-l’,
makewaitsuntiltheloadaveragegoesbelowthatlimit,oruntilalltheotherjobsfinish.
Bydefault,thereisnoloadlimit.
5.4.1 OutputDuringParallelExecution
Whenrunning severalrecipesinparalleltheoutput fromeachrecipeappears as soonas
it isgenerated, , withthe resultthat t messagesfromdifferent recipes may beinterspersed,
sometimesevenappearingonthesameline.Thiscanmakereadingtheoutputverydifficult.
Toavoidthisyoucanusethe‘--output-sync’(‘-O’)option.Thisoptioninstructsmake
tosavetheoutputfromthecommandsitinvokesandprintit alloncethecommandsare
48
GNUmake
completed.Additionally,iftherearemultiplerecursivemakeinvocationsrunninginparallel,
theywillcommunicatesothatonlyoneofthemisgeneratingoutputatatime.
If workingdirectory printingis enabled(see Section5.7.4 [The ‘--print-directory’
Option],page55),theenter/leavemessagesareprintedaroundeachoutputgrouping. If
youprefernottoseethesemessagesaddthe‘--no-print-directory’optiontoMAKEFLAGS.
Therearefourlevels ofgranularity whensynchronizingoutput,specifiedbygivingan
argumenttotheoption(e.g.,‘-Oline’or‘--output-sync=recurse’).
none
Thisisthedefault:alloutputissentdirectlyasitisgeneratedandnosynchro-
nizationisperformed.
line
Outputfromeachindividuallineoftherecipeisgroupedandprintedassoon
as that t line e is complete. . If f a recipe consists s of f multiple lines, they may y be
interspersedwithlinesfromotherrecipes.
target
Outputfromtheentirerecipeforeachtargetisgroupedandprintedoncethe
target is complete. . Thisis s thedefaultif the --output-sync or -O optionis
givenwithnoargument.
recurse
Outputfromeachrecursiveinvocationofmakeisgroupedandprintedoncethe
recursiveinvocationiscomplete.
Regardlessofthemodechosen,thetotalbuildtimewillbethesame. Theonlydifference
isinhowtheoutputappears.
The‘target’and‘recurse’modesbothcollecttheoutputoftheentirerecipeofatarget
anddisplayituninterruptedwhentherecipecompletes.Thedifferencebetweenthemisin
howrecipesthatcontainrecursiveinvocationsofmakearetreated(seeSection5.7[Recursive
Use of make], page 50). For r all l recipes which have no recursive lines, the ‘target’ and
‘recurse’modesbehaveidentically.
If the ‘recurse’ mode e is s chosen, , recipes s that containrecursive make e invocations s are
treatedthesameasothertargets: theoutputfromtherecipe,includingtheoutputfrom
therecursive make,is savedandprintedaftertheentirerecipeis complete. . Thisensures
outputfromallthetargetsbuiltbyagivenrecursivemakeinstancearegroupedtogether,
whichmaymaketheoutputeasiertounderstand.Howeveritalsoleadstolongperiodsof
timeduringthebuildwherenooutput isseen,followedbylargeburstsofoutput. . Ifyou
arenotwatchingthebuildasitproceeds,butinsteadviewingalogofthebuildafterthe
fact,thismaybethebestoptionforyou.
Ifyouarewatchingtheoutput,thelonggapsofquietduringthebuildcanbefrustrat-
ing. The‘target’outputsynchronizationmodedetectswhenmakeisgoingtobeinvoked
recursively, usingthestandardmethods,andit t willnot synchronizethe outputofthose
lines. Therecursivemake e willperformthesynchronizationfor its targetsandtheoutput
from each willbedisplayedimmediately y whenit completes. . Be e awarethat output from
recursivelinesoftherecipearenotsynchronized(forexampleiftherecursivelineprintsa
messagebeforerunningmake,thatmessagewillnotbesynchronized).
The‘line’modecanbeusefulforfront-ends thatarewatchingtheoutputofmaketo
trackwhenrecipesarestartedandcompleted.
Someprogramsinvokedbymakemaybehavedifferentlyiftheydeterminethey’rewriting
output to aterminalversusa file(oftendescribedas“interactive” vs. . “non-interactive”
Chapter5:WritingRecipesinRules
49
modes). For r example, , many programs s that t can display y colorizedoutput will l not do so
ifthey determinetheyarenotwritingtoaterminal. . Ifyourmakefileinvokesaprogram
likethis thenusingtheoutput synchronizationoptions willcausethe programtobelieve
it’s runningin“non-interactive” modeeventhoughthe output willultimatelygotothe
terminal.
5.4.2 InputDuringParallelExecution
Twoprocessescannotbothtake inputfromthesamedevice atthesame time. . Tomake
surethatonlyonerecipetriestotakeinputfromtheterminalatonce,makewillinvalidate
thestandardinputstreamsofallbutonerunningrecipe. Ifanotherrecipeattemptstoread
fromstandardinputitwillusuallyincurafatalerror(a‘Brokenpipe’signal).
Itisunpredictablewhichrecipewillhaveavalidstandardinputstream(whichwillcome
fromtheterminal,orwhereveryouredirectthestandardinputofmake). Thefirstrecipe
runwillalwaysgetitfirst,andthefirstrecipestartedafterthatonefinisheswillgetitnext,
andsoon.
Wewillchangehow this aspectofmake works ifwe finda better alternative. . In n the
meantime,youshouldnotrelyonanyrecipeusingstandardinputatallifyouareusing
theparallelexecutionfeature; butif youare not t usingthisfeature, , thenstandardinput
worksnormallyinallrecipes.
5.5 ErrorsinRecipes
After eachshellinvocationreturns, , makelooks s at its exit status. . Ifthe e shellcompleted
successfully(theexitstatusiszero),thenextlineintherecipeisexecutedinanewshell;
afterthelastlineisfinished,theruleisfinished.
Ifthereisanerror(theexitstatusisnonzero),makegivesuponthecurrentrule,and
perhapsonallrules.
Sometimesthefailureofacertainrecipelinedoesnotindicateaproblem. Forexample,
youmayusethemkdircommandtoensurethatadirectoryexists. Ifthedirectoryalready
exists,mkdirwillreportanerror,butyouprobablywantmaketocontinueregardless.
Toignoreerrorsinarecipeline,writea‘-’atthebeginningoftheline’stext(afterthe
initialtab).The‘-’isdiscardedbeforethelineispassedtotheshellforexecution.
Forexample,
clean:
-rm -f *.o
Thiscausesmaketocontinueevenifrmisunabletoremoveafile.
Whenyourunmakewiththe‘-i’or‘--ignore-errors’flag,errorsareignoredinall
recipesofallrules. Aruleinthemakefileforthespecialtarget.IGNOREhasthesameeffect,
iftherearenoprerequisites. Thesewaysofignoringerrorsareobsoletebecause‘-’ismore
flexible.
Whenerrorsare tobeignored,becauseofeithera‘-’orthe‘-i’flag,maketreats an
errorreturnjustlikesuccess,exceptthatitprintsoutamessagethattellsyouthestatus
codetheshellexitedwith,andsaysthattheerrorhasbeenignored.
When an n error happens that make has not been told to ignore, , it t implies that the
currenttargetcannot becorrectlyremade,andneither cananyotherthat depends onit
50
GNUmake
eitherdirectlyorindirectly. Nofurtherrecipeswillbeexecutedforthesetargets,sincetheir
preconditionshavenotbeenachieved.
Normally make givesupimmediatelyinthiscircumstance,returninganonzerostatus.
However, if the ‘-k’or r ‘--keep-going’flag is specified, , make continues s to consider r the
other prerequisitesofthependingtargets,remakingthemifnecessary,beforeit givesup
andreturnsnonzerostatus. Forexample,afteranerrorincompilingoneobjectfile,‘make
-k’willcontinuecompilingotherobjectfileseventhoughitalreadyknowsthatlinkingthem
willbeimpossible. SeeSection9.7[SummaryofOptions],page104.
Theusualbehaviorassumesthatyourpurposeistogetthespecifiedtargetsuptodate;
oncemake learnsthat this isimpossible, , it t mightaswellreportthe failure immediately.
The‘-k’optionsaysthattherealpurposeistotestas manyofthechangesmadeinthe
programaspossible,perhapstofindseveralindependentproblemssothatyoucancorrect
themallbeforethenextattempttocompile. ThisiswhyEmacs’compilecommandpasses
the‘-k’flagbydefault.
Usuallywhenarecipelinefails,ifithaschangedthetargetfileatall,thefileiscorrupted
andcannotbeused—oratleastitisnotcompletelyupdated.Yetthefile’stimestampsays
thatitisnowuptodate,sothenexttimemakeruns,itwillnottrytoupdatethatfile. The
situationisjustthesameaswhentheshelliskilledbyasignal;seeSection5.6[Interrupts],
page50.Sogenerallytherightthingtodoistodeletethetargetfileiftherecipefailsafter
beginningtochangethefile. makewilldothisif.DELETE_ON_ERRORappearsasatarget.
Thisis almost alwayswhat youwant make todo,but itis not historicalpractice;sofor
compatibility,youmustexplicitlyrequestit.
5.6 InterruptingorKillingmake
Ifmakegetsafatalsignalwhileashellis executing,itmay deletethetargetfilethatthe
recipewassupposedtoupdate. This s isdoneifthetargetfile’slast-modificationtimehas
changedsincemakefirstcheckedit.
Thepurposeofdeletingthetargetistomakesurethatitisremadefromscratchwhen
makeisnextrun.Whyisthis?SupposeyoutypeCtrl-cwhileacompilerisrunning,and
ithasbeguntowriteanobjectfilefoo.o. TheCtrl-ckillsthecompiler,resultinginan
incompletefilewhoselast-modificationtimeisnewerthanthesourcefilefoo.c. Butmake
alsoreceivestheCtrl-csignalanddeletesthisincompletefile. Ifmakedidnotdothis,the
nextinvocationofmakewouldthinkthat foo.o didnotrequireupdating—resultingina
strangeerror message fromthelinker whenittries tolink anobjectfile halfofwhichis
missing.
Youcanpreventthedeletionofatarget fileinthisway by makingthespecialtarget
.PRECIOUSdependonit. Beforeremakingatarget,makecheckstoseewhetheritappears
ontheprerequisitesof.PRECIOUS,andtherebydecideswhetherthetargetshouldbedeleted
ifasignalhappens. Somereasonswhy y youmight dothisare thatthetarget isupdated
insome atomicfashion,orexistsonlytorecordamodification-time (its contentsdonot
matter),ormustexistatalltimestopreventothersortsoftrouble.
5.7 RecursiveUseofmake
Recursive use e of f make e means s using g make e as a a command in a makefile. . This s technique
is usefulwhenyouwant separatemakefilesfor varioussubsystemsthatcomposealarger
Documents you may be interested
Documents you may be interested