How to run make file from any directory?











up vote
1
down vote

favorite












In order to run make file, I am supposed to go to the make file's directory and from there only I can run the make file. How can I do the same even if i am in any directory?










share|improve this question


















  • 1




    Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
    – JdeBP
    Dec 23 '11 at 13:43















up vote
1
down vote

favorite












In order to run make file, I am supposed to go to the make file's directory and from there only I can run the make file. How can I do the same even if i am in any directory?










share|improve this question


















  • 1




    Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
    – JdeBP
    Dec 23 '11 at 13:43













up vote
1
down vote

favorite









up vote
1
down vote

favorite











In order to run make file, I am supposed to go to the make file's directory and from there only I can run the make file. How can I do the same even if i am in any directory?










share|improve this question













In order to run make file, I am supposed to go to the make file's directory and from there only I can run the make file. How can I do the same even if i am in any directory?







make makefile






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 22 '11 at 9:26









Dinesh

144118




144118








  • 1




    Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
    – JdeBP
    Dec 23 '11 at 13:43














  • 1




    Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
    – JdeBP
    Dec 23 '11 at 13:43








1




1




Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
– JdeBP
Dec 23 '11 at 13:43




Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example.
– JdeBP
Dec 23 '11 at 13:43










3 Answers
3






active

oldest

votes

















up vote
6
down vote



accepted










(cd /other/dir && make)


will not change your shell's current directory, but will run make with the indicated working directory.



The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).






share|improve this answer



















  • 6




    Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
    – Noyo
    Oct 24 '13 at 13:34


















up vote
3
down vote













make -C dir


Change to directory dir before reading the pointed makefile.






share|improve this answer






























    up vote
    0
    down vote













    Use cd ./dir && make && pwd inside Makefile .



    Example of sample Makefile :



    BUILD_DIR       =       $(shell pwd)

    deploy::
    cd ./dist/local && make && pwd && npm publish && cd .. && cd .. && pwd
    clean::
    npm cache clean --force





    share|improve this answer










    New contributor




    Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f370575%2fhow-to-run-make-file-from-any-directory%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      6
      down vote



      accepted










      (cd /other/dir && make)


      will not change your shell's current directory, but will run make with the indicated working directory.



      The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).






      share|improve this answer



















      • 6




        Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
        – Noyo
        Oct 24 '13 at 13:34















      up vote
      6
      down vote



      accepted










      (cd /other/dir && make)


      will not change your shell's current directory, but will run make with the indicated working directory.



      The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).






      share|improve this answer



















      • 6




        Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
        – Noyo
        Oct 24 '13 at 13:34













      up vote
      6
      down vote



      accepted







      up vote
      6
      down vote



      accepted






      (cd /other/dir && make)


      will not change your shell's current directory, but will run make with the indicated working directory.



      The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).






      share|improve this answer














      (cd /other/dir && make)


      will not change your shell's current directory, but will run make with the indicated working directory.



      The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Oct 24 '13 at 14:06









      Scott

      15.4k113789




      15.4k113789










      answered Dec 22 '11 at 9:34









      RedGrittyBrick

      66.3k12104159




      66.3k12104159








      • 6




        Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
        – Noyo
        Oct 24 '13 at 13:34














      • 6




        Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
        – Noyo
        Oct 24 '13 at 13:34








      6




      6




      Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
      – Noyo
      Oct 24 '13 at 13:34




      Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774
      – Noyo
      Oct 24 '13 at 13:34












      up vote
      3
      down vote













      make -C dir


      Change to directory dir before reading the pointed makefile.






      share|improve this answer



























        up vote
        3
        down vote













        make -C dir


        Change to directory dir before reading the pointed makefile.






        share|improve this answer

























          up vote
          3
          down vote










          up vote
          3
          down vote









          make -C dir


          Change to directory dir before reading the pointed makefile.






          share|improve this answer














          make -C dir


          Change to directory dir before reading the pointed makefile.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 12 '17 at 7:53









          Kamil Maciorowski

          22.3k155072




          22.3k155072










          answered Oct 12 '17 at 7:26









          Jonathan

          1311




          1311






















              up vote
              0
              down vote













              Use cd ./dir && make && pwd inside Makefile .



              Example of sample Makefile :



              BUILD_DIR       =       $(shell pwd)

              deploy::
              cd ./dist/local && make && pwd && npm publish && cd .. && cd .. && pwd
              clean::
              npm cache clean --force





              share|improve this answer










              New contributor




              Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                up vote
                0
                down vote













                Use cd ./dir && make && pwd inside Makefile .



                Example of sample Makefile :



                BUILD_DIR       =       $(shell pwd)

                deploy::
                cd ./dist/local && make && pwd && npm publish && cd .. && cd .. && pwd
                clean::
                npm cache clean --force





                share|improve this answer










                New contributor




                Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Use cd ./dir && make && pwd inside Makefile .



                  Example of sample Makefile :



                  BUILD_DIR       =       $(shell pwd)

                  deploy::
                  cd ./dist/local && make && pwd && npm publish && cd .. && cd .. && pwd
                  clean::
                  npm cache clean --force





                  share|improve this answer










                  New contributor




                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  Use cd ./dir && make && pwd inside Makefile .



                  Example of sample Makefile :



                  BUILD_DIR       =       $(shell pwd)

                  deploy::
                  cd ./dist/local && make && pwd && npm publish && cd .. && cd .. && pwd
                  clean::
                  npm cache clean --force






                  share|improve this answer










                  New contributor




                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited Nov 13 at 12:05









                  Twisty Impersonator

                  16.5k126090




                  16.5k126090






                  New contributor




                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Nov 13 at 11:35









                  Mahesh Wable

                  1




                  1




                  New contributor




                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Mahesh Wable is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f370575%2fhow-to-run-make-file-from-any-directory%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Probability when a professor distributes a quiz and homework assignment to a class of n students.

                      Aardman Animations

                      Are they similar matrix