manual.text 369 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801
  1. ---------------------------------------------------------------------
  2. The Buildroot user manual
  3. ---------------------------------------------------------------------
  4. ---------------------------------------------------------------------
  5. Table of Contents
  6. I. Getting started
  7. 1. About Buildroot
  8. 2. System requirements
  9. 2.1. Mandatory packages
  10. 2.2. Optional packages
  11. 3. Getting Buildroot
  12. 4. Buildroot quick start
  13. 5. Community resources
  14. II. User guide
  15. 6. Buildroot configuration
  16. 6.1. Cross-compilation toolchain
  17. 6.2. /dev management
  18. 6.3. init system
  19. 7. Configuration of other components
  20. 8. General Buildroot usage
  21. 8.1. make tips
  22. 8.2. Understanding when a full rebuild is necessary
  23. 8.3. Understanding how to rebuild packages
  24. 8.4. Offline builds
  25. 8.5. Building out-of-tree
  26. 8.6. Environment variables
  27. 8.7. Dealing efficiently with filesystem images
  28. 8.8. Details about packages
  29. 8.9. Graphing the dependencies between packages
  30. 8.10. Graphing the build duration
  31. 8.11. Graphing the filesystem size contribution of packages
  32. 8.12. Top-level parallel build
  33. 8.13. Advanced usage
  34. 9. Project-specific customization
  35. 9.1. Recommended directory structure
  36. 9.2. Keeping customizations outside of Buildroot
  37. 9.3. Storing the Buildroot configuration
  38. 9.4. Storing the configuration of other components
  39. 9.5. Customizing the generated target filesystem
  40. 9.6. Adding custom user accounts
  41. 9.7. Customization after the images have been created
  42. 9.8. Adding project-specific patches and hashes
  43. 9.9. Adding project-specific packages
  44. 9.10. Quick guide to storing your project-specific
  45. customizations
  46. 10. Integration topics
  47. 10.1. Systemd
  48. 10.2. Using SELinux in Buildroot
  49. 11. Frequently Asked Questions & Troubleshooting
  50. 11.1. The boot hangs after Starting network…
  51. 11.2. Why is there no compiler on the target?
  52. 11.3. Why are there no development files on the target?
  53. 11.4. Why is there no documentation on the target?
  54. 11.5. Why are some packages not visible in the Buildroot
  55. config menu?
  56. 11.6. Why not use the target directory as a chroot directory?
  57. 11.7. Why doesn’t Buildroot generate binary packages (.deb,
  58. .ipkg…)?
  59. 11.8. How to speed-up the build process?
  60. 11.9. How does Buildroot support Y2038?
  61. 12. Known issues
  62. 13. Legal notice and licensing
  63. 13.1. Complying with open source licenses
  64. 13.2. Complying with the Buildroot license
  65. 14. Beyond Buildroot
  66. 14.1. Boot the generated images
  67. 14.2. Chroot
  68. III. Developer guide
  69. 15. How Buildroot works
  70. 16. Coding style
  71. 16.1. Config.in file
  72. 16.2. The .mk file
  73. 16.3. The genimage.cfg file
  74. 16.4. The documentation
  75. 16.5. Support scripts
  76. 17. Adding support for a particular board
  77. 18. Adding new packages to Buildroot
  78. 18.1. Package directory
  79. 18.2. Config files
  80. 18.3. The .mk file
  81. 18.4. The .hash file
  82. 18.5. The SNNfoo start script
  83. 18.6. Infrastructure for packages with specific build systems
  84. 18.7. Infrastructure for autotools-based packages
  85. 18.8. Infrastructure for CMake-based packages
  86. 18.9. Infrastructure for Python packages
  87. 18.10. Infrastructure for LuaRocks-based packages
  88. 18.11. Infrastructure for Perl/CPAN packages
  89. 18.12. Infrastructure for virtual packages
  90. 18.13. Infrastructure for packages using kconfig for
  91. configuration files
  92. 18.14. Infrastructure for rebar-based packages
  93. 18.15. Infrastructure for Waf-based packages
  94. 18.16. Infrastructure for Meson-based packages
  95. 18.17. Infrastructure for Cargo-based packages
  96. 18.18. Infrastructure for Go packages
  97. 18.19. Infrastructure for QMake-based packages
  98. 18.20. Infrastructure for packages building kernel modules
  99. 18.21. Infrastructure for asciidoc documents
  100. 18.22. Infrastructure specific to the Linux kernel package
  101. 18.23. Hooks available in the various build steps
  102. 18.24. Gettext integration and interaction with packages
  103. 18.25. Tips and tricks
  104. 18.26. Conclusion
  105. 19. Patching a package
  106. 19.1. Providing patches
  107. 19.2. How patches are applied
  108. 19.3. Format and licensing of the package patches
  109. 19.4. Additional patch documentation
  110. 20. Download infrastructure
  111. 21. Debugging Buildroot
  112. 22. Contributing to Buildroot
  113. 22.1. Reproducing, analyzing and fixing bugs
  114. 22.2. Analyzing and fixing autobuild failures
  115. 22.3. Reviewing and testing patches
  116. 22.4. Work on items from the TODO list
  117. 22.5. Submitting patches
  118. 22.6. Reporting issues/bugs or getting help
  119. 22.7. Using the runtime tests framework
  120. 23. DEVELOPERS file and get-developers
  121. 24. Release Engineering
  122. 24.1. Releases
  123. 24.2. Development
  124. IV. Appendix
  125. 25. Makedev syntax documentation
  126. 26. Makeusers syntax documentation
  127. 26.1. Caveat with automatic UIDs and GIDs
  128. 27. Migrating from older Buildroot versions
  129. 27.1. General approach
  130. 27.2. Migrating to 2016.11
  131. 27.3. Migrating to 2017.08
  132. 27.4. Migrating to 2023.11
  133. List of Examples
  134. 18.1. Config script: divine package
  135. 18.2. Config script: imagemagick package:
  136. ---------------------------------------------------------------------
  137. ---------------------------------------------------------------------
  138. Buildroot 2024.02.10 manual generated on 2025-01-09 13:44:25 UTC from
  139. git revision c9620ac37e
  140. The Buildroot manual is written by the Buildroot developers. It is
  141. licensed under the GNU General Public License, version 2. Refer to
  142. the COPYING [http://git.buildroot.org/buildroot/tree/COPYING?id=
  143. c9620ac37e658d177821be85b4c9484e71e19710] file in the Buildroot
  144. sources for the full text of this license.
  145. Copyright © The Buildroot developers <>
  146. Part I. Getting started
  147. Table of Contents
  148. 1. About Buildroot
  149. 2. System requirements
  150. 2.1. Mandatory packages
  151. 2.2. Optional packages
  152. 3. Getting Buildroot
  153. 4. Buildroot quick start
  154. 5. Community resources
  155. Chapter 1. About Buildroot
  156. Buildroot is a tool that simplifies and automates the process of
  157. building a complete Linux system for an embedded system, using
  158. cross-compilation.
  159. In order to achieve this, Buildroot is able to generate a
  160. cross-compilation toolchain, a root filesystem, a Linux kernel image
  161. and a bootloader for your target. Buildroot can be used for any
  162. combination of these options, independently (you can for example use
  163. an existing cross-compilation toolchain, and build only your root
  164. filesystem with Buildroot).
  165. Buildroot is useful mainly for people working with embedded systems.
  166. Embedded systems often use processors that are not the regular x86
  167. processors everyone is used to having in his PC. They can be PowerPC
  168. processors, MIPS processors, ARM processors, etc.
  169. Buildroot supports numerous processors and their variants; it also
  170. comes with default configurations for several boards available
  171. off-the-shelf. Besides this, a number of third-party projects are
  172. based on, or develop their BSP ^[1] or SDK ^[2] on top of Buildroot.
  173. ---------------------------------------------------------------------
  174. ^[1] BSP: Board Support Package
  175. ^[2] SDK: Software Development Kit
  176. Chapter 2. System requirements
  177. Buildroot is designed to run on Linux systems.
  178. While Buildroot itself will build most host packages it needs for the
  179. compilation, certain standard Linux utilities are expected to be
  180. already installed on the host system. Below you will find an overview
  181. of the mandatory and optional packages (note that package names may
  182. vary between distributions).
  183. 2.1. Mandatory packages
  184. * Build tools:
  185. + which
  186. + sed
  187. + make (version 3.81 or any later)
  188. + binutils
  189. + build-essential (only for Debian based systems)
  190. + diffutils
  191. + gcc (version 4.8 or any later)
  192. + g++ (version 4.8 or any later)
  193. + bash
  194. + patch
  195. + gzip
  196. + bzip2
  197. + perl (version 5.8.7 or any later)
  198. + tar
  199. + cpio
  200. + unzip
  201. + rsync
  202. + file (must be in /usr/bin/file)
  203. + bc
  204. + findutils
  205. * Source fetching tools:
  206. + wget
  207. 2.2. Optional packages
  208. * Recommended dependencies:
  209. Some features or utilities in Buildroot, like the legal-info, or
  210. the graph generation tools, have additional dependencies.
  211. Although they are not mandatory for a simple build, they are
  212. still highly recommended:
  213. + python (version 2.7 or any later)
  214. * Configuration interface dependencies:
  215. For these libraries, you need to install both runtime and
  216. development data, which in many distributions are packaged
  217. separately. The development packages typically have a -dev or
  218. -devel suffix.
  219. + ncurses5 to use the menuconfig interface
  220. + qt5 to use the xconfig interface
  221. + glib2, gtk2 and glade2 to use the gconfig interface
  222. * Source fetching tools:
  223. In the official tree, most of the package sources are retrieved
  224. using wget from ftp, http or https locations. A few packages are
  225. only available through a version control system. Moreover,
  226. Buildroot is capable of downloading sources via other tools, like
  227. git or scp (refer to Chapter 20, Download infrastructure for more
  228. details). If you enable packages using any of these methods, you
  229. will need to install the corresponding tool on the host system:
  230. + bazaar
  231. + cvs
  232. + git
  233. + mercurial
  234. + scp
  235. + sftp
  236. + subversion
  237. * Java-related packages, if the Java Classpath needs to be built
  238. for the target system:
  239. + The javac compiler
  240. + The jar tool
  241. * Documentation generation tools:
  242. + asciidoc, version 8.6.3 or higher
  243. + w3m
  244. + python with the argparse module (automatically present in
  245. 2.7+ and 3.2+)
  246. + dblatex (required for the pdf manual only)
  247. * Graph generation tools:
  248. + graphviz to use graph-depends and <pkg>-graph-depends
  249. + python-matplotlib to use graph-build
  250. * Package statistics tools (pkg-stats):
  251. + python-aiohttp
  252. Chapter 3. Getting Buildroot
  253. Buildroot releases are made every 3 months, in February, May, August
  254. and November. Release numbers are in the format YYYY.MM, so for
  255. example 2013.02, 2014.08.
  256. Release tarballs are available at http://buildroot.org/downloads/.
  257. For your convenience, a Vagrantfile [https://www.vagrantup.com/] is
  258. available in support/misc/Vagrantfile in the Buildroot source tree to
  259. quickly set up a virtual machine with the needed dependencies to get
  260. started.
  261. If you want to setup an isolated buildroot environment on Linux or
  262. Mac Os X, paste this line onto your terminal:
  263. curl -O https://buildroot.org/downloads/Vagrantfile; vagrant up
  264. If you are on Windows, paste this into your powershell:
  265. (new-object System.Net.WebClient).DownloadFile(
  266. "https://buildroot.org/downloads/Vagrantfile","Vagrantfile");
  267. vagrant up
  268. If you want to follow development, you can use the daily snapshots or
  269. make a clone of the Git repository. Refer to the Download page [http:
  270. //buildroot.org/download] of the Buildroot website for more details.
  271. Chapter 4. Buildroot quick start
  272. Important: you can and should build everything as a normal user.
  273. There is no need to be root to configure and use Buildroot. By
  274. running all commands as a regular user, you protect your system
  275. against packages behaving badly during compilation and installation.
  276. The first step when using Buildroot is to create a configuration.
  277. Buildroot has a nice configuration tool similar to the one you can
  278. find in the Linux kernel [http://www.kernel.org/] or in BusyBox
  279. [http://www.busybox.net/].
  280. From the buildroot directory, run
  281. $ make menuconfig
  282. for the original curses-based configurator, or
  283. $ make nconfig
  284. for the new curses-based configurator, or
  285. $ make xconfig
  286. for the Qt-based configurator, or
  287. $ make gconfig
  288. for the GTK-based configurator.
  289. All of these "make" commands will need to build a configuration
  290. utility (including the interface), so you may need to install
  291. "development" packages for relevant libraries used by the
  292. configuration utilities. Refer to Chapter 2, System requirements for
  293. more details, specifically the optional requirements to get the
  294. dependencies of your favorite interface.
  295. For each menu entry in the configuration tool, you can find
  296. associated help that describes the purpose of the entry. Refer to
  297. Chapter 6, Buildroot configuration for details on some specific
  298. configuration aspects.
  299. Once everything is configured, the configuration tool generates a
  300. .config file that contains the entire configuration. This file will
  301. be read by the top-level Makefile.
  302. To start the build process, simply run:
  303. $ make
  304. By default, Buildroot does not support top-level parallel build, so
  305. running make -jN is not necessary. There is however experimental
  306. support for top-level parallel build, see Section 8.12, “Top-level
  307. parallel build”.
  308. The make command will generally perform the following steps:
  309. * download source files (as required);
  310. * configure, build and install the cross-compilation toolchain, or
  311. simply import an external toolchain;
  312. * configure, build and install selected target packages;
  313. * build a kernel image, if selected;
  314. * build a bootloader image, if selected;
  315. * create a root filesystem in selected formats.
  316. Buildroot output is stored in a single directory, output/. This
  317. directory contains several subdirectories:
  318. * images/ where all the images (kernel image, bootloader and root
  319. filesystem images) are stored. These are the files you need to
  320. put on your target system.
  321. * build/ where all the components are built (this includes tools
  322. needed by Buildroot on the host and packages compiled for the
  323. target). This directory contains one subdirectory for each of
  324. these components.
  325. * host/ contains both the tools built for the host, and the sysroot
  326. of the target toolchain. The former is an installation of tools
  327. compiled for the host that are needed for the proper execution of
  328. Buildroot, including the cross-compilation toolchain. The latter
  329. is a hierarchy similar to a root filesystem hierarchy. It
  330. contains the headers and libraries of all user-space packages
  331. that provide and install libraries used by other packages.
  332. However, this directory is not intended to be the root filesystem
  333. for the target: it contains a lot of development files,
  334. unstripped binaries and libraries that make it far too big for an
  335. embedded system. These development files are used to compile
  336. libraries and applications for the target that depend on other
  337. libraries.
  338. * staging/ is a symlink to the target toolchain sysroot inside host
  339. /, which exists for backwards compatibility.
  340. * target/ which contains almost the complete root filesystem for
  341. the target: everything needed is present except the device files
  342. in /dev/ (Buildroot can’t create them because Buildroot doesn’t
  343. run as root and doesn’t want to run as root). Also, it doesn’t
  344. have the correct permissions (e.g. setuid for the busybox
  345. binary). Therefore, this directory should not be used on your
  346. target. Instead, you should use one of the images built in the
  347. images/ directory. If you need an extracted image of the root
  348. filesystem for booting over NFS, then use the tarball image
  349. generated in images/ and extract it as root. Compared to staging
  350. /, target/ contains only the files and libraries needed to run
  351. the selected target applications: the development files (headers,
  352. etc.) are not present, the binaries are stripped.
  353. These commands, make menuconfig|nconfig|gconfig|xconfig and make, are
  354. the basic ones that allow to easily and quickly generate images
  355. fitting your needs, with all the features and applications you
  356. enabled.
  357. More details about the "make" command usage are given in Section 8.1,
  358. “make tips”.
  359. Chapter 5. Community resources
  360. Like any open source project, Buildroot has different ways to share
  361. information in its community and outside.
  362. Each of those ways may interest you if you are looking for some help,
  363. want to understand Buildroot or contribute to the project.
  364. Mailing List
  365. Buildroot has a mailing list for discussion and development. It
  366. is the main method of interaction for Buildroot users and
  367. developers.
  368. Only subscribers to the Buildroot mailing list are allowed to
  369. post to this list. You can subscribe via the mailing list info
  370. page [http://lists.buildroot.org/mailman/listinfo/buildroot].
  371. Mails that are sent to the mailing list are also available in the
  372. mailing list archives, available through Mailman [http://
  373. lists.buildroot.org/pipermail/buildroot] or at lore.kernel.org
  374. [https://lore.kernel.org/buildroot/].
  375. IRC
  376. The Buildroot IRC channel #buildroot [irc://irc.oftc.net/#
  377. buildroot] is hosted on OFTC [https://www.oftc.net/WebChat/]. It
  378. is a useful place to ask quick questions or discuss on certain
  379. topics.
  380. When asking for help on IRC, share relevant logs or pieces of
  381. code using a code sharing website, such as https://paste.ack.tf/.
  382. Note that for certain questions, posting to the mailing list may
  383. be better as it will reach more people, both developers and
  384. users.
  385. Bug tracker
  386. Bugs in Buildroot can be reported via the mailing list or
  387. alternatively via the Buildroot bugtracker [https://
  388. bugs.buildroot.org/buglist.cgi?product=buildroot]. Please refer
  389. to Section 22.6, “Reporting issues/bugs or getting help” before
  390. creating a bug report.
  391. Wiki
  392. The Buildroot wiki page [http://elinux.org/Buildroot] is hosted
  393. on the eLinux [http://elinux.org] wiki. It contains some useful
  394. links, an overview of past and upcoming events, and a TODO list.
  395. Patchwork
  396. Patchwork is a web-based patch tracking system designed to
  397. facilitate the contribution and management of contributions to an
  398. open-source project. Patches that have been sent to a mailing
  399. list are 'caught' by the system, and appear on a web page. Any
  400. comments posted that reference the patch are appended to the
  401. patch page too. For more information on Patchwork see http://
  402. jk.ozlabs.org/projects/patchwork/.
  403. Buildroot’s Patchwork website is mainly for use by Buildroot’s
  404. maintainer to ensure patches aren’t missed. It is also used by
  405. Buildroot patch reviewers (see also Section 22.3.1, “Applying
  406. Patches from Patchwork”). However, since the website exposes
  407. patches and their corresponding review comments in a clean and
  408. concise web interface, it can be useful for all Buildroot
  409. developers.
  410. The Buildroot patch management interface is available at https://
  411. patchwork.ozlabs.org/project/buildroot/list/.
  412. Part II. User guide
  413. Table of Contents
  414. 6. Buildroot configuration
  415. 6.1. Cross-compilation toolchain
  416. 6.2. /dev management
  417. 6.3. init system
  418. 7. Configuration of other components
  419. 8. General Buildroot usage
  420. 8.1. make tips
  421. 8.2. Understanding when a full rebuild is necessary
  422. 8.3. Understanding how to rebuild packages
  423. 8.4. Offline builds
  424. 8.5. Building out-of-tree
  425. 8.6. Environment variables
  426. 8.7. Dealing efficiently with filesystem images
  427. 8.8. Details about packages
  428. 8.9. Graphing the dependencies between packages
  429. 8.10. Graphing the build duration
  430. 8.11. Graphing the filesystem size contribution of packages
  431. 8.12. Top-level parallel build
  432. 8.13. Advanced usage
  433. 9. Project-specific customization
  434. 9.1. Recommended directory structure
  435. 9.2. Keeping customizations outside of Buildroot
  436. 9.3. Storing the Buildroot configuration
  437. 9.4. Storing the configuration of other components
  438. 9.5. Customizing the generated target filesystem
  439. 9.6. Adding custom user accounts
  440. 9.7. Customization after the images have been created
  441. 9.8. Adding project-specific patches and hashes
  442. 9.9. Adding project-specific packages
  443. 9.10. Quick guide to storing your project-specific customizations
  444. 10. Integration topics
  445. 10.1. Systemd
  446. 10.2. Using SELinux in Buildroot
  447. 11. Frequently Asked Questions & Troubleshooting
  448. 11.1. The boot hangs after Starting network…
  449. 11.2. Why is there no compiler on the target?
  450. 11.3. Why are there no development files on the target?
  451. 11.4. Why is there no documentation on the target?
  452. 11.5. Why are some packages not visible in the Buildroot config
  453. menu?
  454. 11.6. Why not use the target directory as a chroot directory?
  455. 11.7. Why doesn’t Buildroot generate binary packages (.deb,
  456. .ipkg…)?
  457. 11.8. How to speed-up the build process?
  458. 11.9. How does Buildroot support Y2038?
  459. 12. Known issues
  460. 13. Legal notice and licensing
  461. 13.1. Complying with open source licenses
  462. 13.2. Complying with the Buildroot license
  463. 14. Beyond Buildroot
  464. 14.1. Boot the generated images
  465. 14.2. Chroot
  466. Chapter 6. Buildroot configuration
  467. All the configuration options in make *config have a help text
  468. providing details about the option.
  469. The make *config commands also offer a search tool. Read the help
  470. message in the different frontend menus to know how to use it:
  471. * in menuconfig, the search tool is called by pressing /;
  472. * in xconfig, the search tool is called by pressing Ctrl + f.
  473. The result of the search shows the help message of the matching
  474. items. In menuconfig, numbers in the left column provide a shortcut
  475. to the corresponding entry. Just type this number to directly jump to
  476. the entry, or to the containing menu in case the entry is not
  477. selectable due to a missing dependency.
  478. Although the menu structure and the help text of the entries should
  479. be sufficiently self-explanatory, a number of topics require
  480. additional explanation that cannot easily be covered in the help text
  481. and are therefore covered in the following sections.
  482. 6.1. Cross-compilation toolchain
  483. A compilation toolchain is the set of tools that allows you to
  484. compile code for your system. It consists of a compiler (in our case,
  485. gcc), binary utils like assembler and linker (in our case, binutils)
  486. and a C standard library (for example GNU Libc [http://www.gnu.org/
  487. software/libc/libc.html], uClibc-ng [http://www.uclibc-ng.org/]).
  488. The system installed on your development station certainly already
  489. has a compilation toolchain that you can use to compile an
  490. application that runs on your system. If you’re using a PC, your
  491. compilation toolchain runs on an x86 processor and generates code for
  492. an x86 processor. Under most Linux systems, the compilation toolchain
  493. uses the GNU libc (glibc) as the C standard library. This compilation
  494. toolchain is called the "host compilation toolchain". The machine on
  495. which it is running, and on which you’re working, is called the "host
  496. system" ^[3].
  497. The compilation toolchain is provided by your distribution, and
  498. Buildroot has nothing to do with it (other than using it to build a
  499. cross-compilation toolchain and other tools that are run on the
  500. development host).
  501. As said above, the compilation toolchain that comes with your system
  502. runs on and generates code for the processor in your host system. As
  503. your embedded system has a different processor, you need a
  504. cross-compilation toolchain - a compilation toolchain that runs on
  505. your host system but generates code for your target system (and
  506. target processor). For example, if your host system uses x86 and your
  507. target system uses ARM, the regular compilation toolchain on your
  508. host runs on x86 and generates code for x86, while the
  509. cross-compilation toolchain runs on x86 and generates code for ARM.
  510. Buildroot provides two solutions for the cross-compilation toolchain:
  511. * The internal toolchain backend, called Buildroot toolchain in the
  512. configuration interface.
  513. * The external toolchain backend, called External toolchain in the
  514. configuration interface.
  515. The choice between these two solutions is done using the Toolchain
  516. Type option in the Toolchain menu. Once one solution has been chosen,
  517. a number of configuration options appear, they are detailed in the
  518. following sections.
  519. 6.1.1. Internal toolchain backend
  520. The internal toolchain backend is the backend where Buildroot builds
  521. by itself a cross-compilation toolchain, before building the
  522. userspace applications and libraries for your target embedded system.
  523. This backend supports several C libraries: uClibc-ng [http://
  524. www.uclibc-ng.org], glibc [http://www.gnu.org/software/libc/
  525. libc.html] and musl [http://www.musl-libc.org].
  526. Once you have selected this backend, a number of options appear. The
  527. most important ones allow to:
  528. * Change the version of the Linux kernel headers used to build the
  529. toolchain. This item deserves a few explanations. In the process
  530. of building a cross-compilation toolchain, the C library is being
  531. built. This library provides the interface between userspace
  532. applications and the Linux kernel. In order to know how to "talk"
  533. to the Linux kernel, the C library needs to have access to the
  534. Linux kernel headers (i.e. the .h files from the kernel), which
  535. define the interface between userspace and the kernel (system
  536. calls, data structures, etc.). Since this interface is backward
  537. compatible, the version of the Linux kernel headers used to build
  538. your toolchain do not need to match exactly the version of the
  539. Linux kernel you intend to run on your embedded system. They only
  540. need to have a version equal or older to the version of the Linux
  541. kernel you intend to run. If you use kernel headers that are more
  542. recent than the Linux kernel you run on your embedded system,
  543. then the C library might be using interfaces that are not
  544. provided by your Linux kernel.
  545. * Change the version of the GCC compiler, binutils and the C
  546. library.
  547. * Select a number of toolchain options (uClibc only): whether the
  548. toolchain should have RPC support (used mainly for NFS),
  549. wide-char support, locale support (for internationalization), C++
  550. support or thread support. Depending on which options you choose,
  551. the number of userspace applications and libraries visible in
  552. Buildroot menus will change: many applications and libraries
  553. require certain toolchain options to be enabled. Most packages
  554. show a comment when a certain toolchain option is required to be
  555. able to enable those packages. If needed, you can further refine
  556. the uClibc configuration by running make uclibc-menuconfig. Note
  557. however that all packages in Buildroot are tested against the
  558. default uClibc configuration bundled in Buildroot: if you deviate
  559. from this configuration by removing features from uClibc, some
  560. packages may no longer build.
  561. It is worth noting that whenever one of those options is modified,
  562. then the entire toolchain and system must be rebuilt. See
  563. Section 8.2, “Understanding when a full rebuild is necessary”.
  564. Advantages of this backend:
  565. * Well integrated with Buildroot
  566. * Fast, only builds what’s necessary
  567. Drawbacks of this backend:
  568. * Rebuilding the toolchain is needed when doing make clean, which
  569. takes time. If you’re trying to reduce your build time, consider
  570. using the External toolchain backend.
  571. 6.1.2. External toolchain backend
  572. The external toolchain backend allows to use existing pre-built
  573. cross-compilation toolchains. Buildroot knows about a number of
  574. well-known cross-compilation toolchains (from Linaro [http://
  575. www.linaro.org] for ARM, Sourcery CodeBench [http://www.mentor.com/
  576. embedded-software/sourcery-tools/sourcery-codebench/editions/
  577. lite-edition/] for ARM, x86-64, PowerPC, and MIPS, and is capable of
  578. downloading them automatically, or it can be pointed to a custom
  579. toolchain, either available for download or installed locally.
  580. Then, you have three solutions to use an external toolchain:
  581. * Use a predefined external toolchain profile, and let Buildroot
  582. download, extract and install the toolchain. Buildroot already
  583. knows about a few CodeSourcery and Linaro toolchains. Just select
  584. the toolchain profile in Toolchain from the available ones. This
  585. is definitely the easiest solution.
  586. * Use a predefined external toolchain profile, but instead of
  587. having Buildroot download and extract the toolchain, you can tell
  588. Buildroot where your toolchain is already installed on your
  589. system. Just select the toolchain profile in Toolchain through
  590. the available ones, unselect Download toolchain automatically,
  591. and fill the Toolchain path text entry with the path to your
  592. cross-compiling toolchain.
  593. * Use a completely custom external toolchain. This is particularly
  594. useful for toolchains generated using crosstool-NG or with
  595. Buildroot itself. To do this, select the Custom toolchain
  596. solution in the Toolchain list. You need to fill the Toolchain
  597. path, Toolchain prefix and External toolchain C library options.
  598. Then, you have to tell Buildroot what your external toolchain
  599. supports. If your external toolchain uses the glibc library, you
  600. only have to tell whether your toolchain supports C++ or not and
  601. whether it has built-in RPC support. If your external toolchain
  602. uses the uClibc library, then you have to tell Buildroot if it
  603. supports RPC, wide-char, locale, program invocation, threads and
  604. C++. At the beginning of the execution, Buildroot will tell you
  605. if the selected options do not match the toolchain configuration.
  606. Our external toolchain support has been tested with toolchains from
  607. CodeSourcery and Linaro, toolchains generated by crosstool-NG [http:/
  608. /crosstool-ng.org], and toolchains generated by Buildroot itself. In
  609. general, all toolchains that support the sysroot feature should work.
  610. If not, do not hesitate to contact the developers.
  611. We do not support toolchains or SDK generated by OpenEmbedded or
  612. Yocto, because these toolchains are not pure toolchains (i.e. just
  613. the compiler, binutils, the C and C++ libraries). Instead these
  614. toolchains come with a very large set of pre-compiled libraries and
  615. programs. Therefore, Buildroot cannot import the sysroot of the
  616. toolchain, as it would contain hundreds of megabytes of pre-compiled
  617. libraries that are normally built by Buildroot.
  618. We also do not support using the distribution toolchain (i.e. the gcc
  619. /binutils/C library installed by your distribution) as the toolchain
  620. to build software for the target. This is because your distribution
  621. toolchain is not a "pure" toolchain (i.e. only with the C/C++
  622. library), so we cannot import it properly into the Buildroot build
  623. environment. So even if you are building a system for a x86 or x86_64
  624. target, you have to generate a cross-compilation toolchain with
  625. Buildroot or crosstool-NG.
  626. If you want to generate a custom toolchain for your project, that can
  627. be used as an external toolchain in Buildroot, our recommendation is
  628. to build it either with Buildroot itself (see Section 6.1.3, “Build
  629. an external toolchain with Buildroot”) or with crosstool-NG [http://
  630. crosstool-ng.org].
  631. Advantages of this backend:
  632. * Allows to use well-known and well-tested cross-compilation
  633. toolchains.
  634. * Avoids the build time of the cross-compilation toolchain, which
  635. is often very significant in the overall build time of an
  636. embedded Linux system.
  637. Drawbacks of this backend:
  638. * If your pre-built external toolchain has a bug, may be hard to
  639. get a fix from the toolchain vendor, unless you build your
  640. external toolchain by yourself using Buildroot or Crosstool-NG.
  641. 6.1.3. Build an external toolchain with Buildroot
  642. The Buildroot internal toolchain option can be used to create an
  643. external toolchain. Here are a series of steps to build an internal
  644. toolchain and package it up for reuse by Buildroot itself (or other
  645. projects).
  646. Create a new Buildroot configuration, with the following details:
  647. * Select the appropriate Target options for your target CPU
  648. architecture
  649. * In the Toolchain menu, keep the default of Buildroot toolchain
  650. for Toolchain type, and configure your toolchain as desired
  651. * In the System configuration menu, select None as the Init system
  652. and none as /bin/sh
  653. * In the Target packages menu, disable BusyBox
  654. * In the Filesystem images menu, disable tar the root filesystem
  655. Then, we can trigger the build, and also ask Buildroot to generate a
  656. SDK. This will conveniently generate for us a tarball which contains
  657. our toolchain:
  658. make sdk
  659. This produces the SDK tarball in $(O)/images, with a name similar to
  660. arm-buildroot-linux-uclibcgnueabi_sdk-buildroot.tar.gz. Save this
  661. tarball, as it is now the toolchain that you can re-use as an
  662. external toolchain in other Buildroot projects.
  663. In those other Buildroot projects, in the Toolchain menu:
  664. * Set Toolchain type to External toolchain
  665. * Set Toolchain to Custom toolchain
  666. * Set Toolchain origin to Toolchain to be downloaded and installed
  667. * Set Toolchain URL to file:///path/to/your/sdk/tarball.tar.gz
  668. 6.1.3.1. External toolchain wrapper
  669. When using an external toolchain, Buildroot generates a wrapper
  670. program, that transparently passes the appropriate options (according
  671. to the configuration) to the external toolchain programs. In case you
  672. need to debug this wrapper to check exactly what arguments are
  673. passed, you can set the environment variable BR2_DEBUG_WRAPPER to
  674. either one of:
  675. * 0, empty or not set: no debug
  676. * 1: trace all arguments on a single line
  677. * 2: trace one argument per line
  678. 6.2. /dev management
  679. On a Linux system, the /dev directory contains special files, called
  680. device files, that allow userspace applications to access the
  681. hardware devices managed by the Linux kernel. Without these device
  682. files, your userspace applications would not be able to use the
  683. hardware devices, even if they are properly recognized by the Linux
  684. kernel.
  685. Under System configuration, /dev management, Buildroot offers four
  686. different solutions to handle the /dev directory :
  687. * The first solution is Static using device table. This is the old
  688. classical way of handling device files in Linux. With this
  689. method, the device files are persistently stored in the root
  690. filesystem (i.e. they persist across reboots), and there is
  691. nothing that will automatically create and remove those device
  692. files when hardware devices are added or removed from the system.
  693. Buildroot therefore creates a standard set of device files using
  694. a device table, the default one being stored in system/
  695. device_table_dev.txt in the Buildroot source code. This file is
  696. processed when Buildroot generates the final root filesystem
  697. image, and the device files are therefore not visible in the
  698. output/target directory. The BR2_ROOTFS_STATIC_DEVICE_TABLE
  699. option allows to change the default device table used by
  700. Buildroot, or to add an additional device table, so that
  701. additional device files are created by Buildroot during the
  702. build. So, if you use this method, and a device file is missing
  703. in your system, you can for example create a board/<yourcompany>/
  704. <yourproject>/device_table_dev.txt file that contains the
  705. description of your additional device files, and then you can set
  706. BR2_ROOTFS_STATIC_DEVICE_TABLE to system/device_table_dev.txt
  707. board/<yourcompany>/<yourproject>/device_table_dev.txt. For more
  708. details about the format of the device table file, see
  709. Chapter 25, Makedev syntax documentation.
  710. * The second solution is Dynamic using devtmpfs only. devtmpfs is a
  711. virtual filesystem inside the Linux kernel that has been
  712. introduced in kernel 2.6.32 (if you use an older kernel, it is
  713. not possible to use this option). When mounted in /dev, this
  714. virtual filesystem will automatically make device files appear
  715. and disappear as hardware devices are added and removed from the
  716. system. This filesystem is not persistent across reboots: it is
  717. filled dynamically by the kernel. Using devtmpfs requires the
  718. following kernel configuration options to be enabled:
  719. CONFIG_DEVTMPFS and CONFIG_DEVTMPFS_MOUNT. When Buildroot is in
  720. charge of building the Linux kernel for your embedded device, it
  721. makes sure that those two options are enabled. However, if you
  722. build your Linux kernel outside of Buildroot, then it is your
  723. responsibility to enable those two options (if you fail to do so,
  724. your Buildroot system will not boot).
  725. * The third solution is Dynamic using devtmpfs + mdev. This method
  726. also relies on the devtmpfs virtual filesystem detailed above (so
  727. the requirement to have CONFIG_DEVTMPFS and CONFIG_DEVTMPFS_MOUNT
  728. enabled in the kernel configuration still apply), but adds the
  729. mdev userspace utility on top of it. mdev is a program part of
  730. BusyBox that the kernel will call every time a device is added or
  731. removed. Thanks to the /etc/mdev.conf configuration file, mdev
  732. can be configured to for example, set specific permissions or
  733. ownership on a device file, call a script or application whenever
  734. a device appears or disappear, etc. Basically, it allows
  735. userspace to react on device addition and removal events. mdev
  736. can for example be used to automatically load kernel modules when
  737. devices appear on the system. mdev is also important if you have
  738. devices that require a firmware, as it will be responsible for
  739. pushing the firmware contents to the kernel. mdev is a
  740. lightweight implementation (with fewer features) of udev. For
  741. more details about mdev and the syntax of its configuration file,
  742. see http://git.busybox.net/busybox/tree/docs/mdev.txt.
  743. * The fourth solution is Dynamic using devtmpfs + eudev. This
  744. method also relies on the devtmpfs virtual filesystem detailed
  745. above, but adds the eudev userspace daemon on top of it. eudev is
  746. a daemon that runs in the background, and gets called by the
  747. kernel when a device gets added or removed from the system. It is
  748. a more heavyweight solution than mdev, but provides higher
  749. flexibility. eudev is a standalone version of udev, the original
  750. userspace daemon used in most desktop Linux distributions, which
  751. is now part of Systemd. For more details, see http://
  752. en.wikipedia.org/wiki/Udev.
  753. The Buildroot developers recommendation is to start with the Dynamic
  754. using devtmpfs only solution, until you have the need for userspace
  755. to be notified when devices are added/removed, or if firmwares are
  756. needed, in which case Dynamic using devtmpfs + mdev is usually a good
  757. solution.
  758. Note that if systemd is chosen as init system, /dev management will
  759. be performed by the udev program provided by systemd.
  760. 6.3. init system
  761. The init program is the first userspace program started by the kernel
  762. (it carries the PID number 1), and is responsible for starting the
  763. userspace services and programs (for example: web server, graphical
  764. applications, other network servers, etc.).
  765. Buildroot allows to use three different types of init systems, which
  766. can be chosen from System configuration, Init system:
  767. * The first solution is BusyBox. Amongst many programs, BusyBox has
  768. an implementation of a basic init program, which is sufficient
  769. for most embedded systems. Enabling the BR2_INIT_BUSYBOX will
  770. ensure BusyBox will build and install its init program. This is
  771. the default solution in Buildroot. The BusyBox init program will
  772. read the /etc/inittab file at boot to know what to do. The syntax
  773. of this file can be found in http://git.busybox.net/busybox/tree/
  774. examples/inittab (note that BusyBox inittab syntax is special: do
  775. not use a random inittab documentation from the Internet to learn
  776. about BusyBox inittab). The default inittab in Buildroot is
  777. stored in package/busybox/inittab. Apart from mounting a few
  778. important filesystems, the main job the default inittab does is
  779. to start the /etc/init.d/rcS shell script, and start a getty
  780. program (which provides a login prompt).
  781. * The second solution is systemV. This solution uses the old
  782. traditional sysvinit program, packed in Buildroot in package/
  783. sysvinit. This was the solution used in most desktop Linux
  784. distributions, until they switched to more recent alternatives
  785. such as Upstart or Systemd. sysvinit also works with an inittab
  786. file (which has a slightly different syntax than the one from
  787. BusyBox). The default inittab installed with this init solution
  788. is located in package/sysvinit/inittab.
  789. * The third solution is systemd. systemd is the new generation init
  790. system for Linux. It does far more than traditional init
  791. programs: aggressive parallelization capabilities, uses socket
  792. and D-Bus activation for starting services, offers on-demand
  793. starting of daemons, keeps track of processes using Linux control
  794. groups, supports snapshotting and restoring of the system state,
  795. etc. systemd will be useful on relatively complex embedded
  796. systems, for example the ones requiring D-Bus and services
  797. communicating between each other. It is worth noting that systemd
  798. brings a fairly big number of large dependencies: dbus, udev and
  799. more. For more details about systemd, see http://
  800. www.freedesktop.org/wiki/Software/systemd.
  801. The solution recommended by Buildroot developers is to use the
  802. BusyBox init as it is sufficient for most embedded systems. systemd
  803. can be used for more complex situations.
  804. ---------------------------------------------------------------------
  805. ^[3] This terminology differs from what is used by GNU configure,
  806. where the host is the machine on which the application will run
  807. (which is usually the same as target)
  808. Chapter 7. Configuration of other components
  809. Before attempting to modify any of the components below, make sure
  810. you have already configured Buildroot itself, and have enabled the
  811. corresponding package.
  812. BusyBox
  813. If you already have a BusyBox configuration file, you can
  814. directly specify this file in the Buildroot configuration, using
  815. BR2_PACKAGE_BUSYBOX_CONFIG. Otherwise, Buildroot will start from
  816. a default BusyBox configuration file.
  817. To make subsequent changes to the configuration, use make
  818. busybox-menuconfig to open the BusyBox configuration editor.
  819. It is also possible to specify a BusyBox configuration file
  820. through an environment variable, although this is not
  821. recommended. Refer to Section 8.6, “Environment variables” for
  822. more details.
  823. uClibc
  824. Configuration of uClibc is done in the same way as for BusyBox.
  825. The configuration variable to specify an existing configuration
  826. file is BR2_UCLIBC_CONFIG. The command to make subsequent changes
  827. is make uclibc-menuconfig.
  828. Linux kernel
  829. If you already have a kernel configuration file, you can directly
  830. specify this file in the Buildroot configuration, using
  831. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG.
  832. If you do not yet have a kernel configuration file, you can
  833. either start by specifying a defconfig in the Buildroot
  834. configuration, using BR2_LINUX_KERNEL_USE_DEFCONFIG, or start by
  835. creating an empty file and specifying it as custom configuration
  836. file, using BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG.
  837. To make subsequent changes to the configuration, use make
  838. linux-menuconfig to open the Linux configuration editor.
  839. Barebox
  840. Configuration of Barebox is done in the same way as for the Linux
  841. kernel. The corresponding configuration variables are
  842. BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG and
  843. BR2_TARGET_BAREBOX_USE_DEFCONFIG. To open the configuration
  844. editor, use make barebox-menuconfig.
  845. U-Boot
  846. Configuration of U-Boot (version 2015.04 or newer) is done in the
  847. same way as for the Linux kernel. The corresponding configuration
  848. variables are BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG and
  849. BR2_TARGET_UBOOT_USE_DEFCONFIG. To open the configuration editor,
  850. use make uboot-menuconfig.
  851. Chapter 8. General Buildroot usage
  852. 8.1. make tips
  853. This is a collection of tips that help you make the most of
  854. Buildroot.
  855. Display all commands executed by make: 
  856. $ make V=1 <target>
  857. Display the list of boards with a defconfig: 
  858. $ make list-defconfigs
  859. Display all available targets: 
  860. $ make help
  861. Not all targets are always available, some settings in the .config
  862. file may hide some targets:
  863. * busybox-menuconfig only works when busybox is enabled;
  864. * linux-menuconfig and linux-savedefconfig only work when linux is
  865. enabled;
  866. * uclibc-menuconfig is only available when the uClibc C library is
  867. selected in the internal toolchain backend;
  868. * barebox-menuconfig and barebox-savedefconfig only work when the
  869. barebox bootloader is enabled.
  870. * uboot-menuconfig and uboot-savedefconfig only work when the
  871. U-Boot bootloader is enabled and the uboot build system is set to
  872. Kconfig.
  873. Cleaning: Explicit cleaning is required when any of the architecture
  874. or toolchain configuration options are changed.
  875. To delete all build products (including build directories, host,
  876. staging and target trees, the images and the toolchain):
  877. $ make clean
  878. Generating the manual: The present manual sources are located in the
  879. docs/manual directory. To generate the manual:
  880. $ make manual-clean
  881. $ make manual
  882. The manual outputs will be generated in output/docs/manual.
  883. Notes
  884. * A few tools are required to build the documentation (see:
  885. Section 2.2, “Optional packages”).
  886. Resetting Buildroot for a new target: To delete all build products as
  887. well as the configuration:
  888. $ make distclean
  889. Notes. If ccache is enabled, running make clean or distclean does not
  890. empty the compiler cache used by Buildroot. To delete it, refer to
  891. Section 8.13.3, “Using ccache in Buildroot”.
  892. Dumping the internal make variables: One can dump the variables known
  893. to make, along with their values:
  894. $ make -s printvars VARS='VARIABLE1 VARIABLE2'
  895. VARIABLE1=value_of_variable
  896. VARIABLE2=value_of_variable
  897. It is possible to tweak the output using some variables:
  898. * VARS will limit the listing to variables which names match the
  899. specified make-patterns - this must be set else nothing is
  900. printed
  901. * QUOTED_VARS, if set to YES, will single-quote the value
  902. * RAW_VARS, if set to YES, will print the unexpanded value
  903. For example:
  904. $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES
  905. BUSYBOX_DEPENDENCIES=skeleton toolchain
  906. BUSYBOX_FINAL_ALL_DEPENDENCIES=skeleton toolchain
  907. BUSYBOX_FINAL_DEPENDENCIES=skeleton toolchain
  908. BUSYBOX_FINAL_PATCH_DEPENDENCIES=
  909. BUSYBOX_RDEPENDENCIES=ncurses util-linux
  910. $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES QUOTED_VARS=YES
  911. BUSYBOX_DEPENDENCIES='skeleton toolchain'
  912. BUSYBOX_FINAL_ALL_DEPENDENCIES='skeleton toolchain'
  913. BUSYBOX_FINAL_DEPENDENCIES='skeleton toolchain'
  914. BUSYBOX_FINAL_PATCH_DEPENDENCIES=''
  915. BUSYBOX_RDEPENDENCIES='ncurses util-linux'
  916. $ make -s printvars VARS=BUSYBOX_%DEPENDENCIES RAW_VARS=YES
  917. BUSYBOX_DEPENDENCIES=skeleton toolchain
  918. BUSYBOX_FINAL_ALL_DEPENDENCIES=$(sort $(BUSYBOX_FINAL_DEPENDENCIES) $(BUSYBOX_FINAL_PATCH_DEPENDENCIES))
  919. BUSYBOX_FINAL_DEPENDENCIES=$(sort $(BUSYBOX_DEPENDENCIES))
  920. BUSYBOX_FINAL_PATCH_DEPENDENCIES=$(sort $(BUSYBOX_PATCH_DEPENDENCIES))
  921. BUSYBOX_RDEPENDENCIES=ncurses util-linux
  922. The output of quoted variables can be reused in shell scripts, for
  923. example:
  924. $ eval $(make -s printvars VARS=BUSYBOX_DEPENDENCIES QUOTED_VARS=YES)
  925. $ echo $BUSYBOX_DEPENDENCIES
  926. skeleton toolchain
  927. 8.2. Understanding when a full rebuild is necessary
  928. Buildroot does not attempt to detect what parts of the system should
  929. be rebuilt when the system configuration is changed through make
  930. menuconfig, make xconfig or one of the other configuration tools. In
  931. some cases, Buildroot should rebuild the entire system, in some
  932. cases, only a specific subset of packages. But detecting this in a
  933. completely reliable manner is very difficult, and therefore the
  934. Buildroot developers have decided to simply not attempt to do this.
  935. Instead, it is the responsibility of the user to know when a full
  936. rebuild is necessary. As a hint, here are a few rules of thumb that
  937. can help you understand how to work with Buildroot:
  938. * When the target architecture configuration is changed, a complete
  939. rebuild is needed. Changing the architecture variant, the binary
  940. format or the floating point strategy for example has an impact
  941. on the entire system.
  942. * When the toolchain configuration is changed, a complete rebuild
  943. generally is needed. Changing the toolchain configuration often
  944. involves changing the compiler version, the type of C library or
  945. its configuration, or some other fundamental configuration item,
  946. and these changes have an impact on the entire system.
  947. * When an additional package is added to the configuration, a full
  948. rebuild is not necessarily needed. Buildroot will detect that
  949. this package has never been built, and will build it. However, if
  950. this package is a library that can optionally be used by packages
  951. that have already been built, Buildroot will not automatically
  952. rebuild those. Either you know which packages should be rebuilt,
  953. and you can rebuild them manually, or you should do a full
  954. rebuild. For example, let’s suppose you have built a system with
  955. the ctorrent package, but without openssl. Your system works, but
  956. you realize you would like to have SSL support in ctorrent, so
  957. you enable the openssl package in Buildroot configuration and
  958. restart the build. Buildroot will detect that openssl should be
  959. built and will be build it, but it will not detect that ctorrent
  960. should be rebuilt to benefit from openssl to add OpenSSL support.
  961. You will either have to do a full rebuild, or rebuild ctorrent
  962. itself.
  963. * When a package is removed from the configuration, Buildroot does
  964. not do anything special. It does not remove the files installed
  965. by this package from the target root filesystem or from the
  966. toolchain sysroot. A full rebuild is needed to get rid of this
  967. package. However, generally you don’t necessarily need this
  968. package to be removed right now: you can wait for the next lunch
  969. break to restart the build from scratch.
  970. * When the sub-options of a package are changed, the package is not
  971. automatically rebuilt. After making such changes, rebuilding only
  972. this package is often sufficient, unless enabling the package
  973. sub-option adds some features to the package that are useful for
  974. another package which has already been built. Again, Buildroot
  975. does not track when a package should be rebuilt: once a package
  976. has been built, it is never rebuilt unless explicitly told to do
  977. so.
  978. * When a change to the root filesystem skeleton is made, a full
  979. rebuild is needed. However, when changes to the root filesystem
  980. overlay, a post-build script or a post-image script are made,
  981. there is no need for a full rebuild: a simple make invocation
  982. will take the changes into account.
  983. * When a package listed in FOO_DEPENDENCIES is rebuilt or removed,
  984. the package foo is not automatically rebuilt. For example, if a
  985. package bar is listed in FOO_DEPENDENCIES with FOO_DEPENDENCIES =
  986. bar and the configuration of the bar package is changed, the
  987. configuration change would not result in a rebuild of package foo
  988. automatically. In this scenario, you may need to either rebuild
  989. any packages in your build which reference bar in their
  990. DEPENDENCIES, or perform a full rebuild to ensure any bar
  991. dependent packages are up to date.
  992. Generally speaking, when you’re facing a build error and you’re
  993. unsure of the potential consequences of the configuration changes
  994. you’ve made, do a full rebuild. If you get the same build error, then
  995. you are sure that the error is not related to partial rebuilds of
  996. packages, and if this error occurs with packages from the official
  997. Buildroot, do not hesitate to report the problem! As your experience
  998. with Buildroot progresses, you will progressively learn when a full
  999. rebuild is really necessary, and you will save more and more time.
  1000. For reference, a full rebuild is achieved by running:
  1001. $ make clean all
  1002. 8.3. Understanding how to rebuild packages
  1003. One of the most common questions asked by Buildroot users is how to
  1004. rebuild a given package or how to remove a package without rebuilding
  1005. everything from scratch.
  1006. Removing a package is unsupported by Buildroot without rebuilding
  1007. from scratch. This is because Buildroot doesn’t keep track of which
  1008. package installs what files in the output/staging and output/target
  1009. directories, or which package would be compiled differently depending
  1010. on the availability of another package.
  1011. The easiest way to rebuild a single package from scratch is to remove
  1012. its build directory in output/build. Buildroot will then re-extract,
  1013. re-configure, re-compile and re-install this package from scratch.
  1014. You can ask buildroot to do this with the make <package>-dirclean
  1015. command.
  1016. On the other hand, if you only want to restart the build process of a
  1017. package from its compilation step, you can run make <package>
  1018. -rebuild. It will restart the compilation and installation of the
  1019. package, but not from scratch: it basically re-executes make and make
  1020. install inside the package, so it will only rebuild files that
  1021. changed.
  1022. If you want to restart the build process of a package from its
  1023. configuration step, you can run make <package>-reconfigure. It will
  1024. restart the configuration, compilation and installation of the
  1025. package.
  1026. While <package>-rebuild implies <package>-reinstall and <package>
  1027. -reconfigure implies <package>-rebuild, these targets as well as
  1028. <package> only act on the said package, and do not trigger
  1029. re-creating the root filesystem image. If re-creating the root
  1030. filesystem in necessary, one should in addition run make or make all.
  1031. Internally, Buildroot creates so-called stamp files to keep track of
  1032. which build steps have been completed for each package. They are
  1033. stored in the package build directory, output/build/<package>-
  1034. <version>/ and are named .stamp_<step-name>. The commands detailed
  1035. above simply manipulate these stamp files to force Buildroot to
  1036. restart a specific set of steps of a package build process.
  1037. Further details about package special make targets are explained in
  1038. Section 8.13.5, “Package-specific make targets”.
  1039. 8.4. Offline builds
  1040. If you intend to do an offline build and just want to download all
  1041. sources that you previously selected in the configurator (menuconfig,
  1042. nconfig, xconfig or gconfig), then issue:
  1043. $ make source
  1044. You can now disconnect or copy the content of your dl directory to
  1045. the build-host.
  1046. 8.5. Building out-of-tree
  1047. As default, everything built by Buildroot is stored in the directory
  1048. output in the Buildroot tree.
  1049. Buildroot also supports building out of tree with a syntax similar to
  1050. the Linux kernel. To use it, add O=<directory> to the make command
  1051. line:
  1052. $ make O=/tmp/build menuconfig
  1053. Or:
  1054. $ cd /tmp/build; make O=$PWD -C path/to/buildroot menuconfig
  1055. All the output files will be located under /tmp/build. If the O path
  1056. does not exist, Buildroot will create it.
  1057. Note: the O path can be either an absolute or a relative path, but if
  1058. it’s passed as a relative path, it is important to note that it is
  1059. interpreted relative to the main Buildroot source directory, not the
  1060. current working directory.
  1061. When using out-of-tree builds, the Buildroot .config and temporary
  1062. files are also stored in the output directory. This means that you
  1063. can safely run multiple builds in parallel using the same source tree
  1064. as long as they use unique output directories.
  1065. For ease of use, Buildroot generates a Makefile wrapper in the output
  1066. directory - so after the first run, you no longer need to pass O=<…>
  1067. and -C <…>, simply run (in the output directory):
  1068. $ make <target>
  1069. 8.6. Environment variables
  1070. Buildroot also honors some environment variables, when they are
  1071. passed to make or set in the environment:
  1072. * HOSTCXX, the host C++ compiler to use
  1073. * HOSTCC, the host C compiler to use
  1074. * UCLIBC_CONFIG_FILE=<path/to/.config>, path to the uClibc
  1075. configuration file, used to compile uClibc, if an internal
  1076. toolchain is being built. Note that the uClibc configuration file
  1077. can also be set from the configuration interface, so through the
  1078. Buildroot .config file; this is the recommended way of setting
  1079. it.
  1080. * BUSYBOX_CONFIG_FILE=<path/to/.config>, path to the BusyBox
  1081. configuration file. Note that the BusyBox configuration file can
  1082. also be set from the configuration interface, so through the
  1083. Buildroot .config file; this is the recommended way of setting
  1084. it.
  1085. * BR2_CCACHE_DIR to override the directory where Buildroot stores
  1086. the cached files when using ccache.
  1087. * BR2_DL_DIR to override the directory in which Buildroot stores/
  1088. retrieves downloaded files. Note that the Buildroot download
  1089. directory can also be set from the configuration interface, so
  1090. through the Buildroot .config file. See Section 8.13.4, “Location
  1091. of downloaded packages” for more details on how you can set the
  1092. download directory.
  1093. * BR2_GRAPH_ALT, if set and non-empty, to use an alternate
  1094. color-scheme in build-time graphs
  1095. * BR2_GRAPH_OUT to set the filetype of generated graphs, either pdf
  1096. (the default), or png.
  1097. * BR2_GRAPH_DEPS_OPTS to pass extra options to the dependency
  1098. graph; see Section 8.9, “Graphing the dependencies between
  1099. packages” for the accepted options
  1100. * BR2_GRAPH_DOT_OPTS is passed verbatim as options to the dot
  1101. utility to draw the dependency graph.
  1102. * BR2_GRAPH_SIZE_OPTS to pass extra options to the size graph; see
  1103. Section 8.11, “Graphing the filesystem size contribution of
  1104. packages” for the acepted options
  1105. An example that uses config files located in the toplevel directory
  1106. and in your $HOME:
  1107. $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
  1108. If you want to use a compiler other than the default gcc or g++ for
  1109. building helper-binaries on your host, then do
  1110. $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
  1111. 8.7. Dealing efficiently with filesystem images
  1112. Filesystem images can get pretty big, depending on the filesystem you
  1113. choose, the number of packages, whether you provisioned free space…
  1114. Yet, some locations in the filesystems images may just be empty (e.g.
  1115. a long run of zeroes); such a file is called a sparse file.
  1116. Most tools can handle sparse files efficiently, and will only store
  1117. or write those parts of a sparse file that are not empty.
  1118. For example:
  1119. * tar accepts the -S option to tell it to only store non-zero
  1120. blocks of sparse files:
  1121. + tar cf archive.tar -S [files…] will efficiently store sparse
  1122. files in a tarball
  1123. + tar xf archive.tar -S will efficiently store sparse files
  1124. extracted from a tarball
  1125. * cp accepts the --sparse=WHEN option (WHEN is one of auto, never
  1126. or always):
  1127. + cp --sparse=always source.file dest.file will make dest.file
  1128. a sparse file if source.file has long runs of zeroes
  1129. Other tools may have similar options. Please consult their respective
  1130. man pages.
  1131. You can use sparse files if you need to store the filesystem images
  1132. (e.g. to transfer from one machine to another), or if you need to
  1133. send them (e.g. to the Q&A team).
  1134. Note however that flashing a filesystem image to a device while using
  1135. the sparse mode of dd may result in a broken filesystem (e.g. the
  1136. block bitmap of an ext2 filesystem may be corrupted; or, if you have
  1137. sparse files in your filesystem, those parts may not be all-zeroes
  1138. when read back). You should only use sparse files when handling files
  1139. on the build machine, not when transferring them to an actual device
  1140. that will be used on the target.
  1141. 8.8. Details about packages
  1142. Buildroot can produce a JSON blurb that describes the set of enabled
  1143. packages in the current configuration, together with their
  1144. dependencies, licenses and other metadata. This JSON blurb is
  1145. produced by using the show-info make target:
  1146. make show-info
  1147. Buildroot can also produce details about packages as HTML and JSON
  1148. output using the pkg-stats make target. Amongst other things, these
  1149. details include whether known CVEs (security vulnerabilities) affect
  1150. the packages in your current configuration. It also shows if there is
  1151. a newer upstream version for those packages.
  1152. make pkg-stats
  1153. 8.9. Graphing the dependencies between packages
  1154. One of Buildroot’s jobs is to know the dependencies between packages,
  1155. and make sure they are built in the right order. These dependencies
  1156. can sometimes be quite complicated, and for a given system, it is
  1157. often not easy to understand why such or such package was brought
  1158. into the build by Buildroot.
  1159. In order to help understanding the dependencies, and therefore better
  1160. understand what is the role of the different components in your
  1161. embedded Linux system, Buildroot is capable of generating dependency
  1162. graphs.
  1163. To generate a dependency graph of the full system you have compiled,
  1164. simply run:
  1165. make graph-depends
  1166. You will find the generated graph in output/graphs/graph-depends.pdf.
  1167. If your system is quite large, the dependency graph may be too
  1168. complex and difficult to read. It is therefore possible to generate
  1169. the dependency graph just for a given package:
  1170. make <pkg>-graph-depends
  1171. You will find the generated graph in output/graph/<pkg>
  1172. -graph-depends.pdf.
  1173. Note that the dependency graphs are generated using the dot tool from
  1174. the Graphviz project, which you must have installed on your system to
  1175. use this feature. In most distributions, it is available as the
  1176. graphviz package.
  1177. By default, the dependency graphs are generated in the PDF format.
  1178. However, by passing the BR2_GRAPH_OUT environment variable, you can
  1179. switch to other output formats, such as PNG, PostScript or SVG. All
  1180. formats supported by the -T option of the dot tool are supported.
  1181. BR2_GRAPH_OUT=svg make graph-depends
  1182. The graph-depends behaviour can be controlled by setting options in
  1183. the BR2_GRAPH_DEPS_OPTS environment variable. The accepted options
  1184. are:
  1185. * --depth N, -d N, to limit the dependency depth to N levels. The
  1186. default, 0, means no limit.
  1187. * --stop-on PKG, -s PKG, to stop the graph on the package PKG. PKG
  1188. can be an actual package name, a glob, the keyword virtual (to
  1189. stop on virtual packages), or the keyword host (to stop on host
  1190. packages). The package is still present on the graph, but its
  1191. dependencies are not.
  1192. * --exclude PKG, -x PKG, like --stop-on, but also omits PKG from
  1193. the graph.
  1194. * --transitive, --no-transitive, to draw (or not) the transitive
  1195. dependencies. The default is to not draw transitive dependencies.
  1196. * --colors R,T,H, the comma-separated list of colors to draw the
  1197. root package (R), the target packages (T) and the host packages
  1198. (H). Defaults to: lightblue,grey,gainsboro
  1199. BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colors=red,green,blue' make graph-depends
  1200. 8.10. Graphing the build duration
  1201. When the build of a system takes a long time, it is sometimes useful
  1202. to be able to understand which packages are the longest to build, to
  1203. see if anything can be done to speed up the build. In order to help
  1204. such build time analysis, Buildroot collects the build time of each
  1205. step of each package, and allows to generate graphs from this data.
  1206. To generate the build time graph after a build, run:
  1207. make graph-build
  1208. This will generate a set of files in output/graphs :
  1209. * build.hist-build.pdf, a histogram of the build time for each
  1210. package, ordered in the build order.
  1211. * build.hist-duration.pdf, a histogram of the build time for each
  1212. package, ordered by duration (longest first)
  1213. * build.hist-name.pdf, a histogram of the build time for each
  1214. package, order by package name.
  1215. * build.pie-packages.pdf, a pie chart of the build time per package
  1216. * build.pie-steps.pdf, a pie chart of the global time spent in each
  1217. step of the packages build process.
  1218. This graph-build target requires the Python Matplotlib and Numpy
  1219. libraries to be installed (python-matplotlib and python-numpy on most
  1220. distributions), and also the argparse module if you’re using a Python
  1221. version older than 2.7 (python-argparse on most distributions).
  1222. By default, the output format for the graph is PDF, but a different
  1223. format can be selected using the BR2_GRAPH_OUT environment variable.
  1224. The only other format supported is PNG:
  1225. BR2_GRAPH_OUT=png make graph-build
  1226. 8.11. Graphing the filesystem size contribution of packages
  1227. When your target system grows, it is sometimes useful to understand
  1228. how much each Buildroot package is contributing to the overall root
  1229. filesystem size. To help with such an analysis, Buildroot collects
  1230. data about files installed by each package and using this data,
  1231. generates a graph and CSV files detailing the size contribution of
  1232. the different packages.
  1233. To generate these data after a build, run:
  1234. make graph-size
  1235. This will generate:
  1236. * output/graphs/graph-size.pdf, a pie chart of the contribution of
  1237. each package to the overall root filesystem size
  1238. * output/graphs/package-size-stats.csv, a CSV file giving the size
  1239. contribution of each package to the overall root filesystem size
  1240. * output/graphs/file-size-stats.csv, a CSV file giving the size
  1241. contribution of each installed file to the package it belongs,
  1242. and to the overall filesystem size.
  1243. This graph-size target requires the Python Matplotlib library to be
  1244. installed (python-matplotlib on most distributions), and also the
  1245. argparse module if you’re using a Python version older than 2.7
  1246. (python-argparse on most distributions).
  1247. Just like for the duration graph, a BR2_GRAPH_OUT environment
  1248. variable is supported to adjust the output file format. See
  1249. Section 8.9, “Graphing the dependencies between packages” for details
  1250. about this environment variable.
  1251. Additionally, one may set the environment variable
  1252. BR2_GRAPH_SIZE_OPTS to further control the generated graph. Accepted
  1253. options are:
  1254. * --size-limit X, -l X, will group all packages which individual
  1255. contribution is below X percent, to a single entry labelled
  1256. Others in the graph. By default, X=0.01, which means packages
  1257. each contributing less than 1% are grouped under Others. Accepted
  1258. values are in the range [0.0..1.0].
  1259. * --iec, --binary, --si, --decimal, to use IEC (binary, powers of
  1260. 1024) or SI (decimal, powers of 1000; the default) prefixes.
  1261. * --biggest-first, to sort packages in decreasing size order,
  1262. rather than in increasing size order.
  1263. Note. The collected filesystem size data is only meaningful after a
  1264. complete clean rebuild. Be sure to run make clean all before using
  1265. make graph-size.
  1266. To compare the root filesystem size of two different Buildroot
  1267. compilations, for example after adjusting the configuration or when
  1268. switching to another Buildroot release, use the size-stats-compare
  1269. script. It takes two file-size-stats.csv files (produced by make
  1270. graph-size) as input. Refer to the help text of this script for more
  1271. details:
  1272. utils/size-stats-compare -h
  1273. 8.12. Top-level parallel build
  1274. Note. This section deals with a very experimental feature, which is
  1275. known to break even in some non-unusual situations. Use at your own
  1276. risk.
  1277. Buildroot has always been capable of using parallel build on a per
  1278. package basis: each package is built by Buildroot using make -jN (or
  1279. the equivalent invocation for non-make-based build systems). The
  1280. level of parallelism is by default number of CPUs + 1, but it can be
  1281. adjusted using the BR2_JLEVEL configuration option.
  1282. Until 2020.02, Buildroot was however building packages in a serial
  1283. fashion: each package was built one after the other, without
  1284. parallelization of the build between packages. As of 2020.02,
  1285. Buildroot has experimental support for top-level parallel build,
  1286. which allows some signicant build time savings by building packages
  1287. that have no dependency relationship in parallel. This feature is
  1288. however marked as experimental and is known not to work in some
  1289. cases.
  1290. In order to use top-level parallel build, one must:
  1291. 1. Enable the option BR2_PER_PACKAGE_DIRECTORIES in the Buildroot
  1292. configuration
  1293. 2. Use make -jN when starting the Buildroot build
  1294. Internally, the BR2_PER_PACKAGE_DIRECTORIES will enable a mechanism
  1295. called per-package directories, which will have the following
  1296. effects:
  1297. * Instead of a global target directory and a global host directory
  1298. common to all packages, per-package target and host directories
  1299. will be used, in $(O)/per-package/<pkg>/target/ and $(O)/
  1300. per-package/<pkg>/host/ respectively. Those folders will be
  1301. populated from the corresponding folders of the package
  1302. dependencies at the beginning of <pkg> build. The compiler and
  1303. all other tools will therefore only be able to see and access
  1304. files installed by dependencies explicitly listed by <pkg>.
  1305. * At the end of the build, the global target and host directories
  1306. will be populated, located in $(O)/target and $(O)/host
  1307. respectively. This means that during the build, those folders
  1308. will be empty and it’s only at the very end of the build that
  1309. they will be populated.
  1310. 8.13. Advanced usage
  1311. 8.13.1. Using the generated toolchain outside Buildroot
  1312. You may want to compile, for your target, your own programs or other
  1313. software that are not packaged in Buildroot. In order to do this you
  1314. can use the toolchain that was generated by Buildroot.
  1315. The toolchain generated by Buildroot is located by default in output/
  1316. host/. The simplest way to use it is to add output/host/bin/ to your
  1317. PATH environment variable and then to use ARCH-linux-gcc,
  1318. ARCH-linux-objdump, ARCH-linux-ld, etc.
  1319. Alternatively, Buildroot can also export the toolchain and the
  1320. development files of all selected packages, as an SDK, by running the
  1321. command make sdk. This generates a tarball of the content of the host
  1322. directory output/host/, named <TARGET-TUPLE>_sdk-buildroot.tar.gz
  1323. (which can be overridden by setting the environment variable
  1324. BR2_SDK_PREFIX) and located in the output directory output/images/.
  1325. This tarball can then be distributed to application developers, when
  1326. they want to develop their applications that are not (yet) packaged
  1327. as a Buildroot package.
  1328. Upon extracting the SDK tarball, the user must run the script
  1329. relocate-sdk.sh (located at the top directory of the SDK), to make
  1330. sure all paths are updated with the new location.
  1331. Alternatively, if you just want to prepare the SDK without generating
  1332. the tarball (e.g. because you will just be moving the host directory,
  1333. or will be generating the tarball on your own), Buildroot also allows
  1334. you to just prepare the SDK with make prepare-sdk without actually
  1335. generating a tarball.
  1336. For your convenience, by selecting the option
  1337. BR2_PACKAGE_HOST_ENVIRONMENT_SETUP, you can get a environment-setup
  1338. script installed in output/host/ and therefore in your SDK. This
  1339. script can be sourced with . your/sdk/path/environment-setup to
  1340. export a number of environment variables that will help cross-compile
  1341. your projects using the Buildroot SDK: the PATH will contain the SDK
  1342. binaries, standard autotools variables will be defined with the
  1343. appropriate values, and CONFIGURE_FLAGS will contain basic ./
  1344. configure options to cross-compile autotools projects. It also
  1345. provides some useful commands. Note however that once this script is
  1346. sourced, the environment is setup only for cross-compilation, and no
  1347. longer for native compilation.
  1348. 8.13.2. Using gdb in Buildroot
  1349. Buildroot allows to do cross-debugging, where the debugger runs on
  1350. the build machine and communicates with gdbserver on the target to
  1351. control the execution of the program.
  1352. To achieve this:
  1353. * If you are using an internal toolchain (built by Buildroot), you
  1354. must enable BR2_PACKAGE_HOST_GDB, BR2_PACKAGE_GDB and
  1355. BR2_PACKAGE_GDB_SERVER. This ensures that both the cross gdb and
  1356. gdbserver get built, and that gdbserver gets installed to your
  1357. target.
  1358. * If you are using an external toolchain, you should enable
  1359. BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY, which will copy the
  1360. gdbserver included with the external toolchain to the target. If
  1361. your external toolchain does not have a cross gdb or gdbserver,
  1362. it is also possible to let Buildroot build them, by enabling the
  1363. same options as for the internal toolchain backend.
  1364. Now, to start debugging a program called foo, you should run on the
  1365. target:
  1366. gdbserver :2345 foo
  1367. This will cause gdbserver to listen on TCP port 2345 for a connection
  1368. from the cross gdb.
  1369. Then, on the host, you should start the cross gdb using the following
  1370. command line:
  1371. <buildroot>/output/host/bin/<tuple>-gdb -ix <buildroot>/output/staging/usr/share/buildroot/gdbinit foo
  1372. Of course, foo must be available in the current directory, built with
  1373. debugging symbols. Typically you start this command from the
  1374. directory where foo is built (and not from output/target/ as the
  1375. binaries in that directory are stripped).
  1376. The <buildroot>/output/staging/usr/share/buildroot/gdbinit file will
  1377. tell the cross gdb where to find the libraries of the target.
  1378. Finally, to connect to the target from the cross gdb:
  1379. (gdb) target remote <target ip address>:2345
  1380. 8.13.3. Using ccache in Buildroot
  1381. ccache [http://ccache.samba.org] is a compiler cache. It stores the
  1382. object files resulting from each compilation process, and is able to
  1383. skip future compilation of the same source file (with same compiler
  1384. and same arguments) by using the pre-existing object files. When
  1385. doing almost identical builds from scratch a number of times, it can
  1386. nicely speed up the build process.
  1387. ccache support is integrated in Buildroot. You just have to enable
  1388. Enable compiler cache in Build options. This will automatically build
  1389. ccache and use it for every host and target compilation.
  1390. The cache is located in the directory defined by the BR2_CCACHE_DIR
  1391. configuration option, which defaults to $HOME/.buildroot-ccache. This
  1392. default location is outside of Buildroot output directory so that it
  1393. can be shared by separate Buildroot builds. If you want to get rid of
  1394. the cache, simply remove this directory.
  1395. You can get statistics on the cache (its size, number of hits,
  1396. misses, etc.) by running make ccache-stats.
  1397. The make target ccache-options and the CCACHE_OPTIONS variable
  1398. provide more generic access to the ccache. For example
  1399. # set cache limit size
  1400. make CCACHE_OPTIONS="--max-size=5G" ccache-options
  1401. # zero statistics counters
  1402. make CCACHE_OPTIONS="--zero-stats" ccache-options
  1403. ccache makes a hash of the source files and of the compiler options.
  1404. If a compiler option is different, the cached object file will not be
  1405. used. Many compiler options, however, contain an absolute path to the
  1406. staging directory. Because of this, building in a different output
  1407. directory would lead to many cache misses.
  1408. To avoid this issue, buildroot has the Use relative paths option
  1409. (BR2_CCACHE_USE_BASEDIR). This will rewrite all absolute paths that
  1410. point inside the output directory into relative paths. Thus, changing
  1411. the output directory no longer leads to cache misses.
  1412. A disadvantage of the relative paths is that they also end up to be
  1413. relative paths in the object file. Therefore, for example, the
  1414. debugger will no longer find the file, unless you cd to the output
  1415. directory first.
  1416. See the ccache manual’s section on "Compiling in different
  1417. directories" [https://ccache.samba.org/manual.html#
  1418. _compiling_in_different_directories] for more details about this
  1419. rewriting of absolute paths.
  1420. When ccache is enabled in Buildroot using the BR2_CCACHE=y option:
  1421. * ccache is used during the Buildroot build itself
  1422. * ccache is not used when building outside of Buildroot, for
  1423. example when directly calling the cross-compiler or using the SDK
  1424. One can override this behavior using the BR2_USE_CCACHE environment
  1425. variable: when set to 1, usage of ccache is enabled (default during
  1426. the Buildroot build), when unset or set to a value different from 1,
  1427. usage of ccache is disabled.
  1428. 8.13.4. Location of downloaded packages
  1429. The various tarballs that are downloaded by Buildroot are all stored
  1430. in BR2_DL_DIR, which by default is the dl directory. If you want to
  1431. keep a complete version of Buildroot which is known to be working
  1432. with the associated tarballs, you can make a copy of this directory.
  1433. This will allow you to regenerate the toolchain and the target
  1434. filesystem with exactly the same versions.
  1435. If you maintain several Buildroot trees, it might be better to have a
  1436. shared download location. This can be achieved by pointing the
  1437. BR2_DL_DIR environment variable to a directory. If this is set, then
  1438. the value of BR2_DL_DIR in the Buildroot configuration is overridden.
  1439. The following line should be added to <~/.bashrc>.
  1440. export BR2_DL_DIR=<shared download location>
  1441. The download location can also be set in the .config file, with the
  1442. BR2_DL_DIR option. Unlike most options in the .config file, this
  1443. value is overridden by the BR2_DL_DIR environment variable.
  1444. 8.13.5. Package-specific make targets
  1445. Running make <package> builds and installs that particular package
  1446. and its dependencies.
  1447. For packages relying on the Buildroot infrastructure, there are
  1448. numerous special make targets that can be called independently like
  1449. this:
  1450. make <package>-<target>
  1451. The package build targets are (in the order they are executed):
  1452. +------------------------------------------------------------+
  1453. |command/target |Description |
  1454. |---------------+--------------------------------------------|
  1455. | source |Fetch the source (download the tarball, |
  1456. | |clone the source repository, etc) |
  1457. |---------------+--------------------------------------------|
  1458. | depends |Build and install all dependencies required |
  1459. | |to build the package |
  1460. |---------------+--------------------------------------------|
  1461. | extract |Put the source in the package build |
  1462. | |directory (extract the tarball, copy the |
  1463. | |source, etc) |
  1464. |---------------+--------------------------------------------|
  1465. | patch |Apply the patches, if any |
  1466. |---------------+--------------------------------------------|
  1467. | configure |Run the configure commands, if any |
  1468. |---------------+--------------------------------------------|
  1469. | build |Run the compilation commands |
  1470. |---------------+--------------------------------------------|
  1471. |install-staging|target package: Run the installation of the |
  1472. | |package in the staging directory, if |
  1473. | |necessary |
  1474. |---------------+--------------------------------------------|
  1475. |install-target |target package: Run the installation of the |
  1476. | |package in the target directory, if |
  1477. | |necessary |
  1478. |---------------+--------------------------------------------|
  1479. | install |target package: Run the 2 previous |
  1480. | |installation commands |
  1481. | | |
  1482. | |host package: Run the installation of the |
  1483. | |package in the host directory |
  1484. +------------------------------------------------------------+
  1485. Additionally, there are some other useful make targets:
  1486. +------------------------------------------------------------+
  1487. | command/target |Description |
  1488. |-----------------------+------------------------------------|
  1489. | show-depends |Displays the first-order |
  1490. | |dependencies required to build the |
  1491. | |package |
  1492. |-----------------------+------------------------------------|
  1493. |show-recursive-depends |Recursively displays the |
  1494. | |dependencies required to build the |
  1495. | |package |
  1496. |-----------------------+------------------------------------|
  1497. | show-rdepends |Displays the first-order reverse |
  1498. | |dependencies of the package (i.e |
  1499. | |packages that directly depend on it)|
  1500. |-----------------------+------------------------------------|
  1501. |show-recursive-rdepends|Recursively displays the reverse |
  1502. | |dependencies of the package (i.e the|
  1503. | |packages that depend on it, directly|
  1504. | |or indirectly) |
  1505. |-----------------------+------------------------------------|
  1506. | graph-depends |Generate a dependency graph of the |
  1507. | |package, in the context of the |
  1508. | |current Buildroot configuration. See|
  1509. | |this section for more details about |
  1510. | |dependency graphs. |
  1511. |-----------------------+------------------------------------|
  1512. | graph-rdepends |Generate a graph of this package |
  1513. | |reverse dependencies (i.e the |
  1514. | |packages that depend on it, directly|
  1515. | |or indirectly) |
  1516. |-----------------------+------------------------------------|
  1517. | dirclean |Remove the whole package build |
  1518. | |directory |
  1519. |-----------------------+------------------------------------|
  1520. | reinstall |Re-run the install commands |
  1521. |-----------------------+------------------------------------|
  1522. | rebuild |Re-run the compilation commands - |
  1523. | |this only makes sense when using the|
  1524. | |OVERRIDE_SRCDIR feature or when you |
  1525. | |modified a file directly in the |
  1526. | |build directory |
  1527. |-----------------------+------------------------------------|
  1528. | reconfigure |Re-run the configure commands, then |
  1529. | |rebuild - this only makes sense when|
  1530. | |using the OVERRIDE_SRCDIR feature or|
  1531. | |when you modified a file directly in|
  1532. | |the build directory |
  1533. +------------------------------------------------------------+
  1534. 8.13.6. Using Buildroot during development
  1535. The normal operation of Buildroot is to download a tarball, extract
  1536. it, configure, compile and install the software component found
  1537. inside this tarball. The source code is extracted in output/build/
  1538. <package>-<version>, which is a temporary directory: whenever make
  1539. clean is used, this directory is entirely removed, and re-created at
  1540. the next make invocation. Even when a Git or Subversion repository is
  1541. used as the input for the package source code, Buildroot creates a
  1542. tarball out of it, and then behaves as it normally does with
  1543. tarballs.
  1544. This behavior is well-suited when Buildroot is used mainly as an
  1545. integration tool, to build and integrate all the components of an
  1546. embedded Linux system. However, if one uses Buildroot during the
  1547. development of certain components of the system, this behavior is not
  1548. very convenient: one would instead like to make a small change to the
  1549. source code of one package, and be able to quickly rebuild the system
  1550. with Buildroot.
  1551. Making changes directly in output/build/<package>-<version> is not an
  1552. appropriate solution, because this directory is removed on make
  1553. clean.
  1554. Therefore, Buildroot provides a specific mechanism for this use case:
  1555. the <pkg>_OVERRIDE_SRCDIR mechanism. Buildroot reads an override
  1556. file, which allows the user to tell Buildroot the location of the
  1557. source for certain packages.
  1558. The default location of the override file is $(CONFIG_DIR)/local.mk,
  1559. as defined by the BR2_PACKAGE_OVERRIDE_FILE configuration option. $
  1560. (CONFIG_DIR) is the location of the Buildroot .config file, so
  1561. local.mk by default lives side-by-side with the .config file, which
  1562. means:
  1563. * In the top-level Buildroot source directory for in-tree builds
  1564. (i.e., when O= is not used)
  1565. * In the out-of-tree directory for out-of-tree builds (i.e., when O
  1566. = is used)
  1567. If a different location than these defaults is required, it can be
  1568. specified through the BR2_PACKAGE_OVERRIDE_FILE configuration option.
  1569. In this override file, Buildroot expects to find lines of the form:
  1570. <pkg1>_OVERRIDE_SRCDIR = /path/to/pkg1/sources
  1571. <pkg2>_OVERRIDE_SRCDIR = /path/to/pkg2/sources
  1572. For example:
  1573. LINUX_OVERRIDE_SRCDIR = /home/bob/linux/
  1574. BUSYBOX_OVERRIDE_SRCDIR = /home/bob/busybox/
  1575. When Buildroot finds that for a given package, an <pkg>
  1576. _OVERRIDE_SRCDIR has been defined, it will no longer attempt to
  1577. download, extract and patch the package. Instead, it will directly
  1578. use the source code available in the specified directory and make
  1579. clean will not touch this directory. This allows to point Buildroot
  1580. to your own directories, that can be managed by Git, Subversion, or
  1581. any other version control system. To achieve this, Buildroot will use
  1582. rsync to copy the source code of the component from the specified
  1583. <pkg>_OVERRIDE_SRCDIR to output/build/<package>-custom/.
  1584. This mechanism is best used in conjunction with the make <pkg>
  1585. -rebuild and make <pkg>-reconfigure targets. A make <pkg>-rebuild all
  1586. sequence will rsync the source code from <pkg>_OVERRIDE_SRCDIR to
  1587. output/build/<package>-custom (thanks to rsync, only the modified
  1588. files are copied), and restart the build process of just this
  1589. package.
  1590. In the example of the linux package above, the developer can then
  1591. make a source code change in /home/bob/linux and then run:
  1592. make linux-rebuild all
  1593. and in a matter of seconds gets the updated Linux kernel image in
  1594. output/images. Similarly, a change can be made to the BusyBox source
  1595. code in /home/bob/busybox, and after:
  1596. make busybox-rebuild all
  1597. the root filesystem image in output/images contains the updated
  1598. BusyBox.
  1599. Source trees for big projects often contain hundreds or thousands of
  1600. files which are not needed for building, but will slow down the
  1601. process of copying the sources with rsync. Optionally, it is possible
  1602. define <pkg>_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS to skip syncing certain
  1603. files from the source tree. For example, when working on the
  1604. webkitgtk package, the following will exclude the tests and in-tree
  1605. builds from a local WebKit source tree:
  1606. WEBKITGTK_OVERRIDE_SRCDIR = /home/bob/WebKit
  1607. WEBKITGTK_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = \
  1608. --exclude JSTests --exclude ManualTests --exclude PerformanceTests \
  1609. --exclude WebDriverTests --exclude WebKitBuild --exclude WebKitLibraries \
  1610. --exclude WebKit.xcworkspace --exclude Websites --exclude Examples
  1611. By default, Buildroot skips syncing of VCS artifacts (e.g., the .git
  1612. and .svn directories). Some packages prefer to have these VCS
  1613. directories available during build, for example for automatically
  1614. determining a precise commit reference for version information. To
  1615. undo this built-in filtering at a cost of a slower speed, add these
  1616. directories back:
  1617. LINUX_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = --include .git
  1618. Chapter 9. Project-specific customization
  1619. Typical actions you may need to perform for a given project are:
  1620. * configuring Buildroot (including build options and toolchain,
  1621. bootloader, kernel, package and filesystem image type selection)
  1622. * configuring other components, like the Linux kernel and BusyBox
  1623. * customizing the generated target filesystem
  1624. + adding or overwriting files on the target filesystem (using
  1625. BR2_ROOTFS_OVERLAY)
  1626. + modifying or deleting files on the target filesystem (using
  1627. BR2_ROOTFS_POST_BUILD_SCRIPT)
  1628. + running arbitrary commands prior to generating the filesystem
  1629. image (using BR2_ROOTFS_POST_BUILD_SCRIPT)
  1630. + setting file permissions and ownership (using
  1631. BR2_ROOTFS_DEVICE_TABLE)
  1632. + adding custom devices nodes (using
  1633. BR2_ROOTFS_STATIC_DEVICE_TABLE)
  1634. * adding custom user accounts (using BR2_ROOTFS_USERS_TABLES)
  1635. * running arbitrary commands after generating the filesystem image
  1636. (using BR2_ROOTFS_POST_IMAGE_SCRIPT)
  1637. * adding project-specific patches to some packages (using
  1638. BR2_GLOBAL_PATCH_DIR)
  1639. * adding project-specific packages
  1640. An important note regarding such project-specific customizations:
  1641. please carefully consider which changes are indeed project-specific
  1642. and which changes are also useful to developers outside your project.
  1643. The Buildroot community highly recommends and encourages the
  1644. upstreaming of improvements, packages and board support to the
  1645. official Buildroot project. Of course, it is sometimes not possible
  1646. or desirable to upstream because the changes are highly specific or
  1647. proprietary.
  1648. This chapter describes how to make such project-specific
  1649. customizations in Buildroot and how to store them in a way that you
  1650. can build the same image in a reproducible way, even after running
  1651. make clean. By following the recommended strategy, you can even use
  1652. the same Buildroot tree to build multiple distinct projects!
  1653. 9.1. Recommended directory structure
  1654. When customizing Buildroot for your project, you will be creating one
  1655. or more project-specific files that need to be stored somewhere.
  1656. While most of these files could be placed in any location as their
  1657. path is to be specified in the Buildroot configuration, the Buildroot
  1658. developers recommend a specific directory structure which is
  1659. described in this section.
  1660. Orthogonal to this directory structure, you can choose where you
  1661. place this structure itself: either inside the Buildroot tree, or
  1662. outside of it using a br2-external tree. Both options are valid, the
  1663. choice is up to you.
  1664. +-- board/
  1665. | +-- <company>/
  1666. | +-- <boardname>/
  1667. | +-- linux.config
  1668. | +-- busybox.config
  1669. | +-- <other configuration files>
  1670. | +-- post_build.sh
  1671. | +-- post_image.sh
  1672. | +-- rootfs_overlay/
  1673. | | +-- etc/
  1674. | | +-- <some files>
  1675. | +-- patches/
  1676. | +-- foo/
  1677. | | +-- <some patches>
  1678. | +-- libbar/
  1679. | +-- <some other patches>
  1680. |
  1681. +-- configs/
  1682. | +-- <boardname>_defconfig
  1683. |
  1684. +-- package/
  1685. | +-- <company>/
  1686. | +-- Config.in (if not using a br2-external tree)
  1687. | +-- <company>.mk (if not using a br2-external tree)
  1688. | +-- package1/
  1689. | | +-- Config.in
  1690. | | +-- package1.mk
  1691. | +-- package2/
  1692. | +-- Config.in
  1693. | +-- package2.mk
  1694. |
  1695. +-- Config.in (if using a br2-external tree)
  1696. +-- external.mk (if using a br2-external tree)
  1697. +-- external.desc (if using a br2-external tree)
  1698. Details on the files shown above are given further in this chapter.
  1699. Note: if you choose to place this structure outside of the Buildroot
  1700. tree but in a br2-external tree, the <company> and possibly
  1701. <boardname> components may be superfluous and can be left out.
  1702. 9.1.1. Implementing layered customizations
  1703. It is quite common for a user to have several related projects that
  1704. partly need the same customizations. Instead of duplicating these
  1705. customizations for each project, it is recommended to use a layered
  1706. customization approach, as explained in this section.
  1707. Almost all of the customization methods available in Buildroot, like
  1708. post-build scripts and root filesystem overlays, accept a
  1709. space-separated list of items. The specified items are always treated
  1710. in order, from left to right. By creating more than one such item,
  1711. one for the common customizations and another one for the really
  1712. project-specific customizations, you can avoid unnecessary
  1713. duplication. Each layer is typically embodied by a separate directory
  1714. inside board/<company>/. Depending on your projects, you could even
  1715. introduce more than two layers.
  1716. An example directory structure for where a user has two customization
  1717. layers common and fooboard is:
  1718. +-- board/
  1719. +-- <company>/
  1720. +-- common/
  1721. | +-- post_build.sh
  1722. | +-- rootfs_overlay/
  1723. | | +-- ...
  1724. | +-- patches/
  1725. | +-- ...
  1726. |
  1727. +-- fooboard/
  1728. +-- linux.config
  1729. +-- busybox.config
  1730. +-- <other configuration files>
  1731. +-- post_build.sh
  1732. +-- rootfs_overlay/
  1733. | +-- ...
  1734. +-- patches/
  1735. +-- ...
  1736. For example, if the user has the BR2_GLOBAL_PATCH_DIR configuration
  1737. option set as:
  1738. BR2_GLOBAL_PATCH_DIR="board/<company>/common/patches board/<company>/fooboard/patches"
  1739. then first the patches from the common layer would be applied,
  1740. followed by the patches from the fooboard layer.
  1741. 9.2. Keeping customizations outside of Buildroot
  1742. As already briefly mentioned in Section 9.1, “Recommended directory
  1743. structure”, you can place project-specific customizations in two
  1744. locations:
  1745. * directly within the Buildroot tree, typically maintaining them
  1746. using branches in a version control system so that upgrading to a
  1747. newer Buildroot release is easy.
  1748. * outside of the Buildroot tree, using the br2-external mechanism.
  1749. This mechanism allows to keep package recipes, board support and
  1750. configuration files outside of the Buildroot tree, while still
  1751. having them nicely integrated in the build logic. We call this
  1752. location a br2-external tree. This section explains how to use
  1753. the br2-external mechanism and what to provide in a br2-external
  1754. tree.
  1755. One can tell Buildroot to use one or more br2-external trees by
  1756. setting the BR2_EXTERNAL make variable set to the path(s) of the
  1757. br2-external tree(s) to use. It can be passed to any Buildroot make
  1758. invocation. It is automatically saved in the hidden .br2-external.mk
  1759. file in the output directory. Thanks to this, there is no need to
  1760. pass BR2_EXTERNAL at every make invocation. It can however be changed
  1761. at any time by passing a new value, and can be removed by passing an
  1762. empty value.
  1763. Note. The path to a br2-external tree can be either absolute or
  1764. relative. If it is passed as a relative path, it is important to note
  1765. that it is interpreted relative to the main Buildroot source
  1766. directory, not to the Buildroot output directory.
  1767. Note: If using an br2-external tree from before Buildroot 2016.11,
  1768. you need to convert it before you can use it with Buildroot 2016.11
  1769. onward. See Section 27.2, “Migrating to 2016.11” for help on doing
  1770. so.
  1771. Some examples:
  1772. buildroot/ $ make BR2_EXTERNAL=/path/to/foo menuconfig
  1773. From now on, definitions from the /path/to/foo br2-external tree will
  1774. be used:
  1775. buildroot/ $ make
  1776. buildroot/ $ make legal-info
  1777. We can switch to another br2-external tree at any time:
  1778. buildroot/ $ make BR2_EXTERNAL=/where/we/have/bar xconfig
  1779. We can also use multiple br2-external trees:
  1780. buildroot/ $ make BR2_EXTERNAL=/path/to/foo:/where/we/have/bar menuconfig
  1781. Or disable the usage of any br2-external tree:
  1782. buildroot/ $ make BR2_EXTERNAL= xconfig
  1783. 9.2.1. Layout of a br2-external tree
  1784. A br2-external tree must contain at least those three files,
  1785. described in the following chapters:
  1786. * external.desc
  1787. * external.mk
  1788. * Config.in
  1789. Apart from those mandatory files, there may be additional and
  1790. optional content that may be present in a br2-external tree, like the
  1791. configs/ or provides/ directories. They are described in the
  1792. following chapters as well.
  1793. A complete example br2-external tree layout is also described later.
  1794. 9.2.1.1. The external.desc file
  1795. That file describes the br2-external tree: the name and description
  1796. for that br2-external tree.
  1797. The format for this file is line based, with each line starting by a
  1798. keyword, followed by a colon and one or more spaces, followed by the
  1799. value assigned to that keyword. There are two keywords currently
  1800. recognised:
  1801. * name, mandatory, defines the name for that br2-external tree.
  1802. That name must only use ASCII characters in the set [A-Za-z0-9_];
  1803. any other character is forbidden. Buildroot sets the variable
  1804. BR2_EXTERNAL_$(NAME)_PATH to the absolute path of the
  1805. br2-external tree, so that you can use it to refer to your
  1806. br2-external tree. This variable is available both in Kconfig, so
  1807. you can use it to source your Kconfig files (see below) and in
  1808. the Makefile, so that you can use it to include other Makefiles
  1809. (see below) or refer to other files (like data files) from your
  1810. br2-external tree.
  1811. Note: Since it is possible to use multiple br2-external trees at
  1812. once, this name is used by Buildroot to generate variables for
  1813. each of those trees. That name is used to identify your
  1814. br2-external tree, so try to come up with a name that really
  1815. describes your br2-external tree, in order for it to be
  1816. relatively unique, so that it does not clash with another name
  1817. from another br2-external tree, especially if you are planning on
  1818. somehow sharing your br2-external tree with third parties or
  1819. using br2-external trees from third parties.
  1820. * desc, optional, provides a short description for that
  1821. br2-external tree. It shall fit on a single line, is mostly
  1822. free-form (see below), and is used when displaying information
  1823. about a br2-external tree (e.g. above the list of defconfig
  1824. files, or as the prompt in the menuconfig); as such, it should
  1825. relatively brief (40 chars is probably a good upper limit). The
  1826. description is available in the BR2_EXTERNAL_$(NAME)_DESC
  1827. variable.
  1828. Examples of names and the corresponding BR2_EXTERNAL_$(NAME)_PATH
  1829. variables:
  1830. * FOO → BR2_EXTERNAL_FOO_PATH
  1831. * BAR_42 → BR2_EXTERNAL_BAR_42_PATH
  1832. In the following examples, it is assumed the name to be set to
  1833. BAR_42.
  1834. Note: Both BR2_EXTERNAL_$(NAME)_PATH and BR2_EXTERNAL_$(NAME)_DESC
  1835. are available in the Kconfig files and the Makefiles. They are also
  1836. exported in the environment so are available in post-build,
  1837. post-image and in-fakeroot scripts.
  1838. 9.2.1.2. The Config.in and external.mk files
  1839. Those files (which may each be empty) can be used to define package
  1840. recipes (i.e. foo/Config.in and foo/foo.mk like for packages bundled
  1841. in Buildroot itself) or other custom configuration options or make
  1842. logic.
  1843. Buildroot automatically includes the Config.in from each br2-external
  1844. tree to make it appear in the top-level configuration menu, and
  1845. includes the external.mk from each br2-external tree with the rest of
  1846. the makefile logic.
  1847. The main usage of this is to store package recipes. The recommended
  1848. way to do this is to write a Config.in file that looks like:
  1849. source "$BR2_EXTERNAL_BAR_42_PATH/package/package1/Config.in"
  1850. source "$BR2_EXTERNAL_BAR_42_PATH/package/package2/Config.in"
  1851. Then, have an external.mk file that looks like:
  1852. include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
  1853. And then in $(BR2_EXTERNAL_BAR_42_PATH)/package/package1 and $
  1854. (BR2_EXTERNAL_BAR_42_PATH)/package/package2 create normal Buildroot
  1855. package recipes, as explained in Chapter 18, Adding new packages to
  1856. Buildroot. If you prefer, you can also group the packages in
  1857. subdirectories called <boardname> and adapt the above paths
  1858. accordingly.
  1859. You can also define custom configuration options in Config.in and
  1860. custom make logic in external.mk.
  1861. 9.2.1.3. The configs/ directory
  1862. One can store Buildroot defconfigs in the configs subdirectory of the
  1863. br2-external tree. Buildroot will automatically show them in the
  1864. output of make list-defconfigs and allow them to be loaded with the
  1865. normal make <name>_defconfig command. They will be visible in the
  1866. make list-defconfigs output, below an External configs label that
  1867. contains the name of the br2-external tree they are defined in.
  1868. Note: If a defconfig file is present in more than one br2-external
  1869. tree, then the one from the last br2-external tree is used. It is
  1870. thus possible to override a defconfig bundled in Buildroot or another
  1871. br2-external tree.
  1872. 9.2.1.4. The provides/ directory
  1873. For some packages, Buildroot provides a choice between two (or more)
  1874. implementations of API-compatible such packages. For example, there
  1875. is a choice to choose either libjpeg or jpeg-turbo; there is one
  1876. between openssl or libressl; there is one to select one of the known,
  1877. pre-configured toolchains…
  1878. It is possible for a br2-external to extend those choices, by
  1879. providing a set of files that define those alternatives:
  1880. * provides/toolchains.in defines the pre-configured toolchains,
  1881. which will then be listed in the toolchain selection;
  1882. * provides/jpeg.in defines the alternative libjpeg implementations;
  1883. * provides/openssl.in defines the alternative openssl
  1884. implementations;
  1885. * provides/skeleton.in defines the alternative skeleton
  1886. implementations;
  1887. * provides/init.in defines the alternative init system
  1888. implementations, this can be used to select a default skeleton
  1889. for your init.
  1890. 9.2.1.5. Free-form content
  1891. One can store all the board-specific configuration files there, such
  1892. as the kernel configuration, the root filesystem overlay, or any
  1893. other configuration file for which Buildroot allows to set the
  1894. location (by using the BR2_EXTERNAL_$(NAME)_PATH variable). For
  1895. example, you could set the paths to a global patch directory, to a
  1896. rootfs overlay and to the kernel configuration file as follows (e.g.
  1897. by running make menuconfig and filling in these options):
  1898. BR2_GLOBAL_PATCH_DIR=$(BR2_EXTERNAL_BAR_42_PATH)/patches/
  1899. BR2_ROOTFS_OVERLAY=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/overlay/
  1900. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/kernel.config
  1901. 9.2.1.6. Additional Linux kernel extensions
  1902. Additional Linux kernel extensions (see Section 18.22.2,
  1903. “linux-kernel-extensions”) can be added by storing them in the linux/
  1904. directory at the root of a br2-external tree.
  1905. 9.2.1.7. Example layout
  1906. Here is an example layout using all features of br2-external (the
  1907. sample content is shown for the file above it, when it is relevant to
  1908. explain the br2-external tree; this is all entirely made up just for
  1909. the sake of illustration, of course):
  1910. /path/to/br2-ext-tree/
  1911. |- external.desc
  1912. | |name: BAR_42
  1913. | |desc: Example br2-external tree
  1914. | `----
  1915. |
  1916. |- Config.in
  1917. | |source "$BR2_EXTERNAL_BAR_42_PATH/toolchain/toolchain-external-mine/Config.in.options"
  1918. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-1/Config.in"
  1919. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-2/Config.in"
  1920. | |source "$BR2_EXTERNAL_BAR_42_PATH/package/my-jpeg/Config.in"
  1921. | |
  1922. | |config BAR_42_FLASH_ADDR
  1923. | | hex "my-board flash address"
  1924. | | default 0x10AD
  1925. | `----
  1926. |
  1927. |- external.mk
  1928. | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
  1929. | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/toolchain/*/*.mk))
  1930. | |
  1931. | |flash-my-board:
  1932. | | $(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/flash-image \
  1933. | | --image $(BINARIES_DIR)/image.bin \
  1934. | | --address $(BAR_42_FLASH_ADDR)
  1935. | `----
  1936. |
  1937. |- package/pkg-1/Config.in
  1938. | |config BR2_PACKAGE_PKG_1
  1939. | | bool "pkg-1"
  1940. | | help
  1941. | | Some help about pkg-1
  1942. | `----
  1943. |- package/pkg-1/pkg-1.hash
  1944. |- package/pkg-1/pkg-1.mk
  1945. | |PKG_1_VERSION = 1.2.3
  1946. | |PKG_1_SITE = /some/where/to/get/pkg-1
  1947. | |PKG_1_LICENSE = blabla
  1948. | |
  1949. | |define PKG_1_INSTALL_INIT_SYSV
  1950. | | $(INSTALL) -D -m 0755 $(PKG_1_PKGDIR)/S99my-daemon \
  1951. | | $(TARGET_DIR)/etc/init.d/S99my-daemon
  1952. | |endef
  1953. | |
  1954. | |$(eval $(autotools-package))
  1955. | `----
  1956. |- package/pkg-1/S99my-daemon
  1957. |
  1958. |- package/pkg-2/Config.in
  1959. |- package/pkg-2/pkg-2.hash
  1960. |- package/pkg-2/pkg-2.mk
  1961. |
  1962. |- provides/jpeg.in
  1963. | |config BR2_PACKAGE_MY_JPEG
  1964. | | bool "my-jpeg"
  1965. | `----
  1966. |- package/my-jpeg/Config.in
  1967. | |config BR2_PACKAGE_PROVIDES_JPEG
  1968. | | default "my-jpeg" if BR2_PACKAGE_MY_JPEG
  1969. | `----
  1970. |- package/my-jpeg/my-jpeg.mk
  1971. | |# This is a normal package .mk file
  1972. | |MY_JPEG_VERSION = 1.2.3
  1973. | |MY_JPEG_SITE = https://example.net/some/place
  1974. | |MY_JPEG_PROVIDES = jpeg
  1975. | |$(eval $(autotools-package))
  1976. | `----
  1977. |
  1978. |- provides/init.in
  1979. | |config BR2_INIT_MINE
  1980. | | bool "my custom init"
  1981. | | select BR2_PACKAGE_MY_INIT
  1982. | | select BR2_PACKAGE_SKELETON_INIT_MINE if BR2_ROOTFS_SKELETON_DEFAULT
  1983. | `----
  1984. |
  1985. |- provides/skeleton.in
  1986. | |config BR2_ROOTFS_SKELETON_MINE
  1987. | | bool "my custom skeleton"
  1988. | | select BR2_PACKAGE_SKELETON_MINE
  1989. | `----
  1990. |- package/skeleton-mine/Config.in
  1991. | |config BR2_PACKAGE_SKELETON_MINE
  1992. | | bool
  1993. | | select BR2_PACKAGE_HAS_SKELETON
  1994. | |
  1995. | |config BR2_PACKAGE_PROVIDES_SKELETON
  1996. | | default "skeleton-mine" if BR2_PACKAGE_SKELETON_MINE
  1997. | `----
  1998. |- package/skeleton-mine/skeleton-mine.mk
  1999. | |SKELETON_MINE_ADD_TOOLCHAIN_DEPENDENCY = NO
  2000. | |SKELETON_MINE_ADD_SKELETON_DEPENDENCY = NO
  2001. | |SKELETON_MINE_PROVIDES = skeleton
  2002. | |SKELETON_MINE_INSTALL_STAGING = YES
  2003. | |$(eval $(generic-package))
  2004. | `----
  2005. |
  2006. |- provides/toolchains.in
  2007. | |config BR2_TOOLCHAIN_EXTERNAL_MINE
  2008. | | bool "my custom toolchain"
  2009. | | depends on BR2_some_arch
  2010. | | select BR2_INSTALL_LIBSTDCPP
  2011. | `----
  2012. |- toolchain/toolchain-external-mine/Config.in.options
  2013. | |if BR2_TOOLCHAIN_EXTERNAL_MINE
  2014. | |config BR2_TOOLCHAIN_EXTERNAL_PREFIX
  2015. | | default "arch-mine-linux-gnu"
  2016. | |config BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL
  2017. | | default "toolchain-external-mine"
  2018. | |endif
  2019. | `----
  2020. |- toolchain/toolchain-external-mine/toolchain-external-mine.mk
  2021. | |TOOLCHAIN_EXTERNAL_MINE_SITE = https://example.net/some/place
  2022. | |TOOLCHAIN_EXTERNAL_MINE_SOURCE = my-toolchain.tar.gz
  2023. | |$(eval $(toolchain-external-package))
  2024. | `----
  2025. |
  2026. |- linux/Config.ext.in
  2027. | |config BR2_LINUX_KERNEL_EXT_EXAMPLE_DRIVER
  2028. | | bool "example-external-driver"
  2029. | | help
  2030. | | Example external driver
  2031. | |---
  2032. |- linux/linux-ext-example-driver.mk
  2033. |
  2034. |- configs/my-board_defconfig
  2035. | |BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_BAR_42_PATH)/patches/"
  2036. | |BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/overlay/"
  2037. | |BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/post-image.sh"
  2038. | |BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/kernel.config"
  2039. | `----
  2040. |
  2041. |- patches/linux/0001-some-change.patch
  2042. |- patches/linux/0002-some-other-change.patch
  2043. |- patches/busybox/0001-fix-something.patch
  2044. |
  2045. |- board/my-board/kernel.config
  2046. |- board/my-board/overlay/var/www/index.html
  2047. |- board/my-board/overlay/var/www/my.css
  2048. |- board/my-board/flash-image
  2049. `- board/my-board/post-image.sh
  2050. |#!/bin/sh
  2051. |generate-my-binary-image \
  2052. | --root ${BINARIES_DIR}/rootfs.tar \
  2053. | --kernel ${BINARIES_DIR}/zImage \
  2054. | --dtb ${BINARIES_DIR}/my-board.dtb \
  2055. | --output ${BINARIES_DIR}/image.bin
  2056. `----
  2057. The br2-external tree will then be visible in the menuconfig (with
  2058. the layout expanded):
  2059. External options --->
  2060. *** Example br2-external tree (in /path/to/br2-ext-tree/)
  2061. [ ] pkg-1
  2062. [ ] pkg-2
  2063. (0x10AD) my-board flash address
  2064. If you are using more than one br2-external tree, it would look like
  2065. (with the layout expanded and the second one with name FOO_27 but no
  2066. desc: field in external.desc):
  2067. External options --->
  2068. Example br2-external tree --->
  2069. *** Example br2-external tree (in /path/to/br2-ext-tree)
  2070. [ ] pkg-1
  2071. [ ] pkg-2
  2072. (0x10AD) my-board flash address
  2073. FOO_27 --->
  2074. *** FOO_27 (in /path/to/another-br2-ext)
  2075. [ ] foo
  2076. [ ] bar
  2077. Additionally, the jpeg provider will be visible in the jpeg choice:
  2078. Target packages --->
  2079. Libraries --->
  2080. Graphics --->
  2081. [*] jpeg support
  2082. jpeg variant () --->
  2083. ( ) jpeg
  2084. ( ) jpeg-turbo
  2085. *** jpeg from: Example br2-external tree ***
  2086. (X) my-jpeg
  2087. *** jpeg from: FOO_27 ***
  2088. ( ) another-jpeg
  2089. And similarly for the toolchains:
  2090. Toolchain --->
  2091. Toolchain () --->
  2092. ( ) Custom toolchain
  2093. *** Toolchains from: Example br2-external tree ***
  2094. (X) my custom toolchain
  2095. Note. The toolchain options in toolchain/toolchain-external-mine/
  2096. Config.in.options will not appear in the Toolchain menu. They must be
  2097. explicitly included from within the br2-external’s top-level
  2098. Config.in and will thus appear in the External options menu.
  2099. 9.3. Storing the Buildroot configuration
  2100. The Buildroot configuration can be stored using the command make
  2101. savedefconfig.
  2102. This strips the Buildroot configuration down by removing
  2103. configuration options that are at their default value. The result is
  2104. stored in a file called defconfig. If you want to save it in another
  2105. place, change the BR2_DEFCONFIG option in the Buildroot configuration
  2106. itself, or call make with make savedefconfig BR2_DEFCONFIG=
  2107. <path-to-defconfig>.
  2108. The recommended place to store this defconfig is configs/<boardname>
  2109. _defconfig. If you follow this recommendation, the configuration will
  2110. be listed in make list-defconfigs and can be set again by running
  2111. make <boardname>_defconfig.
  2112. Alternatively, you can copy the file to any other place and rebuild
  2113. with make defconfig BR2_DEFCONFIG=<path-to-defconfig-file>.
  2114. 9.4. Storing the configuration of other components
  2115. The configuration files for BusyBox, the Linux kernel, Barebox,
  2116. U-Boot and uClibc should be stored as well if changed. For each of
  2117. these components, a Buildroot configuration option exists to point to
  2118. an input configuration file, e.g.
  2119. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE. To store their configuration,
  2120. set these configuration options to a path where you want to save the
  2121. configuration files, and then use the helper targets described below
  2122. to actually store the configuration.
  2123. As explained in Section 9.1, “Recommended directory structure”, the
  2124. recommended path to store these configuration files is board/
  2125. <company>/<boardname>/foo.config.
  2126. Make sure that you create a configuration file before changing the
  2127. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE etc. options. Otherwise,
  2128. Buildroot will try to access this config file, which doesn’t exist
  2129. yet, and will fail. You can create the configuration file by running
  2130. make linux-menuconfig etc.
  2131. Buildroot provides a few helper targets to make the saving of
  2132. configuration files easier.
  2133. * make linux-update-defconfig saves the linux configuration to the
  2134. path specified by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE. It
  2135. simplifies the config file by removing default values. However,
  2136. this only works with kernels starting from 2.6.33. For earlier
  2137. kernels, use make linux-update-config.
  2138. * make busybox-update-config saves the busybox configuration to the
  2139. path specified by BR2_PACKAGE_BUSYBOX_CONFIG.
  2140. * make uclibc-update-config saves the uClibc configuration to the
  2141. path specified by BR2_UCLIBC_CONFIG.
  2142. * make barebox-update-defconfig saves the barebox configuration to
  2143. the path specified by BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE.
  2144. * make uboot-update-defconfig saves the U-Boot configuration to the
  2145. path specified by BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE.
  2146. * For at91bootstrap3, no helper exists so you have to copy the
  2147. config file manually to
  2148. BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE.
  2149. 9.5. Customizing the generated target filesystem
  2150. Besides changing the configuration through make *config, there are a
  2151. few other ways to customize the resulting target filesystem.
  2152. The two recommended methods, which can co-exist, are root filesystem
  2153. overlay(s) and post build script(s).
  2154. Root filesystem overlays (BR2_ROOTFS_OVERLAY)
  2155. A filesystem overlay is a tree of files that is copied directly
  2156. over the target filesystem after it has been built. To enable
  2157. this feature, set config option BR2_ROOTFS_OVERLAY (in the System
  2158. configuration menu) to the root of the overlay. You can even
  2159. specify multiple overlays, space-separated. If you specify a
  2160. relative path, it will be relative to the root of the Buildroot
  2161. tree. Hidden directories of version control systems, like .git,
  2162. .svn, .hg, etc., files called .empty and files ending in ~ are
  2163. excluded from the copy.
  2164. When BR2_ROOTFS_MERGED_USR is enabled, then the overlay must not
  2165. contain the /bin, /lib or /sbin directories, as Buildroot will
  2166. create them as symbolic links to the relevant folders in /usr. In
  2167. such a situation, should the overlay have any programs or
  2168. libraries, they should be placed in /usr/bin, /usr/sbin and /usr/
  2169. lib.
  2170. As shown in Section 9.1, “Recommended directory structure”, the
  2171. recommended path for this overlay is board/<company>/<boardname>/
  2172. rootfs-overlay.
  2173. Post-build scripts (BR2_ROOTFS_POST_BUILD_SCRIPT)
  2174. Post-build scripts are shell scripts called after Buildroot
  2175. builds all the selected software, but before the rootfs images
  2176. are assembled. To enable this feature, specify a space-separated
  2177. list of post-build scripts in config option
  2178. BR2_ROOTFS_POST_BUILD_SCRIPT (in the System configuration menu).
  2179. If you specify a relative path, it will be relative to the root
  2180. of the Buildroot tree.
  2181. Using post-build scripts, you can remove or modify any file in
  2182. your target filesystem. You should, however, use this feature
  2183. with care. Whenever you find that a certain package generates
  2184. wrong or unneeded files, you should fix that package rather than
  2185. work around it with some post-build cleanup scripts.
  2186. As shown in Section 9.1, “Recommended directory structure”, the
  2187. recommended path for this script is board/<company>/<boardname>/
  2188. post_build.sh.
  2189. The post-build scripts are run with the main Buildroot tree as
  2190. current working directory. The path to the target filesystem is
  2191. passed as the first argument to each script. If the config option
  2192. BR2_ROOTFS_POST_SCRIPT_ARGS is not empty, these arguments will be
  2193. passed to the script too. All the scripts will be passed the
  2194. exact same set of arguments, it is not possible to pass different
  2195. sets of arguments to each script.
  2196. In addition, you may also use these environment variables:
  2197. o BR2_CONFIG: the path to the Buildroot .config file
  2198. o CONFIG_DIR: the directory containing the .config file, and
  2199. therefore the top-level Buildroot Makefile to use (which is
  2200. correct for both in-tree and out-of-tree builds)
  2201. o HOST_DIR, STAGING_DIR, TARGET_DIR: see Section 18.6.2,
  2202. “generic-package reference”
  2203. o BUILD_DIR: the directory where packages are extracted and
  2204. built
  2205. o BINARIES_DIR: the place where all binary files (aka images)
  2206. are stored
  2207. o BASE_DIR: the base output directory
  2208. Below three more methods of customizing the target filesystem are
  2209. described, but they are not recommended.
  2210. Direct modification of the target filesystem
  2211. For temporary modifications, you can modify the target filesystem
  2212. directly and rebuild the image. The target filesystem is
  2213. available under output/target/. After making your changes, run
  2214. make to rebuild the target filesystem image.
  2215. This method allows you to do anything to the target filesystem,
  2216. but if you need to clean your Buildroot tree using make clean,
  2217. these changes will be lost. Such cleaning is necessary in several
  2218. cases, refer to Section 8.2, “Understanding when a full rebuild
  2219. is necessary” for details. This solution is therefore only useful
  2220. for quick tests: changes do not survive the make clean command.
  2221. Once you have validated your changes, you should make sure that
  2222. they will persist after a make clean, using a root filesystem
  2223. overlay or a post-build script.
  2224. Custom target skeleton (BR2_ROOTFS_SKELETON_CUSTOM)
  2225. The root filesystem image is created from a target skeleton, on
  2226. top of which all packages install their files. The skeleton is
  2227. copied to the target directory output/target before any package
  2228. is built and installed. The default target skeleton provides the
  2229. standard Unix filesystem layout and some basic init scripts and
  2230. configuration files.
  2231. If the default skeleton (available under system/skeleton) does
  2232. not match your needs, you would typically use a root filesystem
  2233. overlay or post-build script to adapt it. However, if the default
  2234. skeleton is entirely different than what you need, using a custom
  2235. skeleton may be more suitable.
  2236. To enable this feature, enable config option
  2237. BR2_ROOTFS_SKELETON_CUSTOM and set
  2238. BR2_ROOTFS_SKELETON_CUSTOM_PATH to the path of your custom
  2239. skeleton. Both options are available in the System configuration
  2240. menu. If you specify a relative path, it will be relative to the
  2241. root of the Buildroot tree.
  2242. Custom skeletons don’t need to contain the /bin, /lib or /sbin
  2243. directories, since they are created automatically during the
  2244. build. When BR2_ROOTFS_MERGED_USR is enabled, then the custom
  2245. skeleton must not contain the /bin, /lib or /sbin directories, as
  2246. Buildroot will create them as symbolic links to the relevant
  2247. folders in /usr. In such a situation, should the skeleton have
  2248. any programs or libraries, they should be placed in /usr/bin, /
  2249. usr/sbin and /usr/lib.
  2250. This method is not recommended because it duplicates the entire
  2251. skeleton, which prevents taking advantage of the fixes or
  2252. improvements brought to the default skeleton in later Buildroot
  2253. releases.
  2254. Post-fakeroot scripts (BR2_ROOTFS_POST_FAKEROOT_SCRIPT)
  2255. When aggregating the final images, some parts of the process
  2256. requires root rights: creating device nodes in /dev, setting
  2257. permissions or ownership to files and directories… To avoid
  2258. requiring actual root rights, Buildroot uses fakeroot to simulate
  2259. root rights. This is not a complete substitute for actually being
  2260. root, but is enough for what Buildroot needs.
  2261. Post-fakeroot scripts are shell scripts that are called at the
  2262. end of the fakeroot phase, right before the filesystem image
  2263. generator is called. As such, they are called in the fakeroot
  2264. context.
  2265. Post-fakeroot scripts can be useful in case you need to tweak the
  2266. filesystem to do modifications that are usually only available to
  2267. the root user.
  2268. Note: It is recommended to use the existing mechanisms to set
  2269. file permissions or create entries in /dev (see Section 9.5.1,
  2270. “Setting file permissions and ownership and adding custom devices
  2271. nodes”) or to create users (see Section 9.6, “Adding custom user
  2272. accounts”)
  2273. Note: The difference between post-build scripts (above) and
  2274. fakeroot scripts, is that post-build scripts are not called in
  2275. the fakeroot context.
  2276. Note: Using fakeroot is not an absolute substitute for actually
  2277. being root. fakeroot only ever fakes the file access rights and
  2278. types (regular, block-or-char device…) and uid/gid; these are
  2279. emulated in-memory.
  2280. 9.5.1. Setting file permissions and ownership and adding custom
  2281. devices nodes
  2282. Sometimes it is needed to set specific permissions or ownership on
  2283. files or device nodes. For example, certain files may need to be
  2284. owned by root. Since the post-build scripts are not run as root, you
  2285. cannot do such changes from there unless you use an explicit fakeroot
  2286. from the post-build script.
  2287. Instead, Buildroot provides support for so-called permission tables.
  2288. To use this feature, set config option BR2_ROOTFS_DEVICE_TABLE to a
  2289. space-separated list of permission tables, regular text files
  2290. following the makedev syntax.
  2291. If you are using a static device table (i.e. not using devtmpfs,
  2292. mdev, or (e)udev) then you can add device nodes using the same
  2293. syntax, in so-called device tables. To use this feature, set config
  2294. option BR2_ROOTFS_STATIC_DEVICE_TABLE to a space-separated list of
  2295. device tables.
  2296. As shown in Section 9.1, “Recommended directory structure”, the
  2297. recommended location for such files is board/<company>/<boardname>/.
  2298. It should be noted that if the specific permissions or device nodes
  2299. are related to a specific application, you should set variables
  2300. FOO_PERMISSIONS and FOO_DEVICES in the package’s .mk file instead
  2301. (see Section 18.6.2, “generic-package reference”).
  2302. 9.6. Adding custom user accounts
  2303. Sometimes it is needed to add specific users in the target system. To
  2304. cover this requirement, Buildroot provides support for so-called
  2305. users tables. To use this feature, set config option
  2306. BR2_ROOTFS_USERS_TABLES to a space-separated list of users tables,
  2307. regular text files following the makeusers syntax.
  2308. As shown in Section 9.1, “Recommended directory structure”, the
  2309. recommended location for such files is board/<company>/<boardname>/.
  2310. It should be noted that if the custom users are related to a specific
  2311. application, you should set variable FOO_USERS in the package’s .mk
  2312. file instead (see Section 18.6.2, “generic-package reference”).
  2313. 9.7. Customization after the images have been created
  2314. While post-build scripts (Section 9.5, “Customizing the generated
  2315. target filesystem”) are run before building the filesystem image,
  2316. kernel and bootloader, post-image scripts can be used to perform some
  2317. specific actions after all images have been created.
  2318. Post-image scripts can for example be used to automatically extract
  2319. your root filesystem tarball in a location exported by your NFS
  2320. server, or to create a special firmware image that bundles your root
  2321. filesystem and kernel image, or any other custom action required for
  2322. your project.
  2323. To enable this feature, specify a space-separated list of post-image
  2324. scripts in config option BR2_ROOTFS_POST_IMAGE_SCRIPT (in the System
  2325. configuration menu). If you specify a relative path, it will be
  2326. relative to the root of the Buildroot tree.
  2327. Just like post-build scripts, post-image scripts are run with the
  2328. main Buildroot tree as current working directory. The path to the
  2329. images output directory is passed as the first argument to each
  2330. script. If the config option BR2_ROOTFS_POST_SCRIPT_ARGS is not
  2331. empty, these arguments will be passed to the script too. All the
  2332. scripts will be passed the exact same set of arguments, it is not
  2333. possible to pass different sets of arguments to each script.
  2334. Again just like for the post-build scripts, the scripts have access
  2335. to the environment variables BR2_CONFIG, HOST_DIR, STAGING_DIR,
  2336. TARGET_DIR, BUILD_DIR, BINARIES_DIR, CONFIG_DIR and BASE_DIR.
  2337. The post-image scripts will be executed as the user that executes
  2338. Buildroot, which should normally not be the root user. Therefore, any
  2339. action requiring root permissions in one of these scripts will
  2340. require special handling (usage of fakeroot or sudo), which is left
  2341. to the script developer.
  2342. 9.8. Adding project-specific patches and hashes
  2343. 9.8.1. Providing extra patches
  2344. It is sometimes useful to apply extra patches to packages - on top of
  2345. those provided in Buildroot. This might be used to support custom
  2346. features in a project, for example, or when working on a new
  2347. architecture.
  2348. The BR2_GLOBAL_PATCH_DIR configuration option can be used to specify
  2349. a space separated list of one or more directories containing package
  2350. patches.
  2351. For a specific version <packageversion> of a specific package
  2352. <packagename>, patches are applied from BR2_GLOBAL_PATCH_DIR as
  2353. follows:
  2354. 1. For every directory - <global-patch-dir> - that exists in
  2355. BR2_GLOBAL_PATCH_DIR, a <package-patch-dir> will be determined as
  2356. follows:
  2357. + <global-patch-dir>/<packagename>/<packageversion>/ if the
  2358. directory exists.
  2359. + Otherwise, <global-patch-dir>/<packagename> if the directory
  2360. exists.
  2361. 2. Patches will then be applied from a <package-patch-dir> as
  2362. follows:
  2363. + If a series file exists in the package directory, then
  2364. patches are applied according to the series file;
  2365. + Otherwise, patch files matching *.patch are applied in
  2366. alphabetical order. So, to ensure they are applied in the
  2367. right order, it is highly recommended to name the patch files
  2368. like this: <number>-<description>.patch, where <number>
  2369. refers to the apply order.
  2370. For information about how patches are applied for a package, see
  2371. Section 19.2, “How patches are applied”
  2372. The BR2_GLOBAL_PATCH_DIR option is the preferred method for
  2373. specifying a custom patch directory for packages. It can be used to
  2374. specify a patch directory for any package in buildroot. It should
  2375. also be used in place of the custom patch directory options that are
  2376. available for packages such as U-Boot and Barebox. By doing this, it
  2377. will allow a user to manage their patches from one top-level
  2378. directory.
  2379. The exception to BR2_GLOBAL_PATCH_DIR being the preferred method for
  2380. specifying custom patches is BR2_LINUX_KERNEL_PATCH.
  2381. BR2_LINUX_KERNEL_PATCH should be used to specify kernel patches that
  2382. are available at a URL. Note: BR2_LINUX_KERNEL_PATCH specifies kernel
  2383. patches that are applied after patches available in
  2384. BR2_GLOBAL_PATCH_DIR, as it is done from a post-patch hook of the
  2385. Linux package.
  2386. 9.8.2. Providing extra hashes
  2387. Buildroot bundles a list of hashes against which it checks the
  2388. integrity of the downloaded archives, or of those it generates
  2389. locally from VCS checkouts. However, it can only do so for the known
  2390. versions; for packages where it is possible to specify a custom
  2391. version (e.g. a custom version string, a remote tarball URL, or a VCS
  2392. repository location and changeset), Buildroot can’t carry hashes for
  2393. those.
  2394. For users concerned with the integrity of such downloads, it is
  2395. possible to provide a list of hashes that Buildroot can use to check
  2396. arbitrary downloaded files. Those extra hashes are looked up
  2397. similarly to the extra patches (above); for each directory in
  2398. BR2_GLOBAL_PATCH_DIR, the first file to exist is used to check a
  2399. package download:
  2400. * <global-patch-dir>/<packagename>/<packageversion>/
  2401. <packagename>.hash
  2402. * <global-patch-dir>/<packagename>/<packagename>.hash
  2403. The utils/add-custom-hashes script can be used to generate these
  2404. files.
  2405. 9.9. Adding project-specific packages
  2406. In general, any new package should be added directly in the package
  2407. directory and submitted to the Buildroot upstream project. How to add
  2408. packages to Buildroot in general is explained in full detail in
  2409. Chapter 18, Adding new packages to Buildroot and will not be repeated
  2410. here. However, your project may need some proprietary packages that
  2411. cannot be upstreamed. This section will explain how you can keep such
  2412. project-specific packages in a project-specific directory.
  2413. As shown in Section 9.1, “Recommended directory structure”, the
  2414. recommended location for project-specific packages is package/
  2415. <company>/. If you are using the br2-external tree feature (see
  2416. Section 9.2, “Keeping customizations outside of Buildroot”) the
  2417. recommended location is to put them in a sub-directory named package/
  2418. in your br2-external tree.
  2419. However, Buildroot will not be aware of the packages in this
  2420. location, unless we perform some additional steps. As explained in
  2421. Chapter 18, Adding new packages to Buildroot, a package in Buildroot
  2422. basically consists of two files: a .mk file (describing how to build
  2423. the package) and a Config.in file (describing the configuration
  2424. options for this package).
  2425. Buildroot will automatically include the .mk files in first-level
  2426. subdirectories of the package directory (using the pattern package/*/
  2427. *.mk). If we want Buildroot to include .mk files from deeper
  2428. subdirectories (like package/<company>/package1/) then we simply have
  2429. to add a .mk file in a first-level subdirectory that includes these
  2430. additional .mk files. Therefore, create a file package/<company>/
  2431. <company>.mk with following contents (assuming you have only one
  2432. extra directory level below package/<company>/):
  2433. include $(sort $(wildcard package/<company>/*/*.mk))
  2434. For the Config.in files, create a file package/<company>/Config.in
  2435. that includes the Config.in files of all your packages. An exhaustive
  2436. list has to be provided since wildcards are not supported in the
  2437. source command of kconfig. For example:
  2438. source "package/<company>/package1/Config.in"
  2439. source "package/<company>/package2/Config.in"
  2440. Include this new file package/<company>/Config.in from package/
  2441. Config.in, preferably in a company-specific menu to make merges with
  2442. future Buildroot versions easier.
  2443. If using a br2-external tree, refer to Section 9.2, “Keeping
  2444. customizations outside of Buildroot” for how to fill in those files.
  2445. 9.10. Quick guide to storing your project-specific customizations
  2446. Earlier in this chapter, the different methods for making
  2447. project-specific customizations have been described. This section
  2448. will now summarize all this by providing step-by-step instructions to
  2449. storing your project-specific customizations. Clearly, the steps that
  2450. are not relevant to your project can be skipped.
  2451. 1. make menuconfig to configure toolchain, packages and kernel.
  2452. 2. make linux-menuconfig to update the kernel config, similar for
  2453. other configuration like busybox, uclibc, …
  2454. 3. mkdir -p board/<manufacturer>/<boardname>
  2455. 4. Set the following options to board/<manufacturer>/<boardname>/
  2456. <package>.config (as far as they are relevant):
  2457. + BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
  2458. + BR2_PACKAGE_BUSYBOX_CONFIG
  2459. + BR2_UCLIBC_CONFIG
  2460. + BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE
  2461. + BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
  2462. + BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
  2463. 5. Write the configuration files:
  2464. + make linux-update-defconfig
  2465. + make busybox-update-config
  2466. + make uclibc-update-config
  2467. + cp <output>/build/at91bootstrap3-*/.config board/
  2468. <manufacturer>/<boardname>/at91bootstrap3.config
  2469. + make barebox-update-defconfig
  2470. + make uboot-update-defconfig
  2471. 6. Create board/<manufacturer>/<boardname>/rootfs-overlay/ and fill
  2472. it with additional files you need on your rootfs, e.g. board/
  2473. <manufacturer>/<boardname>/rootfs-overlay/etc/inittab. Set
  2474. BR2_ROOTFS_OVERLAY to board/<manufacturer>/<boardname>/
  2475. rootfs-overlay.
  2476. 7. Create a post-build script board/<manufacturer>/<boardname>/
  2477. post_build.sh. Set BR2_ROOTFS_POST_BUILD_SCRIPT to board/
  2478. <manufacturer>/<boardname>/post_build.sh
  2479. 8. If additional setuid permissions have to be set or device nodes
  2480. have to be created, create board/<manufacturer>/<boardname>/
  2481. device_table.txt and add that path to BR2_ROOTFS_DEVICE_TABLE.
  2482. 9. If additional user accounts have to be created, create board/
  2483. <manufacturer>/<boardname>/users_table.txt and add that path to
  2484. BR2_ROOTFS_USERS_TABLES.
  2485. 10. To add custom patches to certain packages, set
  2486. BR2_GLOBAL_PATCH_DIR to board/<manufacturer>/<boardname>/patches/
  2487. and add your patches for each package in a subdirectory named
  2488. after the package. Each patch should be called <packagename>-
  2489. <num>-<description>.patch.
  2490. 11. Specifically for the Linux kernel, there also exists the option
  2491. BR2_LINUX_KERNEL_PATCH with as main advantage that it can also
  2492. download patches from a URL. If you do not need this,
  2493. BR2_GLOBAL_PATCH_DIR is preferred. U-Boot, Barebox, at91bootstrap
  2494. and at91bootstrap3 also have separate options, but these do not
  2495. provide any advantage over BR2_GLOBAL_PATCH_DIR and will likely
  2496. be removed in the future.
  2497. 12. If you need to add project-specific packages, create package/
  2498. <manufacturer>/ and place your packages in that directory. Create
  2499. an overall <manufacturer>.mk file that includes the .mk files of
  2500. all your packages. Create an overall Config.in file that sources
  2501. the Config.in files of all your packages. Include this Config.in
  2502. file from Buildroot’s package/Config.in file.
  2503. 13. make savedefconfig to save the buildroot configuration.
  2504. 14. cp defconfig configs/<boardname>_defconfig
  2505. Chapter 10. Integration topics
  2506. This chapter discusses how various things are integrated at system
  2507. level. Buildroot is highly configurable, almost everything discussed
  2508. here can be changed or overridden by rootfs overlay or custom
  2509. skeleton configuration.
  2510. 10.1. Systemd
  2511. This chapter describes the decisions taken in Buildroot’s integration
  2512. of systemd, and how various use cases can be implemented.
  2513. 10.1.1. DBus daemon
  2514. Systemd requires a DBus daemon. There are two options for it:
  2515. traditional dbus (BR2_PACKAGE_DBUS) and bus1 dbus-broker
  2516. (BR2_PACKAGE_DBUS_BROKER). At least one of them must be chosen. If
  2517. both are included in the configuration, dbus-broker will be used as
  2518. system bus, but the traditional dbus-daemon is still installed as
  2519. well and can be used as session bus. Also its tools (e.g. dbus-send)
  2520. can be used (systemd itself has busctl as an alternative). In
  2521. addition, the traditional dbus package is the only one that provides
  2522. libdbus, which is used by many packages as dbus integration library.
  2523. Both in the dbus and in the dbus-broker case, the daemon runs as user
  2524. dbus. The DBus configuration files are also identical for both.
  2525. To make sure that only one of the two daemons is started as system
  2526. bus, the systemd activation files of the dbus package (dbus.socket
  2527. and the dbus.service symlink in multi-user.target.wants) are removed
  2528. when dbus-broker is selected.
  2529. 10.2. Using SELinux in Buildroot
  2530. SELinux [https://selinuxproject.org] is a Linux kernel security
  2531. module enforcing access control policies. In addition to the
  2532. traditional file permissions and access control lists, SELinux allows
  2533. to write rules for users or processes to access specific functions of
  2534. resources (files, sockets…).
  2535. SELinux has three modes of operation:
  2536. * Disabled: the policy is not applied
  2537. * Permissive: the policy is applied, and non-authorized actions are
  2538. simply logged. This mode is often used for troubleshooting
  2539. SELinux issues.
  2540. * Enforcing: the policy is applied, and non-authorized actions are
  2541. denied
  2542. In Buildroot the mode of operation is controlled by the
  2543. BR2_PACKAGE_REFPOLICY_POLICY_STATE_* configuration options. The Linux
  2544. kernel also has various configuration options that affect how SELinux
  2545. is enabled (see security/selinux/Kconfig in the Linux kernel
  2546. sources).
  2547. By default in Buildroot the SELinux policy is provided by the
  2548. upstream refpolicy [https://github.com/SELinuxProject/refpolicy]
  2549. project, enabled with BR2_PACKAGE_REFPOLICY.
  2550. 10.2.1. Enabling SELinux support
  2551. To have proper support for SELinux in a Buildroot generated system,
  2552. the following configuration options must be enabled:
  2553. * BR2_PACKAGE_LIBSELINUX
  2554. * BR2_PACKAGE_REFPOLICY
  2555. In addition, your filesystem image format must support extended
  2556. attributes.
  2557. 10.2.2. SELinux policy tweaking
  2558. The SELinux refpolicy contains modules that can be enabled or
  2559. disabled when being built. Each module provide a number of SELinux
  2560. rules. In Buildroot the non-base modules are disabled by default and
  2561. several ways to enable such modules are provided:
  2562. * Packages can enable a list of SELinux modules within the
  2563. refpolicy using the <packagename>_SELINUX_MODULES variable.
  2564. * Packages can provide additional SELinux modules by putting them
  2565. (.fc, .if and .te files) in package/<packagename>/selinux/.
  2566. * Extra SELinux modules can be added in directories pointed by the
  2567. BR2_REFPOLICY_EXTRA_MODULES_DIRS configuration option.
  2568. * Additional modules in the refpolicy can be enabled if listed in
  2569. the BR2_REFPOLICY_EXTRA_MODULES_DEPENDENCIES configuration
  2570. option.
  2571. Buildroot also allows to completely override the refpolicy. This
  2572. allows to provide a full custom policy designed specifically for a
  2573. given system. When going this way, all of the above mechanisms are
  2574. disabled: no extra SElinux module is added to the policy, and all the
  2575. available modules within the custom policy are enabled and built into
  2576. the final binary policy. The custom policy must be a fork of the
  2577. official refpolicy [https://github.com/SELinuxProject/refpolicy].
  2578. In order to fully override the refpolicy the following configuration
  2579. variables have to be set:
  2580. * BR2_PACKAGE_REFPOLICY_CUSTOM_GIT
  2581. * BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL
  2582. * BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_VERSION
  2583. Chapter 11. Frequently Asked Questions & Troubleshooting
  2584. 11.1. The boot hangs after Starting network…
  2585. If the boot process seems to hang after the following messages
  2586. (messages not necessarily exactly similar, depending on the list of
  2587. packages selected):
  2588. Freeing init memory: 3972K
  2589. Initializing random number generator... done.
  2590. Starting network...
  2591. Starting dropbear sshd: generating rsa key... generating dsa key... OK
  2592. then it means that your system is running, but didn’t start a shell
  2593. on the serial console. In order to have the system start a shell on
  2594. your serial console, you have to go into the Buildroot configuration,
  2595. in System configuration, modify Run a getty (login prompt) after boot
  2596. and set the appropriate port and baud rate in the getty options
  2597. submenu. This will automatically tune the /etc/inittab file of the
  2598. generated system so that a shell starts on the correct serial port.
  2599. 11.2. Why is there no compiler on the target?
  2600. It has been decided that support for the native compiler on the
  2601. target would be stopped from the Buildroot-2012.11 release because:
  2602. * this feature was neither maintained nor tested, and often broken;
  2603. * this feature was only available for Buildroot toolchains;
  2604. * Buildroot mostly targets small or very small target hardware with
  2605. limited resource onboard (CPU, ram, mass-storage), for which
  2606. compiling on the target does not make much sense;
  2607. * Buildroot aims at easing the cross-compilation, making native
  2608. compilation on the target unnecessary.
  2609. If you need a compiler on your target anyway, then Buildroot is not
  2610. suitable for your purpose. In such case, you need a real distribution
  2611. and you should opt for something like:
  2612. * openembedded [http://www.openembedded.org]
  2613. * yocto [https://www.yoctoproject.org]
  2614. * Debian [https://www.debian.org/ports/]
  2615. * Fedora [https://fedoraproject.org/wiki/Architectures]
  2616. * openSUSE ARM [http://en.opensuse.org/Portal:ARM]
  2617. * Arch Linux ARM [http://archlinuxarm.org]
  2618. * …
  2619. 11.3. Why are there no development files on the target?
  2620. Since there is no compiler available on the target (see Section 11.2,
  2621. “Why is there no compiler on the target?”), it does not make sense to
  2622. waste space with headers or static libraries.
  2623. Therefore, those files are always removed from the target since the
  2624. Buildroot-2012.11 release.
  2625. 11.4. Why is there no documentation on the target?
  2626. Because Buildroot mostly targets small or very small target hardware
  2627. with limited resource onboard (CPU, ram, mass-storage), it does not
  2628. make sense to waste space with the documentation data.
  2629. If you need documentation data on your target anyway, then Buildroot
  2630. is not suitable for your purpose, and you should look for a real
  2631. distribution (see: Section 11.2, “Why is there no compiler on the
  2632. target?”).
  2633. 11.5. Why are some packages not visible in the Buildroot config menu?
  2634. If a package exists in the Buildroot tree and does not appear in the
  2635. config menu, this most likely means that some of the package’s
  2636. dependencies are not met.
  2637. To know more about the dependencies of a package, search for the
  2638. package symbol in the config menu (see Section 8.1, “make tips”).
  2639. Then, you may have to recursively enable several options (which
  2640. correspond to the unmet dependencies) to finally be able to select
  2641. the package.
  2642. If the package is not visible due to some unmet toolchain options,
  2643. then you should certainly run a full rebuild (see Section 8.1, “make
  2644. tips” for more explanations).
  2645. 11.6. Why not use the target directory as a chroot directory?
  2646. There are plenty of reasons to not use the target directory a chroot
  2647. one, among these:
  2648. * file ownerships, modes and permissions are not correctly set in
  2649. the target directory;
  2650. * device nodes are not created in the target directory.
  2651. For these reasons, commands run through chroot, using the target
  2652. directory as the new root, will most likely fail.
  2653. If you want to run the target filesystem inside a chroot, or as an
  2654. NFS root, then use the tarball image generated in images/ and extract
  2655. it as root.
  2656. 11.7. Why doesn’t Buildroot generate binary packages (.deb, .ipkg…)?
  2657. One feature that is often discussed on the Buildroot list is the
  2658. general topic of "package management". To summarize, the idea would
  2659. be to add some tracking of which Buildroot package installs what
  2660. files, with the goals of:
  2661. * being able to remove files installed by a package when this
  2662. package gets unselected from the menuconfig;
  2663. * being able to generate binary packages (ipk or other format) that
  2664. can be installed on the target without re-generating a new root
  2665. filesystem image.
  2666. In general, most people think it is easy to do: just track which
  2667. package installed what and remove it when the package is unselected.
  2668. However, it is much more complicated than that:
  2669. * It is not only about the target/ directory, but also the sysroot
  2670. in host/<tuple>/sysroot and the host/ directory itself. All files
  2671. installed in those directories by various packages must be
  2672. tracked.
  2673. * When a package is unselected from the configuration, it is not
  2674. sufficient to remove just the files it installed. One must also
  2675. remove all its reverse dependencies (i.e. packages relying on it)
  2676. and rebuild all those packages. For example, package A depends
  2677. optionally on the OpenSSL library. Both are selected, and
  2678. Buildroot is built. Package A is built with crypto support using
  2679. OpenSSL. Later on, OpenSSL gets unselected from the
  2680. configuration, but package A remains (since OpenSSL is an
  2681. optional dependency, this is possible.) If only OpenSSL files are
  2682. removed, then the files installed by package A are broken: they
  2683. use a library that is no longer present on the target. Although
  2684. this is technically doable, it adds a lot of complexity to
  2685. Buildroot, which goes against the simplicity we try to stick to.
  2686. * In addition to the previous problem, there is the case where the
  2687. optional dependency is not even known to Buildroot. For example,
  2688. package A in version 1.0 never used OpenSSL, but in version 2.0
  2689. it automatically uses OpenSSL if available. If the Buildroot .mk
  2690. file hasn’t been updated to take this into account, then package
  2691. A will not be part of the reverse dependencies of OpenSSL and
  2692. will not be removed and rebuilt when OpenSSL is removed. For
  2693. sure, the .mk file of package A should be fixed to mention this
  2694. optional dependency, but in the mean time, you can have
  2695. non-reproducible behaviors.
  2696. * The request is to also allow changes in the menuconfig to be
  2697. applied on the output directory without having to rebuild
  2698. everything from scratch. However, this is very difficult to
  2699. achieve in a reliable way: what happens when the suboptions of a
  2700. package are changed (we would have to detect this, and rebuild
  2701. the package from scratch and potentially all its reverse
  2702. dependencies), what happens if toolchain options are changed,
  2703. etc. At the moment, what Buildroot does is clear and simple so
  2704. its behaviour is very reliable and it is easy to support users.
  2705. If configuration changes done in menuconfig are applied after the
  2706. next make, then it has to work correctly and properly in all
  2707. situations, and not have some bizarre corner cases. The risk is
  2708. to get bug reports like "I have enabled package A, B and C, then
  2709. ran make, then disabled package C and enabled package D and ran
  2710. make, then re-enabled package C and enabled package E and then
  2711. there is a build failure". Or worse "I did some configuration,
  2712. then built, then did some changes, built, some more changes,
  2713. built, some more changes, built, and now it fails, but I don’t
  2714. remember all the changes I did and in which order". This will be
  2715. impossible to support.
  2716. For all these reasons, the conclusion is that adding tracking of
  2717. installed files to remove them when the package is unselected, or to
  2718. generate a repository of binary packages, is something that is very
  2719. hard to achieve reliably and will add a lot of complexity.
  2720. On this matter, the Buildroot developers make this position
  2721. statement:
  2722. * Buildroot strives to make it easy to generate a root filesystem
  2723. (hence the name, by the way.) That is what we want to make
  2724. Buildroot good at: building root filesystems.
  2725. * Buildroot is not meant to be a distribution (or rather, a
  2726. distribution generator.) It is the opinion of most Buildroot
  2727. developers that this is not a goal we should pursue. We believe
  2728. that there are other tools better suited to generate a distro
  2729. than Buildroot is. For example, Open Embedded [http://
  2730. openembedded.org/], or openWRT [https://openwrt.org/], are such
  2731. tools.
  2732. * We prefer to push Buildroot in a direction that makes it easy (or
  2733. even easier) to generate complete root filesystems. This is what
  2734. makes Buildroot stands out in the crowd (among other things, of
  2735. course!)
  2736. * We believe that for most embedded Linux systems, binary packages
  2737. are not necessary, and potentially harmful. When binary packages
  2738. are used, it means that the system can be partially upgraded,
  2739. which creates an enormous number of possible combinations of
  2740. package versions that should be tested before doing the upgrade
  2741. on the embedded device. On the other hand, by doing complete
  2742. system upgrades by upgrading the entire root filesystem image at
  2743. once, the image deployed to the embedded system is guaranteed to
  2744. really be the one that has been tested and validated.
  2745. 11.8. How to speed-up the build process?
  2746. Since Buildroot often involves doing full rebuilds of the entire
  2747. system that can be quite long, we provide below a number of tips to
  2748. help reduce the build time:
  2749. * Use a pre-built external toolchain instead of the default
  2750. Buildroot internal toolchain. By using a pre-built Linaro
  2751. toolchain (on ARM) or a Sourcery CodeBench toolchain (for ARM,
  2752. x86, x86-64, MIPS, etc.), you will save the build time of the
  2753. toolchain at each complete rebuild, approximately 15 to 20
  2754. minutes. Note that temporarily using an external toolchain does
  2755. not prevent you to switch back to an internal toolchain (that may
  2756. provide a higher level of customization) once the rest of your
  2757. system is working;
  2758. * Use the ccache compiler cache (see: Section 8.13.3, “Using ccache
  2759. in Buildroot”);
  2760. * Learn about rebuilding only the few packages you actually care
  2761. about (see Section 8.3, “Understanding how to rebuild packages”),
  2762. but beware that sometimes full rebuilds are anyway necessary (see
  2763. Section 8.2, “Understanding when a full rebuild is necessary”);
  2764. * Make sure you are not using a virtual machine for the Linux
  2765. system used to run Buildroot. Most of the virtual machine
  2766. technologies are known to cause a significant performance impact
  2767. on I/O, which is really important for building source code;
  2768. * Make sure that you’re using only local files: do not attempt to
  2769. do a build over NFS, which significantly slows down the build.
  2770. Having the Buildroot download folder available locally also helps
  2771. a bit.
  2772. * Buy new hardware. SSDs and lots of RAM are key to speeding up the
  2773. builds.
  2774. * Experiment with top-level parallel build, see Section 8.12,
  2775. “Top-level parallel build”.
  2776. 11.9. How does Buildroot support Y2038?
  2777. There are multiple situations to consider:
  2778. * On 64-bit architectures, there is no problem, as time_t has
  2779. always been 64-bit.
  2780. * On 32-bit architectures, the situation depends on the C library:
  2781. + With uclibc-ng, there is no support for 64-bit time_t on
  2782. 32-bit architectures, so systems using uclibc-ng on 32-bit
  2783. platforms will not be Y2038 compatible.
  2784. + With musl, 64-bit time_t has always been used on 32-bit
  2785. architectures, so systems using musl on 32-bit platforms are
  2786. Y2038 compatible.
  2787. + With glibc, 64-bit time_t on 32-bit architectures is enabled
  2788. by the Buildroot option BR2_TIME_BITS_64. With this option
  2789. enabled, systems using glibc on 32-bit platforms are Y2038
  2790. compatible.
  2791. Note that the above only comments about the capabilities of the C
  2792. library. Individual user-space libraries or applications, even when
  2793. built in a Y2038-compatible setup, can exhibit incorrect behavior if
  2794. they do not make correct use of the time APIs and types.
  2795. Chapter 12. Known issues
  2796. * It is not possible to pass extra linker options via
  2797. BR2_TARGET_LDFLAGS if such options contain a $ sign. For example,
  2798. the following is known to break: BR2_TARGET_LDFLAGS="-Wl,-rpath=
  2799. '$ORIGIN/../lib'"
  2800. * The libffi package is not supported on the SuperH 2 and ARMv7-M
  2801. architectures.
  2802. * The prboom package triggers a compiler failure with the SuperH 4
  2803. compiler from Sourcery CodeBench, version 2012.09.
  2804. Chapter 13. Legal notice and licensing
  2805. 13.1. Complying with open source licenses
  2806. All of the end products of Buildroot (toolchain, root filesystem,
  2807. kernel, bootloaders) contain open source software, released under
  2808. various licenses.
  2809. Using open source software gives you the freedom to build rich
  2810. embedded systems, choosing from a wide range of packages, but also
  2811. imposes some obligations that you must know and honour. Some licenses
  2812. require you to publish the license text in the documentation of your
  2813. product. Others require you to redistribute the source code of the
  2814. software to those that receive your product.
  2815. The exact requirements of each license are documented in each
  2816. package, and it is your responsibility (or that of your legal office)
  2817. to comply with those requirements. To make this easier for you,
  2818. Buildroot can collect for you some material you will probably need.
  2819. To produce this material, after you have configured Buildroot with
  2820. make menuconfig, make xconfig or make gconfig, run:
  2821. make legal-info
  2822. Buildroot will collect legally-relevant material in your output
  2823. directory, under the legal-info/ subdirectory. There you will find:
  2824. * A README file, that summarizes the produced material and contains
  2825. warnings about material that Buildroot could not produce.
  2826. * buildroot.config: this is the Buildroot configuration file that
  2827. is usually produced with make menuconfig, and which is necessary
  2828. to reproduce the build.
  2829. * The source code for all packages; this is saved in the sources/
  2830. and host-sources/ subdirectories for target and host packages
  2831. respectively. The source code for packages that set <PKG>
  2832. _REDISTRIBUTE = NO will not be saved. Patches that were applied
  2833. are also saved, along with a file named series that lists the
  2834. patches in the order they were applied. Patches are under the
  2835. same license as the files that they modify. Note: Buildroot
  2836. applies additional patches to Libtool scripts of autotools-based
  2837. packages. These patches can be found under support/libtool in the
  2838. Buildroot source and, due to technical limitations, are not saved
  2839. with the package sources. You may need to collect them manually.
  2840. * A manifest file (one for host and one for target packages)
  2841. listing the configured packages, their version, license and
  2842. related information. Some of this information might not be
  2843. defined in Buildroot; such items are marked as "unknown".
  2844. * The license texts of all packages, in the licenses/ and
  2845. host-licenses/ subdirectories for target and host packages
  2846. respectively. If the license file(s) are not defined in
  2847. Buildroot, the file is not produced and a warning in the README
  2848. indicates this.
  2849. Please note that the aim of the legal-info feature of Buildroot is to
  2850. produce all the material that is somehow relevant for legal
  2851. compliance with the package licenses. Buildroot does not try to
  2852. produce the exact material that you must somehow make public.
  2853. Certainly, more material is produced than is needed for a strict
  2854. legal compliance. For example, it produces the source code for
  2855. packages released under BSD-like licenses, that you are not required
  2856. to redistribute in source form.
  2857. Moreover, due to technical limitations, Buildroot does not produce
  2858. some material that you will or may need, such as the toolchain source
  2859. code for some of the external toolchains and the Buildroot source
  2860. code itself. When you run make legal-info, Buildroot produces
  2861. warnings in the README file to inform you of relevant material that
  2862. could not be saved.
  2863. Finally, keep in mind that the output of make legal-info is based on
  2864. declarative statements in each of the packages recipes. The Buildroot
  2865. developers try to do their best to keep those declarative statements
  2866. as accurate as possible, to the best of their knowledge. However, it
  2867. is very well possible that those declarative statements are not all
  2868. fully accurate nor exhaustive. You (or your legal department) have to
  2869. check the output of make legal-info before using it as your own
  2870. compliance delivery. See the NO WARRANTY clauses (clauses 11 and 12)
  2871. in the COPYING file at the root of the Buildroot distribution.
  2872. 13.2. Complying with the Buildroot license
  2873. Buildroot itself is an open source software, released under the GNU
  2874. General Public License, version 2 [http://www.gnu.org/licenses/
  2875. old-licenses/gpl-2.0.html] or (at your option) any later version,
  2876. with the exception of the package patches detailed below. However,
  2877. being a build system, it is not normally part of the end product: if
  2878. you develop the root filesystem, kernel, bootloader or toolchain for
  2879. a device, the code of Buildroot is only present on the development
  2880. machine, not in the device storage.
  2881. Nevertheless, the general view of the Buildroot developers is that
  2882. you should release the Buildroot source code along with the source
  2883. code of other packages when releasing a product that contains
  2884. GPL-licensed software. This is because the GNU GPL [http://
  2885. www.gnu.org/licenses/old-licenses/gpl-2.0.html] defines the "complete
  2886. source code" for an executable work as "all the source code for all
  2887. modules it contains, plus any associated interface definition files,
  2888. plus the scripts used to control compilation and installation of the
  2889. executable". Buildroot is part of the scripts used to control
  2890. compilation and installation of the executable, and as such it is
  2891. considered part of the material that must be redistributed.
  2892. Keep in mind that this is only the Buildroot developers' opinion, and
  2893. you should consult your legal department or lawyer in case of any
  2894. doubt.
  2895. 13.2.1. Patches to packages
  2896. Buildroot also bundles patch files, which are applied to the sources
  2897. of the various packages. Those patches are not covered by the license
  2898. of Buildroot. Instead, they are covered by the license of the
  2899. software to which the patches are applied. When said software is
  2900. available under multiple licenses, the Buildroot patches are only
  2901. provided under the publicly accessible licenses.
  2902. See Chapter 19, Patching a package for the technical details.
  2903. Chapter 14. Beyond Buildroot
  2904. 14.1. Boot the generated images
  2905. 14.1.1. NFS boot
  2906. To achieve NFS-boot, enable tar root filesystem in the Filesystem
  2907. images menu.
  2908. After a complete build, just run the following commands to setup the
  2909. NFS-root directory:
  2910. sudo tar -xavf /path/to/output_dir/rootfs.tar -C /path/to/nfs_root_dir
  2911. Remember to add this path to /etc/exports.
  2912. Then, you can execute a NFS-boot from your target.
  2913. 14.1.2. Live CD
  2914. To build a live CD image, enable the iso image option in the
  2915. Filesystem images menu. Note that this option is only available on
  2916. the x86 and x86-64 architectures, and if you are building your kernel
  2917. with Buildroot.
  2918. You can build a live CD image with either IsoLinux, Grub or Grub 2 as
  2919. a bootloader, but only Isolinux supports making this image usable
  2920. both as a live CD and live USB (through the Build hybrid image
  2921. option).
  2922. You can test your live CD image using QEMU:
  2923. qemu-system-i386 -cdrom output/images/rootfs.iso9660
  2924. Or use it as a hard-drive image if it is a hybrid ISO:
  2925. qemu-system-i386 -hda output/images/rootfs.iso9660
  2926. It can be easily flashed to a USB drive with dd:
  2927. dd if=output/images/rootfs.iso9660 of=/dev/sdb
  2928. 14.2. Chroot
  2929. If you want to chroot in a generated image, then there are few thing
  2930. you should be aware of:
  2931. * you should setup the new root from the tar root filesystem image;
  2932. * either the selected target architecture is compatible with your
  2933. host machine, or you should use some qemu-* binary and correctly
  2934. set it within the binfmt properties to be able to run the
  2935. binaries built for the target on your host machine;
  2936. * Buildroot does not currently provide host-qemu and binfmt
  2937. correctly built and set for that kind of use.
  2938. Part III. Developer guide
  2939. Table of Contents
  2940. 15. How Buildroot works
  2941. 16. Coding style
  2942. 16.1. Config.in file
  2943. 16.2. The .mk file
  2944. 16.3. The genimage.cfg file
  2945. 16.4. The documentation
  2946. 16.5. Support scripts
  2947. 17. Adding support for a particular board
  2948. 18. Adding new packages to Buildroot
  2949. 18.1. Package directory
  2950. 18.2. Config files
  2951. 18.3. The .mk file
  2952. 18.4. The .hash file
  2953. 18.5. The SNNfoo start script
  2954. 18.6. Infrastructure for packages with specific build systems
  2955. 18.7. Infrastructure for autotools-based packages
  2956. 18.8. Infrastructure for CMake-based packages
  2957. 18.9. Infrastructure for Python packages
  2958. 18.10. Infrastructure for LuaRocks-based packages
  2959. 18.11. Infrastructure for Perl/CPAN packages
  2960. 18.12. Infrastructure for virtual packages
  2961. 18.13. Infrastructure for packages using kconfig for
  2962. configuration files
  2963. 18.14. Infrastructure for rebar-based packages
  2964. 18.15. Infrastructure for Waf-based packages
  2965. 18.16. Infrastructure for Meson-based packages
  2966. 18.17. Infrastructure for Cargo-based packages
  2967. 18.18. Infrastructure for Go packages
  2968. 18.19. Infrastructure for QMake-based packages
  2969. 18.20. Infrastructure for packages building kernel modules
  2970. 18.21. Infrastructure for asciidoc documents
  2971. 18.22. Infrastructure specific to the Linux kernel package
  2972. 18.23. Hooks available in the various build steps
  2973. 18.24. Gettext integration and interaction with packages
  2974. 18.25. Tips and tricks
  2975. 18.26. Conclusion
  2976. 19. Patching a package
  2977. 19.1. Providing patches
  2978. 19.2. How patches are applied
  2979. 19.3. Format and licensing of the package patches
  2980. 19.4. Additional patch documentation
  2981. 20. Download infrastructure
  2982. 21. Debugging Buildroot
  2983. 22. Contributing to Buildroot
  2984. 22.1. Reproducing, analyzing and fixing bugs
  2985. 22.2. Analyzing and fixing autobuild failures
  2986. 22.3. Reviewing and testing patches
  2987. 22.4. Work on items from the TODO list
  2988. 22.5. Submitting patches
  2989. 22.6. Reporting issues/bugs or getting help
  2990. 22.7. Using the runtime tests framework
  2991. 23. DEVELOPERS file and get-developers
  2992. 24. Release Engineering
  2993. 24.1. Releases
  2994. 24.2. Development
  2995. Chapter 15. How Buildroot works
  2996. As mentioned above, Buildroot is basically a set of Makefiles that
  2997. download, configure, and compile software with the correct options.
  2998. It also includes patches for various software packages - mainly the
  2999. ones involved in the cross-compilation toolchain (gcc, binutils and
  3000. uClibc).
  3001. There is basically one Makefile per software package, and they are
  3002. named with the .mk extension. Makefiles are split into many different
  3003. parts.
  3004. * The toolchain/ directory contains the Makefiles and associated
  3005. files for all software related to the cross-compilation
  3006. toolchain: binutils, gcc, gdb, kernel-headers and uClibc.
  3007. * The arch/ directory contains the definitions for all the
  3008. processor architectures that are supported by Buildroot.
  3009. * The package/ directory contains the Makefiles and associated
  3010. files for all user-space tools and libraries that Buildroot can
  3011. compile and add to the target root filesystem. There is one
  3012. sub-directory per package.
  3013. * The linux/ directory contains the Makefiles and associated files
  3014. for the Linux kernel.
  3015. * The boot/ directory contains the Makefiles and associated files
  3016. for the bootloaders supported by Buildroot.
  3017. * The system/ directory contains support for system integration,
  3018. e.g. the target filesystem skeleton and the selection of an init
  3019. system.
  3020. * The fs/ directory contains the Makefiles and associated files for
  3021. software related to the generation of the target root filesystem
  3022. image.
  3023. Each directory contains at least 2 files:
  3024. * something.mk is the Makefile that downloads, configures, compiles
  3025. and installs the package something.
  3026. * Config.in is a part of the configuration tool description file.
  3027. It describes the options related to the package.
  3028. The main Makefile performs the following steps (once the
  3029. configuration is done):
  3030. * Create all the output directories: staging, target, build, etc.
  3031. in the output directory (output/ by default, another value can be
  3032. specified using O=)
  3033. * Generate the toolchain target. When an internal toolchain is
  3034. used, this means generating the cross-compilation toolchain. When
  3035. an external toolchain is used, this means checking the features
  3036. of the external toolchain and importing it into the Buildroot
  3037. environment.
  3038. * Generate all the targets listed in the TARGETS variable. This
  3039. variable is filled by all the individual components' Makefiles.
  3040. Generating these targets will trigger the compilation of the
  3041. userspace packages (libraries, programs), the kernel, the
  3042. bootloader and the generation of the root filesystem images,
  3043. depending on the configuration.
  3044. Chapter 16. Coding style
  3045. Overall, these coding style rules are here to help you to add new
  3046. files in Buildroot or refactor existing ones.
  3047. If you slightly modify some existing file, the important thing is to
  3048. keep the consistency of the whole file, so you can:
  3049. * either follow the potentially deprecated coding style used in
  3050. this file,
  3051. * or entirely rework it in order to make it comply with these
  3052. rules.
  3053. 16.1. Config.in file
  3054. Config.in files contain entries for almost anything configurable in
  3055. Buildroot.
  3056. An entry has the following pattern:
  3057. config BR2_PACKAGE_LIBFOO
  3058. bool "libfoo"
  3059. depends on BR2_PACKAGE_LIBBAZ
  3060. select BR2_PACKAGE_LIBBAR
  3061. help
  3062. This is a comment that explains what libfoo is. The help text
  3063. should be wrapped.
  3064. http://foosoftware.org/libfoo/
  3065. * The bool, depends on, select and help lines are indented with one
  3066. tab.
  3067. * The help text itself should be indented with one tab and two
  3068. spaces.
  3069. * The help text should be wrapped to fit 72 columns, where tab
  3070. counts for 8, so 62 characters in the text itself.
  3071. The Config.in files are the input for the configuration tool used in
  3072. Buildroot, which is the regular Kconfig. For further details about
  3073. the Kconfig language, refer to http://kernel.org/doc/Documentation/
  3074. kbuild/kconfig-language.txt.
  3075. 16.2. The .mk file
  3076. * Header: The file starts with a header. It contains the module
  3077. name, preferably in lowercase, enclosed between separators made
  3078. of 80 hashes. A blank line is mandatory after the header:
  3079. ################################################################################
  3080. #
  3081. # libfoo
  3082. #
  3083. ################################################################################
  3084. * Assignment: use = preceded and followed by one space:
  3085. LIBFOO_VERSION = 1.0
  3086. LIBFOO_CONF_OPTS += --without-python-support
  3087. Do not align the = signs.
  3088. * Indentation: use tab only:
  3089. define LIBFOO_REMOVE_DOC
  3090. $(RM) -r $(TARGET_DIR)/usr/share/libfoo/doc \
  3091. $(TARGET_DIR)/usr/share/man/man3/libfoo*
  3092. endef
  3093. Note that commands inside a define block should always start with
  3094. a tab, so make recognizes them as commands.
  3095. * Optional dependency:
  3096. + Prefer multi-line syntax.
  3097. YES:
  3098. ifeq ($(BR2_PACKAGE_PYTHON3),y)
  3099. LIBFOO_CONF_OPTS += --with-python-support
  3100. LIBFOO_DEPENDENCIES += python3
  3101. else
  3102. LIBFOO_CONF_OPTS += --without-python-support
  3103. endif
  3104. NO:
  3105. LIBFOO_CONF_OPTS += --with$(if $(BR2_PACKAGE_PYTHON3),,out)-python-support
  3106. LIBFOO_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON3),python3,)
  3107. + Keep configure options and dependencies close together.
  3108. * Optional hooks: keep hook definition and assignment together in
  3109. one if block.
  3110. YES:
  3111. ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  3112. define LIBFOO_REMOVE_DATA
  3113. $(RM) -r $(TARGET_DIR)/usr/share/libfoo/data
  3114. endef
  3115. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  3116. endif
  3117. NO:
  3118. define LIBFOO_REMOVE_DATA
  3119. $(RM) -r $(TARGET_DIR)/usr/share/libfoo/data
  3120. endef
  3121. ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  3122. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  3123. endif
  3124. 16.3. The genimage.cfg file
  3125. genimage.cfg files contain the output image layout that genimage
  3126. utility uses to create final .img file.
  3127. An example follows:
  3128. image efi-part.vfat {
  3129. vfat {
  3130. file EFI {
  3131. image = "efi-part/EFI"
  3132. }
  3133. file Image {
  3134. image = "Image"
  3135. }
  3136. }
  3137. size = 32M
  3138. }
  3139. image sdimage.img {
  3140. hdimage {
  3141. }
  3142. partition u-boot {
  3143. image = "efi-part.vfat"
  3144. offset = 8K
  3145. }
  3146. partition root {
  3147. image = "rootfs.ext2"
  3148. size = 512M
  3149. }
  3150. }
  3151. * Every section(i.e. hdimage, vfat etc.), partition must be
  3152. indented with one tab.
  3153. * Every file or other subnode must be indented with two tabs.
  3154. * Every node(section, partition, file, subnode) must have an open
  3155. curly bracket on the same line of the node’s name, while the
  3156. closing one must be on a newline and after it a newline must be
  3157. added except for the last one node. Same goes for its option, for
  3158. example option size =.
  3159. * Every option(i.e. image, offset, size) must have the = assignment
  3160. one space from it and one space from the value specified.
  3161. * Filename must at least begin with genimage prefix and have the
  3162. .cfg extension to be easy to recognize.
  3163. * Allowed notations for offset and size options are: G, M, K (not
  3164. k). If it’s not possible to express a precise byte count with
  3165. notations above then use hexadecimal 0x prefix or, as last
  3166. chance, the byte count. In comments instead use GB, MB, KB (not
  3167. kb) in place of G, M, K.
  3168. * For GPT partitions, the partition-type-uuid value must be U for
  3169. the EFI System Partition (expanded to
  3170. c12a7328-f81f-11d2-ba4b-00a0c93ec93b by genimage), F for a FAT
  3171. partition (expanded to ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 by
  3172. genimage) or L for the root filesystem or other filesystems
  3173. (expanded to 0fc63daf-8483-4772-8e79-3d69d8477de4 by genimage).
  3174. Even though L is the default value of genimage, we prefer to have
  3175. it explicitly specified in our genimage.cfg files. Finally, these
  3176. shortcuts should be used without double quotes, e.g
  3177. partition-type-uuid = U. If an explicit GUID is specified,
  3178. lower-case letters should be used.
  3179. The genimage.cfg files are the input for the genimage tool used in
  3180. Buildroot to generate the final image file(i.e. sdcard.img). For
  3181. further details about the genimage language, refer to https://
  3182. github.com/pengutronix/genimage/blob/master/README.rst.
  3183. 16.4. The documentation
  3184. The documentation uses the asciidoc [https://asciidoc-py.github.io/]
  3185. format.
  3186. For further details about the asciidoc syntax, refer to https://
  3187. asciidoc-py.github.io/userguide.html.
  3188. 16.5. Support scripts
  3189. Some scripts in the support/ and utils/ directories are written in
  3190. Python and should follow the PEP8 Style Guide for Python Code [https:
  3191. //www.python.org/dev/peps/pep-0008/].
  3192. Chapter 17. Adding support for a particular board
  3193. Buildroot contains basic configurations for several publicly
  3194. available hardware boards, so that users of such a board can easily
  3195. build a system that is known to work. You are welcome to add support
  3196. for other boards to Buildroot too.
  3197. To do so, you need to create a normal Buildroot configuration that
  3198. builds a basic system for the hardware: (internal) toolchain, kernel,
  3199. bootloader, filesystem and a simple BusyBox-only userspace. No
  3200. specific package should be selected: the configuration should be as
  3201. minimal as possible, and should only build a working basic BusyBox
  3202. system for the target platform. You can of course use more
  3203. complicated configurations for your internal projects, but the
  3204. Buildroot project will only integrate basic board configurations.
  3205. This is because package selections are highly application-specific.
  3206. Once you have a known working configuration, run make savedefconfig.
  3207. This will generate a minimal defconfig file at the root of the
  3208. Buildroot source tree. Move this file into the configs/ directory,
  3209. and rename it <boardname>_defconfig.
  3210. Always use fixed versions or commit hashes for the different
  3211. components, not the "latest" version. For example, set
  3212. BR2_LINUX_KERNEL_CUSTOM_VERSION=y and
  3213. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE to the kernel version you
  3214. tested with. If you are using the buildroot toolchain
  3215. BR2_TOOLCHAIN_BUILDROOT (which is the default), additionally ensure
  3216. that the same kernel headers are used (BR2_KERNEL_HEADERS_AS_KERNEL,
  3217. which is also the default) and set the custom kernel headers series
  3218. to match your kernel version
  3219. (BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_*).
  3220. It is recommended to use as much as possible upstream versions of the
  3221. Linux kernel and bootloaders, and to use as much as possible default
  3222. kernel and bootloader configurations. If they are incorrect for your
  3223. board, or no default exists, we encourage you to send fixes to the
  3224. corresponding upstream projects.
  3225. However, in the mean time, you may want to store kernel or bootloader
  3226. configuration or patches specific to your target platform. To do so,
  3227. create a directory board/<manufacturer> and a subdirectory board/
  3228. <manufacturer>/<boardname>. You can then store your patches and
  3229. configurations in these directories, and reference them from the main
  3230. Buildroot configuration. Refer to Chapter 9, Project-specific
  3231. customization for more details.
  3232. Before submitting patches for new boards it is recommended to test it
  3233. by building it using latest gitlab-CI docker container. To do this
  3234. use utils/docker-run script and inside it issue these commands:
  3235. $ make <boardname>_defconfig
  3236. $ make
  3237. By default, Buildroot developers use the official image hosted on the
  3238. gitlab.com registry [https://gitlab.com/buildroot.org/buildroot/
  3239. container_registry/2395076] and it should be convenient for most
  3240. usage. If you still want to build your own docker image, you can base
  3241. it off the official image as the FROM directive of your own
  3242. Dockerfile:
  3243. FROM registry.gitlab.com/buildroot.org/buildroot/base:YYYYMMDD.HHMM
  3244. RUN ...
  3245. COPY ...
  3246. The current version YYYYMMDD.HHMM can be found in the .gitlab-ci.yml
  3247. file at the top of the Buildroot source tree; all past versions are
  3248. listed in the aforementioned registry as well.
  3249. Chapter 18. Adding new packages to Buildroot
  3250. This section covers how new packages (userspace libraries or
  3251. applications) can be integrated into Buildroot. It also shows how
  3252. existing packages are integrated, which is needed for fixing issues
  3253. or tuning their configuration.
  3254. When you add a new package, be sure to test it in various conditions
  3255. (see Section 18.25.3, “How to test your package”) and also check it
  3256. for coding style (see Section 18.25.2, “How to check the coding
  3257. style”).
  3258. 18.1. Package directory
  3259. First of all, create a directory under the package directory for your
  3260. software, for example libfoo.
  3261. Some packages have been grouped by topic in a sub-directory: x11r7,
  3262. qt5 and gstreamer. If your package fits in one of these categories,
  3263. then create your package directory in these. New subdirectories are
  3264. discouraged, however.
  3265. 18.2. Config files
  3266. For the package to be displayed in the configuration tool, you need
  3267. to create a Config file in your package directory. There are two
  3268. types: Config.in and Config.in.host.
  3269. 18.2.1. Config.in file
  3270. For packages used on the target, create a file named Config.in. This
  3271. file will contain the option descriptions related to our libfoo
  3272. software that will be used and displayed in the configuration tool.
  3273. It should basically contain:
  3274. config BR2_PACKAGE_LIBFOO
  3275. bool "libfoo"
  3276. help
  3277. This is a comment that explains what libfoo is. The help text
  3278. should be wrapped.
  3279. http://foosoftware.org/libfoo/
  3280. The bool line, help line and other metadata information about the
  3281. configuration option must be indented with one tab. The help text
  3282. itself should be indented with one tab and two spaces, lines should
  3283. be wrapped to fit 72 columns, where tab counts for 8, so 62
  3284. characters in the text itself. The help text must mention the
  3285. upstream URL of the project after an empty line.
  3286. As a convention specific to Buildroot, the ordering of the attributes
  3287. is as follows:
  3288. 1. The type of option: bool, string… with the prompt
  3289. 2. If needed, the default value(s)
  3290. 3. Any dependencies on the target in depends on form
  3291. 4. Any dependencies on the toolchain in depends on form
  3292. 5. Any dependencies on other packages in depends on form
  3293. 6. Any dependency of the select form
  3294. 7. The help keyword and help text.
  3295. You can add other sub-options into a if BR2_PACKAGE_LIBFOO…endif
  3296. statement to configure particular things in your software. You can
  3297. look at examples in other packages. The syntax of the Config.in file
  3298. is the same as the one for the kernel Kconfig file. The documentation
  3299. for this syntax is available at http://kernel.org/doc/Documentation/
  3300. kbuild/kconfig-language.txt
  3301. Finally you have to add your new libfoo/Config.in to package/
  3302. Config.in (or in a category subdirectory if you decided to put your
  3303. package in one of the existing categories). The files included there
  3304. are sorted alphabetically per category and are NOT supposed to
  3305. contain anything but the bare name of the package.
  3306. source "package/libfoo/Config.in"
  3307. 18.2.2. Config.in.host file
  3308. Some packages also need to be built for the host system. There are
  3309. two options here:
  3310. * The host package is only required to satisfy build-time
  3311. dependencies of one or more target packages. In this case, add
  3312. host-foo to the target package’s BAR_DEPENDENCIES variable. No
  3313. Config.in.host file should be created.
  3314. * The host package should be explicitly selectable by the user from
  3315. the configuration menu. In this case, create a Config.in.host
  3316. file for that host package:
  3317. config BR2_PACKAGE_HOST_FOO
  3318. bool "host foo"
  3319. help
  3320. This is a comment that explains what foo for the host is.
  3321. http://foosoftware.org/foo/
  3322. The same coding style and options as for the Config.in file are
  3323. valid.
  3324. Finally you have to add your new libfoo/Config.in.host to package
  3325. /Config.in.host. The files included there are sorted
  3326. alphabetically and are NOT supposed to contain anything but the
  3327. bare name of the package.
  3328. source "package/foo/Config.in.host"
  3329. The host package will then be available from the Host utilities
  3330. menu.
  3331. 18.2.3. Choosing depends on or select
  3332. The Config.in file of your package must also ensure that dependencies
  3333. are enabled. Typically, Buildroot uses the following rules:
  3334. * Use a select type of dependency for dependencies on libraries.
  3335. These dependencies are generally not obvious and it therefore
  3336. make sense to have the kconfig system ensure that the
  3337. dependencies are selected. For example, the libgtk2 package uses
  3338. select BR2_PACKAGE_LIBGLIB2 to make sure this library is also
  3339. enabled. The select keyword expresses the dependency with a
  3340. backward semantic.
  3341. * Use a depends on type of dependency when the user really needs to
  3342. be aware of the dependency. Typically, Buildroot uses this type
  3343. of dependency for dependencies on target architecture, MMU
  3344. support and toolchain options (see Section 18.2.4, “Dependencies
  3345. on target and toolchain options”), or for dependencies on "big"
  3346. things, such as the X.org system. The depends on keyword
  3347. expresses the dependency with a forward semantic.
  3348. Note. The current problem with the kconfig language is that these two
  3349. dependency semantics are not internally linked. Therefore, it may be
  3350. possible to select a package, whom one of its dependencies/
  3351. requirement is not met.
  3352. An example illustrates both the usage of select and depends on.
  3353. config BR2_PACKAGE_RRDTOOL
  3354. bool "rrdtool"
  3355. depends on BR2_USE_WCHAR
  3356. select BR2_PACKAGE_FREETYPE
  3357. select BR2_PACKAGE_LIBART
  3358. select BR2_PACKAGE_LIBPNG
  3359. select BR2_PACKAGE_ZLIB
  3360. help
  3361. RRDtool is the OpenSource industry standard, high performance
  3362. data logging and graphing system for time series data.
  3363. http://oss.oetiker.ch/rrdtool/
  3364. comment "rrdtool needs a toolchain w/ wchar"
  3365. depends on !BR2_USE_WCHAR
  3366. Note that these two dependency types are only transitive with the
  3367. dependencies of the same kind.
  3368. This means, in the following example:
  3369. config BR2_PACKAGE_A
  3370. bool "Package A"
  3371. config BR2_PACKAGE_B
  3372. bool "Package B"
  3373. depends on BR2_PACKAGE_A
  3374. config BR2_PACKAGE_C
  3375. bool "Package C"
  3376. depends on BR2_PACKAGE_B
  3377. config BR2_PACKAGE_D
  3378. bool "Package D"
  3379. select BR2_PACKAGE_B
  3380. config BR2_PACKAGE_E
  3381. bool "Package E"
  3382. select BR2_PACKAGE_D
  3383. * Selecting Package C will be visible if Package B has been
  3384. selected, which in turn is only visible if Package A has been
  3385. selected.
  3386. * Selecting Package E will select Package D, which will select
  3387. Package B, it will not check for the dependencies of Package B,
  3388. so it will not select Package A.
  3389. * Since Package B is selected but Package A is not, this violates
  3390. the dependency of Package B on Package A. Therefore, in such a
  3391. situation, the transitive dependency has to be added explicitly:
  3392. config BR2_PACKAGE_D
  3393. bool "Package D"
  3394. depends on BR2_PACKAGE_A
  3395. select BR2_PACKAGE_B
  3396. config BR2_PACKAGE_E
  3397. bool "Package E"
  3398. depends on BR2_PACKAGE_A
  3399. select BR2_PACKAGE_D
  3400. Overall, for package library dependencies, select should be
  3401. preferred.
  3402. Note that such dependencies will ensure that the dependency option is
  3403. also enabled, but not necessarily built before your package. To do
  3404. so, the dependency also needs to be expressed in the .mk file of the
  3405. package.
  3406. Further formatting details: see the coding style.
  3407. 18.2.4. Dependencies on target and toolchain options
  3408. Many packages depend on certain options of the toolchain: the choice
  3409. of C library, C++ support, thread support, RPC support, wchar
  3410. support, or dynamic library support. Some packages can only be built
  3411. on certain target architectures, or if an MMU is available in the
  3412. processor.
  3413. These dependencies have to be expressed with the appropriate depends
  3414. on statements in the Config.in file. Additionally, for dependencies
  3415. on toolchain options, a comment should be displayed when the option
  3416. is not enabled, so that the user knows why the package is not
  3417. available. Dependencies on target architecture or MMU support should
  3418. not be made visible in a comment: since it is unlikely that the user
  3419. can freely choose another target, it makes little sense to show these
  3420. dependencies explicitly.
  3421. The comment should only be visible if the config option itself would
  3422. be visible when the toolchain option dependencies are met. This means
  3423. that all other dependencies of the package (including dependencies on
  3424. target architecture and MMU support) have to be repeated on the
  3425. comment definition. To keep it clear, the depends on statement for
  3426. these non-toolchain option should be kept separate from the depends
  3427. on statement for the toolchain options. If there is a dependency on a
  3428. config option in that same file (typically the main package) it is
  3429. preferable to have a global if … endif construct rather than
  3430. repeating the depends on statement on the comment and other config
  3431. options.
  3432. The general format of a dependency comment for package foo is:
  3433. foo needs a toolchain w/ featA, featB, featC
  3434. for example:
  3435. mpd needs a toolchain w/ C++, threads, wchar
  3436. or
  3437. crda needs a toolchain w/ threads
  3438. Note that this text is kept brief on purpose, so that it will fit on
  3439. a 80-character terminal.
  3440. The rest of this section enumerates the different target and
  3441. toolchain options, the corresponding config symbols to depend on, and
  3442. the text to use in the comment.
  3443. * Target architecture
  3444. + Dependency symbol: BR2_powerpc, BR2_mips, … (see arch/
  3445. Config.in)
  3446. + Comment string: no comment to be added
  3447. * MMU support
  3448. + Dependency symbol: BR2_USE_MMU
  3449. + Comment string: no comment to be added
  3450. * Gcc _sync* built-ins used for atomic operations. They are
  3451. available in variants operating on 1 byte, 2 bytes, 4 bytes and 8
  3452. bytes. Since different architectures support atomic operations on
  3453. different sizes, one dependency symbol is available for each
  3454. size:
  3455. + Dependency symbol: BR2_TOOLCHAIN_HAS_SYNC_1 for 1 byte,
  3456. BR2_TOOLCHAIN_HAS_SYNC_2 for 2 bytes,
  3457. BR2_TOOLCHAIN_HAS_SYNC_4 for 4 bytes,
  3458. BR2_TOOLCHAIN_HAS_SYNC_8 for 8 bytes.
  3459. + Comment string: no comment to be added
  3460. * Gcc _atomic* built-ins used for atomic operations.
  3461. + Dependency symbol: BR2_TOOLCHAIN_HAS_ATOMIC.
  3462. + Comment string: no comment to be added
  3463. * Kernel headers
  3464. + Dependency symbol: BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y,
  3465. (replace X_Y with the proper version, see toolchain/
  3466. Config.in)
  3467. + Comment string: headers >= X.Y and/or headers <= X.Y (replace
  3468. X.Y with the proper version)
  3469. * GCC version
  3470. + Dependency symbol: BR2_TOOLCHAIN_GCC_AT_LEAST_X_Y, (replace
  3471. X_Y with the proper version, see toolchain/Config.in)
  3472. + Comment string: gcc >= X.Y and/or gcc <= X.Y (replace X.Y
  3473. with the proper version)
  3474. * Host GCC version
  3475. + Dependency symbol: BR2_HOST_GCC_AT_LEAST_X_Y, (replace X_Y
  3476. with the proper version, see Config.in)
  3477. + Comment string: no comment to be added
  3478. + Note that it is usually not the package itself that has a
  3479. minimum host GCC version, but rather a host-package on which
  3480. it depends.
  3481. * C library
  3482. + Dependency symbol: BR2_TOOLCHAIN_USES_GLIBC,
  3483. BR2_TOOLCHAIN_USES_MUSL, BR2_TOOLCHAIN_USES_UCLIBC
  3484. + Comment string: for the C library, a slightly different
  3485. comment text is used: foo needs a glibc toolchain, or foo
  3486. needs a glibc toolchain w/ C++
  3487. * C++ support
  3488. + Dependency symbol: BR2_INSTALL_LIBSTDCPP
  3489. + Comment string: C++
  3490. * D support
  3491. + Dependency symbol: BR2_TOOLCHAIN_HAS_DLANG
  3492. + Comment string: Dlang
  3493. * Fortran support
  3494. + Dependency symbol: BR2_TOOLCHAIN_HAS_FORTRAN
  3495. + Comment string: fortran
  3496. * thread support
  3497. + Dependency symbol: BR2_TOOLCHAIN_HAS_THREADS
  3498. + Comment string: threads (unless
  3499. BR2_TOOLCHAIN_HAS_THREADS_NPTL is also needed, in which case,
  3500. specifying only NPTL is sufficient)
  3501. * NPTL thread support
  3502. + Dependency symbol: BR2_TOOLCHAIN_HAS_THREADS_NPTL
  3503. + Comment string: NPTL
  3504. * RPC support
  3505. + Dependency symbol: BR2_TOOLCHAIN_HAS_NATIVE_RPC
  3506. + Comment string: RPC
  3507. * wchar support
  3508. + Dependency symbol: BR2_USE_WCHAR
  3509. + Comment string: wchar
  3510. * dynamic library
  3511. + Dependency symbol: !BR2_STATIC_LIBS
  3512. + Comment string: dynamic library
  3513. 18.2.5. Dependencies on a Linux kernel built by buildroot
  3514. Some packages need a Linux kernel to be built by buildroot. These are
  3515. typically kernel modules or firmware. A comment should be added in
  3516. the Config.in file to express this dependency, similar to
  3517. dependencies on toolchain options. The general format is:
  3518. foo needs a Linux kernel to be built
  3519. If there is a dependency on both toolchain options and the Linux
  3520. kernel, use this format:
  3521. foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
  3522. 18.2.6. Dependencies on udev /dev management
  3523. If a package needs udev /dev management, it should depend on symbol
  3524. BR2_PACKAGE_HAS_UDEV, and the following comment should be added:
  3525. foo needs udev /dev management
  3526. If there is a dependency on both toolchain options and udev /dev
  3527. management, use this format:
  3528. foo needs udev /dev management and a toolchain w/ featA, featB, featC
  3529. 18.2.7. Dependencies on features provided by virtual packages
  3530. Some features can be provided by more than one package, such as the
  3531. openGL libraries.
  3532. See Section 18.12, “Infrastructure for virtual packages” for more on
  3533. the virtual packages.
  3534. 18.3. The .mk file
  3535. Finally, here’s the hardest part. Create a file named libfoo.mk. It
  3536. describes how the package should be downloaded, configured, built,
  3537. installed, etc.
  3538. Depending on the package type, the .mk file must be written in a
  3539. different way, using different infrastructures:
  3540. * Makefiles for generic packages (not using autotools or CMake):
  3541. These are based on an infrastructure similar to the one used for
  3542. autotools-based packages, but require a little more work from the
  3543. developer. They specify what should be done for the
  3544. configuration, compilation and installation of the package. This
  3545. infrastructure must be used for all packages that do not use the
  3546. autotools as their build system. In the future, other specialized
  3547. infrastructures might be written for other build systems. We
  3548. cover them through in a tutorial and a reference.
  3549. * Makefiles for autotools-based software (autoconf, automake,
  3550. etc.): We provide a dedicated infrastructure for such packages,
  3551. since autotools is a very common build system. This
  3552. infrastructure must be used for new packages that rely on the
  3553. autotools as their build system. We cover them through a tutorial
  3554. and reference.
  3555. * Makefiles for cmake-based software: We provide a dedicated
  3556. infrastructure for such packages, as CMake is a more and more
  3557. commonly used build system and has a standardized behaviour. This
  3558. infrastructure must be used for new packages that rely on CMake.
  3559. We cover them through a tutorial and reference.
  3560. * Makefiles for Python modules: We have a dedicated infrastructure
  3561. for Python modules that use the flit, pep517, setuptools,
  3562. setuptools-rust or maturin mechanisms. We cover them through a
  3563. tutorial and a reference.
  3564. * Makefiles for Lua modules: We have a dedicated infrastructure for
  3565. Lua modules available through the LuaRocks web site. We cover
  3566. them through a tutorial and a reference.
  3567. Further formatting details: see the writing rules.
  3568. 18.4. The .hash file
  3569. When possible, you must add a third file, named libfoo.hash, that
  3570. contains the hashes of the downloaded files for the libfoo package.
  3571. The only reason for not adding a .hash file is when hash checking is
  3572. not possible due to how the package is downloaded.
  3573. When a package has a version selection choice, then the hash file may
  3574. be stored in a subdirectory named after the version, e.g. package/
  3575. libfoo/1.2.3/libfoo.hash. This is especially important if the
  3576. different versions have different licensing terms, but they are
  3577. stored in the same file. Otherwise, the hash file should stay in the
  3578. package’s directory.
  3579. The hashes stored in that file are used to validate the integrity of
  3580. the downloaded files and of the license files.
  3581. The format of this file is one line for each file for which to check
  3582. the hash, each line with the following three fields separated by two
  3583. spaces:
  3584. * the type of hash, one of:
  3585. + md5, sha1, sha224, sha256, sha384, sha512
  3586. * the hash of the file:
  3587. + for md5, 32 hexadecimal characters
  3588. + for sha1, 40 hexadecimal characters
  3589. + for sha224, 56 hexadecimal characters
  3590. + for sha256, 64 hexadecimal characters
  3591. + for sha384, 96 hexadecimal characters
  3592. + for sha512, 128 hexadecimal characters
  3593. * the name of the file:
  3594. + for a source archive: the basename of the file, without any
  3595. directory component,
  3596. + for a license file: the path as it appears in
  3597. FOO_LICENSE_FILES.
  3598. Lines starting with a # sign are considered comments, and ignored.
  3599. Empty lines are ignored.
  3600. There can be more than one hash for a single file, each on its own
  3601. line. In this case, all hashes must match.
  3602. Note. Ideally, the hashes stored in this file should match the hashes
  3603. published by upstream, e.g. on their website, in the e-mail
  3604. announcement… If upstream provides more than one type of hash (e.g.
  3605. sha1 and sha512), then it is best to add all those hashes in the
  3606. .hash file. If upstream does not provide any hash, or only provides
  3607. an md5 hash, then compute at least one strong hash yourself
  3608. (preferably sha256, but not md5), and mention this in a comment line
  3609. above the hashes.
  3610. Note. The hashes for license files are used to detect a license
  3611. change when a package version is bumped. The hashes are checked
  3612. during the make legal-info target run. For a package with multiple
  3613. versions (like Qt5), create the hash file in a subdirectory
  3614. <packageversion> of that package (see also Section 19.2, “How patches
  3615. are applied”).
  3616. The example below defines a sha1 and a sha256 published by upstream
  3617. for the main libfoo-1.2.3.tar.bz2 tarball, an md5 from upstream and a
  3618. locally-computed sha256 hashes for a binary blob, a sha256 for a
  3619. downloaded patch, and an archive with no hash:
  3620. # Hashes from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.{sha1,sha256}:
  3621. sha1 486fb55c3efa71148fe07895fd713ea3a5ae343a libfoo-1.2.3.tar.bz2
  3622. sha256 efc8103cc3bcb06bda6a781532d12701eb081ad83e8f90004b39ab81b65d4369 libfoo-1.2.3.tar.bz2
  3623. # md5 from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.md5, sha256 locally computed:
  3624. md5 2d608f3c318c6b7557d551a5a09314f03452f1a1 libfoo-data.bin
  3625. sha256 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b libfoo-data.bin
  3626. # Locally computed:
  3627. sha256 ff52101fb90bbfc3fe9475e425688c660f46216d7e751c4bbdb1dc85cdccacb9 libfoo-fix-blabla.patch
  3628. # Hash for license files:
  3629. sha256 a45a845012742796534f7e91fe623262ccfb99460a2bd04015bd28d66fba95b8 COPYING
  3630. sha256 01b1f9f2c8ee648a7a596a1abe8aa4ed7899b1c9e5551bda06da6e422b04aa55 doc/COPYING.LGPL
  3631. If the .hash file is present, and it contains one or more hashes for
  3632. a downloaded file, the hash(es) computed by Buildroot (after
  3633. download) must match the hash(es) stored in the .hash file. If one or
  3634. more hashes do not match, Buildroot considers this an error, deletes
  3635. the downloaded file, and aborts.
  3636. If the .hash file is present, but it does not contain a hash for a
  3637. downloaded file, Buildroot considers this an error and aborts.
  3638. However, the downloaded file is left in the download directory since
  3639. this typically indicates that the .hash file is wrong but the
  3640. downloaded file is probably OK.
  3641. Hashes are currently checked for files fetched from http/ftp servers,
  3642. Git or subversion repositories, files copied using scp and local
  3643. files. Hashes are not checked for other version control systems (such
  3644. as CVS, mercurial) because Buildroot currently does not generate
  3645. reproducible tarballs when source code is fetched from such version
  3646. control systems.
  3647. Additionally, for packages for which it is possible to specify a
  3648. custom version (e.g. a custom version string, a remote tarball URL,
  3649. or a VCS repository location and changeset), Buildroot can’t carry
  3650. hashes for those. It is however possible to provide a list of extra
  3651. hashes that can cover such cases.
  3652. Hashes should only be added in .hash files for files that are
  3653. guaranteed to be stable. For example, patches auto-generated by
  3654. Github are not guaranteed to be stable, and therefore their hashes
  3655. can change over time. Such patches should not be downloaded, and
  3656. instead be added locally to the package folder.
  3657. If the .hash file is missing, then no check is done at all.
  3658. 18.5. The SNNfoo start script
  3659. Packages that provide a system daemon usually need to be started
  3660. somehow at boot. Buildroot comes with support for several init
  3661. systems, some are considered tier one (see Section 6.3, “init system”
  3662. ), while others are also available but do not have the same level of
  3663. integration. Ideally, all packages providing a system daemon should
  3664. provide a start script for BusyBox/SysV init and a systemd unit file.
  3665. For consistency, the start script must follow the style and
  3666. composition as shown in the reference: package/busybox/S01syslogd. An
  3667. annotated example of this style is shown below. There is no specific
  3668. coding style for systemd unit files, but if a package comes with its
  3669. own unit file, that is preferred over a buildroot specific one, if it
  3670. is compatible with buildroot.
  3671. The name of the start script is composed of the SNN and the daemon
  3672. name. The NN is the start order number which needs to be carefully
  3673. chosen. For example, a program that requires networking to be up
  3674. should not start before S40network. The scripts are started in
  3675. alphabetical order, so S01syslogd starts before S01watchdogd, and
  3676. S02sysctl start thereafter.
  3677. 01: #!/bin/sh
  3678. 02:
  3679. 03: DAEMON="syslogd"
  3680. 04: PIDFILE="/var/run/$DAEMON.pid"
  3681. 05:
  3682. 06: SYSLOGD_ARGS=""
  3683. 07:
  3684. 08: # shellcheck source=/dev/null
  3685. 09: [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
  3686. 10:
  3687. 11: # BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line
  3688. 12: # and use "-m" to instruct start-stop-daemon to create one.
  3689. 13: start() {
  3690. 14: printf 'Starting %s: ' "$DAEMON"
  3691. 15: # shellcheck disable=SC2086 # we need the word splitting
  3692. 16: start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
  3693. 17: -- -n $SYSLOGD_ARGS
  3694. 18: status=$?
  3695. 19: if [ "$status" -eq 0 ]; then
  3696. 20: echo "OK"
  3697. 21: else
  3698. 22: echo "FAIL"
  3699. 23: fi
  3700. 24: return "$status"
  3701. 25: }
  3702. 26:
  3703. 27: stop() {
  3704. 28: printf 'Stopping %s: ' "$DAEMON"
  3705. 29: start-stop-daemon -K -q -p "$PIDFILE"
  3706. 30: status=$?
  3707. 31: if [ "$status" -eq 0 ]; then
  3708. 32: rm -f "$PIDFILE"
  3709. 33: echo "OK"
  3710. 34: else
  3711. 35: echo "FAIL"
  3712. 36: fi
  3713. 37: return "$status"
  3714. 38: }
  3715. 39:
  3716. 40: restart() {
  3717. 41: stop
  3718. 42: sleep 1
  3719. 43: start
  3720. 44: }
  3721. 45:
  3722. 46: case "$1" in
  3723. 47: start|stop|restart)
  3724. 48: "$1";;
  3725. 49: reload)
  3726. 50: # Restart, since there is no true "reload" feature.
  3727. 51: restart;;
  3728. 52: *)
  3729. 53: echo "Usage: $0 {start|stop|restart|reload}"
  3730. 54: exit 1
  3731. 55: esac
  3732. Note: programs that support reloading their configuration in some
  3733. fashion (SIGHUP) should provide a reload() function similar to stop
  3734. (). The start-stop-daemon supports -K -s HUP for this. It is
  3735. recommended to always append -x "/sbin/$DAEMON" to all the
  3736. start-stop-daemon commands to ensure signals are set to a PID that
  3737. matches $DAEMON.
  3738. Both start scripts and unit files can source command line arguments
  3739. from /etc/default/foo, in general, if such a file does not exist it
  3740. should not block the start of the daemon, unless there is some site
  3741. specirfic command line argument the daemon requires to start. For
  3742. start scripts a FOO_ARGS="-s -o -m -e -args" can be defined to a
  3743. default value in and the user can override this from /etc/default/
  3744. foo.
  3745. 18.6. Infrastructure for packages with specific build systems
  3746. By packages with specific build systems we mean all the packages
  3747. whose build system is not one of the standard ones, such as autotools
  3748. or CMake. This typically includes packages whose build system is
  3749. based on hand-written Makefiles or shell scripts.
  3750. 18.6.1. generic-package tutorial
  3751. 01: ################################################################################
  3752. 02: #
  3753. 03: # libfoo
  3754. 04: #
  3755. 05: ################################################################################
  3756. 06:
  3757. 07: LIBFOO_VERSION = 1.0
  3758. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  3759. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  3760. 10: LIBFOO_LICENSE = GPL-3.0+
  3761. 11: LIBFOO_LICENSE_FILES = COPYING
  3762. 12: LIBFOO_INSTALL_STAGING = YES
  3763. 13: LIBFOO_CONFIG_SCRIPTS = libfoo-config
  3764. 14: LIBFOO_DEPENDENCIES = host-libaaa libbbb
  3765. 15:
  3766. 16: define LIBFOO_BUILD_CMDS
  3767. 17: $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) all
  3768. 18: endef
  3769. 19:
  3770. 20: define LIBFOO_INSTALL_STAGING_CMDS
  3771. 21: $(INSTALL) -D -m 0755 $(@D)/libfoo.a $(STAGING_DIR)/usr/lib/libfoo.a
  3772. 22: $(INSTALL) -D -m 0644 $(@D)/foo.h $(STAGING_DIR)/usr/include/foo.h
  3773. 23: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(STAGING_DIR)/usr/lib
  3774. 24: endef
  3775. 25:
  3776. 26: define LIBFOO_INSTALL_TARGET_CMDS
  3777. 27: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(TARGET_DIR)/usr/lib
  3778. 28: $(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/foo.d
  3779. 29: endef
  3780. 30:
  3781. 31: define LIBFOO_USERS
  3782. 32: foo -1 libfoo -1 * - - - LibFoo daemon
  3783. 33: endef
  3784. 34:
  3785. 35: define LIBFOO_DEVICES
  3786. 36: /dev/foo c 666 0 0 42 0 - - -
  3787. 37: endef
  3788. 38:
  3789. 39: define LIBFOO_PERMISSIONS
  3790. 40: /bin/foo f 4755 foo libfoo - - - - -
  3791. 41: endef
  3792. 42:
  3793. 43: $(eval $(generic-package))
  3794. The Makefile begins on line 7 to 11 with metadata information: the
  3795. version of the package (LIBFOO_VERSION), the name of the tarball
  3796. containing the package (LIBFOO_SOURCE) (xz-ed tarball recommended)
  3797. the Internet location at which the tarball can be downloaded from
  3798. (LIBFOO_SITE), the license (LIBFOO_LICENSE) and file with the license
  3799. text (LIBFOO_LICENSE_FILES). All variables must start with the same
  3800. prefix, LIBFOO_ in this case. This prefix is always the uppercased
  3801. version of the package name (see below to understand where the
  3802. package name is defined).
  3803. On line 12, we specify that this package wants to install something
  3804. to the staging space. This is often needed for libraries, since they
  3805. must install header files and other development files in the staging
  3806. space. This will ensure that the commands listed in the
  3807. LIBFOO_INSTALL_STAGING_CMDS variable will be executed.
  3808. On line 13, we specify that there is some fixing to be done to some
  3809. of the libfoo-config files that were installed during
  3810. LIBFOO_INSTALL_STAGING_CMDS phase. These *-config files are
  3811. executable shell script files that are located in $(STAGING_DIR)/usr/
  3812. bin directory and are executed by other 3rd party packages to find
  3813. out the location and the linking flags of this particular package.
  3814. The problem is that all these *-config files by default give wrong,
  3815. host system linking flags that are unsuitable for cross-compiling.
  3816. For example: -I/usr/include instead of -I$(STAGING_DIR)/usr/include
  3817. or: -L/usr/lib instead of -L$(STAGING_DIR)/usr/lib
  3818. So some sed magic is done to these scripts to make them give correct
  3819. flags. The argument to be given to LIBFOO_CONFIG_SCRIPTS is the file
  3820. name(s) of the shell script(s) needing fixing. All these names are
  3821. relative to $(STAGING_DIR)/usr/bin and if needed multiple names can
  3822. be given.
  3823. In addition, the scripts listed in LIBFOO_CONFIG_SCRIPTS are removed
  3824. from $(TARGET_DIR)/usr/bin, since they are not needed on the target.
  3825. Example 18.1. Config script: divine package
  3826. Package divine installs shell script $(STAGING_DIR)/usr/bin/
  3827. divine-config.
  3828. So its fixup would be:
  3829. DIVINE_CONFIG_SCRIPTS = divine-config
  3830. Example 18.2. Config script: imagemagick package:
  3831. Package imagemagick installs the following scripts: $(STAGING_DIR)/
  3832. usr/bin/{Magick,Magick++,MagickCore,MagickWand,Wand}-config
  3833. So it’s fixup would be:
  3834. IMAGEMAGICK_CONFIG_SCRIPTS = \
  3835. Magick-config Magick++-config \
  3836. MagickCore-config MagickWand-config Wand-config
  3837. On line 14, we specify the list of dependencies this package relies
  3838. on. These dependencies are listed in terms of lower-case package
  3839. names, which can be packages for the target (without the host-
  3840. prefix) or packages for the host (with the host-) prefix). Buildroot
  3841. will ensure that all these packages are built and installed before
  3842. the current package starts its configuration.
  3843. The rest of the Makefile, lines 16..29, defines what should be done
  3844. at the different steps of the package configuration, compilation and
  3845. installation. LIBFOO_BUILD_CMDS tells what steps should be performed
  3846. to build the package. LIBFOO_INSTALL_STAGING_CMDS tells what steps
  3847. should be performed to install the package in the staging space.
  3848. LIBFOO_INSTALL_TARGET_CMDS tells what steps should be performed to
  3849. install the package in the target space.
  3850. All these steps rely on the $(@D) variable, which contains the
  3851. directory where the source code of the package has been extracted.
  3852. On lines 31..33, we define a user that is used by this package (e.g.
  3853. to run a daemon as non-root) (LIBFOO_USERS).
  3854. On line 35..37, we define a device-node file used by this package
  3855. (LIBFOO_DEVICES).
  3856. On line 39..41, we define the permissions to set to specific files
  3857. installed by this package (LIBFOO_PERMISSIONS).
  3858. Finally, on line 43, we call the generic-package function, which
  3859. generates, according to the variables defined previously, all the
  3860. Makefile code necessary to make your package working.
  3861. 18.6.2. generic-package reference
  3862. There are two variants of the generic target. The generic-package
  3863. macro is used for packages to be cross-compiled for the target. The
  3864. host-generic-package macro is used for host packages, natively
  3865. compiled for the host. It is possible to call both of them in a
  3866. single .mk file: once to create the rules to generate a target
  3867. package and once to create the rules to generate a host package:
  3868. $(eval $(generic-package))
  3869. $(eval $(host-generic-package))
  3870. This might be useful if the compilation of the target package
  3871. requires some tools to be installed on the host. If the package name
  3872. is libfoo, then the name of the package for the target is also
  3873. libfoo, while the name of the package for the host is host-libfoo.
  3874. These names should be used in the DEPENDENCIES variables of other
  3875. packages, if they depend on libfoo or host-libfoo.
  3876. The call to the generic-package and/or host-generic-package macro
  3877. must be at the end of the .mk file, after all variable definitions.
  3878. The call to host-generic-package must be after the call to
  3879. generic-package, if any.
  3880. For the target package, the generic-package uses the variables
  3881. defined by the .mk file and prefixed by the uppercased package name:
  3882. LIBFOO_*. host-generic-package uses the HOST_LIBFOO_* variables. For
  3883. some variables, if the HOST_LIBFOO_ prefixed variable doesn’t exist,
  3884. the package infrastructure uses the corresponding variable prefixed
  3885. by LIBFOO_. This is done for variables that are likely to have the
  3886. same value for both the target and host packages. See below for
  3887. details.
  3888. The list of variables that can be set in a .mk file to give metadata
  3889. information is (assuming the package name is libfoo) :
  3890. * LIBFOO_VERSION, mandatory, must contain the version of the
  3891. package. Note that if HOST_LIBFOO_VERSION doesn’t exist, it is
  3892. assumed to be the same as LIBFOO_VERSION. It can also be a
  3893. revision number or a tag for packages that are fetched directly
  3894. from their version control system. Examples:
  3895. + a version for a release tarball: LIBFOO_VERSION = 0.1.2
  3896. + a sha1 for a git tree: LIBFOO_VERSION =
  3897. cb9d6aa9429e838f0e54faa3d455bcbab5eef057
  3898. + a tag for a git tree LIBFOO_VERSION = v0.1.2
  3899. Note: Using a branch name as FOO_VERSION is not supported,
  3900. because it does not and can not work as people would expect
  3901. it should:
  3902. 1. due to local caching, Buildroot will not re-fetch the
  3903. repository, so people who expect to be able to follow the
  3904. remote repository would be quite surprised and
  3905. disappointed;
  3906. 2. because two builds can never be perfectly simultaneous,
  3907. and because the remote repository may get new commits on
  3908. the branch anytime, two users, using the same Buildroot
  3909. tree and building the same configuration, may get
  3910. different source, thus rendering the build non
  3911. reproducible, and people would be quite surprised and
  3912. disappointed.
  3913. * LIBFOO_SOURCE may contain the name of the tarball of the package,
  3914. which Buildroot will use to download the tarball from
  3915. LIBFOO_SITE. If HOST_LIBFOO_SOURCE is not specified, it defaults
  3916. to LIBFOO_SOURCE. If none are specified, then the value is
  3917. assumed to be libfoo-$(LIBFOO_VERSION).tar.gz. Example:
  3918. LIBFOO_SOURCE = foobar-$(LIBFOO_VERSION).tar.bz2
  3919. * LIBFOO_PATCH may contain a space-separated list of patch file
  3920. names, that Buildroot will download and apply to the package
  3921. source code. If an entry contains ://, then Buildroot will assume
  3922. it is a full URL and download the patch from this location.
  3923. Otherwise, Buildroot will assume that the patch should be
  3924. downloaded from LIBFOO_SITE. If HOST_LIBFOO_PATCH is not
  3925. specified, it defaults to LIBFOO_PATCH. Note that patches that
  3926. are included in Buildroot itself use a different mechanism: all
  3927. files of the form *.patch present in the package directory inside
  3928. Buildroot will be applied to the package after extraction (see
  3929. patching a package). Finally, patches listed in the LIBFOO_PATCH
  3930. variable are applied before the patches stored in the Buildroot
  3931. package directory.
  3932. * LIBFOO_SITE provides the location of the package, which can be a
  3933. URL or a local filesystem path. HTTP, FTP and SCP are supported
  3934. URL types for retrieving package tarballs. In these cases don’t
  3935. include a trailing slash: it will be added by Buildroot between
  3936. the directory and the filename as appropriate. Git, Subversion,
  3937. Mercurial, and Bazaar are supported URL types for retrieving
  3938. packages directly from source code management systems. There is a
  3939. helper function to make it easier to download source tarballs
  3940. from GitHub (refer to Section 18.25.4, “How to add a package from
  3941. GitHub” for details). A filesystem path may be used to specify
  3942. either a tarball or a directory containing the package source
  3943. code. See LIBFOO_SITE_METHOD below for more details on how
  3944. retrieval works. Note that SCP URLs should be of the form scp://
  3945. [user@]host:filepath, and that filepath is relative to the user’s
  3946. home directory, so you may want to prepend the path with a slash
  3947. for absolute paths: scp://[user@]host:/absolutepath. The same
  3948. goes for SFTP URLs. If HOST_LIBFOO_SITE is not specified, it
  3949. defaults to LIBFOO_SITE. Examples: LIBFOO_SITE=http://
  3950. www.libfoosoftware.org/libfoo LIBFOO_SITE=http://svn.xiph.org/
  3951. trunk/Tremor LIBFOO_SITE=/opt/software/libfoo.tar.gz LIBFOO_SITE=
  3952. $(TOPDIR)/../src/libfoo
  3953. * LIBFOO_DL_OPTS is a space-separated list of additional options to
  3954. pass to the downloader. Useful for retrieving documents with
  3955. server-side checking for user logins and passwords, or to use a
  3956. proxy. All download methods valid for LIBFOO_SITE_METHOD are
  3957. supported; valid options depend on the download method (consult
  3958. the man page for the respective download utilities).
  3959. * LIBFOO_EXTRA_DOWNLOADS is a space-separated list of additional
  3960. files that Buildroot should download. If an entry contains ://
  3961. then Buildroot will assume it is a complete URL and will download
  3962. the file using this URL. Otherwise, Buildroot will assume the
  3963. file to be downloaded is located at LIBFOO_SITE. Buildroot will
  3964. not do anything with those additional files, except download
  3965. them: it will be up to the package recipe to use them from $
  3966. (LIBFOO_DL_DIR).
  3967. * LIBFOO_SITE_METHOD determines the method used to fetch or copy
  3968. the package source code. In many cases, Buildroot guesses the
  3969. method from the contents of LIBFOO_SITE and setting
  3970. LIBFOO_SITE_METHOD is unnecessary. When HOST_LIBFOO_SITE_METHOD
  3971. is not specified, it defaults to the value of LIBFOO_SITE_METHOD.
  3972. The possible values of LIBFOO_SITE_METHOD are:
  3973. + wget for normal FTP/HTTP downloads of tarballs. Used by
  3974. default when LIBFOO_SITE begins with http://, https:// or
  3975. ftp://.
  3976. + scp for downloads of tarballs over SSH with scp. Used by
  3977. default when LIBFOO_SITE begins with scp://.
  3978. + sftp for downloads of tarballs over SSH with sftp. Used by
  3979. default when LIBFOO_SITE begins with sftp://.
  3980. + svn for retrieving source code from a Subversion repository.
  3981. Used by default when LIBFOO_SITE begins with svn://. When a
  3982. http:// Subversion repository URL is specified in
  3983. LIBFOO_SITE, one must specify LIBFOO_SITE_METHOD=svn.
  3984. Buildroot performs a checkout which is preserved as a tarball
  3985. in the download cache; subsequent builds use the tarball
  3986. instead of performing another checkout.
  3987. + cvs for retrieving source code from a CVS repository. Used by
  3988. default when LIBFOO_SITE begins with cvs://. The downloaded
  3989. source code is cached as with the svn method. Anonymous
  3990. pserver mode is assumed otherwise explicitly defined on
  3991. LIBFOO_SITE. Both LIBFOO_SITE=cvs://libfoo.net:/cvsroot/
  3992. libfoo and LIBFOO_SITE=cvs://:ext:libfoo.net:/cvsroot/libfoo
  3993. are accepted, on the former anonymous pserver access mode is
  3994. assumed. LIBFOO_SITE must contain the source URL as well as
  3995. the remote repository directory. The module is the package
  3996. name. LIBFOO_VERSION is mandatory and must be a tag, a
  3997. branch, or a date (e.g. "2014-10-20", "2014-10-20 13:45",
  3998. "2014-10-20 13:45+01" see "man cvs" for further details).
  3999. + git for retrieving source code from a Git repository. Used by
  4000. default when LIBFOO_SITE begins with git://. The downloaded
  4001. source code is cached as with the svn method.
  4002. + hg for retrieving source code from a Mercurial repository.
  4003. One must specify LIBFOO_SITE_METHOD=hg when LIBFOO_SITE
  4004. contains a Mercurial repository URL. The downloaded source
  4005. code is cached as with the svn method.
  4006. + bzr for retrieving source code from a Bazaar repository. Used
  4007. by default when LIBFOO_SITE begins with bzr://. The
  4008. downloaded source code is cached as with the svn method.
  4009. + file for a local tarball. One should use this when
  4010. LIBFOO_SITE specifies a package tarball as a local filename.
  4011. Useful for software that isn’t available publicly or in
  4012. version control.
  4013. + local for a local source code directory. One should use this
  4014. when LIBFOO_SITE specifies a local directory path containing
  4015. the package source code. Buildroot copies the contents of the
  4016. source directory into the package’s build directory. Note
  4017. that for local packages, no patches are applied. If you need
  4018. to still patch the source code, use LIBFOO_POST_RSYNC_HOOKS,
  4019. see Section 18.23.1, “Using the POST_RSYNC hook”.
  4020. * LIBFOO_GIT_SUBMODULES can be set to YES to create an archive with
  4021. the git submodules in the repository. This is only available for
  4022. packages downloaded with git (i.e. when LIBFOO_SITE_METHOD=git).
  4023. Note that we try not to use such git submodules when they contain
  4024. bundled libraries, in which case we prefer to use those libraries
  4025. from their own package.
  4026. * LIBFOO_GIT_LFS should be set to YES if the Git repository uses
  4027. Git LFS to store large files out of band. This is only available
  4028. for packages downloaded with git (i.e. when LIBFOO_SITE_METHOD=
  4029. git).
  4030. * LIBFOO_SVN_EXTERNALS can be set to YES to create an archive with
  4031. the svn external references. This is only available for packages
  4032. downloaded with subversion.
  4033. * LIBFOO_STRIP_COMPONENTS is the number of leading components
  4034. (directories) that tar must strip from file names on extraction.
  4035. The tarball for most packages has one leading component named "
  4036. <pkg-name>-<pkg-version>", thus Buildroot passes
  4037. --strip-components=1 to tar to remove it. For non-standard
  4038. packages that don’t have this component, or that have more than
  4039. one leading component to strip, set this variable with the value
  4040. to be passed to tar. Default: 1.
  4041. * LIBFOO_EXCLUDES is a space-separated list of patterns to exclude
  4042. when extracting the archive. Each item from that list is passed
  4043. as a tar’s --exclude option. By default, empty.
  4044. * LIBFOO_DEPENDENCIES lists the dependencies (in terms of package
  4045. name) that are required for the current target package to
  4046. compile. These dependencies are guaranteed to be compiled and
  4047. installed before the configuration of the current package starts.
  4048. However, modifications to configuration of these dependencies
  4049. will not force a rebuild of the current package. In a similar
  4050. way, HOST_LIBFOO_DEPENDENCIES lists the dependencies for the
  4051. current host package.
  4052. * LIBFOO_EXTRACT_DEPENDENCIES lists the dependencies (in terms of
  4053. package name) that are required for the current target package to
  4054. be extracted. These dependencies are guaranteed to be compiled
  4055. and installed before the extract step of the current package
  4056. starts. This is only used internally by the package
  4057. infrastructure, and should typically not be used directly by
  4058. packages.
  4059. * LIBFOO_PATCH_DEPENDENCIES lists the dependencies (in terms of
  4060. package name) that are required for the current package to be
  4061. patched. These dependencies are guaranteed to be extracted and
  4062. patched (but not necessarily built) before the current package is
  4063. patched. In a similar way, HOST_LIBFOO_PATCH_DEPENDENCIES lists
  4064. the dependencies for the current host package. This is seldom
  4065. used; usually, LIBFOO_DEPENDENCIES is what you really want to
  4066. use.
  4067. * LIBFOO_PROVIDES lists all the virtual packages libfoo is an
  4068. implementation of. See Section 18.12, “Infrastructure for virtual
  4069. packages”.
  4070. * LIBFOO_INSTALL_STAGING can be set to YES or NO (default). If set
  4071. to YES, then the commands in the LIBFOO_INSTALL_STAGING_CMDS
  4072. variables are executed to install the package into the staging
  4073. directory.
  4074. * LIBFOO_INSTALL_TARGET can be set to YES (default) or NO. If set
  4075. to YES, then the commands in the LIBFOO_INSTALL_TARGET_CMDS
  4076. variables are executed to install the package into the target
  4077. directory.
  4078. * LIBFOO_INSTALL_IMAGES can be set to YES or NO (default). If set
  4079. to YES, then the commands in the LIBFOO_INSTALL_IMAGES_CMDS
  4080. variable are executed to install the package into the images
  4081. directory.
  4082. * LIBFOO_CONFIG_SCRIPTS lists the names of the files in $
  4083. (STAGING_DIR)/usr/bin that need some special fixing to make them
  4084. cross-compiling friendly. Multiple file names separated by space
  4085. can be given and all are relative to $(STAGING_DIR)/usr/bin. The
  4086. files listed in LIBFOO_CONFIG_SCRIPTS are also removed from $
  4087. (TARGET_DIR)/usr/bin since they are not needed on the target.
  4088. * LIBFOO_DEVICES lists the device files to be created by Buildroot
  4089. when using the static device table. The syntax to use is the
  4090. makedevs one. You can find some documentation for this syntax in
  4091. the Chapter 25, Makedev syntax documentation. This variable is
  4092. optional.
  4093. * LIBFOO_PERMISSIONS lists the changes of permissions to be done at
  4094. the end of the build process. The syntax is once again the
  4095. makedevs one. You can find some documentation for this syntax in
  4096. the Chapter 25, Makedev syntax documentation. This variable is
  4097. optional.
  4098. * LIBFOO_USERS lists the users to create for this package, if it
  4099. installs a program you want to run as a specific user (e.g. as a
  4100. daemon, or as a cron-job). The syntax is similar in spirit to the
  4101. makedevs one, and is described in the Chapter 26, Makeusers
  4102. syntax documentation. This variable is optional.
  4103. * LIBFOO_LICENSE defines the license (or licenses) under which the
  4104. package is released. This name will appear in the manifest file
  4105. produced by make legal-info. If the license appears in the SPDX
  4106. License List [https://spdx.org/licenses/], use the SPDX short
  4107. identifier to make the manifest file uniform. Otherwise, describe
  4108. the license in a precise and concise way, avoiding ambiguous
  4109. names such as BSD which actually name a family of licenses. This
  4110. variable is optional. If it is not defined, unknown will appear
  4111. in the license field of the manifest file for this package. The
  4112. expected format for this variable must comply with the following
  4113. rules:
  4114. + If different parts of the package are released under
  4115. different licenses, then comma separate licenses (e.g.
  4116. LIBFOO_LICENSE = GPL-2.0+, LGPL-2.1+). If there is clear
  4117. distinction between which component is licensed under what
  4118. license, then annotate the license with that component,
  4119. between parenthesis (e.g. LIBFOO_LICENSE = GPL-2.0+
  4120. (programs), LGPL-2.1+ (libraries)).
  4121. + If some licenses are conditioned on a sub-option being
  4122. enabled, append the conditional licenses with a comma (e.g.:
  4123. FOO_LICENSE += , GPL-2.0+ (programs)); the infrastructure
  4124. will internally remove the space before the comma.
  4125. + If the package is dual licensed, then separate licenses with
  4126. the or keyword (e.g. LIBFOO_LICENSE = AFL-2.1 or GPL-2.0+).
  4127. * LIBFOO_LICENSE_FILES is a space-separated list of files in the
  4128. package tarball that contain the license(s) under which the
  4129. package is released. make legal-info copies all of these files in
  4130. the legal-info directory. See Chapter 13, Legal notice and
  4131. licensing for more information. This variable is optional. If it
  4132. is not defined, a warning will be produced to let you know, and
  4133. not saved will appear in the license files field of the manifest
  4134. file for this package.
  4135. * LIBFOO_ACTUAL_SOURCE_TARBALL only applies to packages whose
  4136. LIBFOO_SITE / LIBFOO_SOURCE pair points to an archive that does
  4137. not actually contain source code, but binary code. This a very
  4138. uncommon case, only known to apply to external toolchains which
  4139. come already compiled, although theoretically it might apply to
  4140. other packages. In such cases a separate tarball is usually
  4141. available with the actual source code. Set
  4142. LIBFOO_ACTUAL_SOURCE_TARBALL to the name of the actual source
  4143. code archive and Buildroot will download it and use it when you
  4144. run make legal-info to collect legally-relevant material. Note
  4145. this file will not be downloaded during regular builds nor by
  4146. make source.
  4147. * LIBFOO_ACTUAL_SOURCE_SITE provides the location of the actual
  4148. source tarball. The default value is LIBFOO_SITE, so you don’t
  4149. need to set this variable if the binary and source archives are
  4150. hosted on the same directory. If LIBFOO_ACTUAL_SOURCE_TARBALL is
  4151. not set, it doesn’t make sense to define
  4152. LIBFOO_ACTUAL_SOURCE_SITE.
  4153. * LIBFOO_REDISTRIBUTE can be set to YES (default) or NO to indicate
  4154. if the package source code is allowed to be redistributed. Set it
  4155. to NO for non-opensource packages: Buildroot will not save the
  4156. source code for this package when collecting the legal-info.
  4157. * LIBFOO_FLAT_STACKSIZE defines the stack size of an application
  4158. built into the FLAT binary format. The application stack size on
  4159. the NOMMU architecture processors can’t be enlarged at run time.
  4160. The default stack size for the FLAT binary format is only 4k
  4161. bytes. If the application consumes more stack, append the
  4162. required number here.
  4163. * LIBFOO_BIN_ARCH_EXCLUDE is a space-separated list of paths
  4164. (relative to the target directory) to ignore when checking that
  4165. the package installs correctly cross-compiled binaries. You
  4166. seldom need to set this variable, unless the package installs
  4167. binary blobs outside the default locations, /lib/firmware, /usr/
  4168. lib/firmware, /lib/modules, /usr/lib/modules, and /usr/share,
  4169. which are automatically excluded.
  4170. * LIBFOO_IGNORE_CVES is a space-separated list of CVEs that tells
  4171. Buildroot CVE tracking tools which CVEs should be ignored for
  4172. this package. This is typically used when the CVE is fixed by a
  4173. patch in the package, or when the CVE for some reason does not
  4174. affect the Buildroot package. A Makefile comment must always
  4175. precede the addition of a CVE to this variable. Example:
  4176. # 0001-fix-cve-2020-12345.patch
  4177. LIBFOO_IGNORE_CVES += CVE-2020-12345
  4178. # only when built with libbaz, which Buildroot doesn't support
  4179. LIBFOO_IGNORE_CVES += CVE-2020-54321
  4180. * LIBFOO_CPE_ID_* variables is a set of variables that allows the
  4181. package to define its CPE identifier [https://nvd.nist.gov/
  4182. products/cpe]. The available variables are:
  4183. + LIBFOO_CPE_ID_VALID, if set to YES, specifies that the
  4184. default values for each of the following variables is
  4185. appropriate, and generates a valid CPE ID.
  4186. + LIBFOO_CPE_ID_PREFIX, specifies the prefix of the CPE
  4187. identifier, i.e the first three fields. When not defined, the
  4188. default value is cpe:2.3:a.
  4189. + LIBFOO_CPE_ID_VENDOR, specifies the vendor part of the CPE
  4190. identifier. When not defined, the default value is <pkgname>
  4191. _project.
  4192. + LIBFOO_CPE_ID_PRODUCT, specifies the product part of the CPE
  4193. identifier. When not defined, the default value is <pkgname>.
  4194. + LIBFOO_CPE_ID_VERSION, specifies the version part of the CPE
  4195. identifier. When not defined the default value is $
  4196. (LIBFOO_VERSION).
  4197. + LIBFOO_CPE_ID_UPDATE specifies the update part of the CPE
  4198. identifier. When not defined the default value is *.
  4199. If any of those variables is defined, then the generic package
  4200. infrastructure assumes the package provides valid CPE
  4201. information. In this case, the generic package infrastructure
  4202. will define LIBFOO_CPE_ID.
  4203. For a host package, if its LIBFOO_CPE_ID_* variables are not
  4204. defined, it inherits the value of those variables from the
  4205. corresponding target package.
  4206. The recommended way to define these variables is to use the following
  4207. syntax:
  4208. LIBFOO_VERSION = 2.32
  4209. Now, the variables that define what should be performed at the
  4210. different steps of the build process.
  4211. * LIBFOO_EXTRACT_CMDS lists the actions to be performed to extract
  4212. the package. This is generally not needed as tarballs are
  4213. automatically handled by Buildroot. However, if the package uses
  4214. a non-standard archive format, such as a ZIP or RAR file, or has
  4215. a tarball with a non-standard organization, this variable allows
  4216. to override the package infrastructure default behavior.
  4217. * LIBFOO_CONFIGURE_CMDS lists the actions to be performed to
  4218. configure the package before its compilation.
  4219. * LIBFOO_BUILD_CMDS lists the actions to be performed to compile
  4220. the package.
  4221. * HOST_LIBFOO_INSTALL_CMDS lists the actions to be performed to
  4222. install the package, when the package is a host package. The
  4223. package must install its files to the directory given by $
  4224. (HOST_DIR). All files, including development files such as
  4225. headers should be installed, since other packages might be
  4226. compiled on top of this package.
  4227. * LIBFOO_INSTALL_TARGET_CMDS lists the actions to be performed to
  4228. install the package to the target directory, when the package is
  4229. a target package. The package must install its files to the
  4230. directory given by $(TARGET_DIR). Only the files required for
  4231. execution of the package have to be installed. Header files,
  4232. static libraries and documentation will be removed again when the
  4233. target filesystem is finalized.
  4234. * LIBFOO_INSTALL_STAGING_CMDS lists the actions to be performed to
  4235. install the package to the staging directory, when the package is
  4236. a target package. The package must install its files to the
  4237. directory given by $(STAGING_DIR). All development files should
  4238. be installed, since they might be needed to compile other
  4239. packages.
  4240. * LIBFOO_INSTALL_IMAGES_CMDS lists the actions to be performed to
  4241. install the package to the images directory, when the package is
  4242. a target package. The package must install its files to the
  4243. directory given by $(BINARIES_DIR). Only files that are binary
  4244. images (aka images) that do not belong in the TARGET_DIR but are
  4245. necessary for booting the board should be placed here. For
  4246. example, a package should utilize this step if it has binaries
  4247. which would be similar to the kernel image, bootloader or root
  4248. filesystem images.
  4249. * LIBFOO_INSTALL_INIT_SYSV, LIBFOO_INSTALL_INIT_OPENRC and
  4250. LIBFOO_INSTALL_INIT_SYSTEMD list the actions to install init
  4251. scripts either for the systemV-like init systems (busybox,
  4252. sysvinit, etc.), openrc or for the systemd units. These commands
  4253. will be run only when the relevant init system is installed (i.e.
  4254. if systemd is selected as the init system in the configuration,
  4255. only LIBFOO_INSTALL_INIT_SYSTEMD will be run). The only exception
  4256. is when openrc is chosen as init system and
  4257. LIBFOO_INSTALL_INIT_OPENRC has not been set, in such situation
  4258. LIBFOO_INSTALL_INIT_SYSV will be called, since openrc supports
  4259. sysv init scripts. When systemd is used as the init system,
  4260. buildroot will automatically enable all services using the
  4261. systemctl preset-all command in the final phase of image
  4262. building. You can add preset files to prevent a particular unit
  4263. from being automatically enabled by buildroot.
  4264. * LIBFOO_HELP_CMDS lists the actions to print the package help,
  4265. which is included to the main make help output. These commands
  4266. can print anything in any format. This is seldom used, as
  4267. packages rarely have custom rules. Do not use this variable,
  4268. unless you really know that you need to print help.
  4269. * LIBFOO_LINUX_CONFIG_FIXUPS lists the Linux kernel configuration
  4270. options that are needed to build and use this package, and
  4271. without which the package is fundamentally broken. This shall be
  4272. a set of calls to one of the kconfig tweaking option:
  4273. KCONFIG_ENABLE_OPT, KCONFIG_DISABLE_OPT, or KCONFIG_SET_OPT. This
  4274. is seldom used, as package usually have no strict requirements on
  4275. the kernel options.
  4276. The preferred way to define these variables is:
  4277. define LIBFOO_CONFIGURE_CMDS
  4278. action 1
  4279. action 2
  4280. action 3
  4281. endef
  4282. In the action definitions, you can use the following variables:
  4283. * $(LIBFOO_PKGDIR) contains the path to the directory containing
  4284. the libfoo.mk and Config.in files. This variable is useful when
  4285. it is necessary to install a file bundled in Buildroot, like a
  4286. runtime configuration file, a splashscreen image…
  4287. * $(@D), which contains the directory in which the package source
  4288. code has been uncompressed.
  4289. * $(LIBFOO_DL_DIR) contains the path to the directory where all the
  4290. downloads made by Buildroot for libfoo are stored in.
  4291. * $(TARGET_CC), $(TARGET_LD), etc. to get the target
  4292. cross-compilation utilities
  4293. * $(TARGET_CROSS) to get the cross-compilation toolchain prefix
  4294. * Of course the $(HOST_DIR), $(STAGING_DIR) and $(TARGET_DIR)
  4295. variables to install the packages properly. Those variables point
  4296. to the global host, staging and target directories, unless
  4297. per-package directory support is used, in which case they point
  4298. to the current package host, staging and target directories. In
  4299. both cases, it doesn’t make any difference from the package point
  4300. of view: it should simply use HOST_DIR, STAGING_DIR and
  4301. TARGET_DIR. See Section 8.12, “Top-level parallel build” for more
  4302. details about per-package directory support.
  4303. Finally, you can also use hooks. See Section 18.23, “Hooks available
  4304. in the various build steps” for more information.
  4305. 18.7. Infrastructure for autotools-based packages
  4306. 18.7.1. autotools-package tutorial
  4307. First, let’s see how to write a .mk file for an autotools-based
  4308. package, with an example :
  4309. 01: ################################################################################
  4310. 02: #
  4311. 03: # libfoo
  4312. 04: #
  4313. 05: ################################################################################
  4314. 06:
  4315. 07: LIBFOO_VERSION = 1.0
  4316. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  4317. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  4318. 10: LIBFOO_INSTALL_STAGING = YES
  4319. 11: LIBFOO_INSTALL_TARGET = NO
  4320. 12: LIBFOO_CONF_OPTS = --disable-shared
  4321. 13: LIBFOO_DEPENDENCIES = libglib2 host-pkgconf
  4322. 14:
  4323. 15: $(eval $(autotools-package))
  4324. On line 7, we declare the version of the package.
  4325. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4326. recommended) and the location of the tarball on the Web. Buildroot
  4327. will automatically download the tarball from this location.
  4328. On line 10, we tell Buildroot to install the package to the staging
  4329. directory. The staging directory, located in output/staging/ is the
  4330. directory where all the packages are installed, including their
  4331. development files, etc. By default, packages are not installed to the
  4332. staging directory, since usually, only libraries need to be installed
  4333. in the staging directory: their development files are needed to
  4334. compile other libraries or applications depending on them. Also by
  4335. default, when staging installation is enabled, packages are installed
  4336. in this location using the make install command.
  4337. On line 11, we tell Buildroot to not install the package to the
  4338. target directory. This directory contains what will become the root
  4339. filesystem running on the target. For purely static libraries, it is
  4340. not necessary to install them in the target directory because they
  4341. will not be used at runtime. By default, target installation is
  4342. enabled; setting this variable to NO is almost never needed. Also by
  4343. default, packages are installed in this location using the make
  4344. install command.
  4345. On line 12, we tell Buildroot to pass a custom configure option, that
  4346. will be passed to the ./configure script before configuring and
  4347. building the package.
  4348. On line 13, we declare our dependencies, so that they are built
  4349. before the build process of our package starts.
  4350. Finally, on line line 15, we invoke the autotools-package macro that
  4351. generates all the Makefile rules that actually allows the package to
  4352. be built.
  4353. 18.7.2. autotools-package reference
  4354. The main macro of the autotools package infrastructure is
  4355. autotools-package. It is similar to the generic-package macro. The
  4356. ability to have target and host packages is also available, with the
  4357. host-autotools-package macro.
  4358. Just like the generic infrastructure, the autotools infrastructure
  4359. works by defining a number of variables before calling the
  4360. autotools-package macro.
  4361. All the package metadata information variables that exist in the
  4362. generic package infrastructure also exist in the autotools
  4363. infrastructure.
  4364. A few additional variables, specific to the autotools infrastructure,
  4365. can also be defined. Many of them are only useful in very specific
  4366. cases, typical packages will therefore only use a few of them.
  4367. * LIBFOO_SUBDIR may contain the name of a subdirectory inside the
  4368. package that contains the configure script. This is useful, if
  4369. for example, the main configure script is not at the root of the
  4370. tree extracted by the tarball. If HOST_LIBFOO_SUBDIR is not
  4371. specified, it defaults to LIBFOO_SUBDIR.
  4372. * LIBFOO_CONF_ENV, to specify additional environment variables to
  4373. pass to the configure script. By default, empty.
  4374. * LIBFOO_CONF_OPTS, to specify additional configure options to pass
  4375. to the configure script. By default, empty.
  4376. * LIBFOO_MAKE, to specify an alternate make command. This is
  4377. typically useful when parallel make is enabled in the
  4378. configuration (using BR2_JLEVEL) but that this feature should be
  4379. disabled for the given package, for one reason or another. By
  4380. default, set to $(MAKE). If parallel building is not supported by
  4381. the package, then it should be set to LIBFOO_MAKE=$(MAKE1).
  4382. * LIBFOO_MAKE_ENV, to specify additional environment variables to
  4383. pass to make in the build step. These are passed before the make
  4384. command. By default, empty.
  4385. * LIBFOO_MAKE_OPTS, to specify additional variables to pass to make
  4386. in the build step. These are passed after the make command. By
  4387. default, empty.
  4388. * LIBFOO_AUTORECONF, tells whether the package should be
  4389. autoreconfigured or not (i.e. if the configure script and
  4390. Makefile.in files should be re-generated by re-running autoconf,
  4391. automake, libtool, etc.). Valid values are YES and NO. By
  4392. default, the value is NO
  4393. * LIBFOO_AUTORECONF_ENV, to specify additional environment
  4394. variables to pass to the autoreconf program if LIBFOO_AUTORECONF=
  4395. YES. These are passed in the environment of the autoreconf
  4396. command. By default, empty.
  4397. * LIBFOO_AUTORECONF_OPTS to specify additional options passed to
  4398. the autoreconf program if LIBFOO_AUTORECONF=YES. By default,
  4399. empty.
  4400. * LIBFOO_AUTOPOINT, tells whether the package should be autopointed
  4401. or not (i.e. if the package needs I18N infrastructure copied in.)
  4402. Only valid when LIBFOO_AUTORECONF=YES. Valid values are YES and
  4403. NO. The default is NO.
  4404. * LIBFOO_LIBTOOL_PATCH tells whether the Buildroot patch to fix
  4405. libtool cross-compilation issues should be applied or not. Valid
  4406. values are YES and NO. By default, the value is YES
  4407. * LIBFOO_INSTALL_STAGING_OPTS contains the make options used to
  4408. install the package to the staging directory. By default, the
  4409. value is DESTDIR=$(STAGING_DIR) install, which is correct for
  4410. most autotools packages. It is still possible to override it.
  4411. * LIBFOO_INSTALL_TARGET_OPTS contains the make options used to
  4412. install the package to the target directory. By default, the
  4413. value is DESTDIR=$(TARGET_DIR) install. The default value is
  4414. correct for most autotools packages, but it is still possible to
  4415. override it if needed.
  4416. With the autotools infrastructure, all the steps required to build
  4417. and install the packages are already defined, and they generally work
  4418. well for most autotools-based packages. However, when required, it is
  4419. still possible to customize what is done in any particular step:
  4420. * By adding a post-operation hook (after extract, patch, configure,
  4421. build or install). See Section 18.23, “Hooks available in the
  4422. various build steps” for details.
  4423. * By overriding one of the steps. For example, even if the
  4424. autotools infrastructure is used, if the package .mk file defines
  4425. its own LIBFOO_CONFIGURE_CMDS variable, it will be used instead
  4426. of the default autotools one. However, using this method should
  4427. be restricted to very specific cases. Do not use it in the
  4428. general case.
  4429. 18.8. Infrastructure for CMake-based packages
  4430. 18.8.1. cmake-package tutorial
  4431. First, let’s see how to write a .mk file for a CMake-based package,
  4432. with an example :
  4433. 01: ################################################################################
  4434. 02: #
  4435. 03: # libfoo
  4436. 04: #
  4437. 05: ################################################################################
  4438. 06:
  4439. 07: LIBFOO_VERSION = 1.0
  4440. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  4441. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  4442. 10: LIBFOO_INSTALL_STAGING = YES
  4443. 11: LIBFOO_INSTALL_TARGET = NO
  4444. 12: LIBFOO_CONF_OPTS = -DBUILD_DEMOS=ON
  4445. 13: LIBFOO_DEPENDENCIES = libglib2 host-pkgconf
  4446. 14:
  4447. 15: $(eval $(cmake-package))
  4448. On line 7, we declare the version of the package.
  4449. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4450. recommended) and the location of the tarball on the Web. Buildroot
  4451. will automatically download the tarball from this location.
  4452. On line 10, we tell Buildroot to install the package to the staging
  4453. directory. The staging directory, located in output/staging/ is the
  4454. directory where all the packages are installed, including their
  4455. development files, etc. By default, packages are not installed to the
  4456. staging directory, since usually, only libraries need to be installed
  4457. in the staging directory: their development files are needed to
  4458. compile other libraries or applications depending on them. Also by
  4459. default, when staging installation is enabled, packages are installed
  4460. in this location using the make install command.
  4461. On line 11, we tell Buildroot to not install the package to the
  4462. target directory. This directory contains what will become the root
  4463. filesystem running on the target. For purely static libraries, it is
  4464. not necessary to install them in the target directory because they
  4465. will not be used at runtime. By default, target installation is
  4466. enabled; setting this variable to NO is almost never needed. Also by
  4467. default, packages are installed in this location using the make
  4468. install command.
  4469. On line 12, we tell Buildroot to pass custom options to CMake when it
  4470. is configuring the package.
  4471. On line 13, we declare our dependencies, so that they are built
  4472. before the build process of our package starts.
  4473. Finally, on line line 15, we invoke the cmake-package macro that
  4474. generates all the Makefile rules that actually allows the package to
  4475. be built.
  4476. 18.8.2. cmake-package reference
  4477. The main macro of the CMake package infrastructure is cmake-package.
  4478. It is similar to the generic-package macro. The ability to have
  4479. target and host packages is also available, with the
  4480. host-cmake-package macro.
  4481. Just like the generic infrastructure, the CMake infrastructure works
  4482. by defining a number of variables before calling the cmake-package
  4483. macro.
  4484. All the package metadata information variables that exist in the
  4485. generic package infrastructure also exist in the CMake
  4486. infrastructure.
  4487. A few additional variables, specific to the CMake infrastructure, can
  4488. also be defined. Many of them are only useful in very specific cases,
  4489. typical packages will therefore only use a few of them.
  4490. * LIBFOO_SUBDIR may contain the name of a subdirectory inside the
  4491. package that contains the main CMakeLists.txt file. This is
  4492. useful, if for example, the main CMakeLists.txt file is not at
  4493. the root of the tree extracted by the tarball. If
  4494. HOST_LIBFOO_SUBDIR is not specified, it defaults to
  4495. LIBFOO_SUBDIR.
  4496. * LIBFOO_CMAKE_BACKEND specifies the cmake backend to use, one of
  4497. make (to use the GNU Makefiles generator, the default) or ninja
  4498. (to use the Ninja generator).
  4499. * LIBFOO_CONF_ENV, to specify additional environment variables to
  4500. pass to CMake. By default, empty.
  4501. * LIBFOO_CONF_OPTS, to specify additional configure options to pass
  4502. to CMake. By default, empty. A number of common CMake options are
  4503. set by the cmake-package infrastructure; so it is normally not
  4504. necessary to set them in the package’s *.mk file unless you want
  4505. to override them:
  4506. + CMAKE_BUILD_TYPE is driven by BR2_ENABLE_RUNTIME_DEBUG;
  4507. + CMAKE_INSTALL_PREFIX;
  4508. + BUILD_SHARED_LIBS is driven by BR2_STATIC_LIBS;
  4509. + BUILD_DOC, BUILD_DOCS are disabled;
  4510. + BUILD_EXAMPLE, BUILD_EXAMPLES are disabled;
  4511. + BUILD_TEST, BUILD_TESTS, BUILD_TESTING are disabled.
  4512. * LIBFOO_BUILD_ENV and LIBFOO_BUILD_OPTS to specify additional
  4513. environment variables, or command line options, to pass to the
  4514. backend at build time.
  4515. * LIBFOO_SUPPORTS_IN_SOURCE_BUILD = NO should be set when the
  4516. package cannot be built inside the source tree but needs a
  4517. separate build directory.
  4518. * LIBFOO_MAKE, to specify an alternate make command. This is
  4519. typically useful when parallel make is enabled in the
  4520. configuration (using BR2_JLEVEL) but that this feature should be
  4521. disabled for the given package, for one reason or another. By
  4522. default, set to $(MAKE). If parallel building is not supported by
  4523. the package, then it should be set to LIBFOO_MAKE=$(MAKE1).
  4524. * LIBFOO_MAKE_ENV, to specify additional environment variables to
  4525. pass to make in the build step. These are passed before the make
  4526. command. By default, empty.
  4527. * LIBFOO_MAKE_OPTS, to specify additional variables to pass to make
  4528. in the build step. These are passed after the make command. By
  4529. default, empty.
  4530. * LIBFOO_INSTALL_OPTS contains the make options used to install the
  4531. package to the host directory. By default, the value is install,
  4532. which is correct for most CMake packages. It is still possible to
  4533. override it.
  4534. * LIBFOO_INSTALL_STAGING_OPTS contains the make options used to
  4535. install the package to the staging directory. By default, the
  4536. value is DESTDIR=$(STAGING_DIR) install/fast, which is correct
  4537. for most CMake packages. It is still possible to override it.
  4538. * LIBFOO_INSTALL_TARGET_OPTS contains the make options used to
  4539. install the package to the target directory. By default, the
  4540. value is DESTDIR=$(TARGET_DIR) install/fast. The default value is
  4541. correct for most CMake packages, but it is still possible to
  4542. override it if needed.
  4543. With the CMake infrastructure, all the steps required to build and
  4544. install the packages are already defined, and they generally work
  4545. well for most CMake-based packages. However, when required, it is
  4546. still possible to customize what is done in any particular step:
  4547. * By adding a post-operation hook (after extract, patch, configure,
  4548. build or install). See Section 18.23, “Hooks available in the
  4549. various build steps” for details.
  4550. * By overriding one of the steps. For example, even if the CMake
  4551. infrastructure is used, if the package .mk file defines its own
  4552. LIBFOO_CONFIGURE_CMDS variable, it will be used instead of the
  4553. default CMake one. However, using this method should be
  4554. restricted to very specific cases. Do not use it in the general
  4555. case.
  4556. 18.9. Infrastructure for Python packages
  4557. This infrastructure applies to Python packages that use the standard
  4558. Python setuptools, pep517, flit or maturin mechanisms as their build
  4559. system, generally recognizable by the usage of a setup.py script or
  4560. pyproject.toml file.
  4561. 18.9.1. python-package tutorial
  4562. First, let’s see how to write a .mk file for a Python package, with
  4563. an example :
  4564. 01: ################################################################################
  4565. 02: #
  4566. 03: # python-foo
  4567. 04: #
  4568. 05: ################################################################################
  4569. 06:
  4570. 07: PYTHON_FOO_VERSION = 1.0
  4571. 08: PYTHON_FOO_SOURCE = python-foo-$(PYTHON_FOO_VERSION).tar.xz
  4572. 09: PYTHON_FOO_SITE = http://www.foosoftware.org/download
  4573. 10: PYTHON_FOO_LICENSE = BSD-3-Clause
  4574. 11: PYTHON_FOO_LICENSE_FILES = LICENSE
  4575. 12: PYTHON_FOO_ENV = SOME_VAR=1
  4576. 13: PYTHON_FOO_DEPENDENCIES = libmad
  4577. 14: PYTHON_FOO_SETUP_TYPE = setuptools
  4578. 15:
  4579. 16: $(eval $(python-package))
  4580. On line 7, we declare the version of the package.
  4581. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  4582. recommended) and the location of the tarball on the Web. Buildroot
  4583. will automatically download the tarball from this location.
  4584. On line 10 and 11, we give licensing details about the package (its
  4585. license on line 10, and the file containing the license text on line
  4586. 11).
  4587. On line 12, we tell Buildroot to pass custom options to the Python
  4588. setup.py script when it is configuring the package.
  4589. On line 13, we declare our dependencies, so that they are built
  4590. before the build process of our package starts.
  4591. On line 14, we declare the specific Python build system being used.
  4592. In this case the setuptools Python build system is used. The five
  4593. supported ones are flit, pep517, setuptools, setuptools-rust and
  4594. maturin.
  4595. Finally, on line 16, we invoke the python-package macro that
  4596. generates all the Makefile rules that actually allow the package to
  4597. be built.
  4598. 18.9.2. python-package reference
  4599. As a policy, packages that merely provide Python modules should all
  4600. be named python-<something> in Buildroot. Other packages that use the
  4601. Python build system, but are not Python modules, can freely choose
  4602. their name (existing examples in Buildroot are scons and supervisor).
  4603. The main macro of the Python package infrastructure is
  4604. python-package. It is similar to the generic-package macro. It is
  4605. also possible to create Python host packages with the
  4606. host-python-package macro.
  4607. Just like the generic infrastructure, the Python infrastructure works
  4608. by defining a number of variables before calling the python-package
  4609. or host-python-package macros.
  4610. All the package metadata information variables that exist in the
  4611. generic package infrastructure also exist in the Python
  4612. infrastructure.
  4613. Note that:
  4614. * It is not necessary to add python or host-python in the
  4615. PYTHON_FOO_DEPENDENCIES variable of a package, since these basic
  4616. dependencies are automatically added as needed by the Python
  4617. package infrastructure.
  4618. * Similarly, it is not needed to add host-python-setuptools to
  4619. PYTHON_FOO_DEPENDENCIES for setuptools-based packages, since it’s
  4620. automatically added by the Python infrastructure as needed.
  4621. One variable specific to the Python infrastructure is mandatory:
  4622. * PYTHON_FOO_SETUP_TYPE, to define which Python build system is
  4623. used by the package. The five supported values are flit, pep517
  4624. and setuptools, setuptools-rust and maturin. If you don’t know
  4625. which one is used in your package, look at the setup.py or
  4626. pyproject.toml file in your package source code, and see whether
  4627. it imports things from the flit module or the setuptools module.
  4628. If the package is using a pyproject.toml file without any
  4629. build-system requires and with a local in-tree backend-path one
  4630. should use pep517.
  4631. A few additional variables, specific to the Python infrastructure,
  4632. can optionally be defined, depending on the package’s needs. Many of
  4633. them are only useful in very specific cases, typical packages will
  4634. therefore only use a few of them, or none.
  4635. * PYTHON_FOO_SUBDIR may contain the name of a subdirectory inside
  4636. the package that contains the main setup.py or pyproject.toml
  4637. file. This is useful, if for example, the main setup.py or
  4638. pyproject.toml file is not at the root of the tree extracted by
  4639. the tarball. If HOST_PYTHON_FOO_SUBDIR is not specified, it
  4640. defaults to PYTHON_FOO_SUBDIR.
  4641. * PYTHON_FOO_ENV, to specify additional environment variables to
  4642. pass to the Python setup.py script (for setuptools packages) or
  4643. the support/scripts/pyinstaller.py script (for flit/pep517
  4644. packages) for both the build and install steps. Note that the
  4645. infrastructure is automatically passing several standard
  4646. variables, defined in PKG_PYTHON_SETUPTOOLS_ENV (for setuptools
  4647. target packages), HOST_PKG_PYTHON_SETUPTOOLS_ENV (for setuptools
  4648. host packages), PKG_PYTHON_PEP517_ENV (for flit/pep517 target
  4649. packages) and HOST_PKG_PYTHON_PEP517_ENV (for flit/pep517 host
  4650. packages).
  4651. * PYTHON_FOO_BUILD_OPTS, to specify additional options to pass to
  4652. the Python setup.py script during the build step, this generally
  4653. only makes sense to use for setuptools based packages as flit/
  4654. pep517 based packages do not pass these options to a setup.py
  4655. script but instead pass them to support/scripts/pyinstaller.py.
  4656. * PYTHON_FOO_INSTALL_TARGET_OPTS, PYTHON_FOO_INSTALL_STAGING_OPTS,
  4657. HOST_PYTHON_FOO_INSTALL_OPTS to specify additional options to
  4658. pass to the Python setup.py script (for setuptools packages) or
  4659. support/scripts/pyinstaller.py (for flit/pep517 packages) during
  4660. the target installation step, the staging installation step or
  4661. the host installation, respectively.
  4662. With the Python infrastructure, all the steps required to build and
  4663. install the packages are already defined, and they generally work
  4664. well for most Python-based packages. However, when required, it is
  4665. still possible to customize what is done in any particular step:
  4666. * By adding a post-operation hook (after extract, patch, configure,
  4667. build or install). See Section 18.23, “Hooks available in the
  4668. various build steps” for details.
  4669. * By overriding one of the steps. For example, even if the Python
  4670. infrastructure is used, if the package .mk file defines its own
  4671. PYTHON_FOO_BUILD_CMDS variable, it will be used instead of the
  4672. default Python one. However, using this method should be
  4673. restricted to very specific cases. Do not use it in the general
  4674. case.
  4675. 18.9.3. Generating a python-package from a PyPI repository
  4676. If the Python package for which you would like to create a Buildroot
  4677. package is available on PyPI, you may want to use the scanpypi tool
  4678. located in utils/ to automate the process.
  4679. You can find the list of existing PyPI packages here [https://
  4680. pypi.python.org].
  4681. scanpypi requires Python’s setuptools package to be installed on your
  4682. host.
  4683. When at the root of your buildroot directory just do :
  4684. utils/scanpypi foo bar -o package
  4685. This will generate packages python-foo and python-bar in the package
  4686. folder if they exist on https://pypi.python.org.
  4687. Find the external python modules menu and insert your package inside.
  4688. Keep in mind that the items inside a menu should be in alphabetical
  4689. order.
  4690. Please keep in mind that you’ll most likely have to manually check
  4691. the package for any mistakes as there are things that cannot be
  4692. guessed by the generator (e.g. dependencies on any of the python core
  4693. modules such as BR2_PACKAGE_PYTHON_ZLIB). Also, please take note that
  4694. the license and license files are guessed and must be checked. You
  4695. also need to manually add the package to the package/Config.in file.
  4696. If your Buildroot package is not in the official Buildroot tree but
  4697. in a br2-external tree, use the -o flag as follows:
  4698. utils/scanpypi foo bar -o other_package_dir
  4699. This will generate packages python-foo and python-bar in the
  4700. other_package_directory instead of package.
  4701. Option -h will list the available options:
  4702. utils/scanpypi -h
  4703. 18.9.4. python-package CFFI backend
  4704. C Foreign Function Interface for Python (CFFI) provides a convenient
  4705. and reliable way to call compiled C code from Python using interface
  4706. declarations written in C. Python packages relying on this backend
  4707. can be identified by the appearance of a cffi dependency in the
  4708. install_requires field of their setup.py file.
  4709. Such a package should:
  4710. * add python-cffi as a runtime dependency in order to install the
  4711. compiled C library wrapper on the target. This is achieved by
  4712. adding select BR2_PACKAGE_PYTHON_CFFI to the package Config.in.
  4713. config BR2_PACKAGE_PYTHON_FOO
  4714. bool "python-foo"
  4715. select BR2_PACKAGE_PYTHON_CFFI # runtime
  4716. * add host-python-cffi as a build-time dependency in order to
  4717. cross-compile the C wrapper. This is achieved by adding
  4718. host-python-cffi to the PYTHON_FOO_DEPENDENCIES variable.
  4719. ################################################################################
  4720. #
  4721. # python-foo
  4722. #
  4723. ################################################################################
  4724. ...
  4725. PYTHON_FOO_DEPENDENCIES = host-python-cffi
  4726. $(eval $(python-package))
  4727. 18.10. Infrastructure for LuaRocks-based packages
  4728. 18.10.1. luarocks-package tutorial
  4729. First, let’s see how to write a .mk file for a LuaRocks-based
  4730. package, with an example :
  4731. 01: ################################################################################
  4732. 02: #
  4733. 03: # lua-foo
  4734. 04: #
  4735. 05: ################################################################################
  4736. 06:
  4737. 07: LUA_FOO_VERSION = 1.0.2-1
  4738. 08: LUA_FOO_NAME_UPSTREAM = foo
  4739. 09: LUA_FOO_DEPENDENCIES = bar
  4740. 10:
  4741. 11: LUA_FOO_BUILD_OPTS += BAR_INCDIR=$(STAGING_DIR)/usr/include
  4742. 12: LUA_FOO_BUILD_OPTS += BAR_LIBDIR=$(STAGING_DIR)/usr/lib
  4743. 13: LUA_FOO_LICENSE = luaFoo license
  4744. 14: LUA_FOO_LICENSE_FILES = $(LUA_FOO_SUBDIR)/COPYING
  4745. 15:
  4746. 16: $(eval $(luarocks-package))
  4747. On line 7, we declare the version of the package (the same as in the
  4748. rockspec, which is the concatenation of the upstream version and the
  4749. rockspec revision, separated by a hyphen -).
  4750. On line 8, we declare that the package is called "foo" on LuaRocks.
  4751. In Buildroot, we give Lua-related packages a name that starts with
  4752. "lua", so the Buildroot name is different from the upstream name.
  4753. LUA_FOO_NAME_UPSTREAM makes the link between the two names.
  4754. On line 9, we declare our dependencies against native libraries, so
  4755. that they are built before the build process of our package starts.
  4756. On lines 11-12, we tell Buildroot to pass custom options to LuaRocks
  4757. when it is building the package.
  4758. On lines 13-14, we specify the licensing terms for the package.
  4759. Finally, on line 16, we invoke the luarocks-package macro that
  4760. generates all the Makefile rules that actually allows the package to
  4761. be built.
  4762. Most of these details can be retrieved from the rock and rockspec.
  4763. So, this file and the Config.in file can be generated by running the
  4764. command luarocks buildroot foo lua-foo in the Buildroot directory.
  4765. This command runs a specific Buildroot addon of luarocks that will
  4766. automatically generate a Buildroot package. The result must still be
  4767. manually inspected and possibly modified.
  4768. * The package/Config.in file has to be updated manually to include
  4769. the generated Config.in files.
  4770. 18.10.2. luarocks-package reference
  4771. LuaRocks is a deployment and management system for Lua modules, and
  4772. supports various build.type: builtin, make and cmake. In the context
  4773. of Buildroot, the luarocks-package infrastructure only supports the
  4774. builtin mode. LuaRocks packages that use the make or cmake build
  4775. mechanisms should instead be packaged using the generic-package and
  4776. cmake-package infrastructures in Buildroot, respectively.
  4777. The main macro of the LuaRocks package infrastructure is
  4778. luarocks-package: like generic-package it works by defining a number
  4779. of variables providing metadata information about the package, and
  4780. then calling the luarocks-package macro.
  4781. Just like the generic infrastructure, the LuaRocks infrastructure
  4782. works by defining a number of variables before calling the
  4783. luarocks-package macro.
  4784. All the package metadata information variables that exist in the
  4785. generic package infrastructure also exist in the LuaRocks
  4786. infrastructure.
  4787. Two of them are populated by the LuaRocks infrastructure (for the
  4788. download step). If your package is not hosted on the LuaRocks mirror
  4789. $(BR2_LUAROCKS_MIRROR), you can override them:
  4790. * LUA_FOO_SITE, which defaults to $(BR2_LUAROCKS_MIRROR)
  4791. * LUA_FOO_SOURCE, which defaults to $(lowercase
  4792. LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).src.rock
  4793. A few additional variables, specific to the LuaRocks infrastructure,
  4794. are also defined. They can be overridden in specific cases.
  4795. * LUA_FOO_NAME_UPSTREAM, which defaults to lua-foo, i.e. the
  4796. Buildroot package name
  4797. * LUA_FOO_ROCKSPEC, which defaults to $(lowercase
  4798. LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).rockspec
  4799. * LUA_FOO_SUBDIR, which defaults to $(LUA_FOO_NAME_UPSTREAM)-$
  4800. (LUA_FOO_VERSION_WITHOUT_ROCKSPEC_REVISION)
  4801. * LUA_FOO_BUILD_OPTS contains additional build options for the
  4802. luarocks build call.
  4803. 18.11. Infrastructure for Perl/CPAN packages
  4804. 18.11.1. perl-package tutorial
  4805. First, let’s see how to write a .mk file for a Perl/CPAN package,
  4806. with an example :
  4807. 01: ################################################################################
  4808. 02: #
  4809. 03: # perl-foo-bar
  4810. 04: #
  4811. 05: ################################################################################
  4812. 06:
  4813. 07: PERL_FOO_BAR_VERSION = 0.02
  4814. 08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz
  4815. 09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER
  4816. 10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures
  4817. 11: PERL_FOO_BAR_LICENSE = Artistic or GPL-1.0+
  4818. 12: PERL_FOO_BAR_LICENSE_FILES = LICENSE
  4819. 13: PERL_FOO_BAR_DISTNAME = Foo-Bar
  4820. 14:
  4821. 15: $(eval $(perl-package))
  4822. On line 7, we declare the version of the package.
  4823. On line 8 and 9, we declare the name of the tarball and the location
  4824. of the tarball on a CPAN server. Buildroot will automatically
  4825. download the tarball from this location.
  4826. On line 10, we declare our dependencies, so that they are built
  4827. before the build process of our package starts.
  4828. On line 11 and 12, we give licensing details about the package (its
  4829. license on line 11, and the file containing the license text on line
  4830. 12).
  4831. On line 13, the name of the distribution as needed by the script
  4832. utils/scancpan (in order to regenerate/upgrade these package files).
  4833. Finally, on line 15, we invoke the perl-package macro that generates
  4834. all the Makefile rules that actually allow the package to be built.
  4835. Most of these data can be retrieved from https://metacpan.org/. So,
  4836. this file and the Config.in can be generated by running the script
  4837. utils/scancpan Foo-Bar in the Buildroot directory (or in a
  4838. br2-external tree). This script creates a Config.in file and
  4839. foo-bar.mk file for the requested package, and also recursively for
  4840. all dependencies specified by CPAN. You should still manually edit
  4841. the result. In particular, the following things should be checked.
  4842. * If the perl module links with a shared library that is provided
  4843. by another (non-perl) package, this dependency is not added
  4844. automatically. It has to be added manually to
  4845. PERL_FOO_BAR_DEPENDENCIES.
  4846. * The package/Config.in file has to be updated manually to include
  4847. the generated Config.in files. As a hint, the scancpan script
  4848. prints out the required source "…" statements, sorted
  4849. alphabetically.
  4850. 18.11.2. perl-package reference
  4851. As a policy, packages that provide Perl/CPAN modules should all be
  4852. named perl-<something> in Buildroot.
  4853. This infrastructure handles various Perl build systems :
  4854. ExtUtils-MakeMaker (EUMM), Module-Build (MB) and Module-Build-Tiny.
  4855. Build.PL is preferred by default when a package provides a
  4856. Makefile.PL and a Build.PL.
  4857. The main macro of the Perl/CPAN package infrastructure is
  4858. perl-package. It is similar to the generic-package macro. The ability
  4859. to have target and host packages is also available, with the
  4860. host-perl-package macro.
  4861. Just like the generic infrastructure, the Perl/CPAN infrastructure
  4862. works by defining a number of variables before calling the
  4863. perl-package macro.
  4864. All the package metadata information variables that exist in the
  4865. generic package infrastructure also exist in the Perl/CPAN
  4866. infrastructure.
  4867. Note that setting PERL_FOO_INSTALL_STAGING to YES has no effect
  4868. unless a PERL_FOO_INSTALL_STAGING_CMDS variable is defined. The perl
  4869. infrastructure doesn’t define these commands since Perl modules
  4870. generally don’t need to be installed to the staging directory.
  4871. A few additional variables, specific to the Perl/CPAN infrastructure,
  4872. can also be defined. Many of them are only useful in very specific
  4873. cases, typical packages will therefore only use a few of them.
  4874. * PERL_FOO_PREFER_INSTALLER/HOST_PERL_FOO_PREFER_INSTALLER,
  4875. specifies the preferred installation method. Possible values are
  4876. EUMM (for Makefile.PL based installation using
  4877. ExtUtils-MakeMaker) and MB (for Build.PL based installation using
  4878. Module-Build). This variable is only used when the package
  4879. provides both installation methods.
  4880. * PERL_FOO_CONF_ENV/HOST_PERL_FOO_CONF_ENV, to specify additional
  4881. environment variables to pass to the perl Makefile.PL or perl
  4882. Build.PL. By default, empty.
  4883. * PERL_FOO_CONF_OPTS/HOST_PERL_FOO_CONF_OPTS, to specify additional
  4884. configure options to pass to the perl Makefile.PL or perl
  4885. Build.PL. By default, empty.
  4886. * PERL_FOO_BUILD_OPTS/HOST_PERL_FOO_BUILD_OPTS, to specify
  4887. additional options to pass to make pure_all or perl Build build
  4888. in the build step. By default, empty.
  4889. * PERL_FOO_INSTALL_TARGET_OPTS, to specify additional options to
  4890. pass to make pure_install or perl Build install in the install
  4891. step. By default, empty.
  4892. * HOST_PERL_FOO_INSTALL_OPTS, to specify additional options to pass
  4893. to make pure_install or perl Build install in the install step.
  4894. By default, empty.
  4895. 18.12. Infrastructure for virtual packages
  4896. In Buildroot, a virtual package is a package whose functionalities
  4897. are provided by one or more packages, referred to as providers. The
  4898. virtual package management is an extensible mechanism allowing the
  4899. user to choose the provider used in the rootfs.
  4900. For example, OpenGL ES is an API for 2D and 3D graphics on embedded
  4901. systems. The implementation of this API is different for the
  4902. Allwinner Tech Sunxi and the Texas Instruments OMAP35xx platforms. So
  4903. libgles will be a virtual package and sunxi-mali-utgard and ti-gfx
  4904. will be the providers.
  4905. 18.12.1. virtual-package tutorial
  4906. In the following example, we will explain how to add a new virtual
  4907. package (something-virtual) and a provider for it (some-provider).
  4908. First, let’s create the virtual package.
  4909. 18.12.2. Virtual package’s Config.in file
  4910. The Config.in file of virtual package something-virtual should
  4911. contain:
  4912. 01: config BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  4913. 02: bool
  4914. 03:
  4915. 04: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  4916. 05: depends on BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  4917. 06: string
  4918. In this file, we declare two options,
  4919. BR2_PACKAGE_HAS_SOMETHING_VIRTUAL and
  4920. BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL, whose values will be used by
  4921. the providers.
  4922. 18.12.3. Virtual package’s .mk file
  4923. The .mk for the virtual package should just evaluate the
  4924. virtual-package macro:
  4925. 01: ################################################################################
  4926. 02: #
  4927. 03: # something-virtual
  4928. 04: #
  4929. 05: ################################################################################
  4930. 06:
  4931. 07: $(eval $(virtual-package))
  4932. The ability to have target and host packages is also available, with
  4933. the host-virtual-package macro.
  4934. 18.12.4. Provider’s Config.in file
  4935. When adding a package as a provider, only the Config.in file requires
  4936. some modifications.
  4937. The Config.in file of the package some-provider, which provides the
  4938. functionalities of something-virtual, should contain:
  4939. 01: config BR2_PACKAGE_SOME_PROVIDER
  4940. 02: bool "some-provider"
  4941. 03: select BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  4942. 04: help
  4943. 05: This is a comment that explains what some-provider is.
  4944. 06:
  4945. 07: http://foosoftware.org/some-provider/
  4946. 08:
  4947. 09: if BR2_PACKAGE_SOME_PROVIDER
  4948. 10: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  4949. 11: default "some-provider"
  4950. 12: endif
  4951. On line 3, we select BR2_PACKAGE_HAS_SOMETHING_VIRTUAL, and on line
  4952. 11, we set the value of BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL to the
  4953. name of the provider, but only if it is selected.
  4954. 18.12.5. Provider’s .mk file
  4955. The .mk file should also declare an additional variable
  4956. SOME_PROVIDER_PROVIDES to contain the names of all the virtual
  4957. packages it is an implementation of:
  4958. 01: SOME_PROVIDER_PROVIDES = something-virtual
  4959. Of course, do not forget to add the proper build and runtime
  4960. dependencies for this package!
  4961. 18.12.6. Notes on depending on a virtual package
  4962. When adding a package that requires a certain FEATURE provided by a
  4963. virtual package, you have to use depends on BR2_PACKAGE_HAS_FEATURE,
  4964. like so:
  4965. config BR2_PACKAGE_HAS_FEATURE
  4966. bool
  4967. config BR2_PACKAGE_FOO
  4968. bool "foo"
  4969. depends on BR2_PACKAGE_HAS_FEATURE
  4970. 18.12.7. Notes on depending on a specific provider
  4971. If your package really requires a specific provider, then you’ll have
  4972. to make your package depends on this provider; you can not select a
  4973. provider.
  4974. Let’s take an example with two providers for a FEATURE:
  4975. config BR2_PACKAGE_HAS_FEATURE
  4976. bool
  4977. config BR2_PACKAGE_FOO
  4978. bool "foo"
  4979. select BR2_PACKAGE_HAS_FEATURE
  4980. config BR2_PACKAGE_BAR
  4981. bool "bar"
  4982. select BR2_PACKAGE_HAS_FEATURE
  4983. And you are adding a package that needs FEATURE as provided by foo,
  4984. but not as provided by bar.
  4985. If you were to use select BR2_PACKAGE_FOO, then the user would still
  4986. be able to select BR2_PACKAGE_BAR in the menuconfig. This would
  4987. create a configuration inconsistency, whereby two providers of the
  4988. same FEATURE would be enabled at once, one explicitly set by the
  4989. user, the other implicitly by your select.
  4990. Instead, you have to use depends on BR2_PACKAGE_FOO, which avoids any
  4991. implicit configuration inconsistency.
  4992. 18.13. Infrastructure for packages using kconfig for configuration
  4993. files
  4994. A popular way for a software package to handle user-specified
  4995. configuration is kconfig. Among others, it is used by the Linux
  4996. kernel, Busybox, and Buildroot itself. The presence of a .config file
  4997. and a menuconfig target are two well-known symptoms of kconfig being
  4998. used.
  4999. Buildroot features an infrastructure for packages that use kconfig
  5000. for their configuration. This infrastructure provides the necessary
  5001. logic to expose the package’s menuconfig target as foo-menuconfig in
  5002. Buildroot, and to handle the copying back and forth of the
  5003. configuration file in a correct way.
  5004. The main macro of the kconfig package infrastructure is
  5005. kconfig-package. It is similar to the generic-package macro.
  5006. Just like the generic infrastructure, the kconfig infrastructure
  5007. works by defining a number of variables before calling the
  5008. kconfig-package macro.
  5009. All the package metadata information variables that exist in the
  5010. generic package infrastructure also exist in the kconfig
  5011. infrastructure.
  5012. In order to use the kconfig-package infrastructure for a Buildroot
  5013. package, the minimally required lines in the .mk file, in addition to
  5014. the variables required by the generic-package infrastructure, are:
  5015. FOO_KCONFIG_FILE = reference-to-source-configuration-file
  5016. $(eval $(kconfig-package))
  5017. This snippet creates the following make targets:
  5018. * foo-menuconfig, which calls the package’s menuconfig target
  5019. * foo-update-config, which copies the configuration back to the
  5020. source configuration file. It is not possible to use this target
  5021. when fragment files are set.
  5022. * foo-update-defconfig, which copies the configuration back to the
  5023. source configuration file. The configuration file will only list
  5024. the options that differ from the default values. It is not
  5025. possible to use this target when fragment files are set.
  5026. * foo-diff-config, which outputs the differences between the
  5027. current configuration and the one defined in the Buildroot
  5028. configuration for this kconfig package. The output is useful to
  5029. identify the configuration changes that may have to be propagated
  5030. to configuration fragments for example.
  5031. and ensures that the source configuration file is copied to the build
  5032. directory at the right moment.
  5033. There are two options to specify a configuration file to use, either
  5034. FOO_KCONFIG_FILE (as in the example, above) or FOO_KCONFIG_DEFCONFIG.
  5035. It is mandatory to provide either, but not both:
  5036. * FOO_KCONFIG_FILE specifies the path to a defconfig or full-config
  5037. file to be used to configure the package.
  5038. * FOO_KCONFIG_DEFCONFIG specifies the defconfig make rule to call
  5039. to configure the package.
  5040. In addition to these minimally required lines, several optional
  5041. variables can be set to suit the needs of the package under
  5042. consideration:
  5043. * FOO_KCONFIG_EDITORS: a space-separated list of kconfig editors to
  5044. support, for example menuconfig xconfig. By default, menuconfig.
  5045. * FOO_KCONFIG_FRAGMENT_FILES: a space-separated list of
  5046. configuration fragment files that are merged to the main
  5047. configuration file. Fragment files are typically used when there
  5048. is a desire to stay in sync with an upstream (def)config file,
  5049. with some minor modifications.
  5050. * FOO_KCONFIG_OPTS: extra options to pass when calling the kconfig
  5051. editors. This may need to include $(FOO_MAKE_OPTS), for example.
  5052. By default, empty.
  5053. * FOO_KCONFIG_FIXUP_CMDS: a list of shell commands needed to fixup
  5054. the configuration file after copying it or running a kconfig
  5055. editor. Such commands may be needed to ensure a configuration
  5056. consistent with other configuration of Buildroot, for example. By
  5057. default, empty.
  5058. * FOO_KCONFIG_DOTCONFIG: path (with filename) of the .config file,
  5059. relative to the package source tree. The default, .config, should
  5060. be well suited for all packages that use the standard kconfig
  5061. infrastructure as inherited from the Linux kernel; some packages
  5062. use a derivative of kconfig that use a different location.
  5063. * FOO_KCONFIG_DEPENDENCIES: the list of packages (most probably,
  5064. host packages) that need to be built before this package’s
  5065. kconfig is interpreted. Seldom used. By default, empty.
  5066. * FOO_KCONFIG_SUPPORTS_DEFCONFIG: whether the package’s kconfig
  5067. system supports using defconfig files; few packages do not. By
  5068. default, YES.
  5069. 18.14. Infrastructure for rebar-based packages
  5070. 18.14.1. rebar-package tutorial
  5071. First, let’s see how to write a .mk file for a rebar-based package,
  5072. with an example :
  5073. 01: ################################################################################
  5074. 02: #
  5075. 03: # erlang-foobar
  5076. 04: #
  5077. 05: ################################################################################
  5078. 06:
  5079. 07: ERLANG_FOOBAR_VERSION = 1.0
  5080. 08: ERLANG_FOOBAR_SOURCE = erlang-foobar-$(ERLANG_FOOBAR_VERSION).tar.xz
  5081. 09: ERLANG_FOOBAR_SITE = http://www.foosoftware.org/download
  5082. 10: ERLANG_FOOBAR_DEPENDENCIES = host-libaaa libbbb
  5083. 11:
  5084. 12: $(eval $(rebar-package))
  5085. On line 7, we declare the version of the package.
  5086. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  5087. recommended) and the location of the tarball on the Web. Buildroot
  5088. will automatically download the tarball from this location.
  5089. On line 10, we declare our dependencies, so that they are built
  5090. before the build process of our package starts.
  5091. Finally, on line 12, we invoke the rebar-package macro that generates
  5092. all the Makefile rules that actually allows the package to be built.
  5093. 18.14.2. rebar-package reference
  5094. The main macro of the rebar package infrastructure is rebar-package.
  5095. It is similar to the generic-package macro. The ability to have host
  5096. packages is also available, with the host-rebar-package macro.
  5097. Just like the generic infrastructure, the rebar infrastructure works
  5098. by defining a number of variables before calling the rebar-package
  5099. macro.
  5100. All the package metadata information variables that exist in the
  5101. generic package infrastructure also exist in the rebar
  5102. infrastructure.
  5103. A few additional variables, specific to the rebar infrastructure, can
  5104. also be defined. Many of them are only useful in very specific cases,
  5105. typical packages will therefore only use a few of them.
  5106. * ERLANG_FOOBAR_USE_AUTOCONF, to specify that the package uses
  5107. autoconf at the configuration step. When a package sets this
  5108. variable to YES, the autotools infrastructure is used.
  5109. Note. You can also use some of the variables from the autotools
  5110. infrastructure: ERLANG_FOOBAR_CONF_ENV, ERLANG_FOOBAR_CONF_OPTS,
  5111. ERLANG_FOOBAR_AUTORECONF, ERLANG_FOOBAR_AUTORECONF_ENV and
  5112. ERLANG_FOOBAR_AUTORECONF_OPTS.
  5113. * ERLANG_FOOBAR_USE_BUNDLED_REBAR, to specify that the package has
  5114. a bundled version of rebar and that it shall be used. Valid
  5115. values are YES or NO (the default).
  5116. Note. If the package bundles a rebar utility, but can use the
  5117. generic one that Buildroot provides, just say NO (i.e., do not
  5118. specify this variable). Only set if it is mandatory to use the
  5119. rebar utility bundled in this package.
  5120. * ERLANG_FOOBAR_REBAR_ENV, to specify additional environment
  5121. variables to pass to the rebar utility.
  5122. * ERLANG_FOOBAR_KEEP_DEPENDENCIES, to keep the dependencies
  5123. described in the rebar.config file. Valid values are YES or NO
  5124. (the default). Unless this variable is set to YES, the rebar
  5125. infrastructure removes such dependencies in a post-patch hook to
  5126. ensure rebar does not download nor compile them.
  5127. With the rebar infrastructure, all the steps required to build and
  5128. install the packages are already defined, and they generally work
  5129. well for most rebar-based packages. However, when required, it is
  5130. still possible to customize what is done in any particular step:
  5131. * By adding a post-operation hook (after extract, patch, configure,
  5132. build or install). See Section 18.23, “Hooks available in the
  5133. various build steps” for details.
  5134. * By overriding one of the steps. For example, even if the rebar
  5135. infrastructure is used, if the package .mk file defines its own
  5136. ERLANG_FOOBAR_BUILD_CMDS variable, it will be used instead of the
  5137. default rebar one. However, using this method should be
  5138. restricted to very specific cases. Do not use it in the general
  5139. case.
  5140. 18.15. Infrastructure for Waf-based packages
  5141. 18.15.1. waf-package tutorial
  5142. First, let’s see how to write a .mk file for a Waf-based package,
  5143. with an example :
  5144. 01: ################################################################################
  5145. 02: #
  5146. 03: # libfoo
  5147. 04: #
  5148. 05: ################################################################################
  5149. 06:
  5150. 07: LIBFOO_VERSION = 1.0
  5151. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  5152. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  5153. 10: LIBFOO_CONF_OPTS = --enable-bar --disable-baz
  5154. 11: LIBFOO_DEPENDENCIES = bar
  5155. 12:
  5156. 13: $(eval $(waf-package))
  5157. On line 7, we declare the version of the package.
  5158. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  5159. recommended) and the location of the tarball on the Web. Buildroot
  5160. will automatically download the tarball from this location.
  5161. On line 10, we tell Buildroot what options to enable for libfoo.
  5162. On line 11, we tell Buildroot the dependencies of libfoo.
  5163. Finally, on line line 13, we invoke the waf-package macro that
  5164. generates all the Makefile rules that actually allows the package to
  5165. be built.
  5166. 18.15.2. waf-package reference
  5167. The main macro of the Waf package infrastructure is waf-package. It
  5168. is similar to the generic-package macro.
  5169. Just like the generic infrastructure, the Waf infrastructure works by
  5170. defining a number of variables before calling the waf-package macro.
  5171. All the package metadata information variables that exist in the
  5172. generic package infrastructure also exist in the Waf infrastructure.
  5173. A few additional variables, specific to the Waf infrastructure, can
  5174. also be defined.
  5175. * LIBFOO_SUBDIR may contain the name of a subdirectory inside the
  5176. package that contains the main wscript file. This is useful, if
  5177. for example, the main wscript file is not at the root of the tree
  5178. extracted by the tarball. If HOST_LIBFOO_SUBDIR is not specified,
  5179. it defaults to LIBFOO_SUBDIR.
  5180. * LIBFOO_NEEDS_EXTERNAL_WAF can be set to YES or NO to tell
  5181. Buildroot to use the bundled waf executable. If set to NO, the
  5182. default, then Buildroot will use the waf executable provided in
  5183. the package source tree; if set to YES, then Buildroot will
  5184. download, install waf as a host tool and use it to build the
  5185. package.
  5186. * LIBFOO_WAF_OPTS, to specify additional options to pass to the waf
  5187. script at every step of the package build process: configure,
  5188. build and installation. By default, empty.
  5189. * LIBFOO_CONF_OPTS, to specify additional options to pass to the
  5190. waf script for the configuration step. By default, empty.
  5191. * LIBFOO_BUILD_OPTS, to specify additional options to pass to the
  5192. waf script during the build step. By default, empty.
  5193. * LIBFOO_INSTALL_STAGING_OPTS, to specify additional options to
  5194. pass to the waf script during the staging installation step. By
  5195. default, empty.
  5196. * LIBFOO_INSTALL_TARGET_OPTS, to specify additional options to pass
  5197. to the waf script during the target installation step. By
  5198. default, empty.
  5199. 18.16. Infrastructure for Meson-based packages
  5200. 18.16.1. meson-package tutorial
  5201. Meson [http://mesonbuild.com] is an open source build system meant to
  5202. be both extremely fast, and, even more importantly, as user friendly
  5203. as possible. It uses Ninja [https://ninja-build.org] as a companion
  5204. tool to perform the actual build operations.
  5205. Let’s see how to write a .mk file for a Meson-based package, with an
  5206. example:
  5207. 01: ################################################################################
  5208. 02: #
  5209. 03: # foo
  5210. 04: #
  5211. 05: ################################################################################
  5212. 06:
  5213. 07: FOO_VERSION = 1.0
  5214. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
  5215. 09: FOO_SITE = http://www.foosoftware.org/download
  5216. 10: FOO_LICENSE = GPL-3.0+
  5217. 11: FOO_LICENSE_FILES = COPYING
  5218. 12: FOO_INSTALL_STAGING = YES
  5219. 13:
  5220. 14: FOO_DEPENDENCIES = host-pkgconf bar
  5221. 15:
  5222. 16: ifeq ($(BR2_PACKAGE_BAZ),y)
  5223. 17: FOO_CONF_OPTS += -Dbaz=true
  5224. 18: FOO_DEPENDENCIES += baz
  5225. 19: else
  5226. 20: FOO_CONF_OPTS += -Dbaz=false
  5227. 21: endif
  5228. 22:
  5229. 23: $(eval $(meson-package))
  5230. The Makefile starts with the definition of the standard variables for
  5231. package declaration (lines 7 to 11).
  5232. On line line 23, we invoke the meson-package macro that generates all
  5233. the Makefile rules that actually allows the package to be built.
  5234. In the example, host-pkgconf and bar are declared as dependencies in
  5235. FOO_DEPENDENCIES at line 14 because the Meson build file of foo uses
  5236. pkg-config to determine the compilation flags and libraries of
  5237. package bar.
  5238. Note that it is not necessary to add host-meson in the
  5239. FOO_DEPENDENCIES variable of a package, since this basic dependency
  5240. is automatically added as needed by the Meson package infrastructure.
  5241. If the "baz" package is selected, then support for the "baz" feature
  5242. in "foo" is activated by adding -Dbaz=true to FOO_CONF_OPTS at line
  5243. 17, as specified in the meson_options.txt file in "foo" source tree.
  5244. The "baz" package is also added to FOO_DEPENDENCIES. Note that the
  5245. support for baz is explicitly disabled at line 20, if the package is
  5246. not selected.
  5247. To sum it up, to add a new meson-based package, the Makefile example
  5248. can be copied verbatim then edited to replace all occurrences of FOO
  5249. with the uppercase name of the new package and update the values of
  5250. the standard variables.
  5251. 18.16.2. meson-package reference
  5252. The main macro of the Meson package infrastructure is meson-package.
  5253. It is similar to the generic-package macro. The ability to have
  5254. target and host packages is also available, with the
  5255. host-meson-package macro.
  5256. Just like the generic infrastructure, the Meson infrastructure works
  5257. by defining a number of variables before calling the meson-package
  5258. macro.
  5259. All the package metadata information variables that exist in the
  5260. generic package infrastructure also exist in the Meson
  5261. infrastructure.
  5262. A few additional variables, specific to the Meson infrastructure, can
  5263. also be defined. Many of them are only useful in very specific cases,
  5264. typical packages will therefore only use a few of them.
  5265. * FOO_SUBDIR may contain the name of a subdirectory inside the
  5266. package that contains the main meson.build file. This is useful,
  5267. if for example, the main meson.build file is not at the root of
  5268. the tree extracted by the tarball. If HOST_FOO_SUBDIR is not
  5269. specified, it defaults to FOO_SUBDIR.
  5270. * FOO_CONF_ENV, to specify additional environment variables to pass
  5271. to meson for the configuration step. By default, empty.
  5272. * FOO_CONF_OPTS, to specify additional options to pass to meson for
  5273. the configuration step. By default, empty.
  5274. * FOO_CFLAGS, to specify compiler arguments added to the package
  5275. specific cross-compile.conf file c_args property. By default, the
  5276. value of TARGET_CFLAGS.
  5277. * FOO_CXXFLAGS, to specify compiler arguments added to the package
  5278. specific cross-compile.conf file cpp_args property. By default,
  5279. the value of TARGET_CXXFLAGS.
  5280. * FOO_LDFLAGS, to specify compiler arguments added to the package
  5281. specific cross-compile.conf file c_link_args and cpp_link_args
  5282. properties. By default, the value of TARGET_LDFLAGS.
  5283. * FOO_MESON_EXTRA_BINARIES, to specify a space-separated list of
  5284. programs to add to the [binaries] section of the meson
  5285. cross-compilation.conf configuration file. The format is
  5286. program-name='/path/to/program', with no space around the = sign,
  5287. and with the path of the program between single quotes. By
  5288. default, empty. Note that Buildroot already sets the correct
  5289. values for c, cpp, ar, strip, and pkgconfig.
  5290. * FOO_MESON_EXTRA_PROPERTIES, to specify a space-separated list of
  5291. properties to add to the [properties] section of the meson
  5292. cross-compilation.conf configuration file. The format is
  5293. property-name=<value> with no space around the = sign, and with
  5294. single quotes around string values. By default, empty. Note that
  5295. Buildroot already sets values for needs_exe_wrapper, c_args,
  5296. c_link_args, cpp_args, cpp_link_args, sys_root, and
  5297. pkg_config_libdir.
  5298. * FOO_NINJA_ENV, to specify additional environment variables to
  5299. pass to ninja, meson companion tool in charge of the build
  5300. operations. By default, empty.
  5301. * FOO_NINJA_OPTS, to specify a space-separated list of targets to
  5302. build. By default, empty, to build the default target(s).
  5303. 18.17. Infrastructure for Cargo-based packages
  5304. Cargo is the package manager for the Rust programming language. It
  5305. allows the user to build programs or libraries written in Rust, but
  5306. it also downloads and manages their dependencies, to ensure
  5307. repeatable builds. Cargo packages are called "crates".
  5308. 18.17.1. cargo-package tutorial
  5309. The Config.in file of Cargo-based package foo should contain:
  5310. 01: config BR2_PACKAGE_FOO
  5311. 02: bool "foo"
  5312. 03: depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
  5313. 04: select BR2_PACKAGE_HOST_RUSTC
  5314. 05: help
  5315. 06: This is a comment that explains what foo is.
  5316. 07:
  5317. 08: http://foosoftware.org/foo/
  5318. And the .mk file for this package should contain:
  5319. 01: ################################################################################
  5320. 02: #
  5321. 03: # foo
  5322. 04: #
  5323. 05: ################################################################################
  5324. 06:
  5325. 07: FOO_VERSION = 1.0
  5326. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
  5327. 09: FOO_SITE = http://www.foosoftware.org/download
  5328. 10: FOO_LICENSE = GPL-3.0+
  5329. 11: FOO_LICENSE_FILES = COPYING
  5330. 12:
  5331. 13: $(eval $(cargo-package))
  5332. The Makefile starts with the definition of the standard variables for
  5333. package declaration (lines 7 to 11).
  5334. As seen in line 13, it is based on the cargo-package infrastructure.
  5335. Cargo will be invoked automatically by this infrastructure to build
  5336. and install the package.
  5337. It is still possible to define custom build commands or install
  5338. commands (i.e. with FOO_BUILD_CMDS and FOO_INSTALL_TARGET_CMDS).
  5339. Those will then replace the commands from the cargo infrastructure.
  5340. 18.17.2. cargo-package reference
  5341. The main macros for the Cargo package infrastructure are
  5342. cargo-package for target packages and host-cargo-package for host
  5343. packages.
  5344. Just like the generic infrastructure, the Cargo infrastructure works
  5345. by defining a number of variables before calling the cargo-package or
  5346. host-cargo-package macros.
  5347. All the package metadata information variables that exist in the
  5348. generic package infrastructure also exist in the Cargo
  5349. infrastructure.
  5350. A few additional variables, specific to the Cargo infrastructure, can
  5351. also be defined. Many of them are only useful in very specific cases,
  5352. typical packages will therefore only use a few of them.
  5353. * FOO_SUBDIR may contain the name of a subdirectory inside the
  5354. package that contains the Cargo.toml file. This is useful, if for
  5355. example, it is not at the root of the tree extracted by the
  5356. tarball. If HOST_FOO_SUBDIR is not specified, it defaults to
  5357. FOO_SUBDIR.
  5358. * FOO_CARGO_ENV can be used to pass additional variables in the
  5359. environment of cargo invocations. It used at both build and
  5360. installation time
  5361. * FOO_CARGO_BUILD_OPTS can be used to pass additional options to
  5362. cargo at build time.
  5363. * FOO_CARGO_INSTALL_OPTS can be used to pass additional options to
  5364. cargo at install time.
  5365. A crate can depend on other libraries from crates.io or git
  5366. repositories, listed in its Cargo.toml file. Buildroot automatically
  5367. takes care of downloading such dependencies as part of the download
  5368. step of packages that use the cargo-package infrastructure. Such
  5369. dependencies are then kept together with the package source code in
  5370. the tarball cached in Buildroot’s DL_DIR, and therefore the hash of
  5371. the package’s tarball includes such dependencies.
  5372. This mechanism ensures that any change in the dependencies will be
  5373. detected, and allows the build to be performed completely offline.
  5374. 18.18. Infrastructure for Go packages
  5375. This infrastructure applies to Go packages that use the standard
  5376. build system and use bundled dependencies.
  5377. 18.18.1. golang-package tutorial
  5378. First, let’s see how to write a .mk file for a go package, with an
  5379. example :
  5380. 01: ################################################################################
  5381. 02: #
  5382. 03: # foo
  5383. 04: #
  5384. 05: ################################################################################
  5385. 06:
  5386. 07: FOO_VERSION = 1.0
  5387. 08: FOO_SITE = $(call github,bar,foo,$(FOO_VERSION))
  5388. 09: FOO_LICENSE = BSD-3-Clause
  5389. 10: FOO_LICENSE_FILES = LICENSE
  5390. 11:
  5391. 12: $(eval $(golang-package))
  5392. On line 7, we declare the version of the package.
  5393. On line 8, we declare the upstream location of the package, here
  5394. fetched from Github, since a large number of Go packages are hosted
  5395. on Github.
  5396. On line 9 and 10, we give licensing details about the package.
  5397. Finally, on line 12, we invoke the golang-package macro that
  5398. generates all the Makefile rules that actually allow the package to
  5399. be built.
  5400. 18.18.2. golang-package reference
  5401. In their Config.in file, packages using the golang-package
  5402. infrastructure should depend on
  5403. BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS because Buildroot will
  5404. automatically add a dependency on host-go to such packages. If you
  5405. need CGO support in your package, you must add a dependency on
  5406. BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS.
  5407. The main macro of the Go package infrastructure is golang-package. It
  5408. is similar to the generic-package macro. The ability to build host
  5409. packages is also available, with the host-golang-package macro. Host
  5410. packages built by host-golang-package macro should depend on
  5411. BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS.
  5412. Just like the generic infrastructure, the Go infrastructure works by
  5413. defining a number of variables before calling the golang-package
  5414. macro.
  5415. All the package metadata information variables that exist in the
  5416. generic package infrastructure also exist in the Go infrastructure.
  5417. Note that it is not necessary to add host-go in the FOO_DEPENDENCIES
  5418. variable of a package, since this basic dependency is automatically
  5419. added as needed by the Go package infrastructure.
  5420. A few additional variables, specific to the Go infrastructure, can
  5421. optionally be defined, depending on the package’s needs. Many of them
  5422. are only useful in very specific cases, typical packages will
  5423. therefore only use a few of them, or none.
  5424. * The package must specify its Go module name in the FOO_GOMOD
  5425. variable. If not specified, it defaults to URL-domain/
  5426. 1st-part-of-URL/2nd-part-of-URL, e.g FOO_GOMOD will take the
  5427. value github.com/bar/foo for a package that specifies FOO_SITE =
  5428. $(call github,bar,foo,$(FOO_VERSION)). The Go package
  5429. infrastructure will automatically generate a minimal go.mod file
  5430. in the package source tree if it doesn’t exist.
  5431. * FOO_LDFLAGS and FOO_TAGS can be used to pass respectively the
  5432. LDFLAGS or the TAGS to the go build command.
  5433. * FOO_BUILD_TARGETS can be used to pass the list of targets that
  5434. should be built. If FOO_BUILD_TARGETS is not specified, it
  5435. defaults to .. We then have two cases:
  5436. + FOO_BUILD_TARGETS is .. In this case, we assume only one
  5437. binary will be produced, and that by default we name it after
  5438. the package name. If that is not appropriate, the name of the
  5439. produced binary can be overridden using FOO_BIN_NAME.
  5440. + FOO_BUILD_TARGETS is not .. In this case, we iterate over the
  5441. values to build each target, and for each produced a binary
  5442. that is the non-directory component of the target. For
  5443. example if FOO_BUILD_TARGETS = cmd/docker cmd/dockerd the
  5444. binaries produced are docker and dockerd.
  5445. * FOO_INSTALL_BINS can be used to pass the list of binaries that
  5446. should be installed in /usr/bin on the target. If
  5447. FOO_INSTALL_BINS is not specified, it defaults to the lower-case
  5448. name of package.
  5449. With the Go infrastructure, all the steps required to build and
  5450. install the packages are already defined, and they generally work
  5451. well for most Go-based packages. However, when required, it is still
  5452. possible to customize what is done in any particular step:
  5453. * By adding a post-operation hook (after extract, patch, configure,
  5454. build or install). See Section 18.23, “Hooks available in the
  5455. various build steps” for details.
  5456. * By overriding one of the steps. For example, even if the Go
  5457. infrastructure is used, if the package .mk file defines its own
  5458. FOO_BUILD_CMDS variable, it will be used instead of the default
  5459. Go one. However, using this method should be restricted to very
  5460. specific cases. Do not use it in the general case.
  5461. A Go package can depend on other Go modules, listed in its go.mod
  5462. file. Buildroot automatically takes care of downloading such
  5463. dependencies as part of the download step of packages that use the
  5464. golang-package infrastructure. Such dependencies are then kept
  5465. together with the package source code in the tarball cached in
  5466. Buildroot’s DL_DIR, and therefore the hash of the package’s tarball
  5467. includes such dependencies.
  5468. This mechanism ensures that any change in the dependencies will be
  5469. detected, and allows the build to be performed completely offline.
  5470. 18.19. Infrastructure for QMake-based packages
  5471. 18.19.1. qmake-package tutorial
  5472. First, let’s see how to write a .mk file for a QMake-based package,
  5473. with an example :
  5474. 01: ################################################################################
  5475. 02: #
  5476. 03: # libfoo
  5477. 04: #
  5478. 05: ################################################################################
  5479. 06:
  5480. 07: LIBFOO_VERSION = 1.0
  5481. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  5482. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  5483. 10: LIBFOO_CONF_OPTS = QT_CONFIG+=bar QT_CONFIG-=baz
  5484. 11: LIBFOO_DEPENDENCIES = bar
  5485. 12:
  5486. 13: $(eval $(qmake-package))
  5487. On line 7, we declare the version of the package.
  5488. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  5489. recommended) and the location of the tarball on the Web. Buildroot
  5490. will automatically download the tarball from this location.
  5491. On line 10, we tell Buildroot what options to enable for libfoo.
  5492. On line 11, we tell Buildroot the dependencies of libfoo.
  5493. Finally, on line line 13, we invoke the qmake-package macro that
  5494. generates all the Makefile rules that actually allows the package to
  5495. be built.
  5496. 18.19.2. qmake-package reference
  5497. The main macro of the QMake package infrastructure is qmake-package.
  5498. It is similar to the generic-package macro.
  5499. Just like the generic infrastructure, the QMake infrastructure works
  5500. by defining a number of variables before calling the qmake-package
  5501. macro.
  5502. All the package metadata information variables that exist in the
  5503. generic package infrastructure also exist in the QMake
  5504. infrastructure.
  5505. A few additional variables, specific to the QMake infrastructure, can
  5506. also be defined.
  5507. * LIBFOO_CONF_ENV, to specify additional environment variables to
  5508. pass to the qmake script for the configuration step. By default,
  5509. empty.
  5510. * LIBFOO_CONF_OPTS, to specify additional options to pass to the
  5511. qmake script for the configuration step. By default, empty.
  5512. * LIBFOO_MAKE_ENV, to specify additional environment variables to
  5513. the make command during the build and install steps. By default,
  5514. empty.
  5515. * LIBFOO_MAKE_OPTS, to specify additional targets to pass to the
  5516. make command during the build step. By default, empty.
  5517. * LIBFOO_INSTALL_STAGING_OPTS, to specify additional targets to
  5518. pass to the make command during the staging installation step. By
  5519. default, install.
  5520. * LIBFOO_INSTALL_TARGET_OPTS, to specify additional targets to pass
  5521. to the make command during the target installation step. By
  5522. default, install.
  5523. * LIBFOO_SYNC_QT_HEADERS, to run syncqt.pl before qmake. Some
  5524. packages need this to have a properly populated include directory
  5525. before running the build.
  5526. 18.20. Infrastructure for packages building kernel modules
  5527. Buildroot offers a helper infrastructure to make it easy to write
  5528. packages that build and install Linux kernel modules. Some packages
  5529. only contain a kernel module, other packages contain programs and
  5530. libraries in addition to kernel modules. Buildroot’s helper
  5531. infrastructure supports either case.
  5532. 18.20.1. kernel-module tutorial
  5533. Let’s start with an example on how to prepare a simple package that
  5534. only builds a kernel module, and no other component:
  5535. 01: ################################################################################
  5536. 02: #
  5537. 03: # foo
  5538. 04: #
  5539. 05: ################################################################################
  5540. 06:
  5541. 07: FOO_VERSION = 1.2.3
  5542. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
  5543. 09: FOO_SITE = http://www.foosoftware.org/download
  5544. 10: FOO_LICENSE = GPL-2.0
  5545. 11: FOO_LICENSE_FILES = COPYING
  5546. 12:
  5547. 13: $(eval $(kernel-module))
  5548. 14: $(eval $(generic-package))
  5549. Lines 7-11 define the usual meta-data to specify the version, archive
  5550. name, remote URI where to find the package source, licensing
  5551. information.
  5552. On line 13, we invoke the kernel-module helper infrastructure, that
  5553. generates all the appropriate Makefile rules and variables to build
  5554. that kernel module.
  5555. Finally, on line 14, we invoke the generic-package infrastructure.
  5556. The dependency on linux is automatically added, so it is not needed
  5557. to specify it in FOO_DEPENDENCIES.
  5558. What you may have noticed is that, unlike other package
  5559. infrastructures, we explicitly invoke a second infrastructure. This
  5560. allows a package to build a kernel module, but also, if needed, use
  5561. any one of other package infrastructures to build normal userland
  5562. components (libraries, executables…). Using the kernel-module
  5563. infrastructure on its own is not sufficient; another package
  5564. infrastructure must be used.
  5565. Let’s look at a more complex example:
  5566. 01: ################################################################################
  5567. 02: #
  5568. 03: # foo
  5569. 04: #
  5570. 05: ################################################################################
  5571. 06:
  5572. 07: FOO_VERSION = 1.2.3
  5573. 08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
  5574. 09: FOO_SITE = http://www.foosoftware.org/download
  5575. 10: FOO_LICENSE = GPL-2.0
  5576. 11: FOO_LICENSE_FILES = COPYING
  5577. 12:
  5578. 13: FOO_MODULE_SUBDIRS = driver/base
  5579. 14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
  5580. 15:
  5581. 16: ifeq ($(BR2_PACKAGE_LIBBAR),y)
  5582. 17: FOO_DEPENDENCIES += libbar
  5583. 18: FOO_CONF_OPTS += --enable-bar
  5584. 19: FOO_MODULE_SUBDIRS += driver/bar
  5585. 20: else
  5586. 21: FOO_CONF_OPTS += --disable-bar
  5587. 22: endif
  5588. 23:
  5589. 24: $(eval $(kernel-module))
  5590. 26: $(eval $(autotools-package))
  5591. Here, we see that we have an autotools-based package, that also
  5592. builds the kernel module located in sub-directory driver/base and, if
  5593. libbar is enabled, the kernel module located in sub-directory driver/
  5594. bar, and defines the variable KVERSION to be passed to the Linux
  5595. buildsystem when building the module(s).
  5596. 18.20.2. kernel-module reference
  5597. The main macro for the kernel module infrastructure is kernel-module.
  5598. Unlike other package infrastructures, it is not stand-alone, and
  5599. requires any of the other *-package macros be called after it.
  5600. The kernel-module macro defines post-build and post-target-install
  5601. hooks to build the kernel modules. If the package’s .mk needs access
  5602. to the built kernel modules, it should do so in a post-build hook,
  5603. registered after the call to kernel-module. Similarly, if the
  5604. package’s .mk needs access to the kernel module after it has been
  5605. installed, it should do so in a post-install hook, registered after
  5606. the call to kernel-module. Here’s an example:
  5607. $(eval $(kernel-module))
  5608. define FOO_DO_STUFF_WITH_KERNEL_MODULE
  5609. # Do something with it...
  5610. endef
  5611. FOO_POST_BUILD_HOOKS += FOO_DO_STUFF_WITH_KERNEL_MODULE
  5612. $(eval $(generic-package))
  5613. Finally, unlike the other package infrastructures, there is no
  5614. host-kernel-module variant to build a host kernel module.
  5615. The following additional variables can optionally be defined to
  5616. further configure the build of the kernel module:
  5617. * FOO_MODULE_SUBDIRS may be set to one or more sub-directories
  5618. (relative to the package source top-directory) where the kernel
  5619. module sources are. If empty or not set, the sources for the
  5620. kernel module(s) are considered to be located at the top of the
  5621. package source tree.
  5622. * FOO_MODULE_MAKE_OPTS may be set to contain extra variable
  5623. definitions to pass to the Linux buildsystem.
  5624. You may also reference (but you may not set!) those variables:
  5625. * LINUX_DIR contains the path to where the Linux kernel has been
  5626. extracted and built.
  5627. * LINUX_VERSION contains the version string as configured by the
  5628. user.
  5629. * LINUX_VERSION_PROBED contains the real version string of the
  5630. kernel, retrieved with running make -C $(LINUX_DIR) kernelrelease
  5631. * KERNEL_ARCH contains the name of the current architecture, like
  5632. arm, mips…
  5633. 18.21. Infrastructure for asciidoc documents
  5634. The Buildroot manual, which you are currently reading, is entirely
  5635. written using the AsciiDoc [http://asciidoc.org/] mark-up syntax. The
  5636. manual is then rendered to many formats:
  5637. * html
  5638. * split-html
  5639. * pdf
  5640. * epub
  5641. * text
  5642. Although Buildroot only contains one document written in AsciiDoc,
  5643. there is, as for packages, an infrastructure for rendering documents
  5644. using the AsciiDoc syntax.
  5645. Also as for packages, the AsciiDoc infrastructure is available from a
  5646. br2-external tree. This allows documentation for a br2-external tree
  5647. to match the Buildroot documentation, as it will be rendered to the
  5648. same formats and use the same layout and theme.
  5649. 18.21.1. asciidoc-document tutorial
  5650. Whereas package infrastructures are suffixed with -package, the
  5651. document infrastructures are suffixed with -document. So, the
  5652. AsciiDoc infrastructure is named asciidoc-document.
  5653. Here is an example to render a simple AsciiDoc document.
  5654. 01: ################################################################################
  5655. 02: #
  5656. 03: # foo-document
  5657. 04: #
  5658. 05: ################################################################################
  5659. 06:
  5660. 07: FOO_SOURCES = $(sort $(wildcard $(FOO_DOCDIR)/*))
  5661. 08: $(eval $(call asciidoc-document))
  5662. On line 7, the Makefile declares what the sources of the document
  5663. are. Currently, it is expected that the document’s sources are only
  5664. local; Buildroot will not attempt to download anything to render a
  5665. document. Thus, you must indicate where the sources are. Usually, the
  5666. string above is sufficient for a document with no sub-directory
  5667. structure.
  5668. On line 8, we call the asciidoc-document function, which generates
  5669. all the Makefile code necessary to render the document.
  5670. 18.21.2. asciidoc-document reference
  5671. The list of variables that can be set in a .mk file to give metadata
  5672. information is (assuming the document name is foo) :
  5673. * FOO_SOURCES, mandatory, defines the source files for the
  5674. document.
  5675. * FOO_RESOURCES, optional, may contain a space-separated list of
  5676. paths to one or more directories containing so-called resources
  5677. (like CSS or images). By default, empty.
  5678. * FOO_DEPENDENCIES, optional, the list of packages (most probably,
  5679. host-packages) that must be built before building this document.
  5680. * FOO_TOC_DEPTH, FOO_TOC_DEPTH_<FMT>, optionals, the depth of the
  5681. table of content for this document, which can be overridden for
  5682. the specified format <FMT> (see the list of rendered formats,
  5683. above, but in uppercase, and with dash replaced by underscore;
  5684. see example, below). By default: 1.
  5685. There are also additional hooks (see Section 18.23, “Hooks available
  5686. in the various build steps” for general information on hooks), that a
  5687. document may set to define extra actions to be done at various steps:
  5688. * FOO_POST_RSYNC_HOOKS to run additional commands after the sources
  5689. have been copied by Buildroot. This can for example be used to
  5690. generate part of the manual with information extracted from the
  5691. tree. As an example, Buildroot uses this hook to generate the
  5692. tables in the appendices.
  5693. * FOO_CHECK_DEPENDENCIES_HOOKS to run additional tests on required
  5694. components to generate the document. In AsciiDoc, it is possible
  5695. to call filters, that is, programs that will parse an AsciiDoc
  5696. block and render it appropriately (e.g. ditaa [http://
  5697. ditaa.sourceforge.net/] or aafigure [https://pythonhosted.org/
  5698. aafigure/]).
  5699. * FOO_CHECK_DEPENDENCIES_<FMT>_HOOKS, to run additional tests for
  5700. the specified format <FMT> (see the list of rendered formats,
  5701. above).
  5702. Buildroot sets the following variable that can be used in the
  5703. definitions above:
  5704. * $(FOO_DOCDIR), similar to $(FOO_PKGDIR), contains the path to the
  5705. directory containing foo.mk. It can be used to refer to the
  5706. document sources, and can be used in the hooks, especially the
  5707. post-rsync hook if parts of the documentation needs to be
  5708. generated.
  5709. * $(@D), as for traditional packages, contains the path to the
  5710. directory where the document will be copied and built.
  5711. Here is a complete example that uses all variables and all hooks:
  5712. 01: ################################################################################
  5713. 02: #
  5714. 03: # foo-document
  5715. 04: #
  5716. 05: ################################################################################
  5717. 06:
  5718. 07: FOO_SOURCES = $(sort $(wildcard $(FOO_DOCDIR)/*))
  5719. 08: FOO_RESOURCES = $(sort $(wildcard $(FOO_DOCDIR)/resources))
  5720. 09:
  5721. 10: FOO_TOC_DEPTH = 2
  5722. 11: FOO_TOC_DEPTH_HTML = 1
  5723. 12: FOO_TOC_DEPTH_SPLIT_HTML = 3
  5724. 13:
  5725. 14: define FOO_GEN_EXTRA_DOC
  5726. 15: /path/to/generate-script --outdir=$(@D)
  5727. 16: endef
  5728. 17: FOO_POST_RSYNC_HOOKS += FOO_GEN_EXTRA_DOC
  5729. 18:
  5730. 19: define FOO_CHECK_MY_PROG
  5731. 20: if ! which my-prog >/dev/null 2>&1; then \
  5732. 21: echo "You need my-prog to generate the foo document"; \
  5733. 22: exit 1; \
  5734. 23: fi
  5735. 24: endef
  5736. 25: FOO_CHECK_DEPENDENCIES_HOOKS += FOO_CHECK_MY_PROG
  5737. 26:
  5738. 27: define FOO_CHECK_MY_OTHER_PROG
  5739. 28: if ! which my-other-prog >/dev/null 2>&1; then \
  5740. 29: echo "You need my-other-prog to generate the foo document as PDF"; \
  5741. 30: exit 1; \
  5742. 31: fi
  5743. 32: endef
  5744. 33: FOO_CHECK_DEPENDENCIES_PDF_HOOKS += FOO_CHECK_MY_OTHER_PROG
  5745. 34:
  5746. 35: $(eval $(call asciidoc-document))
  5747. 18.22. Infrastructure specific to the Linux kernel package
  5748. The Linux kernel package can use some specific infrastructures based
  5749. on package hooks for building Linux kernel tools or/and building
  5750. Linux kernel extensions.
  5751. 18.22.1. linux-kernel-tools
  5752. Buildroot offers a helper infrastructure to build some userspace
  5753. tools for the target available within the Linux kernel sources. Since
  5754. their source code is part of the kernel source code, a special
  5755. package, linux-tools, exists and re-uses the sources of the Linux
  5756. kernel that runs on the target.
  5757. Let’s look at an example of a Linux tool. For a new Linux tool named
  5758. foo, create a new menu entry in the existing package/linux-tools/
  5759. Config.in. This file will contain the option descriptions related to
  5760. each kernel tool that will be used and displayed in the configuration
  5761. tool. It would basically look like:
  5762. 01: config BR2_PACKAGE_LINUX_TOOLS_FOO
  5763. 02: bool "foo"
  5764. 03: select BR2_PACKAGE_LINUX_TOOLS
  5765. 04: help
  5766. 05: This is a comment that explains what foo kernel tool is.
  5767. 06:
  5768. 07: http://foosoftware.org/foo/
  5769. The name of the option starts with the prefix
  5770. BR2_PACKAGE_LINUX_TOOLS_, followed by the uppercase name of the tool
  5771. (like is done for packages).
  5772. Note. Unlike other packages, the linux-tools package options appear
  5773. in the linux kernel menu, under the Linux Kernel Tools sub-menu, not
  5774. under the Target packages main menu.
  5775. Then for each linux tool, add a new .mk.in file named package/
  5776. linux-tools/linux-tool-foo.mk.in. It would basically look like:
  5777. 01: ################################################################################
  5778. 02: #
  5779. 03: # foo
  5780. 04: #
  5781. 05: ################################################################################
  5782. 06:
  5783. 07: LINUX_TOOLS += foo
  5784. 08:
  5785. 09: FOO_DEPENDENCIES = libbbb
  5786. 10:
  5787. 11: define FOO_BUILD_CMDS
  5788. 12: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools foo
  5789. 13: endef
  5790. 14:
  5791. 15: define FOO_INSTALL_STAGING_CMDS
  5792. 16: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
  5793. 17: DESTDIR=$(STAGING_DIR) \
  5794. 18: foo_install
  5795. 19: endef
  5796. 20:
  5797. 21: define FOO_INSTALL_TARGET_CMDS
  5798. 22: $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
  5799. 23: DESTDIR=$(TARGET_DIR) \
  5800. 24: foo_install
  5801. 25: endef
  5802. On line 7, we register the Linux tool foo to the list of available
  5803. Linux tools.
  5804. On line 9, we specify the list of dependencies this tool relies on.
  5805. These dependencies are added to the Linux package dependencies list
  5806. only when the foo tool is selected.
  5807. The rest of the Makefile, lines 11-25 defines what should be done at
  5808. the different steps of the Linux tool build process like for a
  5809. generic package. They will actually be used only when the foo tool is
  5810. selected. The only supported commands are _BUILD_CMDS,
  5811. _INSTALL_STAGING_CMDS and _INSTALL_TARGET_CMDS.
  5812. Note. One must not call $(eval $(generic-package)) or any other
  5813. package infrastructure! Linux tools are not packages by themselves,
  5814. they are part of the linux-tools package.
  5815. 18.22.2. linux-kernel-extensions
  5816. Some packages provide new features that require the Linux kernel tree
  5817. to be modified. This can be in the form of patches to be applied on
  5818. the kernel tree, or in the form of new files to be added to the tree.
  5819. The Buildroot’s Linux kernel extensions infrastructure provides a
  5820. simple solution to automatically do this, just after the kernel
  5821. sources are extracted and before the kernel patches are applied.
  5822. Examples of extensions packaged using this mechanism are the
  5823. real-time extensions Xenomai and RTAI, as well as the set of
  5824. out-of-tree LCD screens drivers fbtft.
  5825. Let’s look at an example on how to add a new Linux extension foo.
  5826. First, create the package foo that provides the extension: this
  5827. package is a standard package; see the previous chapters on how to
  5828. create such a package. This package is in charge of downloading the
  5829. sources archive, checking the hash, defining the licence information
  5830. and building user space tools if any.
  5831. Then create the Linux extension proper: create a new menu entry in
  5832. the existing linux/Config.ext.in. This file contains the option
  5833. descriptions related to each kernel extension that will be used and
  5834. displayed in the configuration tool. It would basically look like:
  5835. 01: config BR2_LINUX_KERNEL_EXT_FOO
  5836. 02: bool "foo"
  5837. 03: help
  5838. 04: This is a comment that explains what foo kernel extension is.
  5839. 05:
  5840. 06: http://foosoftware.org/foo/
  5841. Then for each linux extension, add a new .mk file named linux/
  5842. linux-ext-foo.mk. It should basically contain:
  5843. 01: ################################################################################
  5844. 02: #
  5845. 03: # foo
  5846. 04: #
  5847. 05: ################################################################################
  5848. 06:
  5849. 07: LINUX_EXTENSIONS += foo
  5850. 08:
  5851. 09: define FOO_PREPARE_KERNEL
  5852. 10: $(FOO_DIR)/prepare-kernel-tree.sh --linux-dir=$(@D)
  5853. 11: endef
  5854. On line 7, we add the Linux extension foo to the list of available
  5855. Linux extensions.
  5856. On line 9-11, we define what should be done by the extension to
  5857. modify the Linux kernel tree; this is specific to the linux extension
  5858. and can use the variables defined by the foo package, like: $
  5859. (FOO_DIR) or $(FOO_VERSION)… as well as all the Linux variables,
  5860. like: $(LINUX_VERSION) or $(LINUX_VERSION_PROBED), $(KERNEL_ARCH)…
  5861. See the definition of those kernel variables.
  5862. 18.23. Hooks available in the various build steps
  5863. The generic infrastructure (and as a result also the derived
  5864. autotools and cmake infrastructures) allow packages to specify hooks.
  5865. These define further actions to perform after existing steps. Most
  5866. hooks aren’t really useful for generic packages, since the .mk file
  5867. already has full control over the actions performed in each step of
  5868. the package construction.
  5869. The following hook points are available:
  5870. * LIBFOO_PRE_DOWNLOAD_HOOKS
  5871. * LIBFOO_POST_DOWNLOAD_HOOKS
  5872. * LIBFOO_PRE_EXTRACT_HOOKS
  5873. * LIBFOO_POST_EXTRACT_HOOKS
  5874. * LIBFOO_PRE_RSYNC_HOOKS
  5875. * LIBFOO_POST_RSYNC_HOOKS
  5876. * LIBFOO_PRE_PATCH_HOOKS
  5877. * LIBFOO_POST_PATCH_HOOKS
  5878. * LIBFOO_PRE_CONFIGURE_HOOKS
  5879. * LIBFOO_POST_CONFIGURE_HOOKS
  5880. * LIBFOO_PRE_BUILD_HOOKS
  5881. * LIBFOO_POST_BUILD_HOOKS
  5882. * LIBFOO_PRE_INSTALL_HOOKS (for host packages only)
  5883. * LIBFOO_POST_INSTALL_HOOKS (for host packages only)
  5884. * LIBFOO_PRE_INSTALL_STAGING_HOOKS (for target packages only)
  5885. * LIBFOO_POST_INSTALL_STAGING_HOOKS (for target packages only)
  5886. * LIBFOO_PRE_INSTALL_TARGET_HOOKS (for target packages only)
  5887. * LIBFOO_POST_INSTALL_TARGET_HOOKS (for target packages only)
  5888. * LIBFOO_PRE_INSTALL_IMAGES_HOOKS
  5889. * LIBFOO_POST_INSTALL_IMAGES_HOOKS
  5890. * LIBFOO_PRE_LEGAL_INFO_HOOKS
  5891. * LIBFOO_POST_LEGAL_INFO_HOOKS
  5892. * LIBFOO_TARGET_FINALIZE_HOOKS
  5893. These variables are lists of variable names containing actions to be
  5894. performed at this hook point. This allows several hooks to be
  5895. registered at a given hook point. Here is an example:
  5896. define LIBFOO_POST_PATCH_FIXUP
  5897. action1
  5898. action2
  5899. endef
  5900. LIBFOO_POST_PATCH_HOOKS += LIBFOO_POST_PATCH_FIXUP
  5901. 18.23.1. Using the POST_RSYNC hook
  5902. The POST_RSYNC hook is run only for packages that use a local source,
  5903. either through the local site method or the OVERRIDE_SRCDIR
  5904. mechanism. In this case, package sources are copied using rsync from
  5905. the local location into the buildroot build directory. The rsync
  5906. command does not copy all files from the source directory, though.
  5907. Files belonging to a version control system, like the directories
  5908. .git, .hg, etc. are not copied. For most packages this is sufficient,
  5909. but a given package can perform additional actions using the
  5910. POST_RSYNC hook.
  5911. In principle, the hook can contain any command you want. One specific
  5912. use case, though, is the intentional copying of the version control
  5913. directory using rsync. The rsync command you use in the hook can,
  5914. among others, use the following variables:
  5915. * $(SRCDIR): the path to the overridden source directory
  5916. * $(@D): the path to the build directory
  5917. 18.23.2. Target-finalize hook
  5918. Packages may also register hooks in LIBFOO_TARGET_FINALIZE_HOOKS.
  5919. These hooks are run after all packages are built, but before the
  5920. filesystem images are generated. They are seldom used, and your
  5921. package probably do not need them.
  5922. 18.24. Gettext integration and interaction with packages
  5923. Many packages that support internationalization use the gettext
  5924. library. Dependencies for this library are fairly complicated and
  5925. therefore, deserve some explanation.
  5926. The glibc C library integrates a full-blown implementation of gettext
  5927. , supporting translation. Native Language Support is therefore
  5928. built-in in glibc.
  5929. On the other hand, the uClibc and musl C libraries only provide a
  5930. stub implementation of the gettext functionality, which allows to
  5931. compile libraries and programs using gettext functions, but without
  5932. providing the translation capabilities of a full-blown gettext
  5933. implementation. With such C libraries, if real Native Language
  5934. Support is necessary, it can be provided by the libintl library of
  5935. the gettext package.
  5936. Due to this, and in order to make sure that Native Language Support
  5937. is properly handled, packages in Buildroot that can use NLS support
  5938. should:
  5939. 1. Ensure NLS support is enabled when BR2_SYSTEM_ENABLE_NLS=y. This
  5940. is done automatically for autotools packages and therefore should
  5941. only be done for packages using other package infrastructures.
  5942. 2. Add $(TARGET_NLS_DEPENDENCIES) to the package <pkg>_DEPENDENCIES
  5943. variable. This addition should be done unconditionally: the value
  5944. of this variable is automatically adjusted by the core
  5945. infrastructure to contain the relevant list of packages. If NLS
  5946. support is disabled, this variable is empty. If NLS support is
  5947. enabled, this variable contains host-gettext so that tools needed
  5948. to compile translation files are available on the host. In
  5949. addition, if uClibc or musl are used, this variable also contains
  5950. gettext in order to get the full-blown gettext implementation.
  5951. 3. If needed, add $(TARGET_NLS_LIBS) to the linker flags, so that
  5952. the package gets linked with libintl. This is generally not
  5953. needed with autotools packages as they usually detect
  5954. automatically that they should link with libintl. However,
  5955. packages using other build systems, or problematic
  5956. autotools-based packages may need this. $(TARGET_NLS_LIBS) should
  5957. be added unconditionally to the linker flags, as the core
  5958. automatically makes it empty or defined to -lintl depending on
  5959. the configuration.
  5960. No changes should be made to the Config.in file to support NLS.
  5961. Finally, certain packages need some gettext utilities on the target,
  5962. such as the gettext program itself, which allows to retrieve
  5963. translated strings, from the command line. In such a case, the
  5964. package should:
  5965. * use select BR2_PACKAGE_GETTEXT in their Config.in file,
  5966. indicating in a comment above that it’s a runtime dependency
  5967. only.
  5968. * not add any gettext dependency in the DEPENDENCIES variable of
  5969. their .mk file.
  5970. 18.25. Tips and tricks
  5971. 18.25.1. Package name, config entry name and makefile variable
  5972. relationship
  5973. In Buildroot, there is some relationship between:
  5974. * the package name, which is the package directory name (and the
  5975. name of the *.mk file);
  5976. * the config entry name that is declared in the Config.in file;
  5977. * the makefile variable prefix.
  5978. It is mandatory to maintain consistency between these elements, using
  5979. the following rules:
  5980. * the package directory and the *.mk name are the package name
  5981. itself (e.g.: package/foo-bar_boo/foo-bar_boo.mk);
  5982. * the make target name is the package name itself (e.g.:
  5983. foo-bar_boo);
  5984. * the config entry is the upper case package name with . and -
  5985. characters substituted with _, prefixed with BR2_PACKAGE_ (e.g.:
  5986. BR2_PACKAGE_FOO_BAR_BOO);
  5987. * the *.mk file variable prefix is the upper case package name with
  5988. . and - characters substituted with _ (e.g.:
  5989. FOO_BAR_BOO_VERSION).
  5990. 18.25.2. How to check the coding style
  5991. Buildroot provides a script in utils/check-package that checks new or
  5992. changed files for coding style. It is not a complete language
  5993. validator, but it catches many common mistakes. It is meant to run in
  5994. the actual files you created or modified, before creating the patch
  5995. for submission.
  5996. This script can be used for packages, filesystem makefiles, Config.in
  5997. files, etc. It does not check the files defining the package
  5998. infrastructures and some other files containing similar common code.
  5999. To use it, run the check-package script, by telling which files you
  6000. created or changed:
  6001. $ ./utils/check-package package/new-package/*
  6002. If you have the utils directory in your path you can also run:
  6003. $ cd package/new-package/
  6004. $ check-package *
  6005. The tool can also be used for packages in a br2-external:
  6006. $ check-package -b /path/to/br2-ext-tree/package/my-package/*
  6007. The check-package script requires you install shellcheck and the
  6008. Python PyPi packages flake8 and python-magic. The Buildroot code base
  6009. is currently tested against version 0.7.1 of ShellCheck. If you use a
  6010. different version of ShellCheck, you may see additional, unfixed,
  6011. warnings.
  6012. If you have Docker or Podman you can run check-package without
  6013. installing dependencies:
  6014. $ ./utils/docker-run ./utils/check-package
  6015. 18.25.3. How to test your package
  6016. Once you have added your new package, it is important that you test
  6017. it under various conditions: does it build for all architectures?
  6018. Does it build with the different C libraries? Does it need threads,
  6019. NPTL? And so on…
  6020. Buildroot runs autobuilders [http://autobuild.buildroot.org/] which
  6021. continuously test random configurations. However, these only build
  6022. the master branch of the git tree, and your new fancy package is not
  6023. yet there.
  6024. Buildroot provides a script in utils/test-pkg that uses the same base
  6025. configurations as used by the autobuilders so you can test your
  6026. package in the same conditions.
  6027. First, create a config snippet that contains all the necessary
  6028. options needed to enable your package, but without any architecture
  6029. or toolchain option. For example, let’s create a config snippet that
  6030. just enables libcurl, without any TLS backend:
  6031. $ cat libcurl.config
  6032. BR2_PACKAGE_LIBCURL=y
  6033. If your package needs more configuration options, you can add them to
  6034. the config snippet. For example, here’s how you would test libcurl
  6035. with openssl as a TLS backend and the curl program:
  6036. $ cat libcurl.config
  6037. BR2_PACKAGE_LIBCURL=y
  6038. BR2_PACKAGE_LIBCURL_CURL=y
  6039. BR2_PACKAGE_OPENSSL=y
  6040. Then run the test-pkg script, by telling it what config snippet to
  6041. use and what package to test:
  6042. $ ./utils/test-pkg -c libcurl.config -p libcurl
  6043. By default, test-pkg will build your package against a subset of the
  6044. toolchains used by the autobuilders, which has been selected by the
  6045. Buildroot developers as being the most useful and representative
  6046. subset. If you want to test all toolchains, pass the -a option. Note
  6047. that in any case, internal toolchains are excluded as they take too
  6048. long to build.
  6049. The output lists all toolchains that are tested and the corresponding
  6050. result (excerpt, results are fake):
  6051. $ ./utils/test-pkg -c libcurl.config -p libcurl
  6052. armv5-ctng-linux-gnueabi [ 1/11]: OK
  6053. armv7-ctng-linux-gnueabihf [ 2/11]: OK
  6054. br-aarch64-glibc [ 3/11]: SKIPPED
  6055. br-arcle-hs38 [ 4/11]: SKIPPED
  6056. br-arm-basic [ 5/11]: FAILED
  6057. br-arm-cortex-a9-glibc [ 6/11]: OK
  6058. br-arm-cortex-a9-musl [ 7/11]: FAILED
  6059. br-arm-cortex-m4-full [ 8/11]: OK
  6060. br-arm-full [ 9/11]: OK
  6061. br-arm-full-nothread [10/11]: FAILED
  6062. br-arm-full-static [11/11]: OK
  6063. 11 builds, 2 skipped, 2 build failed, 1 legal-info failed
  6064. The results mean:
  6065. * OK: the build was successful.
  6066. * SKIPPED: one or more configuration options listed in the config
  6067. snippet were not present in the final configuration. This is due
  6068. to options having dependencies not satisfied by the toolchain,
  6069. such as for example a package that depends on BR2_USE_MMU with a
  6070. noMMU toolchain. The missing options are reported in
  6071. missing.config in the output build directory (~/br-test-pkg/
  6072. TOOLCHAIN_NAME/ by default).
  6073. * FAILED: the build failed. Inspect the logfile file in the output
  6074. build directory to see what went wrong:
  6075. + the actual build failed,
  6076. + the legal-info failed,
  6077. + one of the preliminary steps (downloading the config file,
  6078. applying the configuration, running dirclean for the package)
  6079. failed.
  6080. When there are failures, you can just re-run the script with the same
  6081. options (after you fixed your package); the script will attempt to
  6082. re-build the package specified with -p for all toolchains, without
  6083. the need to re-build all the dependencies of that package.
  6084. The test-pkg script accepts a few options, for which you can get some
  6085. help by running:
  6086. $ ./utils/test-pkg -h
  6087. 18.25.4. How to add a package from GitHub
  6088. Packages on GitHub often don’t have a download area with release
  6089. tarballs. However, it is possible to download tarballs directly from
  6090. the repository on GitHub. As GitHub is known to have changed download
  6091. mechanisms in the past, the github helper function should be used as
  6092. shown below.
  6093. # Use a tag or a full commit ID
  6094. FOO_VERSION = 1.0
  6095. FOO_SITE = $(call github,<user>,<package>,v$(FOO_VERSION))
  6096. Notes
  6097. * The FOO_VERSION can either be a tag or a commit ID.
  6098. * The tarball name generated by github matches the default one from
  6099. Buildroot (e.g.:
  6100. foo-f6fb6654af62045239caed5950bc6c7971965e60.tar.gz), so it is
  6101. not necessary to specify it in the .mk file.
  6102. * When using a commit ID as version, you should use the full 40 hex
  6103. characters.
  6104. * When the tag contains a prefix such as v in v1.0, then the
  6105. VERSION variable should contain just 1.0, and the v should be
  6106. added directly in the SITE variable, as illustrated above. This
  6107. ensures that the VERSION variable value can be used to match
  6108. against release-monitoring.org [http://www.release-monitoring.org
  6109. /] results.
  6110. If the package you wish to add does have a release section on GitHub,
  6111. the maintainer may have uploaded a release tarball, or the release
  6112. may just point to the automatically generated tarball from the git
  6113. tag. If there is a release tarball uploaded by the maintainer, we
  6114. prefer to use that since it may be slightly different (e.g. it
  6115. contains a configure script so we don’t need to do AUTORECONF).
  6116. You can see on the release page if it’s an uploaded tarball or a git
  6117. tag:
  6118. * If it looks like the image above then it was uploaded by the
  6119. maintainer and you should use that link (in that example:
  6120. mongrel2-v1.9.2.tar.bz2) to specify FOO_SITE, and not use the
  6121. github helper.
  6122. * On the other hand, if there’s is only the "Source code" link,
  6123. then it’s an automatically generated tarball and you should use
  6124. the github helper function.
  6125. 18.25.5. How to add a package from Gitlab
  6126. In a similar way to the github macro described in Section 18.25.4,
  6127. “How to add a package from GitHub”, Buildroot also provides the
  6128. gitlab macro to download from Gitlab repositories. It can be used to
  6129. download auto-generated tarballs produced by Gitlab, either for
  6130. specific tags or commits:
  6131. # Use a tag or a full commit ID
  6132. FOO_VERSION = 1.0
  6133. FOO_SITE = $(call gitlab,<user>,<package>,v$(FOO_VERSION))
  6134. By default, it will use a .tar.gz tarball, but Gitlab also provides
  6135. .tar.bz2 tarballs, so by adding a <pkg>_SOURCE variable, this
  6136. .tar.bz2 tarball can be used:
  6137. # Use a tag or a full commit ID
  6138. FOO_VERSION = 1.0
  6139. FOO_SITE = $(call gitlab,<user>,<package>,v$(FOO_VERSION))
  6140. FOO_SOURCE = foo-$(FOO_VERSION).tar.bz2
  6141. If there is a specific tarball uploaded by the upstream developers in
  6142. https://gitlab.com/<project>/releases/, do not use this macro, but
  6143. rather use directly the link to the tarball.
  6144. 18.26. Conclusion
  6145. As you can see, adding a software package to Buildroot is simply a
  6146. matter of writing a Makefile using an existing example and modifying
  6147. it according to the compilation process required by the package.
  6148. If you package software that might be useful for other people, don’t
  6149. forget to send a patch to the Buildroot mailing list (see
  6150. Section 22.5, “Submitting patches”)!
  6151. Chapter 19. Patching a package
  6152. While integrating a new package or updating an existing one, it may
  6153. be necessary to patch the source of the software to get it
  6154. cross-built within Buildroot.
  6155. Buildroot offers an infrastructure to automatically handle this
  6156. during the builds. It supports three ways of applying patch sets:
  6157. downloaded patches, patches supplied within buildroot and patches
  6158. located in a user-defined global patch directory.
  6159. 19.1. Providing patches
  6160. 19.1.1. Downloaded
  6161. If it is necessary to apply a patch that is available for download,
  6162. then add it to the <packagename>_PATCH variable. If an entry contains
  6163. ://, then Buildroot will assume it is a full URL and download the
  6164. patch from this location. Otherwise, Buildroot will assume that the
  6165. patch should be downloaded from <packagename>_SITE. It can be a
  6166. single patch, or a tarball containing a patch series.
  6167. Like for all downloads, a hash should be added to the
  6168. <packagename>.hash file.
  6169. This method is typically used for packages from Debian.
  6170. 19.1.2. Within Buildroot
  6171. Most patches are provided within Buildroot, in the package directory;
  6172. these typically aim to fix cross-compilation, libc support, or other
  6173. such issues.
  6174. These patch files should be named <number>-<description>.patch.
  6175. Notes
  6176. * The patch files coming with Buildroot should not contain any
  6177. package version reference in their filename.
  6178. * The field <number> in the patch file name refers to the apply
  6179. order, and shall start at 1; It is preferred to pad the number
  6180. with zeros up to 4 digits, like git-format-patch does. E.g.:
  6181. 0001-foobar-the-buz.patch
  6182. * The patch email subject prefix shall not be numbered. Patches
  6183. shall be generated with the git format-patch -N command, since
  6184. this numbering is automatically added for series. For example,
  6185. the patch subject line should look like Subject: [PATCH] foobar
  6186. the buz rather than Subject: [PATCH n/m] foobar the buz.
  6187. * Previously, it was mandatory for patches to be prefixed with the
  6188. name of the package, like <package>-<number>-<description>.patch,
  6189. but that is no longer the case. Existing packages will be fixed
  6190. as time passes. Do not prefix patches with the package name.
  6191. * Previously, a series file, as used by quilt, could also be added
  6192. in the package directory. In that case, the series file defines
  6193. the patch application order. This is deprecated, and will be
  6194. removed in the future. Do not use a series file.
  6195. 19.1.3. Global patch directory
  6196. The BR2_GLOBAL_PATCH_DIR configuration file option can be used to
  6197. specify a space separated list of one or more directories containing
  6198. global package patches. See Section 9.8.1, “Providing extra patches”
  6199. for details.
  6200. 19.2. How patches are applied
  6201. 1. Run the <packagename>_PRE_PATCH_HOOKS commands if defined;
  6202. 2. Cleanup the build directory, removing any existing *.rej files;
  6203. 3. If <packagename>_PATCH is defined, then patches from these
  6204. tarballs are applied;
  6205. 4. If there are some *.patch files in the package’s Buildroot
  6206. directory or in a package subdirectory named <packageversion>,
  6207. then:
  6208. + If a series file exists in the package directory, then
  6209. patches are applied according to the series file;
  6210. + Otherwise, patch files matching *.patch are applied in
  6211. alphabetical order. So, to ensure they are applied in the
  6212. right order, it is highly recommended to name the patch files
  6213. like this: <number>-<description>.patch, where <number>
  6214. refers to the apply order.
  6215. 5. If BR2_GLOBAL_PATCH_DIR is defined, the directories will be
  6216. enumerated in the order they are specified. The patches are
  6217. applied as described in the previous step.
  6218. 6. Run the <packagename>_POST_PATCH_HOOKS commands if defined.
  6219. If something goes wrong in the steps 3 or 4, then the build fails.
  6220. 19.3. Format and licensing of the package patches
  6221. Patches are released under the same license as the software they
  6222. apply to (see Section 13.2, “Complying with the Buildroot license”).
  6223. A message explaining what the patch does, and why it is needed,
  6224. should be added in the header commentary of the patch.
  6225. You should add a Signed-off-by statement in the header of the each
  6226. patch to help with keeping track of the changes and to certify that
  6227. the patch is released under the same license as the software that is
  6228. modified.
  6229. If the software is under version control, it is recommended to use
  6230. the upstream SCM software to generate the patch set.
  6231. Otherwise, concatenate the header with the output of the diff -purN
  6232. package-version.orig/ package-version/ command.
  6233. If you update an existing patch (e.g. when bumping the package
  6234. version), make sure the existing From header and Signed-off-by tags
  6235. are not removed, but do update the rest of the patch comment when
  6236. appropriate.
  6237. At the end, the patch should look like:
  6238. configure.ac: add C++ support test
  6239. Signed-off-by: John Doe <john.doe@noname.org>
  6240. --- configure.ac.orig
  6241. +++ configure.ac
  6242. @@ -40,2 +40,12 @@
  6243. AC_PROG_MAKE_SET
  6244. +
  6245. +AC_CACHE_CHECK([whether the C++ compiler works],
  6246. + [rw_cv_prog_cxx_works],
  6247. + [AC_LANG_PUSH([C++])
  6248. + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  6249. + [rw_cv_prog_cxx_works=yes],
  6250. + [rw_cv_prog_cxx_works=no])
  6251. + AC_LANG_POP([C++])])
  6252. +
  6253. +AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"])
  6254. 19.4. Additional patch documentation
  6255. Ideally, all patches should document an upstream patch or patch
  6256. submission, when applicable, via the Upstream trailer.
  6257. When backporting an upstream patch that has been accepted into
  6258. mainline, it is preferred that the URL to the commit is referenced:
  6259. Upstream: <URL to upstream commit>
  6260. If a new issue is identified in Buildroot and upstream is generally
  6261. affected by the issue (it’s not a Buildroot specific issue), users
  6262. should submit the patch upstream and provide a link to that
  6263. submission when possible:
  6264. Upstream: <URL to upstream mailing list submission or merge request>
  6265. Patches that have been submitted but were denied upstream should note
  6266. that and include comments about why the patch is being used despite
  6267. the upstream status.
  6268. Note: in any of the above scenarios, it is also sensible to add a few
  6269. words about any changes to the patch that may have been necessary.
  6270. If a patch does not apply upstream then this should be noted with a
  6271. comment:
  6272. Upstream: N/A <additional information about why patch is Buildroot specific>
  6273. Adding this documentation helps streamline the patch review process
  6274. during package version updates.
  6275. Chapter 20. Download infrastructure
  6276. TODO
  6277. Chapter 21. Debugging Buildroot
  6278. It is possible to instrument the steps Buildroot does when building
  6279. packages. Define the variable BR2_INSTRUMENTATION_SCRIPTS to contain
  6280. the path of one or more scripts (or other executables), in a
  6281. space-separated list, you want called before and after each step. The
  6282. scripts are called in sequence, with three parameters:
  6283. * start or end to denote the start (resp. the end) of a step;
  6284. * the name of the step about to be started, or which just ended;
  6285. * the name of the package.
  6286. For example :
  6287. make BR2_INSTRUMENTATION_SCRIPTS="/path/to/my/script1 /path/to/my/script2"
  6288. The list of steps is:
  6289. * extract
  6290. * patch
  6291. * configure
  6292. * build
  6293. * install-host, when a host-package is installed in $(HOST_DIR)
  6294. * install-target, when a target-package is installed in $
  6295. (TARGET_DIR)
  6296. * install-staging, when a target-package is installed in $
  6297. (STAGING_DIR)
  6298. * install-image, when a target-package installs files in $
  6299. (BINARIES_DIR)
  6300. The script has access to the following variables:
  6301. * BR2_CONFIG: the path to the Buildroot .config file
  6302. * HOST_DIR, STAGING_DIR, TARGET_DIR: see Section 18.6.2,
  6303. “generic-package reference”
  6304. * BUILD_DIR: the directory where packages are extracted and built
  6305. * BINARIES_DIR: the place where all binary files (aka images) are
  6306. stored
  6307. * BASE_DIR: the base output directory
  6308. Chapter 22. Contributing to Buildroot
  6309. There are many ways in which you can contribute to Buildroot:
  6310. analyzing and fixing bugs, analyzing and fixing package build
  6311. failures detected by the autobuilders, testing and reviewing patches
  6312. sent by other developers, working on the items in our TODO list and
  6313. sending your own improvements to Buildroot or its manual. The
  6314. following sections give a little more detail on each of these items.
  6315. If you are interested in contributing to Buildroot, the first thing
  6316. you should do is to subscribe to the Buildroot mailing list. This
  6317. list is the main way of interacting with other Buildroot developers
  6318. and to send contributions to. If you aren’t subscribed yet, then
  6319. refer to Chapter 5, Community resources for the subscription link.
  6320. If you are going to touch the code, it is highly recommended to use a
  6321. git repository of Buildroot, rather than starting from an extracted
  6322. source code tarball. Git is the easiest way to develop from and
  6323. directly send your patches to the mailing list. Refer to Chapter 3,
  6324. Getting Buildroot for more information on obtaining a Buildroot git
  6325. tree.
  6326. 22.1. Reproducing, analyzing and fixing bugs
  6327. A first way of contributing is to have a look at the open bug reports
  6328. in the Buildroot bug tracker [https://bugs.buildroot.org/buglist.cgi?
  6329. product=buildroot]. As we strive to keep the bug count as small as
  6330. possible, all help in reproducing, analyzing and fixing reported bugs
  6331. is more than welcome. Don’t hesitate to add a comment to bug reports
  6332. reporting your findings, even if you don’t yet see the full picture.
  6333. 22.2. Analyzing and fixing autobuild failures
  6334. The Buildroot autobuilders are a set of build machines that
  6335. continuously run Buildroot builds based on random configurations.
  6336. This is done for all architectures supported by Buildroot, with
  6337. various toolchains, and with a random selection of packages. With the
  6338. large commit activity on Buildroot, these autobuilders are a great
  6339. help in detecting problems very early after commit.
  6340. All build results are available at http://autobuild.buildroot.org,
  6341. statistics are at http://autobuild.buildroot.org/stats.php. Every
  6342. day, an overview of all failed packages is sent to the mailing list.
  6343. Detecting problems is great, but obviously these problems have to be
  6344. fixed as well. Your contribution is very welcome here! There are
  6345. basically two things that can be done:
  6346. * Analyzing the problems. The daily summary mails do not contain
  6347. details about the actual failures: in order to see what’s going
  6348. on you have to open the build log and check the last output.
  6349. Having someone doing this for all packages in the mail is very
  6350. useful for other developers, as they can make a quick initial
  6351. analysis based on this output alone.
  6352. * Fixing a problem. When fixing autobuild failures, you should
  6353. follow these steps:
  6354. 1. Check if you can reproduce the problem by building with the
  6355. same configuration. You can do this manually, or use the
  6356. br-reproduce-build [http://git.buildroot.org/buildroot-test/
  6357. tree/utils/br-reproduce-build] script that will automatically
  6358. clone a Buildroot git repository, checkout the correct
  6359. revision, download and set the right configuration, and start
  6360. the build.
  6361. 2. Analyze the problem and create a fix.
  6362. 3. Verify that the problem is really fixed by starting from a
  6363. clean Buildroot tree and only applying your fix.
  6364. 4. Send the fix to the Buildroot mailing list (see Section 22.5,
  6365. “Submitting patches”). In case you created a patch against
  6366. the package sources, you should also send the patch upstream
  6367. so that the problem will be fixed in a later release, and the
  6368. patch in Buildroot can be removed. In the commit message of a
  6369. patch fixing an autobuild failure, add a reference to the
  6370. build result directory, as follows:
  6371. Fixes: http://autobuild.buildroot.org/results/51000a9d4656afe9e0ea6f07b9f8ed374c2e4069
  6372. 22.3. Reviewing and testing patches
  6373. With the amount of patches sent to the mailing list each day, the
  6374. maintainer has a very hard job to judge which patches are ready to
  6375. apply and which ones aren’t. Contributors can greatly help here by
  6376. reviewing and testing these patches.
  6377. In the review process, do not hesitate to respond to patch
  6378. submissions for remarks, suggestions or anything that will help
  6379. everyone to understand the patches and make them better. Please use
  6380. internet style replies in plain text emails when responding to patch
  6381. submissions.
  6382. To indicate approval of a patch, there are three formal tags that
  6383. keep track of this approval. To add your tag to a patch, reply to it
  6384. with the approval tag below the original author’s Signed-off-by line.
  6385. These tags will be picked up automatically by patchwork (see
  6386. Section 22.3.1, “Applying Patches from Patchwork”) and will be part
  6387. of the commit log when the patch is accepted.
  6388. Tested-by
  6389. Indicates that the patch has been tested successfully. You are
  6390. encouraged to specify what kind of testing you performed
  6391. (compile-test on architecture X and Y, runtime test on target A,
  6392. …). This additional information helps other testers and the
  6393. maintainer.
  6394. Reviewed-by
  6395. Indicates that you code-reviewed the patch and did your best in
  6396. spotting problems, but you are not sufficiently familiar with the
  6397. area touched to provide an Acked-by tag. This means that there
  6398. may be remaining problems in the patch that would be spotted by
  6399. someone with more experience in that area. Should such problems
  6400. be detected, your Reviewed-by tag remains appropriate and you
  6401. cannot be blamed.
  6402. Acked-by
  6403. Indicates that you code-reviewed the patch and you are familiar
  6404. enough with the area touched to feel that the patch can be
  6405. committed as-is (no additional changes required). In case it
  6406. later turns out that something is wrong with the patch, your
  6407. Acked-by could be considered inappropriate. The difference
  6408. between Acked-by and Reviewed-by is thus mainly that you are
  6409. prepared to take the blame on Acked patches, but not on Reviewed
  6410. ones.
  6411. If you reviewed a patch and have comments on it, you should simply
  6412. reply to the patch stating these comments, without providing a
  6413. Reviewed-by or Acked-by tag. These tags should only be provided if
  6414. you judge the patch to be good as it is.
  6415. It is important to note that neither Reviewed-by nor Acked-by imply
  6416. that testing has been performed. To indicate that you both reviewed
  6417. and tested the patch, provide two separate tags (Reviewed/Acked-by
  6418. and Tested-by).
  6419. Note also that any developer can provide Tested/Reviewed/Acked-by
  6420. tags, without exception, and we encourage everyone to do this.
  6421. Buildroot does not have a defined group of core developers, it just
  6422. so happens that some developers are more active than others. The
  6423. maintainer will value tags according to the track record of their
  6424. submitter. Tags provided by a regular contributor will naturally be
  6425. trusted more than tags provided by a newcomer. As you provide tags
  6426. more regularly, your trustworthiness (in the eyes of the maintainer)
  6427. will go up, but any tag provided is valuable.
  6428. Buildroot’s Patchwork website can be used to pull in patches for
  6429. testing purposes. Please see Section 22.3.1, “Applying Patches from
  6430. Patchwork” for more information on using Buildroot’s Patchwork
  6431. website to apply patches.
  6432. 22.3.1. Applying Patches from Patchwork
  6433. The main use of Buildroot’s Patchwork website for a developer is for
  6434. pulling in patches into their local git repository for testing
  6435. purposes.
  6436. When browsing patches in the patchwork management interface, an mbox
  6437. link is provided at the top of the page. Copy this link address and
  6438. run the following commands:
  6439. $ git checkout -b <test-branch-name>
  6440. $ wget -O - <mbox-url> | git am
  6441. Another option for applying patches is to create a bundle. A bundle
  6442. is a set of patches that you can group together using the patchwork
  6443. interface. Once the bundle is created and the bundle is made public,
  6444. you can copy the mbox link for the bundle and apply the bundle using
  6445. the above commands.
  6446. 22.4. Work on items from the TODO list
  6447. If you want to contribute to Buildroot but don’t know where to start,
  6448. and you don’t like any of the above topics, you can always work on
  6449. items from the Buildroot TODO list [http://elinux.org/Buildroot#
  6450. Todo_list]. Don’t hesitate to discuss an item first on the mailing
  6451. list or on IRC. Do edit the wiki to indicate when you start working
  6452. on an item, so we avoid duplicate efforts.
  6453. 22.5. Submitting patches
  6454. Note
  6455. Please, do not attach patches to bugs, send them to the mailing list
  6456. instead.
  6457. If you made some changes to Buildroot and you would like to
  6458. contribute them to the Buildroot project, proceed as follows.
  6459. 22.5.1. The formatting of a patch
  6460. We expect patches to be formatted in a specific way. This is
  6461. necessary to make it easy to review patches, to be able to apply them
  6462. easily to the git repository, to make it easy to find back in the
  6463. history how and why things have changed, and to make it possible to
  6464. use git bisect to locate the origin of a problem.
  6465. First of all, it is essential that the patch has a good commit
  6466. message. The commit message should start with a separate line with a
  6467. brief summary of the change, prefixed by the area touched by the
  6468. patch. A few examples of good commit titles:
  6469. * package/linuxptp: bump version to 2.0
  6470. * configs/imx23evk: bump Linux version to 4.19
  6471. * package/pkg-generic: postpone evaluation of dependency conditions
  6472. * boot/uboot: needs host-{flex,bison}
  6473. * support/testing: add python-ubjson tests
  6474. The description that follows the prefix should start with a lower
  6475. case letter (i.e "bump", "needs", "postpone", "add" in the above
  6476. examples).
  6477. Second, the body of the commit message should describe why this
  6478. change is needed, and if necessary also give details about how it was
  6479. done. When writing the commit message, think of how the reviewers
  6480. will read it, but also think about how you will read it when you look
  6481. at this change again a few years down the line.
  6482. Third, the patch itself should do only one change, but do it
  6483. completely. Two unrelated or weakly related changes should usually be
  6484. done in two separate patches. This usually means that a patch affects
  6485. only a single package. If several changes are related, it is often
  6486. still possible to split them up in small patches and apply them in a
  6487. specific order. Small patches make it easier to review, and often
  6488. make it easier to understand afterwards why a change was done.
  6489. However, each patch must be complete. It is not allowed that the
  6490. build is broken when only the first but not the second patch is
  6491. applied. This is necessary to be able to use git bisect afterwards.
  6492. Of course, while you’re doing your development, you’re probably going
  6493. back and forth between packages, and certainly not committing things
  6494. immediately in a way that is clean enough for submission. So most
  6495. developers rewrite the history of commits to produce a clean set of
  6496. commits that is appropriate for submission. To do this, you need to
  6497. use interactive rebasing. You can learn about it in the Pro Git book
  6498. [https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History].
  6499. Sometimes, it is even easier to discard you history with git reset
  6500. --soft origin/master and select individual changes with git add -i or
  6501. git add -p.
  6502. Finally, the patch should be signed off. This is done by adding
  6503. Signed-off-by: Your Real Name <> at the end of the commit message.
  6504. git commit -s does that for you, if configured properly. The
  6505. Signed-off-by tag means that you publish the patch under the
  6506. Buildroot license (i.e. GPL-2.0+, except for package patches, which
  6507. have the upstream license), and that you are allowed to do so. See
  6508. the Developer Certificate of Origin [http://developercertificate.org
  6509. /] for details.
  6510. To give credits to who sponsored the creation of a patch or the
  6511. process of upstreaming it, you may use email subaddressing [https://
  6512. datatracker.ietf.org/doc/html/rfc5233] for your git identity (i.e.
  6513. what is used as commit author and email From: field, as well as your
  6514. Signed-off-by tag); add suffix to the local part, separated from it
  6515. by a plus + sign. E.g.:
  6516. * for a company which sponsored the submitted work, use the company
  6517. name as the detail (suffix) part:
  6518. Your-Name Your-Surname
  6519. <your-name.your-surname+companyname@mail.com>
  6520. * for an individual who sponsored the submitted work, use their
  6521. name and surname:
  6522. Your-Name Your-Surname
  6523. <your-name.your-surname+their-name.their-surname@mail.com>
  6524. When adding new packages, you should submit every package in a
  6525. separate patch. This patch should have the update to package/
  6526. Config.in, the package Config.in file, the .mk file, the .hash file,
  6527. any init script, and all package patches. If the package has many
  6528. sub-options, these are sometimes better added as separate follow-up
  6529. patches. The summary line should be something like <packagename>: new
  6530. package. The body of the commit message can be empty for simple
  6531. packages, or it can contain the description of the package (like the
  6532. Config.in help text). If anything special has to be done to build the
  6533. package, this should also be explained explicitly in the commit
  6534. message body.
  6535. When you bump a package to a new version, you should also submit a
  6536. separate patch for each package. Don’t forget to update the .hash
  6537. file, or add it if it doesn’t exist yet. Also don’t forget to check
  6538. if the _LICENSE and _LICENSE_FILES are still valid. The summary line
  6539. should be something like <packagename>: bump to version <new
  6540. version>. If the new version only contains security updates compared
  6541. to the existing one, the summary should be <packagename>: security
  6542. bump to version <new version> and the commit message body should show
  6543. the CVE numbers that are fixed. If some package patches can be
  6544. removed in the new version, it should be explained explicitly why
  6545. they can be removed, preferably with the upstream commit ID. Also any
  6546. other required changes should be explained explicitly, like configure
  6547. options that no longer exist or are no longer needed.
  6548. If you are interested in getting notified of build failures and of
  6549. further changes in the packages you added or modified, please add
  6550. yourself to the DEVELOPERS file. This should be done in the same
  6551. patch creating or modifying the package. See the DEVELOPERS file for
  6552. more information.
  6553. Buildroot provides a handy tool to check for common coding style
  6554. mistakes on files you created or modified, called check-package (see
  6555. Section 18.25.2, “How to check the coding style” for more
  6556. information).
  6557. 22.5.2. Preparing a patch series
  6558. Starting from the changes committed in your local git view, rebase
  6559. your development branch on top of the upstream tree before generating
  6560. a patch set. To do so, run:
  6561. $ git fetch --all --tags
  6562. $ git rebase origin/master
  6563. Now check the coding style for the changes you committed:
  6564. $ utils/docker-run make check-package
  6565. Now, you are ready to generate then submit your patch set.
  6566. To generate it, run:
  6567. $ git format-patch -M -n -s -o outgoing origin/master
  6568. This will generate patch files in the outgoing subdirectory,
  6569. automatically adding the Signed-off-by line.
  6570. Once patch files are generated, you can review/edit the commit
  6571. message before submitting them, using your favorite text editor.
  6572. Buildroot provides a handy tool to know to whom your patches should
  6573. be sent, called get-developers (see Chapter 23, DEVELOPERS file and
  6574. get-developers for more information). This tool reads your patches
  6575. and outputs the appropriate git send-email command to use:
  6576. $ ./utils/get-developers outgoing/*
  6577. Use the output of get-developers to send your patches:
  6578. $ git send-email --to buildroot@buildroot.org --cc bob --cc alice outgoing/*
  6579. Alternatively, get-developers -e can be used directly with the
  6580. --cc-cmd argument to git send-email to automatically CC the affected
  6581. developers:
  6582. $ git send-email --to buildroot@buildroot.org \
  6583. --cc-cmd './utils/get-developers -e' origin/master
  6584. git can be configured to automatically do this out of the box with:
  6585. $ git config sendemail.to buildroot@buildroot.org
  6586. $ git config sendemail.ccCmd "$(pwd)/utils/get-developers -e"
  6587. And then just do:
  6588. $ git send-email origin/master
  6589. Note that git should be configured to use your mail account. To
  6590. configure git, see man git-send-email or https://git-send-email.io/.
  6591. If you do not use git send-email, make sure posted patches are not
  6592. line-wrapped, otherwise they cannot easily be applied. In such a
  6593. case, fix your e-mail client, or better yet, learn to use git
  6594. send-email.
  6595. https://sr.ht also has a light-weight UI for preparing patchseries
  6596. [https://man.sr.ht/git.sr.ht/#sending-patches-upstream] and can also
  6597. send out the patches for you. There are a few drawbacks to this, as
  6598. you cannot edit your patches' status in Patchwork and you currently
  6599. can’t edit your display name with which the match emails are sent out
  6600. but it is an option if you cannot get git send-email to work with
  6601. your mail provider (i.e. O365); it shall not be considered the
  6602. official way of sending patches, but just a fallback.
  6603. 22.5.3. Cover letter
  6604. If you want to present the whole patch set in a separate mail, add
  6605. --cover-letter to the git format-patch command (see man
  6606. git-format-patch for further information). This will generate a
  6607. template for an introduction e-mail to your patch series.
  6608. A cover letter may be useful to introduce the changes you propose in
  6609. the following cases:
  6610. * large number of commits in the series;
  6611. * deep impact of the changes in the rest of the project;
  6612. * RFC ^[4];
  6613. * whenever you feel it will help presenting your work, your
  6614. choices, the review process, etc.
  6615. 22.5.4. Patches for maintenance branches
  6616. When fixing bugs on a maintenance branch, bugs should be fixed on the
  6617. master branch first. The commit log for such a patch may then contain
  6618. a post-commit note specifying what branches are affected:
  6619. package/foo: fix stuff
  6620. Signed-off-by: Your Real Name <your@email.address>
  6621. ---
  6622. Backport to: 2020.02.x, 2020.05.x
  6623. (2020.08.x not affected as the version was bumped)
  6624. Those changes will then be backported by a maintainer to the affected
  6625. branches.
  6626. However, some bugs may apply only to a specific release, for example
  6627. because it is using an older version of a package. In that case,
  6628. patches should be based off the maintenance branch, and the patch
  6629. subject prefix must include the maintenance branch name (for example
  6630. "[PATCH 2020.02.x]"). This can be done with the git format-patch flag
  6631. --subject-prefix:
  6632. $ git format-patch --subject-prefix "PATCH 2020.02.x" \
  6633. -M -s -o outgoing origin/2020.02.x
  6634. Then send the patches with git send-email, as described above.
  6635. 22.5.5. Patch revision changelog
  6636. When improvements are requested, the new revision of each commit
  6637. should include a changelog of the modifications between each
  6638. submission. Note that when your patch series is introduced by a cover
  6639. letter, an overall changelog may be added to the cover letter in
  6640. addition to the changelog in the individual commits. The best thing
  6641. to rework a patch series is by interactive rebasing: git rebase -i
  6642. origin/master. Consult the git manual for more information.
  6643. When added to the individual commits, this changelog is added when
  6644. editing the commit message. Below the Signed-off-by section, add ---
  6645. and your changelog.
  6646. Although the changelog will be visible for the reviewers in the mail
  6647. thread, as well as in patchwork [https://patchwork.ozlabs.org/project
  6648. /buildroot/list/], git will automatically ignores lines below ---
  6649. when the patch will be merged. This is the intended behavior: the
  6650. changelog is not meant to be preserved forever in the git history of
  6651. the project.
  6652. Hereafter the recommended layout:
  6653. Patch title: short explanation, max 72 chars
  6654. A paragraph that explains the problem, and how it manifests itself. If
  6655. the problem is complex, it is OK to add more paragraphs. All paragraphs
  6656. should be wrapped at 72 characters.
  6657. A paragraph that explains the root cause of the problem. Again, more
  6658. than one paragraph is OK.
  6659. Finally, one or more paragraphs that explain how the problem is solved.
  6660. Don't hesitate to explain complex solutions in detail.
  6661. Signed-off-by: John DOE <john.doe@example.net>
  6662. ---
  6663. Changes v2 -> v3:
  6664. - foo bar (suggested by Jane)
  6665. - bar buz
  6666. Changes v1 -> v2:
  6667. - alpha bravo (suggested by John)
  6668. - charly delta
  6669. Any patch revision should include the version number. The version
  6670. number is simply composed of the letter v followed by an integer
  6671. greater or equal to two (i.e. "PATCH v2", "PATCH v3" …).
  6672. This can be easily handled with git format-patch by using the option
  6673. --subject-prefix:
  6674. $ git format-patch --subject-prefix "PATCH v4" \
  6675. -M -s -o outgoing origin/master
  6676. Since git version 1.8.1, you can also use -v <n> (where <n> is the
  6677. version number):
  6678. $ git format-patch -v4 -M -s -o outgoing origin/master
  6679. When you provide a new version of a patch, please mark the old one as
  6680. superseded in patchwork [https://patchwork.ozlabs.org/project/
  6681. buildroot/list/]. You need to create an account on patchwork [https:/
  6682. /patchwork.ozlabs.org/project/buildroot/list/] to be able to modify
  6683. the status of your patches. Note that you can only change the status
  6684. of patches you submitted yourself, which means the email address you
  6685. register in patchwork [https://patchwork.ozlabs.org/project/buildroot
  6686. /list/] should match the one you use for sending patches to the
  6687. mailing list.
  6688. You can also add the --in-reply-to=<message-id> option when
  6689. submitting a patch to the mailing list. The id of the mail to reply
  6690. to can be found under the "Message Id" tag on patchwork [https://
  6691. patchwork.ozlabs.org/project/buildroot/list/]. The advantage of
  6692. in-reply-to is that patchwork will automatically mark the previous
  6693. version of the patch as superseded.
  6694. 22.6. Reporting issues/bugs or getting help
  6695. Before reporting any issue, please check in the mailing list archive
  6696. whether someone has already reported and/or fixed a similar problem.
  6697. However you choose to report bugs or get help, either by opening a
  6698. bug in the bug tracker or by sending a mail to the mailing list,
  6699. there are a number of details to provide in order to help people
  6700. reproduce and find a solution to the issue.
  6701. Try to think as if you were trying to help someone else; in that
  6702. case, what would you need?
  6703. Here is a short list of details to provide in such case:
  6704. * host machine (OS/release)
  6705. * version of Buildroot
  6706. * target for which the build fails
  6707. * package(s) for which the build fails
  6708. * the command that fails and its output
  6709. * any information you think that may be relevant
  6710. Additionally, you should add the .config file (or if you know how, a
  6711. defconfig; see Section 9.3, “Storing the Buildroot configuration”).
  6712. If some of these details are too large, do not hesitate to use a
  6713. pastebin service. Note that not all available pastebin services will
  6714. preserve Unix-style line terminators when downloading raw pastes.
  6715. Following pastebin services are known to work correctly: - https://
  6716. gist.github.com/ - http://code.bulix.org/
  6717. 22.7. Using the runtime tests framework
  6718. Buildroot includes a run-time testing framework built upon Python
  6719. scripting and QEMU runtime execution. The goals of the framework are
  6720. the following:
  6721. * build a well defined Buildroot configuration
  6722. * optionally, verify some properties of the build output
  6723. * optionally, boot the build results under Qemu, and verify that a
  6724. given feature is working as expected
  6725. The entry point to use the runtime tests framework is the support/
  6726. testing/run-tests tool, which has a series of options documented in
  6727. the tool’s help -h description. Some common options include setting
  6728. the download folder, the output folder, keeping build output, and for
  6729. multiple test cases, you can set the JLEVEL for each.
  6730. Here is an example walk through of running a test case.
  6731. * For a first step, let us see what all the test case options are.
  6732. The test cases can be listed by executing support/testing/
  6733. run-tests -l. These tests can all be run individually during test
  6734. development from the console. Both one at a time and selectively
  6735. as a group of a subset of tests.
  6736. $ support/testing/run-tests -l
  6737. List of tests
  6738. test_run (tests.utils.test_check_package.TestCheckPackage)
  6739. test_run (tests.toolchain.test_external.TestExternalToolchainBuildrootMusl) ... ok
  6740. test_run (tests.toolchain.test_external.TestExternalToolchainBuildrootuClibc) ... ok
  6741. test_run (tests.toolchain.test_external.TestExternalToolchainCCache) ... ok
  6742. test_run (tests.toolchain.test_external.TestExternalToolchainCtngMusl) ... ok
  6743. test_run (tests.toolchain.test_external.TestExternalToolchainLinaroArm) ... ok
  6744. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv4) ... ok
  6745. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv5) ... ok
  6746. test_run (tests.toolchain.test_external.TestExternalToolchainSourceryArmv7) ... ok
  6747. [snip]
  6748. test_run (tests.init.test_systemd.TestInitSystemSystemdRoFull) ... ok
  6749. test_run (tests.init.test_systemd.TestInitSystemSystemdRoIfupdown) ... ok
  6750. test_run (tests.init.test_systemd.TestInitSystemSystemdRoNetworkd) ... ok
  6751. test_run (tests.init.test_systemd.TestInitSystemSystemdRwFull) ... ok
  6752. test_run (tests.init.test_systemd.TestInitSystemSystemdRwIfupdown) ... ok
  6753. test_run (tests.init.test_systemd.TestInitSystemSystemdRwNetworkd) ... ok
  6754. test_run (tests.init.test_busybox.TestInitSystemBusyboxRo) ... ok
  6755. test_run (tests.init.test_busybox.TestInitSystemBusyboxRoNet) ... ok
  6756. test_run (tests.init.test_busybox.TestInitSystemBusyboxRw) ... ok
  6757. test_run (tests.init.test_busybox.TestInitSystemBusyboxRwNet) ... ok
  6758. Ran 157 tests in 0.021s
  6759. OK
  6760. * Then, to run one test case:
  6761. $ support/testing/run-tests -d dl -o output_folder -k tests.init.test_busybox.TestInitSystemBusyboxRw
  6762. 15:03:26 TestInitSystemBusyboxRw Starting
  6763. 15:03:28 TestInitSystemBusyboxRw Building
  6764. 15:08:18 TestInitSystemBusyboxRw Building done
  6765. 15:08:27 TestInitSystemBusyboxRw Cleaning up
  6766. .
  6767. Ran 1 test in 301.140s
  6768. OK
  6769. The standard output indicates if the test is successful or not. By
  6770. default, the output folder for the test is deleted automatically
  6771. unless the option -k is passed to keep the output directory.
  6772. 22.7.1. Creating a test case
  6773. Within the Buildroot repository, the testing framework is organized
  6774. at the top level in support/testing/ by folders of conf, infra and
  6775. tests. All the test cases live under the tests folder and are
  6776. organized in various folders representing the category of test.
  6777. The best way to get familiar with how to create a test case is to
  6778. look at a few of the basic file system support/testing/tests/fs/ and
  6779. init support/testing/tests/init/ test scripts. Those tests give good
  6780. examples of a basic tests that include both checking the build
  6781. results, and doing runtime tests. There are other more advanced cases
  6782. that use things like nested br2-external folders to provide skeletons
  6783. and additional packages.
  6784. Creating a basic test case involves:
  6785. * Defining a test class that inherits from infra.basetest.BRTest
  6786. * Defining the config member of the test class, to the Buildroot
  6787. configuration to build for this test case. It can optionally rely
  6788. on configuration snippets provided by the runtime test
  6789. infrastructure: infra.basetest.BASIC_TOOLCHAIN_CONFIG to get a
  6790. basic architecture/toolchain configuration, and
  6791. infra.basetest.MINIMAL_CONFIG to not build any filesystem. The
  6792. advantage of using infra.basetest.BASIC_TOOLCHAIN_CONFIG is that
  6793. a matching Linux kernel image is provided, which allows to boot
  6794. the resulting image in Qemu without having to build a Linux
  6795. kernel image as part of the test case, therefore significant
  6796. decreasing the build time required for the test case.
  6797. * Implementing a def test_run(self): function to implement the
  6798. actual tests to run after the build has completed. They may be
  6799. tests that verify the build output, by running command on the
  6800. host using the run_cmd_on_host() helper function. Or they may
  6801. boot the generated system in Qemu using the Emulator object
  6802. available as self.emulator in the test case. For example
  6803. self.emulator.boot() allows to boot the system in Qemu,
  6804. self.emulator.login() allows to login, self.emulator.run() allows
  6805. to run shell commands inside Qemu.
  6806. After creating the test script, add yourself to the DEVELOPERS file
  6807. to be the maintainer of that test case.
  6808. 22.7.2. Debugging a test case
  6809. When a test case runs, the output_folder will contain the following:
  6810. $ ls output_folder/
  6811. TestInitSystemBusyboxRw/
  6812. TestInitSystemBusyboxRw-build.log
  6813. TestInitSystemBusyboxRw-run.log
  6814. TestInitSystemBusyboxRw/ is the Buildroot output directory, and it is
  6815. preserved only if the -k option is passed.
  6816. TestInitSystemBusyboxRw-build.log is the log of the Buildroot build.
  6817. TestInitSystemBusyboxRw-run.log is the log of the Qemu boot and test.
  6818. This file will only exist if the build was successful and the test
  6819. case involves booting under Qemu.
  6820. If you want to manually run Qemu to do manual tests of the build
  6821. result, the first few lines of TestInitSystemBusyboxRw-run.log
  6822. contain the Qemu command line to use.
  6823. You can also make modifications to the current sources inside the
  6824. output_folder (e.g. for debug purposes) and rerun the standard
  6825. Buildroot make targets (in order to regenerate the complete image
  6826. with the new modifications) and then rerun the test.
  6827. 22.7.3. Runtime tests and Gitlab CI
  6828. All runtime tests are regularly executed by Buildroot Gitlab CI
  6829. infrastructure, see .gitlab.yml and https://gitlab.com/buildroot.org/
  6830. buildroot/-/jobs.
  6831. You can also use Gitlab CI to test your new test cases, or verify
  6832. that existing tests continue to work after making changes in
  6833. Buildroot.
  6834. In order to achieve this, you need to create a fork of the Buildroot
  6835. project on Gitlab, and be able to push branches to your Buildroot
  6836. fork on Gitlab.
  6837. The name of the branch that you push will determine if a Gitlab CI
  6838. pipeline will be triggered or not, and for which test cases.
  6839. In the examples below, the <name> component of the branch name is an
  6840. arbitrary string you choose.
  6841. * To trigger all run-test test case jobs, push a branch that ends
  6842. with -runtime-tests:
  6843. $ git push gitlab HEAD:<name>-runtime-tests
  6844. * To trigger one or several test case jobs, push a branch that ends
  6845. with the complete test case name
  6846. (tests.init.test_busybox.TestInitSystemBusyboxRo) or with the
  6847. name of a category of tests (tests.init.test_busybox):
  6848. $ git push gitlab HEAD:<name>-<test case name>
  6849. Example to run one test:
  6850. $ git push gitlab HEAD:foo-tests.init.test_busybox.TestInitSystemBusyboxRo
  6851. Examples to run several tests part of the same group:
  6852. $ git push gitlab HEAD:foo-tests.init.test_busybox
  6853. $ git push gitlab HEAD:foo-tests.init
  6854. ---------------------------------------------------------------------
  6855. ^[4] RFC: (Request for comments) change proposal
  6856. Chapter 23. DEVELOPERS file and get-developers
  6857. The main Buildroot directory contains a file named DEVELOPERS that
  6858. lists the developers involved with various areas of Buildroot. Thanks
  6859. to this file, the get-developers tool allows to:
  6860. * Calculate the list of developers to whom patches should be sent,
  6861. by parsing the patches and matching the modified files with the
  6862. relevant developers. See Section 22.5, “Submitting patches” for
  6863. details.
  6864. * Find which developers are taking care of a given architecture or
  6865. package, so that they can be notified when a build failure occurs
  6866. on this architecture or package. This is done in interaction with
  6867. Buildroot’s autobuild infrastructure.
  6868. We ask developers adding new packages, new boards, or generally new
  6869. functionality in Buildroot, to register themselves in the DEVELOPERS
  6870. file. As an example, we expect a developer contributing a new package
  6871. to include in his patch the appropriate modification to the
  6872. DEVELOPERS file.
  6873. The DEVELOPERS file format is documented in detail inside the file
  6874. itself.
  6875. The get-developers tool, located in utils/ allows to use the
  6876. DEVELOPERS file for various tasks:
  6877. * When passing one or several patches as command line argument,
  6878. get-developers will return the appropriate git send-email
  6879. command. If the -e option is passed, only the email addresses are
  6880. printed in a format suitable for git send-email --cc-cmd.
  6881. * When using the -a <arch> command line option, get-developers will
  6882. return the list of developers in charge of the given
  6883. architecture.
  6884. * When using the -p <package> command line option, get-developers
  6885. will return the list of developers in charge of the given
  6886. package.
  6887. * When using the -c command line option, get-developers will look
  6888. at all files under version control in the Buildroot repository,
  6889. and list the ones that are not handled by any developer. The
  6890. purpose of this option is to help completing the DEVELOPERS file.
  6891. * When using the -v command line option, it validates the integrity
  6892. of the DEVELOPERS file and will note WARNINGS for items that
  6893. don’t match.
  6894. Chapter 24. Release Engineering
  6895. 24.1. Releases
  6896. The Buildroot project makes quarterly releases with monthly bugfix
  6897. releases. The first release of each year is a long term support
  6898. release, LTS.
  6899. * Quarterly releases: 2020.02, 2020.05, 2020.08, and 2020.11
  6900. * Bugfix releases: 2020.02.1, 2020.02.2, …
  6901. * LTS releases: 2020.02, 2021.02, …
  6902. Releases are supported until the first bugfix release of the next
  6903. release, e.g., 2020.05.x is EOL when 2020.08.1 is released.
  6904. LTS releases are supported until the first bugfix release of the next
  6905. LTS, e.g., 2020.02.x is supported until 2021.02.1 is released.
  6906. 24.2. Development
  6907. Each release cycle consist of two months of development on the master
  6908. branch and one month stabilization before the release is made. During
  6909. this phase no new features are added to master, only bugfixes.
  6910. The stabilization phase starts with tagging -rc1, and every week
  6911. until the release, another release candidate is tagged.
  6912. To handle new features and version bumps during the stabilization
  6913. phase, a next branch may be created for these features. Once the
  6914. current release has been made, the next branch is merged into master
  6915. and the development cycle for the next release continues there.
  6916. Part IV. Appendix
  6917. Table of Contents
  6918. 25. Makedev syntax documentation
  6919. 26. Makeusers syntax documentation
  6920. 26.1. Caveat with automatic UIDs and GIDs
  6921. 27. Migrating from older Buildroot versions
  6922. 27.1. General approach
  6923. 27.2. Migrating to 2016.11
  6924. 27.3. Migrating to 2017.08
  6925. 27.4. Migrating to 2023.11
  6926. Chapter 25. Makedev syntax documentation
  6927. The makedev syntax is used in several places in Buildroot to define
  6928. changes to be made for permissions, or which device files to create
  6929. and how to create them, in order to avoid calls to mknod.
  6930. This syntax is derived from the makedev utility, and more complete
  6931. documentation can be found in the package/makedevs/README file.
  6932. It takes the form of a space separated list of fields, one file per
  6933. line; the fields are:
  6934. +--------------------------------------------------+
  6935. |name|type|mode|uid|gid|major|minor|start|inc|count|
  6936. +--------------------------------------------------+
  6937. There are a few non-trivial blocks:
  6938. * name is the path to the file you want to create/modify
  6939. * type is the type of the file, being one of:
  6940. + f: a regular file, which must already exist
  6941. + F: a regular file, which is ignored and not created if
  6942. missing
  6943. + d: a directory, which is created, as well as its parents, if
  6944. missing
  6945. + r: a directory recursively, which must already exist
  6946. + c: a character device file, which parent directory must exist
  6947. + b: a block device file, which parent directory must exist
  6948. + p: a named pipe, which parent directory must exist
  6949. * mode are the usual permissions settings (only numerical values
  6950. are allowed); for type d, the mode of existing parents is not
  6951. changed, but the mode of created parents is set; for types f, F,
  6952. and r, mode can also be set to -1 to not change the mode (and
  6953. only change uid and gid)
  6954. * uid and gid are the UID and GID to set on this file; can be
  6955. either numerical values or actual names
  6956. * major and minor are here for device files, set to - for other
  6957. files
  6958. * start, inc and count are for when you want to create a batch of
  6959. files, and can be reduced to a loop, beginning at start,
  6960. incrementing its counter by inc until it reaches count
  6961. Let’s say you want to change the ownership and permissions of a given
  6962. file; using this syntax, you will need to write:
  6963. /usr/bin/foo f 755 0 0 - - - - -
  6964. /usr/bin/bar f 755 root root - - - - -
  6965. /data/buz f 644 buz-user buz-group - - - - -
  6966. /data/baz f -1 baz-user baz-group - - - - -
  6967. Alternatively, if you want to change owner of a directory
  6968. recursively, you can write (to set UID to foo and GID to bar for the
  6969. directory /usr/share/myapp and all files and directories below it):
  6970. /usr/share/myapp r -1 foo bar - - - - -
  6971. On the other hand, if you want to create the device file /dev/hda and
  6972. the corresponding 15 files for the partitions, you will need for /dev
  6973. /hda:
  6974. /dev/hda b 640 root root 3 0 0 0 -
  6975. and then for device files corresponding to the partitions of /dev/
  6976. hda, /dev/hdaX, X ranging from 1 to 15:
  6977. /dev/hda b 640 root root 3 1 1 1 15
  6978. Extended attributes are supported if
  6979. BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES is enabled. This
  6980. is done by adding a line starting with |xattr after the line
  6981. describing the file. Right now, only capability is supported as
  6982. extended attribute.
  6983. +------------------+
  6984. ||xattr|capability |
  6985. +------------------+
  6986. * |xattr is a "flag" that indicate an extended attribute
  6987. * capability is a capability to add to the previous file
  6988. If you want to add the capability cap_sys_admin to the binary foo,
  6989. you will write :
  6990. /usr/bin/foo f 755 root root - - - - -
  6991. |xattr cap_sys_admin+eip
  6992. You can add several capabilities to a file by using several |xattr
  6993. lines. If you want to add the capability cap_sys_admin and
  6994. cap_net_admin to the binary foo, you will write :
  6995. /usr/bin/foo f 755 root root - - - - -
  6996. |xattr cap_sys_admin+eip
  6997. |xattr cap_net_admin+eip
  6998. Chapter 26. Makeusers syntax documentation
  6999. The syntax to create users is inspired by the makedev syntax, above,
  7000. but is specific to Buildroot.
  7001. The syntax for adding a user is a space-separated list of fields, one
  7002. user per line; the fields are:
  7003. +---------------------------------------------------------+
  7004. |username|uid|group|gid|password|home|shell|groups|comment|
  7005. +---------------------------------------------------------+
  7006. Where:
  7007. * username is the desired user name (aka login name) for the user.
  7008. It can not be root, and must be unique. If set to -, then just a
  7009. group will be created.
  7010. * uid is the desired UID for the user. It must be unique, and not
  7011. 0. If set to -1 or -2, then a unique UID will be computed by
  7012. Buildroot, with -1 denoting a system UID from [100…999] and -2
  7013. denoting a user UID from [1000…1999].
  7014. * group is the desired name for the user’s main group. It can not
  7015. be root. If the group does not exist, it will be created.
  7016. * gid is the desired GID for the user’s main group. It must be
  7017. unique, and not 0. If set to -1 or -2, and the group does not
  7018. already exist, then a unique GID will be computed by Buildroot,
  7019. with -1 denoting a system GID from [100…999] and -2 denoting a
  7020. user GID from [1000…1999].
  7021. * password is the crypt(3)-encoded password. If prefixed with !,
  7022. then login is disabled. If prefixed with =, then it is
  7023. interpreted as clear-text, and will be crypt-encoded (using MD5).
  7024. If prefixed with !=, then the password will be crypt-encoded
  7025. (using MD5) and login will be disabled. If set to *, then login
  7026. is not allowed. If set to -, then no password value will be set.
  7027. * home is the desired home directory for the user. If set to -, no
  7028. home directory will be created, and the user’s home will be /.
  7029. Explicitly setting home to / is not allowed.
  7030. * shell is the desired shell for the user. If set to -, then /bin/
  7031. false is set as the user’s shell.
  7032. * groups is the comma-separated list of additional groups the user
  7033. should be part of. If set to -, then the user will be a member of
  7034. no additional group. Missing groups will be created with an
  7035. arbitrary gid.
  7036. * comment (aka GECOS [https://en.wikipedia.org/wiki/Gecos_field]
  7037. field) is an almost-free-form text.
  7038. There are a few restrictions on the content of each field:
  7039. * except for comment, all fields are mandatory.
  7040. * except for comment, fields may not contain spaces.
  7041. * no field may contain a colon (:).
  7042. If home is not -, then the home directory, and all files below, will
  7043. belong to the user and its main group.
  7044. Examples:
  7045. foo -1 bar -1 !=blabla /home/foo /bin/sh alpha,bravo Foo user
  7046. This will create this user:
  7047. * username (aka login name) is: foo
  7048. * uid is computed by Buildroot
  7049. * main group is: bar
  7050. * main group gid is computed by Buildroot
  7051. * clear-text password is: blabla, will be crypt(3)-encoded, and
  7052. login is disabled.
  7053. * home is: /home/foo
  7054. * shell is: /bin/sh
  7055. * foo is also a member of groups: alpha and bravo
  7056. * comment is: Foo user
  7057. test 8000 wheel -1 = - /bin/sh - Test user
  7058. This will create this user:
  7059. * username (aka login name) is: test
  7060. * uid is : 8000
  7061. * main group is: wheel
  7062. * main group gid is computed by Buildroot, and will use the value
  7063. defined in the rootfs skeleton
  7064. * password is empty (aka no password).
  7065. * home is / but will not belong to test
  7066. * shell is: /bin/sh
  7067. * test is not a member of any additional groups
  7068. * comment is: Test user
  7069. 26.1. Caveat with automatic UIDs and GIDs
  7070. When updating buildroot or when packages are added or removed to/from
  7071. the configuration, it is possible that the automatic UIDs and GIDs
  7072. are changed. This can be a problem if persistent files were created
  7073. with that user or group: after upgrade, they will suddenly have a
  7074. different owner.
  7075. Therefore, it is advisable to perpetuate the automatic IDs. This can
  7076. be done by adding a users table with the generated IDs. It is only
  7077. needed to do this for UIDs that actually create persistent files,
  7078. e.g. database.
  7079. Chapter 27. Migrating from older Buildroot versions
  7080. Some versions have introduced backward incompatibilities. This
  7081. section explains those incompatibilities, and for each explains what
  7082. to do to complete the migration.
  7083. 27.1. General approach
  7084. To migrate from an older Buildroot version, take the following steps.
  7085. 1. For all your configurations, do a build in the old Buildroot
  7086. environment. Run make graph-size. Save graphs/file-size-stats.csv
  7087. in a different location. Run make clean to remove the rest.
  7088. 2. Review the specific migration notes below and make the required
  7089. adaptations to external packages and custom build scripts.
  7090. 3. Update Buildroot.
  7091. 4. Run make menuconfig starting from the existing .config.
  7092. 5. If anything is enabled in the Legacy menu, check its help text,
  7093. unselect it, and save the configuration.
  7094. 6. For more details, review the git commit messages for the packages
  7095. that you need. Change into the packages directory and run git log
  7096. <old version>.. — <your packages>.
  7097. 7. Build in the new Buildroot environment.
  7098. 8. Fix build issues in external packages (usually due to updated
  7099. dependencies).
  7100. 9. Run make graph-size.
  7101. 10. Compare the new file-size-stats.csv with the original one, to
  7102. check if no required files have disappeared and if no new big
  7103. unneeded files have appeared.
  7104. 11. For configuration (and other) files in a custom overlay that
  7105. overwrite files created by Buildroot, check if there are changes
  7106. in the Buildroot-generated file that need to be propagated to
  7107. your custom file.
  7108. 27.2. Migrating to 2016.11
  7109. Before Buildroot 2016.11, it was possible to use only one
  7110. br2-external tree at once. With Buildroot 2016.11 came the
  7111. possibility to use more than one simultaneously (for details, see
  7112. Section 9.2, “Keeping customizations outside of Buildroot”).
  7113. This however means that older br2-external trees are not usable
  7114. as-is. A minor change has to be made: adding a name to your
  7115. br2-external tree.
  7116. This can be done very easily in just a few steps:
  7117. * First, create a new file named external.desc, at the root of your
  7118. br2-external tree, with a single line defining the name of your
  7119. br2-external tree:
  7120. $ echo 'name: NAME_OF_YOUR_TREE' >external.desc
  7121. Note. Be careful when choosing a name: It has to be unique and be
  7122. made with only ASCII characters from the set [A-Za-z0-9_].
  7123. * Then, change every occurrence of BR2_EXTERNAL in your
  7124. br2-external tree with the new variable:
  7125. $ find . -type f | xargs sed -i 's/BR2_EXTERNAL/BR2_EXTERNAL_NAME_OF_YOUR_TREE_PATH/g'
  7126. Now, your br2-external tree can be used with Buildroot 2016.11
  7127. onward.
  7128. Note: This change makes your br2-external tree incompatible with
  7129. Buildroot before 2016.11.
  7130. 27.3. Migrating to 2017.08
  7131. Before Buildroot 2017.08, host packages were installed in $(HOST_DIR)
  7132. /usr (with e.g. the autotools' --prefix=$(HOST_DIR)/usr). With
  7133. Buildroot 2017.08, they are now installed directly in $(HOST_DIR).
  7134. Whenever a package installs an executable that is linked with a
  7135. library in $(HOST_DIR)/lib, it must have an RPATH pointing to that
  7136. directory.
  7137. An RPATH pointing to $(HOST_DIR)/usr/lib is no longer accepted.
  7138. 27.4. Migrating to 2023.11
  7139. Before Buildroot 2023.11, the subversion download backend
  7140. unconditionally retrieved the external references (objects with an
  7141. svn:externals property). Starting with 2023.11, externals are no
  7142. longer retrieved by default; if you need them, set
  7143. LIBFOO_SVN_EXTERNALS to YES. This change implies that:
  7144. * the generated archive content may change, and thus the hashes may
  7145. need to be updated appropriately;
  7146. * the archive version suffix has been updated to -br3, so the hash
  7147. files must be updated appropriately.
  7148. Before Buildroot 2023.11, it was possible (but undocumented and
  7149. unused) to apply architecture-specific patches, by prefixing the
  7150. patch filename with the architecture, e.g.
  7151. 0001-some-changes.patch.arm and such a patch would only be applied
  7152. for that architecture. With Buildroot 2023.11, this is no longer
  7153. supported, and such patches are no longer applied at all.
  7154. If you still need per-architecture patches, then you may provide a
  7155. pre-patch hook that copies the patches applicable to the configured
  7156. architecture, e.g.:
  7157. define LIBFOO_ARCH_PATCHES
  7158. $(foreach p,$(wildcard $(LIBFOO_PKGDIR)/*.patch.$(ARCH)), \
  7159. cp -f $(p) $(patsubst %.$(ARCH),%,$(p))
  7160. )
  7161. endef
  7162. LIBFOO_PRE_PATCH_HOOKS += LIBFOO_ARCH_PATCHES
  7163. Note that no package in Buildroot has architecture-specific patches,
  7164. and that such patches will most probably not be accepted.