Chapter1:Overviewofmake
1
1 Overviewofmake
The make e utility y automatically determines s which pieces of a a large program need d to be
recompiled,andissuescommandstorecompilethem. This s manualdescribes GNUmake,
whichwas implementedby RichardStallmanand d Roland McGrath. . Development t since
Version3.76hasbeenhandledbyPaulD.Smith.
GNUmakeconformstosection6.2ofIEEEStandard1003.2-1992(POSIX.2).
Our examples showC programs,since they aremost common, , butyoucanusemake
withanyprogramminglanguagewhosecompilercanberunwithashellcommand.Indeed,
makeisnotlimitedtoprograms.Youcanuseittodescribeanytaskwheresomefilesmust
beupdatedautomaticallyfromotherswhenevertheotherschange.
To prepare to use make, youmust write a file called the makefile e that t describes s the
relationships amongfilesinyourprogramandprovidescommandsforupdatingeachfile.
Inaprogram,typically,theexecutablefileisupdatedfromobjectfiles,whichareinturn
madebycompilingsourcefiles.
Onceasuitablemakefileexists,eachtimeyouchangesomesourcefiles,thissimpleshell
command:
make
sufficestoperformallnecessaryrecompilations. Themakeprogramusesthemakefiledata
base and the last-modification times of the files to decide whichof the files need to be
updated. Foreachofthosefiles,itissuestherecipesrecordedinthedatabase.
You can provide command line e arguments to make to control l which h files s should be
recompiled,orhow.SeeChapter9[HowtoRunmake],page99.
1.1 HowtoReadThisManual
Ifyouarenewtomake,orarelookingforageneralintroduction,readthefirstfewsections
ofeachchapter,skippingthelatersections. Ineachchapter,thefirstfewsectionscontain
introductoryorgeneralinformationandthelatersectionscontainspecializedortechnical
information.TheexceptionisChapter2[AnIntroductiontoMakefiles],page3,allofwhich
isintroductory.
Ifyouarefamiliarwithothermakeprograms,seeChapter13[FeaturesofGNUmake],
page143,whichliststheenhancementsGNUmakehas,andChapter14[Incompatibilities
andMissingFeatures],page147,whichexplainsthefewthingsGNUmakelacksthatothers
have.
Foraquicksummary,seeSection9.7[OptionsSummary],page104,AppendixA[Quick
Reference],page165,andSection4.8[SpecialTargets],page32.
1.2 ProblemsandBugs
IfyouhaveproblemswithGNUmakeorthinkyou’vefoundabug,pleasereportittothe
developers;wecannotpromisetodoanythingbutwemightwellwanttofixit.
Beforereportingabug,makesureyou’veactually foundarealbug. . Carefully y reread
thedocumentationandseeifitreallysaysyoucandowhatyou’retryingtodo. Ifit’snot
clearwhetheryoushouldbeabletodosomethingornot,reportthattoo;it’sabuginthe
documentation!
Pdf change font size - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
change font size pdf document; pdf change font size in textbox
Pdf change font size - 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
adjust file size of pdf; change page size pdf acrobat
2
GNUmake
Beforereportingabugortryingtofixityourself,trytoisolateittothesmallestpossible
makefilethatreproducestheproblem.Thensendusthemakefileandtheexactresultsmake
gaveyou,includinganyerrororwarningmessages.Pleasedon’tparaphrasethesemessages:
it’sbesttocutandpastethemintoyourreport. Whengeneratingthissmallmakefile,be
suretonotuseanynon-freeorunusualtoolsinyourrecipes:youcanalmostalwaysemulate
whatsuchatoolwoulddowithsimpleshellcommands. Finally,besuretoexplainwhat
you expected to occur; ; this s will l help p us s decide whether r the e problem was s really in the
documentation.
Once you have apreciseproblemyoucan report it in one of two ways. . Either r send
electronicmailto:
bug-make@gnu.org
oruseourWeb-basedprojectmanagementtool,at:
http://savannah.gnu.org/projects/make/
Inadditionto the informationabove,pleasebecarefulto includetheversionnumber of
makeyouareusing.Youcangetthisinformationwiththecommand‘make--version’.Be
surealsotoincludethetypeofmachineandoperatingsystemyouareusing. Onewayto
obtainthisinformationisbylookingatthefinallinesofoutputfromthecommand‘make
--help’.
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.
can pdf files be compressed; best pdf compressor online
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 change page size; best compression pdf
Chapter2:AnIntroductiontoMakefiles
3
2 AnIntroductiontoMakefiles
Youneedafilecalledamakefiletotellmakewhattodo.Mostoften,themakefiletellsmake
howtocompileandlinkaprogram.
Inthischapter,wewilldiscussasimplemakefilethatdescribeshowtocompileandlink
atexteditorwhichconsistsofeightCsourcefilesandthreeheaderfiles.Themakefilecan
alsotellmakehowtorunmiscellaneouscommandswhenexplicitlyasked(forexample,to
removecertainfilesasaclean-upoperation).Toseeamorecomplexexampleofamakefile,
seeAppendixC[ComplexMakefile],page177.
Whenmakerecompilestheeditor,eachchangedCsourcefilemustberecompiled. Ifa
headerfilehaschanged,eachCsourcefilethatincludestheheaderfilemustberecompiledto
besafe.Eachcompilationproducesanobjectfilecorrespondingtothesourcefile.Finally,
if any source filehas beenrecompiled,allthe object files,whethernewly madeor saved
frompreviouscompilations,mustbelinkedtogethertoproducethenewexecutableeditor.
2.1 WhataRuleLooksLike
Asimplemakefileconsistsof“rules”withthefollowingshape:
target ... : : prerequisites ...
recipe
...
...
Atargetisusuallythenameofafilethatisgeneratedbyaprogram;examplesoftargets
areexecutableorobjectfiles.Atargetcanalsobethenameofanactiontocarryout,such
as‘clean’(seeSection4.5[PhonyTargets],page29).
Aprerequisiteisafilethatisusedasinputtocreatethetarget.Atargetoftendepends
onseveralfiles.
Arecipeisanactionthatmakecarriesout. Arecipemayhavemorethanonecommand,
eitheronthesamelineoreachonitsownline.Pleasenote: youneedtoputatabcharacter
atthebeginningofeveryrecipeline! Thisisanobscuritythatcatchestheunwary. Ifyou
prefertoprefixyourrecipeswithacharacterotherthantab,youcansetthe.RECIPEPREFIX
variabletoanalternatecharacter(seeSection6.14[SpecialVariables],page73).
Usuallyarecipeisinarulewithprerequisitesandservestocreateatargetfileifanyof
theprerequisiteschange. However,therulethatspecifiesarecipeforthetargetneednot
haveprerequisites. Forexample,therulecontainingthedeletecommandassociatedwith
thetarget‘clean’doesnothaveprerequisites.
Arule, then, explains s how andwhento remake certain n files s whichare the targets of
theparticular rule. . makecarries s out the recipeontheprerequisites tocreateor update
thetarget. Arulecanalsoexplainhowandwhentocarryoutanaction. . SeeChapter 4
[WritingRules],page21.
Amakefilemaycontainothertextbesidesrules,butasimplemakefileneedonlycontain
rules.Rulesmaylooksomewhatmorecomplicatedthanshowninthistemplate,butallfit
thepatternmoreorless.
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.
acrobat compress pdf; pdf form change font size
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
change font size in fillable pdf form; pdf file compression
4
GNUmake
2.2 ASimpleMakefile
Here is a straightforward makefile that describes s the e way anexecutable file called edit
dependsoneight object files which,inturn,dependoneight Csource andthreeheader
files.
Inthisexample,alltheCfilesincludedefs.h,butonlythosedefiningeditingcommands
includecommand.h,andonlylowlevelfilesthatchangetheeditorbufferincludebuffer.h.
edit : : main.o kbd.o command.o display.o \
insert.o search.o o files.o utils.o
cc -o edit main.o kbd.o o command.o o display.o \
insert.o search.o files.o utils.o
main.o : main.c c defs.h
cc -c main.c
kbd.o : kbd.c defs.h h command.h
cc -c kbd.c
command.o : : command.c defs.h command.h
cc -c command.c
display.o : : display.c defs.h buffer.h
cc -c display.c
insert.o : insert.c defs.h h buffer.h
cc -c insert.c
search.o : search.c defs.h h buffer.h
cc -c search.c
files.o : : files.c c defs.h buffer.h command.h
cc -c files.c
utils.o : : utils.c c defs.h
cc -c utils.c
clean :
rm edit t main.o o kbd.o command.o display.o o \
insert.o search.o files.o utils.o
Wespliteachlonglineintotwolinesusingbackslash/newline;thisis likeusingonelong
line,butiseasiertoread. SeeSection3.1.1[SplittingLongLines],page12.
Tousethismakefiletocreatetheexecutablefilecallededit,type:
make
Tousethismakefiletodeletetheexecutablefileandalltheobjectfilesfromthedirectory,
type:
make clean
Intheexample makefile,thetargetsincludetheexecutable file‘edit’,andtheobject
files‘main.o’and‘kbd.o’. The e prerequisites arefilessuchas‘main.c’and‘defs.h’. . In
fact,each‘.o’fileisbothatargetandaprerequisite. Recipesinclude‘cc-cmain.c’and
‘cc-ckbd.c’.
Whenatargetisafile,itneedstoberecompiledorrelinkedifanyofitsprerequisites
change. Inaddition,anyprerequisitesthatarethemselvesautomaticallygeneratedshould
beupdatedfirst.Inthisexample,editdependsoneachoftheeightobjectfiles;theobject
filemain.odependsonthesourcefilemain.candontheheaderfiledefs.h.
Generate Barcodes in Web Image Viewer| Online Tutorials
Change Barcode Properties. Select "Font" to choose human-readable text font style, color, size RasterEdge OCR Engine; PDF Reading; Encode & Decode JBIG 2 Files;
change page size of pdf document; pdf file size limit
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.
optimize scanned pdf; adjusting page size in pdf
Chapter2:AnIntroductiontoMakefiles
5
Arecipemayfolloweachlinethatcontainsatargetandprerequisites.Theserecipessay
howtoupdatethetargetfile. Atabcharacter(orwhatevercharacteris s specifiedbythe
.RECIPEPREFIXvariable;see Section6.14[SpecialVariables], page73) must comeat the
beginningofeverylineintherecipetodistinguishrecipesfromotherlinesinthemakefile.
(Bearinmindthatmakedoesnotknowanythingabouthowtherecipeswork. Itisupto
youtosupplyrecipesthatwillupdatethetargetfileproperly.Allmakedoesisexecutethe
recipeyouhavespecifiedwhenthetargetfileneedstobeupdated.)
Thetarget‘clean’isnotafile,butmerelythenameofanaction. Sinceyounormally
donotwanttocarryouttheactionsinthisrule,‘clean’isnotaprerequisiteofanyother
rule. Consequently,make e neverdoes anythingwithit unlessyoutellit specifically. . Note
thatthisrulenotonlyisnotaprerequisite,italsodoesnothaveanyprerequisites,sothe
only purpose of the ruleis to run n the specified recipe. . Targetsthat t donotrefertofiles
butarejustactionsarecalledphonytargets. SeeSection4.5[PhonyTargets],page29,for
informationaboutthiskindoftarget. SeeSection5.5[ErrorsinRecipes],page49,tosee
howtocausemaketoignoreerrorsfromrmoranyothercommand.
2.3 Howmake e ProcessesaMakefile
Bydefault,makestartswiththefirsttarget(nottargetswhosenamesstartwith‘.’). This
iscalledthedefaultgoal. (Goalsarethetargetsthatmakestrivesultimatelytoupdate.You
canoverridethisbehaviorusingthecommandline(seeSection9.2[ArgumentstoSpecify
theGoals],page99) orwiththe.DEFAULT_GOAL specialvariable(seeSection6.14[Other
SpecialVariables],page73).
Inthesimpleexampleoftheprevioussection,thedefaultgoalistoupdatetheexecutable
programedit;therefore,weputthatrulefirst.
Thus,whenyougivethecommand:
make
makereadsthemakefileinthecurrentdirectoryandbeginsbyprocessingthefirstrule.In
theexample,thisruleisforrelinkingedit;butbeforemakecanfullyprocess thisrule,it
mustprocesstherulesforthefilesthateditdependson,whichinthiscasearetheobject
files. Eachofthesefilesisprocessedaccordingtoitsownrule. Theserulessaytoupdate
each‘.o’filebycompilingitssourcefile. Therecompilationmustbedoneifthesourcefile,
oranyoftheheaderfilesnamedasprerequisites,ismorerecentthantheobjectfile,orif
theobjectfiledoesnotexist.
Theotherrulesareprocessedbecausetheirtargetsappearasprerequisitesofthegoal.
Ifsomeotherruleisnotdependedonby thegoal(oranythingit depends on,etc.),that
ruleisnotprocessed,unlessyoutellmaketodoso(withacommandsuchasmakeclean).
Beforerecompilinganobjectfile,makeconsidersupdatingitsprerequisites,thesource
fileandheaderfiles.Thismakefiledoesnotspecifyanythingtobedoneforthem—the‘.c’
and‘.h’files arenotthetargets of anyrules—somake does nothingforthese files. . But
makewouldupdateautomaticallygeneratedCprograms,suchasthosemadebyBisonor
Yacc,bytheirownrulesatthistime.
After recompilingwhichever object files needit, , makedecideswhether r torelinkedit.
Thismustbedoneifthefileeditdoesnotexist,orifanyoftheobjectfilesarenewerthan
it.Ifanobjectfilewasjustrecompiled,itisnownewerthanedit,soeditisrelinked.
VB.NET Image: Visual Basic .NET Guide to Draw Text on Image in .
Please note that you can change some of the LoadImage) Dim DrawFont As New Font("Arial", 16 provide powerful & profession imaging controls, PDF document, image
change font size in fillable pdf; change font size pdf text box
C# Image: Use C# Class to Insert Callout Annotation on Images
including GIF, PNG, BMP, JPEG, TIFF, PDF & Word projects; Easy to set annotation filled font property individually an easy way; C# demo code to change the filled
change font size pdf; change font size in pdf form
6
GNUmake
Thus,ifwechangethefileinsert.candrunmake,makewillcompilethatfiletoupdate
insert.o,andthenlink edit. . Ifwe e change the filecommand.h andrunmake,makewill
recompiletheobjectfileskbd.o,command.oandfiles.oandthenlinkthefileedit.
2.4 VariablesMakeMakefilesSimpler
Inourexample,wehadtolistalltheobjectfilestwiceintheruleforedit(repeatedhere):
edit : : main.o kbd.o command.o display.o \
insert.o search.o o files.o o utils.o
cc -o edit main.o kbd.o o command.o o display.o \
insert.o search.o files.o utils.o
Suchduplicationis error-prone;if anew object fileis addedto the system,we might
addittoonelistandforgettheother. Wecaneliminatetheriskandsimplifythemakefile
by using avariable. . Variables s allow w atext stringto be definedonce andsubstituted in
multipleplaceslater(seeChapter6[HowtoUseVariables],page59).
Itisstandardpracticeforeverymakefiletohaveavariablenamedobjects,OBJECTS,
objs,OBJS, obj,or r OBJ whichis alist ofallobject filenames. . We e woulddefinesucha
variableobjectswithalinelikethisinthemakefile:
objects = = main.o o kbd.o command.o display.o o \
insert.o search.o files.o utils.o
Then, each place we want t to put t alist of f the object t file e names, we can substitute the
variable’svaluebywriting‘$(objects)’(seeChapter6[HowtoUseVariables],page59).
Hereishowthecompletesimplemakefilelooks whenyouuseavariablefortheobject
files:
Chapter2:AnIntroductiontoMakefiles
7
objects = = main.o o kbd.o command.o display.o o \
insert.o search.o files.o utils.o
edit : : $(objects)
cc -o edit $(objects)
main.o : main.c c defs.h
cc -c main.c
kbd.o : kbd.c defs.h h command.h
cc -c kbd.c
command.o : : command.c defs.h command.h
cc -c command.c
display.o : : display.c defs.h buffer.h
cc -c display.c
insert.o : insert.c defs.h h buffer.h
cc -c insert.c
search.o : search.c defs.h h buffer.h
cc -c search.c
files.o : : files.c c defs.h buffer.h command.h
cc -c files.c
utils.o : : utils.c c defs.h
cc -c utils.c
clean :
rm edit t $(objects)
2.5 LettingmakeDeducetheRecipes
It is not necessary to spell out the e recipes s for compiling the e individual l C C source e files,
because make can n figure them out: : it t has an n implicit t rule e for r updatinga ‘.o’file from
acorrespondinglynamed‘.c’file usinga ‘cc-c’command. . For r example,itwilluse the
recipe‘cc-cmain.c-omain.o’tocompilemain.cintomain.o.Wecanthereforeomitthe
recipesfromtherulesfortheobjectfiles.SeeChapter10[UsingImplicitRules],page111.
Whena‘.c’fileisusedautomaticallyinthisway,itisalsoautomaticallyaddedtothe
listofprerequisites. Wecanthereforeomitthe‘.c’filesfromtheprerequisites,provided
weomittherecipe.
Here is the entire e example, , with both h of these e changes, and d a a variable objects as
suggestedabove:
8
GNUmake
objects = = main.o o kbd.o command.o display.o o \
insert.o search.o files.o utils.o
edit : : $(objects)
cc -o edit $(objects)
main.o : defs.h
kbd.o : defs.h command.h
command.o : : defs.h command.h
display.o : : defs.h buffer.h
insert.o : defs.h buffer.h
search.o : defs.h buffer.h
files.o : : defs.h h buffer.h command.h
utils.o : : defs.h
.PHONY : clean
clean :
rm edit t $(objects)
This is how we wouldwrite the makefile in n actual practice. . (The e complications s associ-
atedwith‘clean’aredescribedelsewhere. SeeSection4.5[Phony Targets],page29,and
Section5.5[ErrorsinRecipes],page49.)
Because implicit rules aresoconvenient,they areimportant. . Youwillseethemused
frequently.
2.6 AnotherStyleofMakefile
Whentheobjectsof amakefileare createdonlyby implicit rules,analternative style of
makefileispossible.Inthisstyleofmakefile,yougroupentriesbytheirprerequisitesinstead
ofbytheirtargets. Hereiswhatonelookslike:
objects = = main.o o kbd.o command.o display.o o \
insert.o search.o files.o utils.o
edit : : $(objects)
cc -o edit $(objects)
$(objects) : : defs.h
kbd.o command.o o files.o : : command.h
display.o insert.o o search.o files.o : : buffer.h
Heredefs.hisgivenasaprerequisiteofalltheobjectfiles;command.handbuffer.hare
prerequisitesofthespecificobjectfileslistedforthem.
Whetherthisisbetterisamatteroftaste: itismorecompact,butsomepeopledislike
itbecausetheyfinditclearertoputalltheinformationabouteachtargetinoneplace.
Chapter2:AnIntroductiontoMakefiles
9
2.7 RulesforCleaningtheDirectory
Compilinga programis not the only thingyoumight want towrite rules for. . Makefiles
commonlytellhowtodoafewotherthingsbesidescompilingaprogram:forexample,how
todeletealltheobjectfilesandexecutablessothatthedirectoryis‘clean’.
Hereishowwecouldwriteamakeruleforcleaningourexampleeditor:
clean:
rm edit t $(objects)
Inpractice,wemightwanttowritetheruleinasomewhatmorecomplicatedmanner
tohandleunanticipatedsituations.Wewoulddothis:
.PHONY : clean
clean :
-rm edit $(objects)
Thisprevents makefromgettingconfusedbyanactualfilecalledclean andcauses itto
continueinspiteoferrorsfromrm.(SeeSection4.5[PhonyTargets],page29,andSection5.5
[ErrorsinRecipes],page49.)
Arulesuchasthisshouldnotbeplacedatthebeginningofthemakefile,becausewedo
notwantittorunbydefault! Thus,intheexamplemakefile,wewanttheruleforedit,
whichrecompilestheeditor,toremainthedefaultgoal.
Sinceclean is not a prerequisite ofedit, , this rule willnot t run n at t allifwe give the
command‘make’withnoarguments.Inordertomaketherulerun,wehavetotype‘make
clean’. SeeChapter9[HowtoRunmake],page99.
Documents you may be interested
Documents you may be interested