2
0

automake.in 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247
  1. #!@PERL@ -w
  2. # -*- perl -*-
  3. # @configure_input@
  4. eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
  5. if 0;
  6. # automake - create Makefile.in from Makefile.am
  7. # Copyright (C) 1994-2017 Free Software Foundation, Inc.
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2, or (at your option)
  11. # any later version.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
  19. # Perl reimplementation by Tom Tromey <tromey@redhat.com>, and
  20. # Alexandre Duret-Lutz <adl@gnu.org>.
  21. package Automake;
  22. use strict;
  23. BEGIN
  24. {
  25. @Automake::perl_libdirs = ('@datadir@/@PACKAGE@-@APIVERSION@')
  26. unless @Automake::perl_libdirs;
  27. unshift @INC, @Automake::perl_libdirs;
  28. # Override SHELL. This is required on DJGPP so that system() uses
  29. # bash, not COMMAND.COM which doesn't quote arguments properly.
  30. # Other systems aren't expected to use $SHELL when Automake
  31. # runs, but it should be safe to drop the "if DJGPP" guard if
  32. # it turns up other systems need the same thing. After all,
  33. # if SHELL is used, ./configure's SHELL is always better than
  34. # the user's SHELL (which may be something like tcsh).
  35. $ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJDIR'};
  36. }
  37. use Automake::Config;
  38. BEGIN
  39. {
  40. if ($perl_threads)
  41. {
  42. require threads;
  43. import threads;
  44. require Thread::Queue;
  45. import Thread::Queue;
  46. }
  47. }
  48. use Automake::General;
  49. use Automake::XFile;
  50. use Automake::Channels;
  51. use Automake::ChannelDefs;
  52. use Automake::Configure_ac;
  53. use Automake::FileUtils;
  54. use Automake::Location;
  55. use Automake::Condition qw/TRUE FALSE/;
  56. use Automake::DisjConditions;
  57. use Automake::Options;
  58. use Automake::Variable;
  59. use Automake::VarDef;
  60. use Automake::Rule;
  61. use Automake::RuleDef;
  62. use Automake::Wrap 'makefile_wrap';
  63. use Automake::Language;
  64. use File::Basename;
  65. use File::Spec;
  66. use Carp;
  67. ## ----------------------- ##
  68. ## Subroutine prototypes. ##
  69. ## ----------------------- ##
  70. #! Prototypes here will automatically be generated by the build system.
  71. ## ----------- ##
  72. ## Constants. ##
  73. ## ----------- ##
  74. # Some regular expressions. One reason to put them here is that it
  75. # makes indentation work better in Emacs.
  76. # Writing singled-quoted-$-terminated regexes is a pain because
  77. # perl-mode thinks of $' as the ${'} variable (instead of a $ followed
  78. # by a closing quote. Letting perl-mode think the quote is not closed
  79. # leads to all sort of misindentations. On the other hand, defining
  80. # regexes as double-quoted strings is far less readable. So usually
  81. # we will write:
  82. #
  83. # $REGEX = '^regex_value' . "\$";
  84. my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
  85. my $WHITE_PATTERN = '^\s*' . "\$";
  86. my $COMMENT_PATTERN = '^#';
  87. my $TARGET_PATTERN='[$a-zA-Z0-9_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
  88. # A rule has three parts: a list of targets, a list of dependencies,
  89. # and optionally actions.
  90. my $RULE_PATTERN =
  91. "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
  92. # Only recognize leading spaces, not leading tabs. If we recognize
  93. # leading tabs here then we need to make the reader smarter, because
  94. # otherwise it will think rules like 'foo=bar; \' are errors.
  95. my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
  96. # This pattern recognizes a Gnits version id and sets $1 if the
  97. # release is an alpha release. We also allow a suffix which can be
  98. # used to extend the version number with a "fork" identifier.
  99. my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
  100. my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
  101. my $ELSE_PATTERN =
  102. '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
  103. my $ENDIF_PATTERN =
  104. '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
  105. my $PATH_PATTERN = '(\w|[+/.-])+';
  106. # This will pass through anything not of the prescribed form.
  107. my $INCLUDE_PATTERN = ('^include\s+'
  108. . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
  109. . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
  110. . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
  111. # Directories installed during 'install-exec' phase.
  112. my $EXEC_DIR_PATTERN =
  113. '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
  114. # Values for AC_CANONICAL_*
  115. use constant AC_CANONICAL_BUILD => 1;
  116. use constant AC_CANONICAL_HOST => 2;
  117. use constant AC_CANONICAL_TARGET => 3;
  118. # Values indicating when something should be cleaned.
  119. use constant MOSTLY_CLEAN => 0;
  120. use constant CLEAN => 1;
  121. use constant DIST_CLEAN => 2;
  122. use constant MAINTAINER_CLEAN => 3;
  123. # Libtool files.
  124. my @libtool_files = qw(ltmain.sh config.guess config.sub);
  125. # ltconfig appears here for compatibility with old versions of libtool.
  126. my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
  127. # Commonly found files we look for and automatically include in
  128. # DISTFILES.
  129. my @common_files =
  130. (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
  131. COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
  132. ar-lib compile config.guess config.rpath
  133. config.sub depcomp install-sh libversion.in mdate-sh
  134. missing mkinstalldirs py-compile texinfo.tex ylwrap),
  135. @libtool_files, @libtool_sometimes);
  136. # Commonly used files we auto-include, but only sometimes. This list
  137. # is used for the --help output only.
  138. my @common_sometimes =
  139. qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure
  140. configure.ac configure.in stamp-vti);
  141. # Standard directories from the GNU Coding Standards, and additional
  142. # pkg* directories from Automake. Stored in a hash for fast member check.
  143. my %standard_prefix =
  144. map { $_ => 1 } (qw(bin data dataroot doc dvi exec html include info
  145. lib libexec lisp locale localstate man man1 man2
  146. man3 man4 man5 man6 man7 man8 man9 oldinclude pdf
  147. pkgdata pkginclude pkglib pkglibexec ps sbin
  148. sharedstate sysconf));
  149. # Copyright on generated Makefile.ins.
  150. my $gen_copyright = "\
  151. # Copyright (C) 1994-$RELEASE_YEAR Free Software Foundation, Inc.
  152. # This Makefile.in is free software; the Free Software Foundation
  153. # gives unlimited permission to copy and/or distribute it,
  154. # with or without modifications, as long as this notice is preserved.
  155. # This program is distributed in the hope that it will be useful,
  156. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  157. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  158. # PARTICULAR PURPOSE.
  159. ";
  160. # These constants are returned by the lang_*_rewrite functions.
  161. # LANG_SUBDIR means that the resulting object file should be in a
  162. # subdir if the source file is. In this case the file name cannot
  163. # have '..' components.
  164. use constant LANG_IGNORE => 0;
  165. use constant LANG_PROCESS => 1;
  166. use constant LANG_SUBDIR => 2;
  167. # These are used when keeping track of whether an object can be built
  168. # by two different paths.
  169. use constant COMPILE_LIBTOOL => 1;
  170. use constant COMPILE_ORDINARY => 2;
  171. # We can't always associate a location to a variable or a rule,
  172. # when it's defined by Automake. We use INTERNAL in this case.
  173. use constant INTERNAL => new Automake::Location;
  174. # Serialization keys for message queues.
  175. use constant QUEUE_MESSAGE => "msg";
  176. use constant QUEUE_CONF_FILE => "conf file";
  177. use constant QUEUE_LOCATION => "location";
  178. use constant QUEUE_STRING => "string";
  179. ## ---------------------------------- ##
  180. ## Variables related to the options. ##
  181. ## ---------------------------------- ##
  182. # TRUE if we should always generate Makefile.in.
  183. my $force_generation = 1;
  184. # From the Perl manual.
  185. my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
  186. # TRUE if missing standard files should be installed.
  187. my $add_missing = 0;
  188. # TRUE if we should copy missing files; otherwise symlink if possible.
  189. my $copy_missing = 0;
  190. # TRUE if we should always update files that we know about.
  191. my $force_missing = 0;
  192. ## ---------------------------------------- ##
  193. ## Variables filled during files scanning. ##
  194. ## ---------------------------------------- ##
  195. # Name of the configure.ac file.
  196. my $configure_ac;
  197. # Files found by scanning configure.ac for LIBOBJS.
  198. my %libsources = ();
  199. # Names used in AC_CONFIG_HEADERS call.
  200. my @config_headers = ();
  201. # Names used in AC_CONFIG_LINKS call.
  202. my @config_links = ();
  203. # List of Makefile.am's to process, and their corresponding outputs.
  204. my @input_files = ();
  205. my %output_files = ();
  206. # Complete list of Makefile.am's that exist.
  207. my @configure_input_files = ();
  208. # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
  209. # and their outputs.
  210. my @other_input_files = ();
  211. # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADERS
  212. # appears. The keys are the files created by these macros.
  213. my %ac_config_files_location = ();
  214. # The condition under which AC_CONFIG_FOOS appears.
  215. my %ac_config_files_condition = ();
  216. # Directory to search for configure-required files. This
  217. # will be computed by locate_aux_dir() and can be set using
  218. # AC_CONFIG_AUX_DIR in configure.ac.
  219. # $CONFIG_AUX_DIR is the 'raw' directory, valid only in the source-tree.
  220. my $config_aux_dir = '';
  221. my $config_aux_dir_set_in_configure_ac = 0;
  222. # $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used
  223. # in Makefiles.
  224. my $am_config_aux_dir = '';
  225. # Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR
  226. # in configure.ac.
  227. my $config_libobj_dir = '';
  228. # Whether AM_GNU_GETTEXT has been seen in configure.ac.
  229. my $seen_gettext = 0;
  230. # Whether AM_GNU_GETTEXT([external]) is used.
  231. my $seen_gettext_external = 0;
  232. # Where AM_GNU_GETTEXT appears.
  233. my $ac_gettext_location;
  234. # Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen.
  235. my $seen_gettext_intl = 0;
  236. # The arguments of the AM_EXTRA_RECURSIVE_TARGETS call (if any).
  237. my @extra_recursive_targets = ();
  238. # Lists of tags supported by Libtool.
  239. my %libtool_tags = ();
  240. # 1 if Libtool uses LT_SUPPORTED_TAG. If it does, then it also
  241. # uses AC_REQUIRE_AUX_FILE.
  242. my $libtool_new_api = 0;
  243. # Most important AC_CANONICAL_* macro seen so far.
  244. my $seen_canonical = 0;
  245. # Where AM_MAINTAINER_MODE appears.
  246. my $seen_maint_mode;
  247. # Actual version we've seen.
  248. my $package_version = '';
  249. # Where version is defined.
  250. my $package_version_location;
  251. # TRUE if we've seen AM_PROG_AR
  252. my $seen_ar = 0;
  253. # Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument.
  254. my %required_aux_file = ();
  255. # Where AM_INIT_AUTOMAKE is called.
  256. my $seen_init_automake = 0;
  257. # TRUE if we've seen AM_AUTOMAKE_VERSION.
  258. my $seen_automake_version = 0;
  259. # Hash table of discovered configure substitutions. Keys are names,
  260. # values are 'FILE:LINE' strings which are used by error message
  261. # generation.
  262. my %configure_vars = ();
  263. # Ignored configure substitutions (i.e., variables not to be output in
  264. # Makefile.in)
  265. my %ignored_configure_vars = ();
  266. # Files included by $configure_ac.
  267. my @configure_deps = ();
  268. # Greatest timestamp of configure's dependencies.
  269. my $configure_deps_greatest_timestamp = 0;
  270. # Hash table of AM_CONDITIONAL variables seen in configure.
  271. my %configure_cond = ();
  272. # This maps extensions onto language names.
  273. my %extension_map = ();
  274. # List of the DIST_COMMON files we discovered while reading
  275. # configure.ac.
  276. my @configure_dist_common = ();
  277. # This maps languages names onto objects.
  278. my %languages = ();
  279. # Maps each linker variable onto a language object.
  280. my %link_languages = ();
  281. # maps extensions to needed source flags.
  282. my %sourceflags = ();
  283. # List of targets we must always output.
  284. # FIXME: Complete, and remove falsely required targets.
  285. my %required_targets =
  286. (
  287. 'all' => 1,
  288. 'dvi' => 1,
  289. 'pdf' => 1,
  290. 'ps' => 1,
  291. 'info' => 1,
  292. 'install-info' => 1,
  293. 'install' => 1,
  294. 'install-data' => 1,
  295. 'install-exec' => 1,
  296. 'uninstall' => 1,
  297. # FIXME: Not required, temporary hacks.
  298. # Well, actually they are sort of required: the -recursive
  299. # targets will run them anyway...
  300. 'html-am' => 1,
  301. 'dvi-am' => 1,
  302. 'pdf-am' => 1,
  303. 'ps-am' => 1,
  304. 'info-am' => 1,
  305. 'install-data-am' => 1,
  306. 'install-exec-am' => 1,
  307. 'install-html-am' => 1,
  308. 'install-dvi-am' => 1,
  309. 'install-pdf-am' => 1,
  310. 'install-ps-am' => 1,
  311. 'install-info-am' => 1,
  312. 'installcheck-am' => 1,
  313. 'uninstall-am' => 1,
  314. 'tags-am' => 1,
  315. 'ctags-am' => 1,
  316. 'cscopelist-am' => 1,
  317. 'install-man' => 1,
  318. );
  319. # Queue to push require_conf_file requirements to.
  320. my $required_conf_file_queue;
  321. # The name of the Makefile currently being processed.
  322. my $am_file = 'BUG';
  323. ################################################################
  324. ## ------------------------------------------ ##
  325. ## Variables reset by &initialize_per_input. ##
  326. ## ------------------------------------------ ##
  327. # Relative dir of the output makefile.
  328. my $relative_dir;
  329. # Greatest timestamp of the output's dependencies (excluding
  330. # configure's dependencies).
  331. my $output_deps_greatest_timestamp;
  332. # These variables are used when generating each Makefile.in.
  333. # They hold the Makefile.in until it is ready to be printed.
  334. my $output_vars;
  335. my $output_all;
  336. my $output_header;
  337. my $output_rules;
  338. my $output_trailer;
  339. # This is the conditional stack, updated on if/else/endif, and
  340. # used to build Condition objects.
  341. my @cond_stack;
  342. # This holds the set of included files.
  343. my @include_stack;
  344. # List of dependencies for the obvious targets.
  345. my @all;
  346. my @check;
  347. my @check_tests;
  348. # Keys in this hash table are files to delete. The associated
  349. # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
  350. my %clean_files;
  351. # Keys in this hash table are object files or other files in
  352. # subdirectories which need to be removed. This only holds files
  353. # which are created by compilations. The value in the hash indicates
  354. # when the file should be removed.
  355. my %compile_clean_files;
  356. # Keys in this hash table are directories where we expect to build a
  357. # libtool object. We use this information to decide what directories
  358. # to delete.
  359. my %libtool_clean_directories;
  360. # Value of $(SOURCES), used by tags.am.
  361. my @sources;
  362. # Sources which go in the distribution.
  363. my @dist_sources;
  364. # This hash maps object file names onto their corresponding source
  365. # file names. This is used to ensure that each object is created
  366. # by a single source file.
  367. my %object_map;
  368. # This hash maps object file names onto an integer value representing
  369. # whether this object has been built via ordinary compilation or
  370. # libtool compilation (the COMPILE_* constants).
  371. my %object_compilation_map;
  372. # This keeps track of the directories for which we've already
  373. # created dirstamp code. Keys are directories, values are stamp files.
  374. # Several keys can share the same stamp files if they are equivalent
  375. # (as are './/foo' and 'foo').
  376. my %directory_map;
  377. # All .P files.
  378. my %dep_files;
  379. # This is a list of all targets to run during "make dist".
  380. my @dist_targets;
  381. # Keep track of all programs declared in this Makefile, without
  382. # $(EXEEXT). @substitutions@ are not listed.
  383. my %known_programs;
  384. my %known_libraries;
  385. # This keeps track of which extensions we've seen (that we care
  386. # about).
  387. my %extension_seen;
  388. # This is random scratch space for the language finish functions.
  389. # Don't randomly overwrite it; examine other uses of keys first.
  390. my %language_scratch;
  391. # We keep track of which objects need special (per-executable)
  392. # handling on a per-language basis.
  393. my %lang_specific_files;
  394. # List of distributed files to be put in DIST_COMMON.
  395. my @dist_common;
  396. # This is set when 'handle_dist' has finished. Once this happens,
  397. # we should no longer push on dist_common.
  398. my $handle_dist_run;
  399. # Used to store a set of linkers needed to generate the sources currently
  400. # under consideration.
  401. my %linkers_used;
  402. # True if we need 'LINK' defined. This is a hack.
  403. my $need_link;
  404. # Does the generated Makefile have to build some compiled object
  405. # (for binary programs, or plain or libtool libraries)?
  406. my $must_handle_compiled_objects;
  407. # Record each file processed by make_paragraphs.
  408. my %transformed_files;
  409. ################################################################
  410. ## ---------------------------------------------- ##
  411. ## Variables not reset by &initialize_per_input. ##
  412. ## ---------------------------------------------- ##
  413. # Cache each file processed by make_paragraphs.
  414. # (This is different from %transformed_files because
  415. # %transformed_files is reset for each file while %am_file_cache
  416. # it global to the run.)
  417. my %am_file_cache;
  418. ################################################################
  419. # var_SUFFIXES_trigger ($TYPE, $VALUE)
  420. # ------------------------------------
  421. # This is called by Automake::Variable::define() when SUFFIXES
  422. # is defined ($TYPE eq '') or appended ($TYPE eq '+').
  423. # The work here needs to be performed as a side-effect of the
  424. # macro_define() call because SUFFIXES definitions impact
  425. # on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
  426. # the input am file.
  427. sub var_SUFFIXES_trigger
  428. {
  429. my ($type, $value) = @_;
  430. accept_extensions (split (' ', $value));
  431. }
  432. Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
  433. ################################################################
  434. # initialize_per_input ()
  435. # -----------------------
  436. # (Re)-Initialize per-Makefile.am variables.
  437. sub initialize_per_input ()
  438. {
  439. reset_local_duplicates ();
  440. $relative_dir = undef;
  441. $output_deps_greatest_timestamp = 0;
  442. $output_vars = '';
  443. $output_all = '';
  444. $output_header = '';
  445. $output_rules = '';
  446. $output_trailer = '';
  447. Automake::Options::reset;
  448. Automake::Variable::reset;
  449. Automake::Rule::reset;
  450. @cond_stack = ();
  451. @include_stack = ();
  452. @all = ();
  453. @check = ();
  454. @check_tests = ();
  455. %clean_files = ();
  456. %compile_clean_files = ();
  457. # We always include '.'. This isn't strictly correct.
  458. %libtool_clean_directories = ('.' => 1);
  459. @sources = ();
  460. @dist_sources = ();
  461. %object_map = ();
  462. %object_compilation_map = ();
  463. %directory_map = ();
  464. %dep_files = ();
  465. @dist_targets = ();
  466. @dist_common = ();
  467. $handle_dist_run = 0;
  468. %known_programs = ();
  469. %known_libraries = ();
  470. %extension_seen = ();
  471. %language_scratch = ();
  472. %lang_specific_files = ();
  473. $need_link = 0;
  474. $must_handle_compiled_objects = 0;
  475. %transformed_files = ();
  476. }
  477. ################################################################
  478. # Initialize our list of languages that are internally supported.
  479. my @cpplike_flags =
  480. qw{
  481. $(DEFS)
  482. $(DEFAULT_INCLUDES)
  483. $(INCLUDES)
  484. $(AM_CPPFLAGS)
  485. $(CPPFLAGS)
  486. };
  487. # C.
  488. register_language ('name' => 'c',
  489. 'Name' => 'C',
  490. 'config_vars' => ['CC'],
  491. 'autodep' => '',
  492. 'flags' => ['CFLAGS', 'CPPFLAGS'],
  493. 'ccer' => 'CC',
  494. 'compiler' => 'COMPILE',
  495. 'compile' => "\$(CC) @cpplike_flags \$(AM_CFLAGS) \$(CFLAGS)",
  496. 'lder' => 'CCLD',
  497. 'ld' => '$(CC)',
  498. 'linker' => 'LINK',
  499. 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  500. 'compile_flag' => '-c',
  501. 'output_flag' => '-o',
  502. 'libtool_tag' => 'CC',
  503. 'extensions' => ['.c']);
  504. # C++.
  505. register_language ('name' => 'cxx',
  506. 'Name' => 'C++',
  507. 'config_vars' => ['CXX'],
  508. 'linker' => 'CXXLINK',
  509. 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  510. 'autodep' => 'CXX',
  511. 'flags' => ['CXXFLAGS', 'CPPFLAGS'],
  512. 'compile' => "\$(CXX) @cpplike_flags \$(AM_CXXFLAGS) \$(CXXFLAGS)",
  513. 'ccer' => 'CXX',
  514. 'compiler' => 'CXXCOMPILE',
  515. 'compile_flag' => '-c',
  516. 'output_flag' => '-o',
  517. 'libtool_tag' => 'CXX',
  518. 'lder' => 'CXXLD',
  519. 'ld' => '$(CXX)',
  520. 'pure' => 1,
  521. 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
  522. # Objective C.
  523. register_language ('name' => 'objc',
  524. 'Name' => 'Objective C',
  525. 'config_vars' => ['OBJC'],
  526. 'linker' => 'OBJCLINK',
  527. 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  528. 'autodep' => 'OBJC',
  529. 'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
  530. 'compile' => "\$(OBJC) @cpplike_flags \$(AM_OBJCFLAGS) \$(OBJCFLAGS)",
  531. 'ccer' => 'OBJC',
  532. 'compiler' => 'OBJCCOMPILE',
  533. 'compile_flag' => '-c',
  534. 'output_flag' => '-o',
  535. 'lder' => 'OBJCLD',
  536. 'ld' => '$(OBJC)',
  537. 'pure' => 1,
  538. 'extensions' => ['.m']);
  539. # Objective C++.
  540. register_language ('name' => 'objcxx',
  541. 'Name' => 'Objective C++',
  542. 'config_vars' => ['OBJCXX'],
  543. 'linker' => 'OBJCXXLINK',
  544. 'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  545. 'autodep' => 'OBJCXX',
  546. 'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'],
  547. 'compile' => "\$(OBJCXX) @cpplike_flags \$(AM_OBJCXXFLAGS) \$(OBJCXXFLAGS)",
  548. 'ccer' => 'OBJCXX',
  549. 'compiler' => 'OBJCXXCOMPILE',
  550. 'compile_flag' => '-c',
  551. 'output_flag' => '-o',
  552. 'lder' => 'OBJCXXLD',
  553. 'ld' => '$(OBJCXX)',
  554. 'pure' => 1,
  555. 'extensions' => ['.mm']);
  556. # Unified Parallel C.
  557. register_language ('name' => 'upc',
  558. 'Name' => 'Unified Parallel C',
  559. 'config_vars' => ['UPC'],
  560. 'linker' => 'UPCLINK',
  561. 'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  562. 'autodep' => 'UPC',
  563. 'flags' => ['UPCFLAGS', 'CPPFLAGS'],
  564. 'compile' => "\$(UPC) @cpplike_flags \$(AM_UPCFLAGS) \$(UPCFLAGS)",
  565. 'ccer' => 'UPC',
  566. 'compiler' => 'UPCCOMPILE',
  567. 'compile_flag' => '-c',
  568. 'output_flag' => '-o',
  569. 'lder' => 'UPCLD',
  570. 'ld' => '$(UPC)',
  571. 'pure' => 1,
  572. 'extensions' => ['.upc']);
  573. # Headers.
  574. register_language ('name' => 'header',
  575. 'Name' => 'Header',
  576. 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
  577. '.hpp', '.inc'],
  578. # No output.
  579. 'output_extensions' => sub { return () },
  580. # Nothing to do.
  581. '_finish' => sub { });
  582. # Vala
  583. register_language ('name' => 'vala',
  584. 'Name' => 'Vala',
  585. 'config_vars' => ['VALAC'],
  586. 'flags' => [],
  587. 'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
  588. 'ccer' => 'VALAC',
  589. 'compiler' => 'VALACOMPILE',
  590. 'extensions' => ['.vala'],
  591. 'output_extensions' => sub { (my $ext = $_[0]) =~ s/vala$/c/;
  592. return ($ext,) },
  593. 'rule_file' => 'vala',
  594. '_finish' => \&lang_vala_finish,
  595. '_target_hook' => \&lang_vala_target_hook,
  596. 'nodist_specific' => 1);
  597. # Yacc (C & C++).
  598. register_language ('name' => 'yacc',
  599. 'Name' => 'Yacc',
  600. 'config_vars' => ['YACC'],
  601. 'flags' => ['YFLAGS'],
  602. 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)',
  603. 'ccer' => 'YACC',
  604. 'compiler' => 'YACCCOMPILE',
  605. 'extensions' => ['.y'],
  606. 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
  607. return ($ext,) },
  608. 'rule_file' => 'yacc',
  609. '_finish' => \&lang_yacc_finish,
  610. '_target_hook' => \&lang_yacc_target_hook,
  611. 'nodist_specific' => 1);
  612. register_language ('name' => 'yaccxx',
  613. 'Name' => 'Yacc (C++)',
  614. 'config_vars' => ['YACC'],
  615. 'rule_file' => 'yacc',
  616. 'flags' => ['YFLAGS'],
  617. 'ccer' => 'YACC',
  618. 'compiler' => 'YACCCOMPILE',
  619. 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)',
  620. 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
  621. 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
  622. return ($ext,) },
  623. '_finish' => \&lang_yacc_finish,
  624. '_target_hook' => \&lang_yacc_target_hook,
  625. 'nodist_specific' => 1);
  626. # Lex (C & C++).
  627. register_language ('name' => 'lex',
  628. 'Name' => 'Lex',
  629. 'config_vars' => ['LEX'],
  630. 'rule_file' => 'lex',
  631. 'flags' => ['LFLAGS'],
  632. 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)',
  633. 'ccer' => 'LEX',
  634. 'compiler' => 'LEXCOMPILE',
  635. 'extensions' => ['.l'],
  636. 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
  637. return ($ext,) },
  638. '_finish' => \&lang_lex_finish,
  639. '_target_hook' => \&lang_lex_target_hook,
  640. 'nodist_specific' => 1);
  641. register_language ('name' => 'lexxx',
  642. 'Name' => 'Lex (C++)',
  643. 'config_vars' => ['LEX'],
  644. 'rule_file' => 'lex',
  645. 'flags' => ['LFLAGS'],
  646. 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)',
  647. 'ccer' => 'LEX',
  648. 'compiler' => 'LEXCOMPILE',
  649. 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
  650. 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
  651. return ($ext,) },
  652. '_finish' => \&lang_lex_finish,
  653. '_target_hook' => \&lang_lex_target_hook,
  654. 'nodist_specific' => 1);
  655. # Assembler.
  656. register_language ('name' => 'asm',
  657. 'Name' => 'Assembler',
  658. 'config_vars' => ['CCAS', 'CCASFLAGS'],
  659. 'flags' => ['CCASFLAGS'],
  660. # Users can set AM_CCASFLAGS to include DEFS, INCLUDES,
  661. # or anything else required. They can also set CCAS.
  662. # Or simply use Preprocessed Assembler.
  663. 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
  664. 'ccer' => 'CCAS',
  665. 'compiler' => 'CCASCOMPILE',
  666. 'compile_flag' => '-c',
  667. 'output_flag' => '-o',
  668. 'extensions' => ['.s']);
  669. # Preprocessed Assembler.
  670. register_language ('name' => 'cppasm',
  671. 'Name' => 'Preprocessed Assembler',
  672. 'config_vars' => ['CCAS', 'CCASFLAGS'],
  673. 'autodep' => 'CCAS',
  674. 'flags' => ['CCASFLAGS', 'CPPFLAGS'],
  675. 'compile' => "\$(CCAS) @cpplike_flags \$(AM_CCASFLAGS) \$(CCASFLAGS)",
  676. 'ccer' => 'CPPAS',
  677. 'compiler' => 'CPPASCOMPILE',
  678. 'compile_flag' => '-c',
  679. 'output_flag' => '-o',
  680. 'extensions' => ['.S', '.sx']);
  681. # Fortran 77
  682. register_language ('name' => 'f77',
  683. 'Name' => 'Fortran 77',
  684. 'config_vars' => ['F77'],
  685. 'linker' => 'F77LINK',
  686. 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  687. 'flags' => ['FFLAGS'],
  688. 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
  689. 'ccer' => 'F77',
  690. 'compiler' => 'F77COMPILE',
  691. 'compile_flag' => '-c',
  692. 'output_flag' => '-o',
  693. 'libtool_tag' => 'F77',
  694. 'lder' => 'F77LD',
  695. 'ld' => '$(F77)',
  696. 'pure' => 1,
  697. 'extensions' => ['.f', '.for']);
  698. # Fortran
  699. register_language ('name' => 'fc',
  700. 'Name' => 'Fortran',
  701. 'config_vars' => ['FC'],
  702. 'linker' => 'FCLINK',
  703. 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  704. 'flags' => ['FCFLAGS'],
  705. 'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)',
  706. 'ccer' => 'FC',
  707. 'compiler' => 'FCCOMPILE',
  708. 'compile_flag' => '-c',
  709. 'output_flag' => '-o',
  710. 'libtool_tag' => 'FC',
  711. 'lder' => 'FCLD',
  712. 'ld' => '$(FC)',
  713. 'pure' => 1,
  714. 'extensions' => ['.f90', '.f95', '.f03', '.f08']);
  715. # Preprocessed Fortran
  716. register_language ('name' => 'ppfc',
  717. 'Name' => 'Preprocessed Fortran',
  718. 'config_vars' => ['FC'],
  719. 'linker' => 'FCLINK',
  720. 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  721. 'lder' => 'FCLD',
  722. 'ld' => '$(FC)',
  723. 'flags' => ['FCFLAGS', 'CPPFLAGS'],
  724. 'ccer' => 'PPFC',
  725. 'compiler' => 'PPFCCOMPILE',
  726. 'compile' => "\$(FC) @cpplike_flags \$(AM_FCFLAGS) \$(FCFLAGS)",
  727. 'compile_flag' => '-c',
  728. 'output_flag' => '-o',
  729. 'libtool_tag' => 'FC',
  730. 'pure' => 1,
  731. 'extensions' => ['.F90','.F95', '.F03', '.F08']);
  732. # Preprocessed Fortran 77
  733. #
  734. # The current support for preprocessing Fortran 77 just involves
  735. # passing "$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
  736. # $(CPPFLAGS)" as additional flags to the Fortran 77 compiler, since
  737. # this is how GNU Make does it; see the "GNU Make Manual, Edition 0.51
  738. # for 'make' Version 3.76 Beta" (specifically, from info file
  739. # '(make)Catalogue of Rules').
  740. #
  741. # A better approach would be to write an Autoconf test
  742. # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
  743. # Fortran 77 compilers know how to do preprocessing. The Autoconf
  744. # macro AC_PROG_FPP should test the Fortran 77 compiler first for
  745. # preprocessing capabilities, and then fall back on cpp (if cpp were
  746. # available).
  747. register_language ('name' => 'ppf77',
  748. 'Name' => 'Preprocessed Fortran 77',
  749. 'config_vars' => ['F77'],
  750. 'linker' => 'F77LINK',
  751. 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  752. 'lder' => 'F77LD',
  753. 'ld' => '$(F77)',
  754. 'flags' => ['FFLAGS', 'CPPFLAGS'],
  755. 'ccer' => 'PPF77',
  756. 'compiler' => 'PPF77COMPILE',
  757. 'compile' => "\$(F77) @cpplike_flags \$(AM_FFLAGS) \$(FFLAGS)",
  758. 'compile_flag' => '-c',
  759. 'output_flag' => '-o',
  760. 'libtool_tag' => 'F77',
  761. 'pure' => 1,
  762. 'extensions' => ['.F']);
  763. # Ratfor.
  764. register_language ('name' => 'ratfor',
  765. 'Name' => 'Ratfor',
  766. 'config_vars' => ['F77'],
  767. 'linker' => 'F77LINK',
  768. 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  769. 'lder' => 'F77LD',
  770. 'ld' => '$(F77)',
  771. 'flags' => ['RFLAGS', 'FFLAGS'],
  772. # FIXME also FFLAGS.
  773. 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
  774. 'ccer' => 'F77',
  775. 'compiler' => 'RCOMPILE',
  776. 'compile_flag' => '-c',
  777. 'output_flag' => '-o',
  778. 'libtool_tag' => 'F77',
  779. 'pure' => 1,
  780. 'extensions' => ['.r']);
  781. # Java via gcj.
  782. register_language ('name' => 'java',
  783. 'Name' => 'Java',
  784. 'config_vars' => ['GCJ'],
  785. 'linker' => 'GCJLINK',
  786. 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
  787. 'autodep' => 'GCJ',
  788. 'flags' => ['GCJFLAGS'],
  789. 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
  790. 'ccer' => 'GCJ',
  791. 'compiler' => 'GCJCOMPILE',
  792. 'compile_flag' => '-c',
  793. 'output_flag' => '-o',
  794. 'libtool_tag' => 'GCJ',
  795. 'lder' => 'GCJLD',
  796. 'ld' => '$(GCJ)',
  797. 'pure' => 1,
  798. 'extensions' => ['.java', '.class', '.zip', '.jar']);
  799. ################################################################
  800. # Error reporting functions.
  801. # err_am ($MESSAGE, [%OPTIONS])
  802. # -----------------------------
  803. # Uncategorized errors about the current Makefile.am.
  804. sub err_am
  805. {
  806. msg_am ('error', @_);
  807. }
  808. # err_ac ($MESSAGE, [%OPTIONS])
  809. # -----------------------------
  810. # Uncategorized errors about configure.ac.
  811. sub err_ac
  812. {
  813. msg_ac ('error', @_);
  814. }
  815. # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
  816. # ---------------------------------------
  817. # Messages about about the current Makefile.am.
  818. sub msg_am
  819. {
  820. my ($channel, $msg, %opts) = @_;
  821. msg $channel, "${am_file}.am", $msg, %opts;
  822. }
  823. # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS])
  824. # ---------------------------------------
  825. # Messages about about configure.ac.
  826. sub msg_ac
  827. {
  828. my ($channel, $msg, %opts) = @_;
  829. msg $channel, $configure_ac, $msg, %opts;
  830. }
  831. ################################################################
  832. # subst ($TEXT)
  833. # -------------
  834. # Return a configure-style substitution using the indicated text.
  835. # We do this to avoid having the substitutions directly in automake.in;
  836. # when we do that they are sometimes removed and this causes confusion
  837. # and bugs.
  838. sub subst
  839. {
  840. my ($text) = @_;
  841. return '@' . $text . '@';
  842. }
  843. ################################################################
  844. # $BACKPATH
  845. # backname ($RELDIR)
  846. # -------------------
  847. # If I "cd $RELDIR", then to come back, I should "cd $BACKPATH".
  848. # For instance 'src/foo' => '../..'.
  849. # Works with non strictly increasing paths, i.e., 'src/../lib' => '..'.
  850. sub backname
  851. {
  852. my ($file) = @_;
  853. my @res;
  854. foreach (split (/\//, $file))
  855. {
  856. next if $_ eq '.' || $_ eq '';
  857. if ($_ eq '..')
  858. {
  859. pop @res
  860. or prog_error ("trying to reverse path '$file' pointing outside tree");
  861. }
  862. else
  863. {
  864. push (@res, '..');
  865. }
  866. }
  867. return join ('/', @res) || '.';
  868. }
  869. ################################################################
  870. # Silent rules handling functions.
  871. # verbose_var (NAME)
  872. # ------------------
  873. # The public variable stem used to implement silent rules.
  874. sub verbose_var
  875. {
  876. my ($name) = @_;
  877. return 'AM_V_' . $name;
  878. }
  879. # verbose_private_var (NAME)
  880. # --------------------------
  881. # The naming policy for the private variables for silent rules.
  882. sub verbose_private_var
  883. {
  884. my ($name) = @_;
  885. return 'am__v_' . $name;
  886. }
  887. # define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE])
  888. # ----------------------------------------------------------
  889. # For silent rules, setup VAR and dispatcher, to expand to
  890. # VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to
  891. # empty) if not.
  892. sub define_verbose_var
  893. {
  894. my ($name, $silent_val, $verbose_val) = @_;
  895. $verbose_val = '' unless defined $verbose_val;
  896. my $var = verbose_var ($name);
  897. my $pvar = verbose_private_var ($name);
  898. my $silent_var = $pvar . '_0';
  899. my $verbose_var = $pvar . '_1';
  900. # For typical 'make's, 'configure' replaces AM_V (inside @@) with $(V)
  901. # and AM_DEFAULT_V (inside @@) with $(AM_DEFAULT_VERBOSITY).
  902. # For strict POSIX 2008 'make's, it replaces them with 0 or 1 instead.
  903. # See AM_SILENT_RULES in m4/silent.m4.
  904. define_variable ($var, '$(' . $pvar . '_@'.'AM_V'.'@)', INTERNAL);
  905. define_variable ($pvar . '_', '$(' . $pvar . '_@'.'AM_DEFAULT_V'.'@)',
  906. INTERNAL);
  907. Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE,
  908. $silent_val, '', INTERNAL, VAR_ASIS)
  909. if (! vardef ($silent_var, TRUE));
  910. Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE,
  911. $verbose_val, '', INTERNAL, VAR_ASIS)
  912. if (! vardef ($verbose_var, TRUE));
  913. }
  914. # verbose_flag (NAME)
  915. # -------------------
  916. # Contents of '%VERBOSE%' variable to expand before rule command.
  917. sub verbose_flag
  918. {
  919. my ($name) = @_;
  920. return '$(' . verbose_var ($name) . ')';
  921. }
  922. sub verbose_nodep_flag
  923. {
  924. my ($name) = @_;
  925. return '$(' . verbose_var ($name) . subst ('am__nodep') . ')';
  926. }
  927. # silent_flag
  928. # -----------
  929. # Contents of %SILENT%: variable to expand to '@' when silent.
  930. sub silent_flag ()
  931. {
  932. return verbose_flag ('at');
  933. }
  934. # define_verbose_tagvar (NAME)
  935. # ----------------------------
  936. # Engage the needed silent rules machinery for tag NAME.
  937. sub define_verbose_tagvar
  938. {
  939. my ($name) = @_;
  940. define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;');
  941. }
  942. # Engage the needed silent rules machinery for assorted texinfo commands.
  943. sub define_verbose_texinfo ()
  944. {
  945. my @tagvars = ('DVIPS', 'MAKEINFO', 'INFOHTML', 'TEXI2DVI', 'TEXI2PDF');
  946. foreach my $tag (@tagvars)
  947. {
  948. define_verbose_tagvar($tag);
  949. }
  950. define_verbose_var('texinfo', '-q');
  951. define_verbose_var('texidevnull', '> /dev/null');
  952. }
  953. # Engage the needed silent rules machinery for 'libtool --silent'.
  954. sub define_verbose_libtool ()
  955. {
  956. define_verbose_var ('lt', '--silent');
  957. return verbose_flag ('lt');
  958. }
  959. sub handle_silent ()
  960. {
  961. # Define "$(AM_V_P)", expanding to a shell conditional that can be
  962. # used in make recipes to determine whether we are being run in
  963. # silent mode or not. The choice of the name derives from the LISP
  964. # convention of appending the letter 'P' to denote a predicate (see
  965. # also "the '-P' convention" in the Jargon File); we do so for lack
  966. # of a better convention.
  967. define_verbose_var ('P', 'false', ':');
  968. # *Always* provide the user with '$(AM_V_GEN)', unconditionally.
  969. define_verbose_tagvar ('GEN');
  970. define_verbose_var ('at', '@');
  971. }
  972. ################################################################
  973. # Handle AUTOMAKE_OPTIONS variable. Return 0 on error, 1 otherwise.
  974. sub handle_options ()
  975. {
  976. my $var = var ('AUTOMAKE_OPTIONS');
  977. if ($var)
  978. {
  979. if ($var->has_conditional_contents)
  980. {
  981. msg_var ('unsupported', $var,
  982. "'AUTOMAKE_OPTIONS' cannot have conditional contents");
  983. }
  984. my @options = map { { option => $_->[1], where => $_->[0] } }
  985. $var->value_as_list_recursive (cond_filter => TRUE,
  986. location => 1);
  987. return 0 unless process_option_list (@options);
  988. }
  989. if ($strictness == GNITS)
  990. {
  991. set_option ('readme-alpha', INTERNAL);
  992. set_option ('std-options', INTERNAL);
  993. set_option ('check-news', INTERNAL);
  994. }
  995. return 1;
  996. }
  997. # shadow_unconditionally ($varname, $where)
  998. # -----------------------------------------
  999. # Return a $(variable) that contains all possible values
  1000. # $varname can take.
  1001. # If the VAR wasn't defined conditionally, return $(VAR).
  1002. # Otherwise we create an am__VAR_DIST variable which contains
  1003. # all possible values, and return $(am__VAR_DIST).
  1004. sub shadow_unconditionally
  1005. {
  1006. my ($varname, $where) = @_;
  1007. my $var = var $varname;
  1008. if ($var->has_conditional_contents)
  1009. {
  1010. $varname = "am__${varname}_DIST";
  1011. my @files = uniq ($var->value_as_list_recursive);
  1012. define_pretty_variable ($varname, TRUE, $where, @files);
  1013. }
  1014. return "\$($varname)"
  1015. }
  1016. # check_user_variables (@LIST)
  1017. # ----------------------------
  1018. # Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR
  1019. # otherwise.
  1020. sub check_user_variables
  1021. {
  1022. my @dont_override = @_;
  1023. foreach my $flag (@dont_override)
  1024. {
  1025. my $var = var $flag;
  1026. if ($var)
  1027. {
  1028. for my $cond ($var->conditions->conds)
  1029. {
  1030. if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
  1031. {
  1032. msg_cond_var ('gnu', $cond, $flag,
  1033. "'$flag' is a user variable, "
  1034. . "you should not override it;\n"
  1035. . "use 'AM_$flag' instead");
  1036. }
  1037. }
  1038. }
  1039. }
  1040. }
  1041. # Call finish function for each language that was used.
  1042. sub handle_languages ()
  1043. {
  1044. if (! option 'no-dependencies')
  1045. {
  1046. # Include auto-dep code. Don't include it if DEP_FILES would
  1047. # be empty.
  1048. if (keys %extension_seen && keys %dep_files)
  1049. {
  1050. # Set location of depcomp.
  1051. define_variable ('depcomp',
  1052. "\$(SHELL) $am_config_aux_dir/depcomp",
  1053. INTERNAL);
  1054. define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
  1055. require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
  1056. my @deplist = sort keys %dep_files;
  1057. # Generate each 'include' individually. Irix 6 make will
  1058. # not properly include several files resulting from a
  1059. # variable expansion; generating many separate includes
  1060. # seems safest.
  1061. $output_rules .= "\n";
  1062. foreach my $iter (@deplist)
  1063. {
  1064. $output_rules .= (subst ('AMDEP_TRUE')
  1065. . subst ('am__include')
  1066. . ' '
  1067. . subst ('am__quote')
  1068. . $iter
  1069. . subst ('am__quote')
  1070. . "\n");
  1071. }
  1072. # Compute the set of directories to remove in distclean-depend.
  1073. my @depdirs = uniq (map { dirname ($_) } @deplist);
  1074. $output_rules .= file_contents ('depend',
  1075. new Automake::Location,
  1076. DEPDIRS => "@depdirs");
  1077. }
  1078. }
  1079. else
  1080. {
  1081. define_variable ('depcomp', '', INTERNAL);
  1082. define_variable ('am__depfiles_maybe', '', INTERNAL);
  1083. }
  1084. my %done;
  1085. # Is the C linker needed?
  1086. my $needs_c = 0;
  1087. foreach my $ext (sort keys %extension_seen)
  1088. {
  1089. next unless $extension_map{$ext};
  1090. my $lang = $languages{$extension_map{$ext}};
  1091. my $rule_file = $lang->rule_file || 'depend2';
  1092. # Get information on $LANG.
  1093. my $pfx = $lang->autodep;
  1094. my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
  1095. my ($AMDEP, $FASTDEP) =
  1096. (option 'no-dependencies' || $lang->autodep eq 'no')
  1097. ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx");
  1098. my $verbose = verbose_flag ($lang->ccer || 'GEN');
  1099. my $verbose_nodep = ($AMDEP eq 'FALSE')
  1100. ? $verbose : verbose_nodep_flag ($lang->ccer || 'GEN');
  1101. my $silent = silent_flag ();
  1102. my %transform = ('EXT' => $ext,
  1103. 'PFX' => $pfx,
  1104. 'FPFX' => $fpfx,
  1105. 'AMDEP' => $AMDEP,
  1106. 'FASTDEP' => $FASTDEP,
  1107. '-c' => $lang->compile_flag || '',
  1108. # These are not used, but they need to be defined
  1109. # so transform() do not complain.
  1110. SUBDIROBJ => 0,
  1111. 'DERIVED-EXT' => 'BUG',
  1112. DIST_SOURCE => 1,
  1113. VERBOSE => $verbose,
  1114. 'VERBOSE-NODEP' => $verbose_nodep,
  1115. SILENT => $silent,
  1116. );
  1117. # Generate the appropriate rules for this extension.
  1118. if (((! option 'no-dependencies') && $lang->autodep ne 'no')
  1119. || defined $lang->compile)
  1120. {
  1121. # Compute a possible derived extension.
  1122. # This is not used by depend2.am.
  1123. my $der_ext = ($lang->output_extensions->($ext))[0];
  1124. # When we output an inference rule like '.c.o:' we
  1125. # have two cases to consider: either subdir-objects
  1126. # is used, or it is not.
  1127. #
  1128. # In the latter case the rule is used to build objects
  1129. # in the current directory, and dependencies always
  1130. # go into './$(DEPDIR)/'. We can hard-code this value.
  1131. #
  1132. # In the former case the rule can be used to build
  1133. # objects in sub-directories too. Dependencies should
  1134. # go into the appropriate sub-directories, e.g.,
  1135. # 'sub/$(DEPDIR)/'. The value of this directory
  1136. # needs to be computed on-the-fly.
  1137. #
  1138. # DEPBASE holds the name of this directory, plus the
  1139. # basename part of the object file (extensions Po, TPo,
  1140. # Plo, TPlo will be added later as appropriate). It is
  1141. # either hardcoded, or a shell variable ('$depbase') that
  1142. # will be computed by the rule.
  1143. my $depbase =
  1144. option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*';
  1145. $output_rules .=
  1146. file_contents ($rule_file,
  1147. new Automake::Location,
  1148. %transform,
  1149. GENERIC => 1,
  1150. 'DERIVED-EXT' => $der_ext,
  1151. DEPBASE => $depbase,
  1152. BASE => '$*',
  1153. SOURCE => '$<',
  1154. SOURCEFLAG => $sourceflags{$ext} || '',
  1155. OBJ => '$@',
  1156. OBJOBJ => '$@',
  1157. LTOBJ => '$@',
  1158. COMPILE => '$(' . $lang->compiler . ')',
  1159. LTCOMPILE => '$(LT' . $lang->compiler . ')',
  1160. -o => $lang->output_flag,
  1161. SUBDIROBJ => !! option 'subdir-objects');
  1162. }
  1163. # Now include code for each specially handled object with this
  1164. # language.
  1165. my %seen_files = ();
  1166. foreach my $file (@{$lang_specific_files{$lang->name}})
  1167. {
  1168. my ($derived, $source, $obj, $myext, $srcext, %file_transform) = @$file;
  1169. # We might see a given object twice, for instance if it is
  1170. # used under different conditions.
  1171. next if defined $seen_files{$obj};
  1172. $seen_files{$obj} = 1;
  1173. prog_error ("found " . $lang->name .
  1174. " in handle_languages, but compiler not defined")
  1175. unless defined $lang->compile;
  1176. my $obj_compile = $lang->compile;
  1177. # Rewrite each occurrence of 'AM_$flag' in the compile
  1178. # rule into '${derived}_$flag' if it exists.
  1179. for my $flag (@{$lang->flags})
  1180. {
  1181. my $val = "${derived}_$flag";
  1182. $obj_compile =~ s/\(AM_$flag\)/\($val\)/
  1183. if set_seen ($val);
  1184. }
  1185. my $libtool_tag = '';
  1186. if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag})
  1187. {
  1188. $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
  1189. }
  1190. my $ptltflags = "${derived}_LIBTOOLFLAGS";
  1191. $ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags;
  1192. my $ltverbose = define_verbose_libtool ();
  1193. my $obj_ltcompile =
  1194. "\$(LIBTOOL) $ltverbose $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) "
  1195. . "--mode=compile $obj_compile";
  1196. # We _need_ '-o' for per object rules.
  1197. my $output_flag = $lang->output_flag || '-o';
  1198. my $depbase = dirname ($obj);
  1199. $depbase = ''
  1200. if $depbase eq '.';
  1201. $depbase .= '/'
  1202. unless $depbase eq '';
  1203. $depbase .= '$(DEPDIR)/' . basename ($obj);
  1204. $output_rules .=
  1205. file_contents ($rule_file,
  1206. new Automake::Location,
  1207. %transform,
  1208. GENERIC => 0,
  1209. DEPBASE => $depbase,
  1210. BASE => $obj,
  1211. SOURCE => $source,
  1212. SOURCEFLAG => $sourceflags{$srcext} || '',
  1213. # Use $myext and not '.o' here, in case
  1214. # we are actually building a new source
  1215. # file -- e.g. via yacc.
  1216. OBJ => "$obj$myext",
  1217. OBJOBJ => "$obj.obj",
  1218. LTOBJ => "$obj.lo",
  1219. VERBOSE => $verbose,
  1220. 'VERBOSE-NODEP' => $verbose_nodep,
  1221. SILENT => $silent,
  1222. COMPILE => $obj_compile,
  1223. LTCOMPILE => $obj_ltcompile,
  1224. -o => $output_flag,
  1225. %file_transform);
  1226. }
  1227. # The rest of the loop is done once per language.
  1228. next if defined $done{$lang};
  1229. $done{$lang} = 1;
  1230. # Load the language dependent Makefile chunks.
  1231. my %lang = map { uc ($_) => 0 } keys %languages;
  1232. $lang{uc ($lang->name)} = 1;
  1233. $output_rules .= file_contents ('lang-compile',
  1234. new Automake::Location,
  1235. %transform, %lang);
  1236. # If the source to a program consists entirely of code from a
  1237. # 'pure' language, for instance C++ or Fortran 77, then we
  1238. # don't need the C compiler code. However if we run into
  1239. # something unusual then we do generate the C code. There are
  1240. # probably corner cases here that do not work properly.
  1241. # People linking Java code to Fortran code deserve pain.
  1242. $needs_c ||= ! $lang->pure;
  1243. define_compiler_variable ($lang)
  1244. if ($lang->compile);
  1245. define_linker_variable ($lang)
  1246. if ($lang->link);
  1247. require_variables ("$am_file.am", $lang->Name . " source seen",
  1248. TRUE, @{$lang->config_vars});
  1249. # Call the finisher.
  1250. $lang->finish;
  1251. # Flags listed in '->flags' are user variables (per GNU Standards),
  1252. # they should not be overridden in the Makefile...
  1253. my @dont_override = @{$lang->flags};
  1254. # ... and so is LDFLAGS.
  1255. push @dont_override, 'LDFLAGS' if $lang->link;
  1256. check_user_variables @dont_override;
  1257. }
  1258. # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
  1259. # suffix rule was learned), don't bother with the C stuff. But if
  1260. # anything else creeps in, then use it.
  1261. my @languages_seen = map { $languages{$extension_map{$_}}->name }
  1262. (keys %extension_seen);
  1263. @languages_seen = uniq (@languages_seen);
  1264. $needs_c = 1 if @languages_seen > 1;
  1265. if ($need_link || $needs_c)
  1266. {
  1267. define_compiler_variable ($languages{'c'})
  1268. unless defined $done{$languages{'c'}};
  1269. define_linker_variable ($languages{'c'});
  1270. }
  1271. }
  1272. # append_exeext { PREDICATE } $MACRO
  1273. # ----------------------------------
  1274. # Append $(EXEEXT) to each filename in $F appearing in the Makefile
  1275. # variable $MACRO if &PREDICATE($F) is true. @substitutions@ are
  1276. # ignored.
  1277. #
  1278. # This is typically used on all filenames of *_PROGRAMS, and filenames
  1279. # of TESTS that are programs.
  1280. sub append_exeext (&$)
  1281. {
  1282. my ($pred, $macro) = @_;
  1283. transform_variable_recursively
  1284. ($macro, $macro, 'am__EXEEXT', 0, INTERNAL,
  1285. sub {
  1286. my ($subvar, $val, $cond, $full_cond) = @_;
  1287. # Append $(EXEEXT) unless the user did it already, or it's a
  1288. # @substitution@.
  1289. $val .= '$(EXEEXT)'
  1290. if $val !~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/ && &$pred ($val);
  1291. return $val;
  1292. });
  1293. }
  1294. # Check to make sure a source defined in LIBOBJS is not explicitly
  1295. # mentioned. This is a separate function (as opposed to being inlined
  1296. # in handle_source_transform) because it isn't always appropriate to
  1297. # do this check.
  1298. sub check_libobjs_sources
  1299. {
  1300. my ($one_file, $unxformed) = @_;
  1301. foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
  1302. 'dist_EXTRA_', 'nodist_EXTRA_')
  1303. {
  1304. my @files;
  1305. my $varname = $prefix . $one_file . '_SOURCES';
  1306. my $var = var ($varname);
  1307. if ($var)
  1308. {
  1309. @files = $var->value_as_list_recursive;
  1310. }
  1311. elsif ($prefix eq '')
  1312. {
  1313. @files = ($unxformed . '.c');
  1314. }
  1315. else
  1316. {
  1317. next;
  1318. }
  1319. foreach my $file (@files)
  1320. {
  1321. err_var ($prefix . $one_file . '_SOURCES',
  1322. "automatically discovered file '$file' should not" .
  1323. " be explicitly mentioned")
  1324. if defined $libsources{$file};
  1325. }
  1326. }
  1327. }
  1328. # @OBJECTS
  1329. # handle_single_transform ($VAR, $TOPPARENT, $DERIVED, $OBJ, $FILE, %TRANSFORM)
  1330. # -----------------------------------------------------------------------------
  1331. # Does much of the actual work for handle_source_transform.
  1332. # Arguments are:
  1333. # $VAR is the name of the variable that the source filenames come from
  1334. # $TOPPARENT is the name of the _SOURCES variable which is being processed
  1335. # $DERIVED is the name of resulting executable or library
  1336. # $OBJ is the object extension (e.g., '.lo')
  1337. # $FILE the source file to transform
  1338. # %TRANSFORM contains extras arguments to pass to file_contents
  1339. # when producing explicit rules
  1340. # Result is a list of the names of objects
  1341. # %linkers_used will be updated with any linkers needed
  1342. sub handle_single_transform
  1343. {
  1344. my ($var, $topparent, $derived, $obj, $_file, %transform) = @_;
  1345. my @files = ($_file);
  1346. my @result = ();
  1347. # Turn sources into objects. We use a while loop like this
  1348. # because we might add to @files in the loop.
  1349. while (scalar @files > 0)
  1350. {
  1351. $_ = shift @files;
  1352. # Configure substitutions in _SOURCES variables are errors.
  1353. if (/^\@.*\@$/)
  1354. {
  1355. my $parent_msg = '';
  1356. $parent_msg = "\nand is referred to from '$topparent'"
  1357. if $topparent ne $var->name;
  1358. err_var ($var,
  1359. "'" . $var->name . "' includes configure substitution '$_'"
  1360. . $parent_msg . ";\nconfigure " .
  1361. "substitutions are not allowed in _SOURCES variables");
  1362. next;
  1363. }
  1364. # If the source file is in a subdirectory then the '.o' is put
  1365. # into the current directory, unless the subdir-objects option
  1366. # is in effect.
  1367. # Split file name into base and extension.
  1368. next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
  1369. my $full = $_;
  1370. my $directory = $1 || '';
  1371. my $base = $2;
  1372. my $extension = $3;
  1373. # We must generate a rule for the object if it requires its own flags.
  1374. my $renamed = 0;
  1375. my ($linker, $object);
  1376. # This records whether we've seen a derived source file (e.g.
  1377. # yacc output).
  1378. my $derived_source = 0;
  1379. # This holds the 'aggregate context' of the file we are
  1380. # currently examining. If the file is compiled with
  1381. # per-object flags, then it will be the name of the object.
  1382. # Otherwise it will be 'AM'. This is used by the target hook
  1383. # language function.
  1384. my $aggregate = 'AM';
  1385. $extension = derive_suffix ($extension, $obj);
  1386. my $lang;
  1387. if ($extension_map{$extension} &&
  1388. ($lang = $languages{$extension_map{$extension}}))
  1389. {
  1390. # Found the language, so see what it says.
  1391. saw_extension ($extension);
  1392. # Do we have per-executable flags for this executable?
  1393. my $have_per_exec_flags = 0;
  1394. my @peflags = @{$lang->flags};
  1395. push @peflags, 'LIBTOOLFLAGS' if $obj eq '.lo';
  1396. foreach my $flag (@peflags)
  1397. {
  1398. if (set_seen ("${derived}_$flag"))
  1399. {
  1400. $have_per_exec_flags = 1;
  1401. last;
  1402. }
  1403. }
  1404. # Note: computed subr call. The language rewrite function
  1405. # should return one of the LANG_* constants. It could
  1406. # also return a list whose first value is such a constant
  1407. # and whose second value is a new source extension which
  1408. # should be applied. This means this particular language
  1409. # generates another source file which we must then process
  1410. # further.
  1411. my $subr = \&{'lang_' . $lang->name . '_rewrite'};
  1412. defined &$subr or $subr = \&lang_sub_obj;
  1413. my ($r, $source_extension)
  1414. = &$subr ($directory, $base, $extension,
  1415. $obj, $have_per_exec_flags, $var);
  1416. # Skip this entry if we were asked not to process it.
  1417. next if $r == LANG_IGNORE;
  1418. # Now extract linker and other info.
  1419. $linker = $lang->linker;
  1420. my $this_obj_ext;
  1421. if (defined $source_extension)
  1422. {
  1423. $this_obj_ext = $source_extension;
  1424. $derived_source = 1;
  1425. }
  1426. else
  1427. {
  1428. $this_obj_ext = $obj;
  1429. }
  1430. $object = $base . $this_obj_ext;
  1431. if ($have_per_exec_flags)
  1432. {
  1433. # We have a per-executable flag in effect for this
  1434. # object. In this case we rewrite the object's
  1435. # name to ensure it is unique.
  1436. # We choose the name 'DERIVED_OBJECT' to ensure
  1437. # (1) uniqueness, and (2) continuity between
  1438. # invocations. However, this will result in a
  1439. # name that is too long for losing systems, in
  1440. # some situations. So we provide _SHORTNAME to
  1441. # override.
  1442. my $dname = $derived;
  1443. my $var = var ($derived . '_SHORTNAME');
  1444. if ($var)
  1445. {
  1446. # FIXME: should use the same Condition as
  1447. # the _SOURCES variable. But this is really
  1448. # silly overkill -- nobody should have
  1449. # conditional shortnames.
  1450. $dname = $var->variable_value;
  1451. }
  1452. $object = $dname . '-' . $object;
  1453. prog_error ($lang->name . " flags defined without compiler")
  1454. if ! defined $lang->compile;
  1455. $renamed = 1;
  1456. }
  1457. # If rewrite said it was ok, put the object into a
  1458. # subdir.
  1459. if ($directory ne '')
  1460. {
  1461. if ($r == LANG_SUBDIR)
  1462. {
  1463. $object = $directory . '/' . $object;
  1464. }
  1465. else
  1466. {
  1467. # Since the next major version of automake (2.0) will
  1468. # make the behaviour so far only activated with the
  1469. # 'subdir-object' option mandatory, it's better if we
  1470. # start warning users not using that option.
  1471. # As suggested by Peter Johansson, we strive to avoid
  1472. # the warning when it would be irrelevant, i.e., if
  1473. # all source files sit in "current" directory.
  1474. msg_var 'unsupported', $var,
  1475. "source file '$full' is in a subdirectory,"
  1476. . "\nbut option 'subdir-objects' is disabled";
  1477. msg 'unsupported', INTERNAL, <<'EOF', uniq_scope => US_GLOBAL;
  1478. possible forward-incompatibility.
  1479. At least a source file is in a subdirectory, but the 'subdir-objects'
  1480. automake option hasn't been enabled. For now, the corresponding output
  1481. object file(s) will be placed in the top-level directory. However,
  1482. this behaviour will change in future Automake versions: they will
  1483. unconditionally cause object files to be placed in the same subdirectory
  1484. of the corresponding sources.
  1485. You are advised to start using 'subdir-objects' option throughout your
  1486. project, to avoid future incompatibilities.
  1487. EOF
  1488. }
  1489. }
  1490. # If the object file has been renamed (because per-target
  1491. # flags are used) we cannot compile the file with an
  1492. # inference rule: we need an explicit rule.
  1493. #
  1494. # If the source is in a subdirectory and the object is in
  1495. # the current directory, we also need an explicit rule.
  1496. #
  1497. # If both source and object files are in a subdirectory
  1498. # (this happens when the subdir-objects option is used),
  1499. # then the inference will work.
  1500. #
  1501. # The latter case deserves a historical note. When the
  1502. # subdir-objects option was added on 1999-04-11 it was
  1503. # thought that inferences rules would work for
  1504. # subdirectory objects too. Later, on 1999-11-22,
  1505. # automake was changed to output explicit rules even for
  1506. # subdir-objects. Nobody remembers why, but this occurred
  1507. # soon after the merge of the user-dep-gen-branch so it
  1508. # might be related. In late 2003 people complained about
  1509. # the size of the generated Makefile.ins (libgcj, with
  1510. # 2200+ subdir objects was reported to have a 9MB
  1511. # Makefile), so we now rely on inference rules again.
  1512. # Maybe we'll run across the same issue as in the past,
  1513. # but at least this time we can document it. However since
  1514. # dependency tracking has evolved it is possible that
  1515. # our old problem no longer exists.
  1516. # Using inference rules for subdir-objects has been tested
  1517. # with GNU make, Solaris make, Ultrix make, BSD make,
  1518. # HP-UX make, and OSF1 make successfully.
  1519. if ($renamed
  1520. || ($directory ne '' && ! option 'subdir-objects')
  1521. # We must also use specific rules for a nodist_ source
  1522. # if its language requests it.
  1523. || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'}))
  1524. {
  1525. my $obj_sans_ext = substr ($object, 0,
  1526. - length ($this_obj_ext));
  1527. my $full_ansi;
  1528. if ($directory ne '')
  1529. {
  1530. $full_ansi = $directory . '/' . $base . $extension;
  1531. }
  1532. else
  1533. {
  1534. $full_ansi = $base . $extension;
  1535. }
  1536. my @specifics = ($full_ansi, $obj_sans_ext,
  1537. # Only use $this_obj_ext in the derived
  1538. # source case because in the other case we
  1539. # *don't* want $(OBJEXT) to appear here.
  1540. ($derived_source ? $this_obj_ext : '.o'),
  1541. $extension);
  1542. # If we renamed the object then we want to use the
  1543. # per-executable flag name. But if this is simply a
  1544. # subdir build then we still want to use the AM_ flag
  1545. # name.
  1546. if ($renamed)
  1547. {
  1548. unshift @specifics, $derived;
  1549. $aggregate = $derived;
  1550. }
  1551. else
  1552. {
  1553. unshift @specifics, 'AM';
  1554. }
  1555. # Each item on this list is a reference to a list consisting
  1556. # of four values followed by additional transform flags for
  1557. # file_contents. The four values are the derived flag prefix
  1558. # (e.g. for 'foo_CFLAGS', it is 'foo'), the name of the
  1559. # source file, the base name of the output file, and
  1560. # the extension for the object file.
  1561. push (@{$lang_specific_files{$lang->name}},
  1562. [@specifics, %transform]);
  1563. }
  1564. }
  1565. elsif ($extension eq $obj)
  1566. {
  1567. # This is probably the result of a direct suffix rule.
  1568. # In this case we just accept the rewrite.
  1569. $object = "$base$extension";
  1570. $object = "$directory/$object" if $directory ne '';
  1571. $linker = '';
  1572. }
  1573. else
  1574. {
  1575. # No error message here. Used to have one, but it was
  1576. # very unpopular.
  1577. # FIXME: we could potentially do more processing here,
  1578. # perhaps treating the new extension as though it were a
  1579. # new source extension (as above). This would require
  1580. # more restructuring than is appropriate right now.
  1581. next;
  1582. }
  1583. err_am "object '$object' created by '$full' and '$object_map{$object}'"
  1584. if (defined $object_map{$object}
  1585. && $object_map{$object} ne $full);
  1586. my $comp_val = (($object =~ /\.lo$/)
  1587. ? COMPILE_LIBTOOL : COMPILE_ORDINARY);
  1588. (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/;
  1589. if (defined $object_compilation_map{$comp_obj}
  1590. && $object_compilation_map{$comp_obj} != 0
  1591. # Only see the error once.
  1592. && ($object_compilation_map{$comp_obj}
  1593. != (COMPILE_LIBTOOL | COMPILE_ORDINARY))
  1594. && $object_compilation_map{$comp_obj} != $comp_val)
  1595. {
  1596. err_am "object '$comp_obj' created both with libtool and without";
  1597. }
  1598. $object_compilation_map{$comp_obj} |= $comp_val;
  1599. if (defined $lang)
  1600. {
  1601. # Let the language do some special magic if required.
  1602. $lang->target_hook ($aggregate, $object, $full, %transform);
  1603. }
  1604. if ($derived_source)
  1605. {
  1606. prog_error ($lang->name . " has automatic dependency tracking")
  1607. if $lang->autodep ne 'no';
  1608. # Make sure this new source file is handled next. That will
  1609. # make it appear to be at the right place in the list.
  1610. unshift (@files, $object);
  1611. # Distribute derived sources unless the source they are
  1612. # derived from is not.
  1613. push_dist_common ($object)
  1614. unless ($topparent =~ /^(?:nobase_)?nodist_/);
  1615. next;
  1616. }
  1617. $linkers_used{$linker} = 1;
  1618. push (@result, $object);
  1619. if (! defined $object_map{$object})
  1620. {
  1621. my @dep_list = ();
  1622. $object_map{$object} = $full;
  1623. # If resulting object is in subdir, we need to make
  1624. # sure the subdir exists at build time.
  1625. if ($object =~ /\//)
  1626. {
  1627. # FIXME: check that $DIRECTORY is somewhere in the
  1628. # project
  1629. # For Java, the way we're handling it right now, a
  1630. # '..' component doesn't make sense.
  1631. if ($lang && $lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
  1632. {
  1633. err_am "'$full' should not contain a '..' component";
  1634. }
  1635. # Make sure *all* objects files in the subdirectory are
  1636. # removed by "make mostlyclean". Not only this is more
  1637. # efficient than listing the object files to be removed
  1638. # individually (which would cause an 'rm' invocation for
  1639. # each of them -- very inefficient, see bug#10697), it
  1640. # would also leave stale object files in the subdirectory
  1641. # whenever a source file there is removed or renamed.
  1642. $compile_clean_files{"$directory/*.\$(OBJEXT)"} = MOSTLY_CLEAN;
  1643. if ($object =~ /\.lo$/)
  1644. {
  1645. # If we have a libtool object, then we also must remove
  1646. # any '.lo' objects in its same subdirectory.
  1647. $compile_clean_files{"$directory/*.lo"} = MOSTLY_CLEAN;
  1648. # Remember to cleanup .libs/ in this directory.
  1649. $libtool_clean_directories{$directory} = 1;
  1650. }
  1651. push (@dep_list, require_build_directory ($directory));
  1652. # If we're generating dependencies, we also want
  1653. # to make sure that the appropriate subdir of the
  1654. # .deps directory is created.
  1655. push (@dep_list,
  1656. require_build_directory ($directory . '/$(DEPDIR)'))
  1657. unless option 'no-dependencies';
  1658. }
  1659. pretty_print_rule ($object . ':', "\t", @dep_list)
  1660. if scalar @dep_list > 0;
  1661. }
  1662. # Transform .o or $o file into .P file (for automatic
  1663. # dependency code).
  1664. # Properly flatten multiple adjacent slashes, as Solaris 10 make
  1665. # might fail over them in an include statement.
  1666. # Leading double slashes may be special, as per Posix, so deal
  1667. # with them carefully.
  1668. if ($lang && $lang->autodep ne 'no')
  1669. {
  1670. my $depfile = $object;
  1671. $depfile =~ s/\.([^.]*)$/.P$1/;
  1672. $depfile =~ s/\$\(OBJEXT\)$/o/;
  1673. my $maybe_extra_leading_slash = '';
  1674. $maybe_extra_leading_slash = '/' if $depfile =~ m,^//[^/],;
  1675. $depfile =~ s,/+,/,g;
  1676. my $basename = basename ($depfile);
  1677. # This might make $dirname empty, but we account for that below.
  1678. (my $dirname = dirname ($depfile)) =~ s/\/*$//;
  1679. $dirname = $maybe_extra_leading_slash . $dirname;
  1680. $dep_files{$dirname . '/$(DEPDIR)/' . $basename} = 1;
  1681. }
  1682. }
  1683. return @result;
  1684. }
  1685. # $LINKER
  1686. # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
  1687. # $OBJ, $PARENT, $TOPPARENT, $WHERE, %TRANSFORM)
  1688. # ---------------------------------------------------------------------------
  1689. # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
  1690. #
  1691. # Arguments are:
  1692. # $VAR is the name of the _SOURCES variable
  1693. # $OBJVAR is the name of the _OBJECTS variable if known (otherwise
  1694. # it will be generated and returned).
  1695. # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
  1696. # work done to determine the linker will be).
  1697. # $ONE_FILE is the canonical (transformed) name of object to build
  1698. # $OBJ is the object extension (i.e. either '.o' or '.lo').
  1699. # $TOPPARENT is the _SOURCES variable being processed.
  1700. # $WHERE context into which this definition is done
  1701. # %TRANSFORM extra arguments to pass to file_contents when producing
  1702. # rules
  1703. #
  1704. # Result is a pair ($LINKER, $OBJVAR):
  1705. # $LINKER is a boolean, true if a linker is needed to deal with the objects
  1706. sub define_objects_from_sources
  1707. {
  1708. my ($var, $objvar, $nodefine, $one_file,
  1709. $obj, $topparent, $where, %transform) = @_;
  1710. my $needlinker = "";
  1711. transform_variable_recursively
  1712. ($var, $objvar, 'am__objects', $nodefine, $where,
  1713. # The transform code to run on each filename.
  1714. sub {
  1715. my ($subvar, $val, $cond, $full_cond) = @_;
  1716. my @trans = handle_single_transform ($subvar, $topparent,
  1717. $one_file, $obj, $val,
  1718. %transform);
  1719. $needlinker = "true" if @trans;
  1720. return @trans;
  1721. });
  1722. return $needlinker;
  1723. }
  1724. # handle_source_transform ($CANON_TARGET, $TARGET, $OBJEXT, $WHERE, %TRANSFORM)
  1725. # -----------------------------------------------------------------------------
  1726. # Handle SOURCE->OBJECT transform for one program or library.
  1727. # Arguments are:
  1728. # canonical (transformed) name of target to build
  1729. # actual target of object to build
  1730. # object extension (i.e., either '.o' or '$o')
  1731. # location of the source variable
  1732. # extra arguments to pass to file_contents when producing rules
  1733. # Return the name of the linker variable that must be used.
  1734. # Empty return means just use 'LINK'.
  1735. sub handle_source_transform
  1736. {
  1737. # one_file is canonical name. unxformed is given name. obj is
  1738. # object extension.
  1739. my ($one_file, $unxformed, $obj, $where, %transform) = @_;
  1740. my $linker = '';
  1741. # No point in continuing if _OBJECTS is defined.
  1742. return if reject_var ($one_file . '_OBJECTS',
  1743. $one_file . '_OBJECTS should not be defined');
  1744. my %used_pfx = ();
  1745. my $needlinker;
  1746. %linkers_used = ();
  1747. foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
  1748. 'dist_EXTRA_', 'nodist_EXTRA_')
  1749. {
  1750. my $varname = $prefix . $one_file . "_SOURCES";
  1751. my $var = var $varname;
  1752. next unless $var;
  1753. # We are going to define _OBJECTS variables using the prefix.
  1754. # Then we glom them all together. So we can't use the null
  1755. # prefix here as we need it later.
  1756. my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
  1757. # Keep track of which prefixes we saw.
  1758. $used_pfx{$xpfx} = 1
  1759. unless $prefix =~ /EXTRA_/;
  1760. push @sources, "\$($varname)";
  1761. push @dist_sources, shadow_unconditionally ($varname, $where)
  1762. unless (option ('no-dist') || $prefix =~ /^nodist_/);
  1763. $needlinker |=
  1764. define_objects_from_sources ($varname,
  1765. $xpfx . $one_file . '_OBJECTS',
  1766. !!($prefix =~ /EXTRA_/),
  1767. $one_file, $obj, $varname, $where,
  1768. DIST_SOURCE => ($prefix !~ /^nodist_/),
  1769. %transform);
  1770. }
  1771. if ($needlinker)
  1772. {
  1773. $linker ||= resolve_linker (%linkers_used);
  1774. }
  1775. my @keys = sort keys %used_pfx;
  1776. if (scalar @keys == 0)
  1777. {
  1778. # The default source for libfoo.la is libfoo.c, but for
  1779. # backward compatibility we first look at libfoo_la.c,
  1780. # if no default source suffix is given.
  1781. my $old_default_source = "$one_file.c";
  1782. my $ext_var = var ('AM_DEFAULT_SOURCE_EXT');
  1783. my $default_source_ext = $ext_var ? variable_value ($ext_var) : '.c';
  1784. msg_var ('unsupported', $ext_var, $ext_var->name . " can assume at most one value")
  1785. if $default_source_ext =~ /[\t ]/;
  1786. (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,$default_source_ext,;
  1787. # TODO: Remove this backward-compatibility hack in Automake 2.0.
  1788. if ($old_default_source ne $default_source
  1789. && !$ext_var
  1790. && (rule $old_default_source
  1791. || rule '$(srcdir)/' . $old_default_source
  1792. || rule '${srcdir}/' . $old_default_source
  1793. || -f $old_default_source))
  1794. {
  1795. my $loc = $where->clone;
  1796. $loc->pop_context;
  1797. msg ('obsolete', $loc,
  1798. "the default source for '$unxformed' has been changed "
  1799. . "to '$default_source'.\n(Using '$old_default_source' for "
  1800. . "backward compatibility.)");
  1801. $default_source = $old_default_source;
  1802. }
  1803. # If a rule exists to build this source with a $(srcdir)
  1804. # prefix, use that prefix in our variables too. This is for
  1805. # the sake of BSD Make.
  1806. if (rule '$(srcdir)/' . $default_source
  1807. || rule '${srcdir}/' . $default_source)
  1808. {
  1809. $default_source = '$(srcdir)/' . $default_source;
  1810. }
  1811. define_variable ($one_file . "_SOURCES", $default_source, $where);
  1812. push (@sources, $default_source);
  1813. push (@dist_sources, $default_source);
  1814. %linkers_used = ();
  1815. my (@result) =
  1816. handle_single_transform ($one_file . '_SOURCES',
  1817. $one_file . '_SOURCES',
  1818. $one_file, $obj,
  1819. $default_source, %transform);
  1820. $linker ||= resolve_linker (%linkers_used);
  1821. define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
  1822. }
  1823. else
  1824. {
  1825. @keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys;
  1826. define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys);
  1827. }
  1828. # If we want to use 'LINK' we must make sure it is defined.
  1829. if ($linker eq '')
  1830. {
  1831. $need_link = 1;
  1832. }
  1833. return $linker;
  1834. }
  1835. # handle_lib_objects ($XNAME, $VAR)
  1836. # ---------------------------------
  1837. # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables.
  1838. # Also, generate _DEPENDENCIES variable if appropriate.
  1839. # Arguments are:
  1840. # transformed name of object being built, or empty string if no object
  1841. # name of _LDADD/_LIBADD-type variable to examine
  1842. # Returns 1 if LIBOBJS seen, 0 otherwise.
  1843. sub handle_lib_objects
  1844. {
  1845. my ($xname, $varname) = @_;
  1846. my $var = var ($varname);
  1847. prog_error "'$varname' undefined"
  1848. unless $var;
  1849. prog_error "unexpected variable name '$varname'"
  1850. unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
  1851. my $prefix = $1 || 'AM_';
  1852. my $seen_libobjs = 0;
  1853. my $flagvar = 0;
  1854. transform_variable_recursively
  1855. ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES',
  1856. ! $xname, INTERNAL,
  1857. # Transformation function, run on each filename.
  1858. sub {
  1859. my ($subvar, $val, $cond, $full_cond) = @_;
  1860. if ($val =~ /^-/)
  1861. {
  1862. # Skip -lfoo and -Ldir silently; these are explicitly allowed.
  1863. if ($val !~ /^-[lL]/ &&
  1864. # Skip -dlopen and -dlpreopen; these are explicitly allowed
  1865. # for Libtool libraries or programs. (Actually we are a bit
  1866. # lax here since this code also applies to non-libtool
  1867. # libraries or programs, for which -dlopen and -dlopreopen
  1868. # are pure nonsense. Diagnosing this doesn't seem very
  1869. # important: the developer will quickly get complaints from
  1870. # the linker.)
  1871. $val !~ /^-dl(?:pre)?open$/ &&
  1872. # Only get this error once.
  1873. ! $flagvar)
  1874. {
  1875. $flagvar = 1;
  1876. # FIXME: should display a stack of nested variables
  1877. # as context when $var != $subvar.
  1878. err_var ($var, "linker flags such as '$val' belong in "
  1879. . "'${prefix}LDFLAGS'");
  1880. }
  1881. return ();
  1882. }
  1883. elsif ($val !~ /^\@.*\@$/)
  1884. {
  1885. # Assume we have a file of some sort, and output it into the
  1886. # dependency variable. Autoconf substitutions are not output;
  1887. # rarely is a new dependency substituted into e.g. foo_LDADD
  1888. # -- but bad things (e.g. -lX11) are routinely substituted.
  1889. # Note that LIBOBJS and ALLOCA are exceptions to this rule,
  1890. # and handled specially below.
  1891. return $val;
  1892. }
  1893. elsif ($val =~ /^\@(LT)?LIBOBJS\@$/)
  1894. {
  1895. handle_LIBOBJS ($subvar, $cond, $1);
  1896. $seen_libobjs = 1;
  1897. return $val;
  1898. }
  1899. elsif ($val =~ /^\@(LT)?ALLOCA\@$/)
  1900. {
  1901. handle_ALLOCA ($subvar, $cond, $1);
  1902. return $val;
  1903. }
  1904. else
  1905. {
  1906. return ();
  1907. }
  1908. });
  1909. return $seen_libobjs;
  1910. }
  1911. # handle_LIBOBJS_or_ALLOCA ($VAR)
  1912. # -------------------------------
  1913. # Definitions common to LIBOBJS and ALLOCA.
  1914. # VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA.
  1915. sub handle_LIBOBJS_or_ALLOCA
  1916. {
  1917. my ($var) = @_;
  1918. my $dir = '';
  1919. # If LIBOBJS files must be built in another directory we have
  1920. # to define LIBOBJDIR and ensure the files get cleaned.
  1921. # Otherwise LIBOBJDIR can be left undefined, and the cleaning
  1922. # is achieved by 'rm -f *.$(OBJEXT)' in compile.am.
  1923. if ($config_libobj_dir
  1924. && $relative_dir ne $config_libobj_dir)
  1925. {
  1926. if (option 'subdir-objects')
  1927. {
  1928. # In the top-level Makefile we do not use $(top_builddir), because
  1929. # we are already there, and since the targets are built without
  1930. # a $(top_builddir), it helps BSD Make to match them with
  1931. # dependencies.
  1932. $dir = "$config_libobj_dir/"
  1933. if $config_libobj_dir ne '.';
  1934. $dir = backname ($relative_dir) . "/$dir"
  1935. if $relative_dir ne '.';
  1936. define_variable ('LIBOBJDIR', "$dir", INTERNAL);
  1937. $clean_files{"\$($var)"} = MOSTLY_CLEAN;
  1938. # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
  1939. # be created by libtool as a side-effect of creating LTLIBOBJS).
  1940. $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
  1941. }
  1942. else
  1943. {
  1944. error ("'\$($var)' cannot be used outside '$config_libobj_dir' if"
  1945. . " 'subdir-objects' is not set");
  1946. }
  1947. }
  1948. return $dir;
  1949. }
  1950. sub handle_LIBOBJS
  1951. {
  1952. my ($var, $cond, $lt) = @_;
  1953. my $myobjext = $lt ? 'lo' : 'o';
  1954. $lt ||= '';
  1955. $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS')
  1956. if ! keys %libsources;
  1957. my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS";
  1958. foreach my $iter (keys %libsources)
  1959. {
  1960. if ($iter =~ /\.[cly]$/)
  1961. {
  1962. saw_extension ($&);
  1963. saw_extension ('.c');
  1964. }
  1965. if ($iter =~ /\.h$/)
  1966. {
  1967. require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
  1968. }
  1969. elsif ($iter ne 'alloca.c')
  1970. {
  1971. my $rewrite = $iter;
  1972. $rewrite =~ s/\.c$/.P$myobjext/;
  1973. $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1;
  1974. $rewrite = "^" . quotemeta ($iter) . "\$";
  1975. # Only require the file if it is not a built source.
  1976. my $bs = var ('BUILT_SOURCES');
  1977. if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive))
  1978. {
  1979. require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
  1980. }
  1981. }
  1982. }
  1983. }
  1984. sub handle_ALLOCA
  1985. {
  1986. my ($var, $cond, $lt) = @_;
  1987. my $myobjext = $lt ? 'lo' : 'o';
  1988. $lt ||= '';
  1989. my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA";
  1990. $dir eq '' and $dir = './';
  1991. $var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA');
  1992. $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1;
  1993. require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c');
  1994. saw_extension ('.c');
  1995. }
  1996. # Canonicalize the input parameter.
  1997. sub canonicalize
  1998. {
  1999. my ($string) = @_;
  2000. $string =~ tr/A-Za-z0-9_\@/_/c;
  2001. return $string;
  2002. }
  2003. # Canonicalize a name, and check to make sure the non-canonical name
  2004. # is never used. Returns canonical name. Arguments are name and a
  2005. # list of suffixes to check for.
  2006. sub check_canonical_spelling
  2007. {
  2008. my ($name, @suffixes) = @_;
  2009. my $xname = canonicalize ($name);
  2010. if ($xname ne $name)
  2011. {
  2012. foreach my $xt (@suffixes)
  2013. {
  2014. reject_var ("$name$xt", "use '$xname$xt', not '$name$xt'");
  2015. }
  2016. }
  2017. return $xname;
  2018. }
  2019. # Set up the compile suite.
  2020. sub handle_compile ()
  2021. {
  2022. return if ! $must_handle_compiled_objects;
  2023. # Boilerplate.
  2024. my $default_includes = '';
  2025. if (! option 'nostdinc')
  2026. {
  2027. my @incs = ('-I.', subst ('am__isrc'));
  2028. my $var = var 'CONFIG_HEADER';
  2029. if ($var)
  2030. {
  2031. foreach my $hdr (split (' ', $var->variable_value))
  2032. {
  2033. push @incs, '-I' . dirname ($hdr);
  2034. }
  2035. }
  2036. # We want '-I. -I$(srcdir)', but the latter -I is redundant
  2037. # and unaesthetic in non-VPATH builds. We use `-I.@am__isrc@`
  2038. # instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'.
  2039. # Items in CONFIG_HEADER are never in $(srcdir) so it is safe
  2040. # to just put @am__isrc@ right after '-I.', without a space.
  2041. ($default_includes = ' ' . uniq (@incs)) =~ s/ @/@/;
  2042. }
  2043. my (@mostly_rms, @dist_rms);
  2044. foreach my $item (sort keys %compile_clean_files)
  2045. {
  2046. if ($compile_clean_files{$item} == MOSTLY_CLEAN)
  2047. {
  2048. push (@mostly_rms, "\t-rm -f $item");
  2049. }
  2050. elsif ($compile_clean_files{$item} == DIST_CLEAN)
  2051. {
  2052. push (@dist_rms, "\t-rm -f $item");
  2053. }
  2054. else
  2055. {
  2056. prog_error 'invalid entry in %compile_clean_files';
  2057. }
  2058. }
  2059. my ($coms, $vars, $rules) =
  2060. file_contents_internal (1, "$libdir/am/compile.am",
  2061. new Automake::Location,
  2062. 'DEFAULT_INCLUDES' => $default_includes,
  2063. 'MOSTLYRMS' => join ("\n", @mostly_rms),
  2064. 'DISTRMS' => join ("\n", @dist_rms));
  2065. $output_vars .= $vars;
  2066. $output_rules .= "$coms$rules";
  2067. }
  2068. # Handle libtool rules.
  2069. sub handle_libtool ()
  2070. {
  2071. return unless var ('LIBTOOL');
  2072. # Libtool requires some files, but only at top level.
  2073. # (Starting with Libtool 2.0 we do not have to bother. These
  2074. # requirements are done with AC_REQUIRE_AUX_FILE.)
  2075. require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
  2076. if $relative_dir eq '.' && ! $libtool_new_api;
  2077. my @libtool_rms;
  2078. foreach my $item (sort keys %libtool_clean_directories)
  2079. {
  2080. my $dir = ($item eq '.') ? '' : "$item/";
  2081. # .libs is for Unix, _libs for DOS.
  2082. push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
  2083. }
  2084. check_user_variables 'LIBTOOLFLAGS';
  2085. # Output the libtool compilation rules.
  2086. $output_rules .= file_contents ('libtool',
  2087. new Automake::Location,
  2088. LTRMS => join ("\n", @libtool_rms));
  2089. }
  2090. sub handle_programs ()
  2091. {
  2092. my @proglist = am_install_var ('progs', 'PROGRAMS',
  2093. 'bin', 'sbin', 'libexec', 'pkglibexec',
  2094. 'noinst', 'check');
  2095. return if ! @proglist;
  2096. $must_handle_compiled_objects = 1;
  2097. my $seen_global_libobjs =
  2098. var ('LDADD') && handle_lib_objects ('', 'LDADD');
  2099. foreach my $pair (@proglist)
  2100. {
  2101. my ($where, $one_file) = @$pair;
  2102. my $seen_libobjs = 0;
  2103. my $obj = '.$(OBJEXT)';
  2104. $known_programs{$one_file} = $where;
  2105. # Canonicalize names and check for misspellings.
  2106. my $xname = check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
  2107. '_SOURCES', '_OBJECTS',
  2108. '_DEPENDENCIES');
  2109. $where->push_context ("while processing program '$one_file'");
  2110. $where->set (INTERNAL->get);
  2111. my $linker = handle_source_transform ($xname, $one_file, $obj, $where,
  2112. NONLIBTOOL => 1, LIBTOOL => 0);
  2113. if (var ($xname . "_LDADD"))
  2114. {
  2115. $seen_libobjs = handle_lib_objects ($xname, $xname . '_LDADD');
  2116. }
  2117. else
  2118. {
  2119. # User didn't define prog_LDADD override. So do it.
  2120. define_variable ($xname . '_LDADD', '$(LDADD)', $where);
  2121. # This does a bit too much work. But we need it to
  2122. # generate _DEPENDENCIES when appropriate.
  2123. if (var ('LDADD'))
  2124. {
  2125. $seen_libobjs = handle_lib_objects ($xname, 'LDADD');
  2126. }
  2127. }
  2128. reject_var ($xname . '_LIBADD',
  2129. "use '${xname}_LDADD', not '${xname}_LIBADD'");
  2130. set_seen ($xname . '_DEPENDENCIES');
  2131. set_seen ('EXTRA_' . $xname . '_DEPENDENCIES');
  2132. set_seen ($xname . '_LDFLAGS');
  2133. # Determine program to use for link.
  2134. my($xlink, $vlink) = define_per_target_linker_variable ($linker, $xname);
  2135. $vlink = verbose_flag ($vlink || 'GEN');
  2136. # If the resulting program lies in a subdirectory,
  2137. # ensure that the directory exists before we need it.
  2138. my $dirstamp = require_build_directory_maybe ($one_file);
  2139. $libtool_clean_directories{dirname ($one_file)} = 1;
  2140. $output_rules .= file_contents ('program',
  2141. $where,
  2142. PROGRAM => $one_file,
  2143. XPROGRAM => $xname,
  2144. XLINK => $xlink,
  2145. VERBOSE => $vlink,
  2146. DIRSTAMP => $dirstamp,
  2147. EXEEXT => '$(EXEEXT)');
  2148. if ($seen_libobjs || $seen_global_libobjs)
  2149. {
  2150. if (var ($xname . '_LDADD'))
  2151. {
  2152. check_libobjs_sources ($xname, $xname . '_LDADD');
  2153. }
  2154. elsif (var ('LDADD'))
  2155. {
  2156. check_libobjs_sources ($xname, 'LDADD');
  2157. }
  2158. }
  2159. }
  2160. }
  2161. sub handle_libraries ()
  2162. {
  2163. my @liblist = am_install_var ('libs', 'LIBRARIES',
  2164. 'lib', 'pkglib', 'noinst', 'check');
  2165. return if ! @liblist;
  2166. $must_handle_compiled_objects = 1;
  2167. my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
  2168. 'noinst', 'check');
  2169. if (@prefix)
  2170. {
  2171. my $var = rvar ($prefix[0] . '_LIBRARIES');
  2172. $var->requires_variables ('library used', 'RANLIB');
  2173. }
  2174. define_variable ('AR', 'ar', INTERNAL);
  2175. define_variable ('ARFLAGS', 'cru', INTERNAL);
  2176. define_verbose_tagvar ('AR');
  2177. foreach my $pair (@liblist)
  2178. {
  2179. my ($where, $onelib) = @$pair;
  2180. my $seen_libobjs = 0;
  2181. # Check that the library fits the standard naming convention.
  2182. my $bn = basename ($onelib);
  2183. if ($bn !~ /^lib.*\.a$/)
  2184. {
  2185. $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/;
  2186. my $suggestion = dirname ($onelib) . "/$bn";
  2187. $suggestion =~ s|^\./||g;
  2188. msg ('error-gnu/warn', $where,
  2189. "'$onelib' is not a standard library name\n"
  2190. . "did you mean '$suggestion'?")
  2191. }
  2192. ($known_libraries{$onelib} = $bn) =~ s/\.a$//;
  2193. $where->push_context ("while processing library '$onelib'");
  2194. $where->set (INTERNAL->get);
  2195. my $obj = '.$(OBJEXT)';
  2196. # Canonicalize names and check for misspellings.
  2197. my $xlib = check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
  2198. '_OBJECTS', '_DEPENDENCIES',
  2199. '_AR');
  2200. if (! var ($xlib . '_AR'))
  2201. {
  2202. define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
  2203. }
  2204. # Generate support for conditional object inclusion in
  2205. # libraries.
  2206. if (var ($xlib . '_LIBADD'))
  2207. {
  2208. if (handle_lib_objects ($xlib, $xlib . '_LIBADD'))
  2209. {
  2210. $seen_libobjs = 1;
  2211. }
  2212. }
  2213. else
  2214. {
  2215. define_variable ($xlib . "_LIBADD", '', $where);
  2216. }
  2217. reject_var ($xlib . '_LDADD',
  2218. "use '${xlib}_LIBADD', not '${xlib}_LDADD'");
  2219. # Make sure we at look at this.
  2220. set_seen ($xlib . '_DEPENDENCIES');
  2221. set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES');
  2222. handle_source_transform ($xlib, $onelib, $obj, $where,
  2223. NONLIBTOOL => 1, LIBTOOL => 0);
  2224. # If the resulting library lies in a subdirectory,
  2225. # make sure this directory will exist.
  2226. my $dirstamp = require_build_directory_maybe ($onelib);
  2227. my $verbose = verbose_flag ('AR');
  2228. my $silent = silent_flag ();
  2229. $output_rules .= file_contents ('library',
  2230. $where,
  2231. VERBOSE => $verbose,
  2232. SILENT => $silent,
  2233. LIBRARY => $onelib,
  2234. XLIBRARY => $xlib,
  2235. DIRSTAMP => $dirstamp);
  2236. if ($seen_libobjs)
  2237. {
  2238. if (var ($xlib . '_LIBADD'))
  2239. {
  2240. check_libobjs_sources ($xlib, $xlib . '_LIBADD');
  2241. }
  2242. }
  2243. if (! $seen_ar)
  2244. {
  2245. msg ('extra-portability', $where,
  2246. "'$onelib': linking libraries using a non-POSIX\n"
  2247. . "archiver requires 'AM_PROG_AR' in '$configure_ac'")
  2248. }
  2249. }
  2250. }
  2251. sub handle_ltlibraries ()
  2252. {
  2253. my @liblist = am_install_var ('ltlib', 'LTLIBRARIES',
  2254. 'noinst', 'lib', 'pkglib', 'check');
  2255. return if ! @liblist;
  2256. $must_handle_compiled_objects = 1;
  2257. my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
  2258. 'noinst', 'check');
  2259. if (@prefix)
  2260. {
  2261. my $var = rvar ($prefix[0] . '_LTLIBRARIES');
  2262. $var->requires_variables ('Libtool library used', 'LIBTOOL');
  2263. }
  2264. my %instdirs = ();
  2265. my %instsubdirs = ();
  2266. my %instconds = ();
  2267. my %liblocations = (); # Location (in Makefile.am) of each library.
  2268. foreach my $key (@prefix)
  2269. {
  2270. # Get the installation directory of each library.
  2271. my $dir = $key;
  2272. my $strip_subdir = 1;
  2273. if ($dir =~ /^nobase_/)
  2274. {
  2275. $dir =~ s/^nobase_//;
  2276. $strip_subdir = 0;
  2277. }
  2278. my $var = rvar ($key . '_LTLIBRARIES');
  2279. # We reject libraries which are installed in several places
  2280. # in the same condition, because we can only specify one
  2281. # '-rpath' option.
  2282. $var->traverse_recursively
  2283. (sub
  2284. {
  2285. my ($var, $val, $cond, $full_cond) = @_;
  2286. my $hcond = $full_cond->human;
  2287. my $where = $var->rdef ($cond)->location;
  2288. my $ldir = '';
  2289. $ldir = '/' . dirname ($val)
  2290. if (!$strip_subdir);
  2291. # A library cannot be installed in different directories
  2292. # in overlapping conditions.
  2293. if (exists $instconds{$val})
  2294. {
  2295. my ($msg, $acond) =
  2296. $instconds{$val}->ambiguous_p ($val, $full_cond);
  2297. if ($msg)
  2298. {
  2299. error ($where, $msg, partial => 1);
  2300. my $dirtxt = "installed " . ($strip_subdir ? "in" : "below") . " '$dir'";
  2301. $dirtxt = "built for '$dir'"
  2302. if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check';
  2303. my $dircond =
  2304. $full_cond->true ? "" : " in condition $hcond";
  2305. error ($where, "'$val' should be $dirtxt$dircond ...",
  2306. partial => 1);
  2307. my $hacond = $acond->human;
  2308. my $adir = $instdirs{$val}{$acond};
  2309. my $adirtxt = "installed in '$adir'";
  2310. $adirtxt = "built for '$adir'"
  2311. if ($adir eq 'EXTRA' || $adir eq 'noinst'
  2312. || $adir eq 'check');
  2313. my $adircond = $acond->true ? "" : " in condition $hacond";
  2314. my $onlyone = ($dir ne $adir) ?
  2315. ("\nLibtool libraries can be built for only one "
  2316. . "destination") : "";
  2317. error ($liblocations{$val}{$acond},
  2318. "... and should also be $adirtxt$adircond.$onlyone");
  2319. return;
  2320. }
  2321. }
  2322. else
  2323. {
  2324. $instconds{$val} = new Automake::DisjConditions;
  2325. }
  2326. $instdirs{$val}{$full_cond} = $dir;
  2327. $instsubdirs{$val}{$full_cond} = $ldir;
  2328. $liblocations{$val}{$full_cond} = $where;
  2329. $instconds{$val} = $instconds{$val}->merge ($full_cond);
  2330. },
  2331. sub
  2332. {
  2333. return ();
  2334. },
  2335. skip_ac_subst => 1);
  2336. }
  2337. foreach my $pair (@liblist)
  2338. {
  2339. my ($where, $onelib) = @$pair;
  2340. my $seen_libobjs = 0;
  2341. my $obj = '.lo';
  2342. # Canonicalize names and check for misspellings.
  2343. my $xlib = check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
  2344. '_SOURCES', '_OBJECTS',
  2345. '_DEPENDENCIES');
  2346. # Check that the library fits the standard naming convention.
  2347. my $libname_rx = '^lib.*\.la';
  2348. my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS');
  2349. my $ldvar2 = var ('LDFLAGS');
  2350. if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive))
  2351. || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive)))
  2352. {
  2353. # Relax name checking for libtool modules.
  2354. $libname_rx = '\.la';
  2355. }
  2356. my $bn = basename ($onelib);
  2357. if ($bn !~ /$libname_rx$/)
  2358. {
  2359. my $type = 'library';
  2360. if ($libname_rx eq '\.la')
  2361. {
  2362. $bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/;
  2363. $type = 'module';
  2364. }
  2365. else
  2366. {
  2367. $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/;
  2368. }
  2369. my $suggestion = dirname ($onelib) . "/$bn";
  2370. $suggestion =~ s|^\./||g;
  2371. msg ('error-gnu/warn', $where,
  2372. "'$onelib' is not a standard libtool $type name\n"
  2373. . "did you mean '$suggestion'?")
  2374. }
  2375. ($known_libraries{$onelib} = $bn) =~ s/\.la$//;
  2376. $where->push_context ("while processing Libtool library '$onelib'");
  2377. $where->set (INTERNAL->get);
  2378. # Make sure we look at these.
  2379. set_seen ($xlib . '_LDFLAGS');
  2380. set_seen ($xlib . '_DEPENDENCIES');
  2381. set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES');
  2382. # Generate support for conditional object inclusion in
  2383. # libraries.
  2384. if (var ($xlib . '_LIBADD'))
  2385. {
  2386. if (handle_lib_objects ($xlib, $xlib . '_LIBADD'))
  2387. {
  2388. $seen_libobjs = 1;
  2389. }
  2390. }
  2391. else
  2392. {
  2393. define_variable ($xlib . "_LIBADD", '', $where);
  2394. }
  2395. reject_var ("${xlib}_LDADD",
  2396. "use '${xlib}_LIBADD', not '${xlib}_LDADD'");
  2397. my $linker = handle_source_transform ($xlib, $onelib, $obj, $where,
  2398. NONLIBTOOL => 0, LIBTOOL => 1);
  2399. # Determine program to use for link.
  2400. my($xlink, $vlink) = define_per_target_linker_variable ($linker, $xlib);
  2401. $vlink = verbose_flag ($vlink || 'GEN');
  2402. my $rpathvar = "am_${xlib}_rpath";
  2403. my $rpath = "\$($rpathvar)";
  2404. foreach my $rcond ($instconds{$onelib}->conds)
  2405. {
  2406. my $val;
  2407. if ($instdirs{$onelib}{$rcond} eq 'EXTRA'
  2408. || $instdirs{$onelib}{$rcond} eq 'noinst'
  2409. || $instdirs{$onelib}{$rcond} eq 'check')
  2410. {
  2411. # It's an EXTRA_ library, so we can't specify -rpath,
  2412. # because we don't know where the library will end up.
  2413. # The user probably knows, but generally speaking automake
  2414. # doesn't -- and in fact configure could decide
  2415. # dynamically between two different locations.
  2416. $val = '';
  2417. }
  2418. else
  2419. {
  2420. $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)');
  2421. $val .= $instsubdirs{$onelib}{$rcond}
  2422. if defined $instsubdirs{$onelib}{$rcond};
  2423. }
  2424. if ($rcond->true)
  2425. {
  2426. # If $rcond is true there is only one condition and
  2427. # there is no point defining an helper variable.
  2428. $rpath = $val;
  2429. }
  2430. else
  2431. {
  2432. define_pretty_variable ($rpathvar, $rcond, INTERNAL, $val);
  2433. }
  2434. }
  2435. # If the resulting library lies in a subdirectory,
  2436. # make sure this directory will exist.
  2437. my $dirstamp = require_build_directory_maybe ($onelib);
  2438. # Remember to cleanup .libs/ in this directory.
  2439. my $dirname = dirname $onelib;
  2440. $libtool_clean_directories{$dirname} = 1;
  2441. $output_rules .= file_contents ('ltlibrary',
  2442. $where,
  2443. LTLIBRARY => $onelib,
  2444. XLTLIBRARY => $xlib,
  2445. RPATH => $rpath,
  2446. XLINK => $xlink,
  2447. VERBOSE => $vlink,
  2448. DIRSTAMP => $dirstamp);
  2449. if ($seen_libobjs)
  2450. {
  2451. if (var ($xlib . '_LIBADD'))
  2452. {
  2453. check_libobjs_sources ($xlib, $xlib . '_LIBADD');
  2454. }
  2455. }
  2456. if (! $seen_ar)
  2457. {
  2458. msg ('extra-portability', $where,
  2459. "'$onelib': linking libtool libraries using a non-POSIX\n"
  2460. . "archiver requires 'AM_PROG_AR' in '$configure_ac'")
  2461. }
  2462. }
  2463. }
  2464. # See if any _SOURCES variable were misspelled.
  2465. sub check_typos ()
  2466. {
  2467. # It is ok if the user sets this particular variable.
  2468. set_seen 'AM_LDFLAGS';
  2469. foreach my $primary ('SOURCES', 'LIBADD', 'LDADD', 'LDFLAGS', 'DEPENDENCIES')
  2470. {
  2471. foreach my $var (variables $primary)
  2472. {
  2473. my $varname = $var->name;
  2474. # A configure variable is always legitimate.
  2475. next if exists $configure_vars{$varname};
  2476. for my $cond ($var->conditions->conds)
  2477. {
  2478. $varname =~ /^(?:EXTRA_)?(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
  2479. msg_var ('syntax', $var, "variable '$varname' is defined but no"
  2480. . " program or\nlibrary has '$1' as canonical name"
  2481. . " (possible typo)")
  2482. unless $var->rdef ($cond)->seen;
  2483. }
  2484. }
  2485. }
  2486. }
  2487. sub handle_scripts ()
  2488. {
  2489. # NOTE we no longer automatically clean SCRIPTS, because it is
  2490. # useful to sometimes distribute scripts verbatim. This happens
  2491. # e.g. in Automake itself.
  2492. am_install_var ('-candist', 'scripts', 'SCRIPTS',
  2493. 'bin', 'sbin', 'libexec', 'pkglibexec', 'pkgdata',
  2494. 'noinst', 'check');
  2495. }
  2496. ## ------------------------ ##
  2497. ## Handling Texinfo files. ##
  2498. ## ------------------------ ##
  2499. # ($OUTFILE, $VFILE)
  2500. # scan_texinfo_file ($FILENAME)
  2501. # -----------------------------
  2502. # $OUTFILE - name of the info file produced by $FILENAME.
  2503. # $VFILE - name of the version.texi file used (undef if none).
  2504. sub scan_texinfo_file
  2505. {
  2506. my ($filename) = @_;
  2507. my $texi = new Automake::XFile "< $filename";
  2508. verb "reading $filename";
  2509. my ($outfile, $vfile);
  2510. while ($_ = $texi->getline)
  2511. {
  2512. if (/^\@setfilename +(\S+)/)
  2513. {
  2514. # Honor only the first @setfilename. (It's possible to have
  2515. # more occurrences later if the manual shows examples of how
  2516. # to use @setfilename...)
  2517. next if $outfile;
  2518. $outfile = $1;
  2519. if (index ($outfile, '.') < 0)
  2520. {
  2521. msg 'obsolete', "$filename:$.",
  2522. "use of suffix-less info files is discouraged"
  2523. }
  2524. elsif ($outfile !~ /\.info$/)
  2525. {
  2526. error ("$filename:$.",
  2527. "output '$outfile' has unrecognized extension");
  2528. return;
  2529. }
  2530. }
  2531. # A "version.texi" file is actually any file whose name matches
  2532. # "vers*.texi".
  2533. elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
  2534. {
  2535. $vfile = $1;
  2536. }
  2537. }
  2538. if (! $outfile)
  2539. {
  2540. err_am "'$filename' missing \@setfilename";
  2541. return;
  2542. }
  2543. return ($outfile, $vfile);
  2544. }
  2545. # ($DIRSTAMP, @CLEAN_FILES)
  2546. # output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, @DEPENDENCIES)
  2547. # ------------------------------------------------------------------
  2548. # SOURCE - the source Texinfo file
  2549. # DEST - the destination Info file
  2550. # INSRC - whether DEST should be built in the source tree
  2551. # DEPENDENCIES - known dependencies
  2552. sub output_texinfo_build_rules
  2553. {
  2554. my ($source, $dest, $insrc, @deps) = @_;
  2555. # Split 'a.texi' into 'a' and '.texi'.
  2556. my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/);
  2557. my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/);
  2558. $ssfx ||= "";
  2559. $dsfx ||= "";
  2560. # We can output two kinds of rules: the "generic" rules use Make
  2561. # suffix rules and are appropriate when $source and $dest do not lie
  2562. # in a sub-directory; the "specific" rules are needed in the other
  2563. # case.
  2564. #
  2565. # The former are output only once (this is not really apparent here,
  2566. # but just remember that some logic deeper in Automake will not
  2567. # output the same rule twice); while the later need to be output for
  2568. # each Texinfo source.
  2569. my $generic;
  2570. my $makeinfoflags;
  2571. my $sdir = dirname $source;
  2572. if ($sdir eq '.' && dirname ($dest) eq '.')
  2573. {
  2574. $generic = 1;
  2575. $makeinfoflags = '-I $(srcdir)';
  2576. }
  2577. else
  2578. {
  2579. $generic = 0;
  2580. $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir";
  2581. }
  2582. # A directory can contain two kinds of info files: some built in the
  2583. # source tree, and some built in the build tree. The rules are
  2584. # different in each case. However we cannot output two different
  2585. # set of generic rules. Because in-source builds are more usual, we
  2586. # use generic rules in this case and fall back to "specific" rules
  2587. # for build-dir builds. (It should not be a problem to invert this
  2588. # if needed.)
  2589. $generic = 0 unless $insrc;
  2590. # We cannot use a suffix rule to build info files with an empty
  2591. # extension. Otherwise we would output a single suffix inference
  2592. # rule, with separate dependencies, as in
  2593. #
  2594. # .texi:
  2595. # $(MAKEINFO) ...
  2596. # foo.info: foo.texi
  2597. #
  2598. # which confuse Solaris make. (See the Autoconf manual for
  2599. # details.) Therefore we use a specific rule in this case. This
  2600. # applies to info files only (dvi and pdf files always have an
  2601. # extension).
  2602. my $generic_info = ($generic && $dsfx) ? 1 : 0;
  2603. # If the resulting file lies in a subdirectory,
  2604. # make sure this directory will exist.
  2605. my $dirstamp = require_build_directory_maybe ($dest);
  2606. my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx;
  2607. $output_rules .= file_contents ('texibuild',
  2608. new Automake::Location,
  2609. AM_V_MAKEINFO => verbose_flag('MAKEINFO'),
  2610. AM_V_TEXI2DVI => verbose_flag('TEXI2DVI'),
  2611. AM_V_TEXI2PDF => verbose_flag('TEXI2PDF'),
  2612. DEPS => "@deps",
  2613. DEST_PREFIX => $dpfx,
  2614. DEST_INFO_PREFIX => $dipfx,
  2615. DEST_SUFFIX => $dsfx,
  2616. DIRSTAMP => $dirstamp,
  2617. GENERIC => $generic,
  2618. GENERIC_INFO => $generic_info,
  2619. INSRC => $insrc,
  2620. MAKEINFOFLAGS => $makeinfoflags,
  2621. SILENT => silent_flag(),
  2622. SOURCE => ($generic
  2623. ? '$<' : $source),
  2624. SOURCE_INFO => ($generic_info
  2625. ? '$<' : $source),
  2626. SOURCE_REAL => $source,
  2627. SOURCE_SUFFIX => $ssfx,
  2628. TEXIQUIET => verbose_flag('texinfo'),
  2629. TEXIDEVNULL => verbose_flag('texidevnull'),
  2630. );
  2631. return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html");
  2632. }
  2633. # ($MOSTLYCLEAN, $TEXICLEAN, $MAINTCLEAN)
  2634. # handle_texinfo_helper ($info_texinfos)
  2635. # --------------------------------------
  2636. # Handle all Texinfo source; helper for 'handle_texinfo'.
  2637. sub handle_texinfo_helper
  2638. {
  2639. my ($info_texinfos) = @_;
  2640. my (@infobase, @info_deps_list, @texi_deps);
  2641. my %versions;
  2642. my $done = 0;
  2643. my (@mostly_cleans, @texi_cleans, @maint_cleans) = ('', '', '');
  2644. # Build a regex matching user-cleaned files.
  2645. my $d = var 'DISTCLEANFILES';
  2646. my $c = var 'CLEANFILES';
  2647. my @f = ();
  2648. push @f, $d->value_as_list_recursive (inner_expand => 1) if $d;
  2649. push @f, $c->value_as_list_recursive (inner_expand => 1) if $c;
  2650. @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f;
  2651. my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$';
  2652. foreach my $texi
  2653. ($info_texinfos->value_as_list_recursive (inner_expand => 1))
  2654. {
  2655. my $infobase = $texi;
  2656. if ($infobase =~ s/\.texi$//)
  2657. {
  2658. 1; # Nothing more to do.
  2659. }
  2660. elsif ($infobase =~ s/\.(txi|texinfo)$//)
  2661. {
  2662. msg_var 'obsolete', $info_texinfos,
  2663. "suffix '.$1' for Texinfo files is discouraged;" .
  2664. " use '.texi' instead";
  2665. }
  2666. else
  2667. {
  2668. # FIXME: report line number.
  2669. err_am "texinfo file '$texi' has unrecognized extension";
  2670. next;
  2671. }
  2672. push @infobase, $infobase;
  2673. # If 'version.texi' is referenced by input file, then include
  2674. # automatic versioning capability.
  2675. my ($out_file, $vtexi) =
  2676. scan_texinfo_file ("$relative_dir/$texi")
  2677. or next;
  2678. # Directory of auxiliary files and build by-products used by texi2dvi
  2679. # and texi2pdf.
  2680. push @mostly_cleans, "$infobase.t2d";
  2681. push @mostly_cleans, "$infobase.t2p";
  2682. # If the Texinfo source is in a subdirectory, create the
  2683. # resulting info in this subdirectory. If it is in the current
  2684. # directory, try hard to not prefix "./" because it breaks the
  2685. # generic rules.
  2686. my $outdir = dirname ($texi) . '/';
  2687. $outdir = "" if $outdir eq './';
  2688. $out_file = $outdir . $out_file;
  2689. # Until Automake 1.6.3, .info files were built in the
  2690. # source tree. This was an obstacle to the support of
  2691. # non-distributed .info files, and non-distributed .texi
  2692. # files.
  2693. #
  2694. # * Non-distributed .texi files is important in some packages
  2695. # where .texi files are built at make time, probably using
  2696. # other binaries built in the package itself, maybe using
  2697. # tools or information found on the build host. Because
  2698. # these files are not distributed they are always rebuilt
  2699. # at make time; they should therefore not lie in the source
  2700. # directory. One plan was to support this using
  2701. # nodist_info_TEXINFOS or something similar. (Doing this
  2702. # requires some sanity checks. For instance Automake should
  2703. # not allow:
  2704. # dist_info_TEXINFOS = foo.texi
  2705. # nodist_foo_TEXINFOS = included.texi
  2706. # because a distributed file should never depend on a
  2707. # non-distributed file.)
  2708. #
  2709. # * If .texi files are not distributed, then .info files should
  2710. # not be distributed either. There are also cases where one
  2711. # wants to distribute .texi files, but does not want to
  2712. # distribute the .info files. For instance the Texinfo package
  2713. # distributes the tool used to build these files; it would
  2714. # be a waste of space to distribute them. It's not clear
  2715. # which syntax we should use to indicate that .info files should
  2716. # not be distributed. Akim Demaille suggested that eventually
  2717. # we switch to a new syntax:
  2718. # | Maybe we should take some inspiration from what's already
  2719. # | done in the rest of Automake. Maybe there is too much
  2720. # | syntactic sugar here, and you want
  2721. # | nodist_INFO = bar.info
  2722. # | dist_bar_info_SOURCES = bar.texi
  2723. # | bar_texi_DEPENDENCIES = foo.texi
  2724. # | with a bit of magic to have bar.info represent the whole
  2725. # | bar*info set. That's a lot more verbose that the current
  2726. # | situation, but it is # not new, hence the user has less
  2727. # | to learn.
  2728. # |
  2729. # | But there is still too much room for meaningless specs:
  2730. # | nodist_INFO = bar.info
  2731. # | dist_bar_info_SOURCES = bar.texi
  2732. # | dist_PS = bar.ps something-written-by-hand.ps
  2733. # | nodist_bar_ps_SOURCES = bar.texi
  2734. # | bar_texi_DEPENDENCIES = foo.texi
  2735. # | here bar.texi is dist_ in line 2, and nodist_ in 4.
  2736. #
  2737. # Back to the point, it should be clear that in order to support
  2738. # non-distributed .info files, we need to build them in the
  2739. # build tree, not in the source tree (non-distributed .texi
  2740. # files are less of a problem, because we do not output build
  2741. # rules for them). In Automake 1.7 .info build rules have been
  2742. # largely cleaned up so that .info files get always build in the
  2743. # build tree, even when distributed. The idea was that
  2744. # (1) if during a VPATH build the .info file was found to be
  2745. # absent or out-of-date (in the source tree or in the
  2746. # build tree), Make would rebuild it in the build tree.
  2747. # If an up-to-date source-tree of the .info file existed,
  2748. # make would not rebuild it in the build tree.
  2749. # (2) having two copies of .info files, one in the source tree
  2750. # and one (newer) in the build tree is not a problem
  2751. # because 'make dist' always pick files in the build tree
  2752. # first.
  2753. # However it turned out the be a bad idea for several reasons:
  2754. # * Tru64, OpenBSD, and FreeBSD (not NetBSD) Make do not behave
  2755. # like GNU Make on point (1) above. These implementations
  2756. # of Make would always rebuild .info files in the build
  2757. # tree, even if such files were up to date in the source
  2758. # tree. Consequently, it was impossible to perform a VPATH
  2759. # build of a package containing Texinfo files using these
  2760. # Make implementations.
  2761. # (Refer to the Autoconf Manual, section "Limitation of
  2762. # Make", paragraph "VPATH", item "target lookup", for
  2763. # an account of the differences between these
  2764. # implementations.)
  2765. # * The GNU Coding Standards require these files to be built
  2766. # in the source-tree (when they are distributed, that is).
  2767. # * Keeping a fresher copy of distributed files in the
  2768. # build tree can be annoying during development because
  2769. # - if the files is kept under CVS, you really want it
  2770. # to be updated in the source tree
  2771. # - it is confusing that 'make distclean' does not erase
  2772. # all files in the build tree.
  2773. #
  2774. # Consequently, starting with Automake 1.8, .info files are
  2775. # built in the source tree again. Because we still plan to
  2776. # support non-distributed .info files at some point, we
  2777. # have a single variable ($INSRC) that controls whether
  2778. # the current .info file must be built in the source tree
  2779. # or in the build tree. Actually this variable is switched
  2780. # off in two cases:
  2781. # (1) For '.info' files that appear to be cleaned; this is for
  2782. # backward compatibility with package such as Texinfo,
  2783. # which do things like
  2784. # info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
  2785. # DISTCLEANFILES = texinfo texinfo-* info*.info*
  2786. # # Do not create info files for distribution.
  2787. # dist-info:
  2788. # in order not to distribute .info files.
  2789. # (2) When the undocumented option 'info-in-builddir' is given.
  2790. # This is done to allow the developers of GCC, GDB, GNU
  2791. # binutils and the GNU bfd library to force the '.info' files
  2792. # to be generated in the builddir rather than the srcdir, as
  2793. # was once done when the (now removed) 'cygnus' option was
  2794. # given. See automake bug#11034 for more discussion.
  2795. my $insrc = 1;
  2796. my $soutdir = '$(srcdir)/' . $outdir;
  2797. if (option 'info-in-builddir')
  2798. {
  2799. $insrc = 0;
  2800. }
  2801. elsif ($out_file =~ $user_cleaned_files)
  2802. {
  2803. $insrc = 0;
  2804. msg 'obsolete', "$am_file.am", <<EOF;
  2805. Oops!
  2806. It appears this file (or files included by it) are triggering
  2807. an undocumented, soon-to-be-removed automake hack.
  2808. Future automake versions will no longer place in the builddir
  2809. (rather than in the srcdir) the generated '.info' files that
  2810. appear to be cleaned, by e.g. being listed in CLEANFILES or
  2811. DISTCLEANFILES.
  2812. If you want your '.info' files to be placed in the builddir
  2813. rather than in the srcdir, you have to use the shiny new
  2814. 'info-in-builddir' automake option.
  2815. EOF
  2816. }
  2817. $outdir = $soutdir if $insrc;
  2818. # If user specified file_TEXINFOS, then use that as explicit
  2819. # dependency list.
  2820. @texi_deps = ();
  2821. push (@texi_deps, "${soutdir}${vtexi}") if $vtexi;
  2822. my $canonical = canonicalize ($infobase);
  2823. if (var ($canonical . "_TEXINFOS"))
  2824. {
  2825. push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
  2826. push_dist_common ('$(' . $canonical . '_TEXINFOS)');
  2827. }
  2828. my ($dirstamp, @cfiles) =
  2829. output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps);
  2830. push (@texi_cleans, @cfiles);
  2831. push (@info_deps_list, $out_file);
  2832. # If a vers*.texi file is needed, emit the rule.
  2833. if ($vtexi)
  2834. {
  2835. err_am ("'$vtexi', included in '$texi', "
  2836. . "also included in '$versions{$vtexi}'")
  2837. if defined $versions{$vtexi};
  2838. $versions{$vtexi} = $texi;
  2839. # We number the stamp-vti files. This is doable since the
  2840. # actual names don't matter much. We only number starting
  2841. # with the second one, so that the common case looks nice.
  2842. my $vti = ($done ? $done : 'vti');
  2843. ++$done;
  2844. # This is ugly, but it is our historical practice.
  2845. if ($config_aux_dir_set_in_configure_ac)
  2846. {
  2847. require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
  2848. 'mdate-sh');
  2849. }
  2850. else
  2851. {
  2852. require_file_with_macro (TRUE, 'info_TEXINFOS',
  2853. FOREIGN, 'mdate-sh');
  2854. }
  2855. my $conf_dir;
  2856. if ($config_aux_dir_set_in_configure_ac)
  2857. {
  2858. $conf_dir = "$am_config_aux_dir/";
  2859. }
  2860. else
  2861. {
  2862. $conf_dir = '$(srcdir)/';
  2863. }
  2864. $output_rules .= file_contents ('texi-vers',
  2865. new Automake::Location,
  2866. TEXI => $texi,
  2867. VTI => $vti,
  2868. STAMPVTI => "${soutdir}stamp-$vti",
  2869. VTEXI => "$soutdir$vtexi",
  2870. MDDIR => $conf_dir,
  2871. DIRSTAMP => $dirstamp);
  2872. }
  2873. }
  2874. # Handle location of texinfo.tex.
  2875. my $need_texi_file = 0;
  2876. my $texinfodir;
  2877. if (var ('TEXINFO_TEX'))
  2878. {
  2879. # The user defined TEXINFO_TEX so assume he knows what he is
  2880. # doing.
  2881. $texinfodir = ('$(srcdir)/'
  2882. . dirname (variable_value ('TEXINFO_TEX')));
  2883. }
  2884. elsif ($config_aux_dir_set_in_configure_ac)
  2885. {
  2886. $texinfodir = $am_config_aux_dir;
  2887. define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
  2888. $need_texi_file = 2; # so that we require_conf_file later
  2889. }
  2890. else
  2891. {
  2892. $texinfodir = '$(srcdir)';
  2893. $need_texi_file = 1;
  2894. }
  2895. define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);
  2896. push (@dist_targets, 'dist-info');
  2897. if (! option 'no-installinfo')
  2898. {
  2899. # Make sure documentation is made and installed first. Use
  2900. # $(INFO_DEPS), not 'info', because otherwise recursive makes
  2901. # get run twice during "make all".
  2902. unshift (@all, '$(INFO_DEPS)');
  2903. }
  2904. define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL);
  2905. define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL);
  2906. define_files_variable ("PSS", @infobase, 'ps', INTERNAL);
  2907. define_files_variable ("HTMLS", @infobase, 'html', INTERNAL);
  2908. # This next isn't strictly needed now -- the places that look here
  2909. # could easily be changed to look in info_TEXINFOS. But this is
  2910. # probably better, in case noinst_TEXINFOS is ever supported.
  2911. define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL);
  2912. # Do some error checking. Note that this file is not required
  2913. # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
  2914. # up above.
  2915. if ($need_texi_file && ! option 'no-texinfo.tex')
  2916. {
  2917. if ($need_texi_file > 1)
  2918. {
  2919. require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
  2920. 'texinfo.tex');
  2921. }
  2922. else
  2923. {
  2924. require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
  2925. 'texinfo.tex');
  2926. }
  2927. }
  2928. return (makefile_wrap ("", "\t ", @mostly_cleans),
  2929. makefile_wrap ("", "\t ", @texi_cleans),
  2930. makefile_wrap ("", "\t ", @maint_cleans));
  2931. }
  2932. sub handle_texinfo ()
  2933. {
  2934. reject_var 'TEXINFOS', "'TEXINFOS' is an anachronism; use 'info_TEXINFOS'";
  2935. # FIXME: I think this is an obsolete future feature name.
  2936. reject_var 'html_TEXINFOS', "HTML generation not yet supported";
  2937. my $info_texinfos = var ('info_TEXINFOS');
  2938. my ($mostlyclean, $clean, $maintclean) = ('', '', '');
  2939. if ($info_texinfos)
  2940. {
  2941. define_verbose_texinfo;
  2942. ($mostlyclean, $clean, $maintclean) = handle_texinfo_helper ($info_texinfos);
  2943. chomp $mostlyclean;
  2944. chomp $clean;
  2945. chomp $maintclean;
  2946. }
  2947. $output_rules .= file_contents ('texinfos',
  2948. new Automake::Location,
  2949. AM_V_DVIPS => verbose_flag('DVIPS'),
  2950. MOSTLYCLEAN => $mostlyclean,
  2951. TEXICLEAN => $clean,
  2952. MAINTCLEAN => $maintclean,
  2953. 'LOCAL-TEXIS' => !!$info_texinfos,
  2954. TEXIQUIET => verbose_flag('texinfo'));
  2955. }
  2956. sub handle_man_pages ()
  2957. {
  2958. reject_var 'MANS', "'MANS' is an anachronism; use 'man_MANS'";
  2959. # Find all the sections in use. We do this by first looking for
  2960. # "standard" sections, and then looking for any additional
  2961. # sections used in man_MANS.
  2962. my (%sections, %notrans_sections, %trans_sections,
  2963. %notrans_vars, %trans_vars, %notrans_sect_vars, %trans_sect_vars);
  2964. # We handle nodist_ for uniformity. man pages aren't distributed
  2965. # by default so it isn't actually very important.
  2966. foreach my $npfx ('', 'notrans_')
  2967. {
  2968. foreach my $pfx ('', 'dist_', 'nodist_')
  2969. {
  2970. # Add more sections as needed.
  2971. foreach my $section ('0'..'9', 'n', 'l')
  2972. {
  2973. my $varname = $npfx . $pfx . 'man' . $section . '_MANS';
  2974. if (var ($varname))
  2975. {
  2976. $sections{$section} = 1;
  2977. $varname = '$(' . $varname . ')';
  2978. if ($npfx eq 'notrans_')
  2979. {
  2980. $notrans_sections{$section} = 1;
  2981. $notrans_sect_vars{$varname} = 1;
  2982. }
  2983. else
  2984. {
  2985. $trans_sections{$section} = 1;
  2986. $trans_sect_vars{$varname} = 1;
  2987. }
  2988. push_dist_common ($varname)
  2989. if $pfx eq 'dist_';
  2990. }
  2991. }
  2992. my $varname = $npfx . $pfx . 'man_MANS';
  2993. my $var = var ($varname);
  2994. if ($var)
  2995. {
  2996. foreach ($var->value_as_list_recursive)
  2997. {
  2998. # A page like 'foo.1c' goes into man1dir.
  2999. if (/\.([0-9a-z])([a-z]*)$/)
  3000. {
  3001. $sections{$1} = 1;
  3002. if ($npfx eq 'notrans_')
  3003. {
  3004. $notrans_sections{$1} = 1;
  3005. }
  3006. else
  3007. {
  3008. $trans_sections{$1} = 1;
  3009. }
  3010. }
  3011. }
  3012. $varname = '$(' . $varname . ')';
  3013. if ($npfx eq 'notrans_')
  3014. {
  3015. $notrans_vars{$varname} = 1;
  3016. }
  3017. else
  3018. {
  3019. $trans_vars{$varname} = 1;
  3020. }
  3021. push_dist_common ($varname)
  3022. if $pfx eq 'dist_';
  3023. }
  3024. }
  3025. }
  3026. return unless %sections;
  3027. my @unsorted_deps;
  3028. # Build section independent variables.
  3029. my $have_notrans = %notrans_vars;
  3030. my @notrans_list = sort keys %notrans_vars;
  3031. my $have_trans = %trans_vars;
  3032. my @trans_list = sort keys %trans_vars;
  3033. # Now for each section, generate an install and uninstall rule.
  3034. # Sort sections so output is deterministic.
  3035. foreach my $section (sort keys %sections)
  3036. {
  3037. # Build section dependent variables.
  3038. my $notrans_mans = $have_notrans || exists $notrans_sections{$section};
  3039. my $trans_mans = $have_trans || exists $trans_sections{$section};
  3040. my (%notrans_this_sect, %trans_this_sect);
  3041. my $expr = 'man' . $section . '_MANS';
  3042. foreach my $varname (keys %notrans_sect_vars)
  3043. {
  3044. if ($varname =~ /$expr/)
  3045. {
  3046. $notrans_this_sect{$varname} = 1;
  3047. }
  3048. }
  3049. foreach my $varname (keys %trans_sect_vars)
  3050. {
  3051. if ($varname =~ /$expr/)
  3052. {
  3053. $trans_this_sect{$varname} = 1;
  3054. }
  3055. }
  3056. my @notrans_sect_list = sort keys %notrans_this_sect;
  3057. my @trans_sect_list = sort keys %trans_this_sect;
  3058. @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
  3059. keys %notrans_this_sect, keys %trans_this_sect);
  3060. my @deps = sort @unsorted_deps;
  3061. $output_rules .= file_contents ('mans',
  3062. new Automake::Location,
  3063. SECTION => $section,
  3064. DEPS => "@deps",
  3065. NOTRANS_MANS => $notrans_mans,
  3066. NOTRANS_SECT_LIST => "@notrans_sect_list",
  3067. HAVE_NOTRANS => $have_notrans,
  3068. NOTRANS_LIST => "@notrans_list",
  3069. TRANS_MANS => $trans_mans,
  3070. TRANS_SECT_LIST => "@trans_sect_list",
  3071. HAVE_TRANS => $have_trans,
  3072. TRANS_LIST => "@trans_list");
  3073. }
  3074. @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
  3075. keys %notrans_sect_vars, keys %trans_sect_vars);
  3076. my @mans = sort @unsorted_deps;
  3077. $output_vars .= file_contents ('mans-vars',
  3078. new Automake::Location,
  3079. MANS => "@mans");
  3080. push (@all, '$(MANS)')
  3081. unless option 'no-installman';
  3082. }
  3083. sub handle_data ()
  3084. {
  3085. am_install_var ('-noextra', '-candist', 'data', 'DATA',
  3086. 'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf',
  3087. 'ps', 'sysconf', 'sharedstate', 'localstate',
  3088. 'pkgdata', 'lisp', 'noinst', 'check');
  3089. }
  3090. sub handle_tags ()
  3091. {
  3092. my @config;
  3093. foreach my $spec (@config_headers)
  3094. {
  3095. my ($out, @ins) = split_config_file_spec ($spec);
  3096. foreach my $in (@ins)
  3097. {
  3098. # If the config header source is in this directory,
  3099. # require it.
  3100. push @config, basename ($in)
  3101. if $relative_dir eq dirname ($in);
  3102. }
  3103. }
  3104. define_variable ('am__tagged_files',
  3105. '$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)'
  3106. . "@config", INTERNAL);
  3107. if (rvar('am__tagged_files')->value_as_list_recursive
  3108. || var ('ETAGS_ARGS') || var ('SUBDIRS'))
  3109. {
  3110. $output_rules .= file_contents ('tags', new Automake::Location);
  3111. set_seen 'TAGS_DEPENDENCIES';
  3112. }
  3113. else
  3114. {
  3115. reject_var ('TAGS_DEPENDENCIES',
  3116. "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
  3117. . " without\nsources or 'ETAGS_ARGS'");
  3118. # Every Makefile must define some sort of TAGS rule.
  3119. # Otherwise, it would be possible for a top-level "make TAGS"
  3120. # to fail because some subdirectory failed. Ditto ctags and
  3121. # cscope.
  3122. $output_rules .=
  3123. "tags TAGS:\n\n" .
  3124. "ctags CTAGS:\n\n" .
  3125. "cscope cscopelist:\n\n";
  3126. }
  3127. }
  3128. # user_phony_rule ($NAME)
  3129. # -----------------------
  3130. # Return false if rule $NAME does not exist. Otherwise,
  3131. # declare it as phony, complete its definition (in case it is
  3132. # conditional), and return its Automake::Rule instance.
  3133. sub user_phony_rule
  3134. {
  3135. my ($name) = @_;
  3136. my $rule = rule $name;
  3137. if ($rule)
  3138. {
  3139. depend ('.PHONY', $name);
  3140. # Define $NAME in all condition where it is not already defined,
  3141. # so that it is always OK to depend on $NAME.
  3142. for my $c ($rule->not_always_defined_in_cond (TRUE)->conds)
  3143. {
  3144. Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE,
  3145. $c, INTERNAL);
  3146. $output_rules .= $c->subst_string . "$name:\n";
  3147. }
  3148. }
  3149. return $rule;
  3150. }
  3151. # Handle 'dist' target.
  3152. sub handle_dist ()
  3153. {
  3154. # Substitutions for distdir.am
  3155. my %transform;
  3156. # Define DIST_SUBDIRS. This must always be done, regardless of the
  3157. # no-dist setting: target like 'distclean' or 'maintainer-clean' use it.
  3158. my $subdirs = var ('SUBDIRS');
  3159. if ($subdirs)
  3160. {
  3161. # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
  3162. # to all possible directories, and use it. If DIST_SUBDIRS is
  3163. # defined, just use it.
  3164. # Note that we check DIST_SUBDIRS first on purpose, so that
  3165. # we don't call has_conditional_contents for now reason.
  3166. # (In the past one project used so many conditional subdirectories
  3167. # that calling has_conditional_contents on SUBDIRS caused
  3168. # automake to grow to 150Mb -- this should not happen with
  3169. # the current implementation of has_conditional_contents,
  3170. # but it's more efficient to avoid the call anyway.)
  3171. if (var ('DIST_SUBDIRS'))
  3172. {
  3173. }
  3174. elsif ($subdirs->has_conditional_contents)
  3175. {
  3176. define_pretty_variable
  3177. ('DIST_SUBDIRS', TRUE, INTERNAL,
  3178. uniq ($subdirs->value_as_list_recursive));
  3179. }
  3180. else
  3181. {
  3182. # We always define this because that is what 'distclean'
  3183. # wants.
  3184. define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL,
  3185. '$(SUBDIRS)');
  3186. }
  3187. }
  3188. # The remaining definitions are only required when a dist target is used.
  3189. return if option 'no-dist';
  3190. # At least one of the archive formats must be enabled.
  3191. if ($relative_dir eq '.')
  3192. {
  3193. my $archive_defined = option 'no-dist-gzip' ? 0 : 1;
  3194. $archive_defined ||=
  3195. grep { option "dist-$_" } qw(shar zip tarZ bzip2 lzip xz);
  3196. error (option 'no-dist-gzip',
  3197. "no-dist-gzip specified but no dist-* specified,\n"
  3198. . "at least one archive format must be enabled")
  3199. unless $archive_defined;
  3200. }
  3201. # Look for common files that should be included in distribution.
  3202. # If the aux dir is set, and it does not have a Makefile.am, then
  3203. # we check for these files there as well.
  3204. my $check_aux = 0;
  3205. if ($relative_dir eq '.'
  3206. && $config_aux_dir_set_in_configure_ac)
  3207. {
  3208. if (! is_make_dir ($config_aux_dir))
  3209. {
  3210. $check_aux = 1;
  3211. }
  3212. }
  3213. foreach my $cfile (@common_files)
  3214. {
  3215. if (dir_has_case_matching_file ($relative_dir, $cfile)
  3216. # The file might be absent, but if it can be built it's ok.
  3217. || rule $cfile)
  3218. {
  3219. push_dist_common ($cfile);
  3220. }
  3221. # Don't use 'elsif' here because a file might meaningfully
  3222. # appear in both directories.
  3223. if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile))
  3224. {
  3225. push_dist_common ("$config_aux_dir/$cfile")
  3226. }
  3227. }
  3228. # We might copy elements from @configure_dist_common to
  3229. # @dist_common if we think we need to. If the file appears in our
  3230. # directory, we would have discovered it already, so we don't
  3231. # check that. But if the file is in a subdir without a Makefile,
  3232. # we want to distribute it here if we are doing '.'. Ugly!
  3233. # Also, in some corner cases, it's possible that the following code
  3234. # will cause the same file to appear in the $(DIST_COMMON) variables
  3235. # of two distinct Makefiles; but this is not a problem, since the
  3236. # 'distdir' target in 'lib/am/distdir.am' can deal with the same
  3237. # file being distributed multiple times.
  3238. # See also automake bug#9651.
  3239. if ($relative_dir eq '.')
  3240. {
  3241. foreach my $file (@configure_dist_common)
  3242. {
  3243. my $dir = dirname ($file);
  3244. push_dist_common ($file)
  3245. if ($dir eq '.' || ! is_make_dir ($dir));
  3246. }
  3247. @configure_dist_common = ();
  3248. }
  3249. # $(am__DIST_COMMON): files to be distributed automatically. Will be
  3250. # appended to $(DIST_COMMON) in the generated Makefile.
  3251. # Use 'sort' so that the expansion of $(DIST_COMMON) in the generated
  3252. # Makefile is deterministic, in face of m4 and/or perl randomizations
  3253. # (see automake bug#17908).
  3254. define_pretty_variable ('am__DIST_COMMON', TRUE, INTERNAL,
  3255. uniq (sort @dist_common));
  3256. # Now that we've processed @dist_common, disallow further attempts
  3257. # to modify it.
  3258. $handle_dist_run = 1;
  3259. $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook';
  3260. $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
  3261. # If the target 'dist-hook' exists, make sure it is run. This
  3262. # allows users to do random weird things to the distribution
  3263. # before it is packaged up.
  3264. push (@dist_targets, 'dist-hook')
  3265. if user_phony_rule 'dist-hook';
  3266. $transform{'DIST-TARGETS'} = join (' ', @dist_targets);
  3267. my $flm = option ('filename-length-max');
  3268. my $filename_filter = $flm ? '.' x $flm->[1] : '';
  3269. $output_rules .= file_contents ('distdir',
  3270. new Automake::Location,
  3271. %transform,
  3272. FILENAME_FILTER => $filename_filter);
  3273. }
  3274. # check_directory ($NAME, $WHERE [, $RELATIVE_DIR = "."])
  3275. # -------------------------------------------------------
  3276. # Ensure $NAME is a directory (in $RELATIVE_DIR), and that it uses a sane
  3277. # name. Use $WHERE as a location in the diagnostic, if any.
  3278. sub check_directory
  3279. {
  3280. my ($dir, $where, $reldir) = @_;
  3281. $reldir = '.' unless defined $reldir;
  3282. error $where, "required directory $reldir/$dir does not exist"
  3283. unless -d "$reldir/$dir";
  3284. # If an 'obj/' directory exists, BSD make will enter it before
  3285. # reading 'Makefile'. Hence the 'Makefile' in the current directory
  3286. # will not be read.
  3287. #
  3288. # % cat Makefile
  3289. # all:
  3290. # echo Hello
  3291. # % cat obj/Makefile
  3292. # all:
  3293. # echo World
  3294. # % make # GNU make
  3295. # echo Hello
  3296. # Hello
  3297. # % pmake # BSD make
  3298. # echo World
  3299. # World
  3300. msg ('portability', $where,
  3301. "naming a subdirectory 'obj' causes troubles with BSD make")
  3302. if $dir eq 'obj';
  3303. # 'aux' is probably the most important of the following forbidden name,
  3304. # since it's tempting to use it as an AC_CONFIG_AUX_DIR.
  3305. msg ('portability', $where,
  3306. "name '$dir' is reserved on W32 and DOS platforms")
  3307. if grep (/^\Q$dir\E$/i, qw/aux lpt1 lpt2 lpt3 com1 com2 com3 com4 con prn/);
  3308. }
  3309. # check_directories_in_var ($VARIABLE)
  3310. # ------------------------------------
  3311. # Recursively check all items in variables $VARIABLE as directories
  3312. sub check_directories_in_var
  3313. {
  3314. my ($var) = @_;
  3315. $var->traverse_recursively
  3316. (sub
  3317. {
  3318. my ($var, $val, $cond, $full_cond) = @_;
  3319. check_directory ($val, $var->rdef ($cond)->location, $relative_dir);
  3320. return ();
  3321. },
  3322. undef,
  3323. skip_ac_subst => 1);
  3324. }
  3325. sub handle_subdirs ()
  3326. {
  3327. my $subdirs = var ('SUBDIRS');
  3328. return
  3329. unless $subdirs;
  3330. check_directories_in_var $subdirs;
  3331. my $dsubdirs = var ('DIST_SUBDIRS');
  3332. check_directories_in_var $dsubdirs
  3333. if $dsubdirs;
  3334. $output_rules .= file_contents ('subdirs', new Automake::Location);
  3335. rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross!
  3336. }
  3337. # ($REGEN, @DEPENDENCIES)
  3338. # scan_aclocal_m4
  3339. # ---------------
  3340. # If aclocal.m4 creation is automated, return the list of its dependencies.
  3341. sub scan_aclocal_m4 ()
  3342. {
  3343. my $regen_aclocal = 0;
  3344. set_seen 'CONFIG_STATUS_DEPENDENCIES';
  3345. set_seen 'CONFIGURE_DEPENDENCIES';
  3346. if (-f 'aclocal.m4')
  3347. {
  3348. define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
  3349. my $aclocal = new Automake::XFile "< aclocal.m4";
  3350. my $line = $aclocal->getline;
  3351. $regen_aclocal = $line =~ 'generated automatically by aclocal';
  3352. }
  3353. my @ac_deps = ();
  3354. if (set_seen ('ACLOCAL_M4_SOURCES'))
  3355. {
  3356. push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
  3357. msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
  3358. "'ACLOCAL_M4_SOURCES' is obsolete.\n"
  3359. . "It should be safe to simply remove it");
  3360. }
  3361. # Note that it might be possible that aclocal.m4 doesn't exist but
  3362. # should be auto-generated. This case probably isn't very
  3363. # important.
  3364. return ($regen_aclocal, @ac_deps);
  3365. }
  3366. # Helper function for 'substitute_ac_subst_variables'.
  3367. sub substitute_ac_subst_variables_worker
  3368. {
  3369. my ($token) = @_;
  3370. return "\@$token\@" if var $token;
  3371. return "\${$token\}";
  3372. }
  3373. # substitute_ac_subst_variables ($TEXT)
  3374. # -------------------------------------
  3375. # Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST
  3376. # variable.
  3377. sub substitute_ac_subst_variables
  3378. {
  3379. my ($text) = @_;
  3380. $text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
  3381. return $text;
  3382. }
  3383. # @DEPENDENCIES
  3384. # prepend_srcdir (@INPUTS)
  3385. # ------------------------
  3386. # Prepend $(srcdir) or $(top_srcdir) to all @INPUTS. The idea is that
  3387. # if an input file has a directory part the same as the current
  3388. # directory, then the directory part is simply replaced by $(srcdir).
  3389. # But if the directory part is different, then $(top_srcdir) is
  3390. # prepended.
  3391. sub prepend_srcdir
  3392. {
  3393. my (@inputs) = @_;
  3394. my @newinputs;
  3395. foreach my $single (@inputs)
  3396. {
  3397. if (dirname ($single) eq $relative_dir)
  3398. {
  3399. push (@newinputs, '$(srcdir)/' . basename ($single));
  3400. }
  3401. else
  3402. {
  3403. push (@newinputs, '$(top_srcdir)/' . $single);
  3404. }
  3405. }
  3406. return @newinputs;
  3407. }
  3408. # @DEPENDENCIES
  3409. # rewrite_inputs_into_dependencies ($OUTPUT, @INPUTS)
  3410. # ---------------------------------------------------
  3411. # Compute a list of dependencies appropriate for the rebuild
  3412. # rule of
  3413. # AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...)
  3414. # Also distribute $INPUTs which are not built by another AC_CONFIG_FOOs.
  3415. sub rewrite_inputs_into_dependencies
  3416. {
  3417. my ($file, @inputs) = @_;
  3418. my @res = ();
  3419. for my $i (@inputs)
  3420. {
  3421. # We cannot create dependencies on shell variables.
  3422. next if (substitute_ac_subst_variables $i) =~ /\$/;
  3423. if (exists $ac_config_files_location{$i} && $i ne $file)
  3424. {
  3425. my $di = dirname $i;
  3426. if ($di eq $relative_dir)
  3427. {
  3428. $i = basename $i;
  3429. }
  3430. # In the top-level Makefile we do not use $(top_builddir), because
  3431. # we are already there, and since the targets are built without
  3432. # a $(top_builddir), it helps BSD Make to match them with
  3433. # dependencies.
  3434. elsif ($relative_dir ne '.')
  3435. {
  3436. $i = '$(top_builddir)/' . $i;
  3437. }
  3438. }
  3439. else
  3440. {
  3441. msg ('error', $ac_config_files_location{$file},
  3442. "required file '$i' not found")
  3443. unless $i =~ /\$/ || exists $output_files{$i} || -f $i;
  3444. ($i) = prepend_srcdir ($i);
  3445. push_dist_common ($i);
  3446. }
  3447. push @res, $i;
  3448. }
  3449. return @res;
  3450. }
  3451. # handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
  3452. # -----------------------------------------------------------------
  3453. # Handle remaking and configure stuff.
  3454. # We need the name of the input file, to do proper remaking rules.
  3455. sub handle_configure
  3456. {
  3457. my ($makefile_am, $makefile_in, $makefile, @inputs) = @_;
  3458. prog_error 'empty @inputs'
  3459. unless @inputs;
  3460. my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am,
  3461. $makefile_in);
  3462. my $rel_makefile = basename $makefile;
  3463. my $colon_infile = ':' . join (':', @inputs);
  3464. $colon_infile = '' if $colon_infile eq ":$makefile.in";
  3465. my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs);
  3466. my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
  3467. define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL,
  3468. @configure_deps, @aclocal_m4_deps,
  3469. '$(top_srcdir)/' . $configure_ac);
  3470. my @configuredeps = ('$(am__aclocal_m4_deps)', '$(CONFIGURE_DEPENDENCIES)');
  3471. push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4';
  3472. define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
  3473. @configuredeps);
  3474. my $automake_options = '--' . $strictness_name .
  3475. (global_option 'no-dependencies' ? ' --ignore-deps' : '');
  3476. $output_rules .= file_contents
  3477. ('configure',
  3478. new Automake::Location,
  3479. MAKEFILE => $rel_makefile,
  3480. 'MAKEFILE-DEPS' => "@rewritten",
  3481. 'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
  3482. 'MAKEFILE-IN' => $rel_makefile_in,
  3483. 'HAVE-MAKEFILE-IN-DEPS' => (@include_stack > 0),
  3484. 'MAKEFILE-IN-DEPS' => "@include_stack",
  3485. 'MAKEFILE-AM' => $rel_makefile_am,
  3486. 'AUTOMAKE-OPTIONS' => $automake_options,
  3487. 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile",
  3488. 'REGEN-ACLOCAL-M4' => $regen_aclocal_m4,
  3489. VERBOSE => verbose_flag ('GEN'));
  3490. if ($relative_dir eq '.')
  3491. {
  3492. push_dist_common ('acconfig.h')
  3493. if -f 'acconfig.h';
  3494. }
  3495. # If we have a configure header, require it.
  3496. my $hdr_index = 0;
  3497. my @distclean_config;
  3498. foreach my $spec (@config_headers)
  3499. {
  3500. $hdr_index += 1;
  3501. # $CONFIG_H_PATH: config.h from top level.
  3502. my ($config_h_path, @ins) = split_config_file_spec ($spec);
  3503. my $config_h_dir = dirname ($config_h_path);
  3504. # If the header is in the current directory we want to build
  3505. # the header here. Otherwise, if we're at the topmost
  3506. # directory and the header's directory doesn't have a
  3507. # Makefile, then we also want to build the header.
  3508. if ($relative_dir eq $config_h_dir
  3509. || ($relative_dir eq '.' && ! is_make_dir ($config_h_dir)))
  3510. {
  3511. my ($cn_sans_dir, $stamp_dir);
  3512. if ($relative_dir eq $config_h_dir)
  3513. {
  3514. $cn_sans_dir = basename ($config_h_path);
  3515. $stamp_dir = '';
  3516. }
  3517. else
  3518. {
  3519. $cn_sans_dir = $config_h_path;
  3520. if ($config_h_dir eq '.')
  3521. {
  3522. $stamp_dir = '';
  3523. }
  3524. else
  3525. {
  3526. $stamp_dir = $config_h_dir . '/';
  3527. }
  3528. }
  3529. # This will also distribute all inputs.
  3530. @ins = rewrite_inputs_into_dependencies ($config_h_path, @ins);
  3531. # Cannot define rebuild rules for filenames with shell variables.
  3532. next if (substitute_ac_subst_variables $config_h_path) =~ /\$/;
  3533. # Header defined in this directory.
  3534. my @files;
  3535. if (-f $config_h_path . '.top')
  3536. {
  3537. push (@files, "$cn_sans_dir.top");
  3538. }
  3539. if (-f $config_h_path . '.bot')
  3540. {
  3541. push (@files, "$cn_sans_dir.bot");
  3542. }
  3543. push_dist_common (@files);
  3544. # For now, acconfig.h can only appear in the top srcdir.
  3545. if (-f 'acconfig.h')
  3546. {
  3547. push (@files, '$(top_srcdir)/acconfig.h');
  3548. }
  3549. my $stamp = "${stamp_dir}stamp-h${hdr_index}";
  3550. $output_rules .=
  3551. file_contents ('remake-hdr',
  3552. new Automake::Location,
  3553. FILES => "@files",
  3554. 'FIRST-HDR' => ($hdr_index == 1),
  3555. CONFIG_H => $cn_sans_dir,
  3556. CONFIG_HIN => $ins[0],
  3557. CONFIG_H_DEPS => "@ins",
  3558. CONFIG_H_PATH => $config_h_path,
  3559. STAMP => "$stamp");
  3560. push @distclean_config, $cn_sans_dir, $stamp;
  3561. }
  3562. }
  3563. $output_rules .= file_contents ('clean-hdr',
  3564. new Automake::Location,
  3565. FILES => "@distclean_config")
  3566. if @distclean_config;
  3567. # Distribute and define mkinstalldirs only if it is already present
  3568. # in the package, for backward compatibility (some people may still
  3569. # use $(mkinstalldirs)).
  3570. # TODO: start warning about this in Automake 1.14, and have
  3571. # TODO: Automake 2.0 drop it (and the mkinstalldirs script
  3572. # TODO: as well).
  3573. my $mkidpath = "$config_aux_dir/mkinstalldirs";
  3574. if (-f $mkidpath)
  3575. {
  3576. # Use require_file so that any existing script gets updated
  3577. # by --force-missing.
  3578. require_conf_file ($mkidpath, FOREIGN, 'mkinstalldirs');
  3579. define_variable ('mkinstalldirs',
  3580. "\$(SHELL) $am_config_aux_dir/mkinstalldirs", INTERNAL);
  3581. }
  3582. else
  3583. {
  3584. # Use $(install_sh), not $(MKDIR_P) because the latter requires
  3585. # at least one argument, and $(mkinstalldirs) used to work
  3586. # even without arguments (e.g. $(mkinstalldirs) $(conditional_dir)).
  3587. define_variable ('mkinstalldirs', '$(install_sh) -d', INTERNAL);
  3588. }
  3589. reject_var ('CONFIG_HEADER',
  3590. "'CONFIG_HEADER' is an anachronism; now determined "
  3591. . "automatically\nfrom '$configure_ac'");
  3592. my @config_h;
  3593. foreach my $spec (@config_headers)
  3594. {
  3595. my ($out, @ins) = split_config_file_spec ($spec);
  3596. # Generate CONFIG_HEADER define.
  3597. if ($relative_dir eq dirname ($out))
  3598. {
  3599. push @config_h, basename ($out);
  3600. }
  3601. else
  3602. {
  3603. push @config_h, "\$(top_builddir)/$out";
  3604. }
  3605. }
  3606. define_variable ("CONFIG_HEADER", "@config_h", INTERNAL)
  3607. if @config_h;
  3608. # Now look for other files in this directory which must be remade
  3609. # by config.status, and generate rules for them.
  3610. my @actual_other_files = ();
  3611. # These get cleaned only in a VPATH build.
  3612. my @actual_other_vpath_files = ();
  3613. foreach my $lfile (@other_input_files)
  3614. {
  3615. my $file;
  3616. my @inputs;
  3617. if ($lfile =~ /^([^:]*):(.*)$/)
  3618. {
  3619. # This is the ":" syntax of AC_OUTPUT.
  3620. $file = $1;
  3621. @inputs = split (':', $2);
  3622. }
  3623. else
  3624. {
  3625. # Normal usage.
  3626. $file = $lfile;
  3627. @inputs = $file . '.in';
  3628. }
  3629. # Automake files should not be stored in here, but in %MAKE_LIST.
  3630. prog_error ("$lfile in \@other_input_files\n"
  3631. . "\@other_input_files = (@other_input_files)")
  3632. if -f $file . '.am';
  3633. my $local = basename ($file);
  3634. # We skip files that aren't in this directory. However, if
  3635. # the file's directory does not have a Makefile, and we are
  3636. # currently doing '.', then we create a rule to rebuild the
  3637. # file in the subdir.
  3638. my $fd = dirname ($file);
  3639. if ($fd ne $relative_dir)
  3640. {
  3641. if ($relative_dir eq '.' && ! is_make_dir ($fd))
  3642. {
  3643. $local = $file;
  3644. }
  3645. else
  3646. {
  3647. next;
  3648. }
  3649. }
  3650. my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs);
  3651. # Cannot output rules for shell variables.
  3652. next if (substitute_ac_subst_variables $local) =~ /\$/;
  3653. my $condstr = '';
  3654. my $cond = $ac_config_files_condition{$lfile};
  3655. if (defined $cond)
  3656. {
  3657. $condstr = $cond->subst_string;
  3658. Automake::Rule::define ($local, $configure_ac, RULE_AUTOMAKE, $cond,
  3659. $ac_config_files_location{$file});
  3660. }
  3661. $output_rules .= ($condstr . $local . ': '
  3662. . '$(top_builddir)/config.status '
  3663. . "@rewritten_inputs\n"
  3664. . $condstr . "\t"
  3665. . 'cd $(top_builddir) && '
  3666. . '$(SHELL) ./config.status '
  3667. . ($relative_dir eq '.' ? '' : '$(subdir)/')
  3668. . '$@'
  3669. . "\n");
  3670. push (@actual_other_files, $local);
  3671. }
  3672. # For links we should clean destinations and distribute sources.
  3673. foreach my $spec (@config_links)
  3674. {
  3675. my ($link, $file) = split /:/, $spec;
  3676. # Some people do AC_CONFIG_LINKS($computed). We only handle
  3677. # the DEST:SRC form.
  3678. next unless $file;
  3679. my $where = $ac_config_files_location{$link};
  3680. # Skip destinations that contain shell variables.
  3681. if ((substitute_ac_subst_variables $link) !~ /\$/)
  3682. {
  3683. # We skip links that aren't in this directory. However, if
  3684. # the link's directory does not have a Makefile, and we are
  3685. # currently doing '.', then we add the link to CONFIG_CLEAN_FILES
  3686. # in '.'s Makefile.in.
  3687. my $local = basename ($link);
  3688. my $fd = dirname ($link);
  3689. if ($fd ne $relative_dir)
  3690. {
  3691. if ($relative_dir eq '.' && ! is_make_dir ($fd))
  3692. {
  3693. $local = $link;
  3694. }
  3695. else
  3696. {
  3697. $local = undef;
  3698. }
  3699. }
  3700. if ($file ne $link)
  3701. {
  3702. push @actual_other_files, $local if $local;
  3703. }
  3704. else
  3705. {
  3706. push @actual_other_vpath_files, $local if $local;
  3707. }
  3708. }
  3709. # Do not process sources that contain shell variables.
  3710. if ((substitute_ac_subst_variables $file) !~ /\$/)
  3711. {
  3712. my $fd = dirname ($file);
  3713. # We distribute files that are in this directory.
  3714. # At the top-level ('.') we also distribute files whose
  3715. # directory does not have a Makefile.
  3716. if (($fd eq $relative_dir)
  3717. || ($relative_dir eq '.' && ! is_make_dir ($fd)))
  3718. {
  3719. # The following will distribute $file as a side-effect when
  3720. # it is appropriate (i.e., when $file is not already an output).
  3721. # We do not need the result, just the side-effect.
  3722. rewrite_inputs_into_dependencies ($link, $file);
  3723. }
  3724. }
  3725. }
  3726. # These files get removed by "make distclean".
  3727. define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
  3728. @actual_other_files);
  3729. define_pretty_variable ('CONFIG_CLEAN_VPATH_FILES', TRUE, INTERNAL,
  3730. @actual_other_vpath_files);
  3731. }
  3732. sub handle_headers ()
  3733. {
  3734. my @r = am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
  3735. 'oldinclude', 'pkginclude',
  3736. 'noinst', 'check');
  3737. foreach (@r)
  3738. {
  3739. next unless $_->[1] =~ /\..*$/;
  3740. saw_extension ($&);
  3741. }
  3742. }
  3743. sub handle_gettext ()
  3744. {
  3745. return if ! $seen_gettext || $relative_dir ne '.';
  3746. my $subdirs = var 'SUBDIRS';
  3747. if (! $subdirs)
  3748. {
  3749. err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
  3750. return;
  3751. }
  3752. # Perform some sanity checks to help users get the right setup.
  3753. # We disable these tests when po/ doesn't exist in order not to disallow
  3754. # unusual gettext setups.
  3755. #
  3756. # Bruno Haible:
  3757. # | The idea is:
  3758. # |
  3759. # | 1) If a package doesn't have a directory po/ at top level, it
  3760. # | will likely have multiple po/ directories in subpackages.
  3761. # |
  3762. # | 2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT
  3763. # | is used without 'external'. It is also useful to warn for the
  3764. # | presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both
  3765. # | warnings apply only to the usual layout of packages, therefore
  3766. # | they should both be disabled if no po/ directory is found at
  3767. # | top level.
  3768. if (-d 'po')
  3769. {
  3770. my @subdirs = $subdirs->value_as_list_recursive;
  3771. msg_var ('syntax', $subdirs,
  3772. "AM_GNU_GETTEXT used but 'po' not in SUBDIRS")
  3773. if ! grep ($_ eq 'po', @subdirs);
  3774. # intl/ is not required when AM_GNU_GETTEXT is called with the
  3775. # 'external' option and AM_GNU_GETTEXT_INTL_SUBDIR is not called.
  3776. msg_var ('syntax', $subdirs,
  3777. "AM_GNU_GETTEXT used but 'intl' not in SUBDIRS")
  3778. if (! ($seen_gettext_external && ! $seen_gettext_intl)
  3779. && ! grep ($_ eq 'intl', @subdirs));
  3780. # intl/ should not be used with AM_GNU_GETTEXT([external]), except
  3781. # if AM_GNU_GETTEXT_INTL_SUBDIR is called.
  3782. msg_var ('syntax', $subdirs,
  3783. "'intl' should not be in SUBDIRS when "
  3784. . "AM_GNU_GETTEXT([external]) is used")
  3785. if ($seen_gettext_external && ! $seen_gettext_intl
  3786. && grep ($_ eq 'intl', @subdirs));
  3787. }
  3788. require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
  3789. }
  3790. # Emit makefile footer.
  3791. sub handle_footer ()
  3792. {
  3793. reject_rule ('.SUFFIXES',
  3794. "use variable 'SUFFIXES', not target '.SUFFIXES'");
  3795. # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
  3796. # before .SUFFIXES. So we make sure that .SUFFIXES appears before
  3797. # anything else, by sticking it right after the default: target.
  3798. $output_header .= ".SUFFIXES:\n";
  3799. my $suffixes = var 'SUFFIXES';
  3800. my @suffixes = Automake::Rule::suffixes;
  3801. if (@suffixes || $suffixes)
  3802. {
  3803. # Make sure SUFFIXES has unique elements. Sort them to ensure
  3804. # the output remains consistent. However, $(SUFFIXES) is
  3805. # always at the start of the list, unsorted. This is done
  3806. # because make will choose rules depending on the ordering of
  3807. # suffixes, and this lets the user have some control. Push
  3808. # actual suffixes, and not $(SUFFIXES). Some versions of make
  3809. # do not like variable substitutions on the .SUFFIXES line.
  3810. my @user_suffixes = ($suffixes
  3811. ? $suffixes->value_as_list_recursive : ());
  3812. my %suffixes = map { $_ => 1 } @suffixes;
  3813. delete @suffixes{@user_suffixes};
  3814. $output_header .= (".SUFFIXES: "
  3815. . join (' ', @user_suffixes, sort keys %suffixes)
  3816. . "\n");
  3817. }
  3818. $output_trailer .= file_contents ('footer', new Automake::Location);
  3819. }
  3820. # Generate 'make install' rules.
  3821. sub handle_install ()
  3822. {
  3823. $output_rules .= file_contents
  3824. ('install',
  3825. new Automake::Location,
  3826. maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES')
  3827. ? (" \$(BUILT_SOURCES)\n"
  3828. . "\t\$(MAKE) \$(AM_MAKEFLAGS)")
  3829. : ''),
  3830. 'installdirs-local' => (user_phony_rule ('installdirs-local')
  3831. ? ' installdirs-local' : ''),
  3832. am__installdirs => variable_value ('am__installdirs') || '');
  3833. }
  3834. # handle_all ($MAKEFILE)
  3835. #-----------------------
  3836. # Deal with 'all' and 'all-am'.
  3837. sub handle_all
  3838. {
  3839. my ($makefile) = @_;
  3840. # Output 'all-am'.
  3841. # Put this at the beginning for the sake of non-GNU makes. This
  3842. # is still wrong if these makes can run parallel jobs. But it is
  3843. # right enough.
  3844. unshift (@all, basename ($makefile));
  3845. foreach my $spec (@config_headers)
  3846. {
  3847. my ($out, @ins) = split_config_file_spec ($spec);
  3848. push (@all, basename ($out))
  3849. if dirname ($out) eq $relative_dir;
  3850. }
  3851. # Install 'all' hooks.
  3852. push (@all, "all-local")
  3853. if user_phony_rule "all-local";
  3854. pretty_print_rule ("all-am:", "\t\t", @all);
  3855. depend ('.PHONY', 'all-am', 'all');
  3856. # Output 'all'.
  3857. my @local_headers = ();
  3858. push @local_headers, '$(BUILT_SOURCES)'
  3859. if var ('BUILT_SOURCES');
  3860. foreach my $spec (@config_headers)
  3861. {
  3862. my ($out, @ins) = split_config_file_spec ($spec);
  3863. push @local_headers, basename ($out)
  3864. if dirname ($out) eq $relative_dir;
  3865. }
  3866. if (@local_headers)
  3867. {
  3868. # We need to make sure config.h is built before we recurse.
  3869. # We also want to make sure that built sources are built
  3870. # before any ordinary 'all' targets are run. We can't do this
  3871. # by changing the order of dependencies to the "all" because
  3872. # that breaks when using parallel makes. Instead we handle
  3873. # things explicitly.
  3874. $output_all .= ("all: @local_headers"
  3875. . "\n\t"
  3876. . '$(MAKE) $(AM_MAKEFLAGS) '
  3877. . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
  3878. . "\n\n");
  3879. depend ('.MAKE', 'all');
  3880. }
  3881. else
  3882. {
  3883. $output_all .= "all: " . (var ('SUBDIRS')
  3884. ? 'all-recursive' : 'all-am') . "\n\n";
  3885. }
  3886. }
  3887. # Generate helper targets for user-defined recursive targets, where needed.
  3888. sub handle_user_recursion ()
  3889. {
  3890. return unless @extra_recursive_targets;
  3891. define_pretty_variable ('am__extra_recursive_targets', TRUE, INTERNAL,
  3892. map { "$_-recursive" } @extra_recursive_targets);
  3893. my $aux = var ('SUBDIRS') ? 'recursive' : 'am';
  3894. foreach my $target (@extra_recursive_targets)
  3895. {
  3896. # This allows the default target's rules to be overridden in
  3897. # Makefile.am.
  3898. user_phony_rule ($target);
  3899. depend ("$target", "$target-$aux");
  3900. depend ("$target-am", "$target-local");
  3901. # Every user-defined recursive target 'foo' *must* have a valid
  3902. # associated 'foo-local' rule; we define it as an empty rule by
  3903. # default, so that the user can transparently extend it in his
  3904. # own Makefile.am.
  3905. pretty_print_rule ("$target-local:", '', '');
  3906. # $target-recursive might as well be undefined, so do not add
  3907. # it here; it's taken care of in subdirs.am anyway.
  3908. depend (".PHONY", "$target-am", "$target-local");
  3909. }
  3910. }
  3911. # Handle check merge target specially.
  3912. sub do_check_merge_target ()
  3913. {
  3914. # Include user-defined local form of target.
  3915. push @check_tests, 'check-local'
  3916. if user_phony_rule 'check-local';
  3917. # The check target must depend on the local equivalent of
  3918. # 'all', to ensure all the primary targets are built. Then it
  3919. # must build the local check rules.
  3920. $output_rules .= "check-am: all-am\n";
  3921. if (@check)
  3922. {
  3923. pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @check);
  3924. depend ('.MAKE', 'check-am');
  3925. }
  3926. if (@check_tests)
  3927. {
  3928. pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
  3929. @check_tests);
  3930. depend ('.MAKE', 'check-am');
  3931. }
  3932. depend '.PHONY', 'check', 'check-am';
  3933. # Handle recursion. We have to honor BUILT_SOURCES like for 'all:'.
  3934. $output_rules .= ("check: "
  3935. . (var ('BUILT_SOURCES')
  3936. ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
  3937. : '')
  3938. . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
  3939. . "\n");
  3940. depend ('.MAKE', 'check')
  3941. if var ('BUILT_SOURCES');
  3942. }
  3943. # Handle all 'clean' targets.
  3944. sub handle_clean
  3945. {
  3946. my ($makefile) = @_;
  3947. # Clean the files listed in user variables if they exist.
  3948. $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
  3949. if var ('MOSTLYCLEANFILES');
  3950. $clean_files{'$(CLEANFILES)'} = CLEAN
  3951. if var ('CLEANFILES');
  3952. $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
  3953. if var ('DISTCLEANFILES');
  3954. $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
  3955. if var ('MAINTAINERCLEANFILES');
  3956. # Built sources are automatically removed by maintainer-clean.
  3957. $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
  3958. if var ('BUILT_SOURCES');
  3959. # Compute a list of "rm"s to run for each target.
  3960. my %rms = (MOSTLY_CLEAN, [],
  3961. CLEAN, [],
  3962. DIST_CLEAN, [],
  3963. MAINTAINER_CLEAN, []);
  3964. foreach my $file (keys %clean_files)
  3965. {
  3966. my $when = $clean_files{$file};
  3967. prog_error 'invalid entry in %clean_files'
  3968. unless exists $rms{$when};
  3969. my $rm = "rm -f $file";
  3970. # If file is a variable, make sure when don't call 'rm -f' without args.
  3971. $rm ="test -z \"$file\" || $rm"
  3972. if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
  3973. push @{$rms{$when}}, "\t-$rm\n";
  3974. }
  3975. $output_rules .= file_contents
  3976. ('clean',
  3977. new Automake::Location,
  3978. MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}),
  3979. CLEAN_RMS => join ('', sort @{$rms{&CLEAN}}),
  3980. DISTCLEAN_RMS => join ('', sort @{$rms{&DIST_CLEAN}}),
  3981. MAINTAINER_CLEAN_RMS => join ('', sort @{$rms{&MAINTAINER_CLEAN}}),
  3982. MAKEFILE => basename $makefile,
  3983. );
  3984. }
  3985. # Subroutine for handle_factored_dependencies() to let '.PHONY' and
  3986. # other '.TARGETS' be last. This is meant to be used as a comparison
  3987. # subroutine passed to the sort built-int.
  3988. sub target_cmp
  3989. {
  3990. return 0 if $a eq $b;
  3991. my $a1 = substr ($a, 0, 1);
  3992. my $b1 = substr ($b, 0, 1);
  3993. if ($a1 ne $b1)
  3994. {
  3995. return -1 if $b1 eq '.';
  3996. return 1 if $a1 eq '.';
  3997. }
  3998. return $a cmp $b;
  3999. }
  4000. # Handle everything related to gathered targets.
  4001. sub handle_factored_dependencies ()
  4002. {
  4003. # Reject bad hooks.
  4004. foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
  4005. 'uninstall-exec-local', 'uninstall-exec-hook',
  4006. 'uninstall-dvi-local',
  4007. 'uninstall-html-local',
  4008. 'uninstall-info-local',
  4009. 'uninstall-pdf-local',
  4010. 'uninstall-ps-local')
  4011. {
  4012. my $x = $utarg;
  4013. $x =~ s/-.*-/-/;
  4014. reject_rule ($utarg, "use '$x', not '$utarg'");
  4015. }
  4016. reject_rule ('install-local',
  4017. "use 'install-data-local' or 'install-exec-local', "
  4018. . "not 'install-local'");
  4019. reject_rule ('install-hook',
  4020. "use 'install-data-hook' or 'install-exec-hook', "
  4021. . "not 'install-hook'");
  4022. # Install the -local hooks.
  4023. foreach (keys %dependencies)
  4024. {
  4025. # Hooks are installed on the -am targets.
  4026. s/-am$// or next;
  4027. depend ("$_-am", "$_-local")
  4028. if user_phony_rule "$_-local";
  4029. }
  4030. # Install the -hook hooks.
  4031. # FIXME: Why not be as liberal as we are with -local hooks?
  4032. foreach ('install-exec', 'install-data', 'uninstall')
  4033. {
  4034. if (user_phony_rule "$_-hook")
  4035. {
  4036. depend ('.MAKE', "$_-am");
  4037. register_action("$_-am",
  4038. ("\t\@\$(NORMAL_INSTALL)\n"
  4039. . "\t\$(MAKE) \$(AM_MAKEFLAGS) $_-hook"));
  4040. }
  4041. }
  4042. # All the required targets are phony.
  4043. depend ('.PHONY', keys %required_targets);
  4044. # Actually output gathered targets.
  4045. foreach (sort target_cmp keys %dependencies)
  4046. {
  4047. # If there is nothing about this guy, skip it.
  4048. next
  4049. unless (@{$dependencies{$_}}
  4050. || $actions{$_}
  4051. || $required_targets{$_});
  4052. # Define gathered targets in undefined conditions.
  4053. # FIXME: Right now we must handle .PHONY as an exception,
  4054. # because people write things like
  4055. # .PHONY: myphonytarget
  4056. # to append dependencies. This would not work if Automake
  4057. # refrained from defining its own .PHONY target as it does
  4058. # with other overridden targets.
  4059. # Likewise for '.MAKE' and '.PRECIOUS'.
  4060. my @undefined_conds = (TRUE,);
  4061. if ($_ ne '.PHONY' && $_ ne '.MAKE' && $_ ne '.PRECIOUS')
  4062. {
  4063. @undefined_conds =
  4064. Automake::Rule::define ($_, 'internal',
  4065. RULE_AUTOMAKE, TRUE, INTERNAL);
  4066. }
  4067. my @uniq_deps = uniq (sort @{$dependencies{$_}});
  4068. foreach my $cond (@undefined_conds)
  4069. {
  4070. my $condstr = $cond->subst_string;
  4071. pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
  4072. $output_rules .= $actions{$_} if defined $actions{$_};
  4073. $output_rules .= "\n";
  4074. }
  4075. }
  4076. }
  4077. sub handle_tests_dejagnu ()
  4078. {
  4079. push (@check_tests, 'check-DEJAGNU');
  4080. $output_rules .= file_contents ('dejagnu', new Automake::Location);
  4081. }
  4082. # handle_per_suffix_test ($TEST_SUFFIX, [%TRANSFORM])
  4083. #----------------------------------------------------
  4084. sub handle_per_suffix_test
  4085. {
  4086. my ($test_suffix, %transform) = @_;
  4087. my ($pfx, $generic, $am_exeext);
  4088. if ($test_suffix eq '')
  4089. {
  4090. $pfx = '';
  4091. $generic = 0;
  4092. $am_exeext = 'FALSE';
  4093. }
  4094. else
  4095. {
  4096. prog_error ("test suffix '$test_suffix' lacks leading dot")
  4097. unless $test_suffix =~ m/^\.(.*)/;
  4098. $pfx = uc ($1) . '_';
  4099. $generic = 1;
  4100. $am_exeext = exists $configure_vars{'EXEEXT'} ? 'am__EXEEXT'
  4101. : 'FALSE';
  4102. }
  4103. # The "test driver" program, deputed to handle tests protocol used by
  4104. # test scripts. By default, it's assumed that no protocol is used, so
  4105. # we fall back to the old behaviour, implemented by the 'test-driver'
  4106. # auxiliary script.
  4107. if (! var "${pfx}LOG_DRIVER")
  4108. {
  4109. require_conf_file ("parallel-tests", FOREIGN, 'test-driver');
  4110. define_variable ("${pfx}LOG_DRIVER",
  4111. "\$(SHELL) $am_config_aux_dir/test-driver",
  4112. INTERNAL);
  4113. }
  4114. my $driver = '$(' . $pfx . 'LOG_DRIVER)';
  4115. my $driver_flags = '$(AM_' . $pfx . 'LOG_DRIVER_FLAGS)'
  4116. . ' $(' . $pfx . 'LOG_DRIVER_FLAGS)';
  4117. my $compile = "${pfx}LOG_COMPILE";
  4118. define_variable ($compile,
  4119. '$(' . $pfx . 'LOG_COMPILER)'
  4120. . ' $(AM_' . $pfx . 'LOG_FLAGS)'
  4121. . ' $(' . $pfx . 'LOG_FLAGS)',
  4122. INTERNAL);
  4123. $output_rules .= file_contents ('check2', new Automake::Location,
  4124. GENERIC => $generic,
  4125. DRIVER => $driver,
  4126. DRIVER_FLAGS => $driver_flags,
  4127. COMPILE => '$(' . $compile . ')',
  4128. EXT => $test_suffix,
  4129. am__EXEEXT => $am_exeext,
  4130. %transform);
  4131. }
  4132. # is_valid_test_extension ($EXT)
  4133. # ------------------------------
  4134. # Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
  4135. # otherwise.
  4136. sub is_valid_test_extension
  4137. {
  4138. my $ext = shift;
  4139. return 1
  4140. if ($ext =~ /^\.[a-zA-Z_][a-zA-Z0-9_]*$/);
  4141. return 1
  4142. if (exists $configure_vars{'EXEEXT'} && $ext eq subst ('EXEEXT'));
  4143. return 0;
  4144. }
  4145. sub handle_tests ()
  4146. {
  4147. if (option 'dejagnu')
  4148. {
  4149. handle_tests_dejagnu;
  4150. }
  4151. else
  4152. {
  4153. foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
  4154. {
  4155. reject_var ($c, "'$c' defined but 'dejagnu' not in "
  4156. . "'AUTOMAKE_OPTIONS'");
  4157. }
  4158. }
  4159. if (var ('TESTS'))
  4160. {
  4161. push (@check_tests, 'check-TESTS');
  4162. my $check_deps = "@check";
  4163. $output_rules .= file_contents ('check', new Automake::Location,
  4164. SERIAL_TESTS => !! option 'serial-tests',
  4165. CHECK_DEPS => $check_deps);
  4166. # Tests that are known programs should have $(EXEEXT) appended.
  4167. # For matching purposes, we need to adjust XFAIL_TESTS as well.
  4168. append_exeext { exists $known_programs{$_[0]} } 'TESTS';
  4169. append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS'
  4170. if (var ('XFAIL_TESTS'));
  4171. if (! option 'serial-tests')
  4172. {
  4173. define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL);
  4174. my $suff = '.test';
  4175. my $at_exeext = '';
  4176. my $handle_exeext = exists $configure_vars{'EXEEXT'};
  4177. if ($handle_exeext)
  4178. {
  4179. $at_exeext = subst ('EXEEXT');
  4180. $suff = $at_exeext . ' ' . $suff;
  4181. }
  4182. if (! var 'TEST_EXTENSIONS')
  4183. {
  4184. define_variable ('TEST_EXTENSIONS', $suff, INTERNAL);
  4185. }
  4186. my $var = var 'TEST_EXTENSIONS';
  4187. # Currently, we are not able to deal with conditional contents
  4188. # in TEST_EXTENSIONS.
  4189. if ($var->has_conditional_contents)
  4190. {
  4191. msg_var 'unsupported', $var,
  4192. "'TEST_EXTENSIONS' cannot have conditional contents";
  4193. }
  4194. my @test_suffixes = $var->value_as_list_recursive;
  4195. if ((my @invalid_test_suffixes =
  4196. grep { !is_valid_test_extension $_ } @test_suffixes) > 0)
  4197. {
  4198. error $var->rdef (TRUE)->location,
  4199. "invalid test extensions: @invalid_test_suffixes";
  4200. }
  4201. @test_suffixes = grep { is_valid_test_extension $_ } @test_suffixes;
  4202. if ($handle_exeext)
  4203. {
  4204. unshift (@test_suffixes, $at_exeext)
  4205. unless $test_suffixes[0] eq $at_exeext;
  4206. }
  4207. unshift (@test_suffixes, '');
  4208. transform_variable_recursively
  4209. ('TESTS', 'TEST_LOGS', 'am__testlogs', 1, INTERNAL,
  4210. sub {
  4211. my ($subvar, $val, $cond, $full_cond) = @_;
  4212. my $obj = $val;
  4213. return $obj
  4214. if $val =~ /^\@.*\@$/;
  4215. $obj =~ s/\$\(EXEEXT\)$//o;
  4216. if ($val =~ /(\$\((top_)?srcdir\))\//o)
  4217. {
  4218. msg ('error', $subvar->rdef ($cond)->location,
  4219. "using '$1' in TESTS is currently broken: '$val'");
  4220. }
  4221. foreach my $test_suffix (@test_suffixes)
  4222. {
  4223. next
  4224. if $test_suffix eq $at_exeext || $test_suffix eq '';
  4225. return substr ($obj, 0, length ($obj) - length ($test_suffix)) . '.log'
  4226. if substr ($obj, - length ($test_suffix)) eq $test_suffix;
  4227. }
  4228. my $base = $obj;
  4229. $obj .= '.log';
  4230. handle_per_suffix_test ('',
  4231. OBJ => $obj,
  4232. BASE => $base,
  4233. SOURCE => $val);
  4234. return $obj;
  4235. });
  4236. my $nhelper=1;
  4237. my $prev = 'TESTS';
  4238. my $post = '';
  4239. my $last_suffix = $test_suffixes[$#test_suffixes];
  4240. my $cur = '';
  4241. foreach my $test_suffix (@test_suffixes)
  4242. {
  4243. if ($test_suffix eq $last_suffix)
  4244. {
  4245. $cur = 'TEST_LOGS';
  4246. }
  4247. else
  4248. {
  4249. $cur = 'am__test_logs' . $nhelper;
  4250. }
  4251. define_variable ($cur,
  4252. '$(' . $prev . ':' . $test_suffix . $post . '=.log)', INTERNAL);
  4253. $post = '.log';
  4254. $prev = $cur;
  4255. $nhelper++;
  4256. if ($test_suffix ne $at_exeext && $test_suffix ne '')
  4257. {
  4258. handle_per_suffix_test ($test_suffix,
  4259. OBJ => '',
  4260. BASE => '$*',
  4261. SOURCE => '$<');
  4262. }
  4263. }
  4264. $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN;
  4265. $clean_files{'$(TEST_LOGS:.log=.trs)'} = MOSTLY_CLEAN;
  4266. $clean_files{'$(TEST_SUITE_LOG)'} = MOSTLY_CLEAN;
  4267. }
  4268. }
  4269. }
  4270. sub handle_emacs_lisp ()
  4271. {
  4272. my @elfiles = am_install_var ('-candist', 'lisp', 'LISP',
  4273. 'lisp', 'noinst');
  4274. return if ! @elfiles;
  4275. define_pretty_variable ('am__ELFILES', TRUE, INTERNAL,
  4276. map { $_->[1] } @elfiles);
  4277. define_pretty_variable ('am__ELCFILES', TRUE, INTERNAL,
  4278. '$(am__ELFILES:.el=.elc)');
  4279. # This one can be overridden by users.
  4280. define_pretty_variable ('ELCFILES', TRUE, INTERNAL, '$(LISP:.el=.elc)');
  4281. push @all, '$(ELCFILES)';
  4282. require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE,
  4283. 'EMACS', 'lispdir');
  4284. }
  4285. sub handle_python ()
  4286. {
  4287. my @pyfiles = am_install_var ('-defaultdist', 'python', 'PYTHON',
  4288. 'noinst');
  4289. return if ! @pyfiles;
  4290. require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON');
  4291. require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile');
  4292. define_variable ('py_compile', "$am_config_aux_dir/py-compile", INTERNAL);
  4293. }
  4294. sub handle_java ()
  4295. {
  4296. my @sourcelist = am_install_var ('-candist',
  4297. 'java', 'JAVA',
  4298. 'noinst', 'check');
  4299. return if ! @sourcelist;
  4300. my @prefixes = am_primary_prefixes ('JAVA', 1,
  4301. 'noinst', 'check');
  4302. my $dir;
  4303. my @java_sources = ();
  4304. foreach my $prefix (@prefixes)
  4305. {
  4306. (my $curs = $prefix) =~ s/^(?:nobase_)?(?:dist_|nodist_)?//;
  4307. next
  4308. if $curs eq 'EXTRA';
  4309. push @java_sources, '$(' . $prefix . '_JAVA' . ')';
  4310. if (defined $dir)
  4311. {
  4312. err_var "${curs}_JAVA", "multiple _JAVA primaries in use"
  4313. unless $curs eq $dir;
  4314. }
  4315. $dir = $curs;
  4316. }
  4317. define_pretty_variable ('am__java_sources', TRUE, INTERNAL,
  4318. "@java_sources");
  4319. if ($dir eq 'check')
  4320. {
  4321. push (@check, "class$dir.stamp");
  4322. }
  4323. else
  4324. {
  4325. push (@all, "class$dir.stamp");
  4326. }
  4327. }
  4328. sub handle_minor_options ()
  4329. {
  4330. if (option 'readme-alpha')
  4331. {
  4332. if ($relative_dir eq '.')
  4333. {
  4334. if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
  4335. {
  4336. msg ('error-gnits', $package_version_location,
  4337. "version '$package_version' doesn't follow " .
  4338. "Gnits standards");
  4339. }
  4340. if (defined $1 && -f 'README-alpha')
  4341. {
  4342. # This means we have an alpha release. See
  4343. # GNITS_VERSION_PATTERN for details.
  4344. push_dist_common ('README-alpha');
  4345. }
  4346. }
  4347. }
  4348. }
  4349. ################################################################
  4350. # ($OUTPUT, @INPUTS)
  4351. # split_config_file_spec ($SPEC)
  4352. # ------------------------------
  4353. # Decode the Autoconf syntax for config files (files, headers, links
  4354. # etc.).
  4355. sub split_config_file_spec
  4356. {
  4357. my ($spec) = @_;
  4358. my ($output, @inputs) = split (/:/, $spec);
  4359. push @inputs, "$output.in"
  4360. unless @inputs;
  4361. return ($output, @inputs);
  4362. }
  4363. # $input
  4364. # locate_am (@POSSIBLE_SOURCES)
  4365. # -----------------------------
  4366. # AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
  4367. # This functions returns the first *.in file for which a *.am exists.
  4368. # It returns undef otherwise.
  4369. sub locate_am
  4370. {
  4371. my (@rest) = @_;
  4372. my $input;
  4373. foreach my $file (@rest)
  4374. {
  4375. if (($file =~ /^(.*)\.in$/) && -f "$1.am")
  4376. {
  4377. $input = $file;
  4378. last;
  4379. }
  4380. }
  4381. return $input;
  4382. }
  4383. my %make_list;
  4384. # scan_autoconf_config_files ($WHERE, $CONFIG-FILES)
  4385. # --------------------------------------------------
  4386. # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
  4387. # (or AC_OUTPUT).
  4388. sub scan_autoconf_config_files
  4389. {
  4390. my ($where, $config_files) = @_;
  4391. # Look at potential Makefile.am's.
  4392. foreach (split ' ', $config_files)
  4393. {
  4394. # Must skip empty string for Perl 4.
  4395. next if $_ eq "\\" || $_ eq '';
  4396. # Handle $local:$input syntax.
  4397. my ($local, @rest) = split (/:/);
  4398. @rest = ("$local.in",) unless @rest;
  4399. # Keep in sync with test 'conffile-leading-dot.sh'.
  4400. msg ('unsupported', $where,
  4401. "omit leading './' from config file names such as '$local';"
  4402. . "\nremake rules might be subtly broken otherwise")
  4403. if ($local =~ /^\.\//);
  4404. my $input = locate_am @rest;
  4405. if ($input)
  4406. {
  4407. # We have a file that automake should generate.
  4408. $make_list{$input} = join (':', ($local, @rest));
  4409. }
  4410. else
  4411. {
  4412. # We have a file that automake should cause to be
  4413. # rebuilt, but shouldn't generate itself.
  4414. push (@other_input_files, $_);
  4415. }
  4416. $ac_config_files_location{$local} = $where;
  4417. $ac_config_files_condition{$local} =
  4418. new Automake::Condition (@cond_stack)
  4419. if (@cond_stack);
  4420. }
  4421. }
  4422. sub scan_autoconf_traces
  4423. {
  4424. my ($filename) = @_;
  4425. # Macros to trace, with their minimal number of arguments.
  4426. #
  4427. # IMPORTANT: If you add a macro here, you should also add this macro
  4428. # ========= to Automake-preselection in autoconf/lib/autom4te.in.
  4429. my %traced = (
  4430. AC_CANONICAL_BUILD => 0,
  4431. AC_CANONICAL_HOST => 0,
  4432. AC_CANONICAL_TARGET => 0,
  4433. AC_CONFIG_AUX_DIR => 1,
  4434. AC_CONFIG_FILES => 1,
  4435. AC_CONFIG_HEADERS => 1,
  4436. AC_CONFIG_LIBOBJ_DIR => 1,
  4437. AC_CONFIG_LINKS => 1,
  4438. AC_FC_SRCEXT => 1,
  4439. AC_INIT => 0,
  4440. AC_LIBSOURCE => 1,
  4441. AC_REQUIRE_AUX_FILE => 1,
  4442. AC_SUBST_TRACE => 1,
  4443. AM_AUTOMAKE_VERSION => 1,
  4444. AM_PROG_MKDIR_P => 0,
  4445. AM_CONDITIONAL => 2,
  4446. AM_EXTRA_RECURSIVE_TARGETS => 1,
  4447. AM_GNU_GETTEXT => 0,
  4448. AM_GNU_GETTEXT_INTL_SUBDIR => 0,
  4449. AM_INIT_AUTOMAKE => 0,
  4450. AM_MAINTAINER_MODE => 0,
  4451. AM_PROG_AR => 0,
  4452. _AM_SUBST_NOTMAKE => 1,
  4453. _AM_COND_IF => 1,
  4454. _AM_COND_ELSE => 1,
  4455. _AM_COND_ENDIF => 1,
  4456. LT_SUPPORTED_TAG => 1,
  4457. _LT_AC_TAGCONFIG => 0,
  4458. m4_include => 1,
  4459. m4_sinclude => 1,
  4460. sinclude => 1,
  4461. );
  4462. my $traces = ($ENV{AUTOCONF} || '@am_AUTOCONF@') . " ";
  4463. # Use a separator unlikely to be used, not ':', the default, which
  4464. # has a precise meaning for AC_CONFIG_FILES and so on.
  4465. $traces .= join (' ',
  4466. map { "--trace=$_" . ':\$f:\$l::\$d::\$n::\${::}%' }
  4467. (keys %traced));
  4468. my $tracefh = new Automake::XFile ("$traces $filename |");
  4469. verb "reading $traces";
  4470. @cond_stack = ();
  4471. my $where;
  4472. while ($_ = $tracefh->getline)
  4473. {
  4474. chomp;
  4475. my ($here, $depth, @args) = split (/::/);
  4476. $where = new Automake::Location $here;
  4477. my $macro = $args[0];
  4478. prog_error ("unrequested trace '$macro'")
  4479. unless exists $traced{$macro};
  4480. # Skip and diagnose malformed calls.
  4481. if ($#args < $traced{$macro})
  4482. {
  4483. msg ('syntax', $where, "not enough arguments for $macro");
  4484. next;
  4485. }
  4486. # Alphabetical ordering please.
  4487. if ($macro eq 'AC_CANONICAL_BUILD')
  4488. {
  4489. if ($seen_canonical <= AC_CANONICAL_BUILD)
  4490. {
  4491. $seen_canonical = AC_CANONICAL_BUILD;
  4492. }
  4493. }
  4494. elsif ($macro eq 'AC_CANONICAL_HOST')
  4495. {
  4496. if ($seen_canonical <= AC_CANONICAL_HOST)
  4497. {
  4498. $seen_canonical = AC_CANONICAL_HOST;
  4499. }
  4500. }
  4501. elsif ($macro eq 'AC_CANONICAL_TARGET')
  4502. {
  4503. $seen_canonical = AC_CANONICAL_TARGET;
  4504. }
  4505. elsif ($macro eq 'AC_CONFIG_AUX_DIR')
  4506. {
  4507. if ($seen_init_automake)
  4508. {
  4509. error ($where, "AC_CONFIG_AUX_DIR must be called before "
  4510. . "AM_INIT_AUTOMAKE ...", partial => 1);
  4511. error ($seen_init_automake, "... AM_INIT_AUTOMAKE called here");
  4512. }
  4513. $config_aux_dir = $args[1];
  4514. $config_aux_dir_set_in_configure_ac = 1;
  4515. check_directory ($config_aux_dir, $where);
  4516. }
  4517. elsif ($macro eq 'AC_CONFIG_FILES')
  4518. {
  4519. # Look at potential Makefile.am's.
  4520. scan_autoconf_config_files ($where, $args[1]);
  4521. }
  4522. elsif ($macro eq 'AC_CONFIG_HEADERS')
  4523. {
  4524. foreach my $spec (split (' ', $args[1]))
  4525. {
  4526. my ($dest, @src) = split (':', $spec);
  4527. $ac_config_files_location{$dest} = $where;
  4528. push @config_headers, $spec;
  4529. }
  4530. }
  4531. elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
  4532. {
  4533. $config_libobj_dir = $args[1];
  4534. check_directory ($config_libobj_dir, $where);
  4535. }
  4536. elsif ($macro eq 'AC_CONFIG_LINKS')
  4537. {
  4538. foreach my $spec (split (' ', $args[1]))
  4539. {
  4540. my ($dest, $src) = split (':', $spec);
  4541. $ac_config_files_location{$dest} = $where;
  4542. push @config_links, $spec;
  4543. }
  4544. }
  4545. elsif ($macro eq 'AC_FC_SRCEXT')
  4546. {
  4547. my $suffix = $args[1];
  4548. # These flags are used as %SOURCEFLAG% in depend2.am,
  4549. # where the trailing space is important.
  4550. $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ') '
  4551. if ($suffix eq 'f90' || $suffix eq 'f95' || $suffix eq 'f03' || $suffix eq 'f08');
  4552. }
  4553. elsif ($macro eq 'AC_INIT')
  4554. {
  4555. if (defined $args[2])
  4556. {
  4557. $package_version = $args[2];
  4558. $package_version_location = $where;
  4559. }
  4560. }
  4561. elsif ($macro eq 'AC_LIBSOURCE')
  4562. {
  4563. $libsources{$args[1]} = $here;
  4564. }
  4565. elsif ($macro eq 'AC_REQUIRE_AUX_FILE')
  4566. {
  4567. # Only remember the first time a file is required.
  4568. $required_aux_file{$args[1]} = $where
  4569. unless exists $required_aux_file{$args[1]};
  4570. }
  4571. elsif ($macro eq 'AC_SUBST_TRACE')
  4572. {
  4573. # Just check for alphanumeric in AC_SUBST_TRACE. If you do
  4574. # AC_SUBST(5), then too bad.
  4575. $configure_vars{$args[1]} = $where
  4576. if $args[1] =~ /^\w+$/;
  4577. }
  4578. elsif ($macro eq 'AM_AUTOMAKE_VERSION')
  4579. {
  4580. error ($where,
  4581. "version mismatch. This is Automake $VERSION,\n" .
  4582. "but the definition used by this AM_INIT_AUTOMAKE\n" .
  4583. "comes from Automake $args[1]. You should recreate\n" .
  4584. "aclocal.m4 with aclocal and run automake again.\n",
  4585. # $? = 63 is used to indicate version mismatch to missing.
  4586. exit_code => 63)
  4587. if $VERSION ne $args[1];
  4588. $seen_automake_version = 1;
  4589. }
  4590. elsif ($macro eq 'AM_PROG_MKDIR_P')
  4591. {
  4592. msg 'obsolete', $where, <<'EOF';
  4593. The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
  4594. You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
  4595. and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
  4596. EOF
  4597. }
  4598. elsif ($macro eq 'AM_CONDITIONAL')
  4599. {
  4600. $configure_cond{$args[1]} = $where;
  4601. }
  4602. elsif ($macro eq 'AM_EXTRA_RECURSIVE_TARGETS')
  4603. {
  4604. # Empty leading/trailing fields might be produced by split,
  4605. # hence the grep is really needed.
  4606. push @extra_recursive_targets,
  4607. grep (/./, (split /\s+/, $args[1]));
  4608. }
  4609. elsif ($macro eq 'AM_GNU_GETTEXT')
  4610. {
  4611. $seen_gettext = $where;
  4612. $ac_gettext_location = $where;
  4613. $seen_gettext_external = grep ($_ eq 'external', @args);
  4614. }
  4615. elsif ($macro eq 'AM_GNU_GETTEXT_INTL_SUBDIR')
  4616. {
  4617. $seen_gettext_intl = $where;
  4618. }
  4619. elsif ($macro eq 'AM_INIT_AUTOMAKE')
  4620. {
  4621. $seen_init_automake = $where;
  4622. if (defined $args[2])
  4623. {
  4624. msg 'obsolete', $where, <<'EOF';
  4625. AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
  4626. http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
  4627. EOF
  4628. $package_version = $args[2];
  4629. $package_version_location = $where;
  4630. }
  4631. elsif (defined $args[1])
  4632. {
  4633. my @opts = split (' ', $args[1]);
  4634. @opts = map { { option => $_, where => $where } } @opts;
  4635. exit $exit_code unless process_global_option_list (@opts);
  4636. }
  4637. }
  4638. elsif ($macro eq 'AM_MAINTAINER_MODE')
  4639. {
  4640. $seen_maint_mode = $where;
  4641. }
  4642. elsif ($macro eq 'AM_PROG_AR')
  4643. {
  4644. $seen_ar = $where;
  4645. }
  4646. elsif ($macro eq '_AM_COND_IF')
  4647. {
  4648. cond_stack_if ('', $args[1], $where);
  4649. error ($where, "missing m4 quoting, macro depth $depth")
  4650. if ($depth != 1);
  4651. }
  4652. elsif ($macro eq '_AM_COND_ELSE')
  4653. {
  4654. cond_stack_else ('!', $args[1], $where);
  4655. error ($where, "missing m4 quoting, macro depth $depth")
  4656. if ($depth != 1);
  4657. }
  4658. elsif ($macro eq '_AM_COND_ENDIF')
  4659. {
  4660. cond_stack_endif (undef, undef, $where);
  4661. error ($where, "missing m4 quoting, macro depth $depth")
  4662. if ($depth != 1);
  4663. }
  4664. elsif ($macro eq '_AM_SUBST_NOTMAKE')
  4665. {
  4666. $ignored_configure_vars{$args[1]} = $where;
  4667. }
  4668. elsif ($macro eq 'm4_include'
  4669. || $macro eq 'm4_sinclude'
  4670. || $macro eq 'sinclude')
  4671. {
  4672. # Skip missing 'sinclude'd files.
  4673. next if $macro ne 'm4_include' && ! -f $args[1];
  4674. # Some modified versions of Autoconf don't use
  4675. # frozen files. Consequently it's possible that we see all
  4676. # m4_include's performed during Autoconf's startup.
  4677. # Obviously we don't want to distribute Autoconf's files
  4678. # so we skip absolute filenames here.
  4679. push @configure_deps, '$(top_srcdir)/' . $args[1]
  4680. unless $here =~ m,^(?:\w:)?[\\/],;
  4681. # Keep track of the greatest timestamp.
  4682. if (-e $args[1])
  4683. {
  4684. my $mtime = mtime $args[1];
  4685. $configure_deps_greatest_timestamp = $mtime
  4686. if $mtime > $configure_deps_greatest_timestamp;
  4687. }
  4688. }
  4689. elsif ($macro eq 'LT_SUPPORTED_TAG')
  4690. {
  4691. $libtool_tags{$args[1]} = 1;
  4692. $libtool_new_api = 1;
  4693. }
  4694. elsif ($macro eq '_LT_AC_TAGCONFIG')
  4695. {
  4696. # _LT_AC_TAGCONFIG is an old macro present in Libtool 1.5.
  4697. # We use it to detect whether tags are supported. Our
  4698. # preferred interface is LT_SUPPORTED_TAG, but it was
  4699. # introduced in Libtool 1.6.
  4700. if (0 == keys %libtool_tags)
  4701. {
  4702. # Hardcode the tags supported by Libtool 1.5.
  4703. %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
  4704. }
  4705. }
  4706. }
  4707. error ($where, "condition stack not properly closed")
  4708. if (@cond_stack);
  4709. $tracefh->close;
  4710. }
  4711. # Check whether we use 'configure.ac' or 'configure.in'.
  4712. # Scan it (and possibly 'aclocal.m4') for interesting things.
  4713. # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
  4714. sub scan_autoconf_files ()
  4715. {
  4716. # Reinitialize libsources here. This isn't really necessary,
  4717. # since we currently assume there is only one configure.ac. But
  4718. # that won't always be the case.
  4719. %libsources = ();
  4720. # Keep track of the youngest configure dependency.
  4721. $configure_deps_greatest_timestamp = mtime $configure_ac;
  4722. if (-e 'aclocal.m4')
  4723. {
  4724. my $mtime = mtime 'aclocal.m4';
  4725. $configure_deps_greatest_timestamp = $mtime
  4726. if $mtime > $configure_deps_greatest_timestamp;
  4727. }
  4728. scan_autoconf_traces ($configure_ac);
  4729. @configure_input_files = sort keys %make_list;
  4730. # Set input and output files if not specified by user.
  4731. if (! @input_files)
  4732. {
  4733. @input_files = @configure_input_files;
  4734. %output_files = %make_list;
  4735. }
  4736. if (! $seen_init_automake)
  4737. {
  4738. err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
  4739. . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
  4740. . "\nthat aclocal.m4 is present in the top-level directory,\n"
  4741. . "and that aclocal.m4 was recently regenerated "
  4742. . "(using aclocal)");
  4743. }
  4744. else
  4745. {
  4746. if (! $seen_automake_version)
  4747. {
  4748. if (-f 'aclocal.m4')
  4749. {
  4750. error ($seen_init_automake,
  4751. "your implementation of AM_INIT_AUTOMAKE comes from " .
  4752. "an\nold Automake version. You should recreate " .
  4753. "aclocal.m4\nwith aclocal and run automake again",
  4754. # $? = 63 is used to indicate version mismatch to missing.
  4755. exit_code => 63);
  4756. }
  4757. else
  4758. {
  4759. error ($seen_init_automake,
  4760. "no proper implementation of AM_INIT_AUTOMAKE was " .
  4761. "found,\nprobably because aclocal.m4 is missing.\n" .
  4762. "You should run aclocal to create this file, then\n" .
  4763. "run automake again");
  4764. }
  4765. }
  4766. }
  4767. locate_aux_dir ();
  4768. # Look for some files we need. Always check for these. This
  4769. # check must be done for every run, even those where we are only
  4770. # looking at a subdir Makefile. We must set relative_dir for
  4771. # push_required_file to work.
  4772. # Sort the files for stable verbose output.
  4773. $relative_dir = '.';
  4774. foreach my $file (sort keys %required_aux_file)
  4775. {
  4776. require_conf_file ($required_aux_file{$file}->get, FOREIGN, $file)
  4777. }
  4778. err_am "'install.sh' is an anachronism; use 'install-sh' instead"
  4779. if -f $config_aux_dir . '/install.sh';
  4780. # Preserve dist_common for later.
  4781. @configure_dist_common = @dist_common;
  4782. }
  4783. ################################################################
  4784. # Do any extra checking for GNU standards.
  4785. sub check_gnu_standards ()
  4786. {
  4787. if ($relative_dir eq '.')
  4788. {
  4789. # In top level (or only) directory.
  4790. require_file ("$am_file.am", GNU,
  4791. qw/INSTALL NEWS README AUTHORS ChangeLog/);
  4792. # Accept one of these three licenses; default to COPYING.
  4793. # Make sure we do not overwrite an existing license.
  4794. my $license;
  4795. foreach (qw /COPYING COPYING.LIB COPYING.LESSER/)
  4796. {
  4797. if (-f $_)
  4798. {
  4799. $license = $_;
  4800. last;
  4801. }
  4802. }
  4803. require_file ("$am_file.am", GNU, 'COPYING')
  4804. unless $license;
  4805. }
  4806. for my $opt ('no-installman', 'no-installinfo')
  4807. {
  4808. msg ('error-gnu', option $opt,
  4809. "option '$opt' disallowed by GNU standards")
  4810. if option $opt;
  4811. }
  4812. }
  4813. # Do any extra checking for GNITS standards.
  4814. sub check_gnits_standards ()
  4815. {
  4816. if ($relative_dir eq '.')
  4817. {
  4818. # In top level (or only) directory.
  4819. require_file ("$am_file.am", GNITS, 'THANKS');
  4820. }
  4821. }
  4822. ################################################################
  4823. #
  4824. # Functions to handle files of each language.
  4825. # Each 'lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
  4826. # simple formula: Return value is LANG_SUBDIR if the resulting object
  4827. # file should be in a subdir if the source file is, LANG_PROCESS if
  4828. # file is to be dealt with, LANG_IGNORE otherwise.
  4829. # Much of the actual processing is handled in
  4830. # handle_single_transform. These functions exist so that
  4831. # auxiliary information can be recorded for a later cleanup pass.
  4832. # Note that the calls to these functions are computed, so don't bother
  4833. # searching for their precise names in the source.
  4834. # This is just a convenience function that can be used to determine
  4835. # when a subdir object should be used.
  4836. sub lang_sub_obj ()
  4837. {
  4838. return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
  4839. }
  4840. # Rewrite a single header file.
  4841. sub lang_header_rewrite
  4842. {
  4843. # Header files are simply ignored.
  4844. return LANG_IGNORE;
  4845. }
  4846. # Rewrite a single Vala source file.
  4847. sub lang_vala_rewrite
  4848. {
  4849. my ($directory, $base, $ext) = @_;
  4850. (my $newext = $ext) =~ s/vala$/c/;
  4851. return (LANG_SUBDIR, $newext);
  4852. }
  4853. # Rewrite a single yacc/yacc++ file.
  4854. sub lang_yacc_rewrite
  4855. {
  4856. my ($directory, $base, $ext) = @_;
  4857. my $r = lang_sub_obj;
  4858. (my $newext = $ext) =~ tr/y/c/;
  4859. return ($r, $newext);
  4860. }
  4861. sub lang_yaccxx_rewrite { lang_yacc_rewrite (@_); };
  4862. # Rewrite a single lex/lex++ file.
  4863. sub lang_lex_rewrite
  4864. {
  4865. my ($directory, $base, $ext) = @_;
  4866. my $r = lang_sub_obj;
  4867. (my $newext = $ext) =~ tr/l/c/;
  4868. return ($r, $newext);
  4869. }
  4870. sub lang_lexxx_rewrite { lang_lex_rewrite (@_); };
  4871. # Rewrite a single Java file.
  4872. sub lang_java_rewrite
  4873. {
  4874. return LANG_SUBDIR;
  4875. }
  4876. # The lang_X_finish functions are called after all source file
  4877. # processing is done. Each should handle defining rules for the
  4878. # language, etc. A finish function is only called if a source file of
  4879. # the appropriate type has been seen.
  4880. sub lang_vala_finish_target
  4881. {
  4882. my ($self, $name) = @_;
  4883. my $derived = canonicalize ($name);
  4884. my $var = var "${derived}_SOURCES";
  4885. return unless $var;
  4886. my @vala_sources = grep { /\.(vala|vapi)$/ } ($var->value_as_list_recursive);
  4887. # For automake bug#11229.
  4888. return unless @vala_sources;
  4889. foreach my $vala_file (@vala_sources)
  4890. {
  4891. my $c_file = $vala_file;
  4892. if ($c_file =~ s/(.*)\.vala$/$1.c/)
  4893. {
  4894. $c_file = "\$(srcdir)/$c_file";
  4895. $output_rules .= "$c_file: \$(srcdir)/${derived}_vala.stamp\n"
  4896. . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n"
  4897. . "\t\@if test -f \$@; then :; else \\\n"
  4898. . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(srcdir)/${derived}_vala.stamp; \\\n"
  4899. . "\tfi\n";
  4900. $clean_files{$c_file} = MAINTAINER_CLEAN;
  4901. }
  4902. }
  4903. # Add rebuild rules for generated header and vapi files
  4904. my $flags = var ($derived . '_VALAFLAGS');
  4905. if ($flags)
  4906. {
  4907. my $lastflag = '';
  4908. foreach my $flag ($flags->value_as_list_recursive)
  4909. {
  4910. if (grep (/$lastflag/, ('-H', '-h', '--header', '--internal-header',
  4911. '--vapi', '--internal-vapi', '--gir')))
  4912. {
  4913. my $headerfile = "\$(srcdir)/$flag";
  4914. $output_rules .= "$headerfile: \$(srcdir)/${derived}_vala.stamp\n"
  4915. . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n"
  4916. . "\t\@if test -f \$@; then :; else \\\n"
  4917. . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(srcdir)/${derived}_vala.stamp; \\\n"
  4918. . "\tfi\n";
  4919. # valac is not used when building from dist tarballs
  4920. # distribute the generated files
  4921. push_dist_common ($headerfile);
  4922. $clean_files{$headerfile} = MAINTAINER_CLEAN;
  4923. }
  4924. $lastflag = $flag;
  4925. }
  4926. }
  4927. my $compile = $self->compile;
  4928. # Rewrite each occurrence of 'AM_VALAFLAGS' in the compile
  4929. # rule into '${derived}_VALAFLAGS' if it exists.
  4930. my $val = "${derived}_VALAFLAGS";
  4931. $compile =~ s/\(AM_VALAFLAGS\)/\($val\)/
  4932. if set_seen ($val);
  4933. # VALAFLAGS is a user variable (per GNU Standards),
  4934. # it should not be overridden in the Makefile...
  4935. check_user_variables 'VALAFLAGS';
  4936. my $dirname = dirname ($name);
  4937. # Only generate C code, do not run C compiler
  4938. $compile .= " -C";
  4939. my $verbose = verbose_flag ('VALAC');
  4940. my $silent = silent_flag ();
  4941. my $stampfile = "\$(srcdir)/${derived}_vala.stamp";
  4942. $output_rules .=
  4943. "\$(srcdir)/${derived}_vala.stamp: @vala_sources\n".
  4944. # Since the C files generated from the vala sources depend on the
  4945. # ${derived}_vala.stamp file, we must ensure its timestamp is older than
  4946. # those of the C files generated by the valac invocation below (this is
  4947. # especially important on systems with sub-second timestamp resolution).
  4948. # Thus we need to create the stamp file *before* invoking valac, and to
  4949. # move it to its final location only after valac has been invoked.
  4950. "\t${silent}rm -f \$\@ && echo stamp > \$\@-t\n".
  4951. "\t${verbose}\$(am__cd) \$(srcdir) && $compile @vala_sources\n".
  4952. "\t${silent}mv -f \$\@-t \$\@\n";
  4953. push_dist_common ($stampfile);
  4954. $clean_files{$stampfile} = MAINTAINER_CLEAN;
  4955. }
  4956. # Add output rules to invoke valac and create stamp file as a witness
  4957. # to handle multiple outputs. This function is called after all source
  4958. # file processing is done.
  4959. sub lang_vala_finish ()
  4960. {
  4961. my ($self) = @_;
  4962. foreach my $prog (keys %known_programs)
  4963. {
  4964. lang_vala_finish_target ($self, $prog);
  4965. }
  4966. while (my ($name) = each %known_libraries)
  4967. {
  4968. lang_vala_finish_target ($self, $name);
  4969. }
  4970. }
  4971. # The built .c files should be cleaned only on maintainer-clean
  4972. # as the .c files are distributed. This function is called for each
  4973. # .vala source file.
  4974. sub lang_vala_target_hook
  4975. {
  4976. my ($self, $aggregate, $output, $input, %transform) = @_;
  4977. $clean_files{$output} = MAINTAINER_CLEAN;
  4978. }
  4979. # This is a yacc helper which is called whenever we have decided to
  4980. # compile a yacc file.
  4981. sub lang_yacc_target_hook
  4982. {
  4983. my ($self, $aggregate, $output, $input, %transform) = @_;
  4984. # If some relevant *YFLAGS variable contains the '-d' flag, we'll
  4985. # have to to generate special code.
  4986. my $yflags_contains_minus_d = 0;
  4987. foreach my $pfx ("", "${aggregate}_")
  4988. {
  4989. my $yflagsvar = var ("${pfx}YFLAGS");
  4990. next unless $yflagsvar;
  4991. # We cannot work reliably with conditionally-defined YFLAGS.
  4992. if ($yflagsvar->has_conditional_contents)
  4993. {
  4994. msg_var ('unsupported', $yflagsvar,
  4995. "'${pfx}YFLAGS' cannot have conditional contents");
  4996. }
  4997. else
  4998. {
  4999. $yflags_contains_minus_d = 1
  5000. if grep (/^-d$/, $yflagsvar->value_as_list_recursive);
  5001. }
  5002. }
  5003. if ($yflags_contains_minus_d)
  5004. {
  5005. # Found a '-d' that applies to the compilation of this file.
  5006. # Add a dependency for the generated header file, and arrange
  5007. # for that file to be included in the distribution.
  5008. # The extension of the output file (e.g., '.c' or '.cxx').
  5009. # We'll need it to compute the name of the generated header file.
  5010. (my $output_ext = basename ($output)) =~ s/.*(\.[^.]+)$/$1/;
  5011. # We know that a yacc input should be turned into either a C or
  5012. # C++ output file. We depend on this fact (here and in yacc.am),
  5013. # so check that it really holds.
  5014. my $lang = $languages{$extension_map{$output_ext}};
  5015. prog_error "invalid output name '$output' for yacc file '$input'"
  5016. if (!$lang || ($lang->name ne 'c' && $lang->name ne 'cxx'));
  5017. (my $header_ext = $output_ext) =~ s/c/h/g;
  5018. # Quote $output_ext in the regexp, so that dots in it are taken
  5019. # as literal dots, not as metacharacters.
  5020. (my $header = $output) =~ s/\Q$output_ext\E$/$header_ext/;
  5021. foreach my $cond (Automake::Rule::define (${header}, 'internal',
  5022. RULE_AUTOMAKE, TRUE,
  5023. INTERNAL))
  5024. {
  5025. my $condstr = $cond->subst_string;
  5026. $output_rules .=
  5027. "$condstr${header}: $output\n"
  5028. # Recover from removal of $header
  5029. . "$condstr\t\@if test ! -f \$@; then rm -f $output; else :; fi\n"
  5030. . "$condstr\t\@if test ! -f \$@; then \$(MAKE) \$(AM_MAKEFLAGS) $output; else :; fi\n";
  5031. }
  5032. # Distribute the generated file, unless its .y source was
  5033. # listed in a nodist_ variable. (handle_source_transform()
  5034. # will set DIST_SOURCE.)
  5035. push_dist_common ($header)
  5036. if $transform{'DIST_SOURCE'};
  5037. # The GNU rules say that yacc/lex output files should be removed
  5038. # by maintainer-clean. However, if the files are not distributed,
  5039. # then we want to remove them with "make clean"; otherwise,
  5040. # "make distcheck" will fail.
  5041. $clean_files{$header} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
  5042. }
  5043. # See the comment above for $HEADER.
  5044. $clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
  5045. }
  5046. # This is a lex helper which is called whenever we have decided to
  5047. # compile a lex file.
  5048. sub lang_lex_target_hook
  5049. {
  5050. my ($self, $aggregate, $output, $input, %transform) = @_;
  5051. # The GNU rules say that yacc/lex output files should be removed
  5052. # by maintainer-clean. However, if the files are not distributed,
  5053. # then we want to remove them with "make clean"; otherwise,
  5054. # "make distcheck" will fail.
  5055. $clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
  5056. }
  5057. # This is a helper for both lex and yacc.
  5058. sub yacc_lex_finish_helper ()
  5059. {
  5060. return if defined $language_scratch{'lex-yacc-done'};
  5061. $language_scratch{'lex-yacc-done'} = 1;
  5062. # FIXME: for now, no line number.
  5063. require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
  5064. define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL);
  5065. }
  5066. sub lang_yacc_finish ()
  5067. {
  5068. return if defined $language_scratch{'yacc-done'};
  5069. $language_scratch{'yacc-done'} = 1;
  5070. reject_var 'YACCFLAGS', "'YACCFLAGS' obsolete; use 'YFLAGS' instead";
  5071. yacc_lex_finish_helper;
  5072. }
  5073. sub lang_lex_finish ()
  5074. {
  5075. return if defined $language_scratch{'lex-done'};
  5076. $language_scratch{'lex-done'} = 1;
  5077. yacc_lex_finish_helper;
  5078. }
  5079. # Given a hash table of linker names, pick the name that has the most
  5080. # precedence. This is lame, but something has to have global
  5081. # knowledge in order to eliminate the conflict. Add more linkers as
  5082. # required.
  5083. sub resolve_linker
  5084. {
  5085. my (%linkers) = @_;
  5086. foreach my $l (qw(GCJLINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
  5087. {
  5088. return $l if defined $linkers{$l};
  5089. }
  5090. return 'LINK';
  5091. }
  5092. # Called to indicate that an extension was used.
  5093. sub saw_extension
  5094. {
  5095. my ($ext) = @_;
  5096. $extension_seen{$ext} = 1;
  5097. }
  5098. # register_language (%ATTRIBUTE)
  5099. # ------------------------------
  5100. # Register a single language.
  5101. # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
  5102. sub register_language
  5103. {
  5104. my (%option) = @_;
  5105. # Set the defaults.
  5106. $option{'autodep'} = 'no'
  5107. unless defined $option{'autodep'};
  5108. $option{'linker'} = ''
  5109. unless defined $option{'linker'};
  5110. $option{'flags'} = []
  5111. unless defined $option{'flags'};
  5112. $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
  5113. unless defined $option{'output_extensions'};
  5114. $option{'nodist_specific'} = 0
  5115. unless defined $option{'nodist_specific'};
  5116. my $lang = new Automake::Language (%option);
  5117. # Fill indexes.
  5118. $extension_map{$_} = $lang->name foreach @{$lang->extensions};
  5119. $languages{$lang->name} = $lang;
  5120. my $link = $lang->linker;
  5121. if ($link)
  5122. {
  5123. if (exists $link_languages{$link})
  5124. {
  5125. prog_error ("'$link' has different definitions in "
  5126. . $lang->name . " and " . $link_languages{$link}->name)
  5127. if $lang->link ne $link_languages{$link}->link;
  5128. }
  5129. else
  5130. {
  5131. $link_languages{$link} = $lang;
  5132. }
  5133. }
  5134. # Update the pattern of known extensions.
  5135. accept_extensions (@{$lang->extensions});
  5136. # Update the suffix rules map.
  5137. foreach my $suffix (@{$lang->extensions})
  5138. {
  5139. foreach my $dest ($lang->output_extensions->($suffix))
  5140. {
  5141. register_suffix_rule (INTERNAL, $suffix, $dest);
  5142. }
  5143. }
  5144. }
  5145. # derive_suffix ($EXT, $OBJ)
  5146. # --------------------------
  5147. # This function is used to find a path from a user-specified suffix $EXT
  5148. # to $OBJ or to some other suffix we recognize internally, e.g. 'cc'.
  5149. sub derive_suffix
  5150. {
  5151. my ($source_ext, $obj) = @_;
  5152. while (!$extension_map{$source_ext} && $source_ext ne $obj)
  5153. {
  5154. my $new_source_ext = next_in_suffix_chain ($source_ext, $obj);
  5155. last if not defined $new_source_ext;
  5156. $source_ext = $new_source_ext;
  5157. }
  5158. return $source_ext;
  5159. }
  5160. # Pretty-print something and append to '$output_rules'.
  5161. sub pretty_print_rule
  5162. {
  5163. $output_rules .= makefile_wrap (shift, shift, @_);
  5164. }
  5165. ################################################################
  5166. ## -------------------------------- ##
  5167. ## Handling the conditional stack. ##
  5168. ## -------------------------------- ##
  5169. # $STRING
  5170. # make_conditional_string ($NEGATE, $COND)
  5171. # ----------------------------------------
  5172. sub make_conditional_string
  5173. {
  5174. my ($negate, $cond) = @_;
  5175. $cond = "${cond}_TRUE"
  5176. unless $cond =~ /^TRUE|FALSE$/;
  5177. $cond = Automake::Condition::conditional_negate ($cond)
  5178. if $negate;
  5179. return $cond;
  5180. }
  5181. my %_am_macro_for_cond =
  5182. (
  5183. AMDEP => "one of the compiler tests\n"
  5184. . " AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,\n"
  5185. . " AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
  5186. am__fastdepCC => 'AC_PROG_CC',
  5187. am__fastdepCCAS => 'AM_PROG_AS',
  5188. am__fastdepCXX => 'AC_PROG_CXX',
  5189. am__fastdepGCJ => 'AM_PROG_GCJ',
  5190. am__fastdepOBJC => 'AC_PROG_OBJC',
  5191. am__fastdepOBJCXX => 'AC_PROG_OBJCXX',
  5192. am__fastdepUPC => 'AM_PROG_UPC'
  5193. );
  5194. # $COND
  5195. # cond_stack_if ($NEGATE, $COND, $WHERE)
  5196. # --------------------------------------
  5197. sub cond_stack_if
  5198. {
  5199. my ($negate, $cond, $where) = @_;
  5200. if (! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/)
  5201. {
  5202. my $text = "$cond does not appear in AM_CONDITIONAL";
  5203. my $scope = US_LOCAL;
  5204. if (exists $_am_macro_for_cond{$cond})
  5205. {
  5206. my $mac = $_am_macro_for_cond{$cond};
  5207. $text .= "\n The usual way to define '$cond' is to add ";
  5208. $text .= ($mac =~ / /) ? $mac : "'$mac'";
  5209. $text .= "\n to '$configure_ac' and run 'aclocal' and 'autoconf' again";
  5210. # These warnings appear in Automake files (depend2.am),
  5211. # so there is no need to display them more than once:
  5212. $scope = US_GLOBAL;
  5213. }
  5214. error $where, $text, uniq_scope => $scope;
  5215. }
  5216. push (@cond_stack, make_conditional_string ($negate, $cond));
  5217. return new Automake::Condition (@cond_stack);
  5218. }
  5219. # $COND
  5220. # cond_stack_else ($NEGATE, $COND, $WHERE)
  5221. # ----------------------------------------
  5222. sub cond_stack_else
  5223. {
  5224. my ($negate, $cond, $where) = @_;
  5225. if (! @cond_stack)
  5226. {
  5227. error $where, "else without if";
  5228. return FALSE;
  5229. }
  5230. $cond_stack[$#cond_stack] =
  5231. Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]);
  5232. # If $COND is given, check against it.
  5233. if (defined $cond)
  5234. {
  5235. $cond = make_conditional_string ($negate, $cond);
  5236. error ($where, "else reminder ($negate$cond) incompatible with "
  5237. . "current conditional: $cond_stack[$#cond_stack]")
  5238. if $cond_stack[$#cond_stack] ne $cond;
  5239. }
  5240. return new Automake::Condition (@cond_stack);
  5241. }
  5242. # $COND
  5243. # cond_stack_endif ($NEGATE, $COND, $WHERE)
  5244. # -----------------------------------------
  5245. sub cond_stack_endif
  5246. {
  5247. my ($negate, $cond, $where) = @_;
  5248. my $old_cond;
  5249. if (! @cond_stack)
  5250. {
  5251. error $where, "endif without if";
  5252. return TRUE;
  5253. }
  5254. # If $COND is given, check against it.
  5255. if (defined $cond)
  5256. {
  5257. $cond = make_conditional_string ($negate, $cond);
  5258. error ($where, "endif reminder ($negate$cond) incompatible with "
  5259. . "current conditional: $cond_stack[$#cond_stack]")
  5260. if $cond_stack[$#cond_stack] ne $cond;
  5261. }
  5262. pop @cond_stack;
  5263. return new Automake::Condition (@cond_stack);
  5264. }
  5265. ## ------------------------ ##
  5266. ## Handling the variables. ##
  5267. ## ------------------------ ##
  5268. # define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
  5269. # ----------------------------------------------------
  5270. # Like define_variable, but the value is a list, and the variable may
  5271. # be defined conditionally. The second argument is the condition
  5272. # under which the value should be defined; this should be the empty
  5273. # string to define the variable unconditionally. The third argument
  5274. # is a list holding the values to use for the variable. The value is
  5275. # pretty printed in the output file.
  5276. sub define_pretty_variable
  5277. {
  5278. my ($var, $cond, $where, @value) = @_;
  5279. if (! vardef ($var, $cond))
  5280. {
  5281. Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
  5282. '', $where, VAR_PRETTY);
  5283. rvar ($var)->rdef ($cond)->set_seen;
  5284. }
  5285. }
  5286. # define_variable ($VAR, $VALUE, $WHERE)
  5287. # --------------------------------------
  5288. # Define a new Automake Makefile variable VAR to VALUE, but only if
  5289. # not already defined.
  5290. sub define_variable
  5291. {
  5292. my ($var, $value, $where) = @_;
  5293. define_pretty_variable ($var, TRUE, $where, $value);
  5294. }
  5295. # define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE)
  5296. # ------------------------------------------------------------
  5297. # Define the $VAR which content is the list of file names composed of
  5298. # a @BASENAME and the $EXTENSION.
  5299. sub define_files_variable ($\@$$)
  5300. {
  5301. my ($var, $basename, $extension, $where) = @_;
  5302. define_variable ($var,
  5303. join (' ', map { "$_.$extension" } @$basename),
  5304. $where);
  5305. }
  5306. # Like define_variable, but define a variable to be the configure
  5307. # substitution by the same name.
  5308. sub define_configure_variable
  5309. {
  5310. my ($var) = @_;
  5311. # Some variables we do not want to output. For instance it
  5312. # would be a bad idea to output `U = @U@` when `@U@` can be
  5313. # substituted as `\`.
  5314. my $pretty = exists $ignored_configure_vars{$var} ? VAR_SILENT : VAR_ASIS;
  5315. Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst ($var),
  5316. '', $configure_vars{$var}, $pretty);
  5317. }
  5318. # define_compiler_variable ($LANG)
  5319. # --------------------------------
  5320. # Define a compiler variable. We also handle defining the 'LT'
  5321. # version of the command when using libtool.
  5322. sub define_compiler_variable
  5323. {
  5324. my ($lang) = @_;
  5325. my ($var, $value) = ($lang->compiler, $lang->compile);
  5326. my $libtool_tag = '';
  5327. $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
  5328. if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
  5329. define_variable ($var, $value, INTERNAL);
  5330. if (var ('LIBTOOL'))
  5331. {
  5332. my $verbose = define_verbose_libtool ();
  5333. define_variable ("LT$var",
  5334. "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS)"
  5335. . " \$(LIBTOOLFLAGS) --mode=compile $value",
  5336. INTERNAL);
  5337. }
  5338. define_verbose_tagvar ($lang->ccer || 'GEN');
  5339. }
  5340. sub define_linker_variable
  5341. {
  5342. my ($lang) = @_;
  5343. my $libtool_tag = '';
  5344. $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
  5345. if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
  5346. # CCLD = $(CC).
  5347. define_variable ($lang->lder, $lang->ld, INTERNAL);
  5348. # CCLINK = $(CCLD) blah blah...
  5349. my $link = '';
  5350. if (var ('LIBTOOL'))
  5351. {
  5352. my $verbose = define_verbose_libtool ();
  5353. $link = "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) "
  5354. . "\$(LIBTOOLFLAGS) --mode=link ";
  5355. }
  5356. define_variable ($lang->linker, $link . $lang->link, INTERNAL);
  5357. define_variable ($lang->compiler, $lang, INTERNAL);
  5358. define_verbose_tagvar ($lang->lder || 'GEN');
  5359. }
  5360. sub define_per_target_linker_variable
  5361. {
  5362. my ($linker, $target) = @_;
  5363. # If the user wrote a custom link command, we don't define ours.
  5364. return "${target}_LINK"
  5365. if set_seen "${target}_LINK";
  5366. my $xlink = $linker ? $linker : 'LINK';
  5367. my $lang = $link_languages{$xlink};
  5368. prog_error "Unknown language for linker variable '$xlink'"
  5369. unless $lang;
  5370. my $link_command = $lang->link;
  5371. if (var 'LIBTOOL')
  5372. {
  5373. my $libtool_tag = '';
  5374. $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
  5375. if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
  5376. my $verbose = define_verbose_libtool ();
  5377. $link_command =
  5378. "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) \$(LIBTOOLFLAGS) "
  5379. . "--mode=link " . $link_command;
  5380. }
  5381. # Rewrite each occurrence of 'AM_$flag' in the link
  5382. # command into '${derived}_$flag' if it exists.
  5383. my $orig_command = $link_command;
  5384. my @flags = (@{$lang->flags}, 'LDFLAGS');
  5385. push @flags, 'LIBTOOLFLAGS' if var 'LIBTOOL';
  5386. for my $flag (@flags)
  5387. {
  5388. my $val = "${target}_$flag";
  5389. $link_command =~ s/\(AM_$flag\)/\($val\)/
  5390. if set_seen ($val);
  5391. }
  5392. # If the computed command is the same as the generic command, use
  5393. # the command linker variable.
  5394. return ($lang->linker, $lang->lder)
  5395. if $link_command eq $orig_command;
  5396. define_variable ("${target}_LINK", $link_command, INTERNAL);
  5397. return ("${target}_LINK", $lang->lder);
  5398. }
  5399. ################################################################
  5400. # check_trailing_slash ($WHERE, $LINE)
  5401. # ------------------------------------
  5402. # Return 1 iff $LINE ends with a slash.
  5403. # Might modify $LINE.
  5404. sub check_trailing_slash ($\$)
  5405. {
  5406. my ($where, $line) = @_;
  5407. # Ignore '##' lines.
  5408. return 0 if $$line =~ /$IGNORE_PATTERN/o;
  5409. # Catch and fix a common error.
  5410. msg "syntax", $where, "whitespace following trailing backslash"
  5411. if $$line =~ s/\\\s+\n$/\\\n/;
  5412. return $$line =~ /\\$/;
  5413. }
  5414. # read_am_file ($AMFILE, $WHERE, $RELDIR)
  5415. # ---------------------------------------
  5416. # Read $AMFILE file name which is located in $RELDIR, and set up
  5417. # global variables resetted by '&generate_makefile'. Simultaneously
  5418. # copy lines from $AMFILE into '$output_trailer', or define variables
  5419. # as appropriate.
  5420. #
  5421. # NOTE: We put rules in the trailer section. We want user rules to
  5422. # come after our generated stuff.
  5423. sub read_am_file
  5424. {
  5425. my ($amfile, $where, $reldir) = @_;
  5426. my $canon_reldir = &canonicalize ($reldir);
  5427. my $am_file = new Automake::XFile ("< $amfile");
  5428. verb "reading $amfile";
  5429. # Keep track of the youngest output dependency.
  5430. my $mtime = mtime $amfile;
  5431. $output_deps_greatest_timestamp = $mtime
  5432. if $mtime > $output_deps_greatest_timestamp;
  5433. my $spacing = '';
  5434. my $comment = '';
  5435. my $blank = 0;
  5436. my $saw_bk = 0;
  5437. my $var_look = VAR_ASIS;
  5438. use constant IN_VAR_DEF => 0;
  5439. use constant IN_RULE_DEF => 1;
  5440. use constant IN_COMMENT => 2;
  5441. my $prev_state = IN_RULE_DEF;
  5442. while ($_ = $am_file->getline)
  5443. {
  5444. $where->set ("$amfile:$.");
  5445. if (/$IGNORE_PATTERN/o)
  5446. {
  5447. # Merely delete comments beginning with two hashes.
  5448. }
  5449. elsif (/$WHITE_PATTERN/o)
  5450. {
  5451. error $where, "blank line following trailing backslash"
  5452. if $saw_bk;
  5453. # Stick a single white line before the incoming macro or rule.
  5454. $spacing = "\n";
  5455. $blank = 1;
  5456. # Flush all comments seen so far.
  5457. if ($comment ne '')
  5458. {
  5459. $output_vars .= $comment;
  5460. $comment = '';
  5461. }
  5462. }
  5463. elsif (/$COMMENT_PATTERN/o)
  5464. {
  5465. # Stick comments before the incoming macro or rule. Make
  5466. # sure a blank line precedes the first block of comments.
  5467. $spacing = "\n" unless $blank;
  5468. $blank = 1;
  5469. $comment .= $spacing . $_;
  5470. $spacing = '';
  5471. $prev_state = IN_COMMENT;
  5472. }
  5473. else
  5474. {
  5475. last;
  5476. }
  5477. $saw_bk = check_trailing_slash ($where, $_);
  5478. }
  5479. # We save the conditional stack on entry, and then check to make
  5480. # sure it is the same on exit. This lets us conditionally include
  5481. # other files.
  5482. my @saved_cond_stack = @cond_stack;
  5483. my $cond = new Automake::Condition (@cond_stack);
  5484. my $last_var_name = '';
  5485. my $last_var_type = '';
  5486. my $last_var_value = '';
  5487. my $last_where;
  5488. # FIXME: shouldn't use $_ in this loop; it is too big.
  5489. while ($_)
  5490. {
  5491. $where->set ("$amfile:$.");
  5492. # Make sure the line is \n-terminated.
  5493. chomp;
  5494. $_ .= "\n";
  5495. # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
  5496. # used by users. @MAINT@ is an anachronism now.
  5497. $_ =~ s/\@MAINT\@//g
  5498. unless $seen_maint_mode;
  5499. my $new_saw_bk = check_trailing_slash ($where, $_);
  5500. if ($reldir eq '.')
  5501. {
  5502. # If present, eat the following '_' or '/', converting
  5503. # "%reldir%/foo" and "%canon_reldir%_foo" into plain "foo"
  5504. # when $reldir is '.'.
  5505. $_ =~ s,%(D|reldir)%/,,g;
  5506. $_ =~ s,%(C|canon_reldir)%_,,g;
  5507. }
  5508. $_ =~ s/%(D|reldir)%/${reldir}/g;
  5509. $_ =~ s/%(C|canon_reldir)%/${canon_reldir}/g;
  5510. if (/$IGNORE_PATTERN/o)
  5511. {
  5512. # Merely delete comments beginning with two hashes.
  5513. # Keep any backslash from the previous line.
  5514. $new_saw_bk = $saw_bk;
  5515. }
  5516. elsif (/$WHITE_PATTERN/o)
  5517. {
  5518. # Stick a single white line before the incoming macro or rule.
  5519. $spacing = "\n";
  5520. error $where, "blank line following trailing backslash"
  5521. if $saw_bk;
  5522. }
  5523. elsif (/$COMMENT_PATTERN/o)
  5524. {
  5525. error $where, "comment following trailing backslash"
  5526. if $saw_bk && $prev_state != IN_COMMENT;
  5527. # Stick comments before the incoming macro or rule.
  5528. $comment .= $spacing . $_;
  5529. $spacing = '';
  5530. $prev_state = IN_COMMENT;
  5531. }
  5532. elsif ($saw_bk)
  5533. {
  5534. if ($prev_state == IN_RULE_DEF)
  5535. {
  5536. my $cond = new Automake::Condition @cond_stack;
  5537. $output_trailer .= $cond->subst_string;
  5538. $output_trailer .= $_;
  5539. }
  5540. elsif ($prev_state == IN_COMMENT)
  5541. {
  5542. # If the line doesn't start with a '#', add it.
  5543. # We do this because a continued comment like
  5544. # # A = foo \
  5545. # bar \
  5546. # baz
  5547. # is not portable. BSD make doesn't honor
  5548. # escaped newlines in comments.
  5549. s/^#?/#/;
  5550. $comment .= $spacing . $_;
  5551. }
  5552. else # $prev_state == IN_VAR_DEF
  5553. {
  5554. $last_var_value .= ' '
  5555. unless $last_var_value =~ /\s$/;
  5556. $last_var_value .= $_;
  5557. if (!/\\$/)
  5558. {
  5559. Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
  5560. $last_var_type, $cond,
  5561. $last_var_value, $comment,
  5562. $last_where, VAR_ASIS)
  5563. if $cond != FALSE;
  5564. $comment = $spacing = '';
  5565. }
  5566. }
  5567. }
  5568. elsif (/$IF_PATTERN/o)
  5569. {
  5570. $cond = cond_stack_if ($1, $2, $where);
  5571. }
  5572. elsif (/$ELSE_PATTERN/o)
  5573. {
  5574. $cond = cond_stack_else ($1, $2, $where);
  5575. }
  5576. elsif (/$ENDIF_PATTERN/o)
  5577. {
  5578. $cond = cond_stack_endif ($1, $2, $where);
  5579. }
  5580. elsif (/$RULE_PATTERN/o)
  5581. {
  5582. # Found a rule.
  5583. $prev_state = IN_RULE_DEF;
  5584. # For now we have to output all definitions of user rules
  5585. # and can't diagnose duplicates (see the comment in
  5586. # Automake::Rule::define). So we go on and ignore the return value.
  5587. Automake::Rule::define ($1, $amfile, RULE_USER, $cond, $where);
  5588. check_variable_expansions ($_, $where);
  5589. $output_trailer .= $comment . $spacing;
  5590. my $cond = new Automake::Condition @cond_stack;
  5591. $output_trailer .= $cond->subst_string;
  5592. $output_trailer .= $_;
  5593. $comment = $spacing = '';
  5594. }
  5595. elsif (/$ASSIGNMENT_PATTERN/o)
  5596. {
  5597. # Found a macro definition.
  5598. $prev_state = IN_VAR_DEF;
  5599. $last_var_name = $1;
  5600. $last_var_type = $2;
  5601. $last_var_value = $3;
  5602. $last_where = $where->clone;
  5603. if ($3 ne '' && substr ($3, -1) eq "\\")
  5604. {
  5605. # We preserve the '\' because otherwise the long lines
  5606. # that are generated will be truncated by broken
  5607. # 'sed's.
  5608. $last_var_value = $3 . "\n";
  5609. }
  5610. # Normally we try to output variable definitions in the
  5611. # same format they were input. However, POSIX compliant
  5612. # systems are not required to support lines longer than
  5613. # 2048 bytes (most notably, some sed implementation are
  5614. # limited to 4000 bytes, and sed is used by config.status
  5615. # to rewrite Makefile.in into Makefile). Moreover nobody
  5616. # would really write such long lines by hand since it is
  5617. # hardly maintainable. So if a line is longer that 1000
  5618. # bytes (an arbitrary limit), assume it has been
  5619. # automatically generated by some tools, and flatten the
  5620. # variable definition. Otherwise, keep the variable as it
  5621. # as been input.
  5622. $var_look = VAR_PRETTY if length ($last_var_value) >= 1000;
  5623. if (!/\\$/)
  5624. {
  5625. Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
  5626. $last_var_type, $cond,
  5627. $last_var_value, $comment,
  5628. $last_where, $var_look)
  5629. if $cond != FALSE;
  5630. $comment = $spacing = '';
  5631. $var_look = VAR_ASIS;
  5632. }
  5633. }
  5634. elsif (/$INCLUDE_PATTERN/o)
  5635. {
  5636. my $path = $1;
  5637. if ($path =~ s/^\$\(top_srcdir\)\///)
  5638. {
  5639. push (@include_stack, "\$\(top_srcdir\)/$path");
  5640. # Distribute any included file.
  5641. # Always use the $(top_srcdir) prefix in DIST_COMMON,
  5642. # otherwise OSF make will implicitly copy the included
  5643. # file in the build tree during "make distdir" to satisfy
  5644. # the dependency.
  5645. # (subdir-am-cond.sh and subdir-ac-cond.sh will fail)
  5646. push_dist_common ("\$\(top_srcdir\)/$path");
  5647. }
  5648. else
  5649. {
  5650. $path =~ s/\$\(srcdir\)\///;
  5651. push (@include_stack, "\$\(srcdir\)/$path");
  5652. # Always use the $(srcdir) prefix in DIST_COMMON,
  5653. # otherwise OSF make will implicitly copy the included
  5654. # file in the build tree during "make distdir" to satisfy
  5655. # the dependency.
  5656. # (subdir-am-cond.sh and subdir-ac-cond.sh will fail)
  5657. push_dist_common ("\$\(srcdir\)/$path");
  5658. $path = $relative_dir . "/" . $path if $relative_dir ne '.';
  5659. }
  5660. my $new_reldir = File::Spec->abs2rel ($path, $relative_dir);
  5661. $new_reldir = '.' if $new_reldir !~ s,/[^/]*$,,;
  5662. $where->push_context ("'$path' included from here");
  5663. read_am_file ($path, $where, $new_reldir);
  5664. $where->pop_context;
  5665. }
  5666. else
  5667. {
  5668. # This isn't an error; it is probably a continued rule.
  5669. # In fact, this is what we assume.
  5670. $prev_state = IN_RULE_DEF;
  5671. check_variable_expansions ($_, $where);
  5672. $output_trailer .= $comment . $spacing;
  5673. my $cond = new Automake::Condition @cond_stack;
  5674. $output_trailer .= $cond->subst_string;
  5675. $output_trailer .= $_;
  5676. $comment = $spacing = '';
  5677. error $where, "'#' comment at start of rule is unportable"
  5678. if $_ =~ /^\t\s*\#/;
  5679. }
  5680. $saw_bk = $new_saw_bk;
  5681. $_ = $am_file->getline;
  5682. }
  5683. $output_trailer .= $comment;
  5684. error ($where, "trailing backslash on last line")
  5685. if $saw_bk;
  5686. error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack"
  5687. : "too many conditionals closed in include file"))
  5688. if "@saved_cond_stack" ne "@cond_stack";
  5689. }
  5690. # A helper for read_main_am_file which initializes configure variables
  5691. # and variables from header-vars.am.
  5692. sub define_standard_variables ()
  5693. {
  5694. my $saved_output_vars = $output_vars;
  5695. my ($comments, undef, $rules) =
  5696. file_contents_internal (1, "$libdir/am/header-vars.am",
  5697. new Automake::Location);
  5698. foreach my $var (sort keys %configure_vars)
  5699. {
  5700. define_configure_variable ($var);
  5701. }
  5702. $output_vars .= $comments . $rules;
  5703. }
  5704. # read_main_am_file ($MAKEFILE_AM, $MAKEFILE_IN)
  5705. # ----------------------------------------------
  5706. sub read_main_am_file
  5707. {
  5708. my ($amfile, $infile) = @_;
  5709. # This supports the strange variable tricks we are about to play.
  5710. prog_error ("variable defined before read_main_am_file\n" . variables_dump ())
  5711. if (scalar (variables) > 0);
  5712. # Generate copyright header for generated Makefile.in.
  5713. # We do discard the output of predefined variables, handled below.
  5714. $output_vars = ("# " . basename ($infile) . " generated by automake "
  5715. . $VERSION . " from " . basename ($amfile) . ".\n");
  5716. $output_vars .= '# ' . subst ('configure_input') . "\n";
  5717. $output_vars .= $gen_copyright;
  5718. # We want to predefine as many variables as possible. This lets
  5719. # the user set them with '+=' in Makefile.am.
  5720. define_standard_variables;
  5721. # Read user file, which might override some of our values.
  5722. read_am_file ($amfile, new Automake::Location, '.');
  5723. }
  5724. ################################################################
  5725. # $STRING
  5726. # flatten ($ORIGINAL_STRING)
  5727. # --------------------------
  5728. sub flatten
  5729. {
  5730. $_ = shift;
  5731. s/\\\n//somg;
  5732. s/\s+/ /g;
  5733. s/^ //;
  5734. s/ $//;
  5735. return $_;
  5736. }
  5737. # transform_token ($TOKEN, \%PAIRS, $KEY)
  5738. # ---------------------------------------
  5739. # Return the value associated to $KEY in %PAIRS, as used on $TOKEN
  5740. # (which should be ?KEY? or any of the special %% requests)..
  5741. sub transform_token ($\%$)
  5742. {
  5743. my ($token, $transform, $key) = @_;
  5744. my $res = $transform->{$key};
  5745. prog_error "Unknown key '$key' in '$token'" unless defined $res;
  5746. return $res;
  5747. }
  5748. # transform ($TOKEN, \%PAIRS)
  5749. # ---------------------------
  5750. # If ($TOKEN, $VAL) is in %PAIRS:
  5751. # - replaces %KEY% with $VAL,
  5752. # - enables/disables ?KEY? and ?!KEY?,
  5753. # - replaces %?KEY% with TRUE or FALSE.
  5754. sub transform ($\%)
  5755. {
  5756. my ($token, $transform) = @_;
  5757. # %KEY%.
  5758. # Must be before the following pattern to exclude the case
  5759. # when there is neither IFTRUE nor IFFALSE.
  5760. if ($token =~ /^%([\w\-]+)%$/)
  5761. {
  5762. return transform_token ($token, %$transform, $1);
  5763. }
  5764. # %?KEY%.
  5765. elsif ($token =~ /^%\?([\w\-]+)%$/)
  5766. {
  5767. return transform_token ($token, %$transform, $1) ? 'TRUE' : 'FALSE';
  5768. }
  5769. # ?KEY? and ?!KEY?.
  5770. elsif ($token =~ /^ \? (!?) ([\w\-]+) \? $/x)
  5771. {
  5772. my $neg = ($1 eq '!') ? 1 : 0;
  5773. my $val = transform_token ($token, %$transform, $2);
  5774. return (!!$val == $neg) ? '##%' : '';
  5775. }
  5776. else
  5777. {
  5778. prog_error "Unknown request format: $token";
  5779. }
  5780. }
  5781. # $TEXT
  5782. # preprocess_file ($MAKEFILE, [%TRANSFORM])
  5783. # -----------------------------------------
  5784. # Load a $MAKEFILE, apply the %TRANSFORM, and return the result.
  5785. # No extra parsing or post-processing is done (i.e., recognition of
  5786. # rules declaration or of make variables definitions).
  5787. sub preprocess_file
  5788. {
  5789. my ($file, %transform) = @_;
  5790. # Complete %transform with global options.
  5791. # Note that %transform goes last, so it overrides global options.
  5792. %transform = ( 'MAINTAINER-MODE'
  5793. => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
  5794. 'XZ' => !! option 'dist-xz',
  5795. 'LZIP' => !! option 'dist-lzip',
  5796. 'BZIP2' => !! option 'dist-bzip2',
  5797. 'COMPRESS' => !! option 'dist-tarZ',
  5798. 'GZIP' => ! option 'no-dist-gzip',
  5799. 'SHAR' => !! option 'dist-shar',
  5800. 'ZIP' => !! option 'dist-zip',
  5801. 'INSTALL-INFO' => ! option 'no-installinfo',
  5802. 'INSTALL-MAN' => ! option 'no-installman',
  5803. 'CK-NEWS' => !! option 'check-news',
  5804. 'SUBDIRS' => !! var ('SUBDIRS'),
  5805. 'TOPDIR_P' => $relative_dir eq '.',
  5806. 'BUILD' => ($seen_canonical >= AC_CANONICAL_BUILD),
  5807. 'HOST' => ($seen_canonical >= AC_CANONICAL_HOST),
  5808. 'TARGET' => ($seen_canonical >= AC_CANONICAL_TARGET),
  5809. 'LIBTOOL' => !! var ('LIBTOOL'),
  5810. 'NONLIBTOOL' => 1,
  5811. %transform);
  5812. if (! defined ($_ = $am_file_cache{$file}))
  5813. {
  5814. verb "reading $file";
  5815. # Swallow the whole file.
  5816. my $fc_file = new Automake::XFile "< $file";
  5817. my $saved_dollar_slash = $/;
  5818. undef $/;
  5819. $_ = $fc_file->getline;
  5820. $/ = $saved_dollar_slash;
  5821. $fc_file->close;
  5822. # Remove ##-comments.
  5823. # Besides we don't need more than two consecutive new-lines.
  5824. s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
  5825. # Remember the contents of the just-read file.
  5826. $am_file_cache{$file} = $_;
  5827. }
  5828. # Substitute Automake template tokens.
  5829. s/(?: % \?? [\w\-]+ %
  5830. | \? !? [\w\-]+ \?
  5831. )/transform($&, %transform)/gex;
  5832. # transform() may have added some ##%-comments to strip.
  5833. # (we use '##%' instead of '##' so we can distinguish ##%##%##% from
  5834. # ####### and do not remove the latter.)
  5835. s/^[ \t]*(?:##%)+.*\n//gm;
  5836. return $_;
  5837. }
  5838. # @PARAGRAPHS
  5839. # make_paragraphs ($MAKEFILE, [%TRANSFORM])
  5840. # -----------------------------------------
  5841. # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
  5842. # paragraphs.
  5843. sub make_paragraphs
  5844. {
  5845. my ($file, %transform) = @_;
  5846. $transform{FIRST} = !$transformed_files{$file};
  5847. $transformed_files{$file} = 1;
  5848. my @lines = split /(?<!\\)\n/, preprocess_file ($file, %transform);
  5849. my @res;
  5850. while (defined ($_ = shift @lines))
  5851. {
  5852. my $paragraph = $_;
  5853. # If we are a rule, eat as long as we start with a tab.
  5854. if (/$RULE_PATTERN/smo)
  5855. {
  5856. while (defined ($_ = shift @lines) && $_ =~ /^\t/)
  5857. {
  5858. $paragraph .= "\n$_";
  5859. }
  5860. unshift (@lines, $_);
  5861. }
  5862. # If we are a comments, eat as much comments as you can.
  5863. elsif (/$COMMENT_PATTERN/smo)
  5864. {
  5865. while (defined ($_ = shift @lines)
  5866. && $_ =~ /$COMMENT_PATTERN/smo)
  5867. {
  5868. $paragraph .= "\n$_";
  5869. }
  5870. unshift (@lines, $_);
  5871. }
  5872. push @res, $paragraph;
  5873. }
  5874. return @res;
  5875. }
  5876. # ($COMMENT, $VARIABLES, $RULES)
  5877. # file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
  5878. # ------------------------------------------------------------
  5879. # Return contents of a file from $libdir/am, automatically skipping
  5880. # macros or rules which are already known. $IS_AM iff the caller is
  5881. # reading an Automake file (as opposed to the user's Makefile.am).
  5882. sub file_contents_internal
  5883. {
  5884. my ($is_am, $file, $where, %transform) = @_;
  5885. $where->set ($file);
  5886. my $result_vars = '';
  5887. my $result_rules = '';
  5888. my $comment = '';
  5889. my $spacing = '';
  5890. # The following flags are used to track rules spanning across
  5891. # multiple paragraphs.
  5892. my $is_rule = 0; # 1 if we are processing a rule.
  5893. my $discard_rule = 0; # 1 if the current rule should not be output.
  5894. # We save the conditional stack on entry, and then check to make
  5895. # sure it is the same on exit. This lets us conditionally include
  5896. # other files.
  5897. my @saved_cond_stack = @cond_stack;
  5898. my $cond = new Automake::Condition (@cond_stack);
  5899. foreach (make_paragraphs ($file, %transform))
  5900. {
  5901. # FIXME: no line number available.
  5902. $where->set ($file);
  5903. # Sanity checks.
  5904. error $where, "blank line following trailing backslash:\n$_"
  5905. if /\\$/;
  5906. error $where, "comment following trailing backslash:\n$_"
  5907. if /\\#/;
  5908. if (/^$/)
  5909. {
  5910. $is_rule = 0;
  5911. # Stick empty line before the incoming macro or rule.
  5912. $spacing = "\n";
  5913. }
  5914. elsif (/$COMMENT_PATTERN/mso)
  5915. {
  5916. $is_rule = 0;
  5917. # Stick comments before the incoming macro or rule.
  5918. $comment = "$_\n";
  5919. }
  5920. # Handle inclusion of other files.
  5921. elsif (/$INCLUDE_PATTERN/o)
  5922. {
  5923. if ($cond != FALSE)
  5924. {
  5925. my $file = ($is_am ? "$libdir/am/" : '') . $1;
  5926. $where->push_context ("'$file' included from here");
  5927. # N-ary '.=' fails.
  5928. my ($com, $vars, $rules)
  5929. = file_contents_internal ($is_am, $file, $where, %transform);
  5930. $where->pop_context;
  5931. $comment .= $com;
  5932. $result_vars .= $vars;
  5933. $result_rules .= $rules;
  5934. }
  5935. }
  5936. # Handling the conditionals.
  5937. elsif (/$IF_PATTERN/o)
  5938. {
  5939. $cond = cond_stack_if ($1, $2, $file);
  5940. }
  5941. elsif (/$ELSE_PATTERN/o)
  5942. {
  5943. $cond = cond_stack_else ($1, $2, $file);
  5944. }
  5945. elsif (/$ENDIF_PATTERN/o)
  5946. {
  5947. $cond = cond_stack_endif ($1, $2, $file);
  5948. }
  5949. # Handling rules.
  5950. elsif (/$RULE_PATTERN/mso)
  5951. {
  5952. $is_rule = 1;
  5953. $discard_rule = 0;
  5954. # Separate relationship from optional actions: the first
  5955. # `new-line tab" not preceded by backslash (continuation
  5956. # line).
  5957. my $paragraph = $_;
  5958. /^(.*?)(?:(?<!\\)\n(\t.*))?$/s;
  5959. my ($relationship, $actions) = ($1, $2 || '');
  5960. # Separate targets from dependencies: the first colon.
  5961. $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
  5962. my ($targets, $dependencies) = ($1, $2);
  5963. # Remove the escaped new lines.
  5964. # I don't know why, but I have to use a tmp $flat_deps.
  5965. my $flat_deps = flatten ($dependencies);
  5966. my @deps = split (' ', $flat_deps);
  5967. foreach (split (' ', $targets))
  5968. {
  5969. # FIXME: 1. We are not robust to people defining several targets
  5970. # at once, only some of them being in %dependencies. The
  5971. # actions from the targets in %dependencies are usually generated
  5972. # from the content of %actions, but if some targets in $targets
  5973. # are not in %dependencies the ELSE branch will output
  5974. # a rule for all $targets (i.e. the targets which are both
  5975. # in %dependencies and $targets will have two rules).
  5976. # FIXME: 2. The logic here is not able to output a
  5977. # multi-paragraph rule several time (e.g. for each condition
  5978. # it is defined for) because it only knows the first paragraph.
  5979. # FIXME: 3. We are not robust to people defining a subset
  5980. # of a previously defined "multiple-target" rule. E.g.
  5981. # 'foo:' after 'foo bar:'.
  5982. # Output only if not in FALSE.
  5983. if (defined $dependencies{$_} && $cond != FALSE)
  5984. {
  5985. depend ($_, @deps);
  5986. register_action ($_, $actions);
  5987. }
  5988. else
  5989. {
  5990. # Free-lance dependency. Output the rule for all the
  5991. # targets instead of one by one.
  5992. my @undefined_conds =
  5993. Automake::Rule::define ($targets, $file,
  5994. $is_am ? RULE_AUTOMAKE : RULE_USER,
  5995. $cond, $where);
  5996. for my $undefined_cond (@undefined_conds)
  5997. {
  5998. my $condparagraph = $paragraph;
  5999. $condparagraph =~ s/^/$undefined_cond->subst_string/gme;
  6000. $result_rules .= "$spacing$comment$condparagraph\n";
  6001. }
  6002. if (scalar @undefined_conds == 0)
  6003. {
  6004. # Remember to discard next paragraphs
  6005. # if they belong to this rule.
  6006. # (but see also FIXME: #2 above.)
  6007. $discard_rule = 1;
  6008. }
  6009. $comment = $spacing = '';
  6010. last;
  6011. }
  6012. }
  6013. }
  6014. elsif (/$ASSIGNMENT_PATTERN/mso)
  6015. {
  6016. my ($var, $type, $val) = ($1, $2, $3);
  6017. error $where, "variable '$var' with trailing backslash"
  6018. if /\\$/;
  6019. $is_rule = 0;
  6020. Automake::Variable::define ($var,
  6021. $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
  6022. $type, $cond, $val, $comment, $where,
  6023. VAR_ASIS)
  6024. if $cond != FALSE;
  6025. $comment = $spacing = '';
  6026. }
  6027. else
  6028. {
  6029. # This isn't an error; it is probably some tokens which
  6030. # configure is supposed to replace, such as '@SET-MAKE@',
  6031. # or some part of a rule cut by an if/endif.
  6032. if (! $cond->false && ! ($is_rule && $discard_rule))
  6033. {
  6034. s/^/$cond->subst_string/gme;
  6035. $result_rules .= "$spacing$comment$_\n";
  6036. }
  6037. $comment = $spacing = '';
  6038. }
  6039. }
  6040. error ($where, @cond_stack ?
  6041. "unterminated conditionals: @cond_stack" :
  6042. "too many conditionals closed in include file")
  6043. if "@saved_cond_stack" ne "@cond_stack";
  6044. return ($comment, $result_vars, $result_rules);
  6045. }
  6046. # $CONTENTS
  6047. # file_contents ($BASENAME, $WHERE, [%TRANSFORM])
  6048. # -----------------------------------------------
  6049. # Return contents of a file from $libdir/am, automatically skipping
  6050. # macros or rules which are already known.
  6051. sub file_contents
  6052. {
  6053. my ($basename, $where, %transform) = @_;
  6054. my ($comments, $variables, $rules) =
  6055. file_contents_internal (1, "$libdir/am/$basename.am", $where,
  6056. %transform);
  6057. return "$comments$variables$rules";
  6058. }
  6059. # @PREFIX
  6060. # am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
  6061. # ----------------------------------------------------
  6062. # Find all variable prefixes that are used for install directories. A
  6063. # prefix 'zar' qualifies iff:
  6064. #
  6065. # * 'zardir' is a variable.
  6066. # * 'zar_PRIMARY' is a variable.
  6067. #
  6068. # As a side effect, it looks for misspellings. It is an error to have
  6069. # a variable ending in a "reserved" suffix whose prefix is unknown, e.g.
  6070. # "bni_PROGRAMS". However, unusual prefixes are allowed if a variable
  6071. # of the same name (with "dir" appended) exists. For instance, if the
  6072. # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
  6073. # This is to provide a little extra flexibility in those cases which
  6074. # need it.
  6075. sub am_primary_prefixes
  6076. {
  6077. my ($primary, $can_dist, @prefixes) = @_;
  6078. local $_;
  6079. my %valid = map { $_ => 0 } @prefixes;
  6080. $valid{'EXTRA'} = 0;
  6081. foreach my $var (variables $primary)
  6082. {
  6083. # Automake is allowed to define variables that look like primaries
  6084. # but which aren't. E.g. INSTALL_sh_DATA.
  6085. # Autoconf can also define variables like INSTALL_DATA, so
  6086. # ignore all configure variables (at least those which are not
  6087. # redefined in Makefile.am).
  6088. # FIXME: We should make sure that these variables are not
  6089. # conditionally defined (or else adjust the condition below).
  6090. my $def = $var->def (TRUE);
  6091. next if $def && $def->owner != VAR_MAKEFILE;
  6092. my $varname = $var->name;
  6093. if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_[[:alnum:]]+$/)
  6094. {
  6095. my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
  6096. if ($dist ne '' && ! $can_dist)
  6097. {
  6098. err_var ($var,
  6099. "invalid variable '$varname': 'dist' is forbidden");
  6100. }
  6101. # Standard directories must be explicitly allowed.
  6102. elsif (! defined $valid{$X} && exists $standard_prefix{$X})
  6103. {
  6104. err_var ($var,
  6105. "'${X}dir' is not a legitimate directory " .
  6106. "for '$primary'");
  6107. }
  6108. # A not explicitly valid directory is allowed if Xdir is defined.
  6109. elsif (! defined $valid{$X} &&
  6110. $var->requires_variables ("'$varname' is used", "${X}dir"))
  6111. {
  6112. # Nothing to do. Any error message has been output
  6113. # by $var->requires_variables.
  6114. }
  6115. else
  6116. {
  6117. # Ensure all extended prefixes are actually used.
  6118. $valid{"$base$dist$X"} = 1;
  6119. }
  6120. }
  6121. else
  6122. {
  6123. prog_error "unexpected variable name: $varname";
  6124. }
  6125. }
  6126. # Return only those which are actually defined.
  6127. return sort grep { var ($_ . '_' . $primary) } keys %valid;
  6128. }
  6129. # am_install_var (-OPTION..., file, HOW, where...)
  6130. # ------------------------------------------------
  6131. #
  6132. # Handle 'where_HOW' variable magic. Does all lookups, generates
  6133. # install code, and possibly generates code to define the primary
  6134. # variable. The first argument is the name of the .am file to munge,
  6135. # the second argument is the primary variable (e.g. HEADERS), and all
  6136. # subsequent arguments are possible installation locations.
  6137. #
  6138. # Returns list of [$location, $value] pairs, where
  6139. # $value's are the values in all where_HOW variable, and $location
  6140. # there associated location (the place here their parent variables were
  6141. # defined).
  6142. #
  6143. # FIXME: this should be rewritten to be cleaner. It should be broken
  6144. # up into multiple functions.
  6145. #
  6146. sub am_install_var
  6147. {
  6148. my (@args) = @_;
  6149. my $do_require = 1;
  6150. my $can_dist = 0;
  6151. my $default_dist = 0;
  6152. while (@args)
  6153. {
  6154. if ($args[0] eq '-noextra')
  6155. {
  6156. $do_require = 0;
  6157. }
  6158. elsif ($args[0] eq '-candist')
  6159. {
  6160. $can_dist = 1;
  6161. }
  6162. elsif ($args[0] eq '-defaultdist')
  6163. {
  6164. $default_dist = 1;
  6165. $can_dist = 1;
  6166. }
  6167. elsif ($args[0] !~ /^-/)
  6168. {
  6169. last;
  6170. }
  6171. shift (@args);
  6172. }
  6173. my ($file, $primary, @prefix) = @args;
  6174. # Now that configure substitutions are allowed in where_HOW
  6175. # variables, it is an error to actually define the primary. We
  6176. # allow 'JAVA', as it is customarily used to mean the Java
  6177. # interpreter. This is but one of several Java hacks. Similarly,
  6178. # 'PYTHON' is customarily used to mean the Python interpreter.
  6179. reject_var $primary, "'$primary' is an anachronism"
  6180. unless $primary eq 'JAVA' || $primary eq 'PYTHON';
  6181. # Get the prefixes which are valid and actually used.
  6182. @prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
  6183. # If a primary includes a configure substitution, then the EXTRA_
  6184. # form is required. Otherwise we can't properly do our job.
  6185. my $require_extra;
  6186. my @used = ();
  6187. my @result = ();
  6188. foreach my $X (@prefix)
  6189. {
  6190. my $nodir_name = $X;
  6191. my $one_name = $X . '_' . $primary;
  6192. my $one_var = var $one_name;
  6193. my $strip_subdir = 1;
  6194. # If subdir prefix should be preserved, do so.
  6195. if ($nodir_name =~ /^nobase_/)
  6196. {
  6197. $strip_subdir = 0;
  6198. $nodir_name =~ s/^nobase_//;
  6199. }
  6200. # If files should be distributed, do so.
  6201. my $dist_p = 0;
  6202. if ($can_dist)
  6203. {
  6204. $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
  6205. || (! $default_dist && $nodir_name =~ /^dist_/));
  6206. $nodir_name =~ s/^(dist|nodist)_//;
  6207. }
  6208. # Use the location of the currently processed variable.
  6209. # We are not processing a particular condition, so pick the first
  6210. # available.
  6211. my $tmpcond = $one_var->conditions->one_cond;
  6212. my $where = $one_var->rdef ($tmpcond)->location->clone;
  6213. # Append actual contents of where_PRIMARY variable to
  6214. # @result, skipping @substitutions@.
  6215. foreach my $locvals ($one_var->value_as_list_recursive (location => 1))
  6216. {
  6217. my ($loc, $value) = @$locvals;
  6218. # Skip configure substitutions.
  6219. if ($value =~ /^\@.*\@$/)
  6220. {
  6221. if ($nodir_name eq 'EXTRA')
  6222. {
  6223. error ($where,
  6224. "'$one_name' contains configure substitution, "
  6225. . "but shouldn't");
  6226. }
  6227. # Check here to make sure variables defined in
  6228. # configure.ac do not imply that EXTRA_PRIMARY
  6229. # must be defined.
  6230. elsif (! defined $configure_vars{$one_name})
  6231. {
  6232. $require_extra = $one_name
  6233. if $do_require;
  6234. }
  6235. }
  6236. else
  6237. {
  6238. # Strip any $(EXEEXT) suffix the user might have added,
  6239. # or this will confuse handle_source_transform() and
  6240. # check_canonical_spelling().
  6241. # We'll add $(EXEEXT) back later anyway.
  6242. # Do it here rather than in handle_programs so the
  6243. # uniquifying at the end of this function works.
  6244. ${$locvals}[1] =~ s/\$\(EXEEXT\)$//
  6245. if $primary eq 'PROGRAMS';
  6246. push (@result, $locvals);
  6247. }
  6248. }
  6249. # A blatant hack: we rewrite each _PROGRAMS primary to include
  6250. # EXEEXT.
  6251. append_exeext { 1 } $one_name
  6252. if $primary eq 'PROGRAMS';
  6253. # "EXTRA" shouldn't be used when generating clean targets,
  6254. # all, or install targets. We used to warn if EXTRA_FOO was
  6255. # defined uselessly, but this was annoying.
  6256. next
  6257. if $nodir_name eq 'EXTRA';
  6258. if ($nodir_name eq 'check')
  6259. {
  6260. push (@check, '$(' . $one_name . ')');
  6261. }
  6262. else
  6263. {
  6264. push (@used, '$(' . $one_name . ')');
  6265. }
  6266. # Is this to be installed?
  6267. my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
  6268. # If so, with install-exec? (or install-data?).
  6269. my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
  6270. my $check_options_p = $install_p && !! option 'std-options';
  6271. # Use the location of the currently processed variable as context.
  6272. $where->push_context ("while processing '$one_name'");
  6273. # The variable containing all files to distribute.
  6274. my $distvar = "\$($one_name)";
  6275. $distvar = shadow_unconditionally ($one_name, $where)
  6276. if ($dist_p && $one_var->has_conditional_contents);
  6277. # Singular form of $PRIMARY.
  6278. (my $one_primary = $primary) =~ s/S$//;
  6279. $output_rules .= file_contents ($file, $where,
  6280. PRIMARY => $primary,
  6281. ONE_PRIMARY => $one_primary,
  6282. DIR => $X,
  6283. NDIR => $nodir_name,
  6284. BASE => $strip_subdir,
  6285. EXEC => $exec_p,
  6286. INSTALL => $install_p,
  6287. DIST => $dist_p,
  6288. DISTVAR => $distvar,
  6289. 'CK-OPTS' => $check_options_p);
  6290. }
  6291. # The JAVA variable is used as the name of the Java interpreter.
  6292. # The PYTHON variable is used as the name of the Python interpreter.
  6293. if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
  6294. {
  6295. # Define it.
  6296. define_pretty_variable ($primary, TRUE, INTERNAL, @used);
  6297. $output_vars .= "\n";
  6298. }
  6299. err_var ($require_extra,
  6300. "'$require_extra' contains configure substitution,\n"
  6301. . "but 'EXTRA_$primary' not defined")
  6302. if ($require_extra && ! var ('EXTRA_' . $primary));
  6303. # Push here because PRIMARY might be configure time determined.
  6304. push (@all, '$(' . $primary . ')')
  6305. if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
  6306. # Make the result unique. This lets the user use conditionals in
  6307. # a natural way, but still lets us program lazily -- we don't have
  6308. # to worry about handling a particular object more than once.
  6309. # We will keep only one location per object.
  6310. my %result = ();
  6311. for my $pair (@result)
  6312. {
  6313. my ($loc, $val) = @$pair;
  6314. $result{$val} = $loc;
  6315. }
  6316. my @l = sort keys %result;
  6317. return map { [$result{$_}->clone, $_] } @l;
  6318. }
  6319. ################################################################
  6320. # Each key in this hash is the name of a directory holding a
  6321. # Makefile.in. These variables are local to 'is_make_dir'.
  6322. my %make_dirs = ();
  6323. my $make_dirs_set = 0;
  6324. # is_make_dir ($DIRECTORY)
  6325. # ------------------------
  6326. sub is_make_dir
  6327. {
  6328. my ($dir) = @_;
  6329. if (! $make_dirs_set)
  6330. {
  6331. foreach my $iter (@configure_input_files)
  6332. {
  6333. $make_dirs{dirname ($iter)} = 1;
  6334. }
  6335. # We also want to notice Makefile.in's.
  6336. foreach my $iter (@other_input_files)
  6337. {
  6338. if ($iter =~ /Makefile\.in$/)
  6339. {
  6340. $make_dirs{dirname ($iter)} = 1;
  6341. }
  6342. }
  6343. $make_dirs_set = 1;
  6344. }
  6345. return defined $make_dirs{$dir};
  6346. }
  6347. ################################################################
  6348. # Find the aux dir. This should match the algorithm used by
  6349. # ./configure. (See the Autoconf documentation for for
  6350. # AC_CONFIG_AUX_DIR.)
  6351. sub locate_aux_dir ()
  6352. {
  6353. if (! $config_aux_dir_set_in_configure_ac)
  6354. {
  6355. # The default auxiliary directory is the first
  6356. # of ., .., or ../.. that contains install-sh.
  6357. # Assume . if install-sh doesn't exist yet.
  6358. for my $dir (qw (. .. ../..))
  6359. {
  6360. if (-f "$dir/install-sh")
  6361. {
  6362. $config_aux_dir = $dir;
  6363. last;
  6364. }
  6365. }
  6366. $config_aux_dir = '.' unless $config_aux_dir;
  6367. }
  6368. # Avoid unsightly '/.'s.
  6369. $am_config_aux_dir =
  6370. '$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir");
  6371. $am_config_aux_dir =~ s,/*$,,;
  6372. }
  6373. # push_required_file ($DIR, $FILE, $FULLFILE)
  6374. # -------------------------------------------
  6375. # Push the given file onto DIST_COMMON.
  6376. sub push_required_file
  6377. {
  6378. my ($dir, $file, $fullfile) = @_;
  6379. # If the file to be distributed is in the same directory of the
  6380. # currently processed Makefile.am, then we want to distribute it
  6381. # from this same Makefile.am.
  6382. if ($dir eq $relative_dir)
  6383. {
  6384. push_dist_common ($file);
  6385. }
  6386. # This is needed to allow a construct in a non-top-level Makefile.am
  6387. # to require a file in the build-aux directory (see at least the test
  6388. # script 'test-driver-is-distributed.sh'). This is related to the
  6389. # automake bug#9546. Note that the use of $config_aux_dir instead
  6390. # of $am_config_aux_dir here is deliberate and necessary.
  6391. elsif ($dir eq $config_aux_dir)
  6392. {
  6393. push_dist_common ("$am_config_aux_dir/$file");
  6394. }
  6395. # FIXME: another spacial case, for AC_LIBOBJ/AC_LIBSOURCE support.
  6396. # We probably need some refactoring of this function and its callers,
  6397. # to have a more explicit and systematic handling of all the special
  6398. # cases; but, since there are only two of them, this is low-priority
  6399. # ATM.
  6400. elsif ($config_libobj_dir && $dir eq $config_libobj_dir)
  6401. {
  6402. # Avoid unsightly '/.'s.
  6403. my $am_config_libobj_dir =
  6404. '$(top_srcdir)' .
  6405. ($config_libobj_dir eq '.' ? "" : "/$config_libobj_dir");
  6406. $am_config_libobj_dir =~ s|/*$||;
  6407. push_dist_common ("$am_config_libobj_dir/$file");
  6408. }
  6409. elsif ($relative_dir eq '.' && ! is_make_dir ($dir))
  6410. {
  6411. # If we are doing the topmost directory, and the file is in a
  6412. # subdir which does not have a Makefile, then we distribute it
  6413. # here.
  6414. # If a required file is above the source tree, it is important
  6415. # to prefix it with '$(srcdir)' so that no VPATH search is
  6416. # performed. Otherwise problems occur with Make implementations
  6417. # that rewrite and simplify rules whose dependencies are found in a
  6418. # VPATH location. Here is an example with OSF1/Tru64 Make.
  6419. #
  6420. # % cat Makefile
  6421. # VPATH = sub
  6422. # distdir: ../a
  6423. # echo ../a
  6424. # % ls
  6425. # Makefile a
  6426. # % make
  6427. # echo a
  6428. # a
  6429. #
  6430. # Dependency '../a' was found in 'sub/../a', but this make
  6431. # implementation simplified it as 'a'. (Note that the sub/
  6432. # directory does not even exist.)
  6433. #
  6434. # This kind of VPATH rewriting seems hard to cancel. The
  6435. # distdir.am hack against VPATH rewriting works only when no
  6436. # simplification is done, i.e., for dependencies which are in
  6437. # subdirectories, not in enclosing directories. Hence, in
  6438. # the latter case we use a full path to make sure no VPATH
  6439. # search occurs.
  6440. $fullfile = '$(srcdir)/' . $fullfile
  6441. if $dir =~ m,^\.\.(?:$|/),;
  6442. push_dist_common ($fullfile);
  6443. }
  6444. else
  6445. {
  6446. prog_error "a Makefile in relative directory $relative_dir " .
  6447. "can't add files in directory $dir to DIST_COMMON";
  6448. }
  6449. }
  6450. # If a file name appears as a key in this hash, then it has already
  6451. # been checked for. This allows us not to report the same error more
  6452. # than once.
  6453. my %required_file_not_found = ();
  6454. # required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
  6455. # -------------------------------------------------------
  6456. # Verify that the file must exist in $DIRECTORY, or install it.
  6457. sub required_file_check_or_copy
  6458. {
  6459. my ($where, $dir, $file) = @_;
  6460. my $fullfile = "$dir/$file";
  6461. my $found_it = 0;
  6462. my $dangling_sym = 0;
  6463. if (-l $fullfile && ! -f $fullfile)
  6464. {
  6465. $dangling_sym = 1;
  6466. }
  6467. elsif (dir_has_case_matching_file ($dir, $file))
  6468. {
  6469. $found_it = 1;
  6470. }
  6471. # '--force-missing' only has an effect if '--add-missing' is
  6472. # specified.
  6473. return
  6474. if $found_it && (! $add_missing || ! $force_missing);
  6475. # If we've already looked for it, we're done. You might wonder why we
  6476. # don't do this before searching for the file. If we do that, then
  6477. # something like AC_OUTPUT([subdir/foo foo]) will fail to put 'foo.in'
  6478. # into $(DIST_COMMON).
  6479. if (! $found_it)
  6480. {
  6481. return if defined $required_file_not_found{$fullfile};
  6482. $required_file_not_found{$fullfile} = 1;
  6483. }
  6484. if ($dangling_sym && $add_missing)
  6485. {
  6486. unlink ($fullfile);
  6487. }
  6488. my $trailer = '';
  6489. my $trailer2 = '';
  6490. my $suppress = 0;
  6491. # Only install missing files according to our desired
  6492. # strictness level.
  6493. my $message = "required file '$fullfile' not found";
  6494. if ($add_missing)
  6495. {
  6496. if (-f "$libdir/$file")
  6497. {
  6498. $suppress = 1;
  6499. # Install the missing file. Symlink if we
  6500. # can, copy if we must. Note: delete the file
  6501. # first, in case it is a dangling symlink.
  6502. $message = "installing '$fullfile'";
  6503. # The license file should not be volatile.
  6504. if ($file eq "COPYING")
  6505. {
  6506. $message .= " using GNU General Public License v3 file";
  6507. $trailer2 = "\n Consider adding the COPYING file"
  6508. . " to the version control system"
  6509. . "\n for your code, to avoid questions"
  6510. . " about which license your project uses";
  6511. }
  6512. # Windows Perl will hang if we try to delete a
  6513. # file that doesn't exist.
  6514. unlink ($fullfile) if -f $fullfile;
  6515. if ($symlink_exists && ! $copy_missing)
  6516. {
  6517. if (! symlink ("$libdir/$file", $fullfile)
  6518. || ! -e $fullfile)
  6519. {
  6520. $suppress = 0;
  6521. $trailer = "; error while making link: $!";
  6522. }
  6523. }
  6524. elsif (system ('cp', "$libdir/$file", $fullfile))
  6525. {
  6526. $suppress = 0;
  6527. $trailer = "\n error while copying";
  6528. }
  6529. set_dir_cache_file ($dir, $file);
  6530. }
  6531. }
  6532. else
  6533. {
  6534. $trailer = "\n 'automake --add-missing' can install '$file'"
  6535. if -f "$libdir/$file";
  6536. }
  6537. # If --force-missing was specified, and we have
  6538. # actually found the file, then do nothing.
  6539. return
  6540. if $found_it && $force_missing;
  6541. # If we couldn't install the file, but it is a target in
  6542. # the Makefile, don't print anything. This allows files
  6543. # like README, AUTHORS, or THANKS to be generated.
  6544. return
  6545. if !$suppress && rule $file;
  6546. msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2");
  6547. }
  6548. # require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
  6549. # ---------------------------------------------------------------------
  6550. # Verify that the file must exist in $DIRECTORY, or install it.
  6551. # $MYSTRICT is the strictness level at which this file becomes required.
  6552. # Worker threads may queue up the action to be serialized by the master,
  6553. # if $QUEUE is true
  6554. sub require_file_internal
  6555. {
  6556. my ($where, $mystrict, $dir, $queue, @files) = @_;
  6557. return
  6558. unless $strictness >= $mystrict;
  6559. foreach my $file (@files)
  6560. {
  6561. push_required_file ($dir, $file, "$dir/$file");
  6562. if ($queue)
  6563. {
  6564. queue_required_file_check_or_copy ($required_conf_file_queue,
  6565. QUEUE_CONF_FILE, $relative_dir,
  6566. $where, $mystrict, @files);
  6567. }
  6568. else
  6569. {
  6570. required_file_check_or_copy ($where, $dir, $file);
  6571. }
  6572. }
  6573. }
  6574. # require_file ($WHERE, $MYSTRICT, @FILES)
  6575. # ----------------------------------------
  6576. sub require_file
  6577. {
  6578. my ($where, $mystrict, @files) = @_;
  6579. require_file_internal ($where, $mystrict, $relative_dir, 0, @files);
  6580. }
  6581. # require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
  6582. # ----------------------------------------------------------
  6583. sub require_file_with_macro
  6584. {
  6585. my ($cond, $macro, $mystrict, @files) = @_;
  6586. $macro = rvar ($macro) unless ref $macro;
  6587. require_file ($macro->rdef ($cond)->location, $mystrict, @files);
  6588. }
  6589. # require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
  6590. # ---------------------------------------------------------------
  6591. # Require an AC_LIBSOURCEd file. If AC_CONFIG_LIBOBJ_DIR was called, it
  6592. # must be in that directory. Otherwise expect it in the current directory.
  6593. sub require_libsource_with_macro
  6594. {
  6595. my ($cond, $macro, $mystrict, @files) = @_;
  6596. $macro = rvar ($macro) unless ref $macro;
  6597. if ($config_libobj_dir)
  6598. {
  6599. require_file_internal ($macro->rdef ($cond)->location, $mystrict,
  6600. $config_libobj_dir, 0, @files);
  6601. }
  6602. else
  6603. {
  6604. require_file ($macro->rdef ($cond)->location, $mystrict, @files);
  6605. }
  6606. }
  6607. # queue_required_file_check_or_copy ($QUEUE, $KEY, $DIR, $WHERE,
  6608. # $MYSTRICT, @FILES)
  6609. # --------------------------------------------------------------
  6610. sub queue_required_file_check_or_copy
  6611. {
  6612. my ($queue, $key, $dir, $where, $mystrict, @files) = @_;
  6613. my @serial_loc;
  6614. if (ref $where)
  6615. {
  6616. @serial_loc = (QUEUE_LOCATION, $where->serialize ());
  6617. }
  6618. else
  6619. {
  6620. @serial_loc = (QUEUE_STRING, $where);
  6621. }
  6622. $queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files);
  6623. }
  6624. # require_queued_file_check_or_copy ($QUEUE)
  6625. # ------------------------------------------
  6626. sub require_queued_file_check_or_copy
  6627. {
  6628. my ($queue) = @_;
  6629. my $where;
  6630. my $dir = $queue->dequeue ();
  6631. my $loc_key = $queue->dequeue ();
  6632. if ($loc_key eq QUEUE_LOCATION)
  6633. {
  6634. $where = Automake::Location::deserialize ($queue);
  6635. }
  6636. elsif ($loc_key eq QUEUE_STRING)
  6637. {
  6638. $where = $queue->dequeue ();
  6639. }
  6640. else
  6641. {
  6642. prog_error "unexpected key $loc_key";
  6643. }
  6644. my $mystrict = $queue->dequeue ();
  6645. my $nfiles = $queue->dequeue ();
  6646. my @files;
  6647. push @files, $queue->dequeue ()
  6648. foreach (1 .. $nfiles);
  6649. return
  6650. unless $strictness >= $mystrict;
  6651. foreach my $file (@files)
  6652. {
  6653. required_file_check_or_copy ($where, $config_aux_dir, $file);
  6654. }
  6655. }
  6656. # require_conf_file ($WHERE, $MYSTRICT, @FILES)
  6657. # ---------------------------------------------
  6658. # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
  6659. sub require_conf_file
  6660. {
  6661. my ($where, $mystrict, @files) = @_;
  6662. my $queue = defined $required_conf_file_queue ? 1 : 0;
  6663. require_file_internal ($where, $mystrict, $config_aux_dir,
  6664. $queue, @files);
  6665. }
  6666. # require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
  6667. # ---------------------------------------------------------------
  6668. sub require_conf_file_with_macro
  6669. {
  6670. my ($cond, $macro, $mystrict, @files) = @_;
  6671. require_conf_file (rvar ($macro)->rdef ($cond)->location,
  6672. $mystrict, @files);
  6673. }
  6674. ################################################################
  6675. # require_build_directory ($DIRECTORY)
  6676. # ------------------------------------
  6677. # Emit rules to create $DIRECTORY if needed, and return
  6678. # the file that any target requiring this directory should be made
  6679. # dependent upon.
  6680. # We don't want to emit the rule twice, and want to reuse it
  6681. # for directories with equivalent names (e.g., 'foo/bar' and './foo//bar').
  6682. sub require_build_directory
  6683. {
  6684. my $directory = shift;
  6685. return $directory_map{$directory} if exists $directory_map{$directory};
  6686. my $cdir = File::Spec->canonpath ($directory);
  6687. if (exists $directory_map{$cdir})
  6688. {
  6689. my $stamp = $directory_map{$cdir};
  6690. $directory_map{$directory} = $stamp;
  6691. return $stamp;
  6692. }
  6693. my $dirstamp = "$cdir/\$(am__dirstamp)";
  6694. $directory_map{$directory} = $dirstamp;
  6695. $directory_map{$cdir} = $dirstamp;
  6696. # Set a variable for the dirstamp basename.
  6697. define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
  6698. '$(am__leading_dot)dirstamp');
  6699. # Directory must be removed by 'make distclean'.
  6700. $clean_files{$dirstamp} = DIST_CLEAN;
  6701. $output_rules .= ("$dirstamp:\n"
  6702. . "\t\@\$(MKDIR_P) $directory\n"
  6703. . "\t\@: > $dirstamp\n");
  6704. return $dirstamp;
  6705. }
  6706. # require_build_directory_maybe ($FILE)
  6707. # -------------------------------------
  6708. # If $FILE lies in a subdirectory, emit a rule to create this
  6709. # directory and return the file that $FILE should be made
  6710. # dependent upon. Otherwise, just return the empty string.
  6711. sub require_build_directory_maybe
  6712. {
  6713. my $file = shift;
  6714. my $directory = dirname ($file);
  6715. if ($directory ne '.')
  6716. {
  6717. return require_build_directory ($directory);
  6718. }
  6719. else
  6720. {
  6721. return '';
  6722. }
  6723. }
  6724. ################################################################
  6725. # Push a list of files onto '@dist_common'.
  6726. sub push_dist_common
  6727. {
  6728. prog_error "push_dist_common run after handle_dist"
  6729. if $handle_dist_run;
  6730. push @dist_common, @_;
  6731. }
  6732. ################################################################
  6733. # generate_makefile ($MAKEFILE_AM, $MAKEFILE_IN)
  6734. # ----------------------------------------------
  6735. # Generate a Makefile.in given the name of the corresponding Makefile and
  6736. # the name of the file output by config.status.
  6737. sub generate_makefile
  6738. {
  6739. my ($makefile_am, $makefile_in) = @_;
  6740. # Reset all the Makefile.am related variables.
  6741. initialize_per_input;
  6742. # AUTOMAKE_OPTIONS can contains -W flags to disable or enable
  6743. # warnings for this file. So hold any warning issued before
  6744. # we have processed AUTOMAKE_OPTIONS.
  6745. buffer_messages ('warning');
  6746. # $OUTPUT is encoded. If it contains a ":" then the first element
  6747. # is the real output file, and all remaining elements are input
  6748. # files. We don't scan or otherwise deal with these input files,
  6749. # other than to mark them as dependencies. See the subroutine
  6750. # 'scan_autoconf_files' for details.
  6751. my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in});
  6752. $relative_dir = dirname ($makefile);
  6753. read_main_am_file ($makefile_am, $makefile_in);
  6754. if (not handle_options)
  6755. {
  6756. # Process buffered warnings.
  6757. flush_messages;
  6758. # Fatal error. Just return, so we can continue with next file.
  6759. return;
  6760. }
  6761. # Process buffered warnings.
  6762. flush_messages;
  6763. # There are a few install-related variables that you should not define.
  6764. foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
  6765. {
  6766. my $v = var $var;
  6767. if ($v)
  6768. {
  6769. my $def = $v->def (TRUE);
  6770. prog_error "$var not defined in condition TRUE"
  6771. unless $def;
  6772. reject_var $var, "'$var' should not be defined"
  6773. if $def->owner != VAR_AUTOMAKE;
  6774. }
  6775. }
  6776. # Catch some obsolete variables.
  6777. msg_var ('obsolete', 'INCLUDES',
  6778. "'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')")
  6779. if var ('INCLUDES');
  6780. # Must do this after reading .am file.
  6781. define_variable ('subdir', $relative_dir, INTERNAL);
  6782. # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that
  6783. # recursive rules are enabled.
  6784. define_pretty_variable ('SUBDIRS', TRUE, INTERNAL, '')
  6785. if var 'DIST_SUBDIRS' && ! var 'SUBDIRS';
  6786. # Check first, because we might modify some state.
  6787. check_gnu_standards;
  6788. check_gnits_standards;
  6789. handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
  6790. handle_gettext;
  6791. handle_libraries;
  6792. handle_ltlibraries;
  6793. handle_programs;
  6794. handle_scripts;
  6795. handle_silent;
  6796. # These must be run after all the sources are scanned. They use
  6797. # variables defined by handle_libraries(), handle_ltlibraries(),
  6798. # or handle_programs().
  6799. handle_compile;
  6800. handle_languages;
  6801. handle_libtool;
  6802. # Variables used by distdir.am and tags.am.
  6803. define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
  6804. if (! option 'no-dist')
  6805. {
  6806. define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
  6807. }
  6808. handle_texinfo;
  6809. handle_emacs_lisp;
  6810. handle_python;
  6811. handle_java;
  6812. handle_man_pages;
  6813. handle_data;
  6814. handle_headers;
  6815. handle_subdirs;
  6816. handle_user_recursion;
  6817. handle_tags;
  6818. handle_minor_options;
  6819. # Must come after handle_programs so that %known_programs is up-to-date.
  6820. handle_tests;
  6821. # This must come after most other rules.
  6822. handle_dist;
  6823. handle_footer;
  6824. do_check_merge_target;
  6825. handle_all ($makefile);
  6826. # FIXME: Gross!
  6827. if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
  6828. {
  6829. $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
  6830. }
  6831. if (var ('nobase_lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
  6832. {
  6833. $output_rules .= "install-binPROGRAMS: install-nobase_libLTLIBRARIES\n\n";
  6834. }
  6835. handle_install;
  6836. handle_clean ($makefile);
  6837. handle_factored_dependencies;
  6838. # Comes last, because all the above procedures may have
  6839. # defined or overridden variables.
  6840. $output_vars .= output_variables;
  6841. check_typos;
  6842. if ($exit_code != 0)
  6843. {
  6844. verb "not writing $makefile_in because of earlier errors";
  6845. return;
  6846. }
  6847. my $am_relative_dir = dirname ($makefile_am);
  6848. mkdir ($am_relative_dir, 0755) if ! -d $am_relative_dir;
  6849. # We make sure that 'all:' is the first target.
  6850. my $output =
  6851. "$output_vars$output_all$output_header$output_rules$output_trailer";
  6852. # Decide whether we must update the output file or not.
  6853. # We have to update in the following situations.
  6854. # * $force_generation is set.
  6855. # * any of the output dependencies is younger than the output
  6856. # * the contents of the output is different (this can happen
  6857. # if the project has been populated with a file listed in
  6858. # @common_files since the last run).
  6859. # Output's dependencies are split in two sets:
  6860. # * dependencies which are also configure dependencies
  6861. # These do not change between each Makefile.am
  6862. # * other dependencies, specific to the Makefile.am being processed
  6863. # (such as the Makefile.am itself, or any Makefile fragment
  6864. # it includes).
  6865. my $timestamp = mtime $makefile_in;
  6866. if (! $force_generation
  6867. && $configure_deps_greatest_timestamp < $timestamp
  6868. && $output_deps_greatest_timestamp < $timestamp
  6869. && $output eq contents ($makefile_in))
  6870. {
  6871. verb "$makefile_in unchanged";
  6872. # No need to update.
  6873. return;
  6874. }
  6875. if (-e $makefile_in)
  6876. {
  6877. unlink ($makefile_in)
  6878. or fatal "cannot remove $makefile_in: $!";
  6879. }
  6880. my $gm_file = new Automake::XFile "> $makefile_in";
  6881. verb "creating $makefile_in";
  6882. print $gm_file $output;
  6883. }
  6884. ################################################################
  6885. # Helper function for usage().
  6886. sub print_autodist_files
  6887. {
  6888. my @lcomm = uniq (sort @_);
  6889. my @four;
  6890. format USAGE_FORMAT =
  6891. @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
  6892. $four[0], $four[1], $four[2], $four[3]
  6893. .
  6894. local $~ = "USAGE_FORMAT";
  6895. my $cols = 4;
  6896. my $rows = int(@lcomm / $cols);
  6897. my $rest = @lcomm % $cols;
  6898. if ($rest)
  6899. {
  6900. $rows++;
  6901. }
  6902. else
  6903. {
  6904. $rest = $cols;
  6905. }
  6906. for (my $y = 0; $y < $rows; $y++)
  6907. {
  6908. @four = ("", "", "", "");
  6909. for (my $x = 0; $x < $cols; $x++)
  6910. {
  6911. last if $y + 1 == $rows && $x == $rest;
  6912. my $idx = (($x > $rest)
  6913. ? ($rows * $rest + ($rows - 1) * ($x - $rest))
  6914. : ($rows * $x));
  6915. $idx += $y;
  6916. $four[$x] = $lcomm[$idx];
  6917. }
  6918. write;
  6919. }
  6920. }
  6921. sub usage ()
  6922. {
  6923. print "Usage: $0 [OPTION]... [Makefile]...
  6924. Generate Makefile.in for configure from Makefile.am.
  6925. Operation modes:
  6926. --help print this help, then exit
  6927. --version print version number, then exit
  6928. -v, --verbose verbosely list files processed
  6929. --no-force only update Makefile.in's that are out of date
  6930. -W, --warnings=CATEGORY report the warnings falling in CATEGORY
  6931. Dependency tracking:
  6932. -i, --ignore-deps disable dependency tracking code
  6933. --include-deps enable dependency tracking code
  6934. Flavors:
  6935. --foreign set strictness to foreign
  6936. --gnits set strictness to gnits
  6937. --gnu set strictness to gnu
  6938. Library files:
  6939. -a, --add-missing add missing standard files to package
  6940. --libdir=DIR set directory storing library files
  6941. --print-libdir print directory storing library files
  6942. -c, --copy with -a, copy missing files (default is symlink)
  6943. -f, --force-missing force update of standard files
  6944. ";
  6945. Automake::ChannelDefs::usage;
  6946. print "\nFiles automatically distributed if found " .
  6947. "(always):\n";
  6948. print_autodist_files @common_files;
  6949. print "\nFiles automatically distributed if found " .
  6950. "(under certain conditions):\n";
  6951. print_autodist_files @common_sometimes;
  6952. print '
  6953. Report bugs to <@PACKAGE_BUGREPORT@>.
  6954. GNU Automake home page: <@PACKAGE_URL@>.
  6955. General help using GNU software: <http://www.gnu.org/gethelp/>.
  6956. ';
  6957. # --help always returns 0 per GNU standards.
  6958. exit 0;
  6959. }
  6960. sub version ()
  6961. {
  6962. print <<EOF;
  6963. automake (GNU $PACKAGE) $VERSION
  6964. Copyright (C) $RELEASE_YEAR Free Software Foundation, Inc.
  6965. License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
  6966. This is free software: you are free to change and redistribute it.
  6967. There is NO WARRANTY, to the extent permitted by law.
  6968. Written by Tom Tromey <tromey\@redhat.com>
  6969. and Alexandre Duret-Lutz <adl\@gnu.org>.
  6970. EOF
  6971. # --version always returns 0 per GNU standards.
  6972. exit 0;
  6973. }
  6974. ################################################################
  6975. # Parse command line.
  6976. sub parse_arguments ()
  6977. {
  6978. my $strict = 'gnu';
  6979. my $ignore_deps = 0;
  6980. my @warnings = ();
  6981. my %cli_options =
  6982. (
  6983. 'version' => \&version,
  6984. 'help' => \&usage,
  6985. 'libdir=s' => \$libdir,
  6986. 'print-libdir' => sub { print "$libdir\n"; exit 0; },
  6987. 'gnu' => sub { $strict = 'gnu'; },
  6988. 'gnits' => sub { $strict = 'gnits'; },
  6989. 'foreign' => sub { $strict = 'foreign'; },
  6990. 'include-deps' => sub { $ignore_deps = 0; },
  6991. 'i|ignore-deps' => sub { $ignore_deps = 1; },
  6992. 'no-force' => sub { $force_generation = 0; },
  6993. 'f|force-missing' => \$force_missing,
  6994. 'a|add-missing' => \$add_missing,
  6995. 'c|copy' => \$copy_missing,
  6996. 'v|verbose' => sub { setup_channel 'verb', silent => 0; },
  6997. 'W|warnings=s' => \@warnings,
  6998. );
  6999. use Automake::Getopt ();
  7000. Automake::Getopt::parse_options %cli_options;
  7001. set_strictness ($strict);
  7002. my $cli_where = new Automake::Location;
  7003. set_global_option ('no-dependencies', $cli_where) if $ignore_deps;
  7004. for my $warning (@warnings)
  7005. {
  7006. parse_warnings ('-W', $warning);
  7007. }
  7008. return unless @ARGV;
  7009. my $errspec = 0;
  7010. foreach my $arg (@ARGV)
  7011. {
  7012. fatal ("empty argument\nTry '$0 --help' for more information")
  7013. if ($arg eq '');
  7014. # Handle $local:$input syntax.
  7015. my ($local, @rest) = split (/:/, $arg);
  7016. @rest = ("$local.in",) unless @rest;
  7017. my $input = locate_am @rest;
  7018. if ($input)
  7019. {
  7020. push @input_files, $input;
  7021. $output_files{$input} = join (':', ($local, @rest));
  7022. }
  7023. else
  7024. {
  7025. error "no Automake input file found for '$arg'";
  7026. $errspec = 1;
  7027. }
  7028. }
  7029. fatal "no input file found among supplied arguments"
  7030. if $errspec && ! @input_files;
  7031. }
  7032. # handle_makefile ($MAKEFILE)
  7033. # ---------------------------
  7034. sub handle_makefile
  7035. {
  7036. my ($file) = @_;
  7037. ($am_file = $file) =~ s/\.in$//;
  7038. if (! -f ($am_file . '.am'))
  7039. {
  7040. error "'$am_file.am' does not exist";
  7041. }
  7042. else
  7043. {
  7044. # Any warning setting now local to this Makefile.am.
  7045. dup_channel_setup;
  7046. generate_makefile ($am_file . '.am', $file);
  7047. # Back out any warning setting.
  7048. drop_channel_setup;
  7049. }
  7050. }
  7051. # Deal with all makefiles, without threads.
  7052. sub handle_makefiles_serial ()
  7053. {
  7054. foreach my $file (@input_files)
  7055. {
  7056. handle_makefile ($file);
  7057. }
  7058. }
  7059. # Logic for deciding how many worker threads to use.
  7060. sub get_number_of_threads ()
  7061. {
  7062. my $nthreads = $ENV{'AUTOMAKE_JOBS'} || 0;
  7063. $nthreads = 0
  7064. unless $nthreads =~ /^[0-9]+$/;
  7065. # It doesn't make sense to use more threads than makefiles,
  7066. my $max_threads = @input_files;
  7067. if ($nthreads > $max_threads)
  7068. {
  7069. $nthreads = $max_threads;
  7070. }
  7071. return $nthreads;
  7072. }
  7073. # handle_makefiles_threaded ($NTHREADS)
  7074. # -------------------------------------
  7075. # Deal with all makefiles, using threads. The general strategy is to
  7076. # spawn NTHREADS worker threads, dispatch makefiles to them, and let the
  7077. # worker threads push back everything that needs serialization:
  7078. # * warning and (normal) error messages, for stable stderr output
  7079. # order and content (avoiding duplicates, for example),
  7080. # * races when installing aux files (and respective messages),
  7081. # * races when collecting aux files for distribution.
  7082. #
  7083. # The latter requires that the makefile that deals with the aux dir
  7084. # files be handled last, done by the master thread.
  7085. sub handle_makefiles_threaded
  7086. {
  7087. my ($nthreads) = @_;
  7088. # The file queue distributes all makefiles, the message queues
  7089. # collect all serializations needed for respective files.
  7090. my $file_queue = Thread::Queue->new;
  7091. my %msg_queues;
  7092. foreach my $file (@input_files)
  7093. {
  7094. $msg_queues{$file} = Thread::Queue->new;
  7095. }
  7096. verb "spawning $nthreads worker threads";
  7097. my @threads = (1 .. $nthreads);
  7098. foreach my $t (@threads)
  7099. {
  7100. $t = threads->new (sub
  7101. {
  7102. while (my $file = $file_queue->dequeue)
  7103. {
  7104. verb "handling $file";
  7105. my $queue = $msg_queues{$file};
  7106. setup_channel_queue ($queue, QUEUE_MESSAGE);
  7107. $required_conf_file_queue = $queue;
  7108. handle_makefile ($file);
  7109. $queue->enqueue (undef);
  7110. setup_channel_queue (undef, undef);
  7111. $required_conf_file_queue = undef;
  7112. }
  7113. return $exit_code;
  7114. });
  7115. }
  7116. # Queue all makefiles.
  7117. verb "queuing " . @input_files . " input files";
  7118. $file_queue->enqueue (@input_files, (undef) x @threads);
  7119. # Collect and process serializations.
  7120. foreach my $file (@input_files)
  7121. {
  7122. verb "dequeuing messages for " . $file;
  7123. reset_local_duplicates ();
  7124. my $queue = $msg_queues{$file};
  7125. while (my $key = $queue->dequeue)
  7126. {
  7127. if ($key eq QUEUE_MESSAGE)
  7128. {
  7129. pop_channel_queue ($queue);
  7130. }
  7131. elsif ($key eq QUEUE_CONF_FILE)
  7132. {
  7133. require_queued_file_check_or_copy ($queue);
  7134. }
  7135. else
  7136. {
  7137. prog_error "unexpected key $key";
  7138. }
  7139. }
  7140. }
  7141. foreach my $t (@threads)
  7142. {
  7143. my @exit_thread = $t->join;
  7144. $exit_code = $exit_thread[0]
  7145. if ($exit_thread[0] > $exit_code);
  7146. }
  7147. }
  7148. ################################################################
  7149. # Parse the WARNINGS environment variable.
  7150. parse_WARNINGS;
  7151. # Parse command line.
  7152. parse_arguments;
  7153. $configure_ac = require_configure_ac;
  7154. # Do configure.ac scan only once.
  7155. scan_autoconf_files;
  7156. if (! @input_files)
  7157. {
  7158. my $msg = '';
  7159. $msg = "\nDid you forget AC_CONFIG_FILES([Makefile]) in $configure_ac?"
  7160. if -f 'Makefile.am';
  7161. fatal ("no 'Makefile.am' found for any configure output$msg");
  7162. }
  7163. my $nthreads = get_number_of_threads ();
  7164. if ($perl_threads && $nthreads >= 1)
  7165. {
  7166. handle_makefiles_threaded ($nthreads);
  7167. }
  7168. else
  7169. {
  7170. handle_makefiles_serial ();
  7171. }
  7172. exit $exit_code;
  7173. ### Setup "GNU" style for perl-mode and cperl-mode.
  7174. ## Local Variables:
  7175. ## perl-indent-level: 2
  7176. ## perl-continued-statement-offset: 2
  7177. ## perl-continued-brace-offset: 0
  7178. ## perl-brace-offset: 0
  7179. ## perl-brace-imaginary-offset: 0
  7180. ## perl-label-offset: -2
  7181. ## cperl-indent-level: 2
  7182. ## cperl-brace-offset: 0
  7183. ## cperl-continued-brace-offset: 0
  7184. ## cperl-label-offset: -2
  7185. ## cperl-extra-newline-before-brace: t
  7186. ## cperl-merge-trailing-else: nil
  7187. ## cperl-continued-statement-offset: 2
  7188. ## End: