@commentThisfileisincludedbybothstandards.texiandmake.texinfo.@commentItwasbrokenoutofstandards.texion1/6/93byroland.@nodeMakefileConventions@chapterMakefileConventions@commentstandards.texidoesnotprintanindex,butmake.texinfodoes.@cindexmakefile,conventionsfor@cindexconventionsformakefiles@cindexstandardsformakefilesThis@ifinfonode@endifinfo@iftex@ifsetCODESTDsection@endifset@ifclearCODESTDchapter@endifclear@endiftexdescribesconventionsforwritingtheMakefilesforGNUprograms.@menu*MakefileBasics::GeneralConventionsforMakefiles*UtilitiesinMakefiles::UtilitiesinMakefiles*CommandVariables::VariablesforSpecifyingCommands*DirectoryVariables::VariablesforInstallationDirectories*StandardTargets::StandardTargetsforUsers@endmenu@nodeMakefileBasics@sectionGeneralConventionsforMakefilesEveryMakefileshouldcontainthisline:@exampleSHELL=/bin/sh@endexample@noindenttoavoidtroubleonsystemswherethe@code{SHELL}variablemightbeinheritedfromtheenvironment.(ThisisneveraproblemwithGNU@code{make}.)Different@code{make}programshaveincompatiblesuffixlistsandimplicitrules,andthissometimescreatesconfusionormisbehavior.SoitisagoodideatosetthesuffixlistexplicitlyusingonlythesuffixesyouneedintheparticularMakefile,likethis:@example.SUFFIXES:.SUFFIXES:.c.o@endexample@noindentThefirstlineclearsoutthesuffixlist,thesecondintroducesallsuffixeswhichmaybesubjecttoimplicitrulesinthisMakefile.Don'tassumethat@file{.}isinthepathforcommandexecution.Whenyouneedtorunprogramsthatareapartofyourpackageduringthemake,pleasemakesurethatituses@file{./}iftheprogramisbuiltaspartofthemakeor@file{$(srcdir)/}ifthefileisanunchangingpartofthesourcecode.Withoutoneoftheseprefixes,thecurrentsearchpathisused.Thedistinctionbetween@file{./}and@file{$(srcdir)/}isimportantwhenusingthe@samp{--srcdir}optionto@file{configure}.Aruleoftheform:@smallexamplefoo.1:foo.mansedscriptsed-esedscriptfoo.man>foo.1@endsmallexample@noindentwillfailwhenthecurrentdirectoryisnotthesourcedirectory,because@file{foo.man}and@file{sedscript}arenotinthecurrentdirectory.WhenusingGNU@code{make},relyingon@samp{VPATH}tofindthesourcefilewillworkinthecasewherethereisasingledependencyfile,sincethe@code{make}automaticvariable@samp{$<}willrepresentthesourcefilewhereveritis.(Manyversionsof@code{make}set@samp{$<}onlyinimplicitrules.)AMakefiletargetlike@smallexamplefoo.o:bar.c$(CC)-I.-I$(srcdir)$(CFLAGS)-cbar.c-ofoo.o@endsmallexample@noindentshouldinsteadbewrittenas@smallexamplefoo.o:bar.c$(CC)-I.-I$(srcdir)$(CFLAGS)-c$<-o$@@@endsmallexample@noindentinordertoallow@samp{VPATH}toworkcorrectly.Whenthetargethasmultipledependencies,usinganexplicit@samp{$(srcdir)}istheeasiestwaytomaketheruleworkwell.Forexample,thetargetabovefor@file{foo.1}isbestwrittenas:@smallexamplefoo.1:foo.mansedscriptsed-e$(srcdir)/sedscript$(srcdir)/foo.man>$@@@endsmallexampleTrytomakethebuildandinstallationtargets,atleast(andalltheirsubtargets)workcorrectlywithaparallel@code{make}.@nodeUtilitiesinMakefiles@sectionUtilitiesinMakefilesWritetheMakefilecommands(andanyshellscripts,suchas@code{configure})torunin@code{sh},notin@code{csh}.Don'tuseanyspecialfeaturesof@code{ksh}or@code{bash}.The@code{configure}scriptandtheMakefilerulesforbuildingandinstallationshouldnotuseanyutilitiesdirectlyexceptthese:@examplecatcmpcpechoegrepexprfalsegreplnmkdirmvpwdrmrmdirsedtesttouchtrue@endexampleSticktothegenerallysupportedoptionsfortheseprograms.Forexample,don'tuse@samp{mkdir-p},convenientasitmaybe,becausemostsystemsdon'tsupportit.Itisagoodideatoavoidcreatingsymboliclinksinmakefiles,sinceafewsystemsdon'tsupportthem.TheMakefilerulesforbuildingandinstallationcanalsousecompilersandrelatedprograms,butshoulddosovia@code{make}variablessothattheusercansubstitutealternatives.Herearesomeoftheprogramswemean:@examplearbisonccflexinstallldlexmakemakeinforanlibtexi2dviyacc@endexampleUsethefollowing@code{make}variables:@example$(AR)$(BISON)$(CC)$(FLEX)$(INSTALL)$(LD)$(LEX)$(MAKE)$(MAKEINFO)$(RANLIB)$(TEXI2DVI)$(YACC)@endexampleWhenyouuse@code{ranlib},youshouldmakesurenothingbadhappensifthesystemdoesnothave@code{ranlib}.Arrangetoignoreanerrorfromthatcommand,andprintamessagebeforethecommandtotelltheuserthatfailureofthe@code{ranlib}commanddoesnotmeanaproblem.(TheAutoconf@samp{AC_PROG_RANLIB}macrocanhelpwiththis.)Ifyouusesymboliclinks,youshouldimplementafallbackforsystemsthatdon'thavesymboliclinks.ItisoktouseotherutilitiesinMakefileportions(orscripts)intendedonlyforparticularsystemswhereyouknowthoseutilitiesexist.@nodeCommandVariables@sectionVariablesforSpecifyingCommandsMakefilesshouldprovidevariablesforoverridingcertaincommands,options,andsoon.Inparticular,youshouldrunmostutilityprogramsviavariables.Thus,ifyouuseBison,haveavariablenamed@code{BISON}whosedefaultvalueissetwith@samp{BISON=bison},andrefertoitwith@code{$(BISON)}wheneveryouneedtouseBison.Filemanagementutilitiessuchas@code{ln},@code{rm},@code{mv},andsoon,neednotbereferredtothroughvariablesinthisway,sinceusersdon'tneedtoreplacethemwithotherprograms.Eachprogram-namevariableshouldcomewithanoptionsvariablethatisusedtosupplyoptionstotheprogram.Append@samp{FLAGS}totheprogram-namevariablenametogettheoptionsvariablename---forexample,@code{BISONFLAGS}.(Thename@code{CFLAGS}isanexceptiontothisrule,butwekeepitbecauseitisstandard.)Use@code{CPPFLAGS}inanycompilationcommandthatrunsthepreprocessor,anduse@code{LDFLAGS}inanycompilationcommandthatdoeslinkingaswellasinanydirectuseof@code{ld}.IfthereareCcompileroptionsthat@emph{must}beusedforpropercompilationofcertainfiles,donotincludethemin@code{CFLAGS}.Usersexpecttobeabletospecify@code{CFLAGS}freelythemselves.Instead,arrangetopassthenecessaryoptionstotheCcompilerindependentlyof@code{CFLAGS},bywritingthemexplicitlyinthecompilationcommandsorbydefininganimplicitrule,likethis:@smallexampleCFLAGS=-gALL_CFLAGS=-I.$(CFLAGS).c.o:$(CC)-c$(CPPFLAGS)$(ALL_CFLAGS)$<@endsmallexampleDoincludethe@samp{-g}optionin@code{CFLAGS},becausethatisnot@emph{required}forpropercompilation.Youcanconsideritadefaultthatisonlyrecommended.IfthepackageissetupsothatitiscompiledwithGCCbydefault,thenyoumightaswellinclude@samp{-O}inthedefaultvalueof@code{CFLAGS}aswell.Put@code{CFLAGS}lastinthecompilationcommand,afterothervariablescontainingcompileroptions,sotheusercanuse@code{CFLAGS}tooverridetheothers.EveryMakefileshoulddefinethevariable@code{INSTALL},whichisthebasiccommandforinstallingafileintothesystem.EveryMakefileshouldalsodefinethevariables@code{INSTALL_PROGRAM}and@code{INSTALL_DATA}.(Thedefaultforeachoftheseshouldbe@code{$(INSTALL)}.)Thenitshouldusethosevariablesasthecommandsforactualinstallation,forexecutablesandnonexecutablesrespectively.Usethesevariablesasfollows:@example$(INSTALL_PROGRAM)foo$(bindir)/foo$(INSTALL_DATA)libfoo.a$(libdir)/libfoo.a@endexample@noindentAlwaysuseafilename,notadirectoryname,asthesecondargumentoftheinstallationcommands.Useaseparatecommandforeachfiletobeinstalled.@nodeDirectoryVariables@sectionVariablesforInstallationDirectoriesInstallationdirectoriesshouldalwaysbenamedbyvariables,soitiseasytoinstallinanonstandardplace.Thestandardnamesforthesevariablesaredescribedbelow.Theyarebasedonastandardfilesystemlayout;variantsofitareusedinSVR4,4.4BSD,Linux,Ultrixv4,andothermodernoperatingsystems.Thesetwovariablessettherootfortheinstallation.Alltheotherinstallationdirectoriesshouldbesubdirectoriesofoneofthesetwo,andnothingshouldbedirectlyinstalledintothesetwodirectories.@table@samp@itemprefixAprefixusedinconstructingthedefaultvaluesofthevariableslistedbelow.Thedefaultvalueof@code{prefix}shouldbe@file{/usr/local}.WhenbuildingthecompleteGNUsystem,theprefixwillbeemptyand@file{/usr}willbeasymboliclinkto@file{/}.(IfyouareusingAutoconf,writeitas@samp{@@prefix@@}.)@itemexec_prefixAprefixusedinconstructingthedefaultvaluesofsomeofthevariableslistedbelow.Thedefaultvalueof@code{exec_prefix}shouldbe@code{$(prefix)}.(IfyouareusingAutoconf,writeitas@samp{@@exec_prefix@@}.)Generally,@code{$(exec_prefix)}isusedfordirectoriesthatcontainmachine-specificfiles(suchasexecutablesandsubroutinelibraries),while@code{$(prefix)}isuseddirectlyforotherdirectories.@endtableExecutableprogramsareinstalledinoneofthefollowingdirectories.@table@samp@itembindirThedirectoryforinstallingexecutableprogramsthatuserscanrun.Thisshouldnormallybe@file{/usr/local/bin},butwriteitas@file{$(exec_prefix)/bin}.(IfyouareusingAutoconf,writeitas@samp{@@bindir@@}.)@itemsbindirThedirectoryforinstallingexecutableprogramsthatcanberunfromtheshell,butareonlygenerallyusefultosystemadministrators.Thisshouldnormallybe@file{/usr/local/sbin},butwriteitas@file{$(exec_prefix)/sbin}.(IfyouareusingAutoconf,writeitas@samp{@@sbindir@@}.)@itemlibexecdir@commentThisparagraphadjustedtoavoidoverfullhbox--roland5jul94Thedirectoryforinstallingexecutableprogramstoberunbyotherprogramsratherthanbyusers.Thisdirectoryshouldnormallybe@file{/usr/local/libexec},butwriteitas@file{$(exec_prefix)/libexec}.(IfyouareusingAutoconf,writeitas@samp{@@libexecdir@@}.)@endtableDatafilesusedbytheprogramduringitsexecutionaredividedintocategoriesintwoways.@itemize@bullet@itemSomefilesarenormallymodifiedbyprograms;othersarenevernormallymodified(thoughusersmayeditsomeofthese).@itemSomefilesarearchitecture-independentandcanbesharedbyallmachinesatasite;somearearchitecture-dependentandcanbesharedonlybymachinesofthesamekindandoperatingsystem;othersmayneverbesharedbetweentwomachines.@enditemizeThismakesforsixdifferentpossibilities.However,wewanttodiscouragetheuseofarchitecture-dependentfiles,asidefromobjectfilesandlibraries.Itismuchcleanertomakeotherdatafilesarchitecture-independent,anditisgenerallynothard.Therefore,herearethevariablesMakefilesshouldusetospecifydirectories:@table@samp@itemdatadirThedirectoryforinstallingread-onlyarchitectureindependentdatafiles.Thisshouldnormallybe@file{/usr/local/share},butwriteitas@file{$(prefix)/share}.(IfyouareusingAutoconf,writeitas@samp{@@datadir@@}.)Asaspecialexception,see@file{$(infodir)}and@file{$(includedir)}below.@itemsysconfdirThedirectoryforinstallingread-onlydatafilesthatpertaintoasinglemachine--thatistosay,filesforconfiguringahost.Mailerandnetworkconfigurationfiles,@file{/etc/passwd},andsoforthbelonghere.AllthefilesinthisdirectoryshouldbeordinaryASCIItextfiles.Thisdirectoryshouldnormallybe@file{/usr/local/etc},butwriteitas@file{$(prefix)/etc}.(IfyouareusingAutoconf,writeitas@samp{@@sysconfdir@@}.)@crewrittentoavoidoverfullhbox--towerDonotinstallexecutables@chereinthisdirectory(theyprobablybelongin@file{$(libexecdir)}or@file{$(sbindir)}).Alsodonotinstallfilesthataremodifiedinthenormalcourseoftheiruse(programswhosepurposeistochangetheconfigurationofthesystemexcluded).Thoseprobablybelongin@file{$(localstatedir)}.@itemsharedstatedirThedirectoryforinstallingarchitecture-independentdatafileswhichtheprogramsmodifywhiletheyrun.Thisshouldnormallybe@file{/usr/local/com},butwriteitas@file{$(prefix)/com}.(IfyouareusingAutoconf,writeitas@samp{@@sharedstatedir@@}.)@itemlocalstatedirThedirectoryforinstallingdatafileswhichtheprogramsmodifywhiletheyrun,andthatpertaintoonespecificmachine.Usersshouldneverneedtomodifyfilesinthisdirectorytoconfigurethepackage'soperation;putsuchconfigurationinformationinseparatefilesthatgoin@file{$(datadir)}or@file{$(sysconfdir)}.@file{$(localstatedir)}shouldnormallybe@file{/usr/local/var},butwriteitas@file{$(prefix)/var}.(IfyouareusingAutoconf,writeitas@samp{@@localstatedir@@}.)@itemlibdirThedirectoryforobjectfilesandlibrariesofobjectcode.Donotinstallexecutableshere,theyprobablyoughttogoin@file{$(libexecdir)}instead.Thevalueof@code{libdir}shouldnormallybe@file{/usr/local/lib},butwriteitas@file{$(exec_prefix)/lib}.(IfyouareusingAutoconf,writeitas@samp{@@libdir@@}.)@iteminfodirThedirectoryforinstallingtheInfofilesforthispackage.Bydefault,itshouldbe@file{/usr/local/info},butitshouldbewrittenas@file{$(prefix)/info}.(IfyouareusingAutoconf,writeitas@samp{@@infodir@@}.)@itemincludedir@crewrittentoavoidoverfullhbox--rolandThedirectoryforinstallingheaderfilestobeincludedbyuserprogramswiththeC@samp{#include}preprocessordirective.Thisshouldnormallybe@file{/usr/local/include},butwriteitas@file{$(prefix)/include}.(IfyouareusingAutoconf,writeitas@samp{@@includedir@@}.)MostcompilersotherthanGCCdonotlookforheaderfilesin@file{/usr/local/include}.SoinstallingtheheaderfilesthiswayisonlyusefulwithGCC.SometimesthisisnotaproblembecausesomelibrariesareonlyreallyintendedtoworkwithGCC.Butsomelibrariesareintendedtoworkwithothercompilers.Theyshouldinstalltheirheaderfilesintwoplaces,onespecifiedby@code{includedir}andonespecifiedby@code{oldincludedir}.@itemoldincludedirThedirectoryforinstalling@samp{#include}headerfilesforusewithcompilersotherthanGCC.Thisshouldnormallybe@file{/usr/include}.(IfyouareusingAutoconf,youcanwriteitas@samp{@@oldincludedir@@}.)TheMakefilecommandsshouldcheckwhetherthevalueof@code{oldincludedir}isempty.Ifitis,theyshouldnottrytouseit;theyshouldcancelthesecondinstallationoftheheaderfiles.Apackageshouldnotreplaceanexistingheaderinthisdirectoryunlesstheheadercamefromthesamepackage.Thus,ifyourFoopackageprovidesaheaderfile@file{foo.h},thenitshouldinstalltheheaderfileinthe@code{oldincludedir}directoryifeither(1)thereisno@file{foo.h}thereor(2)the@file{foo.h}thatexistscamefromtheFoopackage.Totellwhether@file{foo.h}camefromtheFoopackage,putamagicstringinthefile---partofacomment---and@code{grep}forthatstring.@endtableUnix-stylemanpagesareinstalledinoneofthefollowing:@table@samp@itemmandirThetop-leveldirectoryforinstallingthemanpages(ifany)forthispackage.Itwillnormallybe@file{/usr/local/man},butyoushouldwriteitas@file{$(prefix)/man}.(IfyouareusingAutoconf,writeitas@samp{@@mandir@@}.)@itemman1dirThedirectoryforinstallingsection1manpages.Writeitas@file{$(mandir)/man1}.@itemman2dirThedirectoryforinstallingsection2manpages.Writeitas@file{$(mandir)/man2}@item@dots{}@strong{Don'tmaketheprimarydocumentationforanyGNUsoftwarebeamanpage.WriteamanualinTexinfoinstead.ManpagesarejustforthesakeofpeoplerunningGNUsoftwareonUnix,whichisasecondaryapplicationonly.}@itemmanextThefilenameextensionfortheinstalledmanpage.Thisshouldcontainaperiodfollowedbytheappropriatedigit;itshouldnormallybe@samp{.1}.@itemman1extThefilenameextensionforinstalledsection1manpages.@itemman2extThefilenameextensionforinstalledsection2manpages.@item@dots{}Usethesenamesinsteadof@samp{manext}ifthepackageneedstoinstallmanpagesinmorethanonesectionofthemanual.@endtableAndfinally,youshouldsetthefollowingvariable:@table@samp@itemsrcdirThedirectoryforthesourcesbeingcompiled.Thevalueofthisvariableisnormallyinsertedbythe@code{configure}shellscript.(IfyouareusingAutconf,use@samp{srcdir=@@srcdir@@}.)@endtableForexample:@smallexample@cIhavechangedsomeofthecommentshereslightlytofixanoverfull@chbox,sothemakemanualcanformatcorrectly.--roland# Common prefix for installation directories.# NOTE: This directory must exist when you start the install.prefix=/usr/localexec_prefix=$(prefix)# Where to put the executable for the command `gcc'.bindir=$(exec_prefix)/bin# Where to put the directories used by the compiler.libexecdir=$(exec_prefix)/libexec# Where to put the Info files.infodir=$(prefix)/info@endsmallexampleIfyourprograminstallsalargenumberoffilesintooneofthestandarduser-specifieddirectories,itmightbeusefultogroupthemintoasubdirectoryparticulartothatprogram.Ifyoudothis,youshouldwritethe@code{install}ruletocreatethesesubdirectories.Donotexpecttheusertoincludethesubdirectorynameinthevalueofanyofthevariableslistedabove.TheideaofhavingauniformsetofvariablenamesforinstallationdirectoriesistoenabletheusertospecifytheexactsamevaluesforseveraldifferentGNUpackages.Inorderforthistobeuseful,allthepackagesmustbedesignedsothattheywillworksensiblywhentheuserdoesso.@nodeStandardTargets@sectionStandardTargetsforUsersAllGNUprogramsshouldhavethefollowingtargetsintheirMakefiles:@table@samp@itemallCompiletheentireprogram.Thisshouldbethedefaulttarget.Thistargetneednotrebuildanydocumentationfiles;Infofilesshouldnormallybeincludedinthedistribution,andDVIfilesshouldbemadeonlywhenexplicitlyaskedfor.Bydefault,theMakerulesshouldcompileandlinkwith@samp{-g},sothatexecutableprogramshavedebuggingsymbols.Userswhodon'tmindbeinghelplesscanstriptheexecutableslateriftheywish.@iteminstallCompiletheprogramandcopytheexecutables,libraries,andsoontothefilenameswheretheyshouldresideforactualuse.Ifthereisasimpletesttoverifythataprogramisproperlyinstalled,thistargetshouldrunthattest.Donotstripexecutableswheninstallingthem.Devil-may-careuserscanusethe@code{install-strip}targettodothat.Ifpossible,writethe@code{install}targetrulesothatitdoesnotmodifyanythinginthedirectorywheretheprogramwasbuilt,provided@samp{makeall}hasjustbeendone.Thisisconvenientforbuildingtheprogramunderoneusernameandinstallingitunderanother.Thecommandsshouldcreateallthedirectoriesinwhichfilesaretobeinstalled,iftheydon'talreadyexist.Thisincludesthedirectoriesspecifiedasthevaluesofthevariables@code{prefix}and@code{exec_prefix},aswellasallsubdirectoriesthatareneeded.Onewaytodothisisbymeansofan@code{installdirs}targetasdescribedbelow.Use@samp{-}beforeanycommandforinstallingamanpage,sothat@code{make}willignoreanyerrors.Thisisincasetherearesystemsthatdon'thavetheUnixmanpagedocumentationsysteminstalled.ThewaytoinstallInfofilesistocopytheminto@file{$(infodir)}with@code{$(INSTALL_DATA)}(@pxref{CommandVariables}),andthenrunthe@code{install-info}programifitispresent.@code{install-info}isaprogramthateditstheInfo@file{dir}filetoaddorupdatethemenuentryforthegivenInfofile;itispartoftheTexinfopackage.HereisasampleruletoinstallanInfofile:@commentThisexamplehasbeencarefullyformattedfortheMakemanual.@commentPleasedonotreformatitwithouttalkingtoroland@gnu.ai.mit.edu.@smallexample$(infodir)/foo.info:foo.info# There may be a newer info file in . than in srcdir.-iftest-ffoo.info;thend=.; \
elsed=$(srcdir);fi; \
$(INSTALL_DATA)$$d/foo.info$@@; \
# Run install-info only if it exists.# Use `if' instead of just prepending `-' to the# line so we notice real errors from install-info.# We use `$(SHELL) -c' because some shells do not# fail gracefully when there is an unknown command.if$(SHELL)-c'install-info--version' \
>/dev/null2>&1;then \
install-info--dir-file=$(infodir)/dir \
$(infodir)/foo.info; \
elsetrue;fi@endsmallexample@itemuninstallDeletealltheinstalledfilesthatthe@samp{install}targetwouldcreate(butnotthenoninstalledfilessuchas@samp{makeall}wouldcreate).Thisruleshouldnotmodifythedirectorieswherecompilationisdone,onlythedirectorieswherefilesareinstalled.@iteminstall-stripLike@code{install},butstriptheexecutablefileswhileinstallingthem.Thedefinitionofthistargetcanbeverysimple:@smallexampleinstall-strip:$(MAKE)INSTALL_PROGRAM='$(INSTALL_PROGRAM)-s' \
install@endsmallexampleNormallywedonotrecommendstrippinganexecutableunlessyouaresuretheprogramhasnobugs.However,itcanbereasonabletoinstallastrippedexecutableforactualexecutionwhilesavingtheunstrippedexecutableelsewhereincasethereisabug.@commentThegratuitousblanklinehereistomakethetablelookbetter@commentintheprintedMakemanual.Pleaseleaveitin.@itemcleanDeleteallfilesfromthecurrentdirectorythatarenormallycreatedbybuildingtheprogram.Don'tdeletethefilesthatrecordtheconfiguration.Alsopreservefilesthatcouldbemadebybuilding,butnormallyaren'tbecausethedistributioncomeswiththem.Delete@file{.dvi}fileshereiftheyarenotpartofthedistribution.@itemdistcleanDeleteallfilesfromthecurrentdirectorythatarecreatedbyconfiguringorbuildingtheprogram.Ifyouhaveunpackedthesourceandbuilttheprogramwithoutcreatinganyotherfiles,@samp{makedistclean}shouldleaveonlythefilesthatwereinthedistribution.@itemmostlycleanLike@samp{clean},butmayrefrainfromdeletingafewfilesthatpeoplenormallydon'twanttorecompile.Forexample,the@samp{mostlyclean}targetforGCCdoesnotdelete@file{libgcc.a},becauserecompilingitisrarelynecessaryandtakesalotoftime.@itemmaintainer-cleanDeletealmosteverythingfromthecurrentdirectorythatcanbereconstructedwiththisMakefile.Thistypicallyincludeseverythingdeletedby@code{distclean},plusmore:CsourcefilesproducedbyBison,tagstables,Infofiles,andsoon.Thereasonwesay``almosteverything''isthatrunningthecommand@samp{makemaintainer-clean}shouldnotdelete@file{configure}evenif@file{configure}canberemadeusingaruleintheMakefile.Moregenerally,@samp{makemaintainer-clean}shouldnotdeleteanythingthatneedstoexistinordertorun@file{configure}andthenbegintobuildtheprogram.Thisistheonlyexception;@code{maintainer-clean}shoulddeleteeverythingelsethatcanberebuilt.The@samp{maintainer-clean}targetisintendedtobeusedbyamaintainerofthepackage,notbyordinaryusers.Youmayneedspecialtoolstoreconstructsomeofthefilesthat@samp{makemaintainer-clean}deletes.Sincethesefilesarenormallyincludedinthedistribution,wedon'ttakecaretomakethemeasytoreconstruct.Ifyoufindyouneedtounpackthefulldistributionagain,don'tblameus.Tohelpmakeusersawareofthis,thecommandsforthespecial@code{maintainer-clean}targetshouldstartwiththesetwo:@smallexample@@echo'Thiscommandisintendedformaintainerstouse;it'@@echo'deletesfilesthatmayneedspecialtoolstorebuild.'@endsmallexample@itemTAGSUpdateatagstableforthisprogram.@cADR:how?@iteminfoGenerateanyInfofilesneeded.Thebestwaytowritetherulesisasfollows:@smallexampleinfo:foo.infofoo.info:foo.texichap1.texichap2.texi$(MAKEINFO)$(srcdir)/foo.texi@endsmallexample@noindentYoumustdefinethevariable@code{MAKEINFO}intheMakefile.Itshouldrunthe@code{makeinfo}program,whichispartoftheTexinfodistribution.@itemdviGenerateDVIfilesforallTexinfodocumentation.Forexample:@smallexampledvi:foo.dvifoo.dvi:foo.texichap1.texichap2.texi$(TEXI2DVI)$(srcdir)/foo.texi@endsmallexample@noindentYoumustdefinethevariable@code{TEXI2DVI}intheMakefile.Itshouldruntheprogram@code{texi2dvi},whichispartoftheTexinfodistribution.@footnote{@code{texi2dvi}uses@TeX{}todotherealworkofformatting.@TeX{}isnotdistributedwithTexinfo.}Alternatively,writejustthedependencies,andallowGNU@code{make}toprovidethecommand.@itemdistCreateadistributiontarfileforthisprogram.Thetarfileshouldbesetupsothatthefilenamesinthetarfilestartwithasubdirectorynamewhichisthenameofthepackageitisadistributionfor.Thisnamecanincludetheversionnumber.Forexample,thedistributiontarfileofGCCversion1.40unpacksintoasubdirectorynamed@file{gcc-1.40}.Theeasiestwaytodothisistocreateasubdirectoryappropriatelynamed,use@code{ln}or@code{cp}toinstalltheproperfilesinit,andthen@code{tar}thatsubdirectory.Compressthetarfilewith@code{gzip}.Forexample,theactualdistributionfileforGCCversion1.40iscalled@file{gcc-1.40.tar.gz}.The@code{dist}targetshouldexplicitlydependonallnon-sourcefilesthatareinthedistribution,tomakesuretheyareuptodateinthedistribution.@ifsetCODESTD@xref{Releases,,MakingReleases}.@endifset@ifclearCODESTD@xref{Releases,,MakingReleases,standards,GNUCodingStandards}.@endifclear@itemcheckPerformself-tests(ifany).Theusermustbuildtheprogrambeforerunningthetests,butneednotinstalltheprogram;youshouldwritetheself-testssothattheyworkwhentheprogramisbuiltbutnotinstalled.@endtableThefollowingtargetsaresuggestedasconventionalnames,forprogramsinwhichtheyareuseful.@table@code@iteminstallcheckPerforminstallationtests(ifany).Theusermustbuildandinstalltheprogrambeforerunningthetests.Youshouldnotassumethat@file{$(bindir)}isinthesearchpath.@iteminstalldirsIt'susefultoaddatargetnamed@samp{installdirs}tocreatethedirectorieswherefilesareinstalled,andtheirparentdirectories.Thereisascriptcalled@file{mkinstalldirs}whichisconvenientforthis;youcanfinditintheTexinfopackage.@cIt'sin/gd/gnu/lib/mkinstalldirs.Youcanusearulelikethis:@commentThishasbeencarefullyformattedtolookdecentintheMakemanual.@commentPleasebesurenottomakeitextendanyfurthertotheright.--roland@smallexample# Make sure all installation directories (e.g. $(bindir))# actually exist by making them if necessary.installdirs:mkinstalldirs$(srcdir)/mkinstalldirs$(bindir)$(datadir) \
$(libdir)$(infodir) \
$(mandir)@endsmallexampleThisruleshouldnotmodifythedirectorieswherecompilationisdone.Itshoulddonothingbutcreateinstallationdirectories.@endtable