欢迎来到天天文库
浏览记录
ID:56972260
大小:58.50 KB
页数:23页
时间:2020-07-25
《北大 internet高级程序设计 lecture5-Makefile课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Lecture5MakefileIntroductionThe“make”utilityinUnixisoneoftheoriginaltoolsdesignedbyS.I.FieldmanofAT&TBelllabscirca1977.Therearemanyversion.Whatis“make”?:Thetoolisdesignedtoallowprogrammerstoefficientlycompilelargecomplexprogramswithmanycomponentseasily.Youcanplacethecommandst
2、ocompileaprograminaUnixscriptbutthiswillcauseALLmodulestobecompiledeverytime.The“make”utilityallowsustoonlycompilethosethathavechangedandthemodulesthatdependuponthem.HowDoesitWork?InUnix,whenyoutypethecommand“make”theoperatingsystemlooksforafilecalledeither“makefile”or“Makefi
3、le”.Thereareexceptionstothisbutwewillassumethatyouwillalwayshavethe“makefile”or“Makefile”fileresidentinthedirectoryofwhereyourprogramresides.Thisfilecontainsaseriesofdirectivesthattellthe“make”utilityhowtocompileyourprogramandinwhatorder.Eachfilewillbeassociatedwithalistofoth
4、erfilesbywhichitisdependent.Thisiscalledadependencyline.Ifanyoftheassociatedfileshavebeenrecentlymodified,themakeutilitywillexecuteadirectivecommandjustbelowthedependencyline.HowDoesitWork?The“make”utilityisrecursive.Forinstance,ifaverylowlevelutilityistheonlythingchanged,itc
5、ouldcauseallofthemoduleswithinaprogramtobere-compiled.Aftertheutilityfinishesthefile,itgoesthroughandchecksallofthedependenciesagaintomakesureallareuptodate.SimpleExamplehello:main.ofactorial.ohello.og++main.ofactorial.ohello.o-ohellomain.o:main.cppg++-cmain.cppfactorial.o:fa
6、ctorial.cppg++-cfactorial.cpphello.o:hello.cppg++-chello.cppclean:rm-rf*ohelloTheTreehellomain.ofactorial.ofactorial.cppmain.cppfactorial.ohello.ohello.cppcleanComponentsofaMakefileCommentsRulesDependencyLinesShellLinesMacrosInferenceRulesCommentsAcommentisindicatedbythechara
7、cter“#”. Alltextthatappearsafteritwillbeignoredbythemakeutilityuntiltheendoflineisdetected.Commentscanstartanywhere. Therearemorecomplexcommentstylesthatinvolvecontinuationcharactersbutpleasestarteachnewcommentlinewithan#andavoidthemoreadvancedfeaturesfornow.Example##Thisisac
8、ommentprojecte.exe:main.objio.obj#thisisalsoacomment.RulesRulestellm
此文档下载收益归作者所有