AnIntroductiontothe SourceCodeControlSystem EricAllman ProjectIngres UniversityofCaliforniaatBerkeley ThisdocumentgivesaquickintroductiontousingtheSourceCodeControlSystem(SCCS). Thepresentationisgearedtoprogrammerswhoaremoreconcernedwithwhattodotogetatask doneratherthanhowitworks;forthisreasonsomeoftheexamplesarenotwellexplained.For detailsofwhatthemagicoptionsdo,seethesectionon“FurtherInformation”. Thisisaworkingdocument.Pleasesendanycommentsorsuggestionsto csvax:eric. 1.Introduction SCCSisasourcemanagementsystem.Suchasystemmaintainsarecordofversionsofa system;arecordiskeptwitheachsetofchangesofwhatthechangesare,whytheyweremade, andwhomadethemandwhen.Oldversionscanberecovered,anddifferentversionscanbe maintainedsimultaneously.Inprojectswithmorethanoneperson,SCCSwillinsurethattwo peoplearenoteditingthesamefileatthesametime. Allversionsofyourprogram,plusthelogandotherinformation,iskeptinafilecalledthe “s-file”.Therearethreemajoroperationsthatcanbeperformedonthes-file: (1)Getafileforcompilation(notforediting).Thisoperationretrievesaversionofthefile fromthes-file.Bydefault,thelatestversionisretrieved.Thisfileisintendedforcompi-lation,printing,orwhatever;itisspecificallyNOTintendedtobeeditedorchangedin anyway;anychangesmadetoafileretrievedinthiswaywillprobablybelost. (2)Getafileforediting.Thisoperationalsoretrievesaversionofthefilefromthes-file,but thisfileisintendedtobeeditedandthenincorporatedbackintothes-file.Onlyoneper-sonmaybeeditingafileatonetime. (3)Mergeafilebackintothes-file.Thisisthecompanionoperationto(2).Anewversion numberisassigned,andcommentsaresavedexplainingwhythischangewasmade. 2.LearningtheLingo Thereareanumberoftermsthatareworthlearningbeforewegoanyfarther. 2.1.S-file Thes-fileisasinglefilethatholdsallthedifferentversionsofyourfile.Thes-fileisstored indifferentialformat;i.e.,onlythedifferencesbetweenversionsarestored,ratherthantheentire textofthenewversion.Thissavesdiskspaceandallowsselectivechangestoberemovedlater. Thisisversion1.21ofthisdocument.Itwaslastmodifiedon12/5/80. SCCSIntroduction 1 SCCSIntroduction 2 Alsoincludedinthes-fileissomeheaderinformationforeachversion,includingthecomments givenbythepersonwhocreatedtheversionexplainingwhythechangesweremade. 2.2.Deltas Eachsetofchangestothes-file(whichisapproximately[butnotexactly!]equivalenttoa versionofthefile)iscalledadelta.Althoughtechnicallyadeltaonlyincludesthechangesmade, inpracticeitisusualforeachdeltatobemadewithrespecttoallthedeltasthathaveoccurred before1.However,itispossibletogetaversionofthefilethathasselecteddeltasremovedoutof themiddleofthelistofchanges—equivalenttoremovingyourchangeslater. 2.3.SID’s(or,versionnumbers) ASID(SCCSId)isanumberthatrepresentsadelta.Thisisnormallyatwo-partnumber consistingofa“release”numberanda“level”number.Normallythereleasenumberstaysthe same,however,itispossibletomoveintoanewreleaseifsomemajorchangeisbeingmade. Sinceallpastdeltasarenormallyapplied,theSIDofthefinaldeltaappliedcanbeusedto representaversionnumberofthefileasawhole. 2.4.Idkeywords Whenyougetaversionofafilewithintenttocompileandinstallit(i.e.,somethingother thaneditit),somespecialkeywordsareexpandedinlinebySCCS.TheseIdKeywordscanbe usedtoincludethecurrentversionnumberorotherinformationintothefile.Allidkeywordsare oftheform%x%,wherexisanuppercaseletter.Forexample,%I%istheSIDofthelatest deltaapplied,%W%includesthemodulename,SID,andamarkthatmakesitfindablebyaprogram,and%G%isthedateofthelatestdeltaapplied.Therearemanyothers,mostofwhich areofdubioususefulness. Whenyougetafileforediting,theidkeywordsarenotexpanded;thisissothatafteryou putthembackintothes-file,theywillbeexpandedautomaticallyoneachnewversion.But notice:ifyouweretogetthemexpandedaccidently,thenyourfilewouldappeartobethesame versionforevermore,whichwouldofcoursedefeatthepurpose.Also,ifyoushouldinstallaversionoftheprogramwithoutexpandingtheidkeywords,itwillbeimpossibletotellwhatversion itis(sinceallitwillhaveis“%W%”orwhatever). 3.CreatingSCCSFiles ToputsourcefilesintoSCCSformat,runthefollowingshellscriptfromcsh: mkdirSCCSsave foreachi(*.[ch]) sccsadmin−i$i$i mv$isave/$i end Thiswillputthenamedfilesintos-filesinthesubdirectory“SCCS”Thefileswillberemoved fromthecurrentdirectoryandhiddenawayinthedirectory“save”,sothenextthingyouwill probablywanttodoistogetallthefiles(describedbelow).WhenyouareconvincedthatSCCS hascorrectlycreatedthes-files,youshouldremovethedirectory“save”. Ifyouwanttohaveidkeywordsinthefiles,itisbesttoputtheminbeforeyoucreatethesfiles.Ifyoudonot,adminwillprint“NoIdKeywords(cm7)”,whichisawarningmessageonly. 1Thismatchesnormalusage,wherethepreviouschangesarenotsavedatall,soallchangesareautomaticallybased onallotherchangesthathavehappenedthroughhistory.

SCCSIntroduction 3 4.GettingFilesforCompilation Togetacopyofthelatestversionofafile,run sccsgetprog.c SCCSwillrespond: 1.1 87lines meaningthatversion1.1wasretrieved2andthatithas87lines.Thefileprog.cwillbecreatedin thecurrentdirectory.Thefilewillberead-onlytoremindyouthatyouarenotsupposedto changeit. Thiscopyofthefileshouldnotbechanged,sinceSCCSisunabletomergethechangesback intothes-file.Ifyoudomakechanges,theywillbelostthenexttimesomeonedoesaget. 5.ChangingFiles(or,CreatingDeltas) 5.1.Gettingacopytoedit Toeditasourcefile,youmustfirstgetit,requestingpermissiontoeditit3: sccseditprog.c Theresponsewillbethesameaswithgetexceptthatitwillalsosay: Newdelta1.2 Youtheneditit,usingastandardtexteditor: viprog.c 5.2.Mergingthechangesbackintothes-file Whenthedesiredchangesaremade,youcanputyourchangesintotheSCCSfileusingthe deltacommand: sccsdeltaprog.c Deltawillpromptyoufor“comments?”beforeitmergesthechangesin.Atthispromptyou shouldtypeaone-linedescriptionofwhatthechangesmean(morelinescanbeenteredbyending eachlineexceptthelastwithabackslash4).Deltawillthentype: 1.2 5inserted 3deleted 84unchanged sayingthatdelta1.2wascreated,anditinsertedfivelines,removedthreelines,andleft84lines unchanged5.Theprog.cfilewillberemoved;itcanberetrievedusingget. 2Actually,theSIDofthefinaldeltaappliedwas1.1. 3The“edit”commandisequivalenttousingthe−eflagtoget,as: sccsget−eprog.c Keepthisinmindwhenreadingotherdocumentation. 4Yes,thisisastupiddefault. 5Changestoalinearecountedasalinedeletedandalineinserted.

SCCSIntroduction 4 5.3.Whentomakedeltas Itisprobablyunwisetomakeadeltabeforeeveryrecompilationortest;otherwise,youtend togetalotofdeltaswithcommentslike“fixedcompilationprobleminpreviousdelta”or“fixed botchin1.3”.However,itisveryimportanttodeltaeverythingbeforeinstallingamodulefor generaluse.Agoodtechniqueistoeditthefilesyouneed,makeallnecessarychangesandtests, compilingandeditingasoftenasnecessarywithoutmakingdeltas.Whenyouaresatisfiedthat youhaveaworkingversion,deltaeverythingbeingedited,re-getthem,andrecompileeverything. 5.4.What’sgoingon:theinfocommand Tofindoutwhatfileswherebeingedited,youcanuse: sccsinfo toprintoutallthefilesbeingeditedandotherinformationsuchasthenameoftheuserwhodid theedit.Also,thecommand: sccscheck isnearlyequivalenttotheinfocommand,exceptthatitissilentifnothingisbeingedited,and returnsnon-zeroexitstatusifanythingisbeingedited;itcanbeusedinan“install”entryina makefiletoaborttheinstallifanythinghasnotbeenproperlydeltaed. Ifyouknowthateverythingbeingeditedshouldbedeltaed,youcanuse: sccsdelta` sccstell` Thetellcommandissimilartoinfoexceptthatonlythenamesoffilesbeingeditedareoutput, oneperline. Allofthesecommandstakea−bflagtoignore“branches”(alternateversions,described later)andthe−uflagtoonlygivefilesbeingeditedbyyou.The−uflagtakesanoptionaluser argument,givingonlyfilesbeingeditedbythatuser.Forexample, sccsinfo−ujohn givesalistingoffilesbeingeditedbyjohn. 5.5.IDkeywords Idkeywordscanbeinsertedintoyourfilethatwillbeexpandedautomaticallybyget.For example,alinesuchas: staticcharSccsId[]="%W%\t%G%"; willbereplacedwithsomethinglike: staticcharSccsId[]="@(#)prog.c1.208/29/80"; Thistellsyouthenameandversionofthesourcefileandthetimethedeltawascreated.The string“@(#)”isaspecialstringwhichsignalsthebeginningofanSCCSIdkeyword. 5.5.1.Thewhatcommand Tofindoutwhatversionofaprogramisbeingrun,use: sccswhatprog.c/usr/bin/prog whichwillprintallstringsitfindsthatbeginwith“@(#)”.Thisworksonalltypesoffiles, includingbinariesandlibraries.Forexample,theabovecommandwilloutputsomethinglike: prog.c: prog.c1.208/29/80 /usr/bin/prog: prog.c1.102/05/79 SCCSIntroduction 5 FromthisIcanseethatthesourcethatIhaveinprog.cwillnotcompileintothesameversionas thebinaryin/usr/bin/prog. 5.5.2.Wheretoputidkeywords IDkeywordscanbeinsertedanywhere,includingincomments,butIdKeywordsthatare compiledintotheobjectmoduleareespeciallyuseful,sinceitletsyoufindoutwhatversionofthe objectisbeingrun,aswellasthesource.However,thereisacost:dataspaceisuseduptostore thekeywords,andonsmalladdressspacemachinesthismaybeprohibitive. Whenyouputidkeywordsintoheaderfiles,itisimportantthatyouassignthemtodifferent variables.Forexample,youmightuse: staticcharAccessSid[]="%W%%G%"; inthefileaccess.hand: staticcharOpsysSid[]="%W%%G%"; inthefileopsys.h.Otherwise,youwillgetcompilationerrorsbecause“SccsId”isredefined.The problemwiththisisthatiftheheaderfileisincludedbymanymodulesthatareloadedtogether, theversionnumberofthatheaderfileisincludedintheobjectmodulemanytimes;youmayfind itmoretoyourtastetoputidkeywordsinheaderfilesincomments. 5.6.KeepingSID’sconsistentacrossfiles Withsomecare,itispossibletokeeptheSID’sconsistentinmulti-filesystems.Thetrick hereistoalwayseditallfilesatonce.Thechangescanthenbemadetowhateverfilesarenecessaryandthenallfiles(eventhosenotchanged)areredeltaed.Thiscanbedonefairlyeasilyby justspecifyingthenameofthedirectorythattheSCCSfilesarein: sccseditSCCS whichwilleditallfilesinthatdirectory.Tomakethedelta,use: sccsdeltaSCCS Youwillbepromptedforcommentsonlyonce. 5.7.Creatingnewreleases Whenyouwanttocreateanewreleaseofaprogram,youcanspecifythereleasenumber youwanttocreateontheeditcommand.Forexample: sccsedit−r2prog.c willcausethenextdeltatobeinreleasetwo(thatis,itwillbenumbered2.1).Futuredeltaswill automaticallybeinreleasetwo.Tochangethereleasenumberofanentiresystem,use: sccsedit−r2SCCS 6.RestoringOldVersions 6.1.Revertingtooldversions Supposethatafterdelta1.2wasstableyoumadeandreleasedadelta1.3.Butthisintroducedabug,soyoumadeadelta1.4tocorrectit.But1.4wasstillbuggy,andyoudecidedyou wantedtogobacktotheoldversion.Youcouldreverttodelta1.2bychoosingtheSIDinaget: sccsget−r1.2prog.c Thiswillproduceaversionofprog.cthatisdelta1.2thatcanbereinstalledsothatworkcanproceed.

SCCSIntroduction 6 Insomecasesyoudon’tknowwhattheSIDofthedeltayouwantis.However,youcan reverttotheversionoftheprogramthatwasrunningasofacertaindatebyusingthe−c(cutoff) flag.Forexample, sccsget−c800722120000prog.c willretrievewhateverversionwascurrentasofJuly22,1980at12:00noon.Trailingcomponents canbestrippedoff(defaultingtotheirhighestlegalvalue),andpunctuationcanbeinsertedin theobviousplaces;forexample,theabovelinecouldbeequivalentlystated: sccsget−c"80/07/2212:00:00"prog.c 6.2.Selectivelydeletingolddeltas Supposethatyoulaterdecidedthatyoulikedthechangesindelta1.4,butthatdelta1.3 shouldberemoved.Youcoulddothisbyexcludingdelta1.3: sccsedit−x1.3prog.c Whendelta1.5ismade,itwillincludethechangesmadeindelta1.4,butwillexcludethechanges madeindelta1.3.Youcanexcludearangeofdeltasusingadash.Forexample,ifyouwantto getridof1.3and1.4youcanuse: sccsedit−x1.3−1.4prog.c whichwillexcludealldeltasfrom1.3to1.4.Alternatively, sccsedit−x1.3−1prog.c willexcludearangeofdeltasfrom1.3tothecurrenthighestdeltainrelease1. Incertaincaseswhenusing−x(or−i;seebelow)therewillbeconflictsbetweenversions; forexample,itmaybenecessarytobothincludeanddeleteaparticularline.Ifthishappens, SCCSalwaysprintsoutamessagetellingtherangeoflineseffected;theselinesshouldthenbe examinedverycarefullytoseeiftheversionSCCSgotisok. Sinceeachdelta(inthesenseof“asetofchanges”)canbeexcludedatwill,thatthismakes itmostusefultoputeachsemanticallydistinctchangeintoitsowndelta. 7.AuditingChanges 7.1.Theprtcommand Whenyoucreatedadelta,youpresumablygaveareasonforthedeltatothe“comments?” prompt.Toprintoutthesecommentslater,use: sccsprtprog.c ThiswillproduceareportforeachdeltaoftheSID,timeanddateofcreation,userwhocreated thedelta,numberoflinesinserted,deleted,andunchanged,andthecommentsassociatedwiththe delta.Forexample,theoutputoftheabovecommandmightbe: D1.280/08/2912:35:31bill2100005/00003/00084 removed"-q"option D1.179/02/0500:19:31eric1000087/00000/00000 dateandtimecreated80/06/1000:19:31byeric 7.2.Findingwhylineswereinserted Tofindoutwhyyouinsertedlines,youcangetacopyofthefilewitheachlineprecededby theSIDthatcreatedit: sccsget−mprog.c SCCSIntroduction 7 Youcanthenfindoutwhatthisdeltadidbyprintingthecommentsusingprt. Tofindoutwhatlinesareassociatedwithaparticulardelta(e.g.,1.3),use: sccsget−m−pprog.c|grep´ ˆ 1.3´ The−pflagcausesSCCStooutputthegeneratedsourcetothestandardoutputratherthantoa file. 7.3.Findingwhatchangesyouhavemade Whenyouareeditingafile,youcanfindoutwhatchangesyouhavemadeusing: sccsdiffsprog.c Mostofthe‘‘diff’’flagscanbeused.Topassthe−cflag,use−C. Tocomparetwoversionsthatareindeltas,use: sccssccsdiff-r1.3-r1.6prog.c toseethedifferencesbetweendelta1.3anddelta1.6. 8.ShorthandNotations Thereareseveralsequencesofcommandsthatgetexecutedfrequently.Sccstriestomakeit easytodothese. 8.1.Delget Afrequentrequirementistomakeadeltaofsomefileandthengetthatfile.Thiscanbe donebyusing: sccsdelgetprog.c whichisentirelyequivalenttousing: sccsdeltaprog.c sccsgetprog.c The“deledit”commandisequivalentto“delget”exceptthatthe“edit”commandisusedinstead ofthe“get”command. 8.2.Fix Frequently,therearesmallbugsindeltas,e.g.,compilationerrors,forwhichthereisnoreasontomaintainanaudittrail.Toreplaceadelta,use: sccsfix−r1.4prog.c Thiswillgetacopyofdelta1.4ofprog.cforyoutoeditandthendeletedelta1.4fromtheSCCS file.Whenyoudoadeltaofprog.c,itwillbedelta1.4again.The−rflagmustbespecified,and thedeltathatisspecifiedmustbealeafdelta,i.e.,nootherdeltasmayhavebeenmadesubsequenttothecreationofthatdelta. 8.3.Unedit Ifyoufoundyoueditedafilethatyoudidnotwanttoedit,youcanbackoutbyusing: sccsuneditprog.c 8.4.The−dflag IfyouareworkingonaprojectwheretheSCCScodeisinadirectorysomewhere,youmay beabletosimplifythingsbyusingashellalias.Forexample,thealias:

SCCSIntroduction 8 aliassyssccssccs−d/usr/src willallowyoutoissuecommandssuchas: syssccseditcmd/who.c whichwilllookforthefile“/usr/src/cmd/SCCS/who.c”.Thefile“who.c”willalwaysbecreated inyourcurrentdirectoryregardlessofthevalueofthe−dflag. 9.UsingSCCSonaProject Workingonaprojectwithseveralpeoplehasitsownsetofspecialproblems.Themain problemoccurswhentwopeoplemodifyafileatthesametime.SCCSpreventsthisbylockingan s-filewhileitisbeingedited. Asaresult,filesshouldnotbereservedforeditingunlesstheyareactuallybeingeditedat thetime,sincethiswillpreventotherpeopleontheprojectfrommakingnecessarychanges.For example,agoodscenarioforworkingmightbe: sccsedita.cg.ct.c via.cg.ct.c #dotestingofthe(experimental)version sccsdelgeta.cg.ct.c sccsinfo #shouldrespond"Nothingbeingedited" makeinstall Asageneralrule,allsourcefilesshouldbedeltaedbeforeinstallingtheprogramforgeneral use.Thiswillinsurethatitispossibletorestoreanyversioninuseatanytime. 10.SavingYourself 10.1.Recoveringamungededitfile Sometimesyoumayfindthatyouhavedestroyedortrashedafilethatyouweretryingto edit6.Unfortunately,youcan’tjustremoveitandre-editit;SCCSkeepstrackofthefactthat someoneistryingtoeditit,soitwon’tletyoudoitagain.Neithercanyoujustgetitusingget, sincethatwouldexpandtheIdkeywords.Instead,youcansay: sccsget−kprog.c ThiswillnotexpandtheIdkeywords,soitissafetodoadeltawithit. Alternately,youcanuneditandeditthefile. 10.2.Restoringthes-file Inparticularlybadcircumstances,theSCCSfileitselfmaygetmunged.Themostcommon waythishappensisthatitgetsedited.SinceSCCSkeepsachecksum,youwillgeterrorsevery timeyoureadthefile.Tofixthischecksum,use: sccsadmin−zprog.c 11.UsingtheAdminCommand Thereareanumberofparametersthatcanbesetusingtheadmincommand.Themost interestingoftheseareflags.Flagscanbeaddedbyusingthe−fflag.Forexample: 6Orgivenupanddecidedtostartover.

SCCSIntroduction 9 sccsadmin−fd1prog.c setsthe“d”flagtothevalue“1”.Thisflagcanbedeletedbyusing: sccsadmin−ddprog.c Themostusefulflagsare: bAllowbranchestobemadeusingthe−bflagtoedit. dSIDDefaultSIDtobeusedonagetoredit.Ifthisisjustareleasenumberitconstrainsthe versiontoaparticularreleaseonly. iGiveafatalerroriftherearenoIdKeywordsinafile.Thisisusefultoguaranteethata versionofthefiledoesnotgetmergedintothes-filethathastheIdKeywordsinsertedas constantsinsteadofinternalforms. yThe“type”ofthemodule.Actually,thevalueofthisflagisunusedbySCCSexceptthat itreplacesthe%Y%keyword. The−tfileflagcanbeusedtostoredescriptivetextfromfile.Thisdescriptivetextmight bethedocumentationoradesignandimplementationdocument.Usingthe−tflaginsuresthat iftheSCCSfileissent,thedocumentationwillbesentalso.Iffileisomitted,thedescriptivetext isdeleted.Toseethedescriptivetext,use“prt−t”. Theadmincommandcanbeusedsafelyanynumberoftimesonfiles.Afileneednotbe gottenforadmintowork. 12.MaintainingDifferentVersions(Branches) Sometimesitisconvenienttomaintainanexperimentalversionofaprogramforan extendedperiodwhilenormalmaintenancecontinuesontheversioninproduction.Thiscanbe doneusinga“branch.”Normallydeltascontinueinastraightline,eachdependingonthedelta before.Creatingabranch“forksoff”aversionoftheprogram. Theabilitytocreatebranchesmustbeenabledinadvanceusing: sccsadmin−fbprog.c The−fbflagcanbespecifiedwhentheSCCSfileisfirstcreated. 12.1.Creatingabranch Tocreateabranch,use: sccsedit−bprog.c Thiswillcreateabranchwith(forexample)SID1.5.1.1.Thedeltasforthisversionwillbenumbered1.5.1.n. 12.2.Gettingfromabranch Deltasinabrancharenormallynotincludedwhenyoudoaget.Togettheseversions,you willhavetosay: sccsget−r1.5.1prog.c 12.3.Mergingabranchbackintothemaintrunk Atsomepointyouwillhavefinishedtheexperiment,andifitwassuccessfulyouwillwant toincorporateitintothereleaseversion.Butinthemeantimesomeonemayhavecreatedadelta 1.6thatyoudon’twanttolose.Thecommands: sccsedit−i1.5.1.1−1.5.1prog.c sccsdeltaprog.c SCCSIntroduction 10 willmergeallofyourchangesintothereleasesystem.Ifsomeofthechangesconflict,getwill printanerror;thegeneratedresultshouldbecarefullyexaminedbeforethedeltaismade. 12.4.Amoredetailedexample Thefollowingtechniquemightbeusedtomaintainadifferentversionofaprogram.First, createadirectorytocontainthenewversion: mkdir../newxyz cd../newxyz Editacopyoftheprogramonabranch: sccs−d../xyzeditprog.c Whenusingtheoldversion,besuretousethe−bflagtoinfo,check,tell,andcleantoavoidconfusion.Forexample,use: sccsinfo−b wheninthedirectory“xyz”. Ifyouwanttosaveacopyoftheprogram(stillonthebranch)backinthes-file,youcan use: sccs-d../xyzdeleditprog.c whichwilldoadeltaonthebranchandreedititforyou. Whentheexperimentiscomplete,mergeitbackintothes-fileusingdelta: sccs-d../xyzdeltaprog.c Atthispointyoumustdecidewhetherthisversionshouldbemergedbackintothetrunk(i.e.the defaultversion),whichmayhaveundergonechanges.Ifso,itcanbemergedusingthe−iflagto editasdescribedabove. 12.5.Awarning Branchesshouldbekepttoaminimum.Afterthefirstbranchfromthetrunk,SID’sare assignedratherhaphazardly,andthestructuregetscomplexfast. 13.UsingSCCSwithMake SCCSandmakecanbemadetoworktogetherwithalittlecare.Afewsamplemakefilesfor commonapplicationsareshown. Thereareafewbasicentriesthateverymakefileoughttohave.Theseare: a.out(orwhateverthemakefilegenerates.)Thisentryregenerateswhateverthismakefileissupposedtoregenerate.Ifthemakefileregeneratesmanythings,this shouldbecalled“all”andshouldinturnhavedependenciesoneverythingthe makefilecangenerate. installMovestheobjectstothefinalrestingplace,doinganyspecialchmod’sorranlib’s asappropriate. sourcesCreatesallthesourcefilesfromSCCSfiles. cleanRemovesallcruftfromthedirectory. printPrintsthecontentsofthedirectory. Theexamplesshownbelowareonlypartialexamples,andmayomitsomeoftheseentrieswhen theyaredeemedtobeobvious. ThecleanentryshouldnotremovefilesthatcanberegeneratedfromtheSCCSfiles.Itis sufficientlyimportanttohavethesourcefilesaroundatalltimesthattheonlytimetheyshould SCCSIntroduction 11 beremovediswhenthedirectoryisbeingmothballed.Todothis,thecommand: sccsclean canbeused.Thiswillremoveallfilesforwhichans-fileexists,butwhichisnotbeingedited. 13.1.Tomaintainsingleprograms Frequentlytherearedirectorieswithseverallargelyunrelatedprograms(suchassimplecommands).Thesecanbeputintoasinglemakefile: LDFLAGS=−i−s prog:prog.o $(CC)$(LDFLAGS)−oprogprog.o prog.o:prog.cprog.h example:example.o $(CC)$(LDFLAGS)−oexampleexample.o example.o:example.c .DEFAULT: sccsget$< Thetrickhereisthatthe.DEFAULTruleiscalledeverytimesomethingisneededthatdoesnot exist,andnootherruleexiststomakeit.Theexplicitdependencyofthe.ofileonthe.cfileis important.Anotherwayofdoingthesamethingis: SRCS=prog.cprog.hexample.c LDFLAGS=−i−s prog:prog.o $(CC)$(LDFLAGS)−oprogprog.o prog.o:prog.h example:example.o $(CC)$(LDFLAGS)−oexampleexample.o sources:$(SRCS) $(SRCS): sccsget$@ Thereareacoupleofadvantagestothisapproach:(1)theexplicitdependenciesofthe.oonthe.c filesarenotneeded,(2)thereisanentrycalled"sources"soifyouwanttogetallthesourcesyou canjustsay“makesources”,and(3)themakefileislesslikelytodoconfusingthingssinceit won’ttrytogetthingsthatdonotexist. 13.2.Tomaintainalibrary Librariesthatarelargelystaticarebestupdatedusingexplicitcommands,sincemake doesn’tknowaboutupdatingthemproperly.However,librariesthatareintheprocessofbeing developedcanbehandledquiteadequately.Theproblemisthatthe.ofileshavetobekeptout ofthelibraryaswellasinthelibrary.

SCCSIntroduction 12 #configurationinformation OBJS=a.ob.oc.od.o SRCS=a.cb.cc.cd.sx.hy.hz.h TARG=/usr/lib #programs GET=sccsget REL= AR=−ar RANLIB=ranlib lib.a:$(OBJS) $(AR)rvulib.a$(OBJS) $(RANLIB)lib.a install:lib.a sccscheck cplib.a$(TARG)/lib.a $(RANLIB)$(TARG)/lib.a sources:$(SRCS) $(SRCS): $(GET)$(REL)$@ print:sources pr*.h*.[cs] clean: rm−f*.o rm−fcorea.out$(LIB) The“$(REL)”inthegetcanbeusedtogetoldversionseasily;forexample: makeb.oREL=−r1.3 Theinstallentryincludestheline“sccscheck”beforeanythingelse.Thisguaranteesthat allthes-filesareuptodate(i.e.,nothingisbeingedited),andwillabortthemakeifthiscondi-tionisnotmet. 13.3.Tomaintainalargeprogram OBJS=a.ob.oc.od.o SRCS=a.cb.cc.yd.sx.hy.hz.h GET=sccsget REL= a.out:$(OBJS) $(CC)$(LDFLAGS)$(OBJS)$(LIBS) sources:$(SRCS) $(SRCS): $(GET)$(REL)$@ (Theprintandcleanentriesareidenticaltothepreviouscase.)Thismakefilerequirescopiesof thesourceandobjectfilestobekeptduringdevelopment.Itisprobablyalsowisetoincludelines oftheform:

SCCSIntroduction 13 a.o:x.hy.h b.o:z.h c.o:x.hy.hz.h z.h:x.h sothatmoduleswillberecompiledifheaderfileschange. Sincemakedoesnotdotransitiveclosureondependencies,youmayfindinsomemakefiles lineslike: z.h:x.h touchz.h Thiswouldbeusedincaseswherefilez.hhasaline: #include"x.h" inordertobringthemoddateofz.hinlinewiththemoddateofx.h.Whenyouhaveamakefile suchasabove,thetouchcommandcanberemovedcompletely;theequivalenteffectwillbe achievedbydoinganautomaticgetonz.h. 14.FurtherInformation TheSCCS/PWBUser’sManualgivesadeeperdescriptionofhowtouseSCCS.Ofparticularinterestarethenumberingofbranches,thel-file,whichgivesadescriptionofwhatdeltaswere usedonaget,andcertainotherSCCScommands. TheSCCSmanualpagesareagoodlastresort.Theseshouldbereadbysoftwaremanagers andbypeoplewhowanttoknoweverythingabouteverything. Bothofthesedocumentswerewrittenwithoutthesccsfrontendinmind,somostofthe examplesareslightlydifferentfromthoseinthisdocument.

SCCSIntroduction 14 QuickReference 1.Commands Thefollowingcommandsshouldallbeprecededwith“sccs”.Thislistisnotexhaustive;for moreoptionsseeFurtherInformation. getGetsfilesforcompilation(notforediting).Idkeywordsareexpanded. −rSIDVersiontoget. −pSendtostandardoutputratherthantotheactualfile. −kDon’texpandidkeywords. −ilistListofdeltastoinclude. −xlistListofdeltastoexclude. −mPrecedeeachlinewithSIDofcreatingdelta. −cdateDon’tapplyanydeltascreatedafterdate. editGetsfilesforediting.Idkeywordsarenotexpanded.Shouldbematchedwithadelta command. −rSIDSameasget.IfSIDspecifiesareleasethatdoesnotyetexist,thehighestnumbereddeltaisretrievedandthenewdeltaisnumberedwithSID. −bCreateabranch. −ilistSameasget. −xlistSameasget. deltaMergeafilegottenusingeditbackintothes-file.Collectcommentsaboutwhythis deltawasmade. uneditRemoveafilethathasbeeneditedpreviouslywithoutmergingthechangesintothesfile. prtProduceareportofchanges. −tPrintthedescriptivetext. −ePrint(nearly)everything. infoGivealistofallfilesbeingedited. −bIgnorebranches. −u[user] Ignorefilesnotbeingeditedbyuser. checkSameasinfo,exceptthatnothingisprintedifnothingisbeingeditedandexitstatusis returned. tellSameasinfo,exceptthatonelineisproducedperfilebeingeditedcontainingonlythe filename. cleanRemoveallfilesthatcanberegeneratedfromthes-file. whatFindandprintidkeywords. adminCreateorsetparametersons-files. −ifileCreate,usingfileastheinitialcontents. −zRebuildthechecksumincasethefilehasbeentrashed.

SCCSIntroduction 15 −fflagTurnontheflag. −dflagTurnoff(delete)theflag. −tfileReplacethedescriptivetextinthes-filewiththecontentsoffile.Iffileis omitted,thetextisdeleted.Usefulforstoringdocumentationor“design& implementation”documentstoinsuretheygetdistributedwiththes-file. Usefulflagsare: bAllowbranchestobemadeusingthe−bflagtoedit. dSIDDefaultSIDtobeusedonagetoredit. iCause“NoIdKeywords”errormessagetobeafatalerrorratherthanawarning. tThemodule“type”;thevalueofthisflagreplacesthe%Y%keyword. fixRemoveadeltaandreeditit. delgetDoadeltafollowedbyaget. deleditDoadeltafollowedbyanedit. 2.IdKeywords %Z%Expandsto“@(#)”forthewhatcommandtofind. %M%Thecurrentmodulename,e.g.,“prog.c”. %I%ThehighestSIDapplied. %W%Ashorthandfor“%Z%%M%<tab>%I%”. %G%Thedateofthedeltacorrespondingtothe“%I%”keyword. %R%Thecurrentreleasenumber,i.e.,thefirstcomponentofthe“%I%”keyword. %Y%Replacedbythevalueofthetflag(setbyadmin).