automake 248 KB

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