manual.html 523 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Buildroot user manual</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /></head><body><div xml:lang="en" class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="idm1"></a>The Buildroot user manual</h1></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="preface"><a href="#idm4"></a></span></dt><dt><span class="part"><a href="#_getting_started">I. Getting started</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_about_buildroot">1. About Buildroot</a></span></dt><dt><span class="chapter"><a href="#requirement">2. System requirements</a></span></dt><dd><dl><dt><span class="section"><a href="#requirement-mandatory">2.1. Mandatory packages</a></span></dt><dt><span class="section"><a href="#requirement-optional">2.2. Optional packages</a></span></dt></dl></dd><dt><span class="chapter"><a href="#getting-buildroot">3. Getting Buildroot</a></span></dt><dt><span class="chapter"><a href="#_buildroot_quick_start">4. Buildroot quick start</a></span></dt><dt><span class="chapter"><a href="#community-resources">5. Community resources</a></span></dt></dl></dd><dt><span class="part"><a href="#_user_guide">II. User guide</a></span></dt><dd><dl><dt><span class="chapter"><a href="#configure">6. Buildroot configuration</a></span></dt><dd><dl><dt><span class="section"><a href="#_cross_compilation_toolchain">6.1. Cross-compilation toolchain</a></span></dt><dt><span class="section"><a href="#_dev_management">6.2. /dev management</a></span></dt><dt><span class="section"><a href="#_init_system">6.3. init system</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_configuration_of_other_components">7. Configuration of other components</a></span></dt><dt><span class="chapter"><a href="#_general_buildroot_usage">8. General Buildroot usage</a></span></dt><dd><dl><dt><span class="section"><a href="#make-tips">8.1. <span class="emphasis"><em>make</em></span> tips</a></span></dt><dt><span class="section"><a href="#full-rebuild">8.2. Understanding when a full rebuild is necessary</a></span></dt><dt><span class="section"><a href="#rebuild-pkg">8.3. Understanding how to rebuild packages</a></span></dt><dt><span class="section"><a href="#_offline_builds">8.4. Offline builds</a></span></dt><dt><span class="section"><a href="#_building_out_of_tree">8.5. Building out-of-tree</a></span></dt><dt><span class="section"><a href="#env-vars">8.6. Environment variables</a></span></dt><dt><span class="section"><a href="#_dealing_efficiently_with_filesystem_images">8.7. Dealing efficiently with filesystem images</a></span></dt><dt><span class="section"><a href="#_details_about_packages">8.8. Details about packages</a></span></dt><dt><span class="section"><a href="#_graphing_the_dependencies_between_packages">8.9. Graphing the dependencies between packages</a></span></dt><dt><span class="section"><a href="#_graphing_the_build_duration">8.10. Graphing the build duration</a></span></dt><dt><span class="section"><a href="#graph-size">8.11. Graphing the filesystem size contribution of packages</a></span></dt><dt><span class="section"><a href="#top-level-parallel-build">8.12. Top-level parallel build</a></span></dt><dt><span class="section"><a href="#_integration_with_eclipse">8.13. Integration with Eclipse</a></span></dt><dt><span class="section"><a href="#_advanced_usage">8.14. Advanced usage</a></span></dt></dl></dd><dt><span class="chapter"><a href="#customize">9. Project-specific customization</a></span></dt><dd><dl><dt><span class="section"><a href="#customize-dir-structure">9.1. Recommended directory structure</a></span></dt><dt><span class="section"><a href="#outside-br-custom">9.2. Keeping customizations outside of Buildroot</a></span></dt><dt><span class="section"><a href="#customize-store-buildroot-config">9.3. Storing the Buildroot configuration</a></span></dt><dt><span class="section"><a href="#customize-store-package-config">9.4. Storing the configuration of other components</a></span></dt><dt><span class="section"><a href="#rootfs-custom">9.5. Customizing the generated target filesystem</a></span></dt><dt><span class="section"><a href="#customize-users">9.6. Adding custom user accounts</a></span></dt><dt><span class="section"><a href="#_customization_emphasis_after_emphasis_the_images_have_been_created">9.7. Customization <span class="emphasis"><em>after</em></span> the images have been created</a></span></dt><dt><span class="section"><a href="#customize-patches">9.8. Adding project-specific patches</a></span></dt><dt><span class="section"><a href="#customize-packages">9.9. Adding project-specific packages</a></span></dt><dt><span class="section"><a href="#_quick_guide_to_storing_your_project_specific_customizations">9.10. Quick guide to storing your project-specific customizations</a></span></dt></dl></dd><dt><span class="chapter"><a href="#selinux">10. Using SELinux in Buildroot</a></span></dt><dd><dl><dt><span class="section"><a href="#enabling-selinux">10.1. Enabling SELinux support</a></span></dt><dt><span class="section"><a href="#selinux-policy-tweaking">10.2. SELinux policy tweaking</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_frequently_asked_questions_amp_troubleshooting">11. Frequently Asked Questions &amp; Troubleshooting</a></span></dt><dd><dl><dt><span class="section"><a href="#faq-boot-hang-after-starting">11.1. The boot hangs after <span class="emphasis"><em>Starting network…</em></span></a></span></dt><dt><span class="section"><a href="#faq-no-compiler-on-target">11.2. Why is there no compiler on the target?</a></span></dt><dt><span class="section"><a href="#faq-no-dev-files-on-target">11.3. Why are there no development files on the target?</a></span></dt><dt><span class="section"><a href="#faq-no-doc-on-target">11.4. Why is there no documentation on the target?</a></span></dt><dt><span class="section"><a href="#faq-why-not-visible-package">11.5. Why are some packages not visible in the Buildroot config menu?</a></span></dt><dt><span class="section"><a href="#faq-why-not-use-target-as-chroot">11.6. Why not use the target directory as a chroot directory?</a></span></dt><dt><span class="section"><a href="#faq-no-binary-packages">11.7. Why doesn’t Buildroot generate binary packages (.deb, .ipkg…)?</a></span></dt><dt><span class="section"><a href="#faq-speeding-up-build">11.8. How to speed-up the build process?</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_known_issues">12. Known issues</a></span></dt><dt><span class="chapter"><a href="#legal-info">13. Legal notice and licensing</a></span></dt><dd><dl><dt><span class="section"><a href="#_complying_with_open_source_licenses">13.1. Complying with open source licenses</a></span></dt><dt><span class="section"><a href="#legal-info-buildroot">13.2. Complying with the Buildroot license</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_beyond_buildroot">14. Beyond Buildroot</a></span></dt><dd><dl><dt><span class="section"><a href="#_boot_the_generated_images">14.1. Boot the generated images</a></span></dt><dt><span class="section"><a href="#_chroot">14.2. Chroot</a></span></dt></dl></dd></dl></dd><dt><span class="part"><a href="#_developer_guide">III. Developer guide</a></span></dt><dd><dl><dt><span class="chapter"><a href="#_how_buildroot_works">15. How Buildroot works</a></span></dt><dt><span class="chapter"><a href="#_coding_style">16. Coding style</a></span></dt><dd><dl><dt><span class="section"><a href="#writing-rules-config-in">16.1. <code class="literal">Config.in</code> file</a></span></dt><dt><span class="section"><a href="#writing-rules-mk">16.2. The <code class="literal">.mk</code> file</a></span></dt><dt><span class="section"><a href="#_the_documentation">16.3. The documentation</a></span></dt><dt><span class="section"><a href="#_support_scripts">16.4. Support scripts</a></span></dt></dl></dd><dt><span class="chapter"><a href="#adding-board-support">17. Adding support for a particular board</a></span></dt><dt><span class="chapter"><a href="#adding-packages">18. Adding new packages to Buildroot</a></span></dt><dd><dl><dt><span class="section"><a href="#_package_directory">18.1. Package directory</a></span></dt><dt><span class="section"><a href="#_config_files">18.2. Config files</a></span></dt><dt><span class="section"><a href="#_the_literal_mk_literal_file">18.3. The <code class="literal">.mk</code> file</a></span></dt><dt><span class="section"><a href="#adding-packages-hash">18.4. The <code class="literal">.hash</code> file</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_packages_with_specific_build_systems">18.5. Infrastructure for packages with specific build systems</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_autotools_based_packages">18.6. Infrastructure for autotools-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_cmake_based_packages">18.7. Infrastructure for CMake-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_python_packages">18.8. Infrastructure for Python packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_luarocks_based_packages">18.9. Infrastructure for LuaRocks-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_perl_cpan_packages">18.10. Infrastructure for Perl/CPAN packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_virtual_packages">18.11. Infrastructure for virtual packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_packages_using_kconfig_for_configuration_files">18.12. Infrastructure for packages using kconfig for configuration files</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_rebar_based_packages">18.13. Infrastructure for rebar-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_waf_based_packages">18.14. Infrastructure for Waf-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_meson_based_packages">18.15. Infrastructure for Meson-based packages</a></span></dt><dt><span class="section"><a href="#_integration_of_cargo_based_packages">18.16. Integration of Cargo-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_go_packages">18.17. Infrastructure for Go packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_qmake_based_packages">18.18. Infrastructure for QMake-based packages</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_packages_building_kernel_modules">18.19. Infrastructure for packages building kernel modules</a></span></dt><dt><span class="section"><a href="#_infrastructure_for_asciidoc_documents">18.20. Infrastructure for asciidoc documents</a></span></dt><dt><span class="section"><a href="#linux-kernel-specific-infra">18.21. Infrastructure specific to the Linux kernel package</a></span></dt><dt><span class="section"><a href="#hooks">18.22. Hooks available in the various build steps</a></span></dt><dt><span class="section"><a href="#_gettext_integration_and_interaction_with_packages">18.23. Gettext integration and interaction with packages</a></span></dt><dt><span class="section"><a href="#_tips_and_tricks">18.24. Tips and tricks</a></span></dt><dt><span class="section"><a href="#_conclusion">18.25. Conclusion</a></span></dt></dl></dd><dt><span class="chapter"><a href="#patch-policy">19. Patching a package</a></span></dt><dd><dl><dt><span class="section"><a href="#_providing_patches">19.1. Providing patches</a></span></dt><dt><span class="section"><a href="#patch-apply-order">19.2. How patches are applied</a></span></dt><dt><span class="section"><a href="#_format_and_licensing_of_the_package_patches">19.3. Format and licensing of the package patches</a></span></dt><dt><span class="section"><a href="#_integrating_patches_found_on_the_web">19.4. Integrating patches found on the Web</a></span></dt></dl></dd><dt><span class="chapter"><a href="#download-infra">20. Download infrastructure</a></span></dt><dt><span class="chapter"><a href="#debugging-buildroot">21. Debugging Buildroot</a></span></dt><dt><span class="chapter"><a href="#_contributing_to_buildroot">22. Contributing to Buildroot</a></span></dt><dd><dl><dt><span class="section"><a href="#_reproducing_analyzing_and_fixing_bugs">22.1. Reproducing, analyzing and fixing bugs</a></span></dt><dt><span class="section"><a href="#_analyzing_and_fixing_autobuild_failures">22.2. Analyzing and fixing autobuild failures</a></span></dt><dt><span class="section"><a href="#_reviewing_and_testing_patches">22.3. Reviewing and testing patches</a></span></dt><dt><span class="section"><a href="#_work_on_items_from_the_todo_list">22.4. Work on items from the TODO list</a></span></dt><dt><span class="section"><a href="#submitting-patches">22.5. Submitting patches</a></span></dt><dt><span class="section"><a href="#reporting-bugs">22.6. Reporting issues/bugs or getting help</a></span></dt><dt><span class="section"><a href="#_using_the_run_tests_framework">22.7. Using the run-tests framework</a></span></dt></dl></dd><dt><span class="chapter"><a href="#DEVELOPERS">23. DEVELOPERS file and get-developers</a></span></dt><dt><span class="chapter"><a href="#RELENG">24. Release Engineering</a></span></dt><dd><dl><dt><span class="section"><a href="#_releases">24.1. Releases</a></span></dt><dt><span class="section"><a href="#_development">24.2. Development</a></span></dt></dl></dd></dl></dd><dt><span class="part"><a href="#_appendix">IV. Appendix</a></span></dt><dd><dl><dt><span class="chapter"><a href="#makedev-syntax">25. Makedev syntax documentation</a></span></dt><dt><span class="chapter"><a href="#makeuser-syntax">26. Makeusers syntax documentation</a></span></dt><dt><span class="chapter"><a href="#migrating-from-ol-versions">27. Migrating from older Buildroot versions</a></span></dt><dd><dl><dt><span class="section"><a href="#br2-external-converting">27.1. Migrating to 2016.11</a></span></dt><dt><span class="section"><a href="#migrating-host-usr">27.2. Migrating to 2017.08</a></span></dt></dl></dd></dl></dd></dl></div><div class="list-of-examples"><p><strong>List of Examples</strong></p><dl><dt>18.1. <a href="#idm3189">Config script: <span class="emphasis"><em>divine</em></span> package</a></dt><dt>18.2. <a href="#idm3196">Config script: <span class="emphasis"><em>imagemagick</em></span> package:</a></dt></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a id="idm4"></a></h1></div></div></div><p>Buildroot 2020.11.1 manual generated on 2020-12-27
  3. 14:25:12 UTC from git revision 804a9e1865</p><p>The Buildroot manual is written by the Buildroot developers.
  4. It is licensed under the GNU General Public License, version 2. Refer to the
  5. <a class="ulink" href="http://git.buildroot.org/buildroot/tree/COPYING?id=804a9e18656c1584b059129e0b5cebe2a2405fac" target="_top">COPYING</a>
  6. file in the Buildroot sources for the full text of this license.</p><p>Copyright © 2004-2020 The Buildroot developers</p><div class="informalfigure"><div class="mediaobject"><img src="logo.png" alt="logo.png" /></div></div></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_getting_started"></a>Part I. Getting started</h1></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_about_buildroot"></a>Chapter 1. About Buildroot</h2></div></div></div><p>Buildroot is a tool that simplifies and automates the process of
  7. building a complete Linux system for an embedded system, using
  8. cross-compilation.</p><p>In order to achieve this, Buildroot is able to generate a
  9. cross-compilation toolchain, a root filesystem, a Linux kernel image
  10. and a bootloader for your target. Buildroot can be used for any
  11. combination of these options, independently (you can for example use
  12. an existing cross-compilation toolchain, and build only your root
  13. filesystem with Buildroot).</p><p>Buildroot is useful mainly for people working with embedded systems.
  14. Embedded systems often use processors that are not the regular x86
  15. processors everyone is used to having in his PC. They can be PowerPC
  16. processors, MIPS processors, ARM processors, etc.</p><p>Buildroot supports numerous processors and their variants; it also
  17. comes with default configurations for several boards available
  18. off-the-shelf. Besides this, a number of third-party projects are based on,
  19. or develop their BSP <a href="#ftn.idm24" class="footnote" id="idm24"><sup class="footnote">[1]</sup></a> or
  20. SDK <a href="#ftn.idm26" class="footnote" id="idm26"><sup class="footnote">[2]</sup></a> on top of Buildroot.</p><div class="footnotes"><br /><hr style="width:100; text-align:left;margin-left: 0" /><div id="ftn.idm24" class="footnote"><p><a href="#idm24" class="simpara"><sup class="simpara">[1] </sup></a>BSP: Board Support Package</p></div><div id="ftn.idm26" class="footnote"><p><a href="#idm26" class="simpara"><sup class="simpara">[2] </sup></a>SDK: Software Development Kit</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="requirement"></a>Chapter 2. System requirements</h2></div></div></div><p>Buildroot is designed to run on Linux systems.</p><p>While Buildroot itself will build most host packages it needs for the
  21. compilation, certain standard Linux utilities are expected to be
  22. already installed on the host system. Below you will find an overview of
  23. the mandatory and optional packages (note that package names may vary
  24. between distributions).</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="requirement-mandatory"></a>2.1. Mandatory packages</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  25. Build tools:
  26. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  27. <code class="literal">which</code>
  28. </li><li class="listitem">
  29. <code class="literal">sed</code>
  30. </li><li class="listitem">
  31. <code class="literal">make</code> (version 3.81 or any later)
  32. </li><li class="listitem">
  33. <code class="literal">binutils</code>
  34. </li><li class="listitem">
  35. <code class="literal">build-essential</code> (only for Debian based systems)
  36. </li><li class="listitem">
  37. <code class="literal">gcc</code> (version 4.8 or any later)
  38. </li><li class="listitem">
  39. <code class="literal">g++</code> (version 4.8 or any later)
  40. </li><li class="listitem">
  41. <code class="literal">bash</code>
  42. </li><li class="listitem">
  43. <code class="literal">patch</code>
  44. </li><li class="listitem">
  45. <code class="literal">gzip</code>
  46. </li><li class="listitem">
  47. <code class="literal">bzip2</code>
  48. </li><li class="listitem">
  49. <code class="literal">perl</code> (version 5.8.7 or any later)
  50. </li><li class="listitem">
  51. <code class="literal">tar</code>
  52. </li><li class="listitem">
  53. <code class="literal">cpio</code>
  54. </li><li class="listitem">
  55. <code class="literal">unzip</code>
  56. </li><li class="listitem">
  57. <code class="literal">rsync</code>
  58. </li><li class="listitem">
  59. <code class="literal">file</code> (must be in <code class="literal">/usr/bin/file</code>)
  60. </li><li class="listitem">
  61. <code class="literal">bc</code>
  62. </li></ul></div></li><li class="listitem"><p class="simpara">
  63. Source fetching tools:
  64. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  65. <code class="literal">wget</code>
  66. </li></ul></div></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="requirement-optional"></a>2.2. Optional packages</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  67. Recommended dependencies:
  68. </p><p class="simpara">Some features or utilities in Buildroot, like the legal-info, or the
  69. graph generation tools, have additional dependencies. Although they
  70. are not mandatory for a simple build, they are still highly recommended:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  71. <code class="literal">python</code> (version 2.7 or any later)
  72. </li></ul></div></li><li class="listitem"><p class="simpara">
  73. Configuration interface dependencies:
  74. </p><p class="simpara">For these libraries, you need to install both runtime and development
  75. data, which in many distributions are packaged separately. The
  76. development packages typically have a <span class="emphasis"><em>-dev</em></span> or <span class="emphasis"><em>-devel</em></span> suffix.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  77. <code class="literal">ncurses5</code> to use the <span class="emphasis"><em>menuconfig</em></span> interface
  78. </li><li class="listitem">
  79. <code class="literal">qt5</code> to use the <span class="emphasis"><em>xconfig</em></span> interface
  80. </li><li class="listitem">
  81. <code class="literal">glib2</code>, <code class="literal">gtk2</code> and <code class="literal">glade2</code> to use the <span class="emphasis"><em>gconfig</em></span> interface
  82. </li></ul></div></li><li class="listitem"><p class="simpara">
  83. Source fetching tools:
  84. </p><p class="simpara">In the official tree, most of the package sources are retrieved using
  85. <code class="literal">wget</code> from <span class="emphasis"><em>ftp</em></span>, <span class="emphasis"><em>http</em></span> or <span class="emphasis"><em>https</em></span> locations. A few packages are only
  86. available through a version control system. Moreover, Buildroot is
  87. capable of downloading sources via other tools, like <code class="literal">rsync</code> or <code class="literal">scp</code>
  88. (refer to <a class="xref" href="#download-infra" title="Chapter 20. Download infrastructure">Chapter 20, <em>Download infrastructure</em></a> for more details). If you enable
  89. packages using any of these methods, you will need to install the
  90. corresponding tool on the host system:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  91. <code class="literal">bazaar</code>
  92. </li><li class="listitem">
  93. <code class="literal">cvs</code>
  94. </li><li class="listitem">
  95. <code class="literal">git</code>
  96. </li><li class="listitem">
  97. <code class="literal">mercurial</code>
  98. </li><li class="listitem">
  99. <code class="literal">rsync</code>
  100. </li><li class="listitem">
  101. <code class="literal">scp</code>
  102. </li><li class="listitem">
  103. <code class="literal">subversion</code>
  104. </li></ul></div></li><li class="listitem"><p class="simpara">
  105. Java-related packages, if the Java Classpath needs to be built for
  106. the target system:
  107. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  108. The <code class="literal">javac</code> compiler
  109. </li><li class="listitem">
  110. The <code class="literal">jar</code> tool
  111. </li></ul></div></li><li class="listitem"><p class="simpara">
  112. Documentation generation tools:
  113. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  114. <code class="literal">asciidoc</code>, version 8.6.3 or higher
  115. </li><li class="listitem">
  116. <code class="literal">w3m</code>
  117. </li><li class="listitem">
  118. <code class="literal">python</code> with the <code class="literal">argparse</code> module (automatically present in 2.7+ and 3.2+)
  119. </li><li class="listitem">
  120. <code class="literal">dblatex</code> (required for the pdf manual only)
  121. </li></ul></div></li><li class="listitem"><p class="simpara">
  122. Graph generation tools:
  123. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  124. <code class="literal">graphviz</code> to use <span class="emphasis"><em>graph-depends</em></span> and <span class="emphasis"><em>&lt;pkg&gt;-graph-depends</em></span>
  125. </li><li class="listitem">
  126. <code class="literal">python-matplotlib</code> to use <span class="emphasis"><em>graph-build</em></span>
  127. </li></ul></div></li></ul></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="getting-buildroot"></a>Chapter 3. Getting Buildroot</h2></div></div></div><p>Buildroot releases are made every 3 months, in February, May, August and
  128. November. Release numbers are in the format YYYY.MM, so for example
  129. 2013.02, 2014.08.</p><p>Release tarballs are available at <a class="ulink" href="http://buildroot.org/downloads/" target="_top">http://buildroot.org/downloads/</a>.</p><p>For your convenience, a <a class="ulink" href="https://www.vagrantup.com/" target="_top">Vagrantfile</a> is
  130. available in <code class="literal">support/misc/Vagrantfile</code> in the Buildroot source tree
  131. to quickly set up a virtual machine with the needed dependencies to
  132. get started.</p><p>If you want to setup an isolated buildroot environment on Linux or Mac
  133. Os X, paste this line onto your terminal:</p><pre class="screen">curl -O https://buildroot.org/downloads/Vagrantfile; vagrant up</pre><p>If you are on Windows, paste this into your powershell:</p><pre class="screen">(new-object System.Net.WebClient).DownloadFile(
  134. "https://buildroot.org/downloads/Vagrantfile","Vagrantfile");
  135. vagrant up</pre><p>If you want to follow development, you can use the daily snapshots or
  136. make a clone of the Git repository. Refer to the
  137. <a class="ulink" href="http://buildroot.org/download" target="_top">Download page</a> of the Buildroot website
  138. for more details.</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_buildroot_quick_start"></a>Chapter 4. Buildroot quick start</h2></div></div></div><p><span class="strong"><strong>Important</strong></span>: you can and should <span class="strong"><strong>build everything as a normal user</strong></span>. There
  139. is no need to be root to configure and use Buildroot. By running all
  140. commands as a regular user, you protect your system against packages
  141. behaving badly during compilation and installation.</p><p>The first step when using Buildroot is to create a configuration.
  142. Buildroot has a nice configuration tool similar to the one you can
  143. find in the <a class="ulink" href="http://www.kernel.org/" target="_top">Linux kernel</a> or in
  144. <a class="ulink" href="http://www.busybox.net/" target="_top">BusyBox</a>.</p><p>From the buildroot directory, run</p><pre class="screen"> $ make menuconfig</pre><p>for the original curses-based configurator, or</p><pre class="screen"> $ make nconfig</pre><p>for the new curses-based configurator, or</p><pre class="screen"> $ make xconfig</pre><p>for the Qt-based configurator, or</p><pre class="screen"> $ make gconfig</pre><p>for the GTK-based configurator.</p><p>All of these "make" commands will need to build a configuration
  145. utility (including the interface), so you may need to install
  146. "development" packages for relevant libraries used by the
  147. configuration utilities. Refer to <a class="xref" href="#requirement" title="Chapter 2. System requirements">Chapter 2, <em>System requirements</em></a> for more details,
  148. specifically the <a class="link" href="#requirement-optional" title="2.2. Optional packages">optional requirements</a>
  149. to get the dependencies of your favorite interface.</p><p>For each menu entry in the configuration tool, you can find associated
  150. help that describes the purpose of the entry. Refer to <a class="xref" href="#configure" title="Chapter 6. Buildroot configuration">Chapter 6, <em>Buildroot configuration</em></a>
  151. for details on some specific configuration aspects.</p><p>Once everything is configured, the configuration tool generates a
  152. <code class="literal">.config</code> file that contains the entire configuration. This file will be
  153. read by the top-level Makefile.</p><p>To start the build process, simply run:</p><pre class="screen"> $ make</pre><p>By default, Buildroot does not support top-level parallel build, so
  154. running <code class="literal">make -jN</code> is not necessary. There is however experimental
  155. support for top-level parallel build, see
  156. <a class="xref" href="#top-level-parallel-build" title="8.12. Top-level parallel build">Section 8.12, “Top-level parallel build”</a>.</p><p>The <code class="literal">make</code> command will generally perform the following steps:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  157. download source files (as required);
  158. </li><li class="listitem">
  159. configure, build and install the cross-compilation toolchain, or
  160. simply import an external toolchain;
  161. </li><li class="listitem">
  162. configure, build and install selected target packages;
  163. </li><li class="listitem">
  164. build a kernel image, if selected;
  165. </li><li class="listitem">
  166. build a bootloader image, if selected;
  167. </li><li class="listitem">
  168. create a root filesystem in selected formats.
  169. </li></ul></div><p>Buildroot output is stored in a single directory, <code class="literal">output/</code>.
  170. This directory contains several subdirectories:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  171. <code class="literal">images/</code> where all the images (kernel image, bootloader and root
  172. filesystem images) are stored. These are the files you need to put
  173. on your target system.
  174. </li><li class="listitem">
  175. <code class="literal">build/</code> where all the components are built (this includes tools
  176. needed by Buildroot on the host and packages compiled for the
  177. target). This directory contains one subdirectory for each of these
  178. components.
  179. </li><li class="listitem">
  180. <code class="literal">host/</code> contains both the tools built for the host, and the sysroot
  181. of the target toolchain. The former is an installation of tools
  182. compiled for the host that are needed for the proper execution of
  183. Buildroot, including the cross-compilation toolchain. The latter
  184. is a hierarchy similar to a root filesystem hierarchy. It contains
  185. the headers and libraries of all user-space packages that provide
  186. and install libraries used by other packages. However, this
  187. directory is <span class="emphasis"><em>not</em></span> intended to be the root filesystem for the target:
  188. it contains a lot of development files, unstripped binaries and
  189. libraries that make it far too big for an embedded system. These
  190. development files are used to compile libraries and applications for
  191. the target that depend on other libraries.
  192. </li><li class="listitem">
  193. <code class="literal">staging/</code> is a symlink to the target toolchain sysroot inside
  194. <code class="literal">host/</code>, which exists for backwards compatibility.
  195. </li><li class="listitem">
  196. <code class="literal">target/</code> which contains <span class="emphasis"><em>almost</em></span> the complete root filesystem for
  197. the target: everything needed is present except the device files in
  198. <code class="literal">/dev/</code> (Buildroot can’t create them because Buildroot doesn’t run
  199. as root and doesn’t want to run as root). Also, it doesn’t have the correct
  200. permissions (e.g. setuid for the busybox binary). Therefore, this directory
  201. <span class="strong"><strong>should not be used on your target</strong></span>. Instead, you should use one of
  202. the images built in the <code class="literal">images/</code> directory. If you need an
  203. extracted image of the root filesystem for booting over NFS, then
  204. use the tarball image generated in <code class="literal">images/</code> and extract it as
  205. root. Compared to <code class="literal">staging/</code>, <code class="literal">target/</code> contains only the files and
  206. libraries needed to run the selected target applications: the
  207. development files (headers, etc.) are not present, the binaries are
  208. stripped.
  209. </li></ul></div><p>These commands, <code class="literal">make menuconfig|nconfig|gconfig|xconfig</code> and <code class="literal">make</code>, are the
  210. basic ones that allow to easily and quickly generate images fitting
  211. your needs, with all the features and applications you enabled.</p><p>More details about the "make" command usage are given in
  212. <a class="xref" href="#make-tips" title="8.1. make tips">Section 8.1, “<span class="emphasis"><em>make</em></span> tips”</a>.</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="community-resources"></a>Chapter 5. Community resources</h2></div></div></div><p>Like any open source project, Buildroot has different ways to share
  213. information in its community and outside.</p><p>Each of those ways may interest you if you are looking for some help,
  214. want to understand Buildroot or contribute to the project.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  215. Mailing List
  216. </span></dt><dd><p class="simpara">Buildroot has a mailing list for discussion and development. It is the
  217. main method of interaction for Buildroot users and developers.</p><p class="simpara">Only subscribers to the Buildroot mailing list are allowed to post to
  218. this list. You can subscribe via the
  219. <a class="ulink" href="http://lists.buildroot.org/mailman/listinfo/buildroot" target="_top">mailing list info
  220. page</a>.</p><p class="simpara">Mails that are sent to the mailing list are also available in the
  221. <a class="ulink" href="http://lists.buildroot.org/pipermail/buildroot" target="_top">mailing list archives</a> and
  222. via <a class="ulink" href="http://gmane.org" target="_top">Gmane</a>, at
  223. <a class="ulink" href="http://dir.gmane.org/gmane.comp.lib.uclibc.buildroot" target="_top"><code class="literal">gmane.comp.lib.uclibc.buildroot</code></a>.
  224. Please search the mailing list archives before asking questions, since
  225. there is a good chance someone else has asked the same question before.</p></dd><dt><span class="term">
  226. IRC
  227. </span></dt><dd><p class="simpara">The Buildroot IRC channel <a class="ulink" href="irc://freenode.net/#buildroot" target="_top">#buildroot</a> is
  228. hosted on <a class="ulink" href="http://webchat.freenode.net" target="_top">Freenode</a>. It is a useful place to
  229. ask quick questions or discuss on certain topics.</p><p class="simpara">When asking for help on IRC, share relevant logs or pieces of code
  230. using a code sharing website, such as <a class="ulink" href="http://code.bulix.org" target="_top">http://code.bulix.org</a>.</p><p class="simpara">Note that for certain questions, posting to the mailing list may be
  231. better as it will reach more people, both developers and users.</p></dd><dt><span class="term">
  232. Bug tracker
  233. </span></dt><dd>Bugs in Buildroot can be reported via the mailing list or alternatively
  234. via the <a class="ulink" href="https://bugs.buildroot.org/buglist.cgi?product=buildroot" target="_top">Buildroot
  235. bugtracker</a>. Please refer to <a class="xref" href="#reporting-bugs" title="22.6. Reporting issues/bugs or getting help">Section 22.6, “Reporting issues/bugs or getting help”</a> before creating a bug
  236. report.</dd><dt><span class="term">
  237. Wiki
  238. </span></dt><dd><a class="ulink" href="http://elinux.org/Buildroot" target="_top">The Buildroot wiki page</a> is hosted on
  239. the <a class="ulink" href="http://elinux.org" target="_top">eLinux</a> wiki. It contains some useful links, an
  240. overview of past and upcoming events, and a TODO list.</dd><dt><span class="term">
  241. Patchwork
  242. </span></dt><dd><p class="simpara">Patchwork is a web-based patch tracking system designed to facilitate
  243. the contribution and management of contributions to an open-source
  244. project. Patches that have been sent to a mailing list are 'caught' by
  245. the system, and appear on a web page. Any comments posted that
  246. reference the patch are appended to the patch page too. For more
  247. information on Patchwork see
  248. <a class="ulink" href="http://jk.ozlabs.org/projects/patchwork/" target="_top">http://jk.ozlabs.org/projects/patchwork/</a>.</p><p class="simpara">Buildroot’s Patchwork website is mainly for use by Buildroot’s
  249. maintainer to ensure patches aren’t missed. It is also used by Buildroot
  250. patch reviewers (see also <a class="xref" href="#apply-patches-patchwork" title="22.3.1. Applying Patches from Patchwork">Section 22.3.1, “Applying Patches from Patchwork”</a>).
  251. However, since the website exposes patches and their corresponding
  252. review comments in a clean and concise web interface, it can be useful
  253. for all Buildroot developers.</p><p class="simpara">The Buildroot patch management interface is available at
  254. <a class="ulink" href="http://patchwork.buildroot.org" target="_top">http://patchwork.buildroot.org</a>.</p></dd></dl></div></div></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_user_guide"></a>Part II. User guide</h1></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="configure"></a>Chapter 6. Buildroot configuration</h2></div></div></div><p>All the configuration options in <code class="literal">make *config</code> have a help text
  255. providing details about the option.</p><p>The <code class="literal">make *config</code> commands also offer a search tool. Read the help
  256. message in the different frontend menus to know how to use it:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  257. in <span class="emphasis"><em>menuconfig</em></span>, the search tool is called by pressing <code class="literal">/</code>;
  258. </li><li class="listitem">
  259. in <span class="emphasis"><em>xconfig</em></span>, the search tool is called by pressing <code class="literal">Ctrl</code> + <code class="literal">f</code>.
  260. </li></ul></div><p>The result of the search shows the help message of the matching items.
  261. In <span class="emphasis"><em>menuconfig</em></span>, numbers in the left column provide a shortcut to the
  262. corresponding entry. Just type this number to directly jump to the
  263. entry, or to the containing menu in case the entry is not selectable due
  264. to a missing dependency.</p><p>Although the menu structure and the help text of the entries should be
  265. sufficiently self-explanatory, a number of topics require additional
  266. explanation that cannot easily be covered in the help text and are
  267. therefore covered in the following sections.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_cross_compilation_toolchain"></a>6.1. Cross-compilation toolchain</h2></div></div></div><p>A compilation toolchain is the set of tools that allows you to compile
  268. code for your system. It consists of a compiler (in our case, <code class="literal">gcc</code>),
  269. binary utils like assembler and linker (in our case, <code class="literal">binutils</code>) and a
  270. C standard library (for example
  271. <a class="ulink" href="http://www.gnu.org/software/libc/libc.html" target="_top">GNU Libc</a>,
  272. <a class="ulink" href="http://www.uclibc-ng.org/" target="_top">uClibc-ng</a>).</p><p>The system installed on your development station certainly already has
  273. a compilation toolchain that you can use to compile an application
  274. that runs on your system. If you’re using a PC, your compilation
  275. toolchain runs on an x86 processor and generates code for an x86
  276. processor. Under most Linux systems, the compilation toolchain uses
  277. the GNU libc (glibc) as the C standard library. This compilation
  278. toolchain is called the "host compilation toolchain". The machine on
  279. which it is running, and on which you’re working, is called the "host
  280. system" <a href="#ftn.idm363" class="footnote" id="idm363"><sup class="footnote">[3]</sup></a>.</p><p>The compilation toolchain is provided by your distribution, and
  281. Buildroot has nothing to do with it (other than using it to build a
  282. cross-compilation toolchain and other tools that are run on the
  283. development host).</p><p>As said above, the compilation toolchain that comes with your system
  284. runs on and generates code for the processor in your host system. As
  285. your embedded system has a different processor, you need a
  286. cross-compilation toolchain - a compilation toolchain that runs on
  287. your <span class="emphasis"><em>host system</em></span> but generates code for your <span class="emphasis"><em>target system</em></span> (and
  288. target processor). For example, if your host system uses x86 and your
  289. target system uses ARM, the regular compilation toolchain on your host
  290. runs on x86 and generates code for x86, while the cross-compilation
  291. toolchain runs on x86 and generates code for ARM.</p><p>Buildroot provides two solutions for the cross-compilation toolchain:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  292. The <span class="strong"><strong>internal toolchain backend</strong></span>, called <code class="literal">Buildroot toolchain</code> in
  293. the configuration interface.
  294. </li><li class="listitem">
  295. The <span class="strong"><strong>external toolchain backend</strong></span>, called <code class="literal">External toolchain</code> in
  296. the configuration interface.
  297. </li></ul></div><p>The choice between these two solutions is done using the <code class="literal">Toolchain
  298. Type</code> option in the <code class="literal">Toolchain</code> menu. Once one solution has been
  299. chosen, a number of configuration options appear, they are detailed in
  300. the following sections.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="internal-toolchain-backend"></a>6.1.1. Internal toolchain backend</h3></div></div></div><p>The <span class="emphasis"><em>internal toolchain backend</em></span> is the backend where Buildroot builds
  301. by itself a cross-compilation toolchain, before building the userspace
  302. applications and libraries for your target embedded system.</p><p>This backend supports several C libraries:
  303. <a class="ulink" href="http://www.uclibc-ng.org" target="_top">uClibc-ng</a>,
  304. <a class="ulink" href="http://www.gnu.org/software/libc/libc.html" target="_top">glibc</a> and
  305. <a class="ulink" href="http://www.musl-libc.org" target="_top">musl</a>.</p><p>Once you have selected this backend, a number of options appear. The
  306. most important ones allow to:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  307. Change the version of the Linux kernel headers used to build the
  308. toolchain. This item deserves a few explanations. In the process of
  309. building a cross-compilation toolchain, the C library is being
  310. built. This library provides the interface between userspace
  311. applications and the Linux kernel. In order to know how to "talk"
  312. to the Linux kernel, the C library needs to have access to the
  313. <span class="emphasis"><em>Linux kernel headers</em></span> (i.e. the <code class="literal">.h</code> files from the kernel), which
  314. define the interface between userspace and the kernel (system
  315. calls, data structures, etc.). Since this interface is backward
  316. compatible, the version of the Linux kernel headers used to build
  317. your toolchain do not need to match <span class="emphasis"><em>exactly</em></span> the version of the
  318. Linux kernel you intend to run on your embedded system. They only
  319. need to have a version equal or older to the version of the Linux
  320. kernel you intend to run. If you use kernel headers that are more
  321. recent than the Linux kernel you run on your embedded system, then
  322. the C library might be using interfaces that are not provided by
  323. your Linux kernel.
  324. </li><li class="listitem">
  325. Change the version of the GCC compiler, binutils and the C library.
  326. </li><li class="listitem">
  327. Select a number of toolchain options (uClibc only): whether the
  328. toolchain should have RPC support (used mainly for NFS),
  329. wide-char support, locale support (for internationalization),
  330. C++ support or thread support. Depending on which options you choose,
  331. the number of userspace applications and libraries visible in
  332. Buildroot menus will change: many applications and libraries require
  333. certain toolchain options to be enabled. Most packages show a comment
  334. when a certain toolchain option is required to be able to enable
  335. those packages. If needed, you can further refine the uClibc
  336. configuration by running <code class="literal">make uclibc-menuconfig</code>. Note however that
  337. all packages in Buildroot are tested against the default uClibc
  338. configuration bundled in Buildroot: if you deviate from this
  339. configuration by removing features from uClibc, some packages may no
  340. longer build.
  341. </li></ul></div><p>It is worth noting that whenever one of those options is modified,
  342. then the entire toolchain and system must be rebuilt. See
  343. <a class="xref" href="#full-rebuild" title="8.2. Understanding when a full rebuild is necessary">Section 8.2, “Understanding when a full rebuild is necessary”</a>.</p><p>Advantages of this backend:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  344. Well integrated with Buildroot
  345. </li><li class="listitem">
  346. Fast, only builds what’s necessary
  347. </li></ul></div><p>Drawbacks of this backend:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  348. Rebuilding the toolchain is needed when doing <code class="literal">make clean</code>, which
  349. takes time. If you’re trying to reduce your build time, consider
  350. using the <span class="emphasis"><em>External toolchain backend</em></span>.
  351. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="external-toolchain-backend"></a>6.1.2. External toolchain backend</h3></div></div></div><p>The <span class="emphasis"><em>external toolchain backend</em></span> allows to use existing pre-built
  352. cross-compilation toolchains. Buildroot knows about a number of
  353. well-known cross-compilation toolchains (from
  354. <a class="ulink" href="http://www.linaro.org" target="_top">Linaro</a> for ARM,
  355. <a class="ulink" href="http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/" target="_top">Sourcery
  356. CodeBench</a> for ARM, x86-64, PowerPC, and MIPS, and is capable of
  357. downloading them automatically, or it can be pointed to a custom
  358. toolchain, either available for download or installed locally.</p><p>Then, you have three solutions to use an external toolchain:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  359. Use a predefined external toolchain profile, and let Buildroot
  360. download, extract and install the toolchain. Buildroot already knows
  361. about a few CodeSourcery and Linaro toolchains. Just select the
  362. toolchain profile in <code class="literal">Toolchain</code> from the available ones. This is
  363. definitely the easiest solution.
  364. </li><li class="listitem">
  365. Use a predefined external toolchain profile, but instead of having
  366. Buildroot download and extract the toolchain, you can tell Buildroot
  367. where your toolchain is already installed on your system. Just
  368. select the toolchain profile in <code class="literal">Toolchain</code> through the available
  369. ones, unselect <code class="literal">Download toolchain automatically</code>, and fill the
  370. <code class="literal">Toolchain path</code> text entry with the path to your cross-compiling
  371. toolchain.
  372. </li><li class="listitem">
  373. Use a completely custom external toolchain. This is particularly
  374. useful for toolchains generated using crosstool-NG or with Buildroot
  375. itself. To do this, select the <code class="literal">Custom toolchain</code> solution in the
  376. <code class="literal">Toolchain</code> list. You need to fill the <code class="literal">Toolchain path</code>, <code class="literal">Toolchain
  377. prefix</code> and <code class="literal">External toolchain C library</code> options. Then, you have
  378. to tell Buildroot what your external toolchain supports. If your
  379. external toolchain uses the <span class="emphasis"><em>glibc</em></span> library, you only have to tell
  380. whether your toolchain supports C++ or not and whether it has
  381. built-in RPC support. If your external toolchain uses the <span class="emphasis"><em>uClibc</em></span>
  382. library, then you have to tell Buildroot if it supports RPC,
  383. wide-char, locale, program invocation, threads and C++.
  384. At the beginning of the execution, Buildroot will tell you if
  385. the selected options do not match the toolchain configuration.
  386. </li></ul></div><p>Our external toolchain support has been tested with toolchains from
  387. CodeSourcery and Linaro, toolchains generated by
  388. <a class="ulink" href="http://crosstool-ng.org" target="_top">crosstool-NG</a>, and toolchains generated by
  389. Buildroot itself. In general, all toolchains that support the
  390. <span class="emphasis"><em>sysroot</em></span> feature should work. If not, do not hesitate to contact the
  391. developers.</p><p>We do not support toolchains or SDK generated by OpenEmbedded or
  392. Yocto, because these toolchains are not pure toolchains (i.e. just the
  393. compiler, binutils, the C and C++ libraries). Instead these toolchains
  394. come with a very large set of pre-compiled libraries and
  395. programs. Therefore, Buildroot cannot import the <span class="emphasis"><em>sysroot</em></span> of the
  396. toolchain, as it would contain hundreds of megabytes of pre-compiled
  397. libraries that are normally built by Buildroot.</p><p>We also do not support using the distribution toolchain (i.e. the
  398. gcc/binutils/C library installed by your distribution) as the
  399. toolchain to build software for the target. This is because your
  400. distribution toolchain is not a "pure" toolchain (i.e. only with the
  401. C/C++ library), so we cannot import it properly into the Buildroot
  402. build environment. So even if you are building a system for a x86 or
  403. x86_64 target, you have to generate a cross-compilation toolchain with
  404. Buildroot or crosstool-NG.</p><p>If you want to generate a custom toolchain for your project, that can
  405. be used as an external toolchain in Buildroot, our recommendation is
  406. to build it either with Buildroot itself (see
  407. <a class="xref" href="#build-toolchain-with-buildroot" title="6.1.3. Build an external toolchain with Buildroot">Section 6.1.3, “Build an external toolchain with Buildroot”</a>) or with
  408. <a class="ulink" href="http://crosstool-ng.org" target="_top">crosstool-NG</a>.</p><p>Advantages of this backend:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  409. Allows to use well-known and well-tested cross-compilation
  410. toolchains.
  411. </li><li class="listitem">
  412. Avoids the build time of the cross-compilation toolchain, which is
  413. often very significant in the overall build time of an embedded
  414. Linux system.
  415. </li></ul></div><p>Drawbacks of this backend:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  416. If your pre-built external toolchain has a bug, may be hard to get a
  417. fix from the toolchain vendor, unless you build your external
  418. toolchain by yourself using Buildroot or Crosstool-NG.
  419. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="build-toolchain-with-buildroot"></a>6.1.3. Build an external toolchain with Buildroot</h3></div></div></div><p>The Buildroot internal toolchain option can be used to create an
  420. external toolchain. Here are a series of steps to build an internal
  421. toolchain and package it up for reuse by Buildroot itself (or other
  422. projects).</p><p>Create a new Buildroot configuration, with the following details:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  423. Select the appropriate <span class="strong"><strong>Target options</strong></span> for your target CPU
  424. architecture
  425. </li><li class="listitem">
  426. In the <span class="strong"><strong>Toolchain</strong></span> menu, keep the default of <span class="strong"><strong>Buildroot toolchain</strong></span>
  427. for <span class="strong"><strong>Toolchain type</strong></span>, and configure your toolchain as desired
  428. </li><li class="listitem">
  429. In the <span class="strong"><strong>System configuration</strong></span> menu, select <span class="strong"><strong>None</strong></span> as the <span class="strong"><strong>Init
  430. system</strong></span> and <span class="strong"><strong>none</strong></span> as <span class="strong"><strong>/bin/sh</strong></span>
  431. </li><li class="listitem">
  432. In the <span class="strong"><strong>Target packages</strong></span> menu, disable <span class="strong"><strong>BusyBox</strong></span>
  433. </li><li class="listitem">
  434. In the <span class="strong"><strong>Filesystem images</strong></span> menu, disable <span class="strong"><strong>tar the root filesystem</strong></span>
  435. </li></ul></div><p>Then, we can trigger the build, and also ask Buildroot to generate a
  436. SDK. This will conveniently generate for us a tarball which contains
  437. our toolchain:</p><pre class="screen">make sdk</pre><p>This produces the SDK tarball in <code class="literal">$(O)/images</code>, with a name similar to
  438. <code class="literal">arm-buildroot-linux-uclibcgnueabi_sdk-buildroot.tar.gz</code>. Save this
  439. tarball, as it is now the toolchain that you can re-use as an external
  440. toolchain in other Buildroot projects.</p><p>In those other Buildroot projects, in the <span class="strong"><strong>Toolchain</strong></span> menu:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  441. Set <span class="strong"><strong>Toolchain type</strong></span> to <span class="strong"><strong>External toolchain</strong></span>
  442. </li><li class="listitem">
  443. Set <span class="strong"><strong>Toolchain</strong></span> to <span class="strong"><strong>Custom toolchain</strong></span>
  444. </li><li class="listitem">
  445. Set <span class="strong"><strong>Toolchain origin</strong></span> to <span class="strong"><strong>Toolchain to be downloaded and installed</strong></span>
  446. </li><li class="listitem">
  447. Set <span class="strong"><strong>Toolchain URL</strong></span> to <code class="literal">file:///path/to/your/sdk/tarball.tar.gz</code>
  448. </li></ul></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_external_toolchain_wrapper"></a>External toolchain wrapper</h4></div></div></div><p>When using an external toolchain, Buildroot generates a wrapper program,
  449. that transparently passes the appropriate options (according to the
  450. configuration) to the external toolchain programs. In case you need to
  451. debug this wrapper to check exactly what arguments are passed, you can
  452. set the environment variable <code class="literal">BR2_DEBUG_WRAPPER</code> to either one of:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  453. <code class="literal">0</code>, empty or not set: no debug
  454. </li><li class="listitem">
  455. <code class="literal">1</code>: trace all arguments on a single line
  456. </li><li class="listitem">
  457. <code class="literal">2</code>: trace one argument per line
  458. </li></ul></div></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_dev_management"></a>6.2. /dev management</h2></div></div></div><p>On a Linux system, the <code class="literal">/dev</code> directory contains special files, called
  459. <span class="emphasis"><em>device files</em></span>, that allow userspace applications to access the
  460. hardware devices managed by the Linux kernel. Without these <span class="emphasis"><em>device
  461. files</em></span>, your userspace applications would not be able to use the
  462. hardware devices, even if they are properly recognized by the Linux
  463. kernel.</p><p>Under <code class="literal">System configuration</code>, <code class="literal">/dev management</code>, Buildroot offers four
  464. different solutions to handle the <code class="literal">/dev</code> directory :</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  465. The first solution is <span class="strong"><strong>Static using device table</strong></span>. This is the old
  466. classical way of handling device files in Linux. With this method,
  467. the device files are persistently stored in the root filesystem
  468. (i.e. they persist across reboots), and there is nothing that will
  469. automatically create and remove those device files when hardware
  470. devices are added or removed from the system. Buildroot therefore
  471. creates a standard set of device files using a <span class="emphasis"><em>device table</em></span>, the
  472. default one being stored in <code class="literal">system/device_table_dev.txt</code> in the
  473. Buildroot source code. This file is processed when Buildroot
  474. generates the final root filesystem image, and the <span class="emphasis"><em>device files</em></span>
  475. are therefore not visible in the <code class="literal">output/target</code> directory. The
  476. <code class="literal">BR2_ROOTFS_STATIC_DEVICE_TABLE</code> option allows to change the
  477. default device table used by Buildroot, or to add an additional
  478. device table, so that additional <span class="emphasis"><em>device files</em></span> are created by
  479. Buildroot during the build. So, if you use this method, and a
  480. <span class="emphasis"><em>device file</em></span> is missing in your system, you can for example create
  481. a <code class="literal">board/&lt;yourcompany&gt;/&lt;yourproject&gt;/device_table_dev.txt</code> file
  482. that contains the description of your additional <span class="emphasis"><em>device files</em></span>,
  483. and then you can set <code class="literal">BR2_ROOTFS_STATIC_DEVICE_TABLE</code> to
  484. <code class="literal">system/device_table_dev.txt
  485. board/&lt;yourcompany&gt;/&lt;yourproject&gt;/device_table_dev.txt</code>. For more
  486. details about the format of the device table file, see
  487. <a class="xref" href="#makedev-syntax" title="Chapter 25. Makedev syntax documentation">Chapter 25, <em>Makedev syntax documentation</em></a>.
  488. </li><li class="listitem">
  489. The second solution is <span class="strong"><strong>Dynamic using devtmpfs only</strong></span>. <span class="emphasis"><em>devtmpfs</em></span> is
  490. a virtual filesystem inside the Linux kernel that has been
  491. introduced in kernel 2.6.32 (if you use an older kernel, it is not
  492. possible to use this option). When mounted in <code class="literal">/dev</code>, this virtual
  493. filesystem will automatically make <span class="emphasis"><em>device files</em></span> appear and
  494. disappear as hardware devices are added and removed from the
  495. system. This filesystem is not persistent across reboots: it is
  496. filled dynamically by the kernel. Using <span class="emphasis"><em>devtmpfs</em></span> requires the
  497. following kernel configuration options to be enabled:
  498. <code class="literal">CONFIG_DEVTMPFS</code> and <code class="literal">CONFIG_DEVTMPFS_MOUNT</code>. When Buildroot is in
  499. charge of building the Linux kernel for your embedded device, it
  500. makes sure that those two options are enabled. However, if you
  501. build your Linux kernel outside of Buildroot, then it is your
  502. responsibility to enable those two options (if you fail to do so,
  503. your Buildroot system will not boot).
  504. </li><li class="listitem">
  505. The third solution is <span class="strong"><strong>Dynamic using devtmpfs + mdev</strong></span>. This method
  506. also relies on the <span class="emphasis"><em>devtmpfs</em></span> virtual filesystem detailed above (so
  507. the requirement to have <code class="literal">CONFIG_DEVTMPFS</code> and
  508. <code class="literal">CONFIG_DEVTMPFS_MOUNT</code> enabled in the kernel configuration still
  509. apply), but adds the <code class="literal">mdev</code> userspace utility on top of it. <code class="literal">mdev</code>
  510. is a program part of BusyBox that the kernel will call every time a
  511. device is added or removed. Thanks to the <code class="literal">/etc/mdev.conf</code>
  512. configuration file, <code class="literal">mdev</code> can be configured to for example, set
  513. specific permissions or ownership on a device file, call a script
  514. or application whenever a device appears or disappear,
  515. etc. Basically, it allows <span class="emphasis"><em>userspace</em></span> to react on device addition
  516. and removal events. <code class="literal">mdev</code> can for example be used to automatically
  517. load kernel modules when devices appear on the system. <code class="literal">mdev</code> is
  518. also important if you have devices that require a firmware, as it
  519. will be responsible for pushing the firmware contents to the
  520. kernel. <code class="literal">mdev</code> is a lightweight implementation (with fewer
  521. features) of <code class="literal">udev</code>. For more details about <code class="literal">mdev</code> and the syntax
  522. of its configuration file, see
  523. <a class="ulink" href="http://git.busybox.net/busybox/tree/docs/mdev.txt" target="_top">http://git.busybox.net/busybox/tree/docs/mdev.txt</a>.
  524. </li><li class="listitem">
  525. The fourth solution is <span class="strong"><strong>Dynamic using devtmpfs + eudev</strong></span>. This
  526. method also relies on the <span class="emphasis"><em>devtmpfs</em></span> virtual filesystem detailed
  527. above, but adds the <code class="literal">eudev</code> userspace daemon on top of it. <code class="literal">eudev</code>
  528. is a daemon that runs in the background, and gets called by the
  529. kernel when a device gets added or removed from the system. It is a
  530. more heavyweight solution than <code class="literal">mdev</code>, but provides higher
  531. flexibility. <code class="literal">eudev</code> is a standalone version of <code class="literal">udev</code>, the
  532. original userspace daemon used in most desktop Linux distributions,
  533. which is now part of Systemd. For more details, see
  534. <a class="ulink" href="http://en.wikipedia.org/wiki/Udev" target="_top">http://en.wikipedia.org/wiki/Udev</a>.
  535. </li></ul></div><p>The Buildroot developers recommendation is to start with the <span class="strong"><strong>Dynamic
  536. using devtmpfs only</strong></span> solution, until you have the need for userspace
  537. to be notified when devices are added/removed, or if firmwares are
  538. needed, in which case <span class="strong"><strong>Dynamic using devtmpfs + mdev</strong></span> is usually a
  539. good solution.</p><p>Note that if <code class="literal">systemd</code> is chosen as init system, /dev management will
  540. be performed by the <code class="literal">udev</code> program provided by <code class="literal">systemd</code>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_init_system"></a>6.3. init system</h2></div></div></div><p>The <span class="emphasis"><em>init</em></span> program is the first userspace program started by the
  541. kernel (it carries the PID number 1), and is responsible for starting
  542. the userspace services and programs (for example: web server,
  543. graphical applications, other network servers, etc.).</p><p>Buildroot allows to use three different types of init systems, which
  544. can be chosen from <code class="literal">System configuration</code>, <code class="literal">Init system</code>:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  545. The first solution is <span class="strong"><strong>BusyBox</strong></span>. Amongst many programs, BusyBox has
  546. an implementation of a basic <code class="literal">init</code> program, which is sufficient
  547. for most embedded systems. Enabling the <code class="literal">BR2_INIT_BUSYBOX</code> will
  548. ensure BusyBox will build and install its <code class="literal">init</code> program. This is
  549. the default solution in Buildroot. The BusyBox <code class="literal">init</code> program will
  550. read the <code class="literal">/etc/inittab</code> file at boot to know what to do. The syntax
  551. of this file can be found in
  552. <a class="ulink" href="http://git.busybox.net/busybox/tree/examples/inittab" target="_top">http://git.busybox.net/busybox/tree/examples/inittab</a> (note that
  553. BusyBox <code class="literal">inittab</code> syntax is special: do not use a random <code class="literal">inittab</code>
  554. documentation from the Internet to learn about BusyBox
  555. <code class="literal">inittab</code>). The default <code class="literal">inittab</code> in Buildroot is stored in
  556. <code class="literal">system/skeleton/etc/inittab</code>. Apart from mounting a few important
  557. filesystems, the main job the default inittab does is to start the
  558. <code class="literal">/etc/init.d/rcS</code> shell script, and start a <code class="literal">getty</code> program (which
  559. provides a login prompt).
  560. </li><li class="listitem">
  561. The second solution is <span class="strong"><strong>systemV</strong></span>. This solution uses the old
  562. traditional <span class="emphasis"><em>sysvinit</em></span> program, packed in Buildroot in
  563. <code class="literal">package/sysvinit</code>. This was the solution used in most desktop
  564. Linux distributions, until they switched to more recent
  565. alternatives such as Upstart or Systemd. <code class="literal">sysvinit</code> also works with
  566. an <code class="literal">inittab</code> file (which has a slightly different syntax than the
  567. one from BusyBox). The default <code class="literal">inittab</code> installed with this init
  568. solution is located in <code class="literal">package/sysvinit/inittab</code>.
  569. </li><li class="listitem">
  570. The third solution is <span class="strong"><strong>systemd</strong></span>. <code class="literal">systemd</code> is the new generation
  571. init system for Linux. It does far more than traditional <span class="emphasis"><em>init</em></span>
  572. programs: aggressive parallelization capabilities, uses socket and
  573. D-Bus activation for starting services, offers on-demand starting
  574. of daemons, keeps track of processes using Linux control groups,
  575. supports snapshotting and restoring of the system state,
  576. etc. <code class="literal">systemd</code> will be useful on relatively complex embedded
  577. systems, for example the ones requiring D-Bus and services
  578. communicating between each other. It is worth noting that <code class="literal">systemd</code>
  579. brings a fairly big number of large dependencies: <code class="literal">dbus</code>, <code class="literal">udev</code>
  580. and more. For more details about <code class="literal">systemd</code>, see
  581. <a class="ulink" href="http://www.freedesktop.org/wiki/Software/systemd" target="_top">http://www.freedesktop.org/wiki/Software/systemd</a>.
  582. </li></ul></div><p>The solution recommended by Buildroot developers is to use the
  583. <span class="strong"><strong>BusyBox init</strong></span> as it is sufficient for most embedded
  584. systems. <span class="strong"><strong>systemd</strong></span> can be used for more complex situations.</p></div><div class="footnotes"><br /><hr style="width:100; text-align:left;margin-left: 0" /><div id="ftn.idm363" class="footnote"><p><a href="#idm363" class="simpara"><sup class="simpara">[3] </sup></a>This terminology differs from what is used by GNU
  585. configure, where the host is the machine on which the application will
  586. run (which is usually the same as target)</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_configuration_of_other_components"></a>Chapter 7. Configuration of other components</h2></div></div></div><p>Before attempting to modify any of the components below, make sure you
  587. have already configured Buildroot itself, and have enabled the
  588. corresponding package.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  589. BusyBox
  590. </span></dt><dd><p class="simpara">If you already have a BusyBox configuration file, you can directly
  591. specify this file in the Buildroot configuration, using
  592. <code class="literal">BR2_PACKAGE_BUSYBOX_CONFIG</code>. Otherwise, Buildroot will start from a
  593. default BusyBox configuration file.</p><p class="simpara">To make subsequent changes to the configuration, use <code class="literal">make
  594. busybox-menuconfig</code> to open the BusyBox configuration editor.</p><p class="simpara">It is also possible to specify a BusyBox configuration file through an
  595. environment variable, although this is not recommended. Refer to
  596. <a class="xref" href="#env-vars" title="8.6. Environment variables">Section 8.6, “Environment variables”</a> for more details.</p></dd><dt><span class="term">
  597. uClibc
  598. </span></dt><dd>Configuration of uClibc is done in the same way as for BusyBox. The
  599. configuration variable to specify an existing configuration file is
  600. <code class="literal">BR2_UCLIBC_CONFIG</code>. The command to make subsequent changes is <code class="literal">make
  601. uclibc-menuconfig</code>.</dd><dt><span class="term">
  602. Linux kernel
  603. </span></dt><dd><p class="simpara">If you already have a kernel configuration file, you can directly
  604. specify this file in the Buildroot configuration, using
  605. <code class="literal">BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG</code>.</p><p class="simpara">If you do not yet have a kernel configuration file, you can either start
  606. by specifying a defconfig in the Buildroot configuration, using
  607. <code class="literal">BR2_LINUX_KERNEL_USE_DEFCONFIG</code>, or start by creating an empty file and
  608. specifying it as custom configuration file, using
  609. <code class="literal">BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG</code>.</p><p class="simpara">To make subsequent changes to the configuration, use <code class="literal">make
  610. linux-menuconfig</code> to open the Linux configuration editor.</p></dd><dt><span class="term">
  611. Barebox
  612. </span></dt><dd>Configuration of Barebox is done in the same way as for the Linux
  613. kernel. The corresponding configuration variables are
  614. <code class="literal">BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG</code> and
  615. <code class="literal">BR2_TARGET_BAREBOX_USE_DEFCONFIG</code>. To open the configuration editor,
  616. use <code class="literal">make barebox-menuconfig</code>.</dd><dt><span class="term">
  617. U-Boot
  618. </span></dt><dd>Configuration of U-Boot (version 2015.04 or newer) is done in the same
  619. way as for the Linux kernel. The corresponding configuration variables
  620. are <code class="literal">BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG</code> and
  621. <code class="literal">BR2_TARGET_UBOOT_USE_DEFCONFIG</code>. To open the configuration editor,
  622. use <code class="literal">make uboot-menuconfig</code>.</dd></dl></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_general_buildroot_usage"></a>Chapter 8. General Buildroot usage</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="make-tips"></a>8.1. <span class="emphasis"><em>make</em></span> tips</h2></div></div></div><p>This is a collection of tips that help you make the most of Buildroot.</p><p><strong>Display all commands executed by make: </strong>
  623. </p><pre class="screen"> $ make V=1 &lt;target&gt;</pre><p>
  624. </p><p><strong>Display the list of boards with a defconfig: </strong>
  625. </p><pre class="screen"> $ make list-defconfigs</pre><p>
  626. </p><p><strong>Display all available targets: </strong>
  627. </p><pre class="screen"> $ make help</pre><p>
  628. </p><p>Not all targets are always available,
  629. some settings in the <code class="literal">.config</code> file may hide some targets:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  630. <code class="literal">busybox-menuconfig</code> only works when <code class="literal">busybox</code> is enabled;
  631. </li><li class="listitem">
  632. <code class="literal">linux-menuconfig</code> and <code class="literal">linux-savedefconfig</code> only work when
  633. <code class="literal">linux</code> is enabled;
  634. </li><li class="listitem">
  635. <code class="literal">uclibc-menuconfig</code> is only available when the uClibc C library is
  636. selected in the internal toolchain backend;
  637. </li><li class="listitem">
  638. <code class="literal">barebox-menuconfig</code> and <code class="literal">barebox-savedefconfig</code> only work when the
  639. <code class="literal">barebox</code> bootloader is enabled.
  640. </li><li class="listitem">
  641. <code class="literal">uboot-menuconfig</code> and <code class="literal">uboot-savedefconfig</code> only work when the
  642. <code class="literal">U-Boot</code> bootloader is enabled.
  643. </li></ul></div><p><strong>Cleaning: </strong>Explicit cleaning is required when any of the architecture or toolchain
  644. configuration options are changed.</p><p>To delete all build products (including build directories, host, staging
  645. and target trees, the images and the toolchain):</p><pre class="screen"> $ make clean</pre><p><strong>Generating the manual: </strong>The present manual sources are located in the <span class="emphasis"><em>docs/manual</em></span> directory.
  646. To generate the manual:</p><pre class="screen"> $ make manual-clean
  647. $ make manual</pre><p>The manual outputs will be generated in <span class="emphasis"><em>output/docs/manual</em></span>.</p><div class="itemizedlist"><p class="title"><strong>Notes</strong></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  648. A few tools are required to build the documentation (see:
  649. <a class="xref" href="#requirement-optional" title="2.2. Optional packages">Section 2.2, “Optional packages”</a>).
  650. </li></ul></div><p><strong>Resetting Buildroot for a new target: </strong>To delete all build products as well as the configuration:</p><pre class="screen"> $ make distclean</pre><p><strong>Notes. </strong>If <code class="literal">ccache</code> is enabled, running <code class="literal">make clean</code> or <code class="literal">distclean</code> does
  651. not empty the compiler cache used by Buildroot. To delete it, refer
  652. to <a class="xref" href="#ccache" title="8.14.3. Using ccache in Buildroot">Section 8.14.3, “Using <code class="literal">ccache</code> in Buildroot”</a>.</p><p><strong>Dumping the internal make variables: </strong>One can dump the variables known to make, along with their values:</p><pre class="screen"> $ make -s printvars VARS='VARIABLE1 VARIABLE2'
  653. VARIABLE1=value_of_variable
  654. VARIABLE2=value_of_variable</pre><p>It is possible to tweak the output using some variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  655. <code class="literal">VARS</code> will limit the listing to variables which names match the
  656. specified make-patterns - this must be set else nothing is printed
  657. </li><li class="listitem">
  658. <code class="literal">QUOTED_VARS</code>, if set to <code class="literal">YES</code>, will single-quote the value
  659. </li><li class="listitem">
  660. <code class="literal">RAW_VARS</code>, if set to <code class="literal">YES</code>, will print the unexpanded value
  661. </li></ul></div><p>For example:</p><pre class="screen"> $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES
  662. BUSYBOX_DEPENDENCIES=skeleton toolchain
  663. BUSYBOX_FINAL_ALL_DEPENDENCIES=skeleton toolchain
  664. BUSYBOX_FINAL_DEPENDENCIES=skeleton toolchain
  665. BUSYBOX_FINAL_PATCH_DEPENDENCIES=
  666. BUSYBOX_RDEPENDENCIES=ncurses util-linux</pre><pre class="screen"> $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES QUOTED_VARS=YES
  667. BUSYBOX_DEPENDENCIES='skeleton toolchain'
  668. BUSYBOX_FINAL_ALL_DEPENDENCIES='skeleton toolchain'
  669. BUSYBOX_FINAL_DEPENDENCIES='skeleton toolchain'
  670. BUSYBOX_FINAL_PATCH_DEPENDENCIES=''
  671. BUSYBOX_RDEPENDENCIES='ncurses util-linux'</pre><pre class="screen"> $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES RAW_VARS=YES
  672. BUSYBOX_DEPENDENCIES=skeleton toolchain
  673. BUSYBOX_FINAL_ALL_DEPENDENCIES=$(sort $(BUSYBOX_FINAL_DEPENDENCIES) $(BUSYBOX_FINAL_PATCH_DEPENDENCIES))
  674. BUSYBOX_FINAL_DEPENDENCIES=$(sort $(BUSYBOX_DEPENDENCIES))
  675. BUSYBOX_FINAL_PATCH_DEPENDENCIES=$(sort $(BUSYBOX_PATCH_DEPENDENCIES))
  676. BUSYBOX_RDEPENDENCIES=ncurses util-linux</pre><p>The output of quoted variables can be reused in shell scripts, for example:</p><pre class="screen"> $ eval $(make -s printvars VARS=BUSYBOX_DEPENDENCIES QUOTED_VARS=YES)
  677. $ echo $BUSYBOX_DEPENDENCIES
  678. skeleton toolchain</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="full-rebuild"></a>8.2. Understanding when a full rebuild is necessary</h2></div></div></div><p>Buildroot does not attempt to detect what parts of the system should
  679. be rebuilt when the system configuration is changed through <code class="literal">make
  680. menuconfig</code>, <code class="literal">make xconfig</code> or one of the other configuration
  681. tools. In some cases, Buildroot should rebuild the entire system, in
  682. some cases, only a specific subset of packages. But detecting this in
  683. a completely reliable manner is very difficult, and therefore the
  684. Buildroot developers have decided to simply not attempt to do this.</p><p>Instead, it is the responsibility of the user to know when a full
  685. rebuild is necessary. As a hint, here are a few rules of thumb that
  686. can help you understand how to work with Buildroot:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  687. When the target architecture configuration is changed, a complete
  688. rebuild is needed. Changing the architecture variant, the binary
  689. format or the floating point strategy for example has an impact on
  690. the entire system.
  691. </li><li class="listitem">
  692. When the toolchain configuration is changed, a complete rebuild
  693. generally is needed. Changing the toolchain configuration often
  694. involves changing the compiler version, the type of C library or
  695. its configuration, or some other fundamental configuration item,
  696. and these changes have an impact on the entire system.
  697. </li><li class="listitem">
  698. When an additional package is added to the configuration, a full
  699. rebuild is not necessarily needed. Buildroot will detect that this
  700. package has never been built, and will build it. However, if this
  701. package is a library that can optionally be used by packages that
  702. have already been built, Buildroot will not automatically rebuild
  703. those. Either you know which packages should be rebuilt, and you
  704. can rebuild them manually, or you should do a full rebuild. For
  705. example, let’s suppose you have built a system with the <code class="literal">ctorrent</code>
  706. package, but without <code class="literal">openssl</code>. Your system works, but you realize
  707. you would like to have SSL support in <code class="literal">ctorrent</code>, so you enable the
  708. <code class="literal">openssl</code> package in Buildroot configuration and restart the
  709. build. Buildroot will detect that <code class="literal">openssl</code> should be built and
  710. will be build it, but it will not detect that <code class="literal">ctorrent</code> should be
  711. rebuilt to benefit from <code class="literal">openssl</code> to add OpenSSL support. You will
  712. either have to do a full rebuild, or rebuild <code class="literal">ctorrent</code> itself.
  713. </li><li class="listitem">
  714. When a package is removed from the configuration, Buildroot does
  715. not do anything special. It does not remove the files installed by
  716. this package from the target root filesystem or from the toolchain
  717. <span class="emphasis"><em>sysroot</em></span>. A full rebuild is needed to get rid of this
  718. package. However, generally you don’t necessarily need this package
  719. to be removed right now: you can wait for the next lunch break to
  720. restart the build from scratch.
  721. </li><li class="listitem">
  722. When the sub-options of a package are changed, the package is not
  723. automatically rebuilt. After making such changes, rebuilding only
  724. this package is often sufficient, unless enabling the package
  725. sub-option adds some features to the package that are useful for
  726. another package which has already been built. Again, Buildroot does
  727. not track when a package should be rebuilt: once a package has been
  728. built, it is never rebuilt unless explicitly told to do so.
  729. </li><li class="listitem">
  730. When a change to the root filesystem skeleton is made, a full
  731. rebuild is needed. However, when changes to the root filesystem
  732. overlay, a post-build script or a post-image script are made,
  733. there is no need for a full rebuild: a simple <code class="literal">make</code> invocation
  734. will take the changes into account.
  735. </li><li class="listitem">
  736. When a package listed in <code class="literal">FOO_DEPENDENCIES</code> is rebuilt or removed,
  737. the package <code class="literal">foo</code> is not automatically rebuilt. For example, if a
  738. package <code class="literal">bar</code> is listed in <code class="literal">FOO_DEPENDENCIES</code> with <code class="literal">FOO_DEPENDENCIES
  739. = bar</code> and the configuration of the <code class="literal">bar</code> package is changed, the
  740. configuration change would not result in a rebuild of package <code class="literal">foo</code>
  741. automatically. In this scenario, you may need to either rebuild any
  742. packages in your build which reference <code class="literal">bar</code> in their <code class="literal">DEPENDENCIES</code>,
  743. or perform a full rebuild to ensure any <code class="literal">bar</code> dependent packages are
  744. up to date.
  745. </li></ul></div><p>Generally speaking, when you’re facing a build error and you’re unsure
  746. of the potential consequences of the configuration changes you’ve
  747. made, do a full rebuild. If you get the same build error, then you are
  748. sure that the error is not related to partial rebuilds of packages,
  749. and if this error occurs with packages from the official Buildroot, do
  750. not hesitate to report the problem! As your experience with Buildroot
  751. progresses, you will progressively learn when a full rebuild is really
  752. necessary, and you will save more and more time.</p><p>For reference, a full rebuild is achieved by running:</p><pre class="screen">$ make clean all</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="rebuild-pkg"></a>8.3. Understanding how to rebuild packages</h2></div></div></div><p>One of the most common questions asked by Buildroot users is how to
  753. rebuild a given package or how to remove a package without rebuilding
  754. everything from scratch.</p><p>Removing a package is unsupported by Buildroot without
  755. rebuilding from scratch. This is because Buildroot doesn’t keep track
  756. of which package installs what files in the <code class="literal">output/staging</code> and
  757. <code class="literal">output/target</code> directories, or which package would be compiled differently
  758. depending on the availability of another package.</p><p>The easiest way to rebuild a single package from scratch is to remove
  759. its build directory in <code class="literal">output/build</code>. Buildroot will then re-extract,
  760. re-configure, re-compile and re-install this package from scratch. You
  761. can ask buildroot to do this with the <code class="literal">make &lt;package&gt;-dirclean</code> command.</p><p>On the other hand, if you only want to restart the build process of a
  762. package from its compilation step, you can run <code class="literal">make &lt;package&gt;-rebuild</code>. It
  763. will restart the compilation and installation of the package, but not from
  764. scratch: it basically re-executes <code class="literal">make</code> and <code class="literal">make install</code> inside the package,
  765. so it will only rebuild files that changed.</p><p>If you want to restart the build process of a package from its configuration
  766. step, you can run <code class="literal">make &lt;package&gt;-reconfigure</code>. It will restart the
  767. configuration, compilation and installation of the package.</p><p>While <code class="literal">&lt;package&gt;-rebuild</code> implies <code class="literal">&lt;package&gt;-reinstall</code> and
  768. <code class="literal">&lt;package&gt;-reconfigure</code> implies <code class="literal">&lt;package&gt;-rebuild</code>, these targets as well
  769. as <code class="literal">&lt;package&gt;</code> only act on the said package, and do not trigger re-creating
  770. the root filesystem image. If re-creating the root filesystem in necessary,
  771. one should in addition run <code class="literal">make</code> or <code class="literal">make all</code>.</p><p>Internally, Buildroot creates so-called <span class="emphasis"><em>stamp files</em></span> to keep track of
  772. which build steps have been completed for each package. They are
  773. stored in the package build directory,
  774. <code class="literal">output/build/&lt;package&gt;-&lt;version&gt;/</code> and are named
  775. <code class="literal">.stamp_&lt;step-name&gt;</code>. The commands detailed above simply manipulate
  776. these stamp files to force Buildroot to restart a specific set of
  777. steps of a package build process.</p><p>Further details about package special make targets are explained in
  778. <a class="xref" href="#pkg-build-steps" title="8.14.5. Package-specific make targets">Section 8.14.5, “Package-specific <span class="emphasis"><em>make</em></span> targets”</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_offline_builds"></a>8.4. Offline builds</h2></div></div></div><p>If you intend to do an offline build and just want to download
  779. all sources that you previously selected in the configurator
  780. (<span class="emphasis"><em>menuconfig</em></span>, <span class="emphasis"><em>nconfig</em></span>, <span class="emphasis"><em>xconfig</em></span> or <span class="emphasis"><em>gconfig</em></span>), then issue:</p><pre class="screen"> $ make source</pre><p>You can now disconnect or copy the content of your <code class="literal">dl</code>
  781. directory to the build-host.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_building_out_of_tree"></a>8.5. Building out-of-tree</h2></div></div></div><p>As default, everything built by Buildroot is stored in the directory
  782. <code class="literal">output</code> in the Buildroot tree.</p><p>Buildroot also supports building out of tree with a syntax similar to
  783. the Linux kernel. To use it, add <code class="literal">O=&lt;directory&gt;</code> to the make command
  784. line:</p><pre class="screen"> $ make O=/tmp/build</pre><p>Or:</p><pre class="screen"> $ cd /tmp/build; make O=$PWD -C path/to/buildroot</pre><p>All the output files will be located under <code class="literal">/tmp/build</code>. If the <code class="literal">O</code>
  785. path does not exist, Buildroot will create it.</p><p><span class="strong"><strong>Note:</strong></span> the <code class="literal">O</code> path can be either an absolute or a relative path, but if it’s
  786. passed as a relative path, it is important to note that it is interpreted
  787. relative to the main Buildroot source directory, <span class="strong"><strong>not</strong></span> the current working
  788. directory.</p><p>When using out-of-tree builds, the Buildroot <code class="literal">.config</code> and temporary
  789. files are also stored in the output directory. This means that you can
  790. safely run multiple builds in parallel using the same source tree as
  791. long as they use unique output directories.</p><p>For ease of use, Buildroot generates a Makefile wrapper in the output
  792. directory - so after the first run, you no longer need to pass <code class="literal">O=&lt;…&gt;</code>
  793. and <code class="literal">-C &lt;…&gt;</code>, simply run (in the output directory):</p><pre class="screen"> $ make &lt;target&gt;</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="env-vars"></a>8.6. Environment variables</h2></div></div></div><p>Buildroot also honors some environment variables, when they are passed
  794. to <code class="literal">make</code> or set in the environment:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  795. <code class="literal">HOSTCXX</code>, the host C++ compiler to use
  796. </li><li class="listitem">
  797. <code class="literal">HOSTCC</code>, the host C compiler to use
  798. </li><li class="listitem">
  799. <code class="literal">UCLIBC_CONFIG_FILE=&lt;path/to/.config&gt;</code>, path to
  800. the uClibc configuration file, used to compile uClibc, if an
  801. internal toolchain is being built.
  802. Note that the uClibc configuration file can also be set from the
  803. configuration interface, so through the Buildroot <code class="literal">.config</code> file; this
  804. is the recommended way of setting it.
  805. </li><li class="listitem">
  806. <code class="literal">BUSYBOX_CONFIG_FILE=&lt;path/to/.config&gt;</code>, path to
  807. the BusyBox configuration file.
  808. Note that the BusyBox configuration file can also be set from the
  809. configuration interface, so through the Buildroot <code class="literal">.config</code> file; this
  810. is the recommended way of setting it.
  811. </li><li class="listitem">
  812. <code class="literal">BR2_CCACHE_DIR</code> to override the directory where
  813. Buildroot stores the cached files when using ccache.
  814. </li><li class="listitem">
  815. <code class="literal">BR2_DL_DIR</code> to override the directory in which
  816. Buildroot stores/retrieves downloaded files.
  817. Note that the Buildroot download directory can also be set from the
  818. configuration interface, so through the Buildroot <code class="literal">.config</code> file. See
  819. <a class="xref" href="#download-location" title="8.14.4. Location of downloaded packages">Section 8.14.4, “Location of downloaded packages”</a> for more details on how you can set the download
  820. directory.
  821. </li><li class="listitem">
  822. <code class="literal">BR2_GRAPH_ALT</code>, if set and non-empty, to use an alternate color-scheme in
  823. build-time graphs
  824. </li><li class="listitem">
  825. <code class="literal">BR2_GRAPH_OUT</code> to set the filetype of generated graphs, either <code class="literal">pdf</code> (the
  826. default), or <code class="literal">png</code>.
  827. </li><li class="listitem">
  828. <code class="literal">BR2_GRAPH_DEPS_OPTS</code> to pass extra options to the dependency graph; see
  829. <a class="xref" href="#graph-depends">Section 8.9, “Graphing the dependencies between packages”</a> for the accepted options
  830. </li><li class="listitem">
  831. <code class="literal">BR2_GRAPH_DOT_OPTS</code> is passed verbatim as options to the <code class="literal">dot</code> utility to
  832. draw the dependency graph.
  833. </li><li class="listitem">
  834. <code class="literal">BR2_GRAPH_SIZE_OPTS</code> to pass extra options to the size graph; see
  835. <a class="xref" href="#graph-size" title="8.11. Graphing the filesystem size contribution of packages">Section 8.11, “Graphing the filesystem size contribution of packages”</a> for the acepted options
  836. </li></ul></div><p>An example that uses config files located in the toplevel directory and
  837. in your $HOME:</p><pre class="screen"> $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config</pre><p>If you want to use a compiler other than the default <code class="literal">gcc</code>
  838. or <code class="literal">g</code>++ for building helper-binaries on your host, then do</p><pre class="screen"> $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_dealing_efficiently_with_filesystem_images"></a>8.7. Dealing efficiently with filesystem images</h2></div></div></div><p>Filesystem images can get pretty big, depending on the filesystem you choose,
  839. the number of packages, whether you provisioned free space… Yet, some
  840. locations in the filesystems images may just be <span class="emphasis"><em>empty</em></span> (e.g. a long run of
  841. <span class="emphasis"><em>zeroes</em></span>); such a file is called a <span class="emphasis"><em>sparse</em></span> file.</p><p>Most tools can handle sparse files efficiently, and will only store or write
  842. those parts of a sparse file that are not empty.</p><p>For example:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  843. <code class="literal">tar</code> accepts the <code class="literal">-S</code> option to tell it to only store non-zero blocks
  844. of sparse files:
  845. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  846. <code class="literal">tar cf archive.tar -S [files…]</code> will efficiently store sparse files
  847. in a tarball
  848. </li><li class="listitem">
  849. <code class="literal">tar xf archive.tar -S</code> will efficiently store sparse files extracted
  850. from a tarball
  851. </li></ul></div></li><li class="listitem"><p class="simpara">
  852. <code class="literal">cp</code> accepts the <code class="literal">--sparse=WHEN</code> option (<code class="literal">WHEN</code> is one of <code class="literal">auto</code>,
  853. <code class="literal">never</code> or <code class="literal">always</code>):
  854. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  855. <code class="literal">cp --sparse=always source.file dest.file</code> will make <code class="literal">dest.file</code> a
  856. sparse file if <code class="literal">source.file</code> has long runs of zeroes
  857. </li></ul></div></li></ul></div><p>Other tools may have similar options. Please consult their respective man
  858. pages.</p><p>You can use sparse files if you need to store the filesystem images (e.g.
  859. to transfer from one machine to another), or if you need to send them (e.g.
  860. to the Q&amp;A team).</p><p>Note however that flashing a filesystem image to a device while using the
  861. sparse mode of <code class="literal">dd</code> may result in a broken filesystem (e.g. the block bitmap
  862. of an ext2 filesystem may be corrupted; or, if you have sparse files in
  863. your filesystem, those parts may not be all-zeroes when read back). You
  864. should only use sparse files when handling files on the build machine, not
  865. when transferring them to an actual device that will be used on the target.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_details_about_packages"></a>8.8. Details about packages</h2></div></div></div><p><a id="package-details"></a>Buildroot can produce a JSON blurb that describes the set of enabled
  866. packages in the current configuration, together with their
  867. dependencies, licenses and other metadata. This JSON blurb is produced
  868. by using the <code class="literal">show-info</code> make target:</p><pre class="screen">make show-info</pre><p>Buildroot can also produce details about packages as HTML and JSON
  869. output using the <code class="literal">pkg-stats</code> make target. Amongst other things, these
  870. details include whether known CVEs (security vulnerabilities) affect
  871. the packages in your current configuration. It also shows if there is
  872. a newer upstream version for those packages.</p><pre class="screen">make pkg-stats</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_graphing_the_dependencies_between_packages"></a>8.9. Graphing the dependencies between packages</h2></div></div></div><p><a id="graph-depends"></a>One of Buildroot’s jobs is to know the dependencies between packages,
  873. and make sure they are built in the right order. These dependencies
  874. can sometimes be quite complicated, and for a given system, it is
  875. often not easy to understand why such or such package was brought into
  876. the build by Buildroot.</p><p>In order to help understanding the dependencies, and therefore better
  877. understand what is the role of the different components in your
  878. embedded Linux system, Buildroot is capable of generating dependency
  879. graphs.</p><p>To generate a dependency graph of the full system you have compiled,
  880. simply run:</p><pre class="screen">make graph-depends</pre><p>You will find the generated graph in
  881. <code class="literal">output/graphs/graph-depends.pdf</code>.</p><p>If your system is quite large, the dependency graph may be too complex
  882. and difficult to read. It is therefore possible to generate the
  883. dependency graph just for a given package:</p><pre class="screen">make &lt;pkg&gt;-graph-depends</pre><p>You will find the generated graph in
  884. <code class="literal">output/graph/&lt;pkg&gt;-graph-depends.pdf</code>.</p><p>Note that the dependency graphs are generated using the <code class="literal">dot</code> tool
  885. from the <span class="emphasis"><em>Graphviz</em></span> project, which you must have installed on your
  886. system to use this feature. In most distributions, it is available as
  887. the <code class="literal">graphviz</code> package.</p><p>By default, the dependency graphs are generated in the PDF
  888. format. However, by passing the <code class="literal">BR2_GRAPH_OUT</code> environment variable, you
  889. can switch to other output formats, such as PNG, PostScript or
  890. SVG. All formats supported by the <code class="literal">-T</code> option of the <code class="literal">dot</code> tool are
  891. supported.</p><pre class="screen">BR2_GRAPH_OUT=svg make graph-depends</pre><p>The <code class="literal">graph-depends</code> behaviour can be controlled by setting options in the
  892. <code class="literal">BR2_GRAPH_DEPS_OPTS</code> environment variable. The accepted options are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  893. <code class="literal">--depth N</code>, <code class="literal">-d N</code>, to limit the dependency depth to <code class="literal">N</code> levels. The
  894. default, <code class="literal">0</code>, means no limit.
  895. </li><li class="listitem">
  896. <code class="literal">--stop-on PKG</code>, <code class="literal">-s PKG</code>, to stop the graph on the package <code class="literal">PKG</code>.
  897. <code class="literal">PKG</code> can be an actual package name, a glob, the keyword <span class="emphasis"><em>virtual</em></span>
  898. (to stop on virtual packages), or the keyword <span class="emphasis"><em>host</em></span> (to stop on
  899. host packages). The package is still present on the graph, but its
  900. dependencies are not.
  901. </li><li class="listitem">
  902. <code class="literal">--exclude PKG</code>, <code class="literal">-x PKG</code>, like <code class="literal">--stop-on</code>, but also omits <code class="literal">PKG</code> from
  903. the graph.
  904. </li><li class="listitem">
  905. <code class="literal">--transitive</code>, <code class="literal">--no-transitive</code>, to draw (or not) the transitive
  906. dependencies. The default is to not draw transitive dependencies.
  907. </li><li class="listitem">
  908. <code class="literal">--colors R,T,H</code>, the comma-separated list of colors to draw the
  909. root package (<code class="literal">R</code>), the target packages (<code class="literal">T</code>) and the host packages
  910. (<code class="literal">H</code>). Defaults to: <code class="literal">lightblue,grey,gainsboro</code>
  911. </li></ul></div><pre class="screen">BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colors=red,green,blue' make graph-depends</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_graphing_the_build_duration"></a>8.10. Graphing the build duration</h2></div></div></div><p><a id="graph-duration"></a>When the build of a system takes a long time, it is sometimes useful
  912. to be able to understand which packages are the longest to build, to
  913. see if anything can be done to speed up the build. In order to help
  914. such build time analysis, Buildroot collects the build time of each
  915. step of each package, and allows to generate graphs from this data.</p><p>To generate the build time graph after a build, run:</p><pre class="screen">make graph-build</pre><p>This will generate a set of files in <code class="literal">output/graphs</code> :</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  916. <code class="literal">build.hist-build.pdf</code>, a histogram of the build time for each
  917. package, ordered in the build order.
  918. </li><li class="listitem">
  919. <code class="literal">build.hist-duration.pdf</code>, a histogram of the build time for each
  920. package, ordered by duration (longest first)
  921. </li><li class="listitem">
  922. <code class="literal">build.hist-name.pdf</code>, a histogram of the build time for each
  923. package, order by package name.
  924. </li><li class="listitem">
  925. <code class="literal">build.pie-packages.pdf</code>, a pie chart of the build time per package
  926. </li><li class="listitem">
  927. <code class="literal">build.pie-steps.pdf</code>, a pie chart of the global time spent in each
  928. step of the packages build process.
  929. </li></ul></div><p>This <code class="literal">graph-build</code> target requires the Python Matplotlib and Numpy
  930. libraries to be installed (<code class="literal">python-matplotlib</code> and <code class="literal">python-numpy</code> on
  931. most distributions), and also the <code class="literal">argparse</code> module if you’re using a
  932. Python version older than 2.7 (<code class="literal">python-argparse</code> on most
  933. distributions).</p><p>By default, the output format for the graph is PDF, but a different
  934. format can be selected using the <code class="literal">BR2_GRAPH_OUT</code> environment variable. The
  935. only other format supported is PNG:</p><pre class="screen">BR2_GRAPH_OUT=png make graph-build</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="graph-size"></a>8.11. Graphing the filesystem size contribution of packages</h2></div></div></div><p>When your target system grows, it is sometimes useful to understand
  936. how much each Buildroot package is contributing to the overall root
  937. filesystem size. To help with such an analysis, Buildroot collects
  938. data about files installed by each package and using this data,
  939. generates a graph and CSV files detailing the size contribution of
  940. the different packages.</p><p>To generate these data after a build, run:</p><pre class="screen">make graph-size</pre><p>This will generate:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  941. <code class="literal">output/graphs/graph-size.pdf</code>, a pie chart of the contribution of
  942. each package to the overall root filesystem size
  943. </li><li class="listitem">
  944. <code class="literal">output/graphs/package-size-stats.csv</code>, a CSV file giving the size
  945. contribution of each package to the overall root filesystem size
  946. </li><li class="listitem">
  947. <code class="literal">output/graphs/file-size-stats.csv</code>, a CSV file giving the size
  948. contribution of each installed file to the package it belongs, and
  949. to the overall filesystem size.
  950. </li></ul></div><p>This <code class="literal">graph-size</code> target requires the Python Matplotlib library to be
  951. installed (<code class="literal">python-matplotlib</code> on most distributions), and also the
  952. <code class="literal">argparse</code> module if you’re using a Python version older than 2.7
  953. (<code class="literal">python-argparse</code> on most distributions).</p><p>Just like for the duration graph, a <code class="literal">BR2_GRAPH_OUT</code> environment variable
  954. is supported to adjust the output file format. See <a class="xref" href="#graph-depends">Section 8.9, “Graphing the dependencies between packages”</a>
  955. for details about this environment variable.</p><p>Additionally, one may set the environment variable <code class="literal">BR2_GRAPH_SIZE_OPTS</code>
  956. to further control the generated graph. Accepted options are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  957. <code class="literal">--size-limit X</code>, <code class="literal">-l X</code>, will group all packages which individual
  958. contribution is below <code class="literal">X</code> percent, to a single entry labelled <span class="emphasis"><em>Others</em></span>
  959. in the graph. By default, <code class="literal">X=0.01</code>, which means packages each
  960. contributing less than 1% are grouped under <span class="emphasis"><em>Others</em></span>. Accepted values
  961. are in the range <code class="literal">[0.0..1.0]</code>.
  962. </li><li class="listitem">
  963. <code class="literal">--iec</code>, <code class="literal">--binary</code>, <code class="literal">--si</code>, <code class="literal">--decimal</code>, to use IEC (binary, powers
  964. of 1024) or SI (decimal, powers of 1000; the default) prefixes.
  965. </li><li class="listitem">
  966. <code class="literal">--biggest-first</code>, to sort packages in decreasing size order, rather
  967. than in increasing size order.
  968. </li></ul></div><p><strong>Note. </strong>The collected filesystem size data is only meaningful after a complete
  969. clean rebuild. Be sure to run <code class="literal">make clean all</code> before using <code class="literal">make
  970. graph-size</code>.</p><p>To compare the root filesystem size of two different Buildroot compilations,
  971. for example after adjusting the configuration or when switching to another
  972. Buildroot release, use the <code class="literal">size-stats-compare</code> script. It takes two
  973. <code class="literal">file-size-stats.csv</code> files (produced by <code class="literal">make graph-size</code>) as input.
  974. Refer to the help text of this script for more details:</p><pre class="screen">utils/size-stats-compare -h</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="top-level-parallel-build"></a>8.12. Top-level parallel build</h2></div></div></div><p><strong>Note. </strong>This section deals with a very experimental feature, which is known to
  975. break even in some non-unusual situations. Use at your own risk.</p><p>Buildroot has always been capable of using parallel build on a per
  976. package basis: each package is built by Buildroot using <code class="literal">make -jN</code> (or
  977. the equivalent invocation for non-make-based build systems). The level
  978. of parallelism is by default number of CPUs + 1, but it can be
  979. adjusted using the <code class="literal">BR2_JLEVEL</code> configuration option.</p><p>Until 2020.02, Buildroot was however building packages in a serial
  980. fashion: each package was built one after the other, without
  981. parallelization of the build between packages. As of 2020.02,
  982. Buildroot has experimental support for <span class="strong"><strong>top-level parallel build</strong></span>,
  983. which allows some signicant build time savings by building packages
  984. that have no dependency relationship in parallel. This feature is
  985. however marked as experimental and is known not to work in some cases.</p><p>In order to use top-level parallel build, one must:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  986. Enable the option <code class="literal">BR2_PER_PACKAGE_DIRECTORIES</code> in the Buildroot
  987. configuration
  988. </li><li class="listitem">
  989. Use <code class="literal">make -jN</code> when starting the Buildroot build
  990. </li></ol></div><p>Internally, the <code class="literal">BR2_PER_PACKAGE_DIRECTORIES</code> will enable a mechanism
  991. called <span class="strong"><strong>per-package directories</strong></span>, which will have the following
  992. effects:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  993. Instead of a global <span class="emphasis"><em>target</em></span> directory and a global <span class="emphasis"><em>host</em></span> directory
  994. common to all packages, per-package <span class="emphasis"><em>target</em></span> and <span class="emphasis"><em>host</em></span> directories
  995. will be used, in <code class="literal">$(O)/per-package/&lt;pkg&gt;/target/</code> and
  996. <code class="literal">$(O)/per-package/&lt;pkg&gt;/host/</code> respectively. Those folders will be
  997. populated from the corresponding folders of the package dependencies
  998. at the beginning of <code class="literal">&lt;pkg&gt;</code> build. The compiler and all other tools
  999. will therefore only be able to see and access files installed by
  1000. dependencies explicitly listed by <code class="literal">&lt;pkg&gt;</code>.
  1001. </li><li class="listitem">
  1002. At the end of the build, the global <span class="emphasis"><em>target</em></span> and <span class="emphasis"><em>host</em></span> directories
  1003. will be populated, located in <code class="literal">$(O)/target</code> and <code class="literal">$(O)/host</code>
  1004. respectively. This means that during the build, those folders will
  1005. be empty and it’s only at the very end of the build that they will
  1006. be populated.
  1007. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_integration_with_eclipse"></a>8.13. Integration with Eclipse</h2></div></div></div><p>While a part of the embedded Linux developers like classical text
  1008. editors like Vim or Emacs, and command-line based interfaces, a number
  1009. of other embedded Linux developers like richer graphical interfaces to
  1010. do their development work. Eclipse being one of the most popular
  1011. Integrated Development Environment, Buildroot integrates with Eclipse
  1012. in order to ease the development work of Eclipse users.</p><p>Our integration with Eclipse simplifies the compilation, remote
  1013. execution and remote debugging of applications and libraries that are
  1014. built on top of a Buildroot system. It does not integrate the
  1015. Buildroot configuration and build processes themselves with
  1016. Eclipse. Therefore, the typical usage model of our Eclipse integration
  1017. would be:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1018. Configure your Buildroot system with <code class="literal">make menuconfig</code>, <code class="literal">make
  1019. xconfig</code> or any other configuration interface provided with
  1020. Buildroot.
  1021. </li><li class="listitem">
  1022. Build your Buildroot system by running <code class="literal">make</code>.
  1023. </li><li class="listitem">
  1024. Start Eclipse to develop, execute and debug your own custom
  1025. applications and libraries, that will rely on the libraries built
  1026. and installed by Buildroot.
  1027. </li></ul></div><p>The Buildroot Eclipse integration installation process and usage is
  1028. described in detail at
  1029. <a class="ulink" href="https://github.com/mbats/eclipse-buildroot-bundle/wiki" target="_top">https://github.com/mbats/eclipse-buildroot-bundle/wiki</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_advanced_usage"></a>8.14. Advanced usage</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_using_the_generated_toolchain_outside_buildroot"></a>8.14.1. Using the generated toolchain outside Buildroot</h3></div></div></div><p>You may want to compile, for your target, your own programs or other
  1030. software that are not packaged in Buildroot. In order to do this you
  1031. can use the toolchain that was generated by Buildroot.</p><p>The toolchain generated by Buildroot is located by default in
  1032. <code class="literal">output/host/</code>. The simplest way to use it is to add
  1033. <code class="literal">output/host/bin/</code> to your PATH environment variable and then to
  1034. use <code class="literal">ARCH-linux-gcc</code>, <code class="literal">ARCH-linux-objdump</code>, <code class="literal">ARCH-linux-ld</code>, etc.</p><p>Alternatively, Buildroot can also export the toolchain and the development
  1035. files of all selected packages, as an SDK, by running the command
  1036. <code class="literal">make sdk</code>. This generates a tarball of the content of the host directory
  1037. <code class="literal">output/host/</code>, named <code class="literal">&lt;TARGET-TUPLE&gt;_sdk-buildroot.tar.gz</code> (which can be
  1038. overriden by setting the environment variable <code class="literal">BR2_SDK_PREFIX</code>) and
  1039. located in the output directory <code class="literal">output/images/</code>.</p><p>This tarball can then be distributed to application developers, when
  1040. they want to develop their applications that are not (yet) packaged as
  1041. a Buildroot package.</p><p>Upon extracting the SDK tarball, the user must run the script
  1042. <code class="literal">relocate-sdk.sh</code> (located at the top directory of the SDK), to make
  1043. sure all paths are updated with the new location.</p><p>Alternatively, if you just want to prepare the SDK without generating
  1044. the tarball (e.g. because you will just be moving the <code class="literal">host</code> directory,
  1045. or will be generating the tarball on your own), Buildroot also allows
  1046. you to just prepare the SDK with <code class="literal">make prepare-sdk</code> without actually
  1047. generating a tarball.</p><p>For your convenience, by selecting the option
  1048. <code class="literal">BR2_PACKAGE_HOST_ENVIRONMENT_SETUP</code>, you can get a
  1049. <code class="literal">setup-environment</code> script installed in <code class="literal">output/host/</code> and therefore
  1050. in your SDK. This script can be sourced with
  1051. <code class="literal">. your/sdk/path/environment-setup</code> to export a number of environment
  1052. variables that will help cross-compile your projects using the
  1053. Buildroot SDK: the <code class="literal">PATH</code> will contain the SDK binaries, standard
  1054. <span class="emphasis"><em>autotools</em></span> variables will be defined with the appropriate values, and
  1055. <code class="literal">CONFIGURE_FLAGS</code> will contain basic <code class="literal">./configure</code> options to
  1056. cross-compile <span class="emphasis"><em>autotools</em></span> projects. It also provides some useful
  1057. commands. Note however that once this script is sourced, the
  1058. environment is setup only for cross-compilation, and no longer for
  1059. native compilation.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_using_literal_gdb_literal_in_buildroot"></a>8.14.2. Using <code class="literal">gdb</code> in Buildroot</h3></div></div></div><p>Buildroot allows to do cross-debugging, where the debugger runs on the
  1060. build machine and communicates with <code class="literal">gdbserver</code> on the target to
  1061. control the execution of the program.</p><p>To achieve this:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1062. If you are using an <span class="emphasis"><em>internal toolchain</em></span> (built by Buildroot), you
  1063. must enable <code class="literal">BR2_PACKAGE_HOST_GDB</code>, <code class="literal">BR2_PACKAGE_GDB</code> and
  1064. <code class="literal">BR2_PACKAGE_GDB_SERVER</code>. This ensures that both the cross gdb and
  1065. gdbserver get built, and that gdbserver gets installed to your target.
  1066. </li><li class="listitem">
  1067. If you are using an <span class="emphasis"><em>external toolchain</em></span>, you should enable
  1068. <code class="literal">BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY</code>, which will copy the
  1069. gdbserver included with the external toolchain to the target. If your
  1070. external toolchain does not have a cross gdb or gdbserver, it is also
  1071. possible to let Buildroot build them, by enabling the same options as
  1072. for the <span class="emphasis"><em>internal toolchain backend</em></span>.
  1073. </li></ul></div><p>Now, to start debugging a program called <code class="literal">foo</code>, you should run on the
  1074. target:</p><pre class="screen">gdbserver :2345 foo</pre><p>This will cause <code class="literal">gdbserver</code> to listen on TCP port 2345 for a connection
  1075. from the cross gdb.</p><p>Then, on the host, you should start the cross gdb using the following
  1076. command line:</p><pre class="screen">&lt;buildroot&gt;/output/host/bin/&lt;tuple&gt;-gdb -x &lt;buildroot&gt;/output/staging/usr/share/buildroot/gdbinit foo</pre><p>Of course, <code class="literal">foo</code> must be available in the current directory, built
  1077. with debugging symbols. Typically you start this command from the
  1078. directory where <code class="literal">foo</code> is built (and not from <code class="literal">output/target/</code> as the
  1079. binaries in that directory are stripped).</p><p>The <code class="literal">&lt;buildroot&gt;/output/staging/usr/share/buildroot/gdbinit</code> file will tell the
  1080. cross gdb where to find the libraries of the target.</p><p>Finally, to connect to the target from the cross gdb:</p><pre class="screen">(gdb) target remote &lt;target ip address&gt;:2345</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="ccache"></a>8.14.3. Using <code class="literal">ccache</code> in Buildroot</h3></div></div></div><p><a class="ulink" href="http://ccache.samba.org" target="_top">ccache</a> is a compiler cache. It stores the
  1081. object files resulting from each compilation process, and is able to
  1082. skip future compilation of the same source file (with same compiler
  1083. and same arguments) by using the pre-existing object files. When doing
  1084. almost identical builds from scratch a number of times, it can nicely
  1085. speed up the build process.</p><p><code class="literal">ccache</code> support is integrated in Buildroot. You just have to enable
  1086. <code class="literal">Enable compiler cache</code> in <code class="literal">Build options</code>. This will automatically
  1087. build <code class="literal">ccache</code> and use it for every host and target compilation.</p><p>The cache is located in <code class="literal">$HOME/.buildroot-ccache</code>. It is stored
  1088. outside of Buildroot output directory so that it can be shared by
  1089. separate Buildroot builds. If you want to get rid of the cache, simply
  1090. remove this directory.</p><p>You can get statistics on the cache (its size, number of hits,
  1091. misses, etc.) by running <code class="literal">make ccache-stats</code>.</p><p>The make target <code class="literal">ccache-options</code> and the <code class="literal">CCACHE_OPTIONS</code> variable
  1092. provide more generic access to the ccache. For example</p><pre class="screen"># set cache limit size
  1093. make CCACHE_OPTIONS="--max-size=5G" ccache-options
  1094. # zero statistics counters
  1095. make CCACHE_OPTIONS="--zero-stats" ccache-options</pre><p><code class="literal">ccache</code> makes a hash of the source files and of the compiler options.
  1096. If a compiler option is different, the cached object file will not be
  1097. used. Many compiler options, however, contain an absolute path to the
  1098. staging directory. Because of this, building in a different output
  1099. directory would lead to many cache misses.</p><p>To avoid this issue, buildroot has the <code class="literal">Use relative paths</code> option
  1100. (<code class="literal">BR2_CCACHE_USE_BASEDIR</code>). This will rewrite all absolute paths that
  1101. point inside the output directory into relative paths. Thus, changing
  1102. the output directory no longer leads to cache misses.</p><p>A disadvantage of the relative paths is that they also end up to be
  1103. relative paths in the object file. Therefore, for example, the debugger
  1104. will no longer find the file, unless you cd to the output directory
  1105. first.</p><p>See <a class="ulink" href="https://ccache.samba.org/manual.html#_compiling_in_different_directories" target="_top">the
  1106. ccache manual’s section on "Compiling in different directories"</a> for
  1107. more details about this rewriting of absolute paths.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="download-location"></a>8.14.4. Location of downloaded packages</h3></div></div></div><p>The various tarballs that are downloaded by Buildroot are all stored
  1108. in <code class="literal">BR2_DL_DIR</code>, which by default is the <code class="literal">dl</code> directory. If you want
  1109. to keep a complete version of Buildroot which is known to be working
  1110. with the associated tarballs, you can make a copy of this directory.
  1111. This will allow you to regenerate the toolchain and the target
  1112. filesystem with exactly the same versions.</p><p>If you maintain several Buildroot trees, it might be better to have a
  1113. shared download location. This can be achieved by pointing the
  1114. <code class="literal">BR2_DL_DIR</code> environment variable to a directory. If this is
  1115. set, then the value of <code class="literal">BR2_DL_DIR</code> in the Buildroot configuration is
  1116. overridden. The following line should be added to <code class="literal">&lt;~/.bashrc&gt;</code>.</p><pre class="screen"> export BR2_DL_DIR=&lt;shared download location&gt;</pre><p>The download location can also be set in the <code class="literal">.config</code> file, with the
  1117. <code class="literal">BR2_DL_DIR</code> option. Unlike most options in the .config file, this value
  1118. is overridden by the <code class="literal">BR2_DL_DIR</code> environment variable.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="pkg-build-steps"></a>8.14.5. Package-specific <span class="emphasis"><em>make</em></span> targets</h3></div></div></div><p>Running <code class="literal">make &lt;package&gt;</code> builds and installs that particular package
  1119. and its dependencies.</p><p>For packages relying on the Buildroot infrastructure, there are
  1120. numerous special make targets that can be called independently like
  1121. this:</p><pre class="screen">make &lt;package&gt;-&lt;target&gt;</pre><p>The package build targets are (in the order they are executed):</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; " width="90%"><colgroup><col class="col_1" /><col class="col_2" /></colgroup><thead><tr><th style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"> command/target </th><th style="border-bottom: 1px solid #527bbd; " align="left" valign="top"> Description</th></tr></thead><tbody><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">source</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Fetch the source (download the tarball, clone
  1122. the source repository, etc)</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">depends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Build and install all dependencies required to
  1123. build the package</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">extract</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Put the source in the package build directory
  1124. (extract the tarball, copy the source, etc)</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">patch</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Apply the patches, if any</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">configure</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Run the configure commands, if any</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">build</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Run the compilation commands</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">install-staging</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p><span class="strong"><strong>target package:</strong></span> Run the installation of the package in the
  1125. staging directory, if necessary</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">install-target</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p><span class="strong"><strong>target package:</strong></span> Run the installation of the package in the
  1126. target directory, if necessary</p></td></tr><tr><td style="border-right: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">install</code></p></td><td style="" align="left" valign="top"><p><span class="strong"><strong>target package:</strong></span> Run the 2 previous installation commands</p>
  1127. <p><span class="strong"><strong>host package:</strong></span> Run the installation of the package in the host
  1128. directory</p></td></tr></tbody></table></div><p>Additionally, there are some other useful make targets:</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; " width="90%"><colgroup><col class="col_1" /><col class="col_2" /></colgroup><thead><tr><th style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"> command/target </th><th style="border-bottom: 1px solid #527bbd; " align="left" valign="top"> Description</th></tr></thead><tbody><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">show-depends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Displays the first-order dependencies required to build the
  1129. package</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">show-recursive-depends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Recursively displays the dependencies
  1130. required to build the package</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">show-rdepends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Displays the first-order reverse dependencies of
  1131. the package (i.e packages that directly depend on it)</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">show-recursive-rdepends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Recursively displays the reverse
  1132. dependencies of the package (i.e the packages that depend on it,
  1133. directly or indirectly)</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">graph-depends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Generate a dependency graph of the package, in the
  1134. context of the current Buildroot configuration. See
  1135. <a class="link" href="#graph-depends">this section</a> for more details about dependency
  1136. graphs.</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">graph-rdepends</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Generate a graph of this package reverse
  1137. dependencies (i.e the packages that depend on it, directly or
  1138. indirectly)</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">dirclean</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Remove the whole package build directory</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">reinstall</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Re-run the install commands</p></td></tr><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">rebuild</code></p></td><td style="border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>Re-run the compilation commands - this only makes
  1139. sense when using the <code class="literal">OVERRIDE_SRCDIR</code> feature or when you modified a file
  1140. directly in the build directory</p></td></tr><tr><td style="border-right: 1px solid #527bbd; " align="center" valign="top"><p><code class="literal">reconfigure</code></p></td><td style="" align="left" valign="top"><p>Re-run the configure commands, then rebuild - this only
  1141. makes sense when using the <code class="literal">OVERRIDE_SRCDIR</code> feature or when you modified a
  1142. file directly in the build directory</p></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_using_buildroot_during_development"></a>8.14.6. Using Buildroot during development</h3></div></div></div><p>The normal operation of Buildroot is to download a tarball, extract
  1143. it, configure, compile and install the software component found inside
  1144. this tarball. The source code is extracted in
  1145. <code class="literal">output/build/&lt;package&gt;-&lt;version&gt;</code>, which is a temporary directory:
  1146. whenever <code class="literal">make clean</code> is used, this directory is entirely removed, and
  1147. re-created at the next <code class="literal">make</code> invocation. Even when a Git or
  1148. Subversion repository is used as the input for the package source
  1149. code, Buildroot creates a tarball out of it, and then behaves as it
  1150. normally does with tarballs.</p><p>This behavior is well-suited when Buildroot is used mainly as an
  1151. integration tool, to build and integrate all the components of an
  1152. embedded Linux system. However, if one uses Buildroot during the
  1153. development of certain components of the system, this behavior is not
  1154. very convenient: one would instead like to make a small change to the
  1155. source code of one package, and be able to quickly rebuild the system
  1156. with Buildroot.</p><p>Making changes directly in <code class="literal">output/build/&lt;package&gt;-&lt;version&gt;</code> is not
  1157. an appropriate solution, because this directory is removed on <code class="literal">make
  1158. clean</code>.</p><p>Therefore, Buildroot provides a specific mechanism for this use case:
  1159. the <code class="literal">&lt;pkg&gt;_OVERRIDE_SRCDIR</code> mechanism. Buildroot reads an <span class="emphasis"><em>override</em></span>
  1160. file, which allows the user to tell Buildroot the location of the
  1161. source for certain packages.</p><p>The default location of the override file is <code class="literal">$(CONFIG_DIR)/local.mk</code>,
  1162. as defined by the <code class="literal">BR2_PACKAGE_OVERRIDE_FILE</code> configuration option.
  1163. <code class="literal">$(CONFIG_DIR)</code> is the location of the Buildroot <code class="literal">.config</code> file, so
  1164. <code class="literal">local.mk</code> by default lives side-by-side with the <code class="literal">.config</code> file,
  1165. which means:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1166. In the top-level Buildroot source directory for in-tree builds
  1167. (i.e., when <code class="literal">O=</code> is not used)
  1168. </li><li class="listitem">
  1169. In the out-of-tree directory for out-of-tree builds (i.e., when
  1170. <code class="literal">O=</code> is used)
  1171. </li></ul></div><p>If a different location than these defaults is required, it can be
  1172. specified through the <code class="literal">BR2_PACKAGE_OVERRIDE_FILE</code> configuration
  1173. option.</p><p>In this <span class="emphasis"><em>override</em></span> file, Buildroot expects to find lines of the form:</p><pre class="screen">&lt;pkg1&gt;_OVERRIDE_SRCDIR = /path/to/pkg1/sources
  1174. &lt;pkg2&gt;_OVERRIDE_SRCDIR = /path/to/pkg2/sources</pre><p>For example:</p><pre class="screen">LINUX_OVERRIDE_SRCDIR = /home/bob/linux/
  1175. BUSYBOX_OVERRIDE_SRCDIR = /home/bob/busybox/</pre><p>When Buildroot finds that for a given package, an
  1176. <code class="literal">&lt;pkg&gt;_OVERRIDE_SRCDIR</code> has been defined, it will no longer attempt to
  1177. download, extract and patch the package. Instead, it will directly use
  1178. the source code available in the specified directory and <code class="literal">make clean</code>
  1179. will not touch this directory. This allows to point Buildroot to your
  1180. own directories, that can be managed by Git, Subversion, or any other
  1181. version control system. To achieve this, Buildroot will use <span class="emphasis"><em>rsync</em></span> to
  1182. copy the source code of the component from the specified
  1183. <code class="literal">&lt;pkg&gt;_OVERRIDE_SRCDIR</code> to <code class="literal">output/build/&lt;package&gt;-custom/</code>.</p><p>This mechanism is best used in conjunction with the <code class="literal">make
  1184. &lt;pkg&gt;-rebuild</code> and <code class="literal">make &lt;pkg&gt;-reconfigure</code> targets. A <code class="literal">make
  1185. &lt;pkg&gt;-rebuild all</code> sequence will <span class="emphasis"><em>rsync</em></span> the source code from
  1186. <code class="literal">&lt;pkg&gt;_OVERRIDE_SRCDIR</code> to <code class="literal">output/build/&lt;package&gt;-custom</code> (thanks to
  1187. <span class="emphasis"><em>rsync</em></span>, only the modified files are copied), and restart the build
  1188. process of just this package.</p><p>In the example of the <code class="literal">linux</code> package above, the developer can then
  1189. make a source code change in <code class="literal">/home/bob/linux</code> and then run:</p><pre class="screen">make linux-rebuild all</pre><p>and in a matter of seconds gets the updated Linux kernel image in
  1190. <code class="literal">output/images</code>. Similarly, a change can be made to the BusyBox source
  1191. code in <code class="literal">/home/bob/busybox</code>, and after:</p><pre class="screen">make busybox-rebuild all</pre><p>the root filesystem image in <code class="literal">output/images</code> contains the updated
  1192. BusyBox.</p><p>Source trees for big projects often contain hundreds or thousands of
  1193. files which are not needed for building, but will slow down the process
  1194. of copying the sources with <span class="emphasis"><em>rsync</em></span>. Optionally, it is possible define
  1195. <code class="literal">&lt;pkg&gt;_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS</code> to skip syncing certain files
  1196. from the source tree. For example, when working on the <code class="literal">webkitgtk</code>
  1197. package, the following will exclude the tests and in-tree builds from
  1198. a local WebKit source tree:</p><pre class="screen">WEBKITGTK_OVERRIDE_SRCDIR = /home/bob/WebKit
  1199. WEBKITGTK_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = \
  1200. --exclude JSTests --exclude ManualTests --exclude PerformanceTests \
  1201. --exclude WebDriverTests --exclude WebKitBuild --exclude WebKitLibraries \
  1202. --exclude WebKit.xcworkspace --exclude Websites --exclude Examples</pre><p>By default, Buildroot skips syncing of VCS artifacts (e.g., the <span class="strong"><strong>.git</strong></span> and
  1203. <span class="strong"><strong>.svn</strong></span> directories). Some packages prefer to have these VCS directories
  1204. available during build, for example for automatically determining a precise
  1205. commit reference for version information. To undo this built-in filtering at a
  1206. cost of a slower speed, add these directories back:</p><pre class="screen">LINUX_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = --include .git</pre></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="customize"></a>Chapter 9. Project-specific customization</h2></div></div></div><p>Typical actions you may need to perform for a given project are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1207. configuring Buildroot (including build options and toolchain,
  1208. bootloader, kernel, package and filesystem image type selection)
  1209. </li><li class="listitem">
  1210. configuring other components, like the Linux kernel and BusyBox
  1211. </li><li class="listitem"><p class="simpara">
  1212. customizing the generated target filesystem
  1213. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  1214. adding or overwriting files on the target filesystem (using
  1215. <code class="literal">BR2_ROOTFS_OVERLAY</code>)
  1216. </li><li class="listitem">
  1217. modifying or deleting files on the target filesystem (using
  1218. <code class="literal">BR2_ROOTFS_POST_BUILD_SCRIPT</code>)
  1219. </li><li class="listitem">
  1220. running arbitrary commands prior to generating the filesystem image
  1221. (using <code class="literal">BR2_ROOTFS_POST_BUILD_SCRIPT</code>)
  1222. </li><li class="listitem">
  1223. setting file permissions and ownership (using
  1224. <code class="literal">BR2_ROOTFS_DEVICE_TABLE</code>)
  1225. </li><li class="listitem">
  1226. adding custom devices nodes (using
  1227. <code class="literal">BR2_ROOTFS_STATIC_DEVICE_TABLE</code>)
  1228. </li></ul></div></li><li class="listitem">
  1229. adding custom user accounts (using <code class="literal">BR2_ROOTFS_USERS_TABLES</code>)
  1230. </li><li class="listitem">
  1231. running arbitrary commands after generating the filesystem image
  1232. (using <code class="literal">BR2_ROOTFS_POST_IMAGE_SCRIPT</code>)
  1233. </li><li class="listitem">
  1234. adding project-specific patches to some packages (using
  1235. <code class="literal">BR2_GLOBAL_PATCH_DIR</code>)
  1236. </li><li class="listitem">
  1237. adding project-specific packages
  1238. </li></ul></div><p>An important note regarding such <span class="emphasis"><em>project-specific</em></span> customizations:
  1239. please carefully consider which changes are indeed project-specific and
  1240. which changes are also useful to developers outside your project. The
  1241. Buildroot community highly recommends and encourages the upstreaming of
  1242. improvements, packages and board support to the official Buildroot
  1243. project. Of course, it is sometimes not possible or desirable to
  1244. upstream because the changes are highly specific or proprietary.</p><p>This chapter describes how to make such project-specific customizations
  1245. in Buildroot and how to store them in a way that you can build the same
  1246. image in a reproducible way, even after running <span class="emphasis"><em>make clean</em></span>. By
  1247. following the recommended strategy, you can even use the same Buildroot
  1248. tree to build multiple distinct projects!</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-dir-structure"></a>9.1. Recommended directory structure</h2></div></div></div><p>When customizing Buildroot for your project, you will be creating one or
  1249. more project-specific files that need to be stored somewhere. While most
  1250. of these files could be placed in <span class="emphasis"><em>any</em></span> location as their path is to be
  1251. specified in the Buildroot configuration, the Buildroot developers
  1252. recommend a specific directory structure which is described in this
  1253. section.</p><p>Orthogonal to this directory structure, you can choose <span class="emphasis"><em>where</em></span> you place
  1254. this structure itself: either inside the Buildroot tree, or outside of
  1255. it using a br2-external tree. Both options are valid, the choice is up
  1256. to you.</p><pre class="screen">+-- board/
  1257. | +-- &lt;company&gt;/
  1258. | +-- &lt;boardname&gt;/
  1259. | +-- linux.config
  1260. | +-- busybox.config
  1261. | +-- &lt;other configuration files&gt;
  1262. | +-- post_build.sh
  1263. | +-- post_image.sh
  1264. | +-- rootfs_overlay/
  1265. | | +-- etc/
  1266. | | +-- &lt;some file&gt;
  1267. | +-- patches/
  1268. | +-- foo/
  1269. | | +-- &lt;some patch&gt;
  1270. | +-- libbar/
  1271. | +-- &lt;some other patches&gt;
  1272. |
  1273. +-- configs/
  1274. | +-- &lt;boardname&gt;_defconfig
  1275. |
  1276. +-- package/
  1277. | +-- &lt;company&gt;/
  1278. | +-- Config.in (if not using a br2-external tree)
  1279. | +-- &lt;company&gt;.mk (if not using a br2-external tree)
  1280. | +-- package1/
  1281. | | +-- Config.in
  1282. | | +-- package1.mk
  1283. | +-- package2/
  1284. | +-- Config.in
  1285. | +-- package2.mk
  1286. |
  1287. +-- Config.in (if using a br2-external tree)
  1288. +-- external.mk (if using a br2-external tree)
  1289. +-- external.desc (if using a br2-external tree)</pre><p>Details on the files shown above are given further in this chapter.</p><p>Note: if you choose to place this structure outside of the Buildroot
  1290. tree but in a br2-external tree, the &lt;company&gt; and possibly &lt;boardname&gt;
  1291. components may be superfluous and can be left out.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_implementing_layered_customizations"></a>9.1.1. Implementing layered customizations</h3></div></div></div><p>It is quite common for a user to have several related projects that partly
  1292. need the same customizations. Instead of duplicating these
  1293. customizations for each project, it is recommended to use a layered
  1294. customization approach, as explained in this section.</p><p>Almost all of the customization methods available in Buildroot, like
  1295. post-build scripts and root filesystem overlays, accept a
  1296. space-separated list of items. The specified items are always treated in
  1297. order, from left to right. By creating more than one such item, one for
  1298. the common customizations and another one for the really
  1299. project-specific customizations, you can avoid unnecessary duplication.
  1300. Each layer is typically embodied by a separate directory inside
  1301. <code class="literal">board/&lt;company&gt;/</code>. Depending on your projects, you could even introduce
  1302. more than two layers.</p><p>An example directory structure for where a user has two customization
  1303. layers <span class="emphasis"><em>common</em></span> and <span class="emphasis"><em>fooboard</em></span> is:</p><pre class="screen">+-- board/
  1304. +-- &lt;company&gt;/
  1305. +-- common/
  1306. | +-- post_build.sh
  1307. | +-- rootfs_overlay/
  1308. | | +-- ...
  1309. | +-- patches/
  1310. | +-- ...
  1311. |
  1312. +-- fooboard/
  1313. +-- linux.config
  1314. +-- busybox.config
  1315. +-- &lt;other configuration files&gt;
  1316. +-- post_build.sh
  1317. +-- rootfs_overlay/
  1318. | +-- ...
  1319. +-- patches/
  1320. +-- ...</pre><p>For example, if the user has the <code class="literal">BR2_GLOBAL_PATCH_DIR</code> configuration
  1321. option set as:</p><pre class="screen">BR2_GLOBAL_PATCH_DIR="board/&lt;company&gt;/common/patches board/&lt;company&gt;/fooboard/patches"</pre><p>then first the patches from the <span class="emphasis"><em>common</em></span> layer would be applied,
  1322. followed by the patches from the <span class="emphasis"><em>fooboard</em></span> layer.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="outside-br-custom"></a>9.2. Keeping customizations outside of Buildroot</h2></div></div></div><p>As already briefly mentioned in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, you can
  1323. place project-specific customizations in two locations:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1324. directly within the Buildroot tree, typically maintaining them using
  1325. branches in a version control system so that upgrading to a newer
  1326. Buildroot release is easy.
  1327. </li><li class="listitem">
  1328. outside of the Buildroot tree, using the <span class="emphasis"><em>br2-external</em></span> mechanism.
  1329. This mechanism allows to keep package recipes, board support and
  1330. configuration files outside of the Buildroot tree, while still
  1331. having them nicely integrated in the build logic. We call this
  1332. location a <span class="emphasis"><em>br2-external tree</em></span>. This section explains how to use
  1333. the br2-external mechanism and what to provide in a br2-external
  1334. tree.
  1335. </li></ul></div><p>One can tell Buildroot to use one or more br2-external trees by setting
  1336. the <code class="literal">BR2_EXTERNAL</code> make variable set to the path(s) of the br2-external
  1337. tree(s) to use. It can be passed to any Buildroot <code class="literal">make</code> invocation. It
  1338. is automatically saved in the hidden <code class="literal">.br2-external.mk</code> file in the output
  1339. directory. Thanks to this, there is no need to pass <code class="literal">BR2_EXTERNAL</code> at
  1340. every <code class="literal">make</code> invocation. It can however be changed at any time by
  1341. passing a new value, and can be removed by passing an empty value.</p><p><strong>Note. </strong>The path to a br2-external tree can be either absolute or relative.
  1342. If it is passed as a relative path, it is important to note that it is
  1343. interpreted relative to the main Buildroot source directory, <span class="strong"><strong>not</strong></span> to
  1344. the Buildroot output directory.</p><p><strong>Note: </strong>If using an br2-external tree from before Buildroot 2016.11, you need to
  1345. convert it before you can use it with Buildroot 2016.11 onward. See
  1346. <a class="xref" href="#br2-external-converting" title="27.1. Migrating to 2016.11">Section 27.1, “Migrating to 2016.11”</a> for help on doing so.</p><p>Some examples:</p><pre class="screen">buildroot/ $ make BR2_EXTERNAL=/path/to/foo menuconfig</pre><p>From now on, definitions from the <code class="literal">/path/to/foo</code> br2-external tree
  1347. will be used:</p><pre class="screen">buildroot/ $ make
  1348. buildroot/ $ make legal-info</pre><p>We can switch to another br2-external tree at any time:</p><pre class="screen">buildroot/ $ make BR2_EXTERNAL=/where/we/have/bar xconfig</pre><p>We can also use multiple br2-external trees:</p><pre class="screen">buildroot/ $ make BR2_EXTERNAL=/path/to/foo:/where/we/have/bar menuconfig</pre><p>Or disable the usage of any br2-external tree:</p><pre class="screen">buildroot/ $ make BR2_EXTERNAL= xconfig</pre><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_layout_of_a_br2_external_tree"></a>9.2.1. Layout of a br2-external tree</h3></div></div></div><p>A br2-external tree must contain at least those three files, described
  1349. in the following chapters:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1350. <code class="literal">external.desc</code>
  1351. </li><li class="listitem">
  1352. <code class="literal">external.mk</code>
  1353. </li><li class="listitem">
  1354. <code class="literal">Config.in</code>
  1355. </li></ul></div><p>Apart from those mandatory files, there may be additional and optional
  1356. content that may be present in a br2-external tree, like the <code class="literal">configs/</code>
  1357. or <code class="literal">provides/</code> directories. They are described in the following chapters
  1358. as well.</p><p>A complete example br2-external tree layout is also described later.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_the_literal_external_desc_literal_file"></a>The <code class="literal">external.desc</code> file</h4></div></div></div><p>That file describes the br2-external tree: the <span class="emphasis"><em>name</em></span> and <span class="emphasis"><em>description</em></span>
  1359. for that br2-external tree.</p><p>The format for this file is line based, with each line starting by a
  1360. keyword, followed by a colon and one or more spaces, followed by the
  1361. value assigned to that keyword. There are two keywords currently
  1362. recognised:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  1363. <code class="literal">name</code>, mandatory, defines the name for that br2-external tree. That
  1364. name must only use ASCII characters in the set <code class="literal">[A-Za-z0-9_]</code>; any
  1365. other character is forbidden. Buildroot sets the variable
  1366. <code class="literal">BR2_EXTERNAL_$(NAME)_PATH</code> to the absolute path of the br2-external
  1367. tree, so that you can use it to refer to your br2-external tree. This
  1368. variable is available both in Kconfig, so you can use it to source your
  1369. Kconfig files (see below) and in the Makefile, so that you can use it
  1370. to include other Makefiles (see below) or refer to other files (like
  1371. data files) from your br2-external tree.
  1372. </p><p><strong>Note: </strong>Since it is possible to use multiple br2-external trees at once, this
  1373. name is used by Buildroot to generate variables for each of those trees.
  1374. That name is used to identify your br2-external tree, so try to come up
  1375. with a name that really describes your br2-external tree, in order for
  1376. it to be relatively unique, so that it does not clash with another name
  1377. from another br2-external tree, especially if you are planning on
  1378. somehow sharing your br2-external tree with third parties or using
  1379. br2-external trees from third parties.</p></li><li class="listitem">
  1380. <code class="literal">desc</code>, optional, provides a short description for that br2-external
  1381. tree. It shall fit on a single line, is mostly free-form (see below),
  1382. and is used when displaying information about a br2-external tree (e.g.
  1383. above the list of defconfig files, or as the prompt in the menuconfig);
  1384. as such, it should relatively brief (40 chars is probably a good upper
  1385. limit). The description is available in the <code class="literal">BR2_EXTERNAL_$(NAME)_DESC</code>
  1386. variable.
  1387. </li></ul></div><p>Examples of names and the corresponding <code class="literal">BR2_EXTERNAL_$(NAME)_PATH</code>
  1388. variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1389. <code class="literal">FOO</code> → <code class="literal">BR2_EXTERNAL_FOO_PATH</code>
  1390. </li><li class="listitem">
  1391. <code class="literal">BAR_42</code> → <code class="literal">BR2_EXTERNAL_BAR_42_PATH</code>
  1392. </li></ul></div><p>In the following examples, it is assumed the name to be set to <code class="literal">BAR_42</code>.</p><p><strong>Note: </strong>Both <code class="literal">BR2_EXTERNAL_$(NAME)_PATH</code> and <code class="literal">BR2_EXTERNAL_$(NAME)_DESC</code> are
  1393. available in the Kconfig files and the Makefiles. They are also
  1394. exported in the environment so are available in post-build, post-image
  1395. and in-fakeroot scripts.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_the_literal_config_in_literal_and_literal_external_mk_literal_files"></a>The <code class="literal">Config.in</code> and <code class="literal">external.mk</code> files</h4></div></div></div><p>Those files (which may each be empty) can be used to define package
  1396. recipes (i.e. <code class="literal">foo/Config.in</code> and <code class="literal">foo/foo.mk</code> like for packages bundled
  1397. in Buildroot itself) or other custom configuration options or make logic.</p><p>Buildroot automatically includes the <code class="literal">Config.in</code> from each br2-external
  1398. tree to make it appear in the top-level configuration menu, and includes
  1399. the <code class="literal">external.mk</code> from each br2-external tree with the rest of the
  1400. makefile logic.</p><p>The main usage of this is to store package recipes. The recommended way
  1401. to do this is to write a <code class="literal">Config.in</code> file that looks like:</p><pre class="screen">source "$BR2_EXTERNAL_BAR_42_PATH/package/package1/Config.in"
  1402. source "$BR2_EXTERNAL_BAR_42_PATH/package/package2/Config.in"</pre><p>Then, have an <code class="literal">external.mk</code> file that looks like:</p><pre class="screen">include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))</pre><p>And then in <code class="literal">$(BR2_EXTERNAL_BAR_42_PATH)/package/package1</code> and
  1403. <code class="literal">$(BR2_EXTERNAL_BAR_42_PATH)/package/package2</code> create normal
  1404. Buildroot package recipes, as explained in <a class="xref" href="#adding-packages" title="Chapter 18. Adding new packages to Buildroot">Chapter 18, <em>Adding new packages to Buildroot</em></a>.
  1405. If you prefer, you can also group the packages in subdirectories
  1406. called &lt;boardname&gt; and adapt the above paths accordingly.</p><p>You can also define custom configuration options in <code class="literal">Config.in</code> and
  1407. custom make logic in <code class="literal">external.mk</code>.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_the_literal_configs_literal_directory"></a>The <code class="literal">configs/</code> directory</h4></div></div></div><p>One can store Buildroot defconfigs in the <code class="literal">configs</code> subdirectory of
  1408. the br2-external tree. Buildroot will automatically show them in the
  1409. output of <code class="literal">make list-defconfigs</code> and allow them to be loaded with the
  1410. normal <code class="literal">make &lt;name&gt;_defconfig</code> command. They will be visible in the
  1411. <span class="emphasis"><em>make list-defconfigs</em></span> output, below an <code class="literal">External configs</code> label that
  1412. contains the name of the br2-external tree they are defined in.</p><p><strong>Note: </strong>If a defconfig file is present in more than one br2-external tree, then
  1413. the one from the last br2-external tree is used. It is thus possible
  1414. to override a defconfig bundled in Buildroot or another br2-external
  1415. tree.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_the_literal_provides_literal_directory"></a>The <code class="literal">provides/</code> directory</h4></div></div></div><p>For some packages, Buildroot provides a choice between two (or more)
  1416. implementations of API-compatible such packages. For example, there is
  1417. a choice to choose either libjpeg ot jpeg-turbo; there is one between
  1418. openssl or libressl; there is one to select one of the known,
  1419. pre-configured toolchains…</p><p>It is possible for a br2-external to extend those choices, by providing
  1420. a set of files that define those alternatives:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1421. <code class="literal">provides/toolchains.in</code> defines the pre-configured toolchains, which
  1422. will then be listed in the toolchain selection;
  1423. </li><li class="listitem">
  1424. <code class="literal">provides/jpeg.in</code> defines the alternative libjpeg implementations;
  1425. </li><li class="listitem">
  1426. <code class="literal">provides/openssl.in</code> defines the alternative openssl implementations;
  1427. </li><li class="listitem">
  1428. <code class="literal">provides/skeleton.in</code> defines the alternative skeleton implementations;
  1429. </li><li class="listitem">
  1430. <code class="literal">provides/init.in</code> defines the alternative init system implementations, this
  1431. can be used to select a default skeleton for your init.
  1432. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_free_form_content"></a>Free-form content</h4></div></div></div><p>One can store all the board-specific configuration files there, such
  1433. as the kernel configuration, the root filesystem overlay, or any other
  1434. configuration file for which Buildroot allows to set the location (by
  1435. using the <code class="literal">BR2_EXTERNAL_$(NAME)_PATH</code> variable). For example, you
  1436. could set the paths to a global patch directory, to a rootfs overlay
  1437. and to the kernel configuration file as follows (e.g. by running
  1438. <code class="literal">make menuconfig</code> and filling in these options):</p><pre class="screen">BR2_GLOBAL_PATCH_DIR=$(BR2_EXTERNAL_BAR_42_PATH)/patches/
  1439. BR2_ROOTFS_OVERLAY=$(BR2_EXTERNAL_BAR_42_PATH)/board/&lt;boardname&gt;/overlay/
  1440. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=$(BR2_EXTERNAL_BAR_42_PATH)/board/&lt;boardname&gt;/kernel.config</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_additional_linux_kernel_extensions"></a>Additional Linux kernel extensions</h4></div></div></div><p>Additional Linux kernel extensions (see <a class="xref" href="#linux-kernel-ext" title="18.21.2. linux-kernel-extensions">Section 18.21.2, “linux-kernel-extensions”</a>) can
  1441. be added by storing them in the <code class="literal">linux/</code> directory at the root of a
  1442. br2-external tree.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_example_layout"></a>Example layout</h4></div></div></div><p>Here is an example layout using all features of br2-external (the sample
  1443. content is shown for the file above it, when it is relevant to explain
  1444. the br2-external tree; this is all entirely made up just for the sake of
  1445. illustration, of course):</p><pre class="screen">/path/to/br2-ext-tree/
  1446. |- external.desc
  1447. | |name: BAR_42
  1448. | |desc: Example br2-external tree
  1449. | `----
  1450. |
  1451. |- Config.in
  1452. | |source "$BR2_EXTERNAL_BAR_42_PATH/toolchain/toolchain-external-mine/Config.in.options"
  1453. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-1/Config.in"
  1454. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-2/Config.in"
  1455. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/my-jpeg/Config.in"
  1456. | |
  1457. | |config BAR_42_FLASH_ADDR
  1458. | | hex "my-board flash address"
  1459. | | default 0x10AD
  1460. | `----
  1461. |
  1462. |- external.mk
  1463. | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
  1464. | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/toolchain/*/*.mk))
  1465. | |
  1466. | |flash-my-board:
  1467. | | $(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/flash-image \
  1468. | | --image $(BINARIES_DIR)/image.bin \
  1469. | | --address $(BAR_42_FLASH_ADDR)
  1470. | `----
  1471. |
  1472. |- package/pkg-1/Config.in
  1473. | |config BR2_PACKAGE_PKG_1
  1474. | | bool "pkg-1"
  1475. | | help
  1476. | | Some help about pkg-1
  1477. | `----
  1478. |- package/pkg-1/pkg-1.hash
  1479. |- package/pkg-1/pkg-1.mk
  1480. | |PKG_1_VERSION = 1.2.3
  1481. | |PKG_1_SITE = /some/where/to/get/pkg-1
  1482. | |PKG_1_LICENSE = blabla
  1483. | |
  1484. | |define PKG_1_INSTALL_INIT_SYSV
  1485. | | $(INSTALL) -D -m 0755 $(PKG_1_PKGDIR)/S99my-daemon \
  1486. | | $(TARGET_DIR)/etc/init.d/S99my-daemon
  1487. | |endef
  1488. | |
  1489. | |$(eval $(autotools-package))
  1490. | `----
  1491. |- package/pkg-1/S99my-daemon
  1492. |
  1493. |- package/pkg-2/Config.in
  1494. |- package/pkg-2/pkg-2.hash
  1495. |- package/pkg-2/pkg-2.mk
  1496. |
  1497. |- provides/jpeg.in
  1498. | |config BR2_PACKAGE_MY_JPEG
  1499. | | bool "my-jpeg"
  1500. | `----
  1501. |- package/my-jpeg/Config.in
  1502. | |config BR2_PACKAGE_PROVIDES_JPEG
  1503. | | default "my-jpeg" if BR2_PACKAGE_MY_JPEG
  1504. | `----
  1505. |- package/my-jpeg/my-jpeg.mk
  1506. | |# This is a normal package .mk file
  1507. | |MY_JPEG_VERSION = 1.2.3
  1508. | |MY_JPEG_SITE = https://example.net/some/place
  1509. | |MY_JPEG_PROVIDES = jpeg
  1510. | |$(eval $(autotools-package))
  1511. | `----
  1512. |
  1513. |- provides/init.in
  1514. | |config BR2_INIT_MINE
  1515. | | bool "my custom init"
  1516. | | select BR2_PACKAGE_MY_INIT
  1517. | | select BR2_PACKAGE_SKELETON_INIT_MINE if BR2_ROOTFS_SKELETON_DEFAULT
  1518. | `----
  1519. |
  1520. |- provides/skeleton.in
  1521. | |config BR2_ROOTFS_SKELETON_MINE
  1522. | | bool "my custom skeleton"
  1523. | | select BR2_PACKAGE_SKELETON_MINE
  1524. | `----
  1525. |- package/skeleton-mine/Config.in
  1526. | |config BR2_PACKAGE_SKELETON_MINE
  1527. | | bool
  1528. | | select BR2_PACKAGE_HAS_SKELETON
  1529. | |
  1530. | |config BR2_PACKAGE_PROVIDES_SKELETON
  1531. | | default "skeleton-mine" if BR2_PACKAGE_SKELETON_MINE
  1532. | `----
  1533. |- package/skeleton-mine/skeleton-mine.mk
  1534. | |SKELETON_MINE_ADD_TOOLCHAIN_DEPENDENCY = NO
  1535. | |SKELETON_MINE_ADD_SKELETON_DEPENDENCY = NO
  1536. | |SKELETON_MINE_PROVIDES = skeleton
  1537. | |SKELETON_MINE_INSTALL_STAGING = YES
  1538. | |$(eval $(generic-package))
  1539. | `----
  1540. |
  1541. |- provides/toolchains.in
  1542. | |config BR2_TOOLCHAIN_EXTERNAL_MINE
  1543. | | bool "my custom toolchain"
  1544. | | depends on BR2_some_arch
  1545. | | select BR2_INSTALL_LIBSTDCPP
  1546. | `----
  1547. |- toolchain/toolchain-external-mine/Config.in.options
  1548. | |if BR2_TOOLCHAIN_EXTERNAL_MINE
  1549. | |config BR2_TOOLCHAIN_EXTERNAL_PREFIX
  1550. | | default "arch-mine-linux-gnu"
  1551. | |config BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL
  1552. | | default "toolchain-external-mine"
  1553. | |endif
  1554. | `----
  1555. |- toolchain/toolchain-external-mine/toolchain-external-mine.mk
  1556. | |TOOLCHAIN_EXTERNAL_MINE_SITE = https://example.net/some/place
  1557. | |TOOLCHAIN_EXTERNAL_MINE_SOURCE = my-toolchain.tar.gz
  1558. | |$(eval $(toolchain-external-package))
  1559. | `----
  1560. |
  1561. |- linux/Config.ext.in
  1562. | |config BR2_LINUX_KERNEL_EXT_EXAMPLE_DRIVER
  1563. | | bool "example-external-driver"
  1564. | | help
  1565. | | Example external driver
  1566. | |---
  1567. |- linux/linux-ext-example-driver.mk
  1568. |
  1569. |- configs/my-board_defconfig
  1570. | |BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_BAR_42_PATH)/patches/"
  1571. | |BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/overlay/"
  1572. | |BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/post-image.sh"
  1573. | |BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/kernel.config"
  1574. | `----
  1575. |
  1576. |- patches/linux/0001-some-change.patch
  1577. |- patches/linux/0002-some-other-change.patch
  1578. |- patches/busybox/0001-fix-something.patch
  1579. |
  1580. |- board/my-board/kernel.config
  1581. |- board/my-board/overlay/var/www/index.html
  1582. |- board/my-board/overlay/var/www/my.css
  1583. |- board/my-board/flash-image
  1584. `- board/my-board/post-image.sh
  1585. |#!/bin/sh
  1586. |generate-my-binary-image \
  1587. | --root ${BINARIES_DIR}/rootfs.tar \
  1588. | --kernel ${BINARIES_DIR}/zImage \
  1589. | --dtb ${BINARIES_DIR}/my-board.dtb \
  1590. | --output ${BINARIES_DIR}/image.bin
  1591. `----</pre><p>The br2-external tree will then be visible in the menuconfig (with
  1592. the layout expanded):</p><pre class="screen">External options ---&gt;
  1593. *** Example br2-external tree (in /path/to/br2-ext-tree/)
  1594. [ ] pkg-1
  1595. [ ] pkg-2
  1596. (0x10AD) my-board flash address</pre><p>If you are using more than one br2-external tree, it would look like
  1597. (with the layout expanded and the second one with name <code class="literal">FOO_27</code> but no
  1598. <code class="literal">desc:</code> field in <code class="literal">external.desc</code>):</p><pre class="screen">External options ---&gt;
  1599. Example br2-external tree ---&gt;
  1600. *** Example br2-external tree (in /path/to/br2-ext-tree)
  1601. [ ] pkg-1
  1602. [ ] pkg-2
  1603. (0x10AD) my-board flash address
  1604. FOO_27 ---&gt;
  1605. *** FOO_27 (in /path/to/another-br2-ext)
  1606. [ ] foo
  1607. [ ] bar</pre><p>Additionally, the jpeg provider will be visible in the jpeg choice:</p><pre class="screen">Target packages ---&gt;
  1608. Libraries ---&gt;
  1609. Graphics ---&gt;
  1610. [*] jpeg support
  1611. jpeg variant () ---&gt;
  1612. ( ) jpeg
  1613. ( ) jpeg-turbo
  1614. *** jpeg from: Example br2-external tree ***
  1615. (X) my-jpeg
  1616. *** jpeg from: FOO_27 ***
  1617. ( ) another-jpeg</pre><p>And similarly for the toolchains:</p><pre class="screen">Toolchain ---&gt;
  1618. Toolchain () ---&gt;
  1619. ( ) Custom toolchain
  1620. *** Toolchains from: Example br2-external tree ***
  1621. (X) my custom toolchain</pre><p><strong>Note. </strong>The toolchain options in <code class="literal">toolchain/toolchain-external-mine/Config.in.options</code>
  1622. will not appear in the <code class="literal">Toolchain</code> menu. They must be explicitly included
  1623. from within the br2-external’s top-level <code class="literal">Config.in</code> and will thus appear
  1624. in the <code class="literal">External options</code> menu.</p></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-store-buildroot-config"></a>9.3. Storing the Buildroot configuration</h2></div></div></div><p>The Buildroot configuration can be stored using the command
  1625. <code class="literal">make savedefconfig</code>.</p><p>This strips the Buildroot configuration down by removing configuration
  1626. options that are at their default value. The result is stored in a file
  1627. called <code class="literal">defconfig</code>. If you want to save it in another place, change the
  1628. <code class="literal">BR2_DEFCONFIG</code> option in the Buildroot configuration itself, or call
  1629. make with <code class="literal">make savedefconfig BR2_DEFCONFIG=&lt;path-to-defconfig&gt;</code>.</p><p>The recommended place to store this defconfig is
  1630. <code class="literal">configs/&lt;boardname&gt;_defconfig</code>. If you follow this recommendation, the
  1631. configuration will be listed in <code class="literal">make help</code> and can be set again by
  1632. running <code class="literal">make &lt;boardname&gt;_defconfig</code>.</p><p>Alternatively, you can copy the file to any other place and rebuild with
  1633. <code class="literal">make defconfig BR2_DEFCONFIG=&lt;path-to-defconfig-file&gt;</code>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-store-package-config"></a>9.4. Storing the configuration of other components</h2></div></div></div><p>The configuration files for BusyBox, the Linux kernel, Barebox, U-Boot
  1634. and uClibc should be stored as well if changed. For each of these
  1635. components, a Buildroot configuration option exists to point to an input
  1636. configuration file, e.g. <code class="literal">BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE</code>. To store
  1637. their configuration, set these configuration options to a path where you
  1638. want to save the configuration files, and then use the helper targets
  1639. described below to actually store the configuration.</p><p>As explained in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended path to
  1640. store these configuration files is
  1641. <code class="literal">board/&lt;company&gt;/&lt;boardname&gt;/foo.config</code>.</p><p>Make sure that you create a configuration file <span class="emphasis"><em>before</em></span> changing
  1642. the <code class="literal">BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE</code> etc. options. Otherwise,
  1643. Buildroot will try to access this config file, which doesn’t exist
  1644. yet, and will fail. You can create the configuration file by running
  1645. <code class="literal">make linux-menuconfig</code> etc.</p><p>Buildroot provides a few helper targets to make the saving of
  1646. configuration files easier.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1647. <code class="literal">make linux-update-defconfig</code> saves the linux configuration to the
  1648. path specified by <code class="literal">BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE</code>. It
  1649. simplifies the config file by removing default values. However,
  1650. this only works with kernels starting from 2.6.33. For earlier
  1651. kernels, use <code class="literal">make linux-update-config</code>.
  1652. </li><li class="listitem">
  1653. <code class="literal">make busybox-update-config</code> saves the busybox configuration to the
  1654. path specified by <code class="literal">BR2_PACKAGE_BUSYBOX_CONFIG</code>.
  1655. </li><li class="listitem">
  1656. <code class="literal">make uclibc-update-config</code> saves the uClibc configuration to the
  1657. path specified by <code class="literal">BR2_UCLIBC_CONFIG</code>.
  1658. </li><li class="listitem">
  1659. <code class="literal">make barebox-update-defconfig</code> saves the barebox configuration to the
  1660. path specified by <code class="literal">BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE</code>.
  1661. </li><li class="listitem">
  1662. <code class="literal">make uboot-update-defconfig</code> saves the U-Boot configuration to the
  1663. path specified by <code class="literal">BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE</code>.
  1664. </li><li class="listitem">
  1665. For at91bootstrap3, no helper exists so you have to copy the config
  1666. file manually to <code class="literal">BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE</code>.
  1667. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="rootfs-custom"></a>9.5. Customizing the generated target filesystem</h2></div></div></div><p>Besides changing the configuration through <code class="literal">make *config</code>,
  1668. there are a few other ways to customize the resulting target filesystem.</p><p>The two recommended methods, which can co-exist, are root filesystem
  1669. overlay(s) and post build script(s).</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  1670. Root filesystem overlays (<code class="literal">BR2_ROOTFS_OVERLAY</code>)
  1671. </span></dt><dd><p class="simpara">A filesystem overlay is a tree of files that is copied directly
  1672. over the target filesystem after it has been built. To enable this
  1673. feature, set config option <code class="literal">BR2_ROOTFS_OVERLAY</code> (in the <code class="literal">System
  1674. configuration</code> menu) to the root of the overlay. You can even specify
  1675. multiple overlays, space-separated. If you specify a relative path,
  1676. it will be relative to the root of the Buildroot tree. Hidden
  1677. directories of version control systems, like <code class="literal">.git</code>, <code class="literal">.svn</code>, <code class="literal">.hg</code>,
  1678. etc., files called <code class="literal">.empty</code> and files ending in <code class="literal">~</code> are excluded from
  1679. the copy.</p><p class="simpara">When <code class="literal">BR2_ROOTFS_MERGED_USR</code> is enabled, then the overlay must not
  1680. contain the <span class="emphasis"><em>/bin</em></span>, <span class="emphasis"><em>/lib</em></span> or <span class="emphasis"><em>/sbin</em></span> directories, as Buildroot will
  1681. create them as symbolic links to the relevant folders in <span class="emphasis"><em>/usr</em></span>. In
  1682. such a situation, should the overlay have any programs or libraries,
  1683. they should be placed in <span class="emphasis"><em>/usr/bin</em></span>, <span class="emphasis"><em>/usr/sbin</em></span> and <span class="emphasis"><em>/usr/lib</em></span>.</p><p class="simpara">As shown in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended path for
  1684. this overlay is <code class="literal">board/&lt;company&gt;/&lt;boardname&gt;/rootfs-overlay</code>.</p></dd><dt><span class="term">
  1685. Post-build scripts (<code class="literal">BR2_ROOTFS_POST_BUILD_SCRIPT</code>)
  1686. </span></dt><dd><p class="simpara">Post-build scripts are shell scripts called <span class="emphasis"><em>after</em></span> Buildroot builds
  1687. all the selected software, but <span class="emphasis"><em>before</em></span> the rootfs images are
  1688. assembled. To enable this feature, specify a space-separated list of
  1689. post-build scripts in config option <code class="literal">BR2_ROOTFS_POST_BUILD_SCRIPT</code> (in
  1690. the <code class="literal">System configuration</code> menu). If you specify a relative path, it
  1691. will be relative to the root of the Buildroot tree.</p><p class="simpara">Using post-build scripts, you can remove or modify any file in your
  1692. target filesystem. You should, however, use this feature with care.
  1693. Whenever you find that a certain package generates wrong or unneeded
  1694. files, you should fix that package rather than work around it with some
  1695. post-build cleanup scripts.</p><p class="simpara">As shown in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended path for
  1696. this script is <code class="literal">board/&lt;company&gt;/&lt;boardname&gt;/post_build.sh</code>.</p><p class="simpara">The post-build scripts are run with the main Buildroot tree as current
  1697. working directory. The path to the target filesystem is passed as the
  1698. first argument to each script. If the config option
  1699. <code class="literal">BR2_ROOTFS_POST_SCRIPT_ARGS</code> is not empty, these arguments will be
  1700. passed to the script too. All the scripts will be passed the exact
  1701. same set of arguments, it is not possible to pass different sets of
  1702. arguments to each script.</p><p class="simpara">In addition, you may also use these environment variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1703. <code class="literal">BR2_CONFIG</code>: the path to the Buildroot .config file
  1704. </li><li class="listitem">
  1705. <code class="literal">HOST_DIR</code>, <code class="literal">STAGING_DIR</code>, <code class="literal">TARGET_DIR</code>: see
  1706. <a class="xref" href="#generic-package-reference" title="18.5.2. generic-package reference">Section 18.5.2, “<code class="literal">generic-package</code> reference”</a>
  1707. </li><li class="listitem">
  1708. <code class="literal">BUILD_DIR</code>: the directory where packages are extracted and built
  1709. </li><li class="listitem">
  1710. <code class="literal">BINARIES_DIR</code>: the place where all binary files (aka images) are
  1711. stored
  1712. </li><li class="listitem">
  1713. <code class="literal">BASE_DIR</code>: the base output directory
  1714. </li></ul></div></dd></dl></div><p>Below three more methods of customizing the target filesystem are
  1715. described, but they are not recommended.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  1716. Direct modification of the target filesystem
  1717. </span></dt><dd><p class="simpara">For temporary modifications, you can modify the target filesystem
  1718. directly and rebuild the image. The target filesystem is available
  1719. under <code class="literal">output/target/</code>. After making your changes, run <code class="literal">make</code> to
  1720. rebuild the target filesystem image.</p><p class="simpara">This method allows you to do anything to the target filesystem, but if
  1721. you need to clean your Buildroot tree using <code class="literal">make clean</code>, these
  1722. changes will be lost. Such cleaning is necessary in several cases,
  1723. refer to <a class="xref" href="#full-rebuild" title="8.2. Understanding when a full rebuild is necessary">Section 8.2, “Understanding when a full rebuild is necessary”</a> for details. This solution is therefore
  1724. only useful for quick tests: <span class="emphasis"><em>changes do not survive the <code class="literal">make clean</code>
  1725. command</em></span>. Once you have validated your changes, you should make sure
  1726. that they will persist after a <code class="literal">make clean</code>, using a root filesystem
  1727. overlay or a post-build script.</p></dd><dt><span class="term">
  1728. Custom target skeleton (<code class="literal">BR2_ROOTFS_SKELETON_CUSTOM</code>)
  1729. </span></dt><dd><p class="simpara">The root filesystem image is created from a target skeleton, on top of
  1730. which all packages install their files. The skeleton is copied to the
  1731. target directory <code class="literal">output/target</code> before any package is built and
  1732. installed. The default target skeleton provides the standard Unix
  1733. filesystem layout and some basic init scripts and configuration files.</p><p class="simpara">If the default skeleton (available under <code class="literal">system/skeleton</code>) does not
  1734. match your needs, you would typically use a root filesystem overlay or
  1735. post-build script to adapt it. However, if the default skeleton is
  1736. entirely different than what you need, using a custom skeleton may be
  1737. more suitable.</p><p class="simpara">To enable this feature, enable config option
  1738. <code class="literal">BR2_ROOTFS_SKELETON_CUSTOM</code> and set <code class="literal">BR2_ROOTFS_SKELETON_CUSTOM_PATH</code>
  1739. to the path of your custom skeleton. Both options are available in the
  1740. <code class="literal">System configuration</code> menu. If you specify a relative path, it will
  1741. be relative to the root of the Buildroot tree.</p><p class="simpara">Custom skeletons don’t need to contain the <span class="emphasis"><em>/bin</em></span>, <span class="emphasis"><em>/lib</em></span> or <span class="emphasis"><em>/sbin</em></span>
  1742. directories, since they are created automatically during the build.
  1743. When <code class="literal">BR2_ROOTFS_MERGED_USR</code> is enabled, then the custom skeleton must
  1744. not contain the <span class="emphasis"><em>/bin</em></span>, <span class="emphasis"><em>/lib</em></span> or <span class="emphasis"><em>/sbin</em></span> directories, as Buildroot
  1745. will create them as symbolic links to the relevant folders in <span class="emphasis"><em>/usr</em></span>.
  1746. In such a situation, should the skeleton have any programs or
  1747. libraries, they should be placed in <span class="emphasis"><em>/usr/bin</em></span>, <span class="emphasis"><em>/usr/sbin</em></span> and
  1748. <span class="emphasis"><em>/usr/lib</em></span>.</p><p class="simpara">This method is not recommended because it duplicates the entire
  1749. skeleton, which prevents taking advantage of the fixes or improvements
  1750. brought to the default skeleton in later Buildroot releases.</p></dd><dt><span class="term">
  1751. Post-fakeroot scripts (<code class="literal">BR2_ROOTFS_POST_FAKEROOT_SCRIPT</code>)
  1752. </span></dt><dd><p class="simpara">When aggregating the final images, some parts of the process requires
  1753. root rights: creating device nodes in <code class="literal">/dev</code>, setting permissions or
  1754. ownership to files and directories… To avoid requiring actual root
  1755. rights, Buildroot uses <code class="literal">fakeroot</code> to simulate root rights. This is not
  1756. a complete substitute for actually being root, but is enough for what
  1757. Buildroot needs.</p><p class="simpara">Post-fakeroot scripts are shell scripts that are called at the <span class="emphasis"><em>end</em></span> of
  1758. the fakeroot phase, <span class="emphasis"><em>right before</em></span> the filesystem image generator is
  1759. called. As such, they are called in the fakeroot context.</p><p class="simpara">Post-fakeroot scripts can be useful in case you need to tweak the
  1760. filesystem to do modifications that are usually only available to the
  1761. root user.</p><p><strong>Note: </strong>It is recommended to use the existing mechanisms to set file permissions
  1762. or create entries in <code class="literal">/dev</code> (see <a class="xref" href="#customize-device-permission" title="9.5.1. Setting file permissions and ownership and adding custom devices nodes">Section 9.5.1, “Setting file permissions and ownership and adding custom devices nodes”</a>) or
  1763. to create users (see <a class="xref" href="#customize-users" title="9.6. Adding custom user accounts">Section 9.6, “Adding custom user accounts”</a>)</p><p><strong>Note: </strong>The difference between post-build scripts (above) and fakeroot scripts,
  1764. is that post-build scripts are not called in the fakeroot context.</p><p><strong>Note: </strong>Using <code class="literal">fakeroot</code> is not an absolute substitute for actually being root.
  1765. <code class="literal">fakeroot</code> only ever fakes the file access rights and types (regular,
  1766. block-or-char device…) and uid/gid; these are emulated in-memory.</p></dd></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="customize-device-permission"></a>9.5.1. Setting file permissions and ownership and adding custom devices nodes</h3></div></div></div><p>Sometimes it is needed to set specific permissions or ownership on files
  1767. or device nodes. For example, certain files may need to be owned by
  1768. root. Since the post-build scripts are not run as root, you cannot do
  1769. such changes from there unless you use an explicit fakeroot from the
  1770. post-build script.</p><p>Instead, Buildroot provides support for so-called <span class="emphasis"><em>permission tables</em></span>.
  1771. To use this feature, set config option <code class="literal">BR2_ROOTFS_DEVICE_TABLE</code> to a
  1772. space-separated list of permission tables, regular text files following
  1773. the <a class="link" href="#makedev-syntax" title="Chapter 25. Makedev syntax documentation">makedev syntax</a>.</p><p>If you are using a static device table (i.e. not using <code class="literal">devtmpfs</code>,
  1774. <code class="literal">mdev</code>, or <code class="literal">(e)udev</code>) then you can add device nodes using the same
  1775. syntax, in so-called <span class="emphasis"><em>device tables</em></span>. To use this feature, set config
  1776. option <code class="literal">BR2_ROOTFS_STATIC_DEVICE_TABLE</code> to a space-separated list of
  1777. device tables.</p><p>As shown in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended location for
  1778. such files is <code class="literal">board/&lt;company&gt;/&lt;boardname&gt;/</code>.</p><p>It should be noted that if the specific permissions or device nodes are
  1779. related to a specific application, you should set variables
  1780. <code class="literal">FOO_PERMISSIONS</code> and <code class="literal">FOO_DEVICES</code> in the package’s <code class="literal">.mk</code> file instead
  1781. (see <a class="xref" href="#generic-package-reference" title="18.5.2. generic-package reference">Section 18.5.2, “<code class="literal">generic-package</code> reference”</a>).</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-users"></a>9.6. Adding custom user accounts</h2></div></div></div><p>Sometimes it is needed to add specific users in the target system.
  1782. To cover this requirement, Buildroot provides support for so-called
  1783. <span class="emphasis"><em>users tables</em></span>. To use this feature, set config option
  1784. <code class="literal">BR2_ROOTFS_USERS_TABLES</code> to a space-separated list of users tables,
  1785. regular text files following the <a class="link" href="#makeuser-syntax" title="Chapter 26. Makeusers syntax documentation">makeusers syntax</a>.</p><p>As shown in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended location for
  1786. such files is <code class="literal">board/&lt;company&gt;/&lt;boardname&gt;/</code>.</p><p>It should be noted that if the custom users are related to a specific
  1787. application, you should set variable <code class="literal">FOO_USERS</code> in the package’s <code class="literal">.mk</code>
  1788. file instead (see <a class="xref" href="#generic-package-reference" title="18.5.2. generic-package reference">Section 18.5.2, “<code class="literal">generic-package</code> reference”</a>).</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_customization_emphasis_after_emphasis_the_images_have_been_created"></a>9.7. Customization <span class="emphasis"><em>after</em></span> the images have been created</h2></div></div></div><p>While post-build scripts (<a class="xref" href="#rootfs-custom" title="9.5. Customizing the generated target filesystem">Section 9.5, “Customizing the generated target filesystem”</a>) are run <span class="emphasis"><em>before</em></span>
  1789. building the filesystem image, kernel and bootloader, <span class="strong"><strong>post-image
  1790. scripts</strong></span> can be used to perform some specific actions <span class="emphasis"><em>after</em></span> all images
  1791. have been created.</p><p>Post-image scripts can for example be used to automatically extract your
  1792. root filesystem tarball in a location exported by your NFS server, or
  1793. to create a special firmware image that bundles your root filesystem and
  1794. kernel image, or any other custom action required for your project.</p><p>To enable this feature, specify a space-separated list of post-image
  1795. scripts in config option <code class="literal">BR2_ROOTFS_POST_IMAGE_SCRIPT</code> (in the <code class="literal">System
  1796. configuration</code> menu). If you specify a relative path, it will be
  1797. relative to the root of the Buildroot tree.</p><p>Just like post-build scripts, post-image scripts are run with the main
  1798. Buildroot tree as current working directory. The path to the <code class="literal">images</code>
  1799. output directory is passed as the first argument to each script. If the
  1800. config option <code class="literal">BR2_ROOTFS_POST_SCRIPT_ARGS</code> is not empty, these
  1801. arguments will be passed to the script too. All the scripts will be
  1802. passed the exact same set of arguments, it is not possible to pass
  1803. different sets of arguments to each script.</p><p>Again just like for the post-build scripts, the scripts have access to
  1804. the environment variables <code class="literal">BR2_CONFIG</code>, <code class="literal">HOST_DIR</code>, <code class="literal">STAGING_DIR</code>,
  1805. <code class="literal">TARGET_DIR</code>, <code class="literal">BUILD_DIR</code>, <code class="literal">BINARIES_DIR</code> and <code class="literal">BASE_DIR</code>.</p><p>The post-image scripts will be executed as the user that executes
  1806. Buildroot, which should normally <span class="emphasis"><em>not</em></span> be the root user. Therefore, any
  1807. action requiring root permissions in one of these scripts will require
  1808. special handling (usage of fakeroot or sudo), which is left to the
  1809. script developer.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-patches"></a>9.8. Adding project-specific patches</h2></div></div></div><p>It is sometimes useful to apply <span class="emphasis"><em>extra</em></span> patches to packages - on top of
  1810. those provided in Buildroot. This might be used to support custom
  1811. features in a project, for example, or when working on a new
  1812. architecture.</p><p>The <code class="literal">BR2_GLOBAL_PATCH_DIR</code> configuration option can be used to specify
  1813. a space separated list of one or more directories containing package
  1814. patches.</p><p>For a specific version <code class="literal">&lt;packageversion&gt;</code> of a specific package
  1815. <code class="literal">&lt;packagename&gt;</code>, patches are applied from <code class="literal">BR2_GLOBAL_PATCH_DIR</code> as
  1816. follows:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
  1817. For every directory - <code class="literal">&lt;global-patch-dir&gt;</code> - that exists in
  1818. <code class="literal">BR2_GLOBAL_PATCH_DIR</code>, a <code class="literal">&lt;package-patch-dir&gt;</code> will be determined as
  1819. follows:
  1820. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1821. <code class="literal">&lt;global-patch-dir&gt;/&lt;packagename&gt;/&lt;packageversion&gt;/</code> if the
  1822. directory exists.
  1823. </li><li class="listitem">
  1824. Otherwise, <code class="literal">&lt;global-patch-dir&gt;/&lt;packagename&gt;</code> if the directory
  1825. exists.
  1826. </li></ul></div></li><li class="listitem"><p class="simpara">
  1827. Patches will then be applied from a <code class="literal">&lt;package-patch-dir&gt;</code> as
  1828. follows:
  1829. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1830. If a <code class="literal">series</code> file exists in the package directory, then patches are
  1831. applied according to the <code class="literal">series</code> file;
  1832. </li><li class="listitem">
  1833. Otherwise, patch files matching <code class="literal">*.patch</code> are applied in
  1834. alphabetical order. So, to ensure they are applied in the right
  1835. order, it is highly recommended to name the patch files like this:
  1836. <code class="literal">&lt;number&gt;-&lt;description&gt;.patch</code>, where <code class="literal">&lt;number&gt;</code> refers to the
  1837. <span class="emphasis"><em>apply order</em></span>.
  1838. </li></ul></div></li></ol></div><p>For information about how patches are applied for a package, see
  1839. <a class="xref" href="#patch-apply-order" title="19.2. How patches are applied">Section 19.2, “How patches are applied”</a></p><p>The <code class="literal">BR2_GLOBAL_PATCH_DIR</code> option is the preferred method for
  1840. specifying a custom patch directory for packages. It can be used to
  1841. specify a patch directory for any package in buildroot. It should also
  1842. be used in place of the custom patch directory options that are
  1843. available for packages such as U-Boot and Barebox. By doing this, it
  1844. will allow a user to manage their patches from one top-level
  1845. directory.</p><p>The exception to <code class="literal">BR2_GLOBAL_PATCH_DIR</code> being the preferred method for
  1846. specifying custom patches is <code class="literal">BR2_LINUX_KERNEL_PATCH</code>.
  1847. <code class="literal">BR2_LINUX_KERNEL_PATCH</code> should be used to specify kernel patches that
  1848. are available at a URL. <span class="strong"><strong>Note:</strong></span> <code class="literal">BR2_LINUX_KERNEL_PATCH</code> specifies kernel
  1849. patches that are applied after patches available in <code class="literal">BR2_GLOBAL_PATCH_DIR</code>,
  1850. as it is done from a post-patch hook of the Linux package.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="customize-packages"></a>9.9. Adding project-specific packages</h2></div></div></div><p>In general, any new package should be added directly in the <code class="literal">package</code>
  1851. directory and submitted to the Buildroot upstream project. How to add
  1852. packages to Buildroot in general is explained in full detail in
  1853. <a class="xref" href="#adding-packages" title="Chapter 18. Adding new packages to Buildroot">Chapter 18, <em>Adding new packages to Buildroot</em></a> and will not be repeated here. However, your
  1854. project may need some proprietary packages that cannot be upstreamed.
  1855. This section will explain how you can keep such project-specific
  1856. packages in a project-specific directory.</p><p>As shown in <a class="xref" href="#customize-dir-structure" title="9.1. Recommended directory structure">Section 9.1, “Recommended directory structure”</a>, the recommended location for
  1857. project-specific packages is <code class="literal">package/&lt;company&gt;/</code>. If you are using the
  1858. br2-external tree feature (see <a class="xref" href="#outside-br-custom" title="9.2. Keeping customizations outside of Buildroot">Section 9.2, “Keeping customizations outside of Buildroot”</a>) the recommended
  1859. location is to put them in a sub-directory named <code class="literal">package/</code> in your
  1860. br2-external tree.</p><p>However, Buildroot will not be aware of the packages in this location,
  1861. unless we perform some additional steps. As explained in
  1862. <a class="xref" href="#adding-packages" title="Chapter 18. Adding new packages to Buildroot">Chapter 18, <em>Adding new packages to Buildroot</em></a>, a package in Buildroot basically consists of two
  1863. files: a <code class="literal">.mk</code> file (describing how to build the package) and a
  1864. <code class="literal">Config.in</code> file (describing the configuration options for this
  1865. package).</p><p>Buildroot will automatically include the <code class="literal">.mk</code> files in first-level
  1866. subdirectories of the <code class="literal">package</code> directory (using the pattern
  1867. <code class="literal">package/*/*.mk</code>). If we want Buildroot to include <code class="literal">.mk</code> files from
  1868. deeper subdirectories (like <code class="literal">package/&lt;company&gt;/package1/</code>) then we
  1869. simply have to add a <code class="literal">.mk</code> file in a first-level subdirectory that
  1870. includes these additional <code class="literal">.mk</code> files. Therefore, create a file
  1871. <code class="literal">package/&lt;company&gt;/&lt;company&gt;.mk</code> with following contents (assuming you
  1872. have only one extra directory level below <code class="literal">package/&lt;company&gt;/</code>):</p><pre class="screen">include $(sort $(wildcard package/&lt;company&gt;/*/*.mk))</pre><p>For the <code class="literal">Config.in</code> files, create a file <code class="literal">package/&lt;company&gt;/Config.in</code>
  1873. that includes the <code class="literal">Config.in</code> files of all your packages. An exhaustive
  1874. list has to be provided since wildcards are not supported in the source command of kconfig.
  1875. For example:</p><pre class="screen">source "package/&lt;company&gt;/package1/Config.in"
  1876. source "package/&lt;company&gt;/package2/Config.in"</pre><p>Include this new file <code class="literal">package/&lt;company&gt;/Config.in</code> from
  1877. <code class="literal">package/Config.in</code>, preferably in a company-specific menu to make
  1878. merges with future Buildroot versions easier.</p><p>If using a br2-external tree, refer to <a class="xref" href="#outside-br-custom" title="9.2. Keeping customizations outside of Buildroot">Section 9.2, “Keeping customizations outside of Buildroot”</a> for how
  1879. to fill in those files.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_quick_guide_to_storing_your_project_specific_customizations"></a>9.10. Quick guide to storing your project-specific customizations</h2></div></div></div><p>Earlier in this chapter, the different methods for making
  1880. project-specific customizations have been described. This section will
  1881. now summarize all this by providing step-by-step instructions to storing your
  1882. project-specific customizations. Clearly, the steps that are not relevant to
  1883. your project can be skipped.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  1884. <code class="literal">make menuconfig</code> to configure toolchain, packages and kernel.
  1885. </li><li class="listitem">
  1886. <code class="literal">make linux-menuconfig</code> to update the kernel config, similar for
  1887. other configuration like busybox, uclibc, …
  1888. </li><li class="listitem">
  1889. <code class="literal">mkdir -p board/&lt;manufacturer&gt;/&lt;boardname&gt;</code>
  1890. </li><li class="listitem"><p class="simpara">
  1891. Set the following options to <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/&lt;package&gt;.config</code>
  1892. (as far as they are relevant):
  1893. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1894. <code class="literal">BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE</code>
  1895. </li><li class="listitem">
  1896. <code class="literal">BR2_PACKAGE_BUSYBOX_CONFIG</code>
  1897. </li><li class="listitem">
  1898. <code class="literal">BR2_UCLIBC_CONFIG</code>
  1899. </li><li class="listitem">
  1900. <code class="literal">BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE</code>
  1901. </li><li class="listitem">
  1902. <code class="literal">BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE</code>
  1903. </li><li class="listitem">
  1904. <code class="literal">BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE</code>
  1905. </li></ul></div></li><li class="listitem"><p class="simpara">
  1906. Write the configuration files:
  1907. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1908. <code class="literal">make linux-update-defconfig</code>
  1909. </li><li class="listitem">
  1910. <code class="literal">make busybox-update-config</code>
  1911. </li><li class="listitem">
  1912. <code class="literal">make uclibc-update-config</code>
  1913. </li><li class="listitem">
  1914. <code class="literal">cp &lt;output&gt;/build/at91bootstrap3-*/.config
  1915. board/&lt;manufacturer&gt;/&lt;boardname&gt;/at91bootstrap3.config</code>
  1916. </li><li class="listitem">
  1917. <code class="literal">make barebox-update-defconfig</code>
  1918. </li><li class="listitem">
  1919. <code class="literal">make uboot-update-defconfig</code>
  1920. </li></ul></div></li><li class="listitem">
  1921. Create <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/rootfs-overlay/</code> and fill it
  1922. with additional files you need on your rootfs, e.g.
  1923. <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/rootfs-overlay/etc/inittab</code>.
  1924. Set <code class="literal">BR2_ROOTFS_OVERLAY</code>
  1925. to <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/rootfs-overlay</code>.
  1926. </li><li class="listitem">
  1927. Create a post-build script
  1928. <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/post_build.sh</code>. Set
  1929. <code class="literal">BR2_ROOTFS_POST_BUILD_SCRIPT</code> to
  1930. <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/post_build.sh</code>
  1931. </li><li class="listitem">
  1932. If additional setuid permissions have to be set or device nodes have
  1933. to be created, create <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/device_table.txt</code>
  1934. and add that path to <code class="literal">BR2_ROOTFS_DEVICE_TABLE</code>.
  1935. </li><li class="listitem">
  1936. If additional user accounts have to be created, create
  1937. <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/users_table.txt</code> and add that path
  1938. to <code class="literal">BR2_ROOTFS_USERS_TABLES</code>.
  1939. </li><li class="listitem">
  1940. To add custom patches to certain packages, set <code class="literal">BR2_GLOBAL_PATCH_DIR</code>
  1941. to <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;/patches/</code> and add your patches
  1942. for each package in a subdirectory named after the package. Each
  1943. patch should be called <code class="literal">&lt;packagename&gt;-&lt;num&gt;-&lt;description&gt;.patch</code>.
  1944. </li><li class="listitem">
  1945. Specifically for the Linux kernel, there also exists the option
  1946. <code class="literal">BR2_LINUX_KERNEL_PATCH</code> with as main advantage that it can also
  1947. download patches from a URL. If you do not need this,
  1948. <code class="literal">BR2_GLOBAL_PATCH_DIR</code> is preferred. U-Boot, Barebox, at91bootstrap
  1949. and at91bootstrap3 also have separate options, but these do not
  1950. provide any advantage over <code class="literal">BR2_GLOBAL_PATCH_DIR</code> and will likely be
  1951. removed in the future.
  1952. </li><li class="listitem">
  1953. If you need to add project-specific packages, create
  1954. <code class="literal">package/&lt;manufacturer&gt;/</code> and place your packages in that
  1955. directory. Create an overall <code class="literal">&lt;manufacturer&gt;.mk</code> file that
  1956. includes the <code class="literal">.mk</code> files of all your packages. Create an overall
  1957. <code class="literal">Config.in</code> file that sources the <code class="literal">Config.in</code> files of all your
  1958. packages. Include this <code class="literal">Config.in</code> file from Buildroot’s
  1959. <code class="literal">package/Config.in</code> file.
  1960. </li><li class="listitem">
  1961. <code class="literal">make savedefconfig</code> to save the buildroot configuration.
  1962. </li><li class="listitem">
  1963. <code class="literal">cp defconfig configs/&lt;boardname&gt;_defconfig</code>
  1964. </li></ol></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="selinux"></a>Chapter 10. Using SELinux in Buildroot</h2></div></div></div><p><a class="ulink" href="https://selinuxproject.org" target="_top">SELinux</a> is a Linux kernel security module
  1965. enforcing access control policies. In addition to the traditional file
  1966. permissions and access control lists, <code class="literal">SELinux</code> allows to write rules
  1967. for users or processes to access specific functions of resources
  1968. (files, sockets…).</p><p><span class="emphasis"><em>SELinux</em></span> has three modes of operation:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1969. <span class="emphasis"><em>Disabled</em></span>: the policy is not applied
  1970. </li><li class="listitem">
  1971. <span class="emphasis"><em>Permissive</em></span>: the policy is applied, and non-authorized actions are
  1972. simply logged. This mode is often used for troubleshooting SELinux
  1973. issues.
  1974. </li><li class="listitem">
  1975. <span class="emphasis"><em>Enforcing</em></span>: the policy is applied, and non-authorized actions are
  1976. denied
  1977. </li></ul></div><p>In Buildroot the mode of operation is controlled by the
  1978. <code class="literal">BR2_PACKAGE_REFPOLICY_POLICY_STATE_*</code> configuration options. The
  1979. Linux kernel also has various configuration options that affect how
  1980. <code class="literal">SELinux</code> is enabled (see <code class="literal">security/selinux/Kconfig</code> in the Linux
  1981. kernel sources).</p><p>By default in Buildroot the <code class="literal">SELinux</code> policy is provided by the
  1982. upstream <a class="ulink" href="https://github.com/SELinuxProject/refpolicy" target="_top">refpolicy</a>
  1983. project, enabled with <code class="literal">BR2_PACKAGE_REFPOLICY</code>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="enabling-selinux"></a>10.1. Enabling SELinux support</h2></div></div></div><p>To have proper support for <code class="literal">SELinux</code> in a Buildroot generated system,
  1984. the following configuration options must be enabled:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1985. <code class="literal">BR2_PACKAGE_LIBSELINUX</code>
  1986. </li><li class="listitem">
  1987. <code class="literal">BR2_PACKAGE_REFPOLICY</code>
  1988. </li></ul></div><p>In addition, your filesystem image format must support extended
  1989. attributes.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="selinux-policy-tweaking"></a>10.2. SELinux policy tweaking</h2></div></div></div><p>The <code class="literal">SELinux refpolicy</code> contains modules that can be enabled or
  1990. disabled when being built. Each module provide a number of <code class="literal">SELinux</code>
  1991. rules. In Buildroot the non-base modules are disabled by default and
  1992. several ways to enable such modules are provided:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  1993. Packages can enable a list of <code class="literal">SELinux</code> modules within the <code class="literal">refpolicy</code> using
  1994. the <code class="literal">&lt;packagename&gt;_SELINUX_MODULES</code> variable.
  1995. </li><li class="listitem">
  1996. Packages can provide additional <code class="literal">SELinux</code> modules by putting them (.fc, .if
  1997. and .te files) in <code class="literal">package/&lt;packagename&gt;/selinux/</code>.
  1998. </li><li class="listitem">
  1999. Extra <code class="literal">SELinux</code> modules can be added in directories pointed by the
  2000. <code class="literal">BR2_REFPOLICY_EXTRA_MODULES_DIRS</code> configuration option.
  2001. </li><li class="listitem">
  2002. Additional modules in the <code class="literal">refpolicy</code> can be enabled if listed in the
  2003. <code class="literal">BR2_REFPOLICY_EXTRA_MODULES_DEPENDENCIES</code> configuration option.
  2004. </li></ul></div><p>Buildroot also allows to completely override the <code class="literal">refpolicy</code>. This
  2005. allows to provide a full custom policy designed specifically for a
  2006. given system. When going this way, all of the above mechanisms are
  2007. disabled: no extra <code class="literal">SElinux</code> module is added to the policy, and all
  2008. the available modules within the custom policy are enabled and built
  2009. into the final binary policy. The custom policy must be a fork of the
  2010. official <a class="ulink" href="https://github.com/SELinuxProject/refpolicy" target="_top">refpolicy</a>.</p><p>In order to fully override the <code class="literal">refpolicy</code> the following configuration
  2011. variables have to be set:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2012. <code class="literal">BR2_PACKAGE_REFPOLICY_CUSTOM_GIT</code>
  2013. </li><li class="listitem">
  2014. <code class="literal">BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL</code>
  2015. </li><li class="listitem">
  2016. <code class="literal">BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_VERSION</code>
  2017. </li></ul></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_frequently_asked_questions_amp_troubleshooting"></a>Chapter 11. Frequently Asked Questions &amp; Troubleshooting</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-boot-hang-after-starting"></a>11.1. The boot hangs after <span class="emphasis"><em>Starting network…</em></span></h2></div></div></div><p>If the boot process seems to hang after the following messages
  2018. (messages not necessarily exactly similar, depending on the list of
  2019. packages selected):</p><pre class="screen">Freeing init memory: 3972K
  2020. Initializing random number generator... done.
  2021. Starting network...
  2022. Starting dropbear sshd: generating rsa key... generating dsa key... OK</pre><p>then it means that your system is running, but didn’t start a shell on
  2023. the serial console. In order to have the system start a shell on your
  2024. serial console, you have to go into the Buildroot configuration, in
  2025. <code class="literal">System configuration</code>, modify <code class="literal">Run a getty (login prompt) after boot</code>
  2026. and set the appropriate port and baud rate in the <code class="literal">getty options</code>
  2027. submenu. This will automatically tune the <code class="literal">/etc/inittab</code> file of the
  2028. generated system so that a shell starts on the correct serial port.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-no-compiler-on-target"></a>11.2. Why is there no compiler on the target?</h2></div></div></div><p>It has been decided that support for the <span class="emphasis"><em>native compiler on the
  2029. target</em></span> would be stopped from the Buildroot-2012.11 release because:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2030. this feature was neither maintained nor tested, and often broken;
  2031. </li><li class="listitem">
  2032. this feature was only available for Buildroot toolchains;
  2033. </li><li class="listitem">
  2034. Buildroot mostly targets <span class="emphasis"><em>small</em></span> or <span class="emphasis"><em>very small</em></span> target hardware
  2035. with limited resource onboard (CPU, ram, mass-storage), for which
  2036. compiling on the target does not make much sense;
  2037. </li><li class="listitem">
  2038. Buildroot aims at easing the cross-compilation, making native
  2039. compilation on the target unnecessary.
  2040. </li></ul></div><p>If you need a compiler on your target anyway, then Buildroot is not
  2041. suitable for your purpose. In such case, you need a <span class="emphasis"><em>real
  2042. distribution</em></span> and you should opt for something like:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2043. <a class="ulink" href="http://www.openembedded.org" target="_top">openembedded</a>
  2044. </li><li class="listitem">
  2045. <a class="ulink" href="https://www.yoctoproject.org" target="_top">yocto</a>
  2046. </li><li class="listitem">
  2047. <a class="ulink" href="http://www.emdebian.org" target="_top">emdebian</a>
  2048. </li><li class="listitem">
  2049. <a class="ulink" href="https://fedoraproject.org/wiki/Architectures" target="_top">Fedora</a>
  2050. </li><li class="listitem">
  2051. <a class="ulink" href="http://en.opensuse.org/Portal:ARM" target="_top">openSUSE ARM</a>
  2052. </li><li class="listitem">
  2053. <a class="ulink" href="http://archlinuxarm.org" target="_top">Arch Linux ARM</a>
  2054. </li><li class="listitem">
  2055. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-no-dev-files-on-target"></a>11.3. Why are there no development files on the target?</h2></div></div></div><p>Since there is no compiler available on the target (see
  2056. <a class="xref" href="#faq-no-compiler-on-target" title="11.2. Why is there no compiler on the target?">Section 11.2, “Why is there no compiler on the target?”</a>), it does not make sense to waste
  2057. space with headers or static libraries.</p><p>Therefore, those files are always removed from the target since the
  2058. Buildroot-2012.11 release.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-no-doc-on-target"></a>11.4. Why is there no documentation on the target?</h2></div></div></div><p>Because Buildroot mostly targets <span class="emphasis"><em>small</em></span> or <span class="emphasis"><em>very small</em></span> target
  2059. hardware with limited resource onboard (CPU, ram, mass-storage), it
  2060. does not make sense to waste space with the documentation data.</p><p>If you need documentation data on your target anyway, then Buildroot
  2061. is not suitable for your purpose, and you should look for a <span class="emphasis"><em>real
  2062. distribution</em></span> (see: <a class="xref" href="#faq-no-compiler-on-target" title="11.2. Why is there no compiler on the target?">Section 11.2, “Why is there no compiler on the target?”</a>).</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-why-not-visible-package"></a>11.5. Why are some packages not visible in the Buildroot config menu?</h2></div></div></div><p>If a package exists in the Buildroot tree and does not appear in the
  2063. config menu, this most likely means that some of the package’s
  2064. dependencies are not met.</p><p>To know more about the dependencies of a package, search for the
  2065. package symbol in the config menu (see <a class="xref" href="#make-tips" title="8.1. make tips">Section 8.1, “<span class="emphasis"><em>make</em></span> tips”</a>).</p><p>Then, you may have to recursively enable several options (which
  2066. correspond to the unmet dependencies) to finally be able to select
  2067. the package.</p><p>If the package is not visible due to some unmet toolchain options,
  2068. then you should certainly run a full rebuild (see <a class="xref" href="#make-tips" title="8.1. make tips">Section 8.1, “<span class="emphasis"><em>make</em></span> tips”</a> for
  2069. more explanations).</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-why-not-use-target-as-chroot"></a>11.6. Why not use the target directory as a chroot directory?</h2></div></div></div><p>There are plenty of reasons to <span class="strong"><strong>not</strong></span> use the target directory a chroot
  2070. one, among these:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2071. file ownerships, modes and permissions are not correctly set in the
  2072. target directory;
  2073. </li><li class="listitem">
  2074. device nodes are not created in the target directory.
  2075. </li></ul></div><p>For these reasons, commands run through chroot, using the target
  2076. directory as the new root, will most likely fail.</p><p>If you want to run the target filesystem inside a chroot, or as an NFS
  2077. root, then use the tarball image generated in <code class="literal">images/</code> and extract it
  2078. as root.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-no-binary-packages"></a>11.7. Why doesn’t Buildroot generate binary packages (.deb, .ipkg…)?</h2></div></div></div><p>One feature that is often discussed on the Buildroot list is the
  2079. general topic of "package management". To summarize, the idea
  2080. would be to add some tracking of which Buildroot package installs
  2081. what files, with the goals of:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2082. being able to remove files installed by a package when this package
  2083. gets unselected from the menuconfig;
  2084. </li><li class="listitem">
  2085. being able to generate binary packages (ipk or other format) that
  2086. can be installed on the target without re-generating a new root
  2087. filesystem image.
  2088. </li></ul></div><p>In general, most people think it is easy to do: just track which package
  2089. installed what and remove it when the package is unselected. However, it
  2090. is much more complicated than that:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2091. It is not only about the <code class="literal">target/</code> directory, but also the sysroot in
  2092. <code class="literal">host/&lt;tuple&gt;/sysroot</code> and the <code class="literal">host/</code> directory itself. All files
  2093. installed in those directories by various packages must be tracked.
  2094. </li><li class="listitem">
  2095. When a package is unselected from the configuration, it is not
  2096. sufficient to remove just the files it installed. One must also
  2097. remove all its reverse dependencies (i.e. packages relying on it)
  2098. and rebuild all those packages. For example, package A depends
  2099. optionally on the OpenSSL library. Both are selected, and Buildroot
  2100. is built. Package A is built with crypto support using OpenSSL.
  2101. Later on, OpenSSL gets unselected from the configuration, but
  2102. package A remains (since OpenSSL is an optional dependency, this
  2103. is possible.) If only OpenSSL files are removed, then the files
  2104. installed by package A are broken: they use a library that is no
  2105. longer present on the target. Although this is technically doable,
  2106. it adds a lot of complexity to Buildroot, which goes against the
  2107. simplicity we try to stick to.
  2108. </li><li class="listitem">
  2109. In addition to the previous problem, there is the case where the
  2110. optional dependency is not even known to Buildroot. For example,
  2111. package A in version 1.0 never used OpenSSL, but in version 2.0 it
  2112. automatically uses OpenSSL if available. If the Buildroot .mk file
  2113. hasn’t been updated to take this into account, then package A will
  2114. not be part of the reverse dependencies of OpenSSL and will not be
  2115. removed and rebuilt when OpenSSL is removed. For sure, the .mk file
  2116. of package A should be fixed to mention this optional dependency,
  2117. but in the mean time, you can have non-reproducible behaviors.
  2118. </li><li class="listitem">
  2119. The request is to also allow changes in the menuconfig to be
  2120. applied on the output directory without having to rebuild
  2121. everything from scratch. However, this is very difficult to achieve
  2122. in a reliable way: what happens when the suboptions of a package
  2123. are changed (we would have to detect this, and rebuild the package
  2124. from scratch and potentially all its reverse dependencies), what
  2125. happens if toolchain options are changed, etc. At the moment, what
  2126. Buildroot does is clear and simple so its behaviour is very
  2127. reliable and it is easy to support users. If configuration changes
  2128. done in menuconfig are applied after the next make, then it has to
  2129. work correctly and properly in all situations, and not have some
  2130. bizarre corner cases. The risk is to get bug reports like "I have
  2131. enabled package A, B and C, then ran make, then disabled package
  2132. C and enabled package D and ran make, then re-enabled package C
  2133. and enabled package E and then there is a build failure". Or worse
  2134. "I did some configuration, then built, then did some changes,
  2135. built, some more changes, built, some more changes, built, and now
  2136. it fails, but I don’t remember all the changes I did and in which
  2137. order". This will be impossible to support.
  2138. </li></ul></div><p>For all these reasons, the conclusion is that adding tracking of
  2139. installed files to remove them when the package is unselected, or to
  2140. generate a repository of binary packages, is something that is very
  2141. hard to achieve reliably and will add a lot of complexity.</p><p>On this matter, the Buildroot developers make this position statement:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2142. Buildroot strives to make it easy to generate a root filesystem (hence
  2143. the name, by the way.) That is what we want to make Buildroot good at:
  2144. building root filesystems.
  2145. </li><li class="listitem">
  2146. Buildroot is not meant to be a distribution (or rather, a distribution
  2147. generator.) It is the opinion of most Buildroot developers that this
  2148. is not a goal we should pursue. We believe that there are other tools
  2149. better suited to generate a distro than Buildroot is. For example,
  2150. <a class="ulink" href="http://openembedded.org/" target="_top">Open Embedded</a>, or <a class="ulink" href="https://openwrt.org/" target="_top">openWRT</a>,
  2151. are such tools.
  2152. </li><li class="listitem">
  2153. We prefer to push Buildroot in a direction that makes it easy (or even
  2154. easier) to generate complete root filesystems. This is what makes
  2155. Buildroot stands out in the crowd (among other things, of course!)
  2156. </li><li class="listitem">
  2157. We believe that for most embedded Linux systems, binary packages are
  2158. not necessary, and potentially harmful. When binary packages are
  2159. used, it means that the system can be partially upgraded, which
  2160. creates an enormous number of possible combinations of package
  2161. versions that should be tested before doing the upgrade on the
  2162. embedded device. On the other hand, by doing complete system
  2163. upgrades by upgrading the entire root filesystem image at once,
  2164. the image deployed to the embedded system is guaranteed to really
  2165. be the one that has been tested and validated.
  2166. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="faq-speeding-up-build"></a>11.8. How to speed-up the build process?</h2></div></div></div><p>Since Buildroot often involves doing full rebuilds of the entire
  2167. system that can be quite long, we provide below a number of tips to
  2168. help reduce the build time:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2169. Use a pre-built external toolchain instead of the default Buildroot
  2170. internal toolchain. By using a pre-built Linaro toolchain (on ARM)
  2171. or a Sourcery CodeBench toolchain (for ARM, x86, x86-64, MIPS,
  2172. etc.), you will save the build time of the toolchain at each
  2173. complete rebuild, approximately 15 to 20 minutes. Note that
  2174. temporarily using an external toolchain does not prevent you to
  2175. switch back to an internal toolchain (that may provide a higher
  2176. level of customization) once the rest of your system is working;
  2177. </li><li class="listitem">
  2178. Use the <code class="literal">ccache</code> compiler cache (see: <a class="xref" href="#ccache" title="8.14.3. Using ccache in Buildroot">Section 8.14.3, “Using <code class="literal">ccache</code> in Buildroot”</a>);
  2179. </li><li class="listitem">
  2180. Learn about rebuilding only the few packages you actually care
  2181. about (see <a class="xref" href="#rebuild-pkg" title="8.3. Understanding how to rebuild packages">Section 8.3, “Understanding how to rebuild packages”</a>), but beware that sometimes full
  2182. rebuilds are anyway necessary (see <a class="xref" href="#full-rebuild" title="8.2. Understanding when a full rebuild is necessary">Section 8.2, “Understanding when a full rebuild is necessary”</a>);
  2183. </li><li class="listitem">
  2184. Make sure you are not using a virtual machine for the Linux system
  2185. used to run Buildroot. Most of the virtual machine technologies are
  2186. known to cause a significant performance impact on I/O, which is
  2187. really important for building source code;
  2188. </li><li class="listitem">
  2189. Make sure that you’re using only local files: do not attempt to do
  2190. a build over NFS, which significantly slows down the build. Having
  2191. the Buildroot download folder available locally also helps a bit.
  2192. </li><li class="listitem">
  2193. Buy new hardware. SSDs and lots of RAM are key to speeding up the
  2194. builds.
  2195. </li><li class="listitem">
  2196. Experiment with top-level parallel build, see
  2197. <a class="xref" href="#top-level-parallel-build" title="8.12. Top-level parallel build">Section 8.12, “Top-level parallel build”</a>.
  2198. </li></ul></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_known_issues"></a>Chapter 12. Known issues</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2199. It is not possible to pass extra linker options via <code class="literal">BR2_TARGET_LDFLAGS</code>
  2200. if such options contain a <code class="literal">$</code> sign. For example, the following is known
  2201. to break: <code class="literal">BR2_TARGET_LDFLAGS="-Wl,-rpath='$ORIGIN/../lib'"</code>
  2202. </li><li class="listitem">
  2203. The <code class="literal">libffi</code> package is not supported on the SuperH 2 and ARC
  2204. architectures.
  2205. </li><li class="listitem">
  2206. The <code class="literal">prboom</code> package triggers a compiler failure with the SuperH 4
  2207. compiler from Sourcery CodeBench, version 2012.09.
  2208. </li></ul></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="legal-info"></a>Chapter 13. Legal notice and licensing</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_complying_with_open_source_licenses"></a>13.1. Complying with open source licenses</h2></div></div></div><p>All of the end products of Buildroot (toolchain, root filesystem, kernel,
  2209. bootloaders) contain open source software, released under various licenses.</p><p>Using open source software gives you the freedom to build rich embedded
  2210. systems, choosing from a wide range of packages, but also imposes some
  2211. obligations that you must know and honour.
  2212. Some licenses require you to publish the license text in the documentation of
  2213. your product. Others require you to redistribute the source code of the
  2214. software to those that receive your product.</p><p>The exact requirements of each license are documented in each package, and
  2215. it is your responsibility (or that of your legal office) to comply with those
  2216. requirements.
  2217. To make this easier for you, Buildroot can collect for you some material you
  2218. will probably need. To produce this material, after you have configured
  2219. Buildroot with <code class="literal">make menuconfig</code>, <code class="literal">make xconfig</code> or <code class="literal">make gconfig</code>, run:</p><pre class="screen">make legal-info</pre><p>Buildroot will collect legally-relevant material in your output directory,
  2220. under the <code class="literal">legal-info/</code> subdirectory.
  2221. There you will find:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2222. A <code class="literal">README</code> file, that summarizes the produced material and contains warnings
  2223. about material that Buildroot could not produce.
  2224. </li><li class="listitem">
  2225. <code class="literal">buildroot.config</code>: this is the Buildroot configuration file that is usually
  2226. produced with <code class="literal">make menuconfig</code>, and which is necessary to reproduce the
  2227. build.
  2228. </li><li class="listitem">
  2229. The source code for all packages; this is saved in the <code class="literal">sources/</code> and
  2230. <code class="literal">host-sources/</code> subdirectories for target and host packages respectively.
  2231. The source code for packages that set <code class="literal">&lt;PKG&gt;_REDISTRIBUTE = NO</code> will not be
  2232. saved.
  2233. Patches that were applied are also saved, along with a file named <code class="literal">series</code>
  2234. that lists the patches in the order they were applied. Patches are under the
  2235. same license as the files that they modify.
  2236. Note: Buildroot applies additional patches to Libtool scripts of
  2237. autotools-based packages. These patches can be found under
  2238. <code class="literal">support/libtool</code> in the Buildroot source and, due to technical
  2239. limitations, are not saved with the package sources. You may need to
  2240. collect them manually.
  2241. </li><li class="listitem">
  2242. A manifest file (one for host and one for target packages) listing the
  2243. configured packages, their version, license and related information.
  2244. Some of this information might not be defined in Buildroot; such items are
  2245. marked as "unknown".
  2246. </li><li class="listitem">
  2247. The license texts of all packages, in the <code class="literal">licenses/</code> and <code class="literal">host-licenses/</code>
  2248. subdirectories for target and host packages respectively.
  2249. If the license file(s) are not defined in Buildroot, the file is not produced
  2250. and a warning in the <code class="literal">README</code> indicates this.
  2251. </li></ul></div><p>Please note that the aim of the <code class="literal">legal-info</code> feature of Buildroot is to
  2252. produce all the material that is somehow relevant for legal compliance with the
  2253. package licenses. Buildroot does not try to produce the exact material that
  2254. you must somehow make public. Certainly, more material is produced than is
  2255. needed for a strict legal compliance. For example, it produces the source code
  2256. for packages released under BSD-like licenses, that you are not required to
  2257. redistribute in source form.</p><p>Moreover, due to technical limitations, Buildroot does not produce some
  2258. material that you will or may need, such as the toolchain source code for
  2259. some of the external toolchains and the Buildroot source code itself.
  2260. When you run <code class="literal">make legal-info</code>, Buildroot produces warnings in the <code class="literal">README</code>
  2261. file to inform you of relevant material that could not be saved.</p><p>Finally, keep in mind that the output of <code class="literal">make legal-info</code> is based on
  2262. declarative statements in each of the packages recipes. The Buildroot
  2263. developers try to do their best to keep those declarative statements as
  2264. accurate as possible, to the best of their knowledge. However, it is very
  2265. well possible that those declarative statements are not all fully accurate
  2266. nor exhaustive. You (or your legal department) <span class="emphasis"><em>have</em></span> to check the output
  2267. of <code class="literal">make legal-info</code> before using it as your own compliance delivery. See
  2268. the <span class="emphasis"><em>NO WARRANTY</em></span> clauses (clauses 11 and 12) in the <code class="literal">COPYING</code> file at the
  2269. root of the Buildroot distribution.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="legal-info-buildroot"></a>13.2. Complying with the Buildroot license</h2></div></div></div><p>Buildroot itself is an open source software, released under the
  2270. <a class="ulink" href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_top">GNU General
  2271. Public License, version 2</a> or (at your option) any later version, with
  2272. the exception of the package patches detailed below.
  2273. However, being a build system, it is not normally part of the end product:
  2274. if you develop the root filesystem, kernel, bootloader or toolchain for a
  2275. device, the code of Buildroot is only present on the development machine, not
  2276. in the device storage.</p><p>Nevertheless, the general view of the Buildroot developers is that you should
  2277. release the Buildroot source code along with the source code of other packages
  2278. when releasing a product that contains GPL-licensed software.
  2279. This is because the
  2280. <a class="ulink" href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_top">GNU GPL</a>
  2281. defines the "<span class="emphasis"><em>complete source code</em></span>" for an executable work as "<span class="emphasis"><em>all the
  2282. source code for all modules it contains, plus any associated interface
  2283. definition files, plus the scripts used to control compilation and installation
  2284. of the executable</em></span>".
  2285. Buildroot is part of the <span class="emphasis"><em>scripts used to control compilation and
  2286. installation of the executable</em></span>, and as such it is considered part of the
  2287. material that must be redistributed.</p><p>Keep in mind that this is only the Buildroot developers' opinion, and you
  2288. should consult your legal department or lawyer in case of any doubt.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_patches_to_packages"></a>13.2.1. Patches to packages</h3></div></div></div><p>Buildroot also bundles patch files, which are applied to the sources
  2289. of the various packages. Those patches are not covered by the license
  2290. of Buildroot. Instead, they are covered by the license of the software
  2291. to which the patches are applied. When said software is available
  2292. under multiple licenses, the Buildroot patches are only provided under
  2293. the publicly accessible licenses.</p><p>See <a class="xref" href="#patch-policy" title="Chapter 19. Patching a package">Chapter 19, <em>Patching a package</em></a> for the technical details.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_beyond_buildroot"></a>Chapter 14. Beyond Buildroot</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_boot_the_generated_images"></a>14.1. Boot the generated images</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_nfs_boot"></a>14.1.1. NFS boot</h3></div></div></div><p>To achieve NFS-boot, enable <span class="emphasis"><em>tar root filesystem</em></span> in the <span class="emphasis"><em>Filesystem
  2294. images</em></span> menu.</p><p>After a complete build, just run the following commands to setup the
  2295. NFS-root directory:</p><pre class="screen">sudo tar -xavf /path/to/output_dir/rootfs.tar -C /path/to/nfs_root_dir</pre><p>Remember to add this path to <code class="literal">/etc/exports</code>.</p><p>Then, you can execute a NFS-boot from your target.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_live_cd"></a>14.1.2. Live CD</h3></div></div></div><p>To build a live CD image, enable the <span class="emphasis"><em>iso image</em></span> option in the
  2296. <span class="emphasis"><em>Filesystem images</em></span> menu. Note that this option is only available on
  2297. the x86 and x86-64 architectures, and if you are building your kernel
  2298. with Buildroot.</p><p>You can build a live CD image with either IsoLinux, Grub or Grub 2 as
  2299. a bootloader, but only Isolinux supports making this image usable both
  2300. as a live CD and live USB (through the <span class="emphasis"><em>Build hybrid image</em></span> option).</p><p>You can test your live CD image using QEMU:</p><pre class="screen">qemu-system-i386 -cdrom output/images/rootfs.iso9660</pre><p>Or use it as a hard-drive image if it is a hybrid ISO:</p><pre class="screen">qemu-system-i386 -hda output/images/rootfs.iso9660</pre><p>It can be easily flashed to a USB drive with <code class="literal">dd</code>:</p><pre class="screen">dd if=output/images/rootfs.iso9660 of=/dev/sdb</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_chroot"></a>14.2. Chroot</h2></div></div></div><p>If you want to chroot in a generated image, then there are few thing
  2301. you should be aware of:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2302. you should setup the new root from the <span class="emphasis"><em>tar root filesystem</em></span> image;
  2303. </li><li class="listitem">
  2304. either the selected target architecture is compatible with your host
  2305. machine, or you should use some <code class="literal">qemu-*</code> binary and correctly set it
  2306. within the <code class="literal">binfmt</code> properties to be able to run the binaries built
  2307. for the target on your host machine;
  2308. </li><li class="listitem">
  2309. Buildroot does not currently provide <code class="literal">host-qemu</code> and <code class="literal">binfmt</code>
  2310. correctly built and set for that kind of use.
  2311. </li></ul></div></div></div></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_developer_guide"></a>Part III. Developer guide</h1></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_how_buildroot_works"></a>Chapter 15. How Buildroot works</h2></div></div></div><p>As mentioned above, Buildroot is basically a set of Makefiles that
  2312. download, configure, and compile software with the correct options. It
  2313. also includes patches for various software packages - mainly the ones
  2314. involved in the cross-compilation toolchain (<code class="literal">gcc</code>, <code class="literal">binutils</code> and
  2315. <code class="literal">uClibc</code>).</p><p>There is basically one Makefile per software package, and they are
  2316. named with the <code class="literal">.mk</code> extension. Makefiles are split into many different
  2317. parts.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2318. The <code class="literal">toolchain/</code> directory contains the Makefiles
  2319. and associated files for all software related to the
  2320. cross-compilation toolchain: <code class="literal">binutils</code>, <code class="literal">gcc</code>, <code class="literal">gdb</code>,
  2321. <code class="literal">kernel-headers</code> and <code class="literal">uClibc</code>.
  2322. </li><li class="listitem">
  2323. The <code class="literal">arch/</code> directory contains the definitions for all the processor
  2324. architectures that are supported by Buildroot.
  2325. </li><li class="listitem">
  2326. The <code class="literal">package/</code> directory contains the Makefiles and
  2327. associated files for all user-space tools and libraries that Buildroot
  2328. can compile and add to the target root filesystem. There is one
  2329. sub-directory per package.
  2330. </li><li class="listitem">
  2331. The <code class="literal">linux/</code> directory contains the Makefiles and associated files for
  2332. the Linux kernel.
  2333. </li><li class="listitem">
  2334. The <code class="literal">boot/</code> directory contains the Makefiles and associated files for
  2335. the bootloaders supported by Buildroot.
  2336. </li><li class="listitem">
  2337. The <code class="literal">system/</code> directory contains support for system integration, e.g.
  2338. the target filesystem skeleton and the selection of an init system.
  2339. </li><li class="listitem">
  2340. The <code class="literal">fs/</code> directory contains the Makefiles and
  2341. associated files for software related to the generation of the
  2342. target root filesystem image.
  2343. </li></ul></div><p>Each directory contains at least 2 files:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2344. <code class="literal">something.mk</code> is the Makefile that downloads, configures,
  2345. compiles and installs the package <code class="literal">something</code>.
  2346. </li><li class="listitem">
  2347. <code class="literal">Config.in</code> is a part of the configuration tool
  2348. description file. It describes the options related to the
  2349. package.
  2350. </li></ul></div><p>The main Makefile performs the following steps (once the
  2351. configuration is done):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2352. Create all the output directories: <code class="literal">staging</code>, <code class="literal">target</code>, <code class="literal">build</code>,
  2353. etc. in the output directory (<code class="literal">output/</code> by default,
  2354. another value can be specified using <code class="literal">O=</code>)
  2355. </li><li class="listitem">
  2356. Generate the toolchain target. When an internal toolchain is used, this
  2357. means generating the cross-compilation toolchain. When an external
  2358. toolchain is used, this means checking the features of the external
  2359. toolchain and importing it into the Buildroot environment.
  2360. </li><li class="listitem">
  2361. Generate all the targets listed in the <code class="literal">TARGETS</code> variable. This
  2362. variable is filled by all the individual components'
  2363. Makefiles. Generating these targets will trigger the compilation of
  2364. the userspace packages (libraries, programs), the kernel, the
  2365. bootloader and the generation of the root filesystem images,
  2366. depending on the configuration.
  2367. </li></ul></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_coding_style"></a>Chapter 16. Coding style</h2></div></div></div><p>Overall, these coding style rules are here to help you to add new files in
  2368. Buildroot or refactor existing ones.</p><p>If you slightly modify some existing file, the important thing is
  2369. to keep the consistency of the whole file, so you can:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2370. either follow the potentially deprecated coding style used in this
  2371. file,
  2372. </li><li class="listitem">
  2373. or entirely rework it in order to make it comply with these rules.
  2374. </li></ul></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="writing-rules-config-in"></a>16.1. <code class="literal">Config.in</code> file</h2></div></div></div><p><code class="literal">Config.in</code> files contain entries for almost anything configurable in
  2375. Buildroot.</p><p>An entry has the following pattern:</p><pre class="screen">config BR2_PACKAGE_LIBFOO
  2376. bool "libfoo"
  2377. depends on BR2_PACKAGE_LIBBAZ
  2378. select BR2_PACKAGE_LIBBAR
  2379. help
  2380. This is a comment that explains what libfoo is. The help text
  2381. should be wrapped.
  2382. http://foosoftware.org/libfoo/</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2383. The <code class="literal">bool</code>, <code class="literal">depends on</code>, <code class="literal">select</code> and <code class="literal">help</code> lines are indented
  2384. with one tab.
  2385. </li><li class="listitem">
  2386. The help text itself should be indented with one tab and two
  2387. spaces.
  2388. </li><li class="listitem">
  2389. The help text should be wrapped to fit 72 columns, where tab counts
  2390. for 8, so 62 characters in the text itself.
  2391. </li></ul></div><p>The <code class="literal">Config.in</code> files are the input for the configuration tool
  2392. used in Buildroot, which is the regular <span class="emphasis"><em>Kconfig</em></span>. For further
  2393. details about the <span class="emphasis"><em>Kconfig</em></span> language, refer to
  2394. <a class="ulink" href="http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt" target="_top">http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="writing-rules-mk"></a>16.2. The <code class="literal">.mk</code> file</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  2395. Header: The file starts with a header. It contains the module name,
  2396. preferably in lowercase, enclosed between separators made of 80 hashes. A
  2397. blank line is mandatory after the header:
  2398. </p><pre class="screen">################################################################################
  2399. #
  2400. # libfoo
  2401. #
  2402. ################################################################################</pre></li><li class="listitem"><p class="simpara">
  2403. Assignment: use <code class="literal">=</code> preceded and followed by one space:
  2404. </p><pre class="screen">LIBFOO_VERSION = 1.0
  2405. LIBFOO_CONF_OPTS += --without-python-support</pre><p class="simpara">Do not align the <code class="literal">=</code> signs.</p></li><li class="listitem"><p class="simpara">
  2406. Indentation: use tab only:
  2407. </p><pre class="screen">define LIBFOO_REMOVE_DOC
  2408. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/doc \
  2409. $(TARGET_DIR)/usr/share/man/man3/libfoo*
  2410. endef</pre><p class="simpara">Note that commands inside a <code class="literal">define</code> block should always start with a tab,
  2411. so <span class="emphasis"><em>make</em></span> recognizes them as commands.</p></li><li class="listitem"><p class="simpara">
  2412. Optional dependency:
  2413. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p class="simpara">
  2414. Prefer multi-line syntax.
  2415. </p><p class="simpara">YES:</p><pre class="screen">ifeq ($(BR2_PACKAGE_PYTHON),y)
  2416. LIBFOO_CONF_OPTS += --with-python-support
  2417. LIBFOO_DEPENDENCIES += python
  2418. else
  2419. LIBFOO_CONF_OPTS += --without-python-support
  2420. endif</pre><p class="simpara">NO:</p><pre class="screen">LIBFOO_CONF_OPTS += --with$(if $(BR2_PACKAGE_PYTHON),,out)-python-support
  2421. LIBFOO_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON),python,)</pre></li><li class="listitem">
  2422. Keep configure options and dependencies close together.
  2423. </li></ul></div></li><li class="listitem"><p class="simpara">
  2424. Optional hooks: keep hook definition and assignment together in one
  2425. if block.
  2426. </p><p class="simpara">YES:</p><pre class="screen">ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  2427. define LIBFOO_REMOVE_DATA
  2428. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
  2429. endef
  2430. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  2431. endif</pre><p class="simpara">NO:</p><pre class="screen">define LIBFOO_REMOVE_DATA
  2432. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
  2433. endef
  2434. ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  2435. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  2436. endif</pre></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_the_documentation"></a>16.3. The documentation</h2></div></div></div><p>The documentation uses the
  2437. <a class="ulink" href="http://www.methods.co.nz/asciidoc/" target="_top">asciidoc</a> format.</p><p>For further details about the asciidoc syntax, refer to
  2438. <a class="ulink" href="http://www.methods.co.nz/asciidoc/userguide.html" target="_top">http://www.methods.co.nz/asciidoc/userguide.html</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_support_scripts"></a>16.4. Support scripts</h2></div></div></div><p>Some scripts in the <code class="literal">support/</code> and <code class="literal">utils/</code> directories are written in
  2439. Python and should follow the
  2440. <a class="ulink" href="https://www.python.org/dev/peps/pep-0008/" target="_top">PEP8 Style Guide for Python Code</a>.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="adding-board-support"></a>Chapter 17. Adding support for a particular board</h2></div></div></div><p>Buildroot contains basic configurations for several publicly available
  2441. hardware boards, so that users of such a board can easily build a system
  2442. that is known to work. You are welcome to add support for other boards
  2443. to Buildroot too.</p><p>To do so, you need to create a normal Buildroot configuration that
  2444. builds a basic system for the hardware: (internal) toolchain, kernel,
  2445. bootloader, filesystem and a simple BusyBox-only userspace. No specific
  2446. package should be selected: the configuration should be as minimal as
  2447. possible, and should only build a working basic BusyBox system for the
  2448. target platform. You can of course use more complicated configurations
  2449. for your internal projects, but the Buildroot project will only
  2450. integrate basic board configurations. This is because package
  2451. selections are highly application-specific.</p><p>Once you have a known working configuration, run <code class="literal">make
  2452. savedefconfig</code>. This will generate a minimal <code class="literal">defconfig</code> file at the
  2453. root of the Buildroot source tree. Move this file into the <code class="literal">configs/</code>
  2454. directory, and rename it <code class="literal">&lt;boardname&gt;_defconfig</code>. If the configuration
  2455. is a bit more complicated, it is nice to manually reformat it and
  2456. separate it into sections, with a comment before each section. Typical
  2457. sections are <span class="emphasis"><em>Architecture</em></span>, <span class="emphasis"><em>Toolchain options</em></span> (typically just linux
  2458. headers version), <span class="emphasis"><em>Firmware</em></span>, <span class="emphasis"><em>Bootloader</em></span>, <span class="emphasis"><em>Kernel</em></span>, and <span class="emphasis"><em>Filesystem</em></span>.</p><p>Always use fixed versions or commit hashes for the different
  2459. components, not the "latest" version. For example, set
  2460. <code class="literal">BR2_LINUX_KERNEL_CUSTOM_VERSION=y</code> and
  2461. <code class="literal">BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE</code> to the kernel version you tested
  2462. with.</p><p>It is recommended to use as much as possible upstream versions of the
  2463. Linux kernel and bootloaders, and to use as much as possible default
  2464. kernel and bootloader configurations. If they are incorrect for your
  2465. board, or no default exists, we encourage you to send fixes to the
  2466. corresponding upstream projects.</p><p>However, in the mean time, you may want to store kernel or bootloader
  2467. configuration or patches specific to your target platform. To do so,
  2468. create a directory <code class="literal">board/&lt;manufacturer&gt;</code> and a subdirectory
  2469. <code class="literal">board/&lt;manufacturer&gt;/&lt;boardname&gt;</code>. You can then store your patches
  2470. and configurations in these directories, and reference them from the main
  2471. Buildroot configuration. Refer to <a class="xref" href="#customize" title="Chapter 9. Project-specific customization">Chapter 9, <em>Project-specific customization</em></a> for more details.</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="adding-packages"></a>Chapter 18. Adding new packages to Buildroot</h2></div></div></div><p>This section covers how new packages (userspace libraries or
  2472. applications) can be integrated into Buildroot. It also shows how
  2473. existing packages are integrated, which is needed for fixing issues or
  2474. tuning their configuration.</p><p>When you add a new package, be sure to test it in various conditions
  2475. (see <a class="xref" href="#testing-package" title="18.24.3. How to test your package">Section 18.24.3, “How to test your package”</a>) and also check it for coding style (see
  2476. <a class="xref" href="#check-package" title="18.24.2. How to check the coding style">Section 18.24.2, “How to check the coding style”</a>).</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_package_directory"></a>18.1. Package directory</h2></div></div></div><p>First of all, create a directory under the <code class="literal">package</code> directory for
  2477. your software, for example <code class="literal">libfoo</code>.</p><p>Some packages have been grouped by topic in a sub-directory:
  2478. <code class="literal">x11r7</code>, <code class="literal">qt5</code> and <code class="literal">gstreamer</code>. If your package fits in
  2479. one of these categories, then create your package directory in these.
  2480. New subdirectories are discouraged, however.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_config_files"></a>18.2. Config files</h2></div></div></div><p>For the package to be displayed in the configuration tool, you need to
  2481. create a Config file in your package directory. There are two types:
  2482. <code class="literal">Config.in</code> and <code class="literal">Config.in.host</code>.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_literal_config_in_literal_file"></a>18.2.1. <code class="literal">Config.in</code> file</h3></div></div></div><p>For packages used on the target, create a file named <code class="literal">Config.in</code>. This
  2483. file will contain the option descriptions related to our <code class="literal">libfoo</code> software
  2484. that will be used and displayed in the configuration tool. It should basically
  2485. contain:</p><pre class="screen">config BR2_PACKAGE_LIBFOO
  2486. bool "libfoo"
  2487. help
  2488. This is a comment that explains what libfoo is. The help text
  2489. should be wrapped.
  2490. http://foosoftware.org/libfoo/</pre><p>The <code class="literal">bool</code> line, <code class="literal">help</code> line and other metadata information about the
  2491. configuration option must be indented with one tab. The help text
  2492. itself should be indented with one tab and two spaces, lines should
  2493. be wrapped to fit 72 columns, where tab counts for 8, so 62 characters
  2494. in the text itself. The help text must mention the upstream URL of the
  2495. project after an empty line.</p><p>As a convention specific to Buildroot, the ordering of the attributes
  2496. is as follows:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  2497. The type of option: <code class="literal">bool</code>, <code class="literal">string</code>… with the prompt
  2498. </li><li class="listitem">
  2499. If needed, the <code class="literal">default</code> value(s)
  2500. </li><li class="listitem">
  2501. Any dependencies on the target in <code class="literal">depends on</code> form
  2502. </li><li class="listitem">
  2503. Any dependencies on the toolchain in <code class="literal">depends on</code> form
  2504. </li><li class="listitem">
  2505. Any dependencies on other packages in <code class="literal">depends on</code> form
  2506. </li><li class="listitem">
  2507. Any dependency of the <code class="literal">select</code> form
  2508. </li><li class="listitem">
  2509. The help keyword and help text.
  2510. </li></ol></div><p>You can add other sub-options into a <code class="literal">if BR2_PACKAGE_LIBFOO…endif</code>
  2511. statement to configure particular things in your software. You can look at
  2512. examples in other packages. The syntax of the <code class="literal">Config.in</code> file is the same
  2513. as the one for the kernel Kconfig file. The documentation for this syntax is
  2514. available at <a class="ulink" href="http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt" target="_top">http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt</a></p><p>Finally you have to add your new <code class="literal">libfoo/Config.in</code> to
  2515. <code class="literal">package/Config.in</code> (or in a category subdirectory if you decided to
  2516. put your package in one of the existing categories). The files
  2517. included there are <span class="emphasis"><em>sorted alphabetically</em></span> per category and are <span class="emphasis"><em>NOT</em></span>
  2518. supposed to contain anything but the <span class="emphasis"><em>bare</em></span> name of the package.</p><pre class="screen">source "package/libfoo/Config.in"</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_literal_config_in_host_literal_file"></a>18.2.2. <code class="literal">Config.in.host</code> file</h3></div></div></div><p>Some packages also need to be built for the host system. There are two
  2519. options here:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2520. The host package is only required to satisfy build-time
  2521. dependencies of one or more target packages. In this case, add
  2522. <code class="literal">host-foo</code> to the target package’s <code class="literal">BAR_DEPENDENCIES</code> variable. No
  2523. <code class="literal">Config.in.host</code> file should be created.
  2524. </li><li class="listitem"><p class="simpara">
  2525. The host package should be explicitly selectable by the user from
  2526. the configuration menu. In this case, create a <code class="literal">Config.in.host</code> file
  2527. for that host package:
  2528. </p><pre class="screen">config BR2_PACKAGE_HOST_FOO
  2529. bool "host foo"
  2530. help
  2531. This is a comment that explains what foo for the host is.
  2532. http://foosoftware.org/foo/</pre><p class="simpara">The same coding style and options as for the <code class="literal">Config.in</code> file are valid.</p><p class="simpara">Finally you have to add your new <code class="literal">libfoo/Config.in.host</code> to
  2533. <code class="literal">package/Config.in.host</code>. The files included there are <span class="emphasis"><em>sorted alphabetically</em></span>
  2534. and are <span class="emphasis"><em>NOT</em></span> supposed to contain anything but the <span class="emphasis"><em>bare</em></span> name of the package.</p><pre class="screen">source "package/foo/Config.in.host"</pre><p class="simpara">The host package will then be available from the <code class="literal">Host utilities</code> menu.</p></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="depends-on-vs-select"></a>18.2.3. Choosing <code class="literal">depends on</code> or <code class="literal">select</code></h3></div></div></div><p>The <code class="literal">Config.in</code> file of your package must also ensure that
  2535. dependencies are enabled. Typically, Buildroot uses the following
  2536. rules:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2537. Use a <code class="literal">select</code> type of dependency for dependencies on
  2538. libraries. These dependencies are generally not obvious and it
  2539. therefore make sense to have the kconfig system ensure that the
  2540. dependencies are selected. For example, the <span class="emphasis"><em>libgtk2</em></span> package uses
  2541. <code class="literal">select BR2_PACKAGE_LIBGLIB2</code> to make sure this library is also
  2542. enabled.
  2543. The <code class="literal">select</code> keyword expresses the dependency with a backward
  2544. semantic.
  2545. </li><li class="listitem">
  2546. Use a <code class="literal">depends on</code> type of dependency when the user really needs to
  2547. be aware of the dependency. Typically, Buildroot uses this type of
  2548. dependency for dependencies on target architecture, MMU support and
  2549. toolchain options (see <a class="xref" href="#dependencies-target-toolchain-options" title="18.2.4. Dependencies on target and toolchain options">Section 18.2.4, “Dependencies on target and toolchain options”</a>),
  2550. or for dependencies on "big" things, such as the X.org system.
  2551. The <code class="literal">depends on</code> keyword expresses the dependency with a forward
  2552. semantic.
  2553. </li></ul></div><p><strong>Note. </strong>The current problem with the <span class="emphasis"><em>kconfig</em></span> language is that these two
  2554. dependency semantics are not internally linked. Therefore, it may be
  2555. possible to select a package, whom one of its dependencies/requirement
  2556. is not met.</p><p>An example illustrates both the usage of <code class="literal">select</code> and <code class="literal">depends on</code>.</p><pre class="screen">config BR2_PACKAGE_RRDTOOL
  2557. bool "rrdtool"
  2558. depends on BR2_USE_WCHAR
  2559. select BR2_PACKAGE_FREETYPE
  2560. select BR2_PACKAGE_LIBART
  2561. select BR2_PACKAGE_LIBPNG
  2562. select BR2_PACKAGE_ZLIB
  2563. help
  2564. RRDtool is the OpenSource industry standard, high performance
  2565. data logging and graphing system for time series data.
  2566. http://oss.oetiker.ch/rrdtool/
  2567. comment "rrdtool needs a toolchain w/ wchar"
  2568. depends on !BR2_USE_WCHAR</pre><p>Note that these two dependency types are only transitive with the
  2569. dependencies of the same kind.</p><p>This means, in the following example:</p><pre class="screen">config BR2_PACKAGE_A
  2570. bool "Package A"
  2571. config BR2_PACKAGE_B
  2572. bool "Package B"
  2573. depends on BR2_PACKAGE_A
  2574. config BR2_PACKAGE_C
  2575. bool "Package C"
  2576. depends on BR2_PACKAGE_B
  2577. config BR2_PACKAGE_D
  2578. bool "Package D"
  2579. select BR2_PACKAGE_B
  2580. config BR2_PACKAGE_E
  2581. bool "Package E"
  2582. select BR2_PACKAGE_D</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2583. Selecting <code class="literal">Package C</code> will be visible if <code class="literal">Package B</code> has been
  2584. selected, which in turn is only visible if <code class="literal">Package A</code> has been
  2585. selected.
  2586. </li><li class="listitem">
  2587. Selecting <code class="literal">Package E</code> will select <code class="literal">Package D</code>, which will select
  2588. <code class="literal">Package B</code>, it will not check for the dependencies of <code class="literal">Package B</code>,
  2589. so it will not select <code class="literal">Package A</code>.
  2590. </li><li class="listitem">
  2591. Since <code class="literal">Package B</code> is selected but <code class="literal">Package A</code> is not, this violates
  2592. the dependency of <code class="literal">Package B</code> on <code class="literal">Package A</code>. Therefore, in such a
  2593. situation, the transitive dependency has to be added explicitly:
  2594. </li></ul></div><pre class="screen">config BR2_PACKAGE_D
  2595. bool "Package D"
  2596. select BR2_PACKAGE_B
  2597. depends on BR2_PACKAGE_A
  2598. config BR2_PACKAGE_E
  2599. bool "Package E"
  2600. select BR2_PACKAGE_D
  2601. depends on BR2_PACKAGE_A</pre><p>Overall, for package library dependencies, <code class="literal">select</code> should be
  2602. preferred.</p><p>Note that such dependencies will ensure that the dependency option
  2603. is also enabled, but not necessarily built before your package. To do
  2604. so, the dependency also needs to be expressed in the <code class="literal">.mk</code> file of the
  2605. package.</p><p>Further formatting details: see <a class="link" href="#writing-rules-config-in" title="16.1. Config.in file">the
  2606. coding style</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="dependencies-target-toolchain-options"></a>18.2.4. Dependencies on target and toolchain options</h3></div></div></div><p>Many packages depend on certain options of the toolchain: the choice of
  2607. C library, C++ support, thread support, RPC support, wchar support,
  2608. or dynamic library support. Some packages can only be built on certain
  2609. target architectures, or if an MMU is available in the processor.</p><p>These dependencies have to be expressed with the appropriate <span class="emphasis"><em>depends
  2610. on</em></span> statements in the Config.in file. Additionally, for dependencies on
  2611. toolchain options, a <code class="literal">comment</code> should be displayed when the option is
  2612. not enabled, so that the user knows why the package is not available.
  2613. Dependencies on target architecture or MMU support should not be
  2614. made visible in a comment: since it is unlikely that the user can
  2615. freely choose another target, it makes little sense to show these
  2616. dependencies explicitly.</p><p>The <code class="literal">comment</code> should only be visible if the <code class="literal">config</code> option itself would
  2617. be visible when the toolchain option dependencies are met. This means
  2618. that all other dependencies of the package (including dependencies on
  2619. target architecture and MMU support) have to be repeated on the
  2620. <code class="literal">comment</code> definition. To keep it clear, the <code class="literal">depends on</code> statement for
  2621. these non-toolchain option should be kept separate from the <code class="literal">depends on</code>
  2622. statement for the toolchain options.
  2623. If there is a dependency on a config option in that same file (typically
  2624. the main package) it is preferable to have a global <code class="literal">if … endif</code>
  2625. construct rather than repeating the <code class="literal">depends on</code> statement on the
  2626. comment and other config options.</p><p>The general format of a dependency <code class="literal">comment</code> for package foo is:</p><pre class="screen">foo needs a toolchain w/ featA, featB, featC</pre><p>for example:</p><pre class="screen">mpd needs a toolchain w/ C++, threads, wchar</pre><p>or</p><pre class="screen">crda needs a toolchain w/ threads</pre><p>Note that this text is kept brief on purpose, so that it will fit on a
  2627. 80-character terminal.</p><p>The rest of this section enumerates the different target and toolchain
  2628. options, the corresponding config symbols to depend on, and the text to
  2629. use in the comment.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  2630. Target architecture
  2631. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2632. Dependency symbol: <code class="literal">BR2_powerpc</code>, <code class="literal">BR2_mips</code>, … (see <code class="literal">arch/Config.in</code>)
  2633. </li><li class="listitem">
  2634. Comment string: no comment to be added
  2635. </li></ul></div></li><li class="listitem"><p class="simpara">
  2636. MMU support
  2637. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2638. Dependency symbol: <code class="literal">BR2_USE_MMU</code>
  2639. </li><li class="listitem">
  2640. Comment string: no comment to be added
  2641. </li></ul></div></li><li class="listitem"><p class="simpara">
  2642. Gcc <code class="literal"><span class="emphasis"><em>_sync</em></span>*</code> built-ins used for atomic operations. They are
  2643. available in variants operating on 1 byte, 2 bytes, 4 bytes and 8
  2644. bytes. Since different architectures support atomic operations on
  2645. different sizes, one dependency symbol is available for each size:
  2646. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2647. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_SYNC_1</code> for 1 byte,
  2648. <code class="literal">BR2_TOOLCHAIN_HAS_SYNC_2</code> for 2 bytes,
  2649. <code class="literal">BR2_TOOLCHAIN_HAS_SYNC_4</code> for 4 bytes, <code class="literal">BR2_TOOLCHAIN_HAS_SYNC_8</code>
  2650. for 8 bytes.
  2651. </li><li class="listitem">
  2652. Comment string: no comment to be added
  2653. </li></ul></div></li><li class="listitem"><p class="simpara">
  2654. Gcc <code class="literal"><span class="emphasis"><em>_atomic</em></span>*</code> built-ins used for atomic operations.
  2655. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2656. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_ATOMIC</code>.
  2657. </li><li class="listitem">
  2658. Comment string: no comment to be added
  2659. </li></ul></div></li><li class="listitem"><p class="simpara">
  2660. Kernel headers
  2661. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2662. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y</code>, (replace
  2663. <code class="literal">X_Y</code> with the proper version, see <code class="literal">toolchain/Config.in</code>)
  2664. </li><li class="listitem">
  2665. Comment string: <code class="literal">headers &gt;= X.Y</code> and/or <code class="literal">headers &lt;= X.Y</code> (replace
  2666. <code class="literal">X.Y</code> with the proper version)
  2667. </li></ul></div></li><li class="listitem"><p class="simpara">
  2668. GCC version
  2669. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2670. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_GCC_AT_LEAST_X_Y</code>, (replace
  2671. <code class="literal">X_Y</code> with the proper version, see <code class="literal">toolchain/Config.in</code>)
  2672. </li><li class="listitem">
  2673. Comment string: <code class="literal">gcc &gt;= X.Y</code> and/or <code class="literal">gcc &lt;= X.Y</code> (replace
  2674. <code class="literal">X.Y</code> with the proper version)
  2675. </li></ul></div></li><li class="listitem"><p class="simpara">
  2676. Host GCC version
  2677. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2678. Dependency symbol: <code class="literal">BR2_HOST_GCC_AT_LEAST_X_Y</code>, (replace
  2679. <code class="literal">X_Y</code> with the proper version, see <code class="literal">Config.in</code>)
  2680. </li><li class="listitem">
  2681. Comment string: no comment to be added
  2682. </li><li class="listitem">
  2683. Note that it is usually not the package itself that has a minimum
  2684. host GCC version, but rather a host-package on which it depends.
  2685. </li></ul></div></li><li class="listitem"><p class="simpara">
  2686. C library
  2687. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2688. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_USES_GLIBC</code>,
  2689. <code class="literal">BR2_TOOLCHAIN_USES_MUSL</code>, <code class="literal">BR2_TOOLCHAIN_USES_UCLIBC</code>
  2690. </li><li class="listitem">
  2691. Comment string: for the C library, a slightly different comment text
  2692. is used: <code class="literal">foo needs a glibc toolchain</code>, or <code class="literal">foo needs a glibc
  2693. toolchain w/ C++</code>
  2694. </li></ul></div></li><li class="listitem"><p class="simpara">
  2695. C++ support
  2696. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2697. Dependency symbol: <code class="literal">BR2_INSTALL_LIBSTDCPP</code>
  2698. </li><li class="listitem">
  2699. Comment string: <code class="literal">C++</code>
  2700. </li></ul></div></li><li class="listitem"><p class="simpara">
  2701. D support
  2702. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2703. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_DLANG</code>
  2704. </li><li class="listitem">
  2705. Comment string: <code class="literal">Dlang</code>
  2706. </li></ul></div></li><li class="listitem"><p class="simpara">
  2707. Fortran support
  2708. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2709. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_FORTRAN</code>
  2710. </li><li class="listitem">
  2711. Comment string: <code class="literal">fortran</code>
  2712. </li></ul></div></li><li class="listitem"><p class="simpara">
  2713. thread support
  2714. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2715. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_THREADS</code>
  2716. </li><li class="listitem">
  2717. Comment string: <code class="literal">threads</code> (unless <code class="literal">BR2_TOOLCHAIN_HAS_THREADS_NPTL</code>
  2718. is also needed, in which case, specifying only <code class="literal">NPTL</code> is sufficient)
  2719. </li></ul></div></li><li class="listitem"><p class="simpara">
  2720. NPTL thread support
  2721. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2722. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_THREADS_NPTL</code>
  2723. </li><li class="listitem">
  2724. Comment string: <code class="literal">NPTL</code>
  2725. </li></ul></div></li><li class="listitem"><p class="simpara">
  2726. RPC support
  2727. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2728. Dependency symbol: <code class="literal">BR2_TOOLCHAIN_HAS_NATIVE_RPC</code>
  2729. </li><li class="listitem">
  2730. Comment string: <code class="literal">RPC</code>
  2731. </li></ul></div></li><li class="listitem"><p class="simpara">
  2732. wchar support
  2733. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2734. Dependency symbol: <code class="literal">BR2_USE_WCHAR</code>
  2735. </li><li class="listitem">
  2736. Comment string: <code class="literal">wchar</code>
  2737. </li></ul></div></li><li class="listitem"><p class="simpara">
  2738. dynamic library
  2739. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2740. Dependency symbol: <code class="literal">!BR2_STATIC_LIBS</code>
  2741. </li><li class="listitem">
  2742. Comment string: <code class="literal">dynamic library</code>
  2743. </li></ul></div></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_dependencies_on_a_linux_kernel_built_by_buildroot"></a>18.2.5. Dependencies on a Linux kernel built by buildroot</h3></div></div></div><p>Some packages need a Linux kernel to be built by buildroot. These are
  2744. typically kernel modules or firmware. A comment should be added in the
  2745. Config.in file to express this dependency, similar to dependencies on
  2746. toolchain options. The general format is:</p><pre class="screen">foo needs a Linux kernel to be built</pre><p>If there is a dependency on both toolchain options and the Linux
  2747. kernel, use this format:</p><pre class="screen">foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_dependencies_on_udev_dev_management"></a>18.2.6. Dependencies on udev /dev management</h3></div></div></div><p>If a package needs udev /dev management, it should depend on symbol
  2748. <code class="literal">BR2_PACKAGE_HAS_UDEV</code>, and the following comment should be added:</p><pre class="screen">foo needs udev /dev management</pre><p>If there is a dependency on both toolchain options and udev /dev
  2749. management, use this format:</p><pre class="screen">foo needs udev /dev management and a toolchain w/ featA, featB, featC</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_dependencies_on_features_provided_by_virtual_packages"></a>18.2.7. Dependencies on features provided by virtual packages</h3></div></div></div><p>Some features can be provided by more than one package, such as the
  2750. openGL libraries.</p><p>See <a class="xref" href="#virtual-package-tutorial">Section 18.11, “Infrastructure for virtual packages”</a> for more on the virtual packages.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_the_literal_mk_literal_file"></a>18.3. The <code class="literal">.mk</code> file</h2></div></div></div><p><a id="adding-packages-mk"></a>Finally, here’s the hardest part. Create a file named <code class="literal">libfoo.mk</code>. It
  2751. describes how the package should be downloaded, configured, built,
  2752. installed, etc.</p><p>Depending on the package type, the <code class="literal">.mk</code> file must be written in a
  2753. different way, using different infrastructures:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  2754. <span class="strong"><strong>Makefiles for generic packages</strong></span> (not using autotools or CMake):
  2755. These are based on an infrastructure similar to the one used for
  2756. autotools-based packages, but require a little more work from the
  2757. developer. They specify what should be done for the configuration,
  2758. compilation and installation of the package. This
  2759. infrastructure must be used for all packages that do not use the
  2760. autotools as their build system. In the future, other specialized
  2761. infrastructures might be written for other build systems. We cover
  2762. them through in a <a class="link" href="#generic-package-tutorial" title="18.5.1. generic-package tutorial">tutorial</a> and a
  2763. <a class="link" href="#generic-package-reference" title="18.5.2. generic-package reference">reference</a>.
  2764. </li><li class="listitem">
  2765. <span class="strong"><strong>Makefiles for autotools-based software</strong></span> (autoconf, automake, etc.):
  2766. We provide a dedicated infrastructure for such packages, since
  2767. autotools is a very common build system. This infrastructure <span class="emphasis"><em>must</em></span>
  2768. be used for new packages that rely on the autotools as their build
  2769. system. We cover them through a <a class="link" href="#autotools-package-tutorial" title="18.6.1. autotools-package tutorial">tutorial</a>
  2770. and <a class="link" href="#autotools-package-reference" title="18.6.2. autotools-package reference">reference</a>.
  2771. </li><li class="listitem">
  2772. <span class="strong"><strong>Makefiles for cmake-based software</strong></span>: We provide a dedicated
  2773. infrastructure for such packages, as CMake is a more and more
  2774. commonly used build system and has a standardized behaviour. This
  2775. infrastructure <span class="emphasis"><em>must</em></span> be used for new packages that rely on
  2776. CMake. We cover them through a <a class="link" href="#cmake-package-tutorial" title="18.7.1. cmake-package tutorial">tutorial</a>
  2777. and <a class="link" href="#cmake-package-reference" title="18.7.2. cmake-package reference">reference</a>.
  2778. </li><li class="listitem">
  2779. <span class="strong"><strong>Makefiles for Python modules</strong></span>: We have a dedicated infrastructure
  2780. for Python modules that use either the <code class="literal">distutils</code> or the
  2781. <code class="literal">setuptools</code> mechanism. We cover them through a
  2782. <a class="link" href="#python-package-tutorial" title="18.8.1. python-package tutorial">tutorial</a> and a
  2783. <a class="link" href="#python-package-reference" title="18.8.2. python-package reference">reference</a>.
  2784. </li><li class="listitem">
  2785. <span class="strong"><strong>Makefiles for Lua modules</strong></span>: We have a dedicated infrastructure for
  2786. Lua modules available through the LuaRocks web site. We cover them
  2787. through a <a class="link" href="#luarocks-package-tutorial" title="18.9.1. luarocks-package tutorial">tutorial</a> and a
  2788. <a class="link" href="#luarocks-package-reference" title="18.9.2. luarocks-package reference">reference</a>.
  2789. </li></ul></div><p>Further formatting details: see <a class="link" href="#writing-rules-mk" title="16.2. The .mk file">the writing
  2790. rules</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="adding-packages-hash"></a>18.4. The <code class="literal">.hash</code> file</h2></div></div></div><p>When possible, you must add a third file, named <code class="literal">libfoo.hash</code>, that
  2791. contains the hashes of the downloaded files for the <code class="literal">libfoo</code>
  2792. package. The only reason for not adding a <code class="literal">.hash</code> file is when hash
  2793. checking is not possible due to how the package is downloaded.</p><p>When a package has a version selection choice, then the hash file may be
  2794. stored in a subdirectory named after the version, e.g.
  2795. <code class="literal">package/libfoo/1.2.3/libfoo.hash</code>. This is especially important if the
  2796. different versions have different licensing terms, but they are stored
  2797. in the same file. Otherwise, the hash file should stay in the package’s
  2798. directory.</p><p>The hashes stored in that file are used to validate the integrity of the
  2799. downloaded files and of the license files.</p><p>The format of this file is one line for each file for which to check the
  2800. hash, each line with the following three fields separated by two spaces:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  2801. the type of hash, one of:
  2802. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2803. <code class="literal">md5</code>, <code class="literal">sha1</code>, <code class="literal">sha224</code>, <code class="literal">sha256</code>, <code class="literal">sha384</code>, <code class="literal">sha512</code>, <code class="literal">none</code>
  2804. </li></ul></div></li><li class="listitem"><p class="simpara">
  2805. the hash of the file:
  2806. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2807. for <code class="literal">none</code>, one or more non-space chars, usually just the string <code class="literal">xxx</code>
  2808. </li><li class="listitem">
  2809. for <code class="literal">md5</code>, 32 hexadecimal characters
  2810. </li><li class="listitem">
  2811. for <code class="literal">sha1</code>, 40 hexadecimal characters
  2812. </li><li class="listitem">
  2813. for <code class="literal">sha224</code>, 56 hexadecimal characters
  2814. </li><li class="listitem">
  2815. for <code class="literal">sha256</code>, 64 hexadecimal characters
  2816. </li><li class="listitem">
  2817. for <code class="literal">sha384</code>, 96 hexadecimal characters
  2818. </li><li class="listitem">
  2819. for <code class="literal">sha512</code>, 128 hexadecimal characters
  2820. </li></ul></div></li><li class="listitem"><p class="simpara">
  2821. the name of the file:
  2822. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2823. for a source archive: the basename of the file, without any directory
  2824. component,
  2825. </li><li class="listitem">
  2826. for a license file: the path as it appears in <code class="literal">FOO_LICENSE_FILES</code>.
  2827. </li></ul></div></li></ul></div><p>Lines starting with a <code class="literal">#</code> sign are considered comments, and ignored. Empty
  2828. lines are ignored.</p><p>There can be more than one hash for a single file, each on its own line. In
  2829. this case, all hashes must match.</p><p><strong>Note. </strong>Ideally, the hashes stored in this file should match the hashes published by
  2830. upstream, e.g. on their website, in the e-mail announcement… If upstream
  2831. provides more than one type of hash (e.g. <code class="literal">sha1</code> and <code class="literal">sha512</code>), then it is
  2832. best to add all those hashes in the <code class="literal">.hash</code> file. If upstream does not
  2833. provide any hash, or only provides an <code class="literal">md5</code> hash, then compute at least one
  2834. strong hash yourself (preferably <code class="literal">sha256</code>, but not <code class="literal">md5</code>), and mention
  2835. this in a comment line above the hashes.</p><p><strong>Note. </strong>The hashes for license files are used to detect a license change when a
  2836. package version is bumped. The hashes are checked during the make legal-info
  2837. target run. For a package with multiple versions (like Qt5),
  2838. create the hash file in a subdirectory <code class="literal">&lt;packageversion&gt;</code> of that package
  2839. (see also <a class="xref" href="#patch-apply-order" title="19.2. How patches are applied">Section 19.2, “How patches are applied”</a>).</p><p>The <code class="literal">none</code> hash type is reserved to those archives downloaded from a
  2840. repository, like a <span class="emphasis"><em>git clone</em></span>, a <span class="emphasis"><em>subversion checkout</em></span>…</p><p>The example below defines a <code class="literal">sha1</code> and a <code class="literal">sha256</code> published by upstream for
  2841. the main <code class="literal">libfoo-1.2.3.tar.bz2</code> tarball, an <code class="literal">md5</code> from upstream and a
  2842. locally-computed <code class="literal">sha256</code> hashes for a binary blob, a <code class="literal">sha256</code> for a
  2843. downloaded patch, and an archive with no hash:</p><pre class="screen"># Hashes from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.{sha1,sha256}:
  2844. sha1 486fb55c3efa71148fe07895fd713ea3a5ae343a libfoo-1.2.3.tar.bz2
  2845. sha256 efc8103cc3bcb06bda6a781532d12701eb081ad83e8f90004b39ab81b65d4369 libfoo-1.2.3.tar.bz2
  2846. # md5 from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.md5, sha256 locally computed:
  2847. md5 2d608f3c318c6b7557d551a5a09314f03452f1a1 libfoo-data.bin
  2848. sha256 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b libfoo-data.bin
  2849. # Locally computed:
  2850. sha256 ff52101fb90bbfc3fe9475e425688c660f46216d7e751c4bbdb1dc85cdccacb9 libfoo-fix-blabla.patch
  2851. # No hash for 1234:
  2852. none xxx libfoo-1234.tar.gz
  2853. # Hash for license files:
  2854. sha256 a45a845012742796534f7e91fe623262ccfb99460a2bd04015bd28d66fba95b8 COPYING
  2855. sha256 01b1f9f2c8ee648a7a596a1abe8aa4ed7899b1c9e5551bda06da6e422b04aa55 doc/COPYING.LGPL</pre><p>If the <code class="literal">.hash</code> file is present, and it contains one or more hashes for a
  2856. downloaded file, the hash(es) computed by Buildroot (after download) must
  2857. match the hash(es) stored in the <code class="literal">.hash</code> file. If one or more hashes do
  2858. not match, Buildroot considers this an error, deletes the downloaded file,
  2859. and aborts.</p><p>If the <code class="literal">.hash</code> file is present, but it does not contain a hash for a
  2860. downloaded file, Buildroot considers this an error and aborts. However,
  2861. the downloaded file is left in the download directory since this
  2862. typically indicates that the <code class="literal">.hash</code> file is wrong but the downloaded
  2863. file is probably OK.</p><p>Hashes are currently checked for files fetched from http/ftp servers,
  2864. Git repositories, files copied using scp and local files. Hashes are
  2865. not checked for other version control systems (such as Subversion,
  2866. CVS, etc.) because Buildroot currently does not generate reproducible
  2867. tarballs when source code is fetched from such version control
  2868. systems.</p><p>Hashes should only be added in <code class="literal">.hash</code> files for files that are
  2869. guaranteed to be stable. For example, patches auto-generated by Github
  2870. are not guaranteed to be stable, and therefore their hashes can change
  2871. over time. Such patches should not be downloaded, and instead be added
  2872. locally to the package folder.</p><p>If the <code class="literal">.hash</code> file is missing, then no check is done at all.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_packages_with_specific_build_systems"></a>18.5. Infrastructure for packages with specific build systems</h2></div></div></div><p>By <span class="emphasis"><em>packages with specific build systems</em></span> we mean all the packages
  2873. whose build system is not one of the standard ones, such as
  2874. <span class="emphasis"><em>autotools</em></span> or <span class="emphasis"><em>CMake</em></span>. This typically includes packages whose build
  2875. system is based on hand-written Makefiles or shell scripts.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="generic-package-tutorial"></a>18.5.1. <code class="literal">generic-package</code> tutorial</h3></div></div></div><pre class="screen">01: ################################################################################
  2876. 02: #
  2877. 03: # libfoo
  2878. 04: #
  2879. 05: ################################################################################
  2880. 06:
  2881. 07: LIBFOO_VERSION = 1.0
  2882. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  2883. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  2884. 10: LIBFOO_LICENSE = GPL-3.0+
  2885. 11: LIBFOO_LICENSE_FILES = COPYING
  2886. 12: LIBFOO_INSTALL_STAGING = YES
  2887. 13: LIBFOO_CONFIG_SCRIPTS = libfoo-config
  2888. 14: LIBFOO_DEPENDENCIES = host-libaaa libbbb
  2889. 15:
  2890. 16: define LIBFOO_BUILD_CMDS
  2891. 17: $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) all
  2892. 18: endef
  2893. 19:
  2894. 20: define LIBFOO_INSTALL_STAGING_CMDS
  2895. 21: $(INSTALL) -D -m 0755 $(@D)/libfoo.a $(STAGING_DIR)/usr/lib/libfoo.a
  2896. 22: $(INSTALL) -D -m 0644 $(@D)/foo.h $(STAGING_DIR)/usr/include/foo.h
  2897. 23: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(STAGING_DIR)/usr/lib
  2898. 24: endef
  2899. 25:
  2900. 26: define LIBFOO_INSTALL_TARGET_CMDS
  2901. 27: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(TARGET_DIR)/usr/lib
  2902. 28: $(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/foo.d
  2903. 29: endef
  2904. 30:
  2905. 31: define LIBFOO_USERS
  2906. 32: foo -1 libfoo -1 * - - - LibFoo daemon
  2907. 33: endef
  2908. 34:
  2909. 35: define LIBFOO_DEVICES
  2910. 36: /dev/foo c 666 0 0 42 0 - - -
  2911. 37: endef
  2912. 38:
  2913. 39: define LIBFOO_PERMISSIONS
  2914. 40: /bin/foo f 4755 foo libfoo - - - - -
  2915. 41: endef
  2916. 42:
  2917. 43: $(eval $(generic-package))</pre><p>The Makefile begins on line 7 to 11 with metadata information: the
  2918. version of the package (<code class="literal">LIBFOO_VERSION</code>), the name of the
  2919. tarball containing the package (<code class="literal">LIBFOO_SOURCE</code>) (xz-ed tarball recommended)
  2920. the Internet location at which the tarball can be downloaded from
  2921. (<code class="literal">LIBFOO_SITE</code>), the license (<code class="literal">LIBFOO_LICENSE</code>) and file with the
  2922. license text (<code class="literal">LIBFOO_LICENSE_FILES</code>). All variables must start with
  2923. the same prefix, <code class="literal">LIBFOO_</code> in this case. This prefix is always the
  2924. uppercased version of the package name (see below to understand where
  2925. the package name is defined).</p><p>On line 12, we specify that this package wants to install something to
  2926. the staging space. This is often needed for libraries, since they must
  2927. install header files and other development files in the staging space.
  2928. This will ensure that the commands listed in the
  2929. <code class="literal">LIBFOO_INSTALL_STAGING_CMDS</code> variable will be executed.</p><p>On line 13, we specify that there is some fixing to be done to some
  2930. of the <span class="emphasis"><em>libfoo-config</em></span> files that were installed during
  2931. <code class="literal">LIBFOO_INSTALL_STAGING_CMDS</code> phase.
  2932. These *-config files are executable shell script files that are
  2933. located in <span class="emphasis"><em>$(STAGING_DIR)/usr/bin</em></span> directory and are executed
  2934. by other 3rd party packages to find out the location and the linking
  2935. flags of this particular package.</p><p>The problem is that all these *-config files by default give wrong,
  2936. host system linking flags that are unsuitable for cross-compiling.</p><p>For example: <span class="emphasis"><em>-I/usr/include</em></span> instead of <span class="emphasis"><em>-I$(STAGING_DIR)/usr/include</em></span>
  2937. or: <span class="emphasis"><em>-L/usr/lib</em></span> instead of <span class="emphasis"><em>-L$(STAGING_DIR)/usr/lib</em></span></p><p>So some sed magic is done to these scripts to make them give correct
  2938. flags.
  2939. The argument to be given to <code class="literal">LIBFOO_CONFIG_SCRIPTS</code> is the file name(s)
  2940. of the shell script(s) needing fixing. All these names are relative to
  2941. <span class="emphasis"><em>$(STAGING_DIR)/usr/bin</em></span> and if needed multiple names can be given.</p><p>In addition, the scripts listed in <code class="literal">LIBFOO_CONFIG_SCRIPTS</code> are removed
  2942. from <code class="literal">$(TARGET_DIR)/usr/bin</code>, since they are not needed on the target.</p><div class="example"><a id="idm3189"></a><p class="title"><strong>Example 18.1. Config script: <span class="emphasis"><em>divine</em></span> package</strong></p><div class="example-contents"><p>Package divine installs shell script <span class="emphasis"><em>$(STAGING_DIR)/usr/bin/divine-config</em></span>.</p><p>So its fixup would be:</p><pre class="screen">DIVINE_CONFIG_SCRIPTS = divine-config</pre></div></div><br class="example-break" /><div class="example"><a id="idm3196"></a><p class="title"><strong>Example 18.2. Config script: <span class="emphasis"><em>imagemagick</em></span> package:</strong></p><div class="example-contents"><p>Package imagemagick installs the following scripts:
  2943. <span class="emphasis"><em>$(STAGING_DIR)/usr/bin/{Magick,Magick++,MagickCore,MagickWand,Wand}-config</em></span></p><p>So it’s fixup would be:</p><pre class="screen">IMAGEMAGICK_CONFIG_SCRIPTS = \
  2944. Magick-config Magick++-config \
  2945. MagickCore-config MagickWand-config Wand-config</pre></div></div><br class="example-break" /><p>On line 14, we specify the list of dependencies this package relies
  2946. on. These dependencies are listed in terms of lower-case package names,
  2947. which can be packages for the target (without the <code class="literal">host-</code>
  2948. prefix) or packages for the host (with the <code class="literal">host-</code>) prefix).
  2949. Buildroot will ensure that all these packages are built and installed
  2950. <span class="emphasis"><em>before</em></span> the current package starts its configuration.</p><p>The rest of the Makefile, lines 16..29, defines what should be done
  2951. at the different steps of the package configuration, compilation and
  2952. installation.
  2953. <code class="literal">LIBFOO_BUILD_CMDS</code> tells what steps should be performed to
  2954. build the package. <code class="literal">LIBFOO_INSTALL_STAGING_CMDS</code> tells what
  2955. steps should be performed to install the package in the staging space.
  2956. <code class="literal">LIBFOO_INSTALL_TARGET_CMDS</code> tells what steps should be
  2957. performed to install the package in the target space.</p><p>All these steps rely on the <code class="literal">$(@D)</code> variable, which
  2958. contains the directory where the source code of the package has been
  2959. extracted.</p><p>On lines 31..33, we define a user that is used by this package (e.g.
  2960. to run a daemon as non-root) (<code class="literal">LIBFOO_USERS</code>).</p><p>On line 35..37, we define a device-node file used by this package
  2961. (<code class="literal">LIBFOO_DEVICES</code>).</p><p>On line 39..41, we define the permissions to set to specific files
  2962. installed by this package (<code class="literal">LIBFOO_PERMISSIONS</code>).</p><p>Finally, on line 43, we call the <code class="literal">generic-package</code> function, which
  2963. generates, according to the variables defined previously, all the
  2964. Makefile code necessary to make your package working.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="generic-package-reference"></a>18.5.2. <code class="literal">generic-package</code> reference</h3></div></div></div><p>There are two variants of the generic target. The <code class="literal">generic-package</code> macro is
  2965. used for packages to be cross-compiled for the target. The
  2966. <code class="literal">host-generic-package</code> macro is used for host packages, natively compiled
  2967. for the host. It is possible to call both of them in a single <code class="literal">.mk</code>
  2968. file: once to create the rules to generate a target
  2969. package and once to create the rules to generate a host package:</p><pre class="screen">$(eval $(generic-package))
  2970. $(eval $(host-generic-package))</pre><p>This might be useful if the compilation of the target package requires
  2971. some tools to be installed on the host. If the package name is
  2972. <code class="literal">libfoo</code>, then the name of the package for the target is also
  2973. <code class="literal">libfoo</code>, while the name of the package for the host is
  2974. <code class="literal">host-libfoo</code>. These names should be used in the DEPENDENCIES
  2975. variables of other packages, if they depend on <code class="literal">libfoo</code> or
  2976. <code class="literal">host-libfoo</code>.</p><p>The call to the <code class="literal">generic-package</code> and/or <code class="literal">host-generic-package</code> macro
  2977. <span class="strong"><strong>must</strong></span> be at the end of the <code class="literal">.mk</code> file, after all variable definitions.
  2978. The call to <code class="literal">host-generic-package</code> <span class="strong"><strong>must</strong></span> be after the call to
  2979. <code class="literal">generic-package</code>, if any.</p><p>For the target package, the <code class="literal">generic-package</code> uses the variables defined by
  2980. the .mk file and prefixed by the uppercased package name:
  2981. <code class="literal">LIBFOO_*</code>. <code class="literal">host-generic-package</code> uses the <code class="literal">HOST_LIBFOO_*</code> variables. For
  2982. <span class="emphasis"><em>some</em></span> variables, if the <code class="literal">HOST_LIBFOO_</code> prefixed variable doesn’t
  2983. exist, the package infrastructure uses the corresponding variable
  2984. prefixed by <code class="literal">LIBFOO_</code>. This is done for variables that are likely to
  2985. have the same value for both the target and host packages. See below
  2986. for details.</p><p>The list of variables that can be set in a <code class="literal">.mk</code> file to give metadata
  2987. information is (assuming the package name is <code class="literal">libfoo</code>) :</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  2988. <code class="literal">LIBFOO_VERSION</code>, mandatory, must contain the version of the
  2989. package. Note that if <code class="literal">HOST_LIBFOO_VERSION</code> doesn’t exist, it is
  2990. assumed to be the same as <code class="literal">LIBFOO_VERSION</code>. It can also be a
  2991. revision number or a tag for packages that are fetched directly
  2992. from their version control system. Examples:
  2993. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  2994. a version for a release tarball: <code class="literal">LIBFOO_VERSION = 0.1.2</code>
  2995. </li><li class="listitem">
  2996. a sha1 for a git tree: <code class="literal">LIBFOO_VERSION = cb9d6aa9429e838f0e54faa3d455bcbab5eef057</code>
  2997. </li><li class="listitem"><p class="simpara">
  2998. a tag for a git tree <code class="literal">LIBFOO_VERSION = v0.1.2</code>
  2999. </p><p><strong>Note: </strong>Using a branch name as <code class="literal">FOO_VERSION</code> is not supported, because it does
  3000. not and can not work as people would expect it should:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  3001. due to local caching, Buildroot will not re-fetch the repository,
  3002. so people who expect to be able to follow the remote repository
  3003. would be quite surprised and disappointed;
  3004. </li><li class="listitem">
  3005. because two builds can never be perfectly simultaneous, and because
  3006. the remote repository may get new commits on the branch anytime,
  3007. two users, using the same Buildroot tree and building the same
  3008. configuration, may get different source, thus rendering the build
  3009. non reproducible, and people would be quite surprised and
  3010. disappointed.
  3011. </li></ol></div></li></ul></div></li><li class="listitem">
  3012. <code class="literal">LIBFOO_SOURCE</code> may contain the name of the tarball of the package,
  3013. which Buildroot will use to download the tarball from
  3014. <code class="literal">LIBFOO_SITE</code>. If <code class="literal">HOST_LIBFOO_SOURCE</code> is not specified, it defaults
  3015. to <code class="literal">LIBFOO_SOURCE</code>. If none are specified, then the value is assumed
  3016. to be <code class="literal">libfoo-$(LIBFOO_VERSION).tar.gz</code>.
  3017. Example: <code class="literal">LIBFOO_SOURCE = foobar-$(LIBFOO_VERSION).tar.bz2</code>
  3018. </li><li class="listitem">
  3019. <code class="literal">LIBFOO_PATCH</code> may contain a space-separated list of patch file
  3020. names, that Buildroot will download and apply to the package source
  3021. code. If an entry contains <code class="literal">://</code>, then Buildroot will assume it is a
  3022. full URL and download the patch from this location. Otherwise,
  3023. Buildroot will assume that the patch should be downloaded from
  3024. <code class="literal">LIBFOO_SITE</code>. If <code class="literal">HOST_LIBFOO_PATCH</code> is not specified, it defaults
  3025. to <code class="literal">LIBFOO_PATCH</code>. Note that patches that are included in Buildroot
  3026. itself use a different mechanism: all files of the form
  3027. <code class="literal">*.patch</code> present in the package directory inside
  3028. Buildroot will be applied to the package after extraction (see
  3029. <a class="link" href="#patch-policy" title="Chapter 19. Patching a package">patching a package</a>). Finally, patches listed in
  3030. the <code class="literal">LIBFOO_PATCH</code> variable are applied <span class="emphasis"><em>before</em></span> the patches stored
  3031. in the Buildroot package directory.
  3032. </li><li class="listitem">
  3033. <code class="literal">LIBFOO_SITE</code> provides the location of the package, which can be a
  3034. URL or a local filesystem path. HTTP, FTP and SCP are supported URL
  3035. types for retrieving package tarballs. In these cases don’t include a
  3036. trailing slash: it will be added by Buildroot between the directory
  3037. and the filename as appropriate. Git, Subversion, Mercurial,
  3038. and Bazaar are supported URL types for retrieving packages directly
  3039. from source code management systems. There is a helper function to make
  3040. it easier to download source tarballs from GitHub (refer to
  3041. <a class="xref" href="#github-download-url" title="18.24.4. How to add a package from GitHub">Section 18.24.4, “How to add a package from GitHub”</a> for details). A filesystem path may be used
  3042. to specify either a tarball or a directory containing the package
  3043. source code. See <code class="literal">LIBFOO_SITE_METHOD</code> below for more details on how
  3044. retrieval works.
  3045. Note that SCP URLs should be of the form
  3046. <code class="literal">scp://[user@]host:filepath</code>, and that filepath is relative to the
  3047. user’s home directory, so you may want to prepend the path with a
  3048. slash for absolute paths:
  3049. <code class="literal">scp://[user@]host:/absolutepath</code>.
  3050. If <code class="literal">HOST_LIBFOO_SITE</code> is not specified, it defaults to
  3051. <code class="literal">LIBFOO_SITE</code>.
  3052. Examples:
  3053. <code class="literal">LIBFOO_SITE=http://www.libfoosoftware.org/libfoo</code>
  3054. <code class="literal">LIBFOO_SITE=http://svn.xiph.org/trunk/Tremor</code>
  3055. <code class="literal">LIBFOO_SITE=/opt/software/libfoo.tar.gz</code>
  3056. <code class="literal">LIBFOO_SITE=$(TOPDIR)/../src/libfoo</code>
  3057. </li><li class="listitem">
  3058. <code class="literal">LIBFOO_DL_OPTS</code> is a space-separated list of additional options to
  3059. pass to the downloader. Useful for retrieving documents with
  3060. server-side checking for user logins and passwords, or to use a proxy.
  3061. All download methods valid for <code class="literal">LIBFOO_SITE_METHOD</code> are supported;
  3062. valid options depend on the download method (consult the man page
  3063. for the respective download utilities).
  3064. </li><li class="listitem">
  3065. <code class="literal">LIBFOO_EXTRA_DOWNLOADS</code> is a space-separated list of additional
  3066. files that Buildroot should download. If an entry contains <code class="literal">://</code>
  3067. then Buildroot will assume it is a complete URL and will download
  3068. the file using this URL. Otherwise, Buildroot will assume the file
  3069. to be downloaded is located at <code class="literal">LIBFOO_SITE</code>. Buildroot will not do
  3070. anything with those additional files, except download them: it will
  3071. be up to the package recipe to use them from <code class="literal">$(LIBFOO_DL_DIR)</code>.
  3072. </li><li class="listitem"><p class="simpara">
  3073. <code class="literal">LIBFOO_SITE_METHOD</code> determines the method used to fetch or copy the
  3074. package source code. In many cases, Buildroot guesses the method
  3075. from the contents of <code class="literal">LIBFOO_SITE</code> and setting <code class="literal">LIBFOO_SITE_METHOD</code>
  3076. is unnecessary. When <code class="literal">HOST_LIBFOO_SITE_METHOD</code> is not specified, it
  3077. defaults to the value of <code class="literal">LIBFOO_SITE_METHOD</code>.
  3078. The possible values of <code class="literal">LIBFOO_SITE_METHOD</code> are:
  3079. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  3080. <code class="literal">wget</code> for normal FTP/HTTP downloads of tarballs. Used by
  3081. default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">http://</code>, <code class="literal">https://</code> or
  3082. <code class="literal">ftp://</code>.
  3083. </li><li class="listitem">
  3084. <code class="literal">scp</code> for downloads of tarballs over SSH with scp. Used by
  3085. default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">scp://</code>.
  3086. </li><li class="listitem">
  3087. <code class="literal">svn</code> for retrieving source code from a Subversion repository.
  3088. Used by default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">svn://</code>. When a
  3089. <code class="literal">http://</code> Subversion repository URL is specified in
  3090. <code class="literal">LIBFOO_SITE</code>, one <span class="emphasis"><em>must</em></span> specify <code class="literal">LIBFOO_SITE_METHOD=svn</code>.
  3091. Buildroot performs a checkout which is preserved as a tarball in
  3092. the download cache; subsequent builds use the tarball instead of
  3093. performing another checkout.
  3094. </li><li class="listitem">
  3095. <code class="literal">cvs</code> for retrieving source code from a CVS repository.
  3096. Used by default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">cvs://</code>.
  3097. The downloaded source code is cached as with the <code class="literal">svn</code> method.
  3098. Anonymous pserver mode is assumed otherwise explicitly defined
  3099. on <code class="literal">LIBFOO_SITE</code>. Both
  3100. <code class="literal">LIBFOO_SITE=cvs://libfoo.net:/cvsroot/libfoo</code> and
  3101. <code class="literal">LIBFOO_SITE=cvs://:ext:libfoo.net:/cvsroot/libfoo</code>
  3102. are accepted, on the former anonymous pserver access mode is
  3103. assumed.
  3104. <code class="literal">LIBFOO_SITE</code> <span class="emphasis"><em>must</em></span> contain the source URL as well as the remote
  3105. repository directory. The module is the package name.
  3106. <code class="literal">LIBFOO_VERSION</code> is <span class="emphasis"><em>mandatory</em></span> and <span class="emphasis"><em>must</em></span> be a tag, a branch, or
  3107. a date (e.g. "2014-10-20", "2014-10-20 13:45", "2014-10-20
  3108. 13:45+01" see "man cvs" for further details).
  3109. </li><li class="listitem">
  3110. <code class="literal">git</code> for retrieving source code from a Git repository. Used by
  3111. default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">git://</code>. The downloaded
  3112. source code is cached as with the <code class="literal">svn</code>
  3113. method.
  3114. </li><li class="listitem">
  3115. <code class="literal">hg</code> for retrieving source code from a Mercurial repository. One
  3116. <span class="emphasis"><em>must</em></span> specify <code class="literal">LIBFOO_SITE_METHOD=hg</code> when <code class="literal">LIBFOO_SITE</code>
  3117. contains a Mercurial repository URL. The downloaded source code
  3118. is cached as with the <code class="literal">svn</code> method.
  3119. </li><li class="listitem">
  3120. <code class="literal">bzr</code> for retrieving source code from a Bazaar repository. Used
  3121. by default when <code class="literal">LIBFOO_SITE</code> begins with <code class="literal">bzr://</code>. The
  3122. downloaded source code is cached as with the <code class="literal">svn</code> method.
  3123. </li><li class="listitem">
  3124. <code class="literal">file</code> for a local tarball. One should use this when
  3125. <code class="literal">LIBFOO_SITE</code> specifies a package tarball as a local filename.
  3126. Useful for software that isn’t available publicly or in version
  3127. control.
  3128. </li><li class="listitem">
  3129. <code class="literal">local</code> for a local source code directory. One should use this
  3130. when <code class="literal">LIBFOO_SITE</code> specifies a local directory path containing
  3131. the package source code. Buildroot copies the contents of the
  3132. source directory into the package’s build directory. Note that
  3133. for <code class="literal">local</code> packages, no patches are applied. If you need to
  3134. still patch the source code, use <code class="literal">LIBFOO_POST_RSYNC_HOOKS</code>, see
  3135. <a class="xref" href="#hooks-rsync" title="18.22.1. Using the POST_RSYNC hook">Section 18.22.1, “Using the <code class="literal">POST_RSYNC</code> hook”</a>.
  3136. </li></ul></div></li><li class="listitem">
  3137. <code class="literal">LIBFOO_GIT_SUBMODULES</code> can be set to <code class="literal">YES</code> to create an archive
  3138. with the git submodules in the repository. This is only available
  3139. for packages downloaded with git (i.e. when
  3140. <code class="literal">LIBFOO_SITE_METHOD=git</code>). Note that we try not to use such git
  3141. submodules when they contain bundled libraries, in which case we
  3142. prefer to use those libraries from their own package.
  3143. </li><li class="listitem">
  3144. <code class="literal">LIBFOO_STRIP_COMPONENTS</code> is the number of leading components
  3145. (directories) that tar must strip from file names on extraction.
  3146. The tarball for most packages has one leading component named
  3147. "&lt;pkg-name&gt;-&lt;pkg-version&gt;", thus Buildroot passes
  3148. --strip-components=1 to tar to remove it.
  3149. For non-standard packages that don’t have this component, or
  3150. that have more than one leading component to strip, set this
  3151. variable with the value to be passed to tar. Default: 1.
  3152. </li><li class="listitem">
  3153. <code class="literal">LIBFOO_EXCLUDES</code> is a space-separated list of patterns to exclude
  3154. when extracting the archive. Each item from that list is passed as
  3155. a tar’s <code class="literal">--exclude</code> option. By default, empty.
  3156. </li><li class="listitem">
  3157. <code class="literal">LIBFOO_DEPENDENCIES</code> lists the dependencies (in terms of package
  3158. name) that are required for the current target package to
  3159. compile. These dependencies are guaranteed to be compiled and
  3160. installed before the configuration of the current package starts.
  3161. However, modifications to configuration of these dependencies will
  3162. not force a rebuild of the current package. In a similar way,
  3163. <code class="literal">HOST_LIBFOO_DEPENDENCIES</code> lists the dependencies for the current
  3164. host package.
  3165. </li><li class="listitem">
  3166. <code class="literal">LIBFOO_EXTRACT_DEPENDENCIES</code> lists the dependencies (in terms of
  3167. package name) that are required for the current target package to be
  3168. extracted. These dependencies are guaranteed to be compiled and
  3169. installed before the extract step of the current package
  3170. starts. This is only used internally by the package infrastructure,
  3171. and should typically not be used directly by packages.
  3172. </li><li class="listitem">
  3173. <code class="literal">LIBFOO_PATCH_DEPENDENCIES</code> lists the dependencies (in terms of
  3174. package name) that are required for the current package to be
  3175. patched. These dependencies are guaranteed to be extracted and
  3176. patched (but not necessarily built) before the current package is
  3177. patched. In a similar way, <code class="literal">HOST_LIBFOO_PATCH_DEPENDENCIES</code> lists
  3178. the dependencies for the current host package.
  3179. This is seldom used; usually, <code class="literal">LIBFOO_DEPENDENCIES</code> is what you
  3180. really want to use.
  3181. </li><li class="listitem">
  3182. <code class="literal">LIBFOO_PROVIDES</code> lists all the virtual packages <code class="literal">libfoo</code> is an
  3183. implementation of. See <a class="xref" href="#virtual-package-tutorial">Section 18.11, “Infrastructure for virtual packages”</a>.
  3184. </li><li class="listitem">
  3185. <code class="literal">LIBFOO_INSTALL_STAGING</code> can be set to <code class="literal">YES</code> or <code class="literal">NO</code> (default). If
  3186. set to <code class="literal">YES</code>, then the commands in the <code class="literal">LIBFOO_INSTALL_STAGING_CMDS</code>
  3187. variables are executed to install the package into the staging
  3188. directory.
  3189. </li><li class="listitem">
  3190. <code class="literal">LIBFOO_INSTALL_TARGET</code> can be set to <code class="literal">YES</code> (default) or <code class="literal">NO</code>. If
  3191. set to <code class="literal">YES</code>, then the commands in the <code class="literal">LIBFOO_INSTALL_TARGET_CMDS</code>
  3192. variables are executed to install the package into the target
  3193. directory.
  3194. </li><li class="listitem">
  3195. <code class="literal">LIBFOO_INSTALL_IMAGES</code> can be set to <code class="literal">YES</code> or <code class="literal">NO</code> (default). If
  3196. set to <code class="literal">YES</code>, then the commands in the <code class="literal">LIBFOO_INSTALL_IMAGES_CMDS</code>
  3197. variable are executed to install the package into the images
  3198. directory.
  3199. </li><li class="listitem">
  3200. <code class="literal">LIBFOO_CONFIG_SCRIPTS</code> lists the names of the files in
  3201. <span class="emphasis"><em>$(STAGING_DIR)/usr/bin</em></span> that need some special fixing to make them
  3202. cross-compiling friendly. Multiple file names separated by space can
  3203. be given and all are relative to <span class="emphasis"><em>$(STAGING_DIR)/usr/bin</em></span>. The files
  3204. listed in <code class="literal">LIBFOO_CONFIG_SCRIPTS</code> are also removed from
  3205. <code class="literal">$(TARGET_DIR)/usr/bin</code> since they are not needed on the target.
  3206. </li><li class="listitem">
  3207. <code class="literal">LIBFOO_DEVICES</code> lists the device files to be created by Buildroot
  3208. when using the static device table. The syntax to use is the
  3209. makedevs one. You can find some documentation for this syntax in the
  3210. <a class="xref" href="#makedev-syntax" title="Chapter 25. Makedev syntax documentation">Chapter 25, <em>Makedev syntax documentation</em></a>. This variable is optional.
  3211. </li><li class="listitem">
  3212. <code class="literal">LIBFOO_PERMISSIONS</code> lists the changes of permissions to be done at
  3213. the end of the build process. The syntax is once again the makedevs one.
  3214. You can find some documentation for this syntax in the <a class="xref" href="#makedev-syntax" title="Chapter 25. Makedev syntax documentation">Chapter 25, <em>Makedev syntax documentation</em></a>.
  3215. This variable is optional.
  3216. </li><li class="listitem">
  3217. <code class="literal">LIBFOO_USERS</code> lists the users to create for this package, if it installs
  3218. a program you want to run as a specific user (e.g. as a daemon, or as a
  3219. cron-job). The syntax is similar in spirit to the makedevs one, and is
  3220. described in the <a class="xref" href="#makeuser-syntax" title="Chapter 26. Makeusers syntax documentation">Chapter 26, <em>Makeusers syntax documentation</em></a>. This variable is optional.
  3221. </li><li class="listitem"><p class="simpara">
  3222. <code class="literal">LIBFOO_LICENSE</code> defines the license (or licenses) under which the package
  3223. is released.
  3224. This name will appear in the manifest file produced by <code class="literal">make legal-info</code>.
  3225. If the license appears in <a class="ulink" href="https://spdx.org/licenses/" target="_top">the SPDX License List</a>,
  3226. use the SPDX short identifier to make the manifest file uniform.
  3227. Otherwise, describe the license in a precise and concise way, avoiding
  3228. ambiguous names such as <code class="literal">BSD</code> which actually name a family of licenses.
  3229. This variable is optional. If it is not defined, <code class="literal">unknown</code> will appear in
  3230. the <code class="literal">license</code> field of the manifest file for this package.
  3231. The expected format for this variable must comply with the following rules:
  3232. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  3233. If different parts of the package are released under different
  3234. licenses, then <code class="literal">comma</code> separate licenses (e.g. <code class="literal"><code class="literal">LIBFOO_LICENSE =
  3235. GPL-2.0+, LGPL-2.1+</code></code>). If there is clear distinction between which
  3236. component is licensed under what license, then annotate the license
  3237. with that component, between parenthesis (e.g. <code class="literal"><code class="literal">LIBFOO_LICENSE =
  3238. GPL-2.0+ (programs), LGPL-2.1+ (libraries)</code></code>).
  3239. </li><li class="listitem">
  3240. If some licenses are conditioned on a sub-option being enabled, append
  3241. the conditional licenses with a comma (e.g.: <code class="literal">FOO_LICENSE += , GPL-2.0+
  3242. (programs)</code>); the infrastructure will internally remove the space before
  3243. the comma.
  3244. </li><li class="listitem">
  3245. If the package is dual licensed, then separate licenses with the
  3246. <code class="literal">or</code> keyword (e.g. <code class="literal"><code class="literal">LIBFOO_LICENSE = AFL-2.1 or GPL-2.0+</code></code>).
  3247. </li></ul></div></li><li class="listitem">
  3248. <code class="literal">LIBFOO_LICENSE_FILES</code> is a space-separated list of files in the package
  3249. tarball that contain the license(s) under which the package is released.
  3250. <code class="literal">make legal-info</code> copies all of these files in the <code class="literal">legal-info</code> directory.
  3251. See <a class="xref" href="#legal-info" title="Chapter 13. Legal notice and licensing">Chapter 13, <em>Legal notice and licensing</em></a> for more information.
  3252. This variable is optional. If it is not defined, a warning will be produced
  3253. to let you know, and <code class="literal">not saved</code> will appear in the <code class="literal">license files</code> field
  3254. of the manifest file for this package.
  3255. </li><li class="listitem">
  3256. <code class="literal">LIBFOO_ACTUAL_SOURCE_TARBALL</code> only applies to packages whose
  3257. <code class="literal">LIBFOO_SITE</code> / <code class="literal">LIBFOO_SOURCE</code> pair points to an archive that does
  3258. not actually contain source code, but binary code. This a very
  3259. uncommon case, only known to apply to external toolchains which come
  3260. already compiled, although theoretically it might apply to other
  3261. packages. In such cases a separate tarball is usually available with
  3262. the actual source code. Set <code class="literal">LIBFOO_ACTUAL_SOURCE_TARBALL</code> to the
  3263. name of the actual source code archive and Buildroot will download
  3264. it and use it when you run <code class="literal">make legal-info</code> to collect
  3265. legally-relevant material. Note this file will not be downloaded
  3266. during regular builds nor by <code class="literal">make source</code>.
  3267. </li><li class="listitem">
  3268. <code class="literal">LIBFOO_ACTUAL_SOURCE_SITE</code> provides the location of the actual
  3269. source tarball. The default value is <code class="literal">LIBFOO_SITE</code>, so you don’t
  3270. need to set this variable if the binary and source archives are
  3271. hosted on the same directory. If <code class="literal">LIBFOO_ACTUAL_SOURCE_TARBALL</code> is
  3272. not set, it doesn’t make sense to define
  3273. <code class="literal">LIBFOO_ACTUAL_SOURCE_SITE</code>.
  3274. </li><li class="listitem">
  3275. <code class="literal">LIBFOO_REDISTRIBUTE</code> can be set to <code class="literal">YES</code> (default) or <code class="literal">NO</code> to indicate if
  3276. the package source code is allowed to be redistributed. Set it to <code class="literal">NO</code> for
  3277. non-opensource packages: Buildroot will not save the source code for this
  3278. package when collecting the <code class="literal">legal-info</code>.
  3279. </li><li class="listitem">
  3280. <code class="literal">LIBFOO_FLAT_STACKSIZE</code> defines the stack size of an application built into
  3281. the FLAT binary format. The application stack size on the NOMMU architecture
  3282. processors can’t be enlarged at run time. The default stack size for the
  3283. FLAT binary format is only 4k bytes. If the application consumes more stack,
  3284. append the required number here.
  3285. </li><li class="listitem">
  3286. <code class="literal">LIBFOO_BIN_ARCH_EXCLUDE</code> is a space-separated list of paths (relative
  3287. to the target directory) to ignore when checking that the package
  3288. installs correctly cross-compiled binaries. You seldom need to set this
  3289. variable, unless the package installs binary blobs outside the default
  3290. locations, <code class="literal">/lib/firmware</code>, <code class="literal">/usr/lib/firmware</code>, <code class="literal">/lib/modules</code>,
  3291. <code class="literal">/usr/lib/modules</code>, and <code class="literal">/usr/share</code>, which are automatically excluded.
  3292. </li><li class="listitem">
  3293. <code class="literal">LIBFOO_IGNORE_CVES</code> is a space-separated list of CVEs that tells
  3294. Buildroot CVE tracking tools which CVEs should be ignored for this
  3295. package. This is typically used when the CVE is fixed by a patch in
  3296. the package, or when the CVE for some reason does not affect the
  3297. Buildroot package. A Makefile comment must always precede the
  3298. addition of a CVE to this variable. Example:
  3299. </li></ul></div><pre class="screen"># 0001-fix-cve-2020-12345.patch
  3300. LIBFOO_IGNORE_CVES += CVE-2020-12345
  3301. # only when built with libbaz, which Buildroot doesn't support
  3302. LIBFOO_IGNORE_CVES += CVE-2020-54321</pre><p>The recommended way to define these variables is to use the following
  3303. syntax:</p><pre class="screen">LIBFOO_VERSION = 2.32</pre><p>Now, the variables that define what should be performed at the
  3304. different steps of the build process.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3305. <code class="literal">LIBFOO_EXTRACT_CMDS</code> lists the actions to be performed to extract
  3306. the package. This is generally not needed as tarballs are
  3307. automatically handled by Buildroot. However, if the package uses a
  3308. non-standard archive format, such as a ZIP or RAR file, or has a
  3309. tarball with a non-standard organization, this variable allows to
  3310. override the package infrastructure default behavior.
  3311. </li><li class="listitem">
  3312. <code class="literal">LIBFOO_CONFIGURE_CMDS</code> lists the actions to be performed to
  3313. configure the package before its compilation.
  3314. </li><li class="listitem">
  3315. <code class="literal">LIBFOO_BUILD_CMDS</code> lists the actions to be performed to
  3316. compile the package.
  3317. </li><li class="listitem">
  3318. <code class="literal">HOST_LIBFOO_INSTALL_CMDS</code> lists the actions to be performed
  3319. to install the package, when the package is a host package. The
  3320. package must install its files to the directory given by
  3321. <code class="literal">$(HOST_DIR)</code>. All files, including development files such as
  3322. headers should be installed, since other packages might be compiled
  3323. on top of this package.
  3324. </li><li class="listitem">
  3325. <code class="literal">LIBFOO_INSTALL_TARGET_CMDS</code> lists the actions to be
  3326. performed to install the package to the target directory, when the
  3327. package is a target package. The package must install its files to
  3328. the directory given by <code class="literal">$(TARGET_DIR)</code>. Only the files required for
  3329. <span class="emphasis"><em>execution</em></span> of the package have to be
  3330. installed. Header files, static libraries and documentation will be
  3331. removed again when the target filesystem is finalized.
  3332. </li><li class="listitem">
  3333. <code class="literal">LIBFOO_INSTALL_STAGING_CMDS</code> lists the actions to be
  3334. performed to install the package to the staging directory, when the
  3335. package is a target package. The package must install its files to
  3336. the directory given by <code class="literal">$(STAGING_DIR)</code>. All development files
  3337. should be installed, since they might be needed to compile other
  3338. packages.
  3339. </li><li class="listitem">
  3340. <code class="literal">LIBFOO_INSTALL_IMAGES_CMDS</code> lists the actions to be performed to
  3341. install the package to the images directory, when the package is a
  3342. target package. The package must install its files to the directory
  3343. given by <code class="literal">$(BINARIES_DIR)</code>. Only files that are binary images (aka
  3344. images) that do not belong in the <code class="literal">TARGET_DIR</code> but are necessary
  3345. for booting the board should be placed here. For example, a package
  3346. should utilize this step if it has binaries which would be similar
  3347. to the kernel image, bootloader or root filesystem images.
  3348. </li><li class="listitem">
  3349. <code class="literal">LIBFOO_INSTALL_INIT_SYSV</code>, <code class="literal">LIBFOO_INSTALL_INIT_OPENRC</code> and
  3350. <code class="literal">LIBFOO_INSTALL_INIT_SYSTEMD</code> list the actions to install init
  3351. scripts either for the systemV-like init systems (busybox,
  3352. sysvinit, etc.), openrc or for the systemd units. These commands
  3353. will be run only when the relevant init system is installed (i.e.
  3354. if systemd is selected as the init system in the configuration,
  3355. only <code class="literal">LIBFOO_INSTALL_INIT_SYSTEMD</code> will be run). The only exception
  3356. is when openrc is chosen as init system and <code class="literal">LIBFOO_INSTALL_INIT_OPENRC</code>
  3357. has not been set, in such situation <code class="literal">LIBFOO_INSTALL_INIT_SYSV</code> will
  3358. be called, since openrc supports sysv init scripts.
  3359. When systemd is used as the init system, buildroot will automatically enable
  3360. all services using the <code class="literal">systemctl preset-all</code> command in the final phase of
  3361. image building. You can add preset files to prevent a particular unit from
  3362. being automatically enabled by buildroot.
  3363. </li><li class="listitem">
  3364. <code class="literal">LIBFOO_HELP_CMDS</code> lists the actions to print the package help, which
  3365. is included to the main <code class="literal">make help</code> output. These commands can print
  3366. anything in any format.
  3367. This is seldom used, as packages rarely have custom rules. <span class="strong"><strong>Do not use
  3368. this variable</strong></span>, unless you really know that you need to print help.
  3369. </li><li class="listitem">
  3370. <code class="literal">LIBFOO_LINUX_CONFIG_FIXUPS</code> lists the Linux kernel configuration
  3371. options that are needed to build and use this package, and without
  3372. which the package is fundamentally broken. This shall be a set of
  3373. calls to one of the kconfig tweaking option: <code class="literal">KCONFIG_ENABLE_OPT</code>,
  3374. <code class="literal">KCONFIG_DISABLE_OPT</code>, or <code class="literal">KCONFIG_SET_OPT</code>.
  3375. This is seldom used, as package usually have no strict requirements on
  3376. the kernel options.
  3377. </li></ul></div><p>The preferred way to define these variables is:</p><pre class="screen">define LIBFOO_CONFIGURE_CMDS
  3378. action 1
  3379. action 2
  3380. action 3
  3381. endef</pre><p>In the action definitions, you can use the following variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3382. <code class="literal">$(LIBFOO_PKGDIR)</code> contains the path to the directory containing the
  3383. <code class="literal">libfoo.mk</code> and <code class="literal">Config.in</code> files. This variable is useful when it is
  3384. necessary to install a file bundled in Buildroot, like a runtime
  3385. configuration file, a splashscreen image…
  3386. </li><li class="listitem">
  3387. <code class="literal">$(@D)</code>, which contains the directory in which the package source
  3388. code has been uncompressed.
  3389. </li><li class="listitem">
  3390. <code class="literal">$(LIBFOO_DL_DIR)</code> contains the path to the directory where all the downloads
  3391. made by Buildroot for <code class="literal">libfoo</code> are stored in.
  3392. </li><li class="listitem">
  3393. <code class="literal">$(TARGET_CC)</code>, <code class="literal">$(TARGET_LD)</code>, etc. to get the target
  3394. cross-compilation utilities
  3395. </li><li class="listitem">
  3396. <code class="literal">$(TARGET_CROSS)</code> to get the cross-compilation toolchain prefix
  3397. </li><li class="listitem">
  3398. Of course the <code class="literal">$(HOST_DIR)</code>, <code class="literal">$(STAGING_DIR)</code> and <code class="literal">$(TARGET_DIR)</code>
  3399. variables to install the packages properly. Those variables point to
  3400. the global <span class="emphasis"><em>host</em></span>, <span class="emphasis"><em>staging</em></span> and <span class="emphasis"><em>target</em></span> directories, unless
  3401. <span class="emphasis"><em>per-package directory</em></span> support is used, in which case they point to
  3402. the current package <span class="emphasis"><em>host</em></span>, <span class="emphasis"><em>staging</em></span> and <span class="emphasis"><em>target</em></span> directories. In
  3403. both cases, it doesn’t make any difference from the package point of
  3404. view: it should simply use <code class="literal">HOST_DIR</code>, <code class="literal">STAGING_DIR</code> and
  3405. <code class="literal">TARGET_DIR</code>. See <a class="xref" href="#top-level-parallel-build" title="8.12. Top-level parallel build">Section 8.12, “Top-level parallel build”</a> for more details
  3406. about <span class="emphasis"><em>per-package directory</em></span> support.
  3407. </li></ul></div><p>Finally, you can also use hooks. See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for more information.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_autotools_based_packages"></a>18.6. Infrastructure for autotools-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="autotools-package-tutorial"></a>18.6.1. <code class="literal">autotools-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for an autotools-based
  3408. package, with an example :</p><pre class="screen">01: ################################################################################
  3409. 02: #
  3410. 03: # libfoo
  3411. 04: #
  3412. 05: ################################################################################
  3413. 06:
  3414. 07: LIBFOO_VERSION = 1.0
  3415. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  3416. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  3417. 10: LIBFOO_INSTALL_STAGING = YES
  3418. 11: LIBFOO_INSTALL_TARGET = NO
  3419. 12: LIBFOO_CONF_OPTS = --disable-shared
  3420. 13: LIBFOO_DEPENDENCIES = libglib2 host-pkgconf
  3421. 14:
  3422. 15: $(eval $(autotools-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball recommended)
  3423. and the location of the tarball on the Web. Buildroot will automatically
  3424. download the tarball from this location.</p><p>On line 10, we tell Buildroot to install the package to the staging
  3425. directory. The staging directory, located in <code class="literal">output/staging/</code>
  3426. is the directory where all the packages are installed, including their
  3427. development files, etc. By default, packages are not installed to the
  3428. staging directory, since usually, only libraries need to be installed in
  3429. the staging directory: their development files are needed to compile
  3430. other libraries or applications depending on them. Also by default, when
  3431. staging installation is enabled, packages are installed in this location
  3432. using the <code class="literal">make install</code> command.</p><p>On line 11, we tell Buildroot to not install the package to the
  3433. target directory. This directory contains what will become the root
  3434. filesystem running on the target. For purely static libraries, it is
  3435. not necessary to install them in the target directory because they will
  3436. not be used at runtime. By default, target installation is enabled; setting
  3437. this variable to NO is almost never needed. Also by default, packages are
  3438. installed in this location using the <code class="literal">make install</code> command.</p><p>On line 12, we tell Buildroot to pass a custom configure option, that
  3439. will be passed to the <code class="literal">./configure</code> script before configuring
  3440. and building the package.</p><p>On line 13, we declare our dependencies, so that they are built
  3441. before the build process of our package starts.</p><p>Finally, on line line 15, we invoke the <code class="literal">autotools-package</code>
  3442. macro that generates all the Makefile rules that actually allows the
  3443. package to be built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="autotools-package-reference"></a>18.6.2. <code class="literal">autotools-package</code> reference</h3></div></div></div><p>The main macro of the autotools package infrastructure is
  3444. <code class="literal">autotools-package</code>. It is similar to the <code class="literal">generic-package</code> macro. The ability to
  3445. have target and host packages is also available, with the
  3446. <code class="literal">host-autotools-package</code> macro.</p><p>Just like the generic infrastructure, the autotools infrastructure
  3447. works by defining a number of variables before calling the
  3448. <code class="literal">autotools-package</code> macro.</p><p>First, all the package metadata information variables that exist in the
  3449. generic infrastructure also exist in the autotools infrastructure:
  3450. <code class="literal">LIBFOO_VERSION</code>, <code class="literal">LIBFOO_SOURCE</code>,
  3451. <code class="literal">LIBFOO_PATCH</code>, <code class="literal">LIBFOO_SITE</code>,
  3452. <code class="literal">LIBFOO_SUBDIR</code>, <code class="literal">LIBFOO_DEPENDENCIES</code>,
  3453. <code class="literal">LIBFOO_INSTALL_STAGING</code>, <code class="literal">LIBFOO_INSTALL_TARGET</code>.</p><p>A few additional variables, specific to the autotools infrastructure,
  3454. can also be defined. Many of them are only useful in very specific
  3455. cases, typical packages will therefore only use a few of them.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3456. <code class="literal">LIBFOO_SUBDIR</code> may contain the name of a subdirectory
  3457. inside the package that contains the configure script. This is useful,
  3458. if for example, the main configure script is not at the root of the
  3459. tree extracted by the tarball. If <code class="literal">HOST_LIBFOO_SUBDIR</code> is
  3460. not specified, it defaults to <code class="literal">LIBFOO_SUBDIR</code>.
  3461. </li><li class="listitem">
  3462. <code class="literal">LIBFOO_CONF_ENV</code>, to specify additional environment
  3463. variables to pass to the configure script. By default, empty.
  3464. </li><li class="listitem">
  3465. <code class="literal">LIBFOO_CONF_OPTS</code>, to specify additional configure
  3466. options to pass to the configure script. By default, empty.
  3467. </li><li class="listitem">
  3468. <code class="literal">LIBFOO_MAKE</code>, to specify an alternate <code class="literal">make</code>
  3469. command. This is typically useful when parallel make is enabled in
  3470. the configuration (using <code class="literal">BR2_JLEVEL</code>) but that this
  3471. feature should be disabled for the given package, for one reason or
  3472. another. By default, set to <code class="literal">$(MAKE)</code>. If parallel building
  3473. is not supported by the package, then it should be set to
  3474. <code class="literal">LIBFOO_MAKE=$(MAKE1)</code>.
  3475. </li><li class="listitem">
  3476. <code class="literal">LIBFOO_MAKE_ENV</code>, to specify additional environment
  3477. variables to pass to make in the build step. These are passed before
  3478. the <code class="literal">make</code> command. By default, empty.
  3479. </li><li class="listitem">
  3480. <code class="literal">LIBFOO_MAKE_OPTS</code>, to specify additional variables to
  3481. pass to make in the build step. These are passed after the
  3482. <code class="literal">make</code> command. By default, empty.
  3483. </li><li class="listitem">
  3484. <code class="literal">LIBFOO_AUTORECONF</code>, tells whether the package should
  3485. be autoreconfigured or not (i.e. if the configure script and
  3486. Makefile.in files should be re-generated by re-running autoconf,
  3487. automake, libtool, etc.). Valid values are <code class="literal">YES</code> and
  3488. <code class="literal">NO</code>. By default, the value is <code class="literal">NO</code>
  3489. </li><li class="listitem">
  3490. <code class="literal">LIBFOO_AUTORECONF_ENV</code>, to specify additional environment
  3491. variables to pass to the <span class="emphasis"><em>autoreconf</em></span> program if
  3492. <code class="literal">LIBFOO_AUTORECONF=YES</code>. These are passed in the environment of
  3493. the <span class="emphasis"><em>autoreconf</em></span> command. By default, empty.
  3494. </li><li class="listitem">
  3495. <code class="literal">LIBFOO_AUTORECONF_OPTS</code> to specify additional options
  3496. passed to the <span class="emphasis"><em>autoreconf</em></span> program if
  3497. <code class="literal">LIBFOO_AUTORECONF=YES</code>. By default, empty.
  3498. </li><li class="listitem">
  3499. <code class="literal">LIBFOO_GETTEXTIZE</code>, tells whether the package should be
  3500. gettextized or not (i.e. if the package uses a different gettext
  3501. version than Buildroot provides, and it is needed to run
  3502. <span class="emphasis"><em>gettextize</em></span>.) Only valid when <code class="literal">LIBFOO_AUTORECONF=YES</code>. Valid
  3503. values are <code class="literal">YES</code> and <code class="literal">NO</code>. The default is <code class="literal">NO</code>.
  3504. </li><li class="listitem">
  3505. <code class="literal">LIBFOO_GETTEXTIZE_OPTS</code>, to specify additional options passed to
  3506. the <span class="emphasis"><em>gettextize</em></span> program, if <code class="literal">LIBFOO_GETTEXTIZE=YES</code>. You may
  3507. use that if, for example, the <code class="literal">.po</code> files are not located in the
  3508. standard place (i.e. in <code class="literal">po/</code> at the root of the package.) By
  3509. default, <span class="emphasis"><em>-f</em></span>.
  3510. </li><li class="listitem">
  3511. <code class="literal">LIBFOO_LIBTOOL_PATCH</code> tells whether the Buildroot
  3512. patch to fix libtool cross-compilation issues should be applied or
  3513. not. Valid values are <code class="literal">YES</code> and <code class="literal">NO</code>. By
  3514. default, the value is <code class="literal">YES</code>
  3515. </li><li class="listitem">
  3516. <code class="literal">LIBFOO_INSTALL_STAGING_OPTS</code> contains the make options
  3517. used to install the package to the staging directory. By default, the
  3518. value is <code class="literal">DESTDIR=$(STAGING_DIR) install</code>, which is
  3519. correct for most autotools packages. It is still possible to override
  3520. it.
  3521. </li><li class="listitem">
  3522. <code class="literal">LIBFOO_INSTALL_TARGET_OPTS</code> contains the make options
  3523. used to install the package to the target directory. By default, the
  3524. value is <code class="literal">DESTDIR=$(TARGET_DIR) install</code>. The default
  3525. value is correct for most autotools packages, but it is still possible
  3526. to override it if needed.
  3527. </li></ul></div><p>With the autotools infrastructure, all the steps required to build
  3528. and install the packages are already defined, and they generally work
  3529. well for most autotools-based packages. However, when required, it is
  3530. still possible to customize what is done in any particular step:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3531. By adding a post-operation hook (after extract, patch, configure,
  3532. build or install). See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for details.
  3533. </li><li class="listitem">
  3534. By overriding one of the steps. For example, even if the autotools
  3535. infrastructure is used, if the package <code class="literal">.mk</code> file defines its
  3536. own <code class="literal">LIBFOO_CONFIGURE_CMDS</code> variable, it will be used
  3537. instead of the default autotools one. However, using this method
  3538. should be restricted to very specific cases. Do not use it in the
  3539. general case.
  3540. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_cmake_based_packages"></a>18.7. Infrastructure for CMake-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="cmake-package-tutorial"></a>18.7.1. <code class="literal">cmake-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a CMake-based package,
  3541. with an example :</p><pre class="screen">01: ################################################################################
  3542. 02: #
  3543. 03: # libfoo
  3544. 04: #
  3545. 05: ################################################################################
  3546. 06:
  3547. 07: LIBFOO_VERSION = 1.0
  3548. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  3549. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  3550. 10: LIBFOO_INSTALL_STAGING = YES
  3551. 11: LIBFOO_INSTALL_TARGET = NO
  3552. 12: LIBFOO_CONF_OPTS = -DBUILD_DEMOS=ON
  3553. 13: LIBFOO_DEPENDENCIES = libglib2 host-pkgconf
  3554. 14:
  3555. 15: $(eval $(cmake-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball recommended)
  3556. and the location of the tarball on the Web. Buildroot will automatically
  3557. download the tarball from this location.</p><p>On line 10, we tell Buildroot to install the package to the staging
  3558. directory. The staging directory, located in <code class="literal">output/staging/</code>
  3559. is the directory where all the packages are installed, including their
  3560. development files, etc. By default, packages are not installed to the
  3561. staging directory, since usually, only libraries need to be installed in
  3562. the staging directory: their development files are needed to compile
  3563. other libraries or applications depending on them. Also by default, when
  3564. staging installation is enabled, packages are installed in this location
  3565. using the <code class="literal">make install</code> command.</p><p>On line 11, we tell Buildroot to not install the package to the
  3566. target directory. This directory contains what will become the root
  3567. filesystem running on the target. For purely static libraries, it is
  3568. not necessary to install them in the target directory because they will
  3569. not be used at runtime. By default, target installation is enabled; setting
  3570. this variable to NO is almost never needed. Also by default, packages are
  3571. installed in this location using the <code class="literal">make install</code> command.</p><p>On line 12, we tell Buildroot to pass custom options to CMake when it is
  3572. configuring the package.</p><p>On line 13, we declare our dependencies, so that they are built
  3573. before the build process of our package starts.</p><p>Finally, on line line 15, we invoke the <code class="literal">cmake-package</code>
  3574. macro that generates all the Makefile rules that actually allows the
  3575. package to be built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="cmake-package-reference"></a>18.7.2. <code class="literal">cmake-package</code> reference</h3></div></div></div><p>The main macro of the CMake package infrastructure is
  3576. <code class="literal">cmake-package</code>. It is similar to the <code class="literal">generic-package</code> macro. The ability to
  3577. have target and host packages is also available, with the
  3578. <code class="literal">host-cmake-package</code> macro.</p><p>Just like the generic infrastructure, the CMake infrastructure works
  3579. by defining a number of variables before calling the <code class="literal">cmake-package</code>
  3580. macro.</p><p>First, all the package metadata information variables that exist in
  3581. the generic infrastructure also exist in the CMake infrastructure:
  3582. <code class="literal">LIBFOO_VERSION</code>, <code class="literal">LIBFOO_SOURCE</code>, <code class="literal">LIBFOO_PATCH</code>, <code class="literal">LIBFOO_SITE</code>,
  3583. <code class="literal">LIBFOO_SUBDIR</code>, <code class="literal">LIBFOO_DEPENDENCIES</code>, <code class="literal">LIBFOO_INSTALL_STAGING</code>,
  3584. <code class="literal">LIBFOO_INSTALL_TARGET</code>.</p><p>A few additional variables, specific to the CMake infrastructure, can
  3585. also be defined. Many of them are only useful in very specific cases,
  3586. typical packages will therefore only use a few of them.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3587. <code class="literal">LIBFOO_SUBDIR</code> may contain the name of a subdirectory inside the
  3588. package that contains the main CMakeLists.txt file. This is useful,
  3589. if for example, the main CMakeLists.txt file is not at the root of
  3590. the tree extracted by the tarball. If <code class="literal">HOST_LIBFOO_SUBDIR</code> is not
  3591. specified, it defaults to <code class="literal">LIBFOO_SUBDIR</code>.
  3592. </li><li class="listitem">
  3593. <code class="literal">LIBFOO_CONF_ENV</code>, to specify additional environment variables to
  3594. pass to CMake. By default, empty.
  3595. </li><li class="listitem"><p class="simpara">
  3596. <code class="literal">LIBFOO_CONF_OPTS</code>, to specify additional configure options to pass
  3597. to CMake. By default, empty. A number of common CMake options are
  3598. set by the <code class="literal">cmake-package</code> infrastructure; so it is normally not
  3599. necessary to set them in the package’s <code class="literal">*.mk</code> file unless you want
  3600. to override them:
  3601. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  3602. <code class="literal">CMAKE_BUILD_TYPE</code> is driven by <code class="literal">BR2_ENABLE_DEBUG</code>;
  3603. </li><li class="listitem">
  3604. <code class="literal">CMAKE_INSTALL_PREFIX</code>;
  3605. </li><li class="listitem">
  3606. <code class="literal">BUILD_SHARED_LIBS</code> is driven by <code class="literal">BR2_STATIC_LIBS</code>;
  3607. </li><li class="listitem">
  3608. <code class="literal">BUILD_DOC</code>, <code class="literal">BUILD_DOCS</code> are disabled;
  3609. </li><li class="listitem">
  3610. <code class="literal">BUILD_EXAMPLE</code>, <code class="literal">BUILD_EXAMPLES</code> are disabled;
  3611. </li><li class="listitem">
  3612. <code class="literal">BUILD_TEST</code>, <code class="literal">BUILD_TESTS</code>, <code class="literal">BUILD_TESTING</code> are disabled.
  3613. </li></ul></div></li><li class="listitem">
  3614. <code class="literal">LIBFOO_SUPPORTS_IN_SOURCE_BUILD = NO</code> should be set when the package
  3615. cannot be built inside the source tree but needs a separate build
  3616. directory.
  3617. </li><li class="listitem">
  3618. <code class="literal">LIBFOO_MAKE</code>, to specify an alternate <code class="literal">make</code> command. This is
  3619. typically useful when parallel make is enabled in the configuration
  3620. (using <code class="literal">BR2_JLEVEL</code>) but that this feature should be disabled for
  3621. the given package, for one reason or another. By default, set to
  3622. <code class="literal">$(MAKE)</code>. If parallel building is not supported by the package,
  3623. then it should be set to <code class="literal">LIBFOO_MAKE=$(MAKE1)</code>.
  3624. </li><li class="listitem">
  3625. <code class="literal">LIBFOO_MAKE_ENV</code>, to specify additional environment variables to
  3626. pass to make in the build step. These are passed before the <code class="literal">make</code>
  3627. command. By default, empty.
  3628. </li><li class="listitem">
  3629. <code class="literal">LIBFOO_MAKE_OPTS</code>, to specify additional variables to pass to make
  3630. in the build step. These are passed after the <code class="literal">make</code> command. By
  3631. default, empty.
  3632. </li><li class="listitem">
  3633. <code class="literal">LIBFOO_INSTALL_STAGING_OPTS</code> contains the make options used to
  3634. install the package to the staging directory. By default, the value
  3635. is <code class="literal">DESTDIR=$(STAGING_DIR) install</code>, which is correct for most
  3636. CMake packages. It is still possible to override it.
  3637. </li><li class="listitem">
  3638. <code class="literal">LIBFOO_INSTALL_TARGET_OPTS</code> contains the make options used to
  3639. install the package to the target directory. By default, the value
  3640. is <code class="literal">DESTDIR=$(TARGET_DIR) install</code>. The default value is correct
  3641. for most CMake packages, but it is still possible to override it if
  3642. needed.
  3643. </li></ul></div><p>With the CMake infrastructure, all the steps required to build and
  3644. install the packages are already defined, and they generally work well
  3645. for most CMake-based packages. However, when required, it is still
  3646. possible to customize what is done in any particular step:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3647. By adding a post-operation hook (after extract, patch, configure,
  3648. build or install). See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for details.
  3649. </li><li class="listitem">
  3650. By overriding one of the steps. For example, even if the CMake
  3651. infrastructure is used, if the package <code class="literal">.mk</code> file defines its own
  3652. <code class="literal">LIBFOO_CONFIGURE_CMDS</code> variable, it will be used instead of the
  3653. default CMake one. However, using this method should be restricted
  3654. to very specific cases. Do not use it in the general case.
  3655. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_python_packages"></a>18.8. Infrastructure for Python packages</h2></div></div></div><p>This infrastructure applies to Python packages that use the standard
  3656. Python setuptools mechanism as their build system, generally
  3657. recognizable by the usage of a <code class="literal">setup.py</code> script.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="python-package-tutorial"></a>18.8.1. <code class="literal">python-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a Python package,
  3658. with an example :</p><pre class="screen">01: ################################################################################
  3659. 02: #
  3660. 03: # python-foo
  3661. 04: #
  3662. 05: ################################################################################
  3663. 06:
  3664. 07: PYTHON_FOO_VERSION = 1.0
  3665. 08: PYTHON_FOO_SOURCE = python-foo-$(PYTHON_FOO_VERSION).tar.xz
  3666. 09: PYTHON_FOO_SITE = http://www.foosoftware.org/download
  3667. 10: PYTHON_FOO_LICENSE = BSD-3-Clause
  3668. 11: PYTHON_FOO_LICENSE_FILES = LICENSE
  3669. 12: PYTHON_FOO_ENV = SOME_VAR=1
  3670. 13: PYTHON_FOO_DEPENDENCIES = libmad
  3671. 14: PYTHON_FOO_SETUP_TYPE = distutils
  3672. 15:
  3673. 16: $(eval $(python-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  3674. recommended) and the location of the tarball on the Web. Buildroot
  3675. will automatically download the tarball from this location.</p><p>On line 10 and 11, we give licensing details about the package (its
  3676. license on line 10, and the file containing the license text on line
  3677. 11).</p><p>On line 12, we tell Buildroot to pass custom options to the Python
  3678. <code class="literal">setup.py</code> script when it is configuring the package.</p><p>On line 13, we declare our dependencies, so that they are built
  3679. before the build process of our package starts.</p><p>On line 14, we declare the specific Python build system being used. In
  3680. this case the <code class="literal">distutils</code> Python build system is used. The two
  3681. supported ones are <code class="literal">distutils</code> and <code class="literal">setuptools</code>.</p><p>Finally, on line 16, we invoke the <code class="literal">python-package</code> macro that
  3682. generates all the Makefile rules that actually allow the package to be
  3683. built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="python-package-reference"></a>18.8.2. <code class="literal">python-package</code> reference</h3></div></div></div><p>As a policy, packages that merely provide Python modules should all be
  3684. named <code class="literal">python-&lt;something&gt;</code> in Buildroot. Other packages that use the
  3685. Python build system, but are not Python modules, can freely choose
  3686. their name (existing examples in Buildroot are <code class="literal">scons</code> and
  3687. <code class="literal">supervisor</code>).</p><p>Packages that are only compatible with one version of Python (as in:
  3688. Python 2 or Python 3) should depend on that version explicitely in
  3689. their <code class="literal">Config.in</code> file (<code class="literal">BR2_PACKAGE_PYTHON</code> for Python 2,
  3690. <code class="literal">BR2_PACKAGE_PYTHON3</code> for Python 3). Packages that are compatible
  3691. with both versions should not explicitely depend on them in their
  3692. <code class="literal">Config.in</code> file, since that condition is already expressed for the
  3693. whole "External python modules" menu.</p><p>The main macro of the Python package infrastructure is
  3694. <code class="literal">python-package</code>. It is similar to the <code class="literal">generic-package</code> macro. It is
  3695. also possible to create Python host packages with the
  3696. <code class="literal">host-python-package</code> macro.</p><p>Just like the generic infrastructure, the Python infrastructure works
  3697. by defining a number of variables before calling the <code class="literal">python-package</code>
  3698. or <code class="literal">host-python-package</code> macros.</p><p>All the package metadata information variables that exist in the
  3699. <a class="link" href="#generic-package-reference" title="18.5.2. generic-package reference">generic package infrastructure</a> also
  3700. exist in the Python infrastructure: <code class="literal">PYTHON_FOO_VERSION</code>,
  3701. <code class="literal">PYTHON_FOO_SOURCE</code>, <code class="literal">PYTHON_FOO_PATCH</code>, <code class="literal">PYTHON_FOO_SITE</code>,
  3702. <code class="literal">PYTHON_FOO_SUBDIR</code>, <code class="literal">PYTHON_FOO_DEPENDENCIES</code>, <code class="literal">PYTHON_FOO_LICENSE</code>,
  3703. <code class="literal">PYTHON_FOO_LICENSE_FILES</code>, <code class="literal">PYTHON_FOO_INSTALL_STAGING</code>, etc.</p><p>Note that:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3704. It is not necessary to add <code class="literal">python</code> or <code class="literal">host-python</code> in the
  3705. <code class="literal">PYTHON_FOO_DEPENDENCIES</code> variable of a package, since these basic
  3706. dependencies are automatically added as needed by the Python
  3707. package infrastructure.
  3708. </li><li class="listitem">
  3709. Similarly, it is not needed to add <code class="literal">host-setuptools</code> to
  3710. <code class="literal">PYTHON_FOO_DEPENDENCIES</code> for setuptools-based packages, since it’s
  3711. automatically added by the Python infrastructure as needed.
  3712. </li></ul></div><p>One variable specific to the Python infrastructure is mandatory:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3713. <code class="literal">PYTHON_FOO_SETUP_TYPE</code>, to define which Python build system is used
  3714. by the package. The two supported values are <code class="literal">distutils</code> and
  3715. <code class="literal">setuptools</code>. If you don’t know which one is used in your package,
  3716. look at the <code class="literal">setup.py</code> file in your package source code, and see
  3717. whether it imports things from the <code class="literal">distutils</code> module or the
  3718. <code class="literal">setuptools</code> module.
  3719. </li></ul></div><p>A few additional variables, specific to the Python infrastructure, can
  3720. optionally be defined, depending on the package’s needs. Many of them
  3721. are only useful in very specific cases, typical packages will
  3722. therefore only use a few of them, or none.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3723. <code class="literal">PYTHON_FOO_SUBDIR</code> may contain the name of a subdirectory inside the
  3724. package that contains the main <code class="literal">setup.py</code> file. This is useful,
  3725. if for example, the main <code class="literal">setup.py</code> file is not at the root of
  3726. the tree extracted by the tarball. If <code class="literal">HOST_PYTHON_FOO_SUBDIR</code> is not
  3727. specified, it defaults to <code class="literal">PYTHON_FOO_SUBDIR</code>.
  3728. </li><li class="listitem">
  3729. <code class="literal">PYTHON_FOO_ENV</code>, to specify additional environment variables to
  3730. pass to the Python <code class="literal">setup.py</code> script (for both the build and install
  3731. steps). Note that the infrastructure is automatically passing
  3732. several standard variables, defined in <code class="literal">PKG_PYTHON_DISTUTILS_ENV</code>
  3733. (for distutils target packages), <code class="literal">HOST_PKG_PYTHON_DISTUTILS_ENV</code>
  3734. (for distutils host packages), <code class="literal">PKG_PYTHON_SETUPTOOLS_ENV</code> (for
  3735. setuptools target packages) and <code class="literal">HOST_PKG_PYTHON_SETUPTOOLS_ENV</code>
  3736. (for setuptools host packages).
  3737. </li><li class="listitem">
  3738. <code class="literal">PYTHON_FOO_BUILD_OPTS</code>, to specify additional options to pass to the
  3739. Python <code class="literal">setup.py</code> script during the build step. For target distutils
  3740. packages, the <code class="literal">PKG_PYTHON_DISTUTILS_BUILD_OPTS</code> options are already
  3741. passed automatically by the infrastructure.
  3742. </li><li class="listitem">
  3743. <code class="literal">PYTHON_FOO_INSTALL_TARGET_OPTS</code>, <code class="literal">PYTHON_FOO_INSTALL_STAGING_OPTS</code>,
  3744. <code class="literal">HOST_PYTHON_FOO_INSTALL_OPTS</code> to specify additional options to pass
  3745. to the Python <code class="literal">setup.py</code> script during the target installation step,
  3746. the staging installation step or the host installation,
  3747. respectively. Note that the infrastructure is automatically passing
  3748. some options, defined in <code class="literal">PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS</code>
  3749. or <code class="literal">PKG_PYTHON_DISTUTILS_INSTALL_STAGING_OPTS</code> (for target distutils
  3750. packages), <code class="literal">HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS</code> (for host
  3751. distutils packages), <code class="literal">PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS</code> or
  3752. <code class="literal">PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS</code> (for target setuptools
  3753. packages) and <code class="literal">HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS</code> (for host
  3754. setuptools packages).
  3755. </li><li class="listitem">
  3756. <code class="literal">HOST_PYTHON_FOO_NEEDS_HOST_PYTHON</code>, to define the host python
  3757. interpreter. The usage of this variable is limited to host
  3758. packages. The two supported value are <code class="literal">python2</code> and <code class="literal">python3</code>. It
  3759. will ensure the right host python package is available and will
  3760. invoke it for the build. If some build steps are overloaded, the
  3761. right python interpreter must be explicitly called in the commands.
  3762. </li></ul></div><p>With the Python infrastructure, all the steps required to build and
  3763. install the packages are already defined, and they generally work well
  3764. for most Python-based packages. However, when required, it is still
  3765. possible to customize what is done in any particular step:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3766. By adding a post-operation hook (after extract, patch, configure,
  3767. build or install). See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for details.
  3768. </li><li class="listitem">
  3769. By overriding one of the steps. For example, even if the Python
  3770. infrastructure is used, if the package <code class="literal">.mk</code> file defines its own
  3771. <code class="literal">PYTHON_FOO_BUILD_CMDS</code> variable, it will be used instead of the
  3772. default Python one. However, using this method should be restricted
  3773. to very specific cases. Do not use it in the general case.
  3774. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="scanpypi"></a>18.8.3. Generating a <code class="literal">python-package</code> from a PyPI repository</h3></div></div></div><p>If the Python package for which you would like to create a Buildroot
  3775. package is available on PyPI, you may want to use the <code class="literal">scanpypi</code> tool
  3776. located in <code class="literal">utils/</code> to automate the process.</p><p>You can find the list of existing PyPI packages
  3777. <a class="ulink" href="https://pypi.python.org" target="_top">here</a>.</p><p><code class="literal">scanpypi</code> requires Python’s <code class="literal">setuptools</code> package to be installed on
  3778. your host.</p><p>When at the root of your buildroot directory just do :</p><pre class="screen">utils/scanpypi foo bar -o package</pre><p>This will generate packages <code class="literal">python-foo</code> and <code class="literal">python-bar</code> in the package
  3779. folder if they exist on <a class="ulink" href="https://pypi.python.org" target="_top">https://pypi.python.org</a>.</p><p>Find the <code class="literal">external python modules</code> menu and insert your package inside.
  3780. Keep in mind that the items inside a menu should be in alphabetical order.</p><p>Please keep in mind that you’ll most likely have to manually check the
  3781. package for any mistakes as there are things that cannot be guessed by
  3782. the generator (e.g. dependencies on any of the python core modules
  3783. such as BR2_PACKAGE_PYTHON_ZLIB). Also, please take note that the
  3784. license and license files are guessed and must be checked. You also
  3785. need to manually add the package to the <code class="literal">package/Config.in</code> file.</p><p>If your Buildroot package is not in the official Buildroot tree but in
  3786. a br2-external tree, use the -o flag as follows:</p><pre class="screen">utils/scanpypi foo bar -o other_package_dir</pre><p>This will generate packages <code class="literal">python-foo</code> and <code class="literal">python-bar</code> in the
  3787. <code class="literal">other_package_directory</code> instead of <code class="literal">package</code>.</p><p>Option <code class="literal">-h</code> will list the available options:</p><pre class="screen">utils/scanpypi -h</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="python-package-cffi-backend"></a>18.8.4. <code class="literal">python-package</code> CFFI backend</h3></div></div></div><p>C Foreign Function Interface for Python (CFFI) provides a convenient
  3788. and reliable way to call compiled C code from Python using interface
  3789. declarations written in C. Python packages relying on this backend can
  3790. be identified by the appearance of a <code class="literal">cffi</code> dependency in the
  3791. <code class="literal">install_requires</code> field of their <code class="literal">setup.py</code> file.</p><p>Such a package should:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3792. add <code class="literal">python-cffi</code> as a runtime dependency in order to install the
  3793. compiled C library wrapper on the target. This is achieved by adding
  3794. <code class="literal">select BR2_PACKAGE_PYTHON_CFFI</code> to the package <code class="literal">Config.in</code>.
  3795. </li></ul></div><pre class="screen">config BR2_PACKAGE_PYTHON_FOO
  3796. bool "python-foo"
  3797. select BR2_PACKAGE_PYTHON_CFFI # runtime</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3798. add <code class="literal">host-python-cffi</code> as a build-time dependency in order to
  3799. cross-compile the C wrapper. This is achieved by adding
  3800. <code class="literal">host-python-cffi</code> to the <code class="literal">PYTHON_FOO_DEPENDENCIES</code> variable.
  3801. </li></ul></div><pre class="screen">################################################################################
  3802. #
  3803. # python-foo
  3804. #
  3805. ################################################################################
  3806. ...
  3807. PYTHON_FOO_DEPENDENCIES = host-python-cffi
  3808. $(eval $(python-package))</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_luarocks_based_packages"></a>18.9. Infrastructure for LuaRocks-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="luarocks-package-tutorial"></a>18.9.1. <code class="literal">luarocks-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a LuaRocks-based package,
  3809. with an example :</p><pre class="screen">01: ################################################################################
  3810. 02: #
  3811. 03: # lua-foo
  3812. 04: #
  3813. 05: ################################################################################
  3814. 06:
  3815. 07: LUA_FOO_VERSION = 1.0.2-1
  3816. 08: LUA_FOO_NAME_UPSTREAM = foo
  3817. 09: LUA_FOO_DEPENDENCIES = bar
  3818. 10:
  3819. 11: LUA_FOO_BUILD_OPTS += BAR_INCDIR=$(STAGING_DIR)/usr/include
  3820. 12: LUA_FOO_BUILD_OPTS += BAR_LIBDIR=$(STAGING_DIR)/usr/lib
  3821. 13: LUA_FOO_LICENSE = luaFoo license
  3822. 14: LUA_FOO_LICENSE_FILES = $(LUA_FOO_SUBDIR)/COPYING
  3823. 15:
  3824. 16: $(eval $(luarocks-package))</pre><p>On line 7, we declare the version of the package (the same as in the rockspec,
  3825. which is the concatenation of the upstream version and the rockspec revision,
  3826. separated by a hyphen <span class="emphasis"><em>-</em></span>).</p><p>On line 8, we declare that the package is called "foo" on LuaRocks. In
  3827. Buildroot, we give Lua-related packages a name that starts with "lua", so the
  3828. Buildroot name is different from the upstream name. <code class="literal">LUA_FOO_NAME_UPSTREAM</code>
  3829. makes the link between the two names.</p><p>On line 9, we declare our dependencies against native libraries, so that they
  3830. are built before the build process of our package starts.</p><p>On lines 11-12, we tell Buildroot to pass custom options to LuaRocks when it is
  3831. building the package.</p><p>On lines 13-14, we specify the licensing terms for the package.</p><p>Finally, on line 16, we invoke the <code class="literal">luarocks-package</code>
  3832. macro that generates all the Makefile rules that actually allows the
  3833. package to be built.</p><p>Most of these details can be retrieved from the <code class="literal">rock</code> and <code class="literal">rockspec</code>.
  3834. So, this file and the Config.in file can be generated by running the
  3835. command <code class="literal">luarocks buildroot foo lua-foo</code> in the Buildroot
  3836. directory. This command runs a specific Buildroot addon of <code class="literal">luarocks</code>
  3837. that will automatically generate a Buildroot package. The result must
  3838. still be manually inspected and possibly modified.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3839. The <code class="literal">package/Config.in</code> file has to be updated manually to include the
  3840. generated Config.in files.
  3841. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="luarocks-package-reference"></a>18.9.2. <code class="literal">luarocks-package</code> reference</h3></div></div></div><p>LuaRocks is a deployment and management system for Lua modules, and supports
  3842. various <code class="literal">build.type</code>: <code class="literal">builtin</code>, <code class="literal">make</code> and <code class="literal">cmake</code>. In the context of
  3843. Buildroot, the <code class="literal">luarocks-package</code> infrastructure only supports the <code class="literal">builtin</code>
  3844. mode. LuaRocks packages that use the <code class="literal">make</code> or <code class="literal">cmake</code> build mechanisms
  3845. should instead be packaged using the <code class="literal">generic-package</code> and <code class="literal">cmake-package</code>
  3846. infrastructures in Buildroot, respectively.</p><p>The main macro of the LuaRocks package infrastructure is <code class="literal">luarocks-package</code>:
  3847. like <code class="literal">generic-package</code> it works by defining a number of variables providing
  3848. metadata information about the package, and then calling <code class="literal">luarocks-package</code>.</p><p>Just like the generic infrastructure, the LuaRocks infrastructure works
  3849. by defining a number of variables before calling the <code class="literal">luarocks-package</code>
  3850. macro.</p><p>First, all the package metadata information variables that exist in
  3851. the generic infrastructure also exist in the LuaRocks infrastructure:
  3852. <code class="literal">LUA_FOO_VERSION</code>, <code class="literal">LUA_FOO_SOURCE</code>, <code class="literal">LUA_FOO_SITE</code>,
  3853. <code class="literal">LUA_FOO_DEPENDENCIES</code>, <code class="literal">LUA_FOO_LICENSE</code>, <code class="literal">LUA_FOO_LICENSE_FILES</code>.</p><p>Two of them are populated by the LuaRocks infrastructure (for the
  3854. <code class="literal">download</code> step). If your package is not hosted on the LuaRocks mirror
  3855. <code class="literal">$(BR2_LUAROCKS_MIRROR)</code>, you can override them:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3856. <code class="literal">LUA_FOO_SITE</code>, which defaults to <code class="literal">$(BR2_LUAROCKS_MIRROR)</code>
  3857. </li><li class="listitem">
  3858. <code class="literal">LUA_FOO_SOURCE</code>, which defaults to
  3859. <code class="literal">$(lowercase LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).src.rock</code>
  3860. </li></ul></div><p>A few additional variables, specific to the LuaRocks infrastructure, are
  3861. also defined. They can be overridden in specific cases.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3862. <code class="literal">LUA_FOO_NAME_UPSTREAM</code>, which defaults to <code class="literal">lua-foo</code>, i.e. the Buildroot
  3863. package name
  3864. </li><li class="listitem">
  3865. <code class="literal">LUA_FOO_ROCKSPEC</code>, which defaults to
  3866. <code class="literal">$(lowercase LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).rockspec</code>
  3867. </li><li class="listitem">
  3868. <code class="literal">LUA_FOO_SUBDIR</code>, which defaults to
  3869. <code class="literal">$(LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION_WITHOUT_ROCKSPEC_REVISION)</code>
  3870. </li><li class="listitem">
  3871. <code class="literal">LUA_FOO_BUILD_OPTS</code> contains additional build options for the
  3872. <code class="literal">luarocks build</code> call.
  3873. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_perl_cpan_packages"></a>18.10. Infrastructure for Perl/CPAN packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="perl-package-tutorial"></a>18.10.1. <code class="literal">perl-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a Perl/CPAN package,
  3874. with an example :</p><pre class="screen">01: ################################################################################
  3875. 02: #
  3876. 03: # perl-foo-bar
  3877. 04: #
  3878. 05: ################################################################################
  3879. 06:
  3880. 07: PERL_FOO_BAR_VERSION = 0.02
  3881. 08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz
  3882. 09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER
  3883. 10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures
  3884. 11: PERL_FOO_BAR_LICENSE = Artistic or GPL-1.0+
  3885. 12: PERL_FOO_BAR_LICENSE_FILES = LICENSE
  3886. 13: PERL_FOO_BAR_DISTNAME = Foo-Bar
  3887. 14:
  3888. 15: $(eval $(perl-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball and the location
  3889. of the tarball on a CPAN server. Buildroot will automatically download
  3890. the tarball from this location.</p><p>On line 10, we declare our dependencies, so that they are built
  3891. before the build process of our package starts.</p><p>On line 11 and 12, we give licensing details about the package (its
  3892. license on line 11, and the file containing the license text on line
  3893. 12).</p><p>On line 13, the name of the distribution as needed by the script
  3894. <code class="literal">utils/scancpan</code> (in order to regenerate/upgrade these package files).</p><p>Finally, on line 15, we invoke the <code class="literal">perl-package</code> macro that
  3895. generates all the Makefile rules that actually allow the package to be
  3896. built.</p><p>Most of these data can be retrieved from <a class="ulink" href="https://metacpan.org/" target="_top">https://metacpan.org/</a>.
  3897. So, this file and the Config.in can be generated by running
  3898. the script <code class="literal">utils/scancpan Foo-Bar</code> in the Buildroot directory
  3899. (or in a br2-external tree).
  3900. This script creates a Config.in file and foo-bar.mk file for the
  3901. requested package, and also recursively for all dependencies specified by
  3902. CPAN. You should still manually edit the result. In particular, the
  3903. following things should be checked.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3904. If the perl module links with a shared library that is provided by
  3905. another (non-perl) package, this dependency is not added automatically.
  3906. It has to be added manually to <code class="literal">PERL_FOO_BAR_DEPENDENCIES</code>.
  3907. </li><li class="listitem">
  3908. The <code class="literal">package/Config.in</code> file has to be updated manually to include the
  3909. generated Config.in files. As a hint, the <code class="literal">scancpan</code> script prints out
  3910. the required <code class="literal">source "…"</code> statements, sorted alphabetically.
  3911. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="perl-package-reference"></a>18.10.2. <code class="literal">perl-package</code> reference</h3></div></div></div><p>As a policy, packages that provide Perl/CPAN modules should all be
  3912. named <code class="literal">perl-&lt;something&gt;</code> in Buildroot.</p><p>This infrastructure handles various Perl build systems :
  3913. <code class="literal">ExtUtils-MakeMaker</code> (EUMM), <code class="literal">Module-Build</code> (MB) and <code class="literal">Module-Build-Tiny</code>.
  3914. <code class="literal">Build.PL</code> is preferred by default when a package provides a <code class="literal">Makefile.PL</code>
  3915. and a <code class="literal">Build.PL</code>.</p><p>The main macro of the Perl/CPAN package infrastructure is
  3916. <code class="literal">perl-package</code>. It is similar to the <code class="literal">generic-package</code> macro. The ability to
  3917. have target and host packages is also available, with the
  3918. <code class="literal">host-perl-package</code> macro.</p><p>Just like the generic infrastructure, the Perl/CPAN infrastructure
  3919. works by defining a number of variables before calling the
  3920. <code class="literal">perl-package</code> macro.</p><p>First, all the package metadata information variables that exist in the
  3921. generic infrastructure also exist in the Perl/CPAN infrastructure:
  3922. <code class="literal">PERL_FOO_VERSION</code>, <code class="literal">PERL_FOO_SOURCE</code>,
  3923. <code class="literal">PERL_FOO_PATCH</code>, <code class="literal">PERL_FOO_SITE</code>,
  3924. <code class="literal">PERL_FOO_SUBDIR</code>, <code class="literal">PERL_FOO_DEPENDENCIES</code>,
  3925. <code class="literal">PERL_FOO_INSTALL_TARGET</code>.</p><p>Note that setting <code class="literal">PERL_FOO_INSTALL_STAGING</code> to <code class="literal">YES</code> has no effect
  3926. unless a <code class="literal">PERL_FOO_INSTALL_STAGING_CMDS</code> variable is defined. The perl
  3927. infrastructure doesn’t define these commands since Perl modules generally
  3928. don’t need to be installed to the <code class="literal">staging</code> directory.</p><p>A few additional variables, specific to the Perl/CPAN infrastructure,
  3929. can also be defined. Many of them are only useful in very specific
  3930. cases, typical packages will therefore only use a few of them.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  3931. <code class="literal">PERL_FOO_PREFER_INSTALLER</code>/<code class="literal">HOST_PERL_FOO_PREFER_INSTALLER</code>,
  3932. specifies the preferred installation method. Possible values are
  3933. <code class="literal">EUMM</code> (for <code class="literal">Makefile.PL</code> based installation using
  3934. <code class="literal">ExtUtils-MakeMaker</code>) and <code class="literal">MB</code> (for <code class="literal">Build.PL</code> based installation
  3935. using <code class="literal">Module-Build</code>). This variable is only used when the package
  3936. provides both installation methods.
  3937. </li><li class="listitem">
  3938. <code class="literal">PERL_FOO_CONF_ENV</code>/<code class="literal">HOST_PERL_FOO_CONF_ENV</code>, to specify additional
  3939. environment variables to pass to the <code class="literal">perl Makefile.PL</code> or <code class="literal">perl Build.PL</code>.
  3940. By default, empty.
  3941. </li><li class="listitem">
  3942. <code class="literal">PERL_FOO_CONF_OPTS</code>/<code class="literal">HOST_PERL_FOO_CONF_OPTS</code>, to specify additional
  3943. configure options to pass to the <code class="literal">perl Makefile.PL</code> or <code class="literal">perl Build.PL</code>.
  3944. By default, empty.
  3945. </li><li class="listitem">
  3946. <code class="literal">PERL_FOO_BUILD_OPTS</code>/<code class="literal">HOST_PERL_FOO_BUILD_OPTS</code>, to specify additional
  3947. options to pass to <code class="literal">make pure_all</code> or <code class="literal">perl Build build</code> in the build step.
  3948. By default, empty.
  3949. </li><li class="listitem">
  3950. <code class="literal">PERL_FOO_INSTALL_TARGET_OPTS</code>, to specify additional options to
  3951. pass to <code class="literal">make pure_install</code> or <code class="literal">perl Build install</code> in the install step.
  3952. By default, empty.
  3953. </li><li class="listitem">
  3954. <code class="literal">HOST_PERL_FOO_INSTALL_OPTS</code>, to specify additional options to
  3955. pass to <code class="literal">make pure_install</code> or <code class="literal">perl Build install</code> in the install step.
  3956. By default, empty.
  3957. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_virtual_packages"></a>18.11. Infrastructure for virtual packages</h2></div></div></div><p><a id="virtual-package-tutorial"></a>In Buildroot, a virtual package is a package whose functionalities are
  3958. provided by one or more packages, referred to as <span class="emphasis"><em>providers</em></span>. The virtual
  3959. package management is an extensible mechanism allowing the user to choose
  3960. the provider used in the rootfs.</p><p>For example, <span class="emphasis"><em>OpenGL ES</em></span> is an API for 2D and 3D graphics on embedded systems.
  3961. The implementation of this API is different for the <span class="emphasis"><em>Allwinner Tech Sunxi</em></span> and
  3962. the <span class="emphasis"><em>Texas Instruments OMAP35xx</em></span> platforms. So <code class="literal">libgles</code> will be a virtual
  3963. package and <code class="literal">sunxi-mali</code> and <code class="literal">ti-gfx</code> will be the providers.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_literal_virtual_package_literal_tutorial"></a>18.11.1. <code class="literal">virtual-package</code> tutorial</h3></div></div></div><p>In the following example, we will explain how to add a new virtual package
  3964. (<span class="emphasis"><em>something-virtual</em></span>) and a provider for it (<span class="emphasis"><em>some-provider</em></span>).</p><p>First, let’s create the virtual package.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_virtual_package_8217_s_literal_config_in_literal_file"></a>18.11.2. Virtual package’s <code class="literal">Config.in</code> file</h3></div></div></div><p>The <code class="literal">Config.in</code> file of virtual package <span class="emphasis"><em>something-virtual</em></span> should contain:</p><pre class="screen">01: config BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  3965. 02: bool
  3966. 03:
  3967. 04: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  3968. 05: depends on BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  3969. 06: string</pre><p>In this file, we declare two options, <code class="literal">BR2_PACKAGE_HAS_SOMETHING_VIRTUAL</code> and
  3970. <code class="literal">BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL</code>, whose values will be used by the
  3971. providers.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_virtual_package_8217_s_literal_mk_literal_file"></a>18.11.3. Virtual package’s <code class="literal">.mk</code> file</h3></div></div></div><p>The <code class="literal">.mk</code> for the virtual package should just evaluate the <code class="literal">virtual-package</code> macro:</p><pre class="screen">01: ################################################################################
  3972. 02: #
  3973. 03: # something-virtual
  3974. 04: #
  3975. 05: ################################################################################
  3976. 06:
  3977. 07: $(eval $(virtual-package))</pre><p>The ability to have target and host packages is also available, with the
  3978. <code class="literal">host-virtual-package</code> macro.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_provider_8217_s_literal_config_in_literal_file"></a>18.11.4. Provider’s <code class="literal">Config.in</code> file</h3></div></div></div><p>When adding a package as a provider, only the <code class="literal">Config.in</code> file requires some
  3979. modifications.</p><p>The <code class="literal">Config.in</code> file of the package <span class="emphasis"><em>some-provider</em></span>, which provides the
  3980. functionalities of <span class="emphasis"><em>something-virtual</em></span>, should contain:</p><pre class="screen">01: config BR2_PACKAGE_SOME_PROVIDER
  3981. 02: bool "some-provider"
  3982. 03: select BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  3983. 04: help
  3984. 05: This is a comment that explains what some-provider is.
  3985. 06:
  3986. 07: http://foosoftware.org/some-provider/
  3987. 08:
  3988. 09: if BR2_PACKAGE_SOME_PROVIDER
  3989. 10: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  3990. 11: default "some-provider"
  3991. 12: endif</pre><p>On line 3, we select <code class="literal">BR2_PACKAGE_HAS_SOMETHING_VIRTUAL</code>, and on line 11, we
  3992. set the value of <code class="literal">BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL</code> to the name of the
  3993. provider, but only if it is selected.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_provider_8217_s_literal_mk_literal_file"></a>18.11.5. Provider’s <code class="literal">.mk</code> file</h3></div></div></div><p>The <code class="literal">.mk</code> file should also declare an additional variable
  3994. <code class="literal">SOME_PROVIDER_PROVIDES</code> to contain the names of all the virtual
  3995. packages it is an implementation of:</p><pre class="screen">01: SOME_PROVIDER_PROVIDES = something-virtual</pre><p>Of course, do not forget to add the proper build and runtime dependencies for
  3996. this package!</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_notes_on_depending_on_a_virtual_package"></a>18.11.6. Notes on depending on a virtual package</h3></div></div></div><p>When adding a package that requires a certain <code class="literal">FEATURE</code> provided by a virtual
  3997. package, you have to use <code class="literal">depends on BR2_PACKAGE_HAS_FEATURE</code>, like so:</p><pre class="screen">config BR2_PACKAGE_HAS_FEATURE
  3998. bool
  3999. config BR2_PACKAGE_FOO
  4000. bool "foo"
  4001. depends on BR2_PACKAGE_HAS_FEATURE</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_notes_on_depending_on_a_specific_provider"></a>18.11.7. Notes on depending on a specific provider</h3></div></div></div><p>If your package really requires a specific provider, then you’ll have to
  4002. make your package <code class="literal">depends on</code> this provider; you can <span class="emphasis"><em>not</em></span> <code class="literal">select</code> a
  4003. provider.</p><p>Let’s take an example with two providers for a <code class="literal">FEATURE</code>:</p><pre class="screen">config BR2_PACKAGE_HAS_FEATURE
  4004. bool
  4005. config BR2_PACKAGE_FOO
  4006. bool "foo"
  4007. select BR2_PACKAGE_HAS_FEATURE
  4008. config BR2_PACKAGE_BAR
  4009. bool "bar"
  4010. select BR2_PACKAGE_HAS_FEATURE</pre><p>And you are adding a package that needs <code class="literal">FEATURE</code> as provided by <code class="literal">foo</code>,
  4011. but not as provided by <code class="literal">bar</code>.</p><p>If you were to use <code class="literal">select BR2_PACKAGE_FOO</code>, then the user would still
  4012. be able to select <code class="literal">BR2_PACKAGE_BAR</code> in the menuconfig. This would create
  4013. a configuration inconsistency, whereby two providers of the same <code class="literal">FEATURE</code>
  4014. would be enabled at once, one explicitly set by the user, the other
  4015. implicitly by your <code class="literal">select</code>.</p><p>Instead, you have to use <code class="literal">depends on BR2_PACKAGE_FOO</code>, which avoids any
  4016. implicit configuration inconsistency.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_packages_using_kconfig_for_configuration_files"></a>18.12. Infrastructure for packages using kconfig for configuration files</h2></div></div></div><p>A popular way for a software package to handle user-specified
  4017. configuration is <code class="literal">kconfig</code>. Among others, it is used by the Linux
  4018. kernel, Busybox, and Buildroot itself. The presence of a .config file
  4019. and a <code class="literal">menuconfig</code> target are two well-known symptoms of kconfig being
  4020. used.</p><p>Buildroot features an infrastructure for packages that use kconfig for
  4021. their configuration. This infrastructure provides the necessary logic to
  4022. expose the package’s <code class="literal">menuconfig</code> target as <code class="literal">foo-menuconfig</code> in
  4023. Buildroot, and to handle the copying back and forth of the configuration
  4024. file in a correct way.</p><p>The <code class="literal">kconfig-package</code> infrastructure is based on the <code class="literal">generic-package</code>
  4025. infrastructure. All variables supported by <code class="literal">generic-package</code> are
  4026. available in <code class="literal">kconfig-package</code> as well. See
  4027. <a class="xref" href="#generic-package-reference" title="18.5.2. generic-package reference">Section 18.5.2, “<code class="literal">generic-package</code> reference”</a> for more details.</p><p>In order to use the <code class="literal">kconfig-package</code> infrastructure for a Buildroot
  4028. package, the minimally required lines in the <code class="literal">.mk</code> file, in addition to
  4029. the variables required by the <code class="literal">generic-package</code> infrastructure, are:</p><pre class="screen">FOO_KCONFIG_FILE = reference-to-source-configuration-file
  4030. $(eval $(kconfig-package))</pre><p>This snippet creates the following make targets:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4031. <code class="literal">foo-menuconfig</code>, which calls the package’s <code class="literal">menuconfig</code> target
  4032. </li><li class="listitem">
  4033. <code class="literal">foo-update-config</code>, which copies the configuration back to the
  4034. source configuration file. It is not possible to use this target
  4035. when fragment files are set.
  4036. </li><li class="listitem">
  4037. <code class="literal">foo-update-defconfig</code>, which copies the configuration back to the
  4038. source configuration file. The configuration file will only list the
  4039. options that differ from the default values. It is not possible to
  4040. use this target when fragment files are set.
  4041. </li><li class="listitem">
  4042. <code class="literal">foo-diff-config</code>, which outputs the differences between the current
  4043. configuration and the one defined in the Buildroot configuration for
  4044. this kconfig package. The output is useful to identify the
  4045. configuration changes that may have to be propagated to
  4046. configuration fragments for example.
  4047. </li></ul></div><p>and ensures that the source configuration file is copied to the build
  4048. directory at the right moment.</p><p>There are two options to specify a configuration file to use, either
  4049. <code class="literal">FOO_KCONFIG_FILE</code> (as in the example, above) or <code class="literal">FOO_KCONFIG_DEFCONFIG</code>.
  4050. It is mandatory to provide either, but not both:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4051. <code class="literal">FOO_KCONFIG_FILE</code> specifies the path to a defconfig or full-config file
  4052. to be used to configure the package.
  4053. </li><li class="listitem">
  4054. <code class="literal">FOO_KCONFIG_DEFCONFIG</code> specifies the defconfig <span class="emphasis"><em>make</em></span> rule to call to
  4055. configure the package.
  4056. </li></ul></div><p>In addition to these minimally required lines, several optional variables can
  4057. be set to suit the needs of the package under consideration:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4058. <code class="literal">FOO_KCONFIG_EDITORS</code>: a space-separated list of kconfig editors to
  4059. support, for example <span class="emphasis"><em>menuconfig xconfig</em></span>. By default, <span class="emphasis"><em>menuconfig</em></span>.
  4060. </li><li class="listitem">
  4061. <code class="literal">FOO_KCONFIG_FRAGMENT_FILES</code>: a space-separated list of configuration
  4062. fragment files that are merged to the main configuration file.
  4063. Fragment files are typically used when there is a desire to stay in sync
  4064. with an upstream (def)config file, with some minor modifications.
  4065. </li><li class="listitem">
  4066. <code class="literal">FOO_KCONFIG_OPTS</code>: extra options to pass when calling the kconfig
  4067. editors. This may need to include <span class="emphasis"><em>$(FOO_MAKE_OPTS)</em></span>, for example. By
  4068. default, empty.
  4069. </li><li class="listitem">
  4070. <code class="literal">FOO_KCONFIG_FIXUP_CMDS</code>: a list of shell commands needed to fixup the
  4071. configuration file after copying it or running a kconfig editor. Such
  4072. commands may be needed to ensure a configuration consistent with other
  4073. configuration of Buildroot, for example. By default, empty.
  4074. </li><li class="listitem">
  4075. <code class="literal">FOO_KCONFIG_DOTCONFIG</code>: path (with filename) of the <code class="literal">.config</code> file,
  4076. relative to the package source tree. The default, <code class="literal">.config</code>, should
  4077. be well suited for all packages that use the standard kconfig
  4078. infrastructure as inherited from the Linux kernel; some packages use
  4079. a derivative of kconfig that use a different location.
  4080. </li><li class="listitem">
  4081. <code class="literal">FOO_KCONFIG_DEPENDENCIES</code>: the list of packages (most probably, host
  4082. packages) that need to be built before this package’s kconfig is
  4083. interpreted. Seldom used. By default, empty.
  4084. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_rebar_based_packages"></a>18.13. Infrastructure for rebar-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="rebar-package-tutorial"></a>18.13.1. <code class="literal">rebar-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a rebar-based package,
  4085. with an example :</p><pre class="screen">01: ################################################################################
  4086. 02: #
  4087. 03: # erlang-foobar
  4088. 04: #
  4089. 05: ################################################################################
  4090. 06:
  4091. 07: ERLANG_FOOBAR_VERSION = 1.0
  4092. 08: ERLANG_FOOBAR_SOURCE = erlang-foobar-$(ERLANG_FOOBAR_VERSION).tar.xz
  4093. 09: ERLANG_FOOBAR_SITE = http://www.foosoftware.org/download
  4094. 10: ERLANG_FOOBAR_DEPENDENCIES = host-libaaa libbbb
  4095. 11:
  4096. 12: $(eval $(rebar-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4097. recommended) and the location of the tarball on the Web. Buildroot
  4098. will automatically download the tarball from this location.</p><p>On line 10, we declare our dependencies, so that they are built
  4099. before the build process of our package starts.</p><p>Finally, on line 12, we invoke the <code class="literal">rebar-package</code> macro that
  4100. generates all the Makefile rules that actually allows the package to
  4101. be built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="rebar-package-reference"></a>18.13.2. <code class="literal">rebar-package</code> reference</h3></div></div></div><p>The main macro of the <code class="literal">rebar</code> package infrastructure is
  4102. <code class="literal">rebar-package</code>. It is similar to the <code class="literal">generic-package</code> macro. The
  4103. ability to have host packages is also available, with the
  4104. <code class="literal">host-rebar-package</code> macro.</p><p>Just like the generic infrastructure, the <code class="literal">rebar</code> infrastructure works
  4105. by defining a number of variables before calling the <code class="literal">rebar-package</code>
  4106. macro.</p><p>First, all the package metadata information variables that exist in
  4107. the generic infrastructure also exist in the <code class="literal">rebar</code> infrastructure:
  4108. <code class="literal">ERLANG_FOOBAR_VERSION</code>, <code class="literal">ERLANG_FOOBAR_SOURCE</code>,
  4109. <code class="literal">ERLANG_FOOBAR_PATCH</code>, <code class="literal">ERLANG_FOOBAR_SITE</code>,
  4110. <code class="literal">ERLANG_FOOBAR_SUBDIR</code>, <code class="literal">ERLANG_FOOBAR_DEPENDENCIES</code>,
  4111. <code class="literal">ERLANG_FOOBAR_INSTALL_STAGING</code>, <code class="literal">ERLANG_FOOBAR_INSTALL_TARGET</code>,
  4112. <code class="literal">ERLANG_FOOBAR_LICENSE</code> and <code class="literal">ERLANG_FOOBAR_LICENSE_FILES</code>.</p><p>A few additional variables, specific to the <code class="literal">rebar</code> infrastructure,
  4113. can also be defined. Many of them are only useful in very specific
  4114. cases, typical packages will therefore only use a few of them.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  4115. <code class="literal">ERLANG_FOOBAR_USE_AUTOCONF</code>, to specify that the package uses
  4116. <span class="emphasis"><em>autoconf</em></span> at the configuration step. When a package sets this
  4117. variable to <code class="literal">YES</code>, the <code class="literal">autotools</code> infrastructure is used.
  4118. </p><p><strong>Note. </strong>You can also use some of the variables from the <code class="literal">autotools</code>
  4119. infrastructure: <code class="literal">ERLANG_FOOBAR_CONF_ENV</code>, <code class="literal">ERLANG_FOOBAR_CONF_OPTS</code>,
  4120. <code class="literal">ERLANG_FOOBAR_AUTORECONF</code>, <code class="literal">ERLANG_FOOBAR_AUTORECONF_ENV</code> and
  4121. <code class="literal">ERLANG_FOOBAR_AUTORECONF_OPTS</code>.</p></li><li class="listitem"><p class="simpara">
  4122. <code class="literal">ERLANG_FOOBAR_USE_BUNDLED_REBAR</code>, to specify that the package has
  4123. a bundled version of <span class="emphasis"><em>rebar</em></span> <span class="strong"><strong>and</strong></span> that it shall be used. Valid
  4124. values are <code class="literal">YES</code> or <code class="literal">NO</code> (the default).
  4125. </p><p><strong>Note. </strong>If the package bundles a <span class="emphasis"><em>rebar</em></span> utility, but can use the generic
  4126. one that Buildroot provides, just say <code class="literal">NO</code> (i.e., do not specify
  4127. this variable). Only set if it is mandatory to use the <span class="emphasis"><em>rebar</em></span>
  4128. utility bundled in this package.</p></li><li class="listitem">
  4129. <code class="literal">ERLANG_FOOBAR_REBAR_ENV</code>, to specify additional environment
  4130. variables to pass to the <span class="emphasis"><em>rebar</em></span> utility.
  4131. </li><li class="listitem">
  4132. <code class="literal">ERLANG_FOOBAR_KEEP_DEPENDENCIES</code>, to keep the dependencies
  4133. described in the rebar.config file. Valid values are <code class="literal">YES</code> or <code class="literal">NO</code>
  4134. (the default). Unless this variable is set to <code class="literal">YES</code>, the <span class="emphasis"><em>rebar</em></span>
  4135. infrastructure removes such dependencies in a post-patch hook to
  4136. ensure rebar does not download nor compile them.
  4137. </li></ul></div><p>With the rebar infrastructure, all the steps required to build
  4138. and install the packages are already defined, and they generally work
  4139. well for most rebar-based packages. However, when required, it is
  4140. still possible to customize what is done in any particular step:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4141. By adding a post-operation hook (after extract, patch, configure,
  4142. build or install). See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for details.
  4143. </li><li class="listitem">
  4144. By overriding one of the steps. For example, even if the rebar
  4145. infrastructure is used, if the package <code class="literal">.mk</code> file defines its
  4146. own <code class="literal">ERLANG_FOOBAR_BUILD_CMDS</code> variable, it will be used instead
  4147. of the default rebar one. However, using this method should be
  4148. restricted to very specific cases. Do not use it in the general
  4149. case.
  4150. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_waf_based_packages"></a>18.14. Infrastructure for Waf-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="waf-package-tutorial"></a>18.14.1. <code class="literal">waf-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a Waf-based package, with
  4151. an example :</p><pre class="screen">01: ################################################################################
  4152. 02: #
  4153. 03: # libfoo
  4154. 04: #
  4155. 05: ################################################################################
  4156. 06:
  4157. 07: LIBFOO_VERSION = 1.0
  4158. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  4159. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  4160. 10: LIBFOO_CONF_OPTS = --enable-bar --disable-baz
  4161. 11: LIBFOO_DEPENDENCIES = bar
  4162. 12:
  4163. 13: $(eval $(waf-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4164. recommended) and the location of the tarball on the Web. Buildroot
  4165. will automatically download the tarball from this location.</p><p>On line 10, we tell Buildroot what options to enable for libfoo.</p><p>On line 11, we tell Buildroot the dependencies of libfoo.</p><p>Finally, on line line 13, we invoke the <code class="literal">waf-package</code>
  4166. macro that generates all the Makefile rules that actually allows the
  4167. package to be built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="waf-package-reference"></a>18.14.2. <code class="literal">waf-package</code> reference</h3></div></div></div><p>The main macro of the Waf package infrastructure is <code class="literal">waf-package</code>.
  4168. It is similar to the <code class="literal">generic-package</code> macro.</p><p>Just like the generic infrastructure, the Waf infrastructure works
  4169. by defining a number of variables before calling the <code class="literal">waf-package</code>
  4170. macro.</p><p>First, all the package metadata information variables that exist in
  4171. the generic infrastructure also exist in the Waf infrastructure:
  4172. <code class="literal">LIBFOO_VERSION</code>, <code class="literal">LIBFOO_SOURCE</code>, <code class="literal">LIBFOO_PATCH</code>, <code class="literal">LIBFOO_SITE</code>,
  4173. <code class="literal">LIBFOO_SUBDIR</code>, <code class="literal">LIBFOO_DEPENDENCIES</code>, <code class="literal">LIBFOO_INSTALL_STAGING</code>,
  4174. <code class="literal">LIBFOO_INSTALL_TARGET</code>.</p><p>An additional variable, specific to the Waf infrastructure, can
  4175. also be defined.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4176. <code class="literal">LIBFOO_SUBDIR</code> may contain the name of a subdirectory inside the
  4177. package that contains the main wscript file. This is useful,
  4178. if for example, the main wscript file is not at the root of
  4179. the tree extracted by the tarball. If <code class="literal">HOST_LIBFOO_SUBDIR</code> is not
  4180. specified, it defaults to <code class="literal">LIBFOO_SUBDIR</code>.
  4181. </li><li class="listitem">
  4182. <code class="literal">LIBFOO_NEEDS_EXTERNAL_WAF</code> can be set to <code class="literal">YES</code> or <code class="literal">NO</code> to tell
  4183. Buildroot to use the bundled <code class="literal">waf</code> executable. If set to <code class="literal">NO</code>, the
  4184. default, then Buildroot will use the waf executable provided in the
  4185. package source tree; if set to <code class="literal">YES</code>, then Buildroot will download,
  4186. install waf as a host tool and use it to build the package.
  4187. </li><li class="listitem">
  4188. <code class="literal">LIBFOO_WAF_OPTS</code>, to specify additional options to pass to the
  4189. <code class="literal">waf</code> script at every step of the package build process: configure,
  4190. build and installation. By default, empty.
  4191. </li><li class="listitem">
  4192. <code class="literal">LIBFOO_CONF_OPTS</code>, to specify additional options to pass to the
  4193. <code class="literal">waf</code> script for the configuration step. By default, empty.
  4194. </li><li class="listitem">
  4195. <code class="literal">LIBFOO_BUILD_OPTS</code>, to specify additional options to pass to the
  4196. <code class="literal">waf</code> script during the build step. By default, empty.
  4197. </li><li class="listitem">
  4198. <code class="literal">LIBFOO_INSTALL_STAGING_OPTS</code>, to specify additional options to pass
  4199. to the <code class="literal">waf</code> script during the staging installation step. By default,
  4200. empty.
  4201. </li><li class="listitem">
  4202. <code class="literal">LIBFOO_INSTALL_TARGET_OPTS</code>, to specify additional options to pass
  4203. to the <code class="literal">waf</code> script during the target installation step. By default,
  4204. empty.
  4205. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_meson_based_packages"></a>18.15. Infrastructure for Meson-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="meson-package-tutorial"></a>18.15.1. <code class="literal">meson-package</code> tutorial</h3></div></div></div><p><a class="ulink" href="http://mesonbuild.com" target="_top">Meson</a> is an open source build system meant to be both
  4206. extremely fast, and, even more importantly, as user friendly as possible. It
  4207. uses <a class="ulink" href="https://ninja-build.org" target="_top">Ninja</a> as a companion tool to perform the actual
  4208. build operations.</p><p>Let’s see how to write a <code class="literal">.mk</code> file for a Meson-based package, with an example:</p><pre class="screen">01: ################################################################################
  4209. 02: #
  4210. 03: # foo
  4211. 04: #
  4212. 05: ################################################################################
  4213. 06:
  4214. 07: FOO_VERSION = 1.0
  4215. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
  4216. 09: FOO_SITE = http://www.foosoftware.org/download
  4217. 10: FOO_LICENSE = GPL-3.0+
  4218. 11: FOO_LICENSE_FILES = COPYING
  4219. 12: FOO_INSTALL_STAGING = YES
  4220. 13:
  4221. 14: FOO_DEPENDENCIES = host-pkgconf bar
  4222. 15:
  4223. 16: ifeq ($(BR2_PACKAGE_BAZ),y)
  4224. 17: FOO_CONF_OPTS += -Dbaz=true
  4225. 18: FOO_DEPENDENCIES += baz
  4226. 19: else
  4227. 20: FOO_CONF_OPTS += -Dbaz=false
  4228. 21: endif
  4229. 22:
  4230. 23: $(eval $(meson-package))</pre><p>The Makefile starts with the definition of the standard variables for package
  4231. declaration (lines 7 to 11).</p><p>On line line 23, we invoke the <code class="literal">meson-package</code> macro that generates all the
  4232. Makefile rules that actually allows the package to be built.</p><p>In the example, <code class="literal">host-pkgconf</code> and <code class="literal">bar</code> are declared as dependencies in
  4233. <code class="literal">FOO_DEPENDENCIES</code> at line 14 because the Meson build file of <code class="literal">foo</code> uses
  4234. <code class="literal">pkg-config</code> to determine the compilation flags and libraries of package <code class="literal">bar</code>.</p><p>Note that it is not necessary to add <code class="literal">host-meson</code> in the <code class="literal">FOO_DEPENDENCIES</code>
  4235. variable of a package, since this basic dependency is automatically added as
  4236. needed by the Meson package infrastructure.</p><p>If the "baz" package is selected, then support for the "baz" feature in "foo" is
  4237. activated by adding <code class="literal">-Dbaz=true</code> to <code class="literal">FOO_CONF_OPTS</code> at line 17, as specified in
  4238. the <code class="literal">meson_options.txt</code> file in "foo" source tree. The "baz" package is also
  4239. added to <code class="literal">FOO_DEPENDENCIES</code>. Note that the support for <code class="literal">baz</code> is explicitly
  4240. disabled at line 20, if the package is not selected.</p><p>To sum it up, to add a new meson-based package, the Makefile example can be
  4241. copied verbatim then edited to replace all occurences of <code class="literal">FOO</code> with the
  4242. uppercase name of the new package and update the values of the standard
  4243. variables.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="meson-package-reference"></a>18.15.2. <code class="literal">meson-package</code> reference</h3></div></div></div><p>The main macro of the Meson package infrastructure is <code class="literal">meson-package</code>. It is
  4244. similar to the <code class="literal">generic-package</code> macro. The ability to have target and host
  4245. packages is also available, with the <code class="literal">host-meson-package</code> macro.</p><p>Just like the generic infrastructure, the Meson infrastructure works by defining
  4246. a number of variables before calling the <code class="literal">meson-package</code> macro.</p><p>First, all the package metadata information variables that exist in the generic
  4247. infrastructure also exist in the Meson infrastructure: <code class="literal">FOO_VERSION</code>,
  4248. <code class="literal">FOO_SOURCE</code>, <code class="literal">FOO_PATCH</code>, <code class="literal">FOO_SITE</code>, <code class="literal">FOO_SUBDIR</code>, <code class="literal">FOO_DEPENDENCIES</code>,
  4249. <code class="literal">FOO_INSTALL_STAGING</code>, <code class="literal">FOO_INSTALL_TARGET</code>.</p><p>A few additional variables, specific to the Meson infrastructure, can also be
  4250. defined. Many of them are only useful in very specific cases, typical packages
  4251. will therefore only use a few of them.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4252. <code class="literal">FOO_SUBDIR</code> may contain the name of a subdirectory inside the
  4253. package that contains the main meson.build file. This is useful,
  4254. if for example, the main meson.build file is not at the root of
  4255. the tree extracted by the tarball. If <code class="literal">HOST_FOO_SUBDIR</code> is not
  4256. specified, it defaults to <code class="literal">FOO_SUBDIR</code>.
  4257. </li><li class="listitem">
  4258. <code class="literal">FOO_CONF_ENV</code>, to specify additional environment variables to pass to
  4259. <code class="literal">meson</code> for the configuration step. By default, empty.
  4260. </li><li class="listitem">
  4261. <code class="literal">FOO_CONF_OPTS</code>, to specify additional options to pass to <code class="literal">meson</code> for the
  4262. configuration step. By default, empty.
  4263. </li><li class="listitem">
  4264. <code class="literal">FOO_CFLAGS</code>, to specify compiler arguments added to the package specific
  4265. <code class="literal">cross-compile.conf</code> file <code class="literal">c_args</code> property. By default, the value of
  4266. <code class="literal">TARGET_CFLAGS</code>.
  4267. </li><li class="listitem">
  4268. <code class="literal">FOO_CXXFLAGS</code>, to specify compiler arguments added to the package specific
  4269. <code class="literal">cross-compile.conf</code> file <code class="literal">cpp_args</code> property. By default, the value of
  4270. <code class="literal">TARGET_CXXFLAGS</code>.
  4271. </li><li class="listitem">
  4272. <code class="literal">FOO_LDFLAGS</code>, to specify compiler arguments added to the package specific
  4273. <code class="literal">cross-compile.conf</code> file <code class="literal">c_link_args</code> and <code class="literal">cpp_link_args</code> properties. By
  4274. default, the value of <code class="literal">TARGET_LDFLAGS</code>.
  4275. </li><li class="listitem">
  4276. <code class="literal">FOO_MESON_EXTRA_BINARIES</code>, to specify a space-separated list of programs
  4277. to add to the <code class="literal">[binaries]</code> section of the meson <code class="literal">cross-compilation.conf</code>
  4278. configuration file. The format is <code class="literal">program-name='/path/to/program'</code>, with
  4279. no space around the <code class="literal">=</code> sign, and with the path of the program between
  4280. single quotes. By default, empty. Note that Buildroot already sets the
  4281. correct values for <code class="literal">c</code>, <code class="literal">cpp</code>, <code class="literal">ar</code>, <code class="literal">strip</code>, and <code class="literal">pkgconfig</code>.
  4282. </li><li class="listitem">
  4283. <code class="literal">FOO_MESON_EXTRA_PROPERTIES</code>, to specify a space-separated list of
  4284. properties to add to the <code class="literal">[properties]</code> section of the meson
  4285. <code class="literal">cross-compilation.conf</code> configuration file. The format is
  4286. <code class="literal">property-name=&lt;value&gt;</code> with no space around the <code class="literal">=</code> sign, and with
  4287. single quotes around string values. By default, empty. Note that
  4288. Buildroot already sets values for <code class="literal">needs_exe_wrapper</code>, <code class="literal">c_args</code>,
  4289. <code class="literal">c_link_args</code>, <code class="literal">cpp_args</code>, <code class="literal">cpp_link_args</code>, <code class="literal">sys_root</code>, and
  4290. <code class="literal">pkg_config_libdir</code>.
  4291. </li><li class="listitem">
  4292. <code class="literal">FOO_NINJA_ENV</code>, to specify additional environment variables to pass to
  4293. <code class="literal">ninja</code>, meson companion tool in charge of the build operations. By default,
  4294. empty.
  4295. </li><li class="listitem">
  4296. <code class="literal">FOO_NINJA_OPTS</code>, to specify a space-separated list of targets to build. By
  4297. default, empty, to build the default target(s).
  4298. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_integration_of_cargo_based_packages"></a>18.16. Integration of Cargo-based packages</h2></div></div></div><p>Cargo is the package manager for the Rust programming language. It allows the
  4299. user to build programs or libraries written in Rust, but it also downloads and
  4300. manages their dependencies, to ensure repeatable builds. Cargo packages are
  4301. called "crates".</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="cargo-package-tutorial"></a>18.16.1. Cargo-based package’s <code class="literal">Config.in</code> file</h3></div></div></div><p>The <code class="literal">Config.in</code> file of Cargo-based package <span class="emphasis"><em>foo</em></span> should contain:</p><pre class="screen">01: config BR2_PACKAGE_FOO
  4302. 02: bool "foo"
  4303. 03: depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
  4304. 04: select BR2_PACKAGE_HOST_RUSTC
  4305. 05: help
  4306. 06: This is a comment that explains what foo is.
  4307. 07:
  4308. 08: http://foosoftware.org/foo/</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_cargo_based_package_8217_s_literal_mk_literal_file"></a>18.16.2. Cargo-based package’s <code class="literal">.mk</code> file</h3></div></div></div><p>Buildroot does not (yet) provide a dedicated package infrastructure for
  4309. Cargo-based packages. So, we will explain how to write a <code class="literal">.mk</code> file for such a
  4310. package. Let’s start with an example:</p><pre class="screen">01: ################################################################################
  4311. 02: #
  4312. 03: # foo
  4313. 04: #
  4314. 05: ################################################################################
  4315. 06:
  4316. 07: FOO_VERSION = 1.0
  4317. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
  4318. 09: FOO_SITE = http://www.foosoftware.org/download
  4319. 10: FOO_LICENSE = GPL-3.0+
  4320. 11: FOO_LICENSE_FILES = COPYING
  4321. 12:
  4322. 13: FOO_DEPENDENCIES = host-rustc
  4323. 14:
  4324. 15: FOO_CARGO_ENV = CARGO_HOME=$(HOST_DIR)/share/cargo
  4325. 16:
  4326. 17: FOO_BIN_DIR = target/$(RUSTC_TARGET_NAME)/$(FOO_CARGO_MODE)
  4327. 18:
  4328. 19: FOO_CARGO_OPTS = \
  4329. 20: $(if $(BR2_ENABLE_DEBUG),,--release) \
  4330. 21: --target=$(RUSTC_TARGET_NAME) \
  4331. 22: --manifest-path=$(@D)/Cargo.toml
  4332. 23:
  4333. 24: define FOO_BUILD_CMDS
  4334. 25: $(TARGET_MAKE_ENV) $(FOO_CARGO_ENV) \
  4335. 26: cargo build $(FOO_CARGO_OPTS)
  4336. 27: endef
  4337. 28:
  4338. 29: define FOO_INSTALL_TARGET_CMDS
  4339. 30: $(INSTALL) -D -m 0755 $(@D)/$(FOO_BIN_DIR)/foo \
  4340. 31: $(TARGET_DIR)/usr/bin/foo
  4341. 32: endef
  4342. 33:
  4343. 34: $(eval $(generic-package))</pre><p>The Makefile starts with the definition of the standard variables for package
  4344. declaration (lines 7 to 11).</p><p>As seen in line 34, it is based on the
  4345. <a class="link" href="#generic-package-tutorial" title="18.5.1. generic-package tutorial"><code class="literal">generic-package</code> infrastructure</a>. So, it defines
  4346. the variables required by this particular infrastructure, where Cargo is
  4347. invoked:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4348. <code class="literal">FOO_BUILD_CMDS</code>: Cargo is invoked to perform the build. The options required
  4349. to configure the cross-compilation of the package are passed via
  4350. <code class="literal">FOO_CONF_OPTS</code>.
  4351. </li><li class="listitem">
  4352. <code class="literal">FOO_INSTALL_TARGET_CMDS</code>: The binary executable generated is installed on
  4353. the target.
  4354. </li></ul></div><p>In order to have Cargo available for the build, <code class="literal">FOO_DEPENDENCIES</code> needs to
  4355. contain <code class="literal">host-cargo</code>.</p><p>To sum it up, to add a new Cargo-based package, the Makefile example can be
  4356. copied verbatim then edited to replace all occurences of <code class="literal">FOO</code> with the
  4357. uppercase name of the new package and update the values of the standard
  4358. variables.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_about_dependencies_management"></a>18.16.3. About Dependencies Management</h3></div></div></div><p>A crate can depend on other libraries from crates.io or git repositories, listed
  4359. in its Cargo.toml file. Before starting a build, Cargo usually downloads
  4360. automatically them. This step can also be performed independently, via the
  4361. <code class="literal">cargo fetch</code> command.</p><p>Cargo maintains a local cache of the registry index and of git checkouts of the
  4362. crates, whose location is given by <code class="literal">$CARGO_HOME</code>. As seen in the package
  4363. Makefile example at line 15, this environment variable is set to
  4364. <code class="literal">$(HOST_DIR)/share/cargo</code>.</p><p>This dependency download mechanism is not convenient when performing an offline
  4365. build, as Cargo will fail to fetch the dependencies. In that case, it is advised
  4366. to generate a tarball of the dependencies using the <code class="literal">cargo vendor</code> and add it to
  4367. <code class="literal">FOO_EXTRA_DOWNLOADS</code>.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_go_packages"></a>18.17. Infrastructure for Go packages</h2></div></div></div><p>This infrastructure applies to Go packages that use the standard
  4368. build system and use bundled dependencies.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="golang-package-tutorial"></a>18.17.1. <code class="literal">golang-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a go package,
  4369. with an example :</p><pre class="screen">01: ################################################################################
  4370. 02: #
  4371. 03: # foo
  4372. 04: #
  4373. 05: ################################################################################
  4374. 06:
  4375. 07: FOO_VERSION = 1.0
  4376. 08: FOO_SITE = $(call github,bar,foo,$(FOO_VERSION))
  4377. 09: FOO_LICENSE = BSD-3-Clause
  4378. 10: FOO_LICENSE_FILES = LICENSE
  4379. 11:
  4380. 12: $(eval $(golang-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8, we declare the upstream location of the package, here
  4381. fetched from Github, since a large number of Go packages are hosted on
  4382. Github.</p><p>On line 9 and 10, we give licensing details about the package.</p><p>Finally, on line 12, we invoke the <code class="literal">golang-package</code> macro that
  4383. generates all the Makefile rules that actually allow the package to be
  4384. built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="golang-package-reference"></a>18.17.2. <code class="literal">golang-package</code> reference</h3></div></div></div><p>In their <code class="literal">Config.in</code> file, packages using the <code class="literal">golang-package</code>
  4385. infrastructure should depend on <code class="literal">BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS</code>
  4386. because Buildroot will automatically add a dependency on <code class="literal">host-go</code>
  4387. to such packages.
  4388. If you need CGO support in your package, you must add a dependency on
  4389. <code class="literal">BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS</code>.</p><p>The main macro of the Go package infrastructure is
  4390. <code class="literal">golang-package</code>. It is similar to the <code class="literal">generic-package</code> macro. The
  4391. ability to build host packages is also available, with the
  4392. <code class="literal">host-golang-package</code> macro.
  4393. Host packages built by <code class="literal">host-golang-package</code> macro should depend on
  4394. BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS.</p><p>Just like the generic infrastructure, the Go infrastructure works
  4395. by defining a number of variables before calling the <code class="literal">golang-package</code>.</p><p>All the package metadata information variables that exist in the
  4396. <a class="link" href="#generic-package-reference" title="18.5.2. generic-package reference">generic package infrastructure</a> also
  4397. exist in the Go infrastructure: <code class="literal">FOO_VERSION</code>, <code class="literal">FOO_SOURCE</code>,
  4398. <code class="literal">FOO_PATCH</code>, <code class="literal">FOO_SITE</code>, <code class="literal">FOO_SUBDIR</code>, <code class="literal">FOO_DEPENDENCIES</code>,
  4399. <code class="literal">FOO_LICENSE</code>, <code class="literal">FOO_LICENSE_FILES</code>, <code class="literal">FOO_INSTALL_STAGING</code>, etc.</p><p>Note that it is not necessary to add <code class="literal">host-go</code> in the
  4400. <code class="literal">FOO_DEPENDENCIES</code> variable of a package, since this basic dependency
  4401. is automatically added as needed by the Go package infrastructure.</p><p>A few additional variables, specific to the Go infrastructure, can
  4402. optionally be defined, depending on the package’s needs. Many of them
  4403. are only useful in very specific cases, typical packages will
  4404. therefore only use a few of them, or none.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4405. The package must specify its Go module name in the <code class="literal">FOO_GOMOD</code>
  4406. variable. If not specified, it defaults to
  4407. <code class="literal">URL-domain/1st-part-of-URL/2nd-part-of-URL</code>, e.g <code class="literal">FOO_GOMOD</code> will
  4408. take the value <code class="literal">github.com/bar/foo</code> for a package that specifies
  4409. <code class="literal">FOO_SITE = $(call github,bar,foo,$(FOO_VERSION))</code>. The Go package
  4410. infrastructure will automatically generate a minimal <code class="literal">go.mod</code> file
  4411. in the package source tree if it doesn’t exist.
  4412. </li><li class="listitem">
  4413. <code class="literal">FOO_LDFLAGS</code> and <code class="literal">FOO_TAGS</code> can be used to pass respectively the
  4414. <code class="literal">LDFLAGS</code> or the <code class="literal">TAGS</code> to the <code class="literal">go</code> build command.
  4415. </li><li class="listitem"><p class="simpara">
  4416. <code class="literal">FOO_BUILD_TARGETS</code> can be used to pass the list of targets that
  4417. should be built. If <code class="literal">FOO_BUILD_TARGETS</code> is not specified, it
  4418. defaults to <code class="literal">.</code>. We then have two cases:
  4419. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  4420. <code class="literal">FOO_BUILD_TARGETS</code> is <code class="literal">.</code>. In this case, we assume only one binary
  4421. will be produced, and that by default we name it after the package
  4422. name. If that is not appropriate, the name of the produced binary
  4423. can be overridden using <code class="literal">FOO_BIN_NAME</code>.
  4424. </li><li class="listitem">
  4425. <code class="literal">FOO_BUILD_TARGETS</code> is not <code class="literal">.</code>. In this case, we iterate over the
  4426. values to build each target, and for each produced a binary that is
  4427. the non-directory component of the target. For example if
  4428. <code class="literal">FOO_BUILD_TARGETS = cmd/docker cmd/dockerd</code> the binaries produced
  4429. are <code class="literal">docker</code> and <code class="literal">dockerd</code>.
  4430. </li></ul></div></li><li class="listitem">
  4431. <code class="literal">FOO_INSTALL_BINS</code> can be used to pass the list of binaries that
  4432. should be installed in <code class="literal">/usr/bin</code> on the target. If
  4433. <code class="literal">FOO_INSTALL_BINS</code> is not specified, it defaults to the lower-case
  4434. name of package.
  4435. </li></ul></div><p>With the Go infrastructure, all the steps required to build and
  4436. install the packages are already defined, and they generally work well
  4437. for most Go-based packages. However, when required, it is still
  4438. possible to customize what is done in any particular step:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4439. By adding a post-operation hook (after extract, patch, configure,
  4440. build or install). See <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for details.
  4441. </li><li class="listitem">
  4442. By overriding one of the steps. For example, even if the Go
  4443. infrastructure is used, if the package <code class="literal">.mk</code> file defines its own
  4444. <code class="literal">FOO_BUILD_CMDS</code> variable, it will be used instead of the default Go
  4445. one. However, using this method should be restricted to very
  4446. specific cases. Do not use it in the general case.
  4447. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_qmake_based_packages"></a>18.18. Infrastructure for QMake-based packages</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="qmake-package-tutorial"></a>18.18.1. <code class="literal">qmake-package</code> tutorial</h3></div></div></div><p>First, let’s see how to write a <code class="literal">.mk</code> file for a QMake-based package, with
  4448. an example :</p><pre class="screen">01: ################################################################################
  4449. 02: #
  4450. 03: # libfoo
  4451. 04: #
  4452. 05: ################################################################################
  4453. 06:
  4454. 07: LIBFOO_VERSION = 1.0
  4455. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  4456. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  4457. 10: LIBFOO_CONF_OPTS = QT_CONFIG+=bar QT_CONFIG-=baz
  4458. 11: LIBFOO_DEPENDENCIES = bar
  4459. 12:
  4460. 13: $(eval $(qmake-package))</pre><p>On line 7, we declare the version of the package.</p><p>On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4461. recommended) and the location of the tarball on the Web. Buildroot
  4462. will automatically download the tarball from this location.</p><p>On line 10, we tell Buildroot what options to enable for libfoo.</p><p>On line 11, we tell Buildroot the dependencies of libfoo.</p><p>Finally, on line line 13, we invoke the <code class="literal">qmake-package</code>
  4463. macro that generates all the Makefile rules that actually allows the
  4464. package to be built.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="qmake-package-reference"></a>18.18.2. <code class="literal">qmake-package</code> reference</h3></div></div></div><p>The main macro of the QMake package infrastructure is <code class="literal">qmake-package</code>.
  4465. It is similar to the <code class="literal">generic-package</code> macro.</p><p>Just like the generic infrastructure, the QMake infrastructure works
  4466. by defining a number of variables before calling the <code class="literal">qmake-package</code>
  4467. macro.</p><p>First, all the package metadata information variables that exist in
  4468. the generic infrastructure also exist in the QMake infrastructure:
  4469. <code class="literal">LIBFOO_VERSION</code>, <code class="literal">LIBFOO_SOURCE</code>, <code class="literal">LIBFOO_PATCH</code>, <code class="literal">LIBFOO_SITE</code>,
  4470. <code class="literal">LIBFOO_SUBDIR</code>, <code class="literal">LIBFOO_DEPENDENCIES</code>, <code class="literal">LIBFOO_INSTALL_STAGING</code>,
  4471. <code class="literal">LIBFOO_INSTALL_TARGET</code>.</p><p>An additional variable, specific to the QMake infrastructure, can
  4472. also be defined.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4473. <code class="literal">LIBFOO_CONF_ENV</code>, to specify additional environment variables to
  4474. pass to the <code class="literal">qmake</code> script for the configuration step. By default, empty.
  4475. </li><li class="listitem">
  4476. <code class="literal">LIBFOO_CONF_OPTS</code>, to specify additional options to pass to the
  4477. <code class="literal">qmake</code> script for the configuration step. By default, empty.
  4478. </li><li class="listitem">
  4479. <code class="literal">LIBFOO_MAKE_ENV</code>, to specify additional environment variables to the
  4480. <code class="literal">make</code> command during the build and install steps. By default, empty.
  4481. </li><li class="listitem">
  4482. <code class="literal">LIBFOO_MAKE_OPTS</code>, to specify additional targets to pass to the
  4483. <code class="literal">make</code> command during the build step. By default, empty.
  4484. </li><li class="listitem">
  4485. <code class="literal">LIBFOO_INSTALL_STAGING_OPTS</code>, to specify additional targets to pass
  4486. to the <code class="literal">make</code> command during the staging installation step. By default,
  4487. <code class="literal">install</code>.
  4488. </li><li class="listitem">
  4489. <code class="literal">LIBFOO_INSTALL_TARGET_OPTS</code>, to specify additional targets to pass
  4490. to the <code class="literal">make</code> command during the target installation step. By default,
  4491. <code class="literal">install</code>.
  4492. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_packages_building_kernel_modules"></a>18.19. Infrastructure for packages building kernel modules</h2></div></div></div><p>Buildroot offers a helper infrastructure to make it easy to write packages that
  4493. build and install Linux kernel modules. Some packages only contain a kernel
  4494. module, other packages contain programs and libraries in addition to kernel
  4495. modules. Buildroot’s helper infrastructure supports either case.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="kernel-module-tutorial"></a>18.19.1. <code class="literal">kernel-module</code> tutorial</h3></div></div></div><p>Let’s start with an example on how to prepare a simple package that only
  4496. builds a kernel module, and no other component:</p><pre class="screen">01: ################################################################################
  4497. 02: #
  4498. 03: # foo
  4499. 04: #
  4500. 05: ################################################################################
  4501. 06:
  4502. 07: FOO_VERSION = 1.2.3
  4503. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
  4504. 09: FOO_SITE = http://www.foosoftware.org/download
  4505. 10: FOO_LICENSE = GPL-2.0
  4506. 11: FOO_LICENSE_FILES = COPYING
  4507. 12:
  4508. 13: $(eval $(kernel-module))
  4509. 14: $(eval $(generic-package))</pre><p>Lines 7-11 define the usual meta-data to specify the version, archive name,
  4510. remote URI where to find the package source, licensing information.</p><p>On line 13, we invoke the <code class="literal">kernel-module</code> helper infrastructure, that
  4511. generates all the appropriate Makefile rules and variables to build
  4512. that kernel module.</p><p>Finally, on line 14, we invoke the
  4513. <a class="link" href="#generic-package-tutorial" title="18.5.1. generic-package tutorial"><code class="literal">generic-package</code> infrastructure</a>.</p><p>The dependency on <code class="literal">linux</code> is automatically added, so it is not needed to
  4514. specify it in <code class="literal">FOO_DEPENDENCIES</code>.</p><p>What you may have noticed is that, unlike other package infrastructures,
  4515. we explicitly invoke a second infrastructure. This allows a package to
  4516. build a kernel module, but also, if needed, use any one of other package
  4517. infrastructures to build normal userland components (libraries,
  4518. executables…). Using the <code class="literal">kernel-module</code> infrastructure on its own is
  4519. not sufficient; another package infrastructure <span class="strong"><strong>must</strong></span> be used.</p><p>Let’s look at a more complex example:</p><pre class="screen">01: ################################################################################
  4520. 02: #
  4521. 03: # foo
  4522. 04: #
  4523. 05: ################################################################################
  4524. 06:
  4525. 07: FOO_VERSION = 1.2.3
  4526. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
  4527. 09: FOO_SITE = http://www.foosoftware.org/download
  4528. 10: FOO_LICENSE = GPL-2.0
  4529. 11: FOO_LICENSE_FILES = COPYING
  4530. 12:
  4531. 13: FOO_MODULE_SUBDIRS = driver/base
  4532. 14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
  4533. 15:
  4534. 16: ifeq ($(BR2_PACKAGE_LIBBAR),y)
  4535. 17: FOO_DEPENDENCIES = libbar
  4536. 18: FOO_CONF_OPTS = --enable-bar
  4537. 19: FOO_MODULE_SUBDIRS += driver/bar
  4538. 20: else
  4539. 21: FOO_CONF_OPTS = --disable-bar
  4540. 22: endif
  4541. 23:
  4542. 24: $(eval $(kernel-module))
  4543. 26: $(eval $(autotools-package))</pre><p>Here, we see that we have an autotools-based package, that also builds
  4544. the kernel module located in sub-directory <code class="literal">driver/base</code> and, if libbar
  4545. is enabled, the kernel module located in sub-directory <code class="literal">driver/bar</code>, and
  4546. defines the variable <code class="literal">KVERSION</code> to be passed to the Linux buildsystem
  4547. when building the module(s).</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="kernel-module-reference"></a>18.19.2. <code class="literal">kernel-module</code> reference</h3></div></div></div><p>The main macro for the kernel module infrastructure is <code class="literal">kernel-module</code>.
  4548. Unlike other package infrastructures, it is not stand-alone, and requires
  4549. any of the other <code class="literal">*-package</code> macros be called after it.</p><p>The <code class="literal">kernel-module</code> macro defines post-build and post-target-install
  4550. hooks to build the kernel modules. If the package’s <code class="literal">.mk</code> needs access
  4551. to the built kernel modules, it should do so in a post-build hook,
  4552. <span class="strong"><strong>registered after</strong></span> the call to <code class="literal">kernel-module</code>. Similarly, if the
  4553. package’s <code class="literal">.mk</code> needs access to the kernel module after it has been
  4554. installed, it should do so in a post-install hook, <span class="strong"><strong>registered after</strong></span>
  4555. the call to <code class="literal">kernel-module</code>. Here’s an example:</p><pre class="screen">$(eval $(kernel-module))
  4556. define FOO_DO_STUFF_WITH_KERNEL_MODULE
  4557. # Do something with it...
  4558. endef
  4559. FOO_POST_BUILD_HOOKS += FOO_DO_STUFF_WITH_KERNEL_MODULE
  4560. $(eval $(generic-package))</pre><p>Finally, unlike the other package infrastructures, there is no
  4561. <code class="literal">host-kernel-module</code> variant to build a host kernel module.</p><p>The following additional variables can optionally be defined to further
  4562. configure the build of the kernel module:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4563. <code class="literal">FOO_MODULE_SUBDIRS</code> may be set to one or more sub-directories (relative
  4564. to the package source top-directory) where the kernel module sources are.
  4565. If empty or not set, the sources for the kernel module(s) are considered
  4566. to be located at the top of the package source tree.
  4567. </li><li class="listitem">
  4568. <code class="literal">FOO_MODULE_MAKE_OPTS</code> may be set to contain extra variable definitions
  4569. to pass to the Linux buildsystem.
  4570. </li></ul></div><p><a id="kernel-variables"></a>You may also reference (but you may <span class="strong"><strong>not</strong></span> set!) those variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4571. <code class="literal">LINUX_DIR</code> contains the path to where the Linux kernel has been
  4572. extracted and built.
  4573. </li><li class="listitem">
  4574. <code class="literal">LINUX_VERSION</code> contains the version string as configured by the user.
  4575. </li><li class="listitem">
  4576. <code class="literal">LINUX_VERSION_PROBED</code> contains the real version string of the kernel,
  4577. retrieved with running <code class="literal">make -C $(LINUX_DIR) kernelrelease</code>
  4578. </li><li class="listitem">
  4579. <code class="literal">KERNEL_ARCH</code> contains the name of the current architecture, like <code class="literal">arm</code>,
  4580. <code class="literal">mips</code>…
  4581. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_infrastructure_for_asciidoc_documents"></a>18.20. Infrastructure for asciidoc documents</h2></div></div></div><p><a id="asciidoc-documents-tutorial"></a>The Buildroot manual, which you are currently reading, is entirely written
  4582. using the <a class="ulink" href="http://asciidoc.org/" target="_top">AsciiDoc</a> mark-up syntax. The manual is then
  4583. rendered to many formats:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4584. html
  4585. </li><li class="listitem">
  4586. split-html
  4587. </li><li class="listitem">
  4588. pdf
  4589. </li><li class="listitem">
  4590. epub
  4591. </li><li class="listitem">
  4592. text
  4593. </li></ul></div><p>Although Buildroot only contains one document written in AsciiDoc, there
  4594. is, as for packages, an infrastructure for rendering documents using the
  4595. AsciiDoc syntax.</p><p>Also as for packages, the AsciiDoc infrastructure is available from a
  4596. <a class="link" href="#outside-br-custom" title="9.2. Keeping customizations outside of Buildroot">br2-external tree</a>. This allows documentation for
  4597. a br2-external tree to match the Buildroot documentation, as it will be
  4598. rendered to the same formats and use the same layout and theme.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_literal_asciidoc_document_literal_tutorial"></a>18.20.1. <code class="literal">asciidoc-document</code> tutorial</h3></div></div></div><p>Whereas package infrastructures are suffixed with <code class="literal">-package</code>, the document
  4599. infrastructures are suffixed with <code class="literal">-document</code>. So, the AsciiDoc infrastructure
  4600. is named <code class="literal">asciidoc-document</code>.</p><p>Here is an example to render a simple AsciiDoc document.</p><pre class="screen">01: ################################################################################
  4601. 02: #
  4602. 03: # foo-document
  4603. 04: #
  4604. 05: ################################################################################
  4605. 06:
  4606. 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
  4607. 08: $(eval $(call asciidoc-document))</pre><p>On line 7, the Makefile declares what the sources of the document are.
  4608. Currently, it is expected that the document’s sources are only local;
  4609. Buildroot will not attempt to download anything to render a document.
  4610. Thus, you must indicate where the sources are. Usually, the string
  4611. above is sufficient for a document with no sub-directory structure.</p><p>On line 8, we call the <code class="literal">asciidoc-document</code> function, which generates all
  4612. the Makefile code necessary to render the document.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_literal_asciidoc_document_literal_reference"></a>18.20.2. <code class="literal">asciidoc-document</code> reference</h3></div></div></div><p>The list of variables that can be set in a <code class="literal">.mk</code> file to give metadata
  4613. information is (assuming the document name is <code class="literal">foo</code>) :</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4614. <code class="literal">FOO_SOURCES</code>, mandatory, defines the source files for the document.
  4615. </li><li class="listitem">
  4616. <code class="literal">FOO_RESOURCES</code>, optional, may contain a space-separated list of paths
  4617. to one or more directories containing so-called resources (like CSS or
  4618. images). By default, empty.
  4619. </li><li class="listitem">
  4620. <code class="literal">FOO_DEPENDENCIES</code>, optional, the list of packages (most probably,
  4621. host-packages) that must be built before building this document.
  4622. </li></ul></div><p>There are also additional hooks (see <a class="xref" href="#hooks" title="18.22. Hooks available in the various build steps">Section 18.22, “Hooks available in the various build steps”</a> for general information
  4623. on hooks), that a document may set to define extra actions to be done at
  4624. various steps:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4625. <code class="literal">FOO_POST_RSYNC_HOOKS</code> to run additional commands after the sources
  4626. have been copied by Buildroot. This can for example be used to
  4627. generate part of the manual with information extracted from the
  4628. tree. As an example, Buildroot uses this hook to generate the tables
  4629. in the appendices.
  4630. </li><li class="listitem">
  4631. <code class="literal">FOO_CHECK_DEPENDENCIES_HOOKS</code> to run additional tests on required
  4632. components to generate the document. In AsciiDoc, it is possible to
  4633. call filters, that is, programs that will parse an AsciiDoc block and
  4634. render it appropriately (e.g. <a class="ulink" href="http://ditaa.sourceforge.net/" target="_top">ditaa</a> or
  4635. <a class="ulink" href="https://pythonhosted.org/aafigure/" target="_top">aafigure</a>).
  4636. </li><li class="listitem">
  4637. <code class="literal">FOO_CHECK_DEPENDENCIES_&lt;FMT&gt;_HOOKS</code>, to run additional tests for
  4638. the specified format <code class="literal">&lt;FMT&gt;</code> (see the list of rendered formats, above).
  4639. </li></ul></div><p>Here is a complete example that uses all variables and all hooks:</p><pre class="screen">01: ################################################################################
  4640. 02: #
  4641. 03: # foo-document
  4642. 04: #
  4643. 05: ################################################################################
  4644. 06:
  4645. 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
  4646. 08: FOO_RESOURCES = $(sort $(wildcard $(pkgdir)/ressources))
  4647. 09:
  4648. 10: define FOO_GEN_EXTRA_DOC
  4649. 11: /path/to/generate-script --outdir=$(@D)
  4650. 12: endef
  4651. 13: FOO_POST_RSYNC_HOOKS += FOO_GEN_EXTRA_DOC
  4652. 14:
  4653. 15: define FOO_CHECK_MY_PROG
  4654. 16: if ! which my-prog &gt;/dev/null 2&gt;&amp;1; then \
  4655. 17: echo "You need my-prog to generate the foo document"; \
  4656. 18: exit 1; \
  4657. 19: fi
  4658. 20: endef
  4659. 21: FOO_CHECK_DEPENDENCIES_HOOKS += FOO_CHECK_MY_PROG
  4660. 22:
  4661. 23: define FOO_CHECK_MY_OTHER_PROG
  4662. 24: if ! which my-other-prog &gt;/dev/null 2&gt;&amp;1; then \
  4663. 25: echo "You need my-other-prog to generate the foo document as PDF"; \
  4664. 26: exit 1; \
  4665. 27: fi
  4666. 28: endef
  4667. 29: FOO_CHECK_DEPENDENCIES_PDF_HOOKS += FOO_CHECK_MY_OTHER_PROG
  4668. 30:
  4669. 31: $(eval $(call asciidoc-document))</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="linux-kernel-specific-infra"></a>18.21. Infrastructure specific to the Linux kernel package</h2></div></div></div><p>The Linux kernel package can use some specific infrastructures based on package
  4670. hooks for building Linux kernel tools or/and building Linux kernel extensions.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="linux-kernel-tools"></a>18.21.1. linux-kernel-tools</h3></div></div></div><p>Buildroot offers a helper infrastructure to build some userspace tools
  4671. for the target available within the Linux kernel sources. Since their
  4672. source code is part of the kernel source code, a special package,
  4673. <code class="literal">linux-tools</code>, exists and re-uses the sources of the Linux kernel that
  4674. runs on the target.</p><p>Let’s look at an example of a Linux tool. For a new Linux tool named
  4675. <code class="literal">foo</code>, create a new menu entry in the existing
  4676. <code class="literal">package/linux-tools/Config.in</code>. This file will contain the option
  4677. descriptions related to each kernel tool that will be used and
  4678. displayed in the configuration tool. It would basically look like:</p><pre class="screen">01: config BR2_PACKAGE_LINUX_TOOLS_FOO
  4679. 02: bool "foo"
  4680. 03: select BR2_PACKAGE_LINUX_TOOLS
  4681. 04: help
  4682. 05: This is a comment that explains what foo kernel tool is.
  4683. 06:
  4684. 07: http://foosoftware.org/foo/</pre><p>The name of the option starts with the prefix <code class="literal">BR2_PACKAGE_LINUX_TOOLS_</code>,
  4685. followed by the uppercase name of the tool (like is done for packages).</p><p><strong>Note. </strong>Unlike other packages, the <code class="literal">linux-tools</code> package options appear in the
  4686. <code class="literal">linux</code> kernel menu, under the <code class="literal">Linux Kernel Tools</code> sub-menu, not under
  4687. the <code class="literal">Target packages</code> main menu.</p><p>Then for each linux tool, add a new <code class="literal">.mk.in</code> file named
  4688. <code class="literal">package/linux-tools/linux-tool-foo.mk.in</code>. It would basically look like:</p><pre class="screen">01: ################################################################################
  4689. 02: #
  4690. 03: # foo
  4691. 04: #
  4692. 05: ################################################################################
  4693. 06:
  4694. 07: LINUX_TOOLS += foo
  4695. 08:
  4696. 09: FOO_DEPENDENCIES = libbbb
  4697. 10:
  4698. 11: define FOO_BUILD_CMDS
  4699. 12: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools foo
  4700. 13: endef
  4701. 14:
  4702. 15: define FOO_INSTALL_STAGING_CMDS
  4703. 16: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
  4704. 17: DESTDIR=$(STAGING_DIR) \
  4705. 18: foo_install
  4706. 19: endef
  4707. 20:
  4708. 21: define FOO_INSTALL_TARGET_CMDS
  4709. 22: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
  4710. 23: DESTDIR=$(TARGET_DIR) \
  4711. 24: foo_install
  4712. 25: endef</pre><p>On line 7, we register the Linux tool <code class="literal">foo</code> to the list of available
  4713. Linux tools.</p><p>On line 9, we specify the list of dependencies this tool relies on. These
  4714. dependencies are added to the Linux package dependencies list only when the
  4715. <code class="literal">foo</code> tool is selected.</p><p>The rest of the Makefile, lines 11-25 defines what should be done at the
  4716. different steps of the Linux tool build process like for a
  4717. <a class="link" href="#generic-package-tutorial" title="18.5.1. generic-package tutorial"><code class="literal">generic package</code></a>. They will actually be
  4718. used only when the <code class="literal">foo</code> tool is selected. The only supported commands are
  4719. <code class="literal">_BUILD_CMDS</code>, <code class="literal">_INSTALL_STAGING_CMDS</code> and <code class="literal">_INSTALL_TARGET_CMDS</code>.</p><p><strong>Note. </strong>One <span class="strong"><strong>must not</strong></span> call <code class="literal">$(eval $(generic-package))</code> or any other
  4720. package infrastructure! Linux tools are not packages by themselves,
  4721. they are part of the <code class="literal">linux-tools</code> package.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="linux-kernel-ext"></a>18.21.2. linux-kernel-extensions</h3></div></div></div><p>Some packages provide new features that require the Linux kernel tree
  4722. to be modified. This can be in the form of patches to be applied on
  4723. the kernel tree, or in the form of new files to be added to the
  4724. tree. The Buildroot’s Linux kernel extensions infrastructure provides
  4725. a simple solution to automatically do this, just after the kernel
  4726. sources are extracted and before the kernel patches are
  4727. applied. Examples of extensions packaged using this mechanism are the
  4728. real-time extensions Xenomai and RTAI, as well as the set of
  4729. out-of-tree LCD screens drivers <code class="literal">fbtft</code>.</p><p>Let’s look at an example on how to add a new Linux extension <code class="literal">foo</code>.</p><p>First, create the package <code class="literal">foo</code> that provides the extension: this
  4730. package is a standard package; see the previous chapters on how to
  4731. create such a package. This package is in charge of downloading the
  4732. sources archive, checking the hash, defining the licence informations
  4733. and building user space tools if any.</p><p>Then create the <span class="emphasis"><em>Linux extension</em></span> proper: create a new menu entry in
  4734. the existing <code class="literal">linux/Config.ext.in</code>. This file contains the option
  4735. descriptions related to each kernel extension that will be used and
  4736. displayed in the configuration tool. It would basically look like:</p><pre class="screen">01: config BR2_LINUX_KERNEL_EXT_FOO
  4737. 02: bool "foo"
  4738. 03: help
  4739. 04: This is a comment that explains what foo kernel extension is.
  4740. 05:
  4741. 06: http://foosoftware.org/foo/</pre><p>Then for each linux extension, add a new <code class="literal">.mk</code> file named
  4742. <code class="literal">linux/linux-ext-foo.mk</code>. It should basically contain:</p><pre class="screen">01: ################################################################################
  4743. 02: #
  4744. 03: # foo
  4745. 04: #
  4746. 05: ################################################################################
  4747. 06:
  4748. 07: LINUX_EXTENSIONS += foo
  4749. 08:
  4750. 09: define FOO_PREPARE_KERNEL
  4751. 10: $(FOO_DIR)/prepare-kernel-tree.sh --linux-dir=$(@D)
  4752. 11: endef</pre><p>On line 7, we add the Linux extension <code class="literal">foo</code> to the list of available
  4753. Linux extensions.</p><p>On line 9-11, we define what should be done by the extension to modify
  4754. the Linux kernel tree; this is specific to the linux extension and can
  4755. use the variables defined by the <code class="literal">foo</code> package, like: <code class="literal">$(FOO_DIR)</code> or
  4756. <code class="literal">$(FOO_VERSION)</code>… as well as all the Linux variables, like:
  4757. <code class="literal">$(LINUX_VERSION)</code> or <code class="literal">$(LINUX_VERSION_PROBED)</code>, <code class="literal">$(KERNEL_ARCH)</code>…
  4758. See the <a class="link" href="#kernel-variables">definition of those kernel variables</a>.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="hooks"></a>18.22. Hooks available in the various build steps</h2></div></div></div><p>The generic infrastructure (and as a result also the derived autotools
  4759. and cmake infrastructures) allow packages to specify hooks.
  4760. These define further actions to perform after existing steps.
  4761. Most hooks aren’t really useful for generic packages, since the <code class="literal">.mk</code>
  4762. file already has full control over the actions performed in each step
  4763. of the package construction.</p><p>The following hook points are available:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4764. <code class="literal">LIBFOO_PRE_DOWNLOAD_HOOKS</code>
  4765. </li><li class="listitem">
  4766. <code class="literal">LIBFOO_POST_DOWNLOAD_HOOKS</code>
  4767. </li><li class="listitem">
  4768. <code class="literal">LIBFOO_PRE_EXTRACT_HOOKS</code>
  4769. </li><li class="listitem">
  4770. <code class="literal">LIBFOO_POST_EXTRACT_HOOKS</code>
  4771. </li><li class="listitem">
  4772. <code class="literal">LIBFOO_PRE_RSYNC_HOOKS</code>
  4773. </li><li class="listitem">
  4774. <code class="literal">LIBFOO_POST_RSYNC_HOOKS</code>
  4775. </li><li class="listitem">
  4776. <code class="literal">LIBFOO_PRE_PATCH_HOOKS</code>
  4777. </li><li class="listitem">
  4778. <code class="literal">LIBFOO_POST_PATCH_HOOKS</code>
  4779. </li><li class="listitem">
  4780. <code class="literal">LIBFOO_PRE_CONFIGURE_HOOKS</code>
  4781. </li><li class="listitem">
  4782. <code class="literal">LIBFOO_POST_CONFIGURE_HOOKS</code>
  4783. </li><li class="listitem">
  4784. <code class="literal">LIBFOO_PRE_BUILD_HOOKS</code>
  4785. </li><li class="listitem">
  4786. <code class="literal">LIBFOO_POST_BUILD_HOOKS</code>
  4787. </li><li class="listitem">
  4788. <code class="literal">LIBFOO_PRE_INSTALL_HOOKS</code> (for host packages only)
  4789. </li><li class="listitem">
  4790. <code class="literal">LIBFOO_POST_INSTALL_HOOKS</code> (for host packages only)
  4791. </li><li class="listitem">
  4792. <code class="literal">LIBFOO_PRE_INSTALL_STAGING_HOOKS</code> (for target packages only)
  4793. </li><li class="listitem">
  4794. <code class="literal">LIBFOO_POST_INSTALL_STAGING_HOOKS</code> (for target packages only)
  4795. </li><li class="listitem">
  4796. <code class="literal">LIBFOO_PRE_INSTALL_TARGET_HOOKS</code> (for target packages only)
  4797. </li><li class="listitem">
  4798. <code class="literal">LIBFOO_POST_INSTALL_TARGET_HOOKS</code> (for target packages only)
  4799. </li><li class="listitem">
  4800. <code class="literal">LIBFOO_PRE_INSTALL_IMAGES_HOOKS</code>
  4801. </li><li class="listitem">
  4802. <code class="literal">LIBFOO_POST_INSTALL_IMAGES_HOOKS</code>
  4803. </li><li class="listitem">
  4804. <code class="literal">LIBFOO_PRE_LEGAL_INFO_HOOKS</code>
  4805. </li><li class="listitem">
  4806. <code class="literal">LIBFOO_POST_LEGAL_INFO_HOOKS</code>
  4807. </li></ul></div><p>These variables are <span class="emphasis"><em>lists</em></span> of variable names containing actions to be
  4808. performed at this hook point. This allows several hooks to be
  4809. registered at a given hook point. Here is an example:</p><pre class="screen">define LIBFOO_POST_PATCH_FIXUP
  4810. action1
  4811. action2
  4812. endef
  4813. LIBFOO_POST_PATCH_HOOKS += LIBFOO_POST_PATCH_FIXUP</pre><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="hooks-rsync"></a>18.22.1. Using the <code class="literal">POST_RSYNC</code> hook</h3></div></div></div><p>The <code class="literal">POST_RSYNC</code> hook is run only for packages that use a local source,
  4814. either through the <code class="literal">local</code> site method or the <code class="literal">OVERRIDE_SRCDIR</code>
  4815. mechanism. In this case, package sources are copied using <code class="literal">rsync</code> from
  4816. the local location into the buildroot build directory. The <code class="literal">rsync</code>
  4817. command does not copy all files from the source directory, though.
  4818. Files belonging to a version control system, like the directories
  4819. <code class="literal">.git</code>, <code class="literal">.hg</code>, etc. are not copied. For most packages this is
  4820. sufficient, but a given package can perform additional actions using
  4821. the <code class="literal">POST_RSYNC</code> hook.</p><p>In principle, the hook can contain any command you want. One specific
  4822. use case, though, is the intentional copying of the version control
  4823. directory using <code class="literal">rsync</code>. The <code class="literal">rsync</code> command you use in the hook can, among
  4824. others, use the following variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4825. <code class="literal">$(SRCDIR)</code>: the path to the overridden source directory
  4826. </li><li class="listitem">
  4827. <code class="literal">$(@D)</code>: the path to the build directory
  4828. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_target_finalize_hook"></a>18.22.2. Target-finalize hook</h3></div></div></div><p>Packages may also register hooks in <code class="literal">LIBFOO_TARGET_FINALIZE_HOOKS</code>.
  4829. These hooks are run after all packages are built, but before the
  4830. filesystem images are generated. They are seldom used, and your
  4831. package probably do not need them.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_gettext_integration_and_interaction_with_packages"></a>18.23. Gettext integration and interaction with packages</h2></div></div></div><p>Many packages that support internationalization use the gettext
  4832. library. Dependencies for this library are fairly complicated and
  4833. therefore, deserve some explanation.</p><p>The <span class="emphasis"><em>glibc</em></span> C library integrates a full-blown implementation of
  4834. <span class="emphasis"><em>gettext</em></span>, supporting translation. Native Language Support is
  4835. therefore built-in in <span class="emphasis"><em>glibc</em></span>.</p><p>On the other hand, the <span class="emphasis"><em>uClibc</em></span> and <span class="emphasis"><em>musl</em></span> C libraries only provide a
  4836. stub implementation of the gettext functionality, which allows to
  4837. compile libraries and programs using gettext functions, but without
  4838. providing the translation capabilities of a full-blown gettext
  4839. implementation. With such C libraries, if real Native Language Support
  4840. is necessary, it can be provided by the <code class="literal">libintl</code> library of the
  4841. <code class="literal">gettext</code> package.</p><p>Due to this, and in order to make sure that Native Language Support is
  4842. properly handled, packages in Buildroot that can use NLS support
  4843. should:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  4844. Ensure NLS support is enabled when <code class="literal">BR2_SYSTEM_ENABLE_NLS=y</code>. This
  4845. is done automatically for <span class="emphasis"><em>autotools</em></span> packages and therefore should
  4846. only be done for packages using other package infrastructures.
  4847. </li><li class="listitem">
  4848. Add <code class="literal">$(TARGET_NLS_DEPENDENCIES)</code> to the package
  4849. <code class="literal">&lt;pkg&gt;_DEPENDENCIES</code> variable. This addition should be done
  4850. unconditionally: the value of this variable is automatically
  4851. adjusted by the core infrastructure to contain the relevant list of
  4852. packages. If NLS support is disabled, this variable is empty. If
  4853. NLS support is enabled, this variable contains <code class="literal">host-gettext</code> so
  4854. that tools needed to compile translation files are available on the
  4855. host. In addition, if <span class="emphasis"><em>uClibc</em></span> or <span class="emphasis"><em>musl</em></span> are used, this variable
  4856. also contains <code class="literal">gettext</code> in order to get the full-blown <span class="emphasis"><em>gettext</em></span>
  4857. implementation.
  4858. </li><li class="listitem">
  4859. If needed, add <code class="literal">$(TARGET_NLS_LIBS)</code> to the linker flags, so that
  4860. the package gets linked with <code class="literal">libintl</code>. This is generally not
  4861. needed with <span class="emphasis"><em>autotools</em></span> packages as they usually detect
  4862. automatically that they should link with <code class="literal">libintl</code>. However,
  4863. packages using other build systems, or problematic autotools-based
  4864. packages may need this. <code class="literal">$(TARGET_NLS_LIBS)</code> should be added
  4865. unconditionally to the linker flags, as the core automatically
  4866. makes it empty or defined to <code class="literal">-lintl</code> depending on the
  4867. configuration.
  4868. </li></ol></div><p>No changes should be made to the <code class="literal">Config.in</code> file to support NLS.</p><p>Finally, certain packages need some gettext utilities on the target,
  4869. such as the <code class="literal">gettext</code> program itself, which allows to retrieve
  4870. translated strings, from the command line. In such a case, the package
  4871. should:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4872. use <code class="literal">select BR2_PACKAGE_GETTEXT</code> in their <code class="literal">Config.in</code> file,
  4873. indicating in a comment above that it’s a runtime dependency only.
  4874. </li><li class="listitem">
  4875. not add any <code class="literal">gettext</code> dependency in the <code class="literal">DEPENDENCIES</code> variable of
  4876. their <code class="literal">.mk</code> file.
  4877. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_tips_and_tricks"></a>18.24. Tips and tricks</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="package-name-variable-relation"></a>18.24.1. Package name, config entry name and makefile variable relationship</h3></div></div></div><p>In Buildroot, there is some relationship between:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4878. the <span class="emphasis"><em>package name</em></span>, which is the package directory name (and the
  4879. name of the <code class="literal">*.mk</code> file);
  4880. </li><li class="listitem">
  4881. the config entry name that is declared in the <code class="literal">Config.in</code> file;
  4882. </li><li class="listitem">
  4883. the makefile variable prefix.
  4884. </li></ul></div><p>It is mandatory to maintain consistency between these elements,
  4885. using the following rules:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4886. the package directory and the <code class="literal">*.mk</code> name are the <span class="emphasis"><em>package name</em></span>
  4887. itself (e.g.: <code class="literal">package/foo-bar_boo/foo-bar_boo.mk</code>);
  4888. </li><li class="listitem">
  4889. the <span class="emphasis"><em>make</em></span> target name is the <span class="emphasis"><em>package name</em></span> itself (e.g.:
  4890. <code class="literal">foo-bar_boo</code>);
  4891. </li><li class="listitem">
  4892. the config entry is the upper case <span class="emphasis"><em>package name</em></span> with <code class="literal">.</code> and <code class="literal">-</code>
  4893. characters substituted with <code class="literal">_</code>, prefixed with <code class="literal">BR2_PACKAGE_</code> (e.g.:
  4894. <code class="literal">BR2_PACKAGE_FOO_BAR_BOO</code>);
  4895. </li><li class="listitem">
  4896. the <code class="literal">*.mk</code> file variable prefix is the upper case <span class="emphasis"><em>package name</em></span>
  4897. with <code class="literal">.</code> and <code class="literal">-</code> characters substituted with <code class="literal">_</code> (e.g.:
  4898. <code class="literal">FOO_BAR_BOO_VERSION</code>).
  4899. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="check-package"></a>18.24.2. How to check the coding style</h3></div></div></div><p>Buildroot provides a script in <code class="literal">utils/check-package</code> that checks new or
  4900. changed files for coding style. It is not a complete language validator,
  4901. but it catches many common mistakes. It is meant to run in the actual
  4902. files you created or modified, before creating the patch for submission.</p><p>This script can be used for packages, filesystem makefiles, Config.in
  4903. files, etc. It does not check the files defining the package
  4904. infrastructures and some other files containing similar common code.</p><p>To use it, run the <code class="literal">check-package</code> script, by telling which files you
  4905. created or changed:</p><pre class="screen">$ ./utils/check-package package/new-package/*</pre><p>If you have the <code class="literal">utils</code> directory in your path you can also run:</p><pre class="screen">$ cd package/new-package/
  4906. $ check-package *</pre><p>The tool can also be used for packages in a br2-external:</p><pre class="screen">$ check-package -b /path/to/br2-ext-tree/package/my-package/*</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="testing-package"></a>18.24.3. How to test your package</h3></div></div></div><p>Once you have added your new package, it is important that you test it
  4907. under various conditions: does it build for all architectures? Does it
  4908. build with the different C libraries? Does it need threads, NPTL? And
  4909. so on…</p><p>Buildroot runs <a class="ulink" href="http://autobuild.buildroot.org/" target="_top">autobuilders</a> which
  4910. continuously test random configurations. However, these only build the
  4911. <code class="literal">master</code> branch of the git tree, and your new fancy package is not yet
  4912. there.</p><p>Buildroot provides a script in <code class="literal">utils/test-pkg</code> that uses the same base
  4913. configurations as used by the autobuilders so you can test your package
  4914. in the same conditions.</p><p>First, create a config snippet that contains all the necessary options
  4915. needed to enable your package, but without any architecture or toolchain
  4916. option. For example, let’s create a config snippet that just enables
  4917. <code class="literal">libcurl</code>, without any TLS backend:</p><pre class="screen">$ cat libcurl.config
  4918. BR2_PACKAGE_LIBCURL=y</pre><p>If your package needs more configuration options, you can add them to the
  4919. config snippet. For example, here’s how you would test <code class="literal">libcurl</code> with
  4920. <code class="literal">openssl</code> as a TLS backend and the <code class="literal">curl</code> program:</p><pre class="screen">$ cat libcurl.config
  4921. BR2_PACKAGE_LIBCURL=y
  4922. BR2_PACKAGE_LIBCURL_CURL=y
  4923. BR2_PACKAGE_OPENSSL=y</pre><p>Then run the <code class="literal">test-pkg</code> script, by telling it what config snippet to use
  4924. and what package to test:</p><pre class="screen">$ ./utils/test-pkg -c libcurl.config -p libcurl</pre><p>By default, <code class="literal">test-pkg</code> will build your package against a subset of the
  4925. toolchains used by the autobuilders, which has been selected by the
  4926. Buildroot developers as being the most useful and representative
  4927. subset. If you want to test all toolchains, pass the <code class="literal">-a</code> option. Note
  4928. that in any case, internal toolchains are excluded as they take too
  4929. long to build.</p><p>The output lists all toolchains that are tested and the corresponding
  4930. result (excerpt, results are fake):</p><pre class="screen">$ ./utils/test-pkg -c libcurl.config -p libcurl
  4931. armv5-ctng-linux-gnueabi [ 1/11]: OK
  4932. armv7-ctng-linux-gnueabihf [ 2/11]: OK
  4933. br-aarch64-glibc [ 3/11]: SKIPPED
  4934. br-arcle-hs38 [ 4/11]: SKIPPED
  4935. br-arm-basic [ 5/11]: FAILED
  4936. br-arm-cortex-a9-glibc [ 6/11]: OK
  4937. br-arm-cortex-a9-musl [ 7/11]: FAILED
  4938. br-arm-cortex-m4-full [ 8/11]: OK
  4939. br-arm-full [ 9/11]: OK
  4940. br-arm-full-nothread [10/11]: FAILED
  4941. br-arm-full-static [11/11]: OK
  4942. 11 builds, 2 skipped, 2 build failed, 1 legal-info failed</pre><p>The results mean:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4943. <code class="literal">OK</code>: the build was successful.
  4944. </li><li class="listitem">
  4945. <code class="literal">SKIPPED</code>: one or more configuration options listed in the config
  4946. snippet were not present in the final configuration. This is due to
  4947. options having dependencies not satisfied by the toolchain, such as
  4948. for example a package that <code class="literal">depends on BR2_USE_MMU</code> with a noMMU
  4949. toolchain. The missing options are reported in <code class="literal">missing.config</code> in
  4950. the output build directory (<code class="literal">~/br-test-pkg/TOOLCHAIN_NAME/</code> by
  4951. default).
  4952. </li><li class="listitem"><p class="simpara">
  4953. <code class="literal">FAILED</code>: the build failed. Inspect the <code class="literal">logfile</code> file in the output
  4954. build directory to see what went wrong:
  4955. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  4956. the actual build failed,
  4957. </li><li class="listitem">
  4958. the legal-info failed,
  4959. </li><li class="listitem">
  4960. one of the preliminary steps (downloading the config file, applying
  4961. the configuration, running <code class="literal">dirclean</code> for the package) failed.
  4962. </li></ul></div></li></ul></div><p>When there are failures, you can just re-run the script with the same
  4963. options (after you fixed your package); the script will attempt to
  4964. re-build the package specified with <code class="literal">-p</code> for all toolchains, without
  4965. the need to re-build all the dependencies of that package.</p><p>The <code class="literal">test-pkg</code> script accepts a few options, for which you can get some
  4966. help by running:</p><pre class="screen">$ ./utils/test-pkg -h</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="github-download-url"></a>18.24.4. How to add a package from GitHub</h3></div></div></div><p>Packages on GitHub often don’t have a download area with release tarballs.
  4967. However, it is possible to download tarballs directly from the repository
  4968. on GitHub. As GitHub is known to have changed download mechanisms in the
  4969. past, the <span class="emphasis"><em>github</em></span> helper function should be used as shown below.</p><pre class="screen"># Use a tag or a full commit ID
  4970. FOO_VERSION = v1.0
  4971. FOO_SITE = $(call github,&lt;user&gt;,&lt;package&gt;,$(FOO_VERSION))</pre><div class="itemizedlist"><p class="title"><strong>Notes</strong></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4972. The FOO_VERSION can either be a tag or a commit ID.
  4973. </li><li class="listitem">
  4974. The tarball name generated by github matches the default one from
  4975. Buildroot (e.g.: <code class="literal">foo-f6fb6654af62045239caed5950bc6c7971965e60.tar.gz</code>),
  4976. so it is not necessary to specify it in the <code class="literal">.mk</code> file.
  4977. </li><li class="listitem">
  4978. When using a commit ID as version, you should use the full 40 hex characters.
  4979. </li></ul></div><p>If the package you wish to add does have a release section on GitHub, the
  4980. maintainer may have uploaded a release tarball, or the release may just point
  4981. to the automatically generated tarball from the git tag. If there is a
  4982. release tarball uploaded by the maintainer, we prefer to use that since it
  4983. may be slightly different (e.g. it contains a configure script so we don’t
  4984. need to do AUTORECONF).</p><p>You can see on the release page if it’s an uploaded tarball or a git tag:</p><div class="informalfigure"><div class="mediaobject"><img src="github_hash_mongrel2.png" alt="github_hash_mongrel2.png" /></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  4985. If it looks like the image above then it was uploaded by the
  4986. maintainer and you should use that link (in that example:
  4987. <span class="emphasis"><em>mongrel2-v1.9.2.tar.bz2</em></span>) to specify <code class="literal">FOO_SITE</code>, and not use the
  4988. <span class="emphasis"><em>github</em></span> helper.
  4989. </li><li class="listitem">
  4990. On the other hand, if there’s is <span class="strong"><strong>only</strong></span> the "Source code" link, then
  4991. it’s an automatically generated tarball and you should use the
  4992. <span class="emphasis"><em>github</em></span> helper function.
  4993. </li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_conclusion"></a>18.25. Conclusion</h2></div></div></div><p>As you can see, adding a software package to Buildroot is simply a
  4994. matter of writing a Makefile using an existing example and modifying it
  4995. according to the compilation process required by the package.</p><p>If you package software that might be useful for other people, don’t
  4996. forget to send a patch to the Buildroot mailing list (see
  4997. <a class="xref" href="#submitting-patches" title="22.5. Submitting patches">Section 22.5, “Submitting patches”</a>)!</p></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="patch-policy"></a>Chapter 19. Patching a package</h2></div></div></div><p>While integrating a new package or updating an existing one, it may be
  4998. necessary to patch the source of the software to get it cross-built within
  4999. Buildroot.</p><p>Buildroot offers an infrastructure to automatically handle this during
  5000. the builds. It supports three ways of applying patch sets: downloaded patches,
  5001. patches supplied within buildroot and patches located in a user-defined
  5002. global patch directory.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_providing_patches"></a>19.1. Providing patches</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_downloaded"></a>19.1.1. Downloaded</h3></div></div></div><p>If it is necessary to apply a patch that is available for download, then add it
  5003. to the <code class="literal">&lt;packagename&gt;_PATCH</code> variable. If an entry contains <code class="literal">://</code>,
  5004. then Buildroot will assume it is a full URL and download the patch
  5005. from this location. Otherwise, Buildroot will assume that the patch should be
  5006. downloaded from <code class="literal">&lt;packagename&gt;_SITE</code>. It can be a single patch,
  5007. or a tarball containing a patch series.</p><p>Like for all downloads, a hash should be added to the <code class="literal">&lt;packagename&gt;.hash</code>
  5008. file.</p><p>This method is typically used for packages from Debian.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_within_buildroot"></a>19.1.2. Within Buildroot</h3></div></div></div><p>Most patches are provided within Buildroot, in the package
  5009. directory; these typically aim to fix cross-compilation, libc support,
  5010. or other such issues.</p><p>These patch files should be named <code class="literal">&lt;number&gt;-&lt;description&gt;.patch</code>.</p><div class="itemizedlist"><p class="title"><strong>Notes</strong></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5011. The patch files coming with Buildroot should not contain any package version
  5012. reference in their filename.
  5013. </li><li class="listitem">
  5014. The field <code class="literal">&lt;number&gt;</code> in the patch file name refers to the <span class="emphasis"><em>apply order</em></span>,
  5015. and shall start at 1; It is preferred to pad the number with zeros up to 4
  5016. digits, like <span class="emphasis"><em>git-format-patch</em></span> does. E.g.: <code class="literal">0001-foobar-the-buz.patch</code>
  5017. </li><li class="listitem">
  5018. Previously, it was mandatory for patches to be prefixed with the name of
  5019. the package, like <code class="literal">&lt;package&gt;-&lt;number&gt;-&lt;description&gt;.patch</code>, but that is
  5020. no longer the case. Existing packages will be fixed as time passes. <span class="emphasis"><em>Do
  5021. not prefix patches with the package name.</em></span>
  5022. </li><li class="listitem">
  5023. Previously, a <code class="literal">series</code> file, as used by <code class="literal">quilt</code>, could also be added in
  5024. the package directory. In that case, the <code class="literal">series</code> file defines the patch
  5025. application order. This is deprecated, and will be removed in the future.
  5026. <span class="emphasis"><em>Do not use a series file.</em></span>
  5027. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_global_patch_directory"></a>19.1.3. Global patch directory</h3></div></div></div><p>The <code class="literal">BR2_GLOBAL_PATCH_DIR</code> configuration file option can be
  5028. used to specify a space separated list of one or more directories
  5029. containing global package patches. See <a class="xref" href="#customize-patches" title="9.8. Adding project-specific patches">Section 9.8, “Adding project-specific patches”</a> for
  5030. details.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="patch-apply-order"></a>19.2. How patches are applied</h2></div></div></div><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  5031. Run the <code class="literal">&lt;packagename&gt;_PRE_PATCH_HOOKS</code> commands if defined;
  5032. </li><li class="listitem">
  5033. Cleanup the build directory, removing any existing <code class="literal">*.rej</code> files;
  5034. </li><li class="listitem">
  5035. If <code class="literal">&lt;packagename&gt;_PATCH</code> is defined, then patches from these
  5036. tarballs are applied;
  5037. </li><li class="listitem"><p class="simpara">
  5038. If there are some <code class="literal">*.patch</code> files in the package’s Buildroot
  5039. directory or in a package subdirectory named <code class="literal">&lt;packageversion&gt;</code>,
  5040. then:
  5041. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5042. If a <code class="literal">series</code> file exists in the package directory, then patches are
  5043. applied according to the <code class="literal">series</code> file;
  5044. </li><li class="listitem">
  5045. Otherwise, patch files matching <code class="literal">*.patch</code> are applied in alphabetical
  5046. order.
  5047. So, to ensure they are applied in the right order, it is highly
  5048. recommended to name the patch files like this:
  5049. <code class="literal">&lt;number&gt;-&lt;description&gt;.patch</code>, where <code class="literal">&lt;number&gt;</code> refers to the
  5050. <span class="emphasis"><em>apply order</em></span>.
  5051. </li></ul></div></li><li class="listitem">
  5052. If <code class="literal">BR2_GLOBAL_PATCH_DIR</code> is defined, the directories will be
  5053. enumerated in the order they are specified. The patches are applied
  5054. as described in the previous step.
  5055. </li><li class="listitem">
  5056. Run the <code class="literal">&lt;packagename&gt;_POST_PATCH_HOOKS</code> commands if defined.
  5057. </li></ol></div><p>If something goes wrong in the steps <span class="emphasis"><em>3</em></span> or <span class="emphasis"><em>4</em></span>, then the build fails.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_format_and_licensing_of_the_package_patches"></a>19.3. Format and licensing of the package patches</h2></div></div></div><p>Patches are released under the same license as the software they apply
  5058. to (see <a class="xref" href="#legal-info-buildroot" title="13.2. Complying with the Buildroot license">Section 13.2, “Complying with the Buildroot license”</a>).</p><p>A message explaining what the patch does, and why it is needed, should
  5059. be added in the header commentary of the patch.</p><p>You should add a <code class="literal">Signed-off-by</code> statement in the header of the each
  5060. patch to help with keeping track of the changes and to certify that the
  5061. patch is released under the same license as the software that is modified.</p><p>If the software is under version control, it is recommended to use the
  5062. upstream SCM software to generate the patch set.</p><p>Otherwise, concatenate the header with the output of the
  5063. <code class="literal">diff -purN package-version.orig/ package-version/</code> command.</p><p>If you update an existing patch (e.g. when bumping the package version),
  5064. make sure the existing From header and Signed-off-by tags are not
  5065. removed, but do update the rest of the patch comment when appropriate.</p><p>At the end, the patch should look like:</p><pre class="screen">configure.ac: add C++ support test
  5066. Signed-off-by: John Doe &lt;john.doe@noname.org&gt;
  5067. --- configure.ac.orig
  5068. +++ configure.ac
  5069. @@ -40,2 +40,12 @@
  5070. AC_PROG_MAKE_SET
  5071. +
  5072. +AC_CACHE_CHECK([whether the C++ compiler works],
  5073. + [rw_cv_prog_cxx_works],
  5074. + [AC_LANG_PUSH([C++])
  5075. + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  5076. + [rw_cv_prog_cxx_works=yes],
  5077. + [rw_cv_prog_cxx_works=no])
  5078. + AC_LANG_POP([C++])])
  5079. +
  5080. +AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"])</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_integrating_patches_found_on_the_web"></a>19.4. Integrating patches found on the Web</h2></div></div></div><p>When integrating a patch of which you are not the author, you have to
  5081. add a few things in the header of the patch itself.</p><p>Depending on whether the patch has been obtained from the project
  5082. repository itself, or from somewhere on the web, add one of the
  5083. following tags:</p><pre class="screen">Backported from: &lt;some commit id&gt;</pre><p>or</p><pre class="screen">Fetch from: &lt;some url&gt;</pre><p>It is also sensible to add a few words about any changes to the patch
  5084. that may have been necessary.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="download-infra"></a>Chapter 20. Download infrastructure</h2></div></div></div><p>TODO</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="debugging-buildroot"></a>Chapter 21. Debugging Buildroot</h2></div></div></div><p>It is possible to instrument the steps <code class="literal">Buildroot</code> does when building
  5085. packages. Define the variable <code class="literal">BR2_INSTRUMENTATION_SCRIPTS</code> to contain
  5086. the path of one or more scripts (or other executables), in a
  5087. space-separated list, you want called before and after each step. The
  5088. scripts are called in sequence, with three parameters:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5089. <code class="literal">start</code> or <code class="literal">end</code> to denote the start (resp. the end) of a step;
  5090. </li><li class="listitem">
  5091. the name of the step about to be started, or which just ended;
  5092. </li><li class="listitem">
  5093. the name of the package.
  5094. </li></ul></div><p>For example :</p><pre class="screen">make BR2_INSTRUMENTATION_SCRIPTS="/path/to/my/script1 /path/to/my/script2"</pre><p>The list of steps is:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5095. <code class="literal">extract</code>
  5096. </li><li class="listitem">
  5097. <code class="literal">patch</code>
  5098. </li><li class="listitem">
  5099. <code class="literal">configure</code>
  5100. </li><li class="listitem">
  5101. <code class="literal">build</code>
  5102. </li><li class="listitem">
  5103. <code class="literal">install-host</code>, when a host-package is installed in <code class="literal">$(HOST_DIR)</code>
  5104. </li><li class="listitem">
  5105. <code class="literal">install-target</code>, when a target-package is installed in <code class="literal">$(TARGET_DIR)</code>
  5106. </li><li class="listitem">
  5107. <code class="literal">install-staging</code>, when a target-package is installed in <code class="literal">$(STAGING_DIR)</code>
  5108. </li><li class="listitem">
  5109. <code class="literal">install-image</code>, when a target-package installs files in <code class="literal">$(BINARIES_DIR)</code>
  5110. </li></ul></div><p>The script has access to the following variables:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5111. <code class="literal">BR2_CONFIG</code>: the path to the Buildroot .config file
  5112. </li><li class="listitem">
  5113. <code class="literal">HOST_DIR</code>, <code class="literal">STAGING_DIR</code>, <code class="literal">TARGET_DIR</code>: see
  5114. <a class="xref" href="#generic-package-reference" title="18.5.2. generic-package reference">Section 18.5.2, “<code class="literal">generic-package</code> reference”</a>
  5115. </li><li class="listitem">
  5116. <code class="literal">BUILD_DIR</code>: the directory where packages are extracted and built
  5117. </li><li class="listitem">
  5118. <code class="literal">BINARIES_DIR</code>: the place where all binary files (aka images) are
  5119. stored
  5120. </li><li class="listitem">
  5121. <code class="literal">BASE_DIR</code>: the base output directory
  5122. </li></ul></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="_contributing_to_buildroot"></a>Chapter 22. Contributing to Buildroot</h2></div></div></div><p>There are many ways in which you can contribute to Buildroot: analyzing
  5123. and fixing bugs, analyzing and fixing package build failures detected by
  5124. the autobuilders, testing and reviewing patches sent by other
  5125. developers, working on the items in our TODO list and sending your own
  5126. improvements to Buildroot or its manual. The following sections give a
  5127. little more detail on each of these items.</p><p>If you are interested in contributing to Buildroot, the first thing you
  5128. should do is to subscribe to the Buildroot mailing list. This list is
  5129. the main way of interacting with other Buildroot developers and to send
  5130. contributions to. If you aren’t subscribed yet, then refer to
  5131. <a class="xref" href="#community-resources" title="Chapter 5. Community resources">Chapter 5, <em>Community resources</em></a> for the subscription link.</p><p>If you are going to touch the code, it is highly recommended to use a
  5132. git repository of Buildroot, rather than starting from an extracted
  5133. source code tarball. Git is the easiest way to develop from and directly
  5134. send your patches to the mailing list. Refer to <a class="xref" href="#getting-buildroot" title="Chapter 3. Getting Buildroot">Chapter 3, <em>Getting Buildroot</em></a>
  5135. for more information on obtaining a Buildroot git tree.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_reproducing_analyzing_and_fixing_bugs"></a>22.1. Reproducing, analyzing and fixing bugs</h2></div></div></div><p>A first way of contributing is to have a look at the open bug reports in
  5136. the <a class="ulink" href="https://bugs.buildroot.org/buglist.cgi?product=buildroot" target="_top">Buildroot bug
  5137. tracker</a>. As we strive to keep the bug count as small as possible, all
  5138. help in reproducing, analyzing and fixing reported bugs is more than
  5139. welcome. Don’t hesitate to add a comment to bug reports reporting your
  5140. findings, even if you don’t yet see the full picture.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_analyzing_and_fixing_autobuild_failures"></a>22.2. Analyzing and fixing autobuild failures</h2></div></div></div><p>The Buildroot autobuilders are a set of build machines that continuously
  5141. run Buildroot builds based on random configurations. This is done for
  5142. all architectures supported by Buildroot, with various toolchains, and
  5143. with a random selection of packages. With the large commit activity on
  5144. Buildroot, these autobuilders are a great help in detecting problems
  5145. very early after commit.</p><p>All build results are available at <a class="ulink" href="http://autobuild.buildroot.org" target="_top">http://autobuild.buildroot.org</a>,
  5146. statistics are at <a class="ulink" href="http://autobuild.buildroot.org/stats.php" target="_top">http://autobuild.buildroot.org/stats.php</a>. Every day,
  5147. an overview of all failed packages is sent to the mailing list.</p><p>Detecting problems is great, but obviously these problems have to be
  5148. fixed as well. Your contribution is very welcome here! There are
  5149. basically two things that can be done:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5150. Analyzing the problems. The daily summary mails do not contain details
  5151. about the actual failures: in order to see what’s going on you have to
  5152. open the build log and check the last output. Having someone doing
  5153. this for all packages in the mail is very useful for other developers,
  5154. as they can make a quick initial analysis based on this output alone.
  5155. </li><li class="listitem"><p class="simpara">
  5156. Fixing a problem. When fixing autobuild failures, you should follow
  5157. these steps:
  5158. </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  5159. Check if you can reproduce the problem by building with the same
  5160. configuration. You can do this manually, or use the
  5161. <a class="ulink" href="http://git.buildroot.org/buildroot-test/tree/utils/br-reproduce-build" target="_top">br-reproduce-build</a>
  5162. script that will automatically clone a Buildroot git repository,
  5163. checkout the correct revision, download and set the right
  5164. configuration, and start the build.
  5165. </li><li class="listitem">
  5166. Analyze the problem and create a fix.
  5167. </li><li class="listitem">
  5168. Verify that the problem is really fixed by starting from a clean
  5169. Buildroot tree and only applying your fix.
  5170. </li><li class="listitem">
  5171. Send the fix to the Buildroot mailing list (see
  5172. <a class="xref" href="#submitting-patches" title="22.5. Submitting patches">Section 22.5, “Submitting patches”</a>). In case you created a patch against the
  5173. package sources, you should also send the patch upstream so that the
  5174. problem will be fixed in a later release, and the patch in Buildroot
  5175. can be removed.
  5176. In the commit message of a patch fixing an autobuild failure, add a
  5177. reference to the build result directory, as follows:
  5178. </li></ol></div></li></ul></div><pre class="screen">Fixes: http://autobuild.buildroot.org/results/51000a9d4656afe9e0ea6f07b9f8ed374c2e4069</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_reviewing_and_testing_patches"></a>22.3. Reviewing and testing patches</h2></div></div></div><p>With the amount of patches sent to the mailing list each day, the
  5179. maintainer has a very hard job to judge which patches are ready to apply
  5180. and which ones aren’t. Contributors can greatly help here by reviewing
  5181. and testing these patches.</p><p>In the review process, do not hesitate to respond to patch submissions
  5182. for remarks, suggestions or anything that will help everyone to
  5183. understand the patches and make them better. Please use internet
  5184. style replies in plain text emails when responding to patch
  5185. submissions.</p><p>To indicate approval of a patch, there are three formal tags that keep
  5186. track of this approval. To add your tag to a patch, reply to it with the
  5187. approval tag below the original author’s Signed-off-by line. These tags
  5188. will be picked up automatically by patchwork (see
  5189. <a class="xref" href="#apply-patches-patchwork" title="22.3.1. Applying Patches from Patchwork">Section 22.3.1, “Applying Patches from Patchwork”</a>) and will be part of the commit log when
  5190. the patch is accepted.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  5191. Tested-by
  5192. </span></dt><dd>
  5193. Indicates that the patch has been tested successfully.
  5194. You are encouraged to specify what kind of testing you performed
  5195. (compile-test on architecture X and Y, runtime test on target A,
  5196. …). This additional information helps other testers and the
  5197. maintainer.
  5198. </dd><dt><span class="term">
  5199. Reviewed-by
  5200. </span></dt><dd>
  5201. Indicates that you code-reviewed the patch and did your
  5202. best in spotting problems, but you are not sufficiently familiar with
  5203. the area touched to provide an Acked-by tag. This means that there
  5204. may be remaining problems in the patch that would be spotted by
  5205. someone with more experience in that area. Should such problems be
  5206. detected, your Reviewed-by tag remains appropriate and you cannot
  5207. be blamed.
  5208. </dd><dt><span class="term">
  5209. Acked-by
  5210. </span></dt><dd>
  5211. Indicates that you code-reviewed the patch and you are
  5212. familiar enough with the area touched to feel that the patch can be
  5213. committed as-is (no additional changes required). In case it later
  5214. turns out that something is wrong with the patch, your Acked-by could
  5215. be considered inappropriate. The difference between Acked-by and
  5216. Reviewed-by is thus mainly that you are prepared to take the blame on
  5217. Acked patches, but not on Reviewed ones.
  5218. </dd></dl></div><p>If you reviewed a patch and have comments on it, you should simply reply
  5219. to the patch stating these comments, without providing a Reviewed-by or
  5220. Acked-by tag. These tags should only be provided if you judge the patch
  5221. to be good as it is.</p><p>It is important to note that neither Reviewed-by nor Acked-by imply
  5222. that testing has been performed. To indicate that you both reviewed and
  5223. tested the patch, provide two separate tags (Reviewed/Acked-by and
  5224. Tested-by).</p><p>Note also that <span class="emphasis"><em>any developer</em></span> can provide Tested/Reviewed/Acked-by
  5225. tags, without exception, and we encourage everyone to do this. Buildroot
  5226. does not have a defined group of <span class="emphasis"><em>core</em></span> developers, it just so happens
  5227. that some developers are more active than others. The maintainer will
  5228. value tags according to the track record of their submitter. Tags
  5229. provided by a regular contributor will naturally be trusted more than
  5230. tags provided by a newcomer. As you provide tags more regularly, your
  5231. <span class="emphasis"><em>trustworthiness</em></span> (in the eyes of the maintainer) will go up, but <span class="emphasis"><em>any</em></span>
  5232. tag provided is valuable.</p><p>Buildroot’s Patchwork website can be used to pull in patches for testing
  5233. purposes. Please see <a class="xref" href="#apply-patches-patchwork" title="22.3.1. Applying Patches from Patchwork">Section 22.3.1, “Applying Patches from Patchwork”</a> for more
  5234. information on using Buildroot’s Patchwork website to apply patches.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="apply-patches-patchwork"></a>22.3.1. Applying Patches from Patchwork</h3></div></div></div><p>The main use of Buildroot’s Patchwork website for a developer is for
  5235. pulling in patches into their local git repository for testing
  5236. purposes.</p><p>When browsing patches in the patchwork management interface, an <code class="literal">mbox</code>
  5237. link is provided at the top of the page. Copy this link address and
  5238. run the following commands:</p><pre class="screen">$ git checkout -b &lt;test-branch-name&gt;
  5239. $ wget -O - &lt;mbox-url&gt; | git am</pre><p>Another option for applying patches is to create a bundle. A bundle is
  5240. a set of patches that you can group together using the patchwork
  5241. interface. Once the bundle is created and the bundle is made public,
  5242. you can copy the <code class="literal">mbox</code> link for the bundle and apply the bundle
  5243. using the above commands.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_work_on_items_from_the_todo_list"></a>22.4. Work on items from the TODO list</h2></div></div></div><p>If you want to contribute to Buildroot but don’t know where to start,
  5244. and you don’t like any of the above topics, you can always work on items
  5245. from the <a class="ulink" href="http://elinux.org/Buildroot#Todo_list" target="_top">Buildroot TODO list</a>.
  5246. Don’t hesitate to discuss an item first on the mailing list or on IRC.
  5247. Do edit the wiki to indicate when you start working on an item, so we
  5248. avoid duplicate efforts.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="submitting-patches"></a>22.5. Submitting patches</h2></div></div></div><div class="note" style="margin-left: 0; margin-right: 10%;"><h3 class="title">Note</h3><p><span class="emphasis"><em>Please, do not attach patches to bugs, send them to the mailing list
  5249. instead</em></span>.</p></div><p>If you made some changes to Buildroot and you would like to contribute
  5250. them to the Buildroot project, proceed as follows.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_the_formatting_of_a_patch"></a>22.5.1. The formatting of a patch</h3></div></div></div><p>We expect patches to be formatted in a specific way. This is necessary
  5251. to make it easy to review patches, to be able to apply them easily to
  5252. the git repository, to make it easy to find back in the history how
  5253. and why things have changed, and to make it possible to use <code class="literal">git
  5254. bisect</code> to locate the origin of a problem.</p><p>First of all, it is essential that the patch has a good commit
  5255. message. The commit message should start with a separate line with a
  5256. brief summary of the change, prefixed by the area touched by the
  5257. patch. A few examples of good commit titles:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5258. <code class="literal">package/linuxptp: bump version to 2.0</code>
  5259. </li><li class="listitem">
  5260. <code class="literal">configs/imx23evk: bump Linux version to 4.19</code>
  5261. </li><li class="listitem">
  5262. <code class="literal">package/pkg-generic: postpone evaluation of dependency conditions</code>
  5263. </li><li class="listitem">
  5264. <code class="literal">boot/uboot: needs host-{flex,bison}</code>
  5265. </li><li class="listitem">
  5266. <code class="literal">support/testing: add python-ubjson tests</code>
  5267. </li></ul></div><p>The description that follows the prefix should start with a lower case
  5268. letter (i.e "bump", "needs", "postpone", "add" in the above examples).</p><p>Second, the body of the commit message should describe <span class="emphasis"><em>why</em></span> this
  5269. change is needed, and if necessary also give details about <span class="emphasis"><em>how</em></span> it
  5270. was done. When writing the commit message, think of how the reviewers
  5271. will read it, but also think about how you will read it when you look
  5272. at this change again a few years down the line.</p><p>Third, the patch itself should do only one change, but do it
  5273. completely. Two unrelated or weakly related changes should usually be
  5274. done in two separate patches. This usually means that a patch affects
  5275. only a single package. If several changes are related, it is often
  5276. still possible to split them up in small patches and apply them in a
  5277. specific order. Small patches make it easier to review, and often
  5278. make it easier to understand afterwards why a change was done.
  5279. However, each patch must be complete. It is not allowed that the
  5280. build is broken when only the first but not the second patch is
  5281. applied. This is necessary to be able to use <code class="literal">git bisect</code> afterwards.</p><p>Of course, while you’re doing your development, you’re probably going
  5282. back and forth between packages, and certainly not committing things
  5283. immediately in a way that is clean enough for submission. So most
  5284. developers rewrite the history of commits to produce a clean set of
  5285. commits that is appropriate for submission. To do this, you need to
  5286. use <span class="emphasis"><em>interactive rebasing</em></span>. You can learn about it
  5287. <a class="ulink" href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History" target="_top">in the Pro
  5288. Git book</a>. Sometimes, it is even easier to discard you history with
  5289. <code class="literal">git reset --soft origin/master</code> and select individual changes with
  5290. <code class="literal">git add -i</code> or <code class="literal">git add -p</code>.</p><p>Finally, the patch should be signed off. This is done by adding
  5291. <code class="literal">Signed-off-by: Your Real Name &lt;<a class="ulink" href="mailto:your@email.address" target="_top">your@email.address</a>&gt;</code> at the end of the
  5292. commit message. <code class="literal">git commit -s</code> does that for you, if configured
  5293. properly. The <code class="literal">Signed-off-by</code> tag means that you publish the patch
  5294. under the Buildroot license (i.e. GPL-2.0+, except for package patches,
  5295. which have the upstream license), and that you are allowed to do so.
  5296. See <a class="ulink" href="http://developercertificate.org/" target="_top">the Developer Certificate of
  5297. Origin</a> for details.</p><p>When adding new packages, you should submit every package in a
  5298. separate patch. This patch should have the update to
  5299. <code class="literal">package/Config.in</code>, the package <code class="literal">Config.in</code> file, the <code class="literal">.mk</code> file, the
  5300. <code class="literal">.hash</code> file, any init script, and all package patches. If the package
  5301. has many sub-options, these are sometimes better added as separate
  5302. follow-up patches. The summary line should be something like
  5303. <code class="literal">&lt;packagename&gt;: new package</code>. The body of the commit message can be
  5304. empty for simple packages, or it can contain the description of the
  5305. package (like the Config.in help text). If anything special has to be
  5306. done to build the package, this should also be explained explicitly in
  5307. the commit message body.</p><p>When you bump a package to a new version, you should also submit a
  5308. separate patch for each package. Don’t forget to update the <code class="literal">.hash</code>
  5309. file, or add it if it doesn’t exist yet. Also don’t forget to check if
  5310. the <code class="literal">_LICENSE</code> and <code class="literal">_LICENSE_FILES</code> are still valid. The summary line
  5311. should be something like <code class="literal">&lt;packagename&gt;: bump to version &lt;new
  5312. version&gt;</code>. If the new version only contains security updates compared
  5313. to the existing one, the summary should be <code class="literal">&lt;packagename&gt;: security
  5314. bump to version &lt;new version&gt;</code> and the commit message body should show
  5315. the CVE numbers that are fixed. If some package patches can be removed
  5316. in the new version, it should be explained explicitly why they can be
  5317. removed, preferably with the upstream commit ID. Also any other
  5318. required changes should be explained explicitly, like configure
  5319. options that no longer exist or are no longer needed.</p><p>If you are interested in getting notified of build failures and of
  5320. further changes in the packages you added or modified, please add
  5321. yourself to the DEVELOPERS file. This should be done in the same patch
  5322. creating or modifying the package. See <a class="link" href="#DEVELOPERS" title="Chapter 23. DEVELOPERS file and get-developers">the DEVELOPERS file</a>
  5323. for more information.</p><p>Buildroot provides a handy tool to check for common coding style
  5324. mistakes on files you created or modified, called <code class="literal">check-package</code> (see
  5325. <a class="xref" href="#check-package" title="18.24.2. How to check the coding style">Section 18.24.2, “How to check the coding style”</a> for more information).</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_preparing_a_patch_series"></a>22.5.2. Preparing a patch series</h3></div></div></div><p>Starting from the changes committed in your local git view, <span class="emphasis"><em>rebase</em></span>
  5326. your development branch on top of the upstream tree before generating
  5327. a patch set. To do so, run:</p><pre class="screen">$ git fetch --all --tags
  5328. $ git rebase origin/master</pre><p>Now, you are ready to generate then submit your patch set.</p><p>To generate it, run:</p><pre class="screen">$ git format-patch -M -n -s -o outgoing origin/master</pre><p>This will generate patch files in the <code class="literal">outgoing</code> subdirectory,
  5329. automatically adding the <code class="literal">Signed-off-by</code> line.</p><p>Once patch files are generated, you can review/edit the commit message
  5330. before submitting them, using your favorite text editor.</p><p>Buildroot provides a handy tool to know to whom your patches should be
  5331. sent, called <code class="literal">get-developers</code> (see <a class="xref" href="#DEVELOPERS" title="Chapter 23. DEVELOPERS file and get-developers">Chapter 23, <em>DEVELOPERS file and get-developers</em></a> for more
  5332. information). This tool reads your patches and outputs the appropriate
  5333. <code class="literal">git send-email</code> command to use:</p><pre class="screen">$ ./utils/get-developers outgoing/*</pre><p>Use the output of <code class="literal">get-developers</code> to send your patches:</p><pre class="screen">$ git send-email --to buildroot@buildroot.org --cc bob --cc alice outgoing/*</pre><p>Alternatively, <code class="literal">get-developers -e</code> can be used directly with the
  5334. <code class="literal">--cc-cmd</code> argument to <code class="literal">git send-email</code> to automatically CC the
  5335. affected developers:</p><pre class="screen">$ git send-email --to buildroot@buildroot.org \
  5336. --cc-cmd './utils/get-developers -e' origin/master</pre><p><code class="literal">git</code> can be configured to automatically do this out of the box with:</p><pre class="screen">$ git config sendemail.to buildroot@buildroot.org
  5337. $ git config sendemail.ccCmd "$(pwd)/utils/get-developers -e"</pre><p>And then just do:</p><pre class="screen">$ git send-email origin/master</pre><p>Note that <code class="literal">git</code> should be configured to use your mail account.
  5338. To configure <code class="literal">git</code>, see <code class="literal">man git-send-email</code> or google it.</p><p>If you do not use <code class="literal">git send-email</code>, make sure posted <span class="strong"><strong>patches are not
  5339. line-wrapped</strong></span>, otherwise they cannot easily be applied. In such a case,
  5340. fix your e-mail client, or better yet, learn to use <code class="literal">git send-email</code>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_cover_letter"></a>22.5.3. Cover letter</h3></div></div></div><p>If you want to present the whole patch set in a separate mail, add
  5341. <code class="literal">--cover-letter</code> to the <code class="literal">git format-patch</code> command (see <code class="literal">man
  5342. git-format-patch</code> for further information). This will generate a
  5343. template for an introduction e-mail to your patch series.</p><p>A <span class="emphasis"><em>cover letter</em></span> may be useful to introduce the changes you propose
  5344. in the following cases:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5345. large number of commits in the series;
  5346. </li><li class="listitem">
  5347. deep impact of the changes in the rest of the project;
  5348. </li><li class="listitem">
  5349. RFC <a href="#ftn.idm5691" class="footnote" id="idm5691"><sup class="footnote">[4]</sup></a>;
  5350. </li><li class="listitem">
  5351. whenever you feel it will help presenting your work, your choices,
  5352. the review process, etc.
  5353. </li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_patches_for_maintenance_branches"></a>22.5.4. Patches for maintenance branches</h3></div></div></div><p>When fixing bugs on a maintenance branch, bugs should be fixed on the
  5354. master branch first. The commit log for such a patch may then contain a
  5355. post-commit note specifying what branches are affected:</p><pre class="screen">package/foo: fix stuff
  5356. Signed-off-by: Your Real Name &lt;your@email.address&gt;
  5357. ---
  5358. Backport to: 2020.02.x, 2020.05.x
  5359. (2020.08.x not affected as the version was bumped)</pre><p>Those changes will then be backported by a maintainer to the affected
  5360. branches.</p><p>However, some bugs may apply only to a specific release, for example
  5361. because it is using an older version of a package. In that case, patches
  5362. should be based off the maintenance branch, and the patch subject prefix
  5363. must include the maintenance branch name (for example "[PATCH 2020.02.x]").
  5364. This can be done with the <code class="literal">git format-patch</code> flag <code class="literal">--subject-prefix</code>:</p><pre class="screen">$ git format-patch --subject-prefix "PATCH 2020.02.x" \
  5365. -M -s -o outgoing origin/2020.02.x</pre><p>Then send the patches with <code class="literal">git send-email</code>, as described above.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_patch_revision_changelog"></a>22.5.5. Patch revision changelog</h3></div></div></div><p>When improvements are requested, the new revision of each commit
  5366. should include a changelog of the modifications between each
  5367. submission. Note that when your patch series is introduced by a cover
  5368. letter, an overall changelog may be added to the cover letter in
  5369. addition to the changelog in the individual commits.
  5370. The best thing to rework a patch series is by interactive rebasing:
  5371. <code class="literal">git rebase -i origin/master</code>. Consult the git manual for more
  5372. information.</p><p>When added to the individual commits, this changelog is added when
  5373. editing the commit message. Below the <code class="literal">Signed-off-by</code> section, add
  5374. <code class="literal">---</code> and your changelog.</p><p>Although the changelog will be visible for the reviewers in the mail
  5375. thread, as well as in <a class="ulink" href="http://patchwork.buildroot.org" target="_top">patchwork</a>, <code class="literal">git</code>
  5376. will automatically ignores lines below <code class="literal">---</code> when the patch will be
  5377. merged. This is the intended behavior: the changelog is not meant to
  5378. be preserved forever in the <code class="literal">git</code> history of the project.</p><p>Hereafter the recommended layout:</p><pre class="screen">Patch title: short explanation, max 72 chars
  5379. A paragraph that explains the problem, and how it manifests itself. If
  5380. the problem is complex, it is OK to add more paragraphs. All paragraphs
  5381. should be wrapped at 72 characters.
  5382. A paragraph that explains the root cause of the problem. Again, more
  5383. than one paragraph is OK.
  5384. Finally, one or more paragraphs that explain how the problem is solved.
  5385. Don't hesitate to explain complex solutions in detail.
  5386. Signed-off-by: John DOE &lt;john.doe@example.net&gt;
  5387. ---
  5388. Changes v2 -&gt; v3:
  5389. - foo bar (suggested by Jane)
  5390. - bar buz
  5391. Changes v1 -&gt; v2:
  5392. - alpha bravo (suggested by John)
  5393. - charly delta</pre><p>Any patch revision should include the version number. The version number
  5394. is simply composed of the letter <code class="literal">v</code> followed by an <code class="literal">integer</code> greater or
  5395. equal to two (i.e. "PATCH v2", "PATCH v3" …).</p><p>This can be easily handled with <code class="literal">git format-patch</code> by using the option
  5396. <code class="literal">--subject-prefix</code>:</p><pre class="screen">$ git format-patch --subject-prefix "PATCH v4" \
  5397. -M -s -o outgoing origin/master</pre><p>Since git version 1.8.1, you can also use <code class="literal">-v &lt;n&gt;</code> (where &lt;n&gt; is the
  5398. version number):</p><pre class="screen">$ git format-patch -v4 -M -s -o outgoing origin/master</pre><p>When you provide a new version of a patch, please mark the old one as
  5399. superseded in <a class="ulink" href="http://patchwork.buildroot.org" target="_top">patchwork</a>. You need to
  5400. create an account on <a class="ulink" href="http://patchwork.buildroot.org" target="_top">patchwork</a> to be
  5401. able to modify the status of your patches. Note that you can only change
  5402. the status of patches you submitted yourself, which means the email
  5403. address you register in <a class="ulink" href="http://patchwork.buildroot.org" target="_top">patchwork</a> should
  5404. match the one you use for sending patches to the mailing list.</p><p>You can also add the <code class="literal">--in-reply-to &lt;message-id&gt;</code> option when
  5405. submitting a patch to the mailing list. The id of the mail to reply to
  5406. can be found under the "Message Id" tag on
  5407. <a class="ulink" href="http://patchwork.buildroot.org" target="_top">patchwork</a>. The advantage of
  5408. <span class="strong"><strong>in-reply-to</strong></span> is that patchwork will automatically mark the previous
  5409. version of the patch as superseded.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="reporting-bugs"></a>22.6. Reporting issues/bugs or getting help</h2></div></div></div><p>Before reporting any issue, please check in
  5410. <a class="link" href="#community-resources" title="Chapter 5. Community resources">the mailing list archive</a> whether someone has
  5411. already reported and/or fixed a similar problem.</p><p>However you choose to report bugs or get help, either by
  5412. opening a bug in the <a class="link" href="#community-resources" title="Chapter 5. Community resources">bug tracker</a> or by
  5413. <a class="link" href="#community-resources" title="Chapter 5. Community resources">sending a mail to the mailing list</a>, there are
  5414. a number of details to provide in order to help people reproduce and
  5415. find a solution to the issue.</p><p>Try to think as if you were trying to help someone else; in
  5416. that case, what would you need?</p><p>Here is a short list of details to provide in such case:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5417. host machine (OS/release)
  5418. </li><li class="listitem">
  5419. version of Buildroot
  5420. </li><li class="listitem">
  5421. target for which the build fails
  5422. </li><li class="listitem">
  5423. package(s) for which the build fails
  5424. </li><li class="listitem">
  5425. the command that fails and its output
  5426. </li><li class="listitem">
  5427. any information you think that may be relevant
  5428. </li></ul></div><p>Additionally, you should add the <code class="literal">.config</code> file (or if you know how, a
  5429. <code class="literal">defconfig</code>; see <a class="xref" href="#customize-store-buildroot-config" title="9.3. Storing the Buildroot configuration">Section 9.3, “Storing the Buildroot configuration”</a>).</p><p>If some of these details are too large, do not hesitate to use a
  5430. pastebin service. Note that not all available pastebin services will
  5431. preserve Unix-style line terminators when downloading raw pastes.
  5432. Following pastebin services are known to work correctly:
  5433. - <a class="ulink" href="https://gist.github.com/" target="_top">https://gist.github.com/</a>
  5434. - <a class="ulink" href="http://code.bulix.org/" target="_top">http://code.bulix.org/</a></p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_using_the_run_tests_framework"></a>22.7. Using the run-tests framework</h2></div></div></div><p>Buildroot includes a run-time testing framework called run-tests built
  5435. upon Python scripting and QEMU runtime execution. There are two types of
  5436. test cases within the framework, one for build time tests and another for
  5437. run-time tests that have a QEMU dependency. The goals of the framework are
  5438. the following:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5439. build a well defined configuration
  5440. </li><li class="listitem">
  5441. optionally, verify some properties of the build output
  5442. </li><li class="listitem"><p class="simpara">
  5443. if it is a run-time test:
  5444. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  5445. boot it under QEMU
  5446. </li><li class="listitem">
  5447. run some test condition to verify that a given feature is working
  5448. </li></ul></div></li></ul></div><p>The run-tests tool has a series of options documented in the tool’s help <span class="emphasis"><em>-h</em></span>
  5449. description. Some common options include setting the download folder, the
  5450. output folder, keeping build output, and for multiple test cases, you can set
  5451. the JLEVEL for each.</p><p>Here is an example walk through of running a test case.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5452. For a first step, let us see what all the test case options are. The test
  5453. cases can be listed by executing <code class="literal">support/testing/run-tests -l</code>. These tests
  5454. can all be run individually during test development from the console. Both
  5455. one at a time and selectively as a group of a subset of tests.
  5456. </li></ul></div><pre class="screen">$ support/testing/run-tests -l
  5457. List of tests
  5458. test_run (tests.utils.test_check_package.TestCheckPackage)
  5459. Test the various ways the script can be called in a simple top to ... ok
  5460. test_run (tests.toolchain.test_external.TestExternalToolchainBuildrootMusl) ... ok
  5461. test_run (tests.toolchain.test_external.TestExternalToolchainBuildrootuClibc) ... ok
  5462. test_run (tests.toolchain.test_external.TestExternalToolchainCCache) ... ok
  5463. test_run (tests.toolchain.test_external.TestExternalToolchainCtngMusl) ... ok
  5464. test_run (tests.toolchain.test_external.TestExternalToolchainLinaroArm) ... ok
  5465. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv4) ... ok
  5466. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv5) ... ok
  5467. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv7) ... ok
  5468. [snip]
  5469. test_run (tests.init.test_systemd.TestInitSystemSystemdRoFull) ... ok
  5470. test_run (tests.init.test_systemd.TestInitSystemSystemdRoIfupdown) ... ok
  5471. test_run (tests.init.test_systemd.TestInitSystemSystemdRoNetworkd) ... ok
  5472. test_run (tests.init.test_systemd.TestInitSystemSystemdRwFull) ... ok
  5473. test_run (tests.init.test_systemd.TestInitSystemSystemdRwIfupdown) ... ok
  5474. test_run (tests.init.test_systemd.TestInitSystemSystemdRwNetworkd) ... ok
  5475. test_run (tests.init.test_busybox.TestInitSystemBusyboxRo) ... ok
  5476. test_run (tests.init.test_busybox.TestInitSystemBusyboxRoNet) ... ok
  5477. test_run (tests.init.test_busybox.TestInitSystemBusyboxRw) ... ok
  5478. test_run (tests.init.test_busybox.TestInitSystemBusyboxRwNet) ... ok
  5479. Ran 157 tests in 0.021s
  5480. OK</pre><p>Those runtime tests are regularly executed by Buildroot Gitlab CI
  5481. infrastructure, see .gitlab.yml and <a class="ulink" href="https://gitlab.com/buildroot.org/buildroot/-/jobs" target="_top">https://gitlab.com/buildroot.org/buildroot/-/jobs</a>.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_creating_a_test_case"></a>22.7.1. Creating a test case</h3></div></div></div><p>The best way to get familiar with how to create a test case is to look at a
  5482. few of the basic file system <code class="literal">support/testing/tests/fs/</code> and init
  5483. <code class="literal">support/testing/tests/init/</code> test scripts. Those tests give good examples
  5484. of a basic build and build with run type of tests. There are other more
  5485. advanced cases that use things like nested <code class="literal">br2-external</code> folders to provide
  5486. skeletons and additional packages.</p><p>The test cases by default use a br-arm-full-* uClibc-ng toolchain and the
  5487. prebuild kernel for a armv5/7 cpu. It is recommended to use the default
  5488. defconfig test configuration except when Glibc/musl or a newer kernel are
  5489. necessary. By using the default it saves build time and the test would
  5490. automatically inherit a kernel/std library upgrade when the default is
  5491. updated.</p><p>The basic test case definition involves</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5492. Creation of a new test file
  5493. </li><li class="listitem">
  5494. Defining a unique test class
  5495. </li><li class="listitem">
  5496. Determining if the default defconfig plus test options can be used
  5497. </li><li class="listitem">
  5498. Implementing a <code class="literal">def test_run(self):</code> function to optionally startup the
  5499. emulator and provide test case conditions.
  5500. </li></ul></div><p>After creating the test script, add yourself to the <code class="literal">DEVELOPERS</code> file to
  5501. be the maintainer of that test case.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_debugging_a_test_case"></a>22.7.2. Debugging a test case</h3></div></div></div><p>Within the Buildroot repository, the testing framework is organized at the
  5502. top level in <code class="literal">support/testing/</code> by folders of <code class="literal">conf</code>, <code class="literal">infra</code> and <code class="literal">tests</code>.
  5503. All the test cases live under the <code class="literal">test</code> folder and are organized in various
  5504. folders representing the catagory of test.</p><p>Lets walk through an example.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5505. Using the Busybox Init system test case with a read/write rootfs
  5506. <code class="literal">tests.init.test_busybox.TestInitSystemBusyboxRw</code>
  5507. </li><li class="listitem">
  5508. A minimal set of command line arguments when debugging a test case would
  5509. include <span class="emphasis"><em>-d</em></span> which points to your dl folder, <span class="emphasis"><em>-o</em></span> to an output folder, and
  5510. <span class="emphasis"><em>-k</em></span> to keep any output on both pass/fail. With those options, the test will
  5511. retain logging and build artifacts providing status of the build and
  5512. execution of the test case.
  5513. </li></ul></div><pre class="screen">$ support/testing/run-tests -d dl -o output_folder -k tests.init.test_busybox.TestInitSystemBusyboxRw
  5514. 15:03:26 TestInitSystemBusyboxRw Starting
  5515. 15:03:28 TestInitSystemBusyboxRw Building
  5516. 15:08:18 TestInitSystemBusyboxRw Building done
  5517. 15:08:27 TestInitSystemBusyboxRw Cleaning up
  5518. .
  5519. Ran 1 test in 301.140s
  5520. OK</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5521. For the case of a successful build, the <code class="literal">output_folder</code> would contain a
  5522. &lt;test name&gt; folder with the Buildroot build, build log and run-time log. If
  5523. the build failed, the console output would show the stage at which it failed
  5524. (setup / build / run). Depending on the failure stage, the build/run logs
  5525. and/or Buildroot build artifacts can be inspected and instrumented. If the
  5526. QEMU instance needs to be launched for additional testing, the first few
  5527. lines of the run-time log capture it and it would allow some incremental
  5528. testing without re-running <code class="literal">support/testing/run-tests</code>.
  5529. </li><li class="listitem">
  5530. You can also make modifications to the current sources inside the
  5531. <code class="literal">output_folder</code> (e.g. for debug purposes) and rerun the standard
  5532. Buildroot make targets (in order to regenerate the complete image with
  5533. the new modifications) and then rerun the test. Modifying the sources
  5534. directly can speed up debugging compared to adding patch files, wiping the
  5535. output directoy, and starting the test again.
  5536. </li></ul></div><pre class="screen">$ ls output_folder/
  5537. TestInitSystemBusyboxRw/
  5538. TestInitSystemBusyboxRw-build.log
  5539. TestInitSystemBusyboxRw-run.log</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5540. The source file used to implement this example test is found under
  5541. <code class="literal">support/testing/tests/init/test_busybox.py</code>. This file outlines the
  5542. minimal defconfig that creates the build, QEMU configuration to launch
  5543. the built images and the test case assertions.
  5544. </li></ul></div><p>To test an existing or new test case within Gitlab CI, there is a method of
  5545. invoking a specific test by creating a Buildroot fork in Gitlab under your
  5546. account. This can be handy when adding/changing a run-time test or fixing a
  5547. bug on a use case tested by a run-time test case.</p><p>In the examples below, the &lt;name&gt; component of the branch name is a unique
  5548. string you choose to identify this specific job being created.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5549. to trigger all run-test test case jobs:
  5550. </li></ul></div><pre class="screen"> $ git push gitlab HEAD:&lt;name&gt;-runtime-tests</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5551. to trigger one test case job, a specific branch naming string is used that
  5552. includes the full test case name.
  5553. </li></ul></div><pre class="screen"> $ git push gitlab HEAD:&lt;name&gt;-&lt;test case name&gt;</pre></div></div><div class="footnotes"><br /><hr style="width:100; text-align:left;margin-left: 0" /><div id="ftn.idm5691" class="footnote"><p><a href="#idm5691" class="simpara"><sup class="simpara">[4] </sup></a>RFC: (Request for comments) change proposal</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="DEVELOPERS"></a>Chapter 23. DEVELOPERS file and get-developers</h2></div></div></div><p>The main Buildroot directory contains a file named <code class="literal">DEVELOPERS</code> that
  5554. lists the developers involved with various areas of Buildroot. Thanks
  5555. to this file, the <code class="literal">get-developers</code> tool allows to:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5556. Calculate the list of developers to whom patches should be sent, by
  5557. parsing the patches and matching the modified files with the
  5558. relevant developers. See <a class="xref" href="#submitting-patches" title="22.5. Submitting patches">Section 22.5, “Submitting patches”</a> for details.
  5559. </li><li class="listitem">
  5560. Find which developers are taking care of a given architecture or
  5561. package, so that they can be notified when a build failure occurs on
  5562. this architecture or package. This is done in interaction with
  5563. Buildroot’s autobuild infrastructure.
  5564. </li></ul></div><p>We ask developers adding new packages, new boards, or generally new
  5565. functionality in Buildroot, to register themselves in the <code class="literal">DEVELOPERS</code>
  5566. file. As an example, we expect a developer contributing a new package
  5567. to include in his patch the appropriate modification to the
  5568. <code class="literal">DEVELOPERS</code> file.</p><p>The <code class="literal">DEVELOPERS</code> file format is documented in detail inside the file
  5569. itself.</p><p>The <code class="literal">get-developers</code> tool, located in <code class="literal">utils/</code> allows to use
  5570. the <code class="literal">DEVELOPERS</code> file for various tasks:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5571. When passing one or several patches as command line argument,
  5572. <code class="literal">get-developers</code> will return the appropriate <code class="literal">git send-email</code>
  5573. command. If the <code class="literal">-e</code> option is passed, only the email addresses are
  5574. printed in a format suitable for <code class="literal">git send-email --cc-cmd</code>.
  5575. </li><li class="listitem">
  5576. When using the <code class="literal">-a &lt;arch&gt;</code> command line option, <code class="literal">get-developers</code> will
  5577. return the list of developers in charge of the given architecture.
  5578. </li><li class="listitem">
  5579. When using the <code class="literal">-p &lt;package&gt;</code> command line option, <code class="literal">get-developers</code>
  5580. will return the list of developers in charge of the given package.
  5581. </li><li class="listitem">
  5582. When using the <code class="literal">-c</code> command line option, <code class="literal">get-developers</code> will look
  5583. at all files under version control in the Buildroot repository, and
  5584. list the ones that are not handled by any developer. The purpose of
  5585. this option is to help completing the <code class="literal">DEVELOPERS</code> file.
  5586. </li><li class="listitem">
  5587. When using without any arguments, it validates the integrity of the
  5588. DEVELOPERS file and will note WARNINGS for items that don’t match.
  5589. </li></ul></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="RELENG"></a>Chapter 24. Release Engineering</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_releases"></a>24.1. Releases</h2></div></div></div><p>The Buildroot project makes quarterly releases with monthly bugfix
  5590. releases. The first release of each year is a long term support
  5591. release, LTS.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5592. Quarterly releases: 2020.02, 2020.05, 2020.08, and 2020.11
  5593. </li><li class="listitem">
  5594. Bugfix releases: 2020.02.1, 2020.02.2, …
  5595. </li><li class="listitem">
  5596. LTS releases: 2020.02, 2021.02, …
  5597. </li></ul></div><p>Releases are supported until the first bugfix release of the next
  5598. release, e.g., 2020.05.x is EOL when 2020.08.1 is released.</p><p>LTS releases are supported until the first bugfix release of the next
  5599. LTS, e.g., 2020.02.x is supported until 2021.02.1 is released.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_development"></a>24.2. Development</h2></div></div></div><p>Each release cycle consist of two months of development on the <code class="literal">master</code>
  5600. branch and one month stabilization before the release is made. During
  5601. this phase no new features are added to <code class="literal">master</code>, only bugfixes.</p><p>The stabilization phase starts with tagging <code class="literal">-rc1</code>, and every week until
  5602. the release, another release candidate is tagged.</p><p>To handle new features and version bumps during the stabilization phase,
  5603. a <code class="literal">next</code> branch may be created for these features. Once the current
  5604. release has been made, the <code class="literal">next</code> branch is merged into <code class="literal">master</code> and
  5605. the development cycle for the next release continues there.</p></div></div></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="_appendix"></a>Part IV. Appendix</h1></div></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="makedev-syntax"></a>Chapter 25. Makedev syntax documentation</h2></div></div></div><p>The makedev syntax is used in several places in Buildroot to
  5606. define changes to be made for permissions, or which device files to
  5607. create and how to create them, in order to avoid calls to mknod.</p><p>This syntax is derived from the makedev utility, and more complete
  5608. documentation can be found in the <code class="literal">package/makedevs/README</code> file.</p><p>It takes the form of a space separated list of fields, one file per
  5609. line; the fields are:</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; "><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /><col class="col_4" /><col class="col_5" /><col class="col_6" /><col class="col_7" /><col class="col_8" /><col class="col_9" /><col class="col_10" /></colgroup><tbody><tr><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>name</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>type</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>mode</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>uid</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>gid</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>major</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>minor</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>start</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>inc</p></td><td style="" align="left" valign="top"><p>count</p></td></tr></tbody></table></div><p>There are a few non-trivial blocks:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5610. <code class="literal">name</code> is the path to the file you want to create/modify
  5611. </li><li class="listitem"><p class="simpara">
  5612. <code class="literal">type</code> is the type of the file, being one of:
  5613. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
  5614. f: a regular file
  5615. </li><li class="listitem">
  5616. d: a directory
  5617. </li><li class="listitem">
  5618. r: a directory recursively
  5619. </li><li class="listitem">
  5620. c: a character device file
  5621. </li><li class="listitem">
  5622. b: a block device file
  5623. </li><li class="listitem">
  5624. p: a named pipe
  5625. </li></ul></div></li><li class="listitem">
  5626. <code class="literal">mode</code> are the usual permissions settings (only numerical values
  5627. are allowed)
  5628. </li><li class="listitem">
  5629. <code class="literal">uid</code> and <code class="literal">gid</code> are the UID and GID to set on this file; can be
  5630. either numerical values or actual names
  5631. </li><li class="listitem">
  5632. <code class="literal">major</code> and <code class="literal">minor</code> are here for device files, set to <code class="literal">-</code> for other
  5633. files
  5634. </li><li class="listitem">
  5635. <code class="literal">start</code>, <code class="literal">inc</code> and <code class="literal">count</code> are for when you want to create a batch
  5636. of files, and can be reduced to a loop, beginning at <code class="literal">start</code>,
  5637. incrementing its counter by <code class="literal">inc</code> until it reaches <code class="literal">count</code>
  5638. </li></ul></div><p>Let’s say you want to change the permissions of a given file; using
  5639. this syntax, you will need to write:</p><pre class="screen">/usr/bin/foo f 755 0 0 - - - - -
  5640. /usr/bin/bar f 755 root root - - - - -
  5641. /data/buz f 644 buz-user buz-group - - - - -</pre><p>Alternatively, if you want to change owner/permission of a directory
  5642. recursively, you can write (to set UID to foo, GID to bar and access
  5643. rights to rwxr-x--- for the directory /usr/share/myapp and all files
  5644. and directories below it):</p><pre class="screen">/usr/share/myapp r 750 foo bar - - - - -</pre><p>On the other hand, if you want to create the device file <code class="literal">/dev/hda</code>
  5645. and the corresponding 15 files for the partitions, you will need for
  5646. <code class="literal">/dev/hda</code>:</p><pre class="screen">/dev/hda b 640 root root 3 0 0 0 -</pre><p>and then for device files corresponding to the partitions of
  5647. <code class="literal">/dev/hda</code>, <code class="literal">/dev/hdaX</code>, <code class="literal">X</code> ranging from 1 to 15:</p><pre class="screen">/dev/hda b 640 root root 3 1 1 1 15</pre><p>Extended attributes are supported if
  5648. <code class="literal">BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES</code> is enabled.
  5649. This is done by adding a line starting with <code class="literal">|xattr</code> after
  5650. the line describing the file. Right now, only capability
  5651. is supported as extended attribute.</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; "><colgroup><col class="col_1" /><col class="col_2" /></colgroup><tbody><tr><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>|xattr</p></td><td style="" align="left" valign="top"><p>capability</p></td></tr></tbody></table></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5652. <code class="literal">|xattr</code> is a "flag" that indicate an extended attribute
  5653. </li><li class="listitem">
  5654. <code class="literal">capability</code> is a capability to add to the previous file
  5655. </li></ul></div><p>If you want to add the capability cap_sys_admin to the binary foo,
  5656. you will write :</p><pre class="screen">/usr/bin/foo f 755 root root - - - - -
  5657. |xattr cap_sys_admin+eip</pre><p>You can add several capabilities to a file by using several <code class="literal">|xattr</code> lines.
  5658. If you want to add the capability cap_sys_admin and cap_net_admin to the
  5659. binary foo, you will write :</p><pre class="screen">/usr/bin/foo f 755 root root - - - - -
  5660. |xattr cap_sys_admin+eip
  5661. |xattr cap_net_admin+eip</pre></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="makeuser-syntax"></a>Chapter 26. Makeusers syntax documentation</h2></div></div></div><p>The syntax to create users is inspired by the makedev syntax, above, but
  5662. is specific to Buildroot.</p><p>The syntax for adding a user is a space-separated list of fields, one
  5663. user per line; the fields are:</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; "><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /><col class="col_4" /><col class="col_5" /><col class="col_6" /><col class="col_7" /><col class="col_8" /><col class="col_9" /></colgroup><tbody><tr><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>username</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>uid</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>group</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>gid</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>password</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>home</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>shell</p></td><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>groups</p></td><td style="" align="left" valign="top"><p>comment</p></td></tr></tbody></table></div><p>Where:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5664. <code class="literal">username</code> is the desired user name (aka login name) for the user.
  5665. It can not be <code class="literal">root</code>, and must be unique. If set to <code class="literal">-</code>, then just a
  5666. group will be created.
  5667. </li><li class="listitem">
  5668. <code class="literal">uid</code> is the desired UID for the user. It must be unique, and not
  5669. <code class="literal">0</code>. If set to <code class="literal">-1</code>, then a unique UID will be computed by Buildroot
  5670. in the range [1000…1999]
  5671. </li><li class="listitem">
  5672. <code class="literal">group</code> is the desired name for the user’s main group. It can not
  5673. be <code class="literal">root</code>. If the group does not exist, it will be created.
  5674. </li><li class="listitem">
  5675. <code class="literal">gid</code> is the desired GID for the user’s main group. It must be unique,
  5676. and not <code class="literal">0</code>. If set to <code class="literal">-1</code>, and the group does not already exist, then
  5677. a unique GID will be computed by Buildroot in the range [1000..1999]
  5678. </li><li class="listitem">
  5679. <code class="literal">password</code> is the crypt(3)-encoded password. If prefixed with <code class="literal">!</code>,
  5680. then login is disabled. If prefixed with <code class="literal">=</code>, then it is interpreted
  5681. as clear-text, and will be crypt-encoded (using MD5). If prefixed with
  5682. <code class="literal">!=</code>, then the password will be crypt-encoded (using MD5) and login
  5683. will be disabled. If set to <code class="literal">*</code>, then login is not allowed. If set to
  5684. <code class="literal">-</code>, then no password value will be set.
  5685. </li><li class="listitem">
  5686. <code class="literal">home</code> is the desired home directory for the user. If set to <span class="emphasis"><em>-</em></span>, no
  5687. home directory will be created, and the user’s home will be <code class="literal">/</code>.
  5688. Explicitly setting <code class="literal">home</code> to <code class="literal">/</code> is not allowed.
  5689. </li><li class="listitem">
  5690. <code class="literal">shell</code> is the desired shell for the user. If set to <code class="literal">-</code>, then
  5691. <code class="literal">/bin/false</code> is set as the user’s shell.
  5692. </li><li class="listitem">
  5693. <code class="literal">groups</code> is the comma-separated list of additional groups the user
  5694. should be part of. If set to <code class="literal">-</code>, then the user will be a member of
  5695. no additional group. Missing groups will be created with an arbitrary
  5696. <code class="literal">gid</code>.
  5697. </li><li class="listitem">
  5698. <code class="literal">comment</code> (aka <a class="ulink" href="https://en.wikipedia.org/wiki/Gecos_field" target="_top">GECOS</a>
  5699. field) is an almost-free-form text.
  5700. </li></ul></div><p>There are a few restrictions on the content of each field:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5701. except for <code class="literal">comment</code>, all fields are mandatory.
  5702. </li><li class="listitem">
  5703. except for <code class="literal">comment</code>, fields may not contain spaces.
  5704. </li><li class="listitem">
  5705. no field may contain a colon (<code class="literal">:</code>).
  5706. </li></ul></div><p>If <code class="literal">home</code> is not <code class="literal">-</code>, then the home directory, and all files below,
  5707. will belong to the user and its main group.</p><p>Examples:</p><pre class="screen">foo -1 bar -1 !=blabla /home/foo /bin/sh alpha,bravo Foo user</pre><p>This will create this user:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5708. <code class="literal">username</code> (aka login name) is: <code class="literal">foo</code>
  5709. </li><li class="listitem">
  5710. <code class="literal">uid</code> is computed by Buildroot
  5711. </li><li class="listitem">
  5712. main <code class="literal">group</code> is: <code class="literal">bar</code>
  5713. </li><li class="listitem">
  5714. main group <code class="literal">gid</code> is computed by Buildroot
  5715. </li><li class="listitem">
  5716. clear-text <code class="literal">password</code> is: <code class="literal">blabla</code>, will be crypt(3)-encoded, and login is disabled.
  5717. </li><li class="listitem">
  5718. <code class="literal">home</code> is: <code class="literal">/home/foo</code>
  5719. </li><li class="listitem">
  5720. <code class="literal">shell</code> is: <code class="literal">/bin/sh</code>
  5721. </li><li class="listitem">
  5722. <code class="literal">foo</code> is also a member of <code class="literal">groups</code>: <code class="literal">alpha</code> and <code class="literal">bravo</code>
  5723. </li><li class="listitem">
  5724. <code class="literal">comment</code> is: <code class="literal">Foo user</code>
  5725. </li></ul></div><pre class="screen">test 8000 wheel -1 = - /bin/sh - Test user</pre><p>This will create this user:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  5726. <code class="literal">username</code> (aka login name) is: <code class="literal">test</code>
  5727. </li><li class="listitem">
  5728. <code class="literal">uid</code> is : <code class="literal">8000</code>
  5729. </li><li class="listitem">
  5730. main <code class="literal">group</code> is: <code class="literal">wheel</code>
  5731. </li><li class="listitem">
  5732. main group <code class="literal">gid</code> is computed by Buildroot, and will use the value defined in the rootfs skeleton
  5733. </li><li class="listitem">
  5734. <code class="literal">password</code> is empty (aka no password).
  5735. </li><li class="listitem">
  5736. <code class="literal">home</code> is <code class="literal">/</code> but will not belong to <code class="literal">test</code>
  5737. </li><li class="listitem">
  5738. <code class="literal">shell</code> is: <code class="literal">/bin/sh</code>
  5739. </li><li class="listitem">
  5740. <code class="literal">test</code> is not a member of any additional <code class="literal">groups</code>
  5741. </li><li class="listitem">
  5742. <code class="literal">comment</code> is: <code class="literal">Test user</code>
  5743. </li></ul></div></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="migrating-from-ol-versions"></a>Chapter 27. Migrating from older Buildroot versions</h2></div></div></div><p>Some versions have introduced backward incompatibilities. This section
  5744. explains those incompatibilities, and for each explains what to do to
  5745. complete the migration.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="br2-external-converting"></a>27.1. Migrating to 2016.11</h2></div></div></div><p>Before Buildroot 2016.11, it was possible to use only one br2-external
  5746. tree at once. With Buildroot 2016.11 came the possibility to use more
  5747. than one simultaneously (for details, see <a class="xref" href="#outside-br-custom" title="9.2. Keeping customizations outside of Buildroot">Section 9.2, “Keeping customizations outside of Buildroot”</a>).</p><p>This however means that older br2-external trees are not usable as-is.
  5748. A minor change has to be made: adding a name to your br2-external tree.</p><p>This can be done very easily in just a few steps:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
  5749. First, create a new file named <code class="literal">external.desc</code>, at the root of your
  5750. br2-external tree, with a single line defining the name of your
  5751. br2-external tree:
  5752. </p><pre class="screen">$ echo 'name: NAME_OF_YOUR_TREE' &gt;external.desc</pre><p><strong>Note. </strong>Be careful when choosing a name: It has to be unique and be made
  5753. with only ASCII characters from the set <code class="literal">[A-Za-z0-9_]</code>.</p></li><li class="listitem"><p class="simpara">
  5754. Then, change every occurence of <code class="literal">BR2_EXTERNAL</code> in your br2-external
  5755. tree with the new variable:
  5756. </p><pre class="screen">$ find . -type f | xargs sed -i 's/BR2_EXTERNAL/BR2_EXTERNAL_NAME_OF_YOUR_TREE_PATH/g'</pre></li></ul></div><p>Now, your br2-external tree can be used with Buildroot 2016.11 onward.</p><p><strong>Note: </strong>This change makes your br2-external tree incompatible with Buildroot
  5757. before 2016.11.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="migrating-host-usr"></a>27.2. Migrating to 2017.08</h2></div></div></div><p>Before Buildroot 2017.08, host packages were installed in <code class="literal">$(HOST_DIR)/usr</code>
  5758. (with e.g. the autotools' <code class="literal">--prefix=$(HOST_DIR)/usr</code>). With Buildroot
  5759. 2017.08, they are now installed directly in <code class="literal">$(HOST_DIR)</code>.</p><p>Whenever a package installs an executable that is linked with a library
  5760. in <code class="literal">$(HOST_DIR)/lib</code>, it must have an RPATH pointing to that directory.</p><p>An RPATH pointing to <code class="literal">$(HOST_DIR)/usr/lib</code> is no longer accepted.</p></div></div></div></div></body></html>