Assign variable once when first used in Makefile [duplicate]












2
















This question already has an answer here:




  • How to get “at most once” semantics in variable assignments?

    2 answers




How do I only invoke a make shell function once in a variable expansion, and only when the variable is first used? I don't want to use := to expand at declaration time (ie: simple expansion) because the expansion is expensive and only some of my targets need the variable.



I tried using conditional variable assignment but it invokes the shell every time, for example, the following invokes shell ls twice:



.PHONY: test

FILES ?= $(warning Invoking the shell)$(shell ls)

test:
echo $(FILES) one
echo $(FILES) two









share|improve this question













marked as duplicate by Renaud Pacalet, Community Nov 21 '18 at 6:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1





    A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

    – MadScientist
    Nov 18 '18 at 14:23
















2
















This question already has an answer here:




  • How to get “at most once” semantics in variable assignments?

    2 answers




How do I only invoke a make shell function once in a variable expansion, and only when the variable is first used? I don't want to use := to expand at declaration time (ie: simple expansion) because the expansion is expensive and only some of my targets need the variable.



I tried using conditional variable assignment but it invokes the shell every time, for example, the following invokes shell ls twice:



.PHONY: test

FILES ?= $(warning Invoking the shell)$(shell ls)

test:
echo $(FILES) one
echo $(FILES) two









share|improve this question













marked as duplicate by Renaud Pacalet, Community Nov 21 '18 at 6:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1





    A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

    – MadScientist
    Nov 18 '18 at 14:23














2












2








2









This question already has an answer here:




  • How to get “at most once” semantics in variable assignments?

    2 answers




How do I only invoke a make shell function once in a variable expansion, and only when the variable is first used? I don't want to use := to expand at declaration time (ie: simple expansion) because the expansion is expensive and only some of my targets need the variable.



I tried using conditional variable assignment but it invokes the shell every time, for example, the following invokes shell ls twice:



.PHONY: test

FILES ?= $(warning Invoking the shell)$(shell ls)

test:
echo $(FILES) one
echo $(FILES) two









share|improve this question















This question already has an answer here:




  • How to get “at most once” semantics in variable assignments?

    2 answers




How do I only invoke a make shell function once in a variable expansion, and only when the variable is first used? I don't want to use := to expand at declaration time (ie: simple expansion) because the expansion is expensive and only some of my targets need the variable.



I tried using conditional variable assignment but it invokes the shell every time, for example, the following invokes shell ls twice:



.PHONY: test

FILES ?= $(warning Invoking the shell)$(shell ls)

test:
echo $(FILES) one
echo $(FILES) two




This question already has an answer here:




  • How to get “at most once” semantics in variable assignments?

    2 answers








makefile gnu-make






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 '18 at 2:38









tekumaratekumara

5,14774058




5,14774058




marked as duplicate by Renaud Pacalet, Community Nov 21 '18 at 6:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Renaud Pacalet, Community Nov 21 '18 at 6:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

    – MadScientist
    Nov 18 '18 at 14:23














  • 1





    A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

    – MadScientist
    Nov 18 '18 at 14:23








1




1





A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

– MadScientist
Nov 18 '18 at 14:23





A longer writeup is here: make.mad-scientist.net/deferred-simple-variable-expansion

– MadScientist
Nov 18 '18 at 14:23












1 Answer
1






active

oldest

votes


















-1














Move the assignment inside the recipe



test:
FILES=$$(ls) ;
echo $$FILES one ;
echo $$FILES two





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    Move the assignment inside the recipe



    test:
    FILES=$$(ls) ;
    echo $$FILES one ;
    echo $$FILES two





    share|improve this answer




























      -1














      Move the assignment inside the recipe



      test:
      FILES=$$(ls) ;
      echo $$FILES one ;
      echo $$FILES two





      share|improve this answer


























        -1












        -1








        -1







        Move the assignment inside the recipe



        test:
        FILES=$$(ls) ;
        echo $$FILES one ;
        echo $$FILES two





        share|improve this answer













        Move the assignment inside the recipe



        test:
        FILES=$$(ls) ;
        echo $$FILES one ;
        echo $$FILES two






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 '18 at 7:21









        user657267user657267

        17.3k53160




        17.3k53160















            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?