What are the advantages of using `make` for small projects? [on hold]IDE for large, multi-language projects...

En passant for beginners

Everyone is beautiful

How can I deal with a significant flaw I found in my previous supervisor’s paper?

Can you earn endless XP using a Flameskull and its self-revival feature?

Why do neural networks need so many training examples to perform?

What is the wife of a henpecked husband called?

What is better: yes / no radio, or simple checkbox?

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?

Inalienable or irrefutable

What is the time complexity of enqueue and dequeue of a queue implemented with a singly linked list?

The vanishing of sum of coefficients: symmetric polynomials

Does Windows 10's telemetry include sending *.doc files if Word crashed?

Am I using the wrong word all along?

Does the "particle exchange" operator have any validity?

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Is there a kind of consulting service in Buddhism?

Why zero tolerance on nudity in space?

Why is button three on trumpet almost never used alone?

Dilemma of explaining to interviewer that he is the reason for declining second interview

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

What happens if a wizard reaches level 20 but has no 3rd-level spells that they can use with the Signature Spells feature?

How can I introduce myself to a party without saying that I am a rogue?

What does conditioning on a random variable mean?



What are the advantages of using `make` for small projects? [on hold]


IDE for large, multi-language projects (ie linux kernel)Make Completion Progress Scriptuse bash to pass 2 variables to a MakefileInvoke python script through make commandWhat is the best approach with checking dependencies for third party library during compilation from the sources?How does this Makefile makes C program without even specifying a compiler?make unable to recurse for autoconf-like projectsWhy don't here strings in Makefiles using Bash work?module makefile fails for armv7l when modules are compressedWhat microarchitecture are packages on apt/yum typically built/tuned for?













8















I've seen that make is useful for large projects, especially with confusing dependencies described in a Makefile, and also helping with workflow. 
I haven't heard any advantages for using make for small projects. 
Are there any?










share|improve this question









New contributor




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











put on hold as primarily opinion-based by Kusalananda, Rui F Ribeiro, Stephen Harris, l0b0, Vlastimil 4 hours ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    optimism for growth? :) good habits? This might stray into opinion territory.

    – Jeff Schaller
    21 hours ago











  • type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

    – user2497
    19 hours ago











  • they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

    – Eevee
    18 hours ago











  • I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

    – Jennifer
    17 hours ago






  • 1





    Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

    – Stephen Harris
    12 hours ago


















8















I've seen that make is useful for large projects, especially with confusing dependencies described in a Makefile, and also helping with workflow. 
I haven't heard any advantages for using make for small projects. 
Are there any?










share|improve this question









New contributor




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











put on hold as primarily opinion-based by Kusalananda, Rui F Ribeiro, Stephen Harris, l0b0, Vlastimil 4 hours ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    optimism for growth? :) good habits? This might stray into opinion territory.

    – Jeff Schaller
    21 hours ago











  • type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

    – user2497
    19 hours ago











  • they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

    – Eevee
    18 hours ago











  • I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

    – Jennifer
    17 hours ago






  • 1





    Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

    – Stephen Harris
    12 hours ago
















8












8








8


1






I've seen that make is useful for large projects, especially with confusing dependencies described in a Makefile, and also helping with workflow. 
I haven't heard any advantages for using make for small projects. 
Are there any?










share|improve this question









New contributor




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












I've seen that make is useful for large projects, especially with confusing dependencies described in a Makefile, and also helping with workflow. 
I haven't heard any advantages for using make for small projects. 
Are there any?







scripting compiling make development






share|improve this question









New contributor




Goodwin Lu 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 question









New contributor




Goodwin Lu 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 question




share|improve this question








edited 14 hours ago









G-Man

13.3k93667




13.3k93667






New contributor




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









asked 21 hours ago









Goodwin LuGoodwin Lu

434




434




New contributor




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





New contributor





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






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




put on hold as primarily opinion-based by Kusalananda, Rui F Ribeiro, Stephen Harris, l0b0, Vlastimil 4 hours ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









put on hold as primarily opinion-based by Kusalananda, Rui F Ribeiro, Stephen Harris, l0b0, Vlastimil 4 hours ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2





    optimism for growth? :) good habits? This might stray into opinion territory.

    – Jeff Schaller
    21 hours ago











  • type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

    – user2497
    19 hours ago











  • they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

    – Eevee
    18 hours ago











  • I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

    – Jennifer
    17 hours ago






  • 1





    Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

    – Stephen Harris
    12 hours ago
















  • 2





    optimism for growth? :) good habits? This might stray into opinion territory.

    – Jeff Schaller
    21 hours ago











  • type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

    – user2497
    19 hours ago











  • they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

    – Eevee
    18 hours ago











  • I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

    – Jennifer
    17 hours ago






  • 1





    Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

    – Stephen Harris
    12 hours ago










2




2





optimism for growth? :) good habits? This might stray into opinion territory.

– Jeff Schaller
21 hours ago





optimism for growth? :) good habits? This might stray into opinion territory.

– Jeff Schaller
21 hours ago













type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

– user2497
19 hours ago





type make to discover the answer. make a decent template Makefile and just edit its source files variable. no need to type all that jazz.

– user2497
19 hours ago













they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

– Eevee
18 hours ago





they're kind of a nightmare for large projects, so honestly, i'd say they're only good for small projects ;)

– Eevee
18 hours ago













I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

– Jennifer
17 hours ago





I could use makefiles, but I don't. I've divided my source code for my biggest (personal) project into 10 files, recompile the first, and the first has #includes for the other nine. With the speed of recompilation, it doesn't matter to me if it all gets recompiled every time.

– Jennifer
17 hours ago




1




1





Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

– Stephen Harris
12 hours ago







Laziness :-) make is so much quicker a command to type than most others, even if you don't create a smart Makefile to handle dependencies cleanly :-)

– Stephen Harris
12 hours ago












6 Answers
6






active

oldest

votes


















10














As opposed to what?



Suppose you have a program that you have split into two files,
which you have imaginatively named file1.c and file2.c
You can compile the program by running



cc file1.c file2.c -o yourprogram


But this requires recompiling both files every time,
even if only one has changed. 
You can decompose the compilation steps into



cc -c file1.c
cc -c file2.c
cc file1.o file2.o -o yourprogram


and then, when you edit one of the files, recompile only that file
(and perform the linking step no matter what you changed). 
But what if you edit one file, and then the other,
and you forget that you edited both files,
and accidentally recompile only one?



Also, even for just two files,
you’ve got about 60 characters’ worth of commands there. 
That quickly gets tedious to type. 
OK, sure, you could put them into a script,
but then you’re back to recompiling every time. 
Or you could write a really fancy, complicated script that checks
what file(s) had been modified and does only the necessary compilations. 
Do you see where I’m going with this?






share|improve this answer
























  • For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

    – Peter Cordes
    17 hours ago






  • 2





    Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

    – Roger Lipscombe
    16 hours ago











  • @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

    – jamesqf
    13 hours ago



















14














A lot of other people are getting into the details of more complex makefiles and a lot of the complexity that comes with them. I typically use makefiles for a completely different reason:



I don't want to remember anything.



Even if your project is really boring and simple, and you don't use makefiles "correctly":



all:
gcc main.c -o project


I don't need to think about it or treat it any differently than a project that's more complex:



all:
gcc libA.c libB.c main.c -o project2


Or if I specified flags (e.g. -O2) I don't need to remember what they were.



Also, if you start with a simple makefile, and you need to merge/refactor things later, you don't need to remember to build every project differently.






share|improve this answer































    5














    Even with small project it can be helpful keeping the dependency logic under control and builds automated. I also used it to trigger installs and deinstallations, so it was a main switch resetting the stage.






    share|improve this answer































      3














      If you link your app from 2 sources (.c files) , you do not need to recompile each file, but only the changed one if you are using make.



      Also, I will give you example from BSD world. They have framework of system-based Makefiles. They provide you paths to system directories and have targets to install your software and manual pages.



      For example, you just wrote beer.c app and manual for it called beer.6.
      You create Makefile:



      PROG=   beer
      MAN= beer.6

      .include <bsd.prog.mk>


      ..and call make install. It automatically compiles and installs your app to /usr/bin and compiles and installs your man page to the place where man can find it. You just installed your app with one simple command!



      Very convenient and absolutely transparent for anyone who is familiar with BSD.
      Much better than manual script.






      share|improve this answer































        0














        make is pretty reliably available. If you distribute your project with a makefile, users will have a simple reference for how to achieve tasks in the same way you do. The makefile can be for more than just compilation.



        Take a project that doesn't require compilation, for example. I recall working on a Python project that had a make command to clear out all the .pyc files, a make command to run the tests, one to download a copy of the static data from the development server, etc.






        share|improve this answer








        New contributor




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




























          0














          Example Makefile for my very small project: getPixelColor



          It does exactly what its name says, taking two optional arguments, the coordinates.



          I especially like the way things get dependent there.





          COORDS ?= 0 0

          CXX := g++-8
          CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
          LDLIBS := -lX11
          RM := rm -f

          BIN := getPixelColor
          SRC := $(BIN).cpp

          $(BIN): $(SRC)
          $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDLIBS)

          .PHONY: clean
          clean:
          $(RM) $(BIN)

          .PHONY: run
          run: $(BIN)
          ./$(BIN) $(COORDS)


          As you can see, it can do all you need, without typing anything extra:





          Usage



          You can run it these ways:





          1. Clean-up the old binary:



            make clean



          2. Compile a new binary:



            make



          3. Run the executable in 2 ways:





            • the default coordinates [0,0]



              make run     # equals COORDS='0 0'



            • any given coordinates



              COORDS='5 6' make run







          Makefiles can be extremely helpful at times. The bigger the project, the bigger the benefit. But even with that my smallest C++ project, as you can see on examples saves you a lot of headaches.






          share|improve this answer
































            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            10














            As opposed to what?



            Suppose you have a program that you have split into two files,
            which you have imaginatively named file1.c and file2.c
            You can compile the program by running



            cc file1.c file2.c -o yourprogram


            But this requires recompiling both files every time,
            even if only one has changed. 
            You can decompose the compilation steps into



            cc -c file1.c
            cc -c file2.c
            cc file1.o file2.o -o yourprogram


            and then, when you edit one of the files, recompile only that file
            (and perform the linking step no matter what you changed). 
            But what if you edit one file, and then the other,
            and you forget that you edited both files,
            and accidentally recompile only one?



            Also, even for just two files,
            you’ve got about 60 characters’ worth of commands there. 
            That quickly gets tedious to type. 
            OK, sure, you could put them into a script,
            but then you’re back to recompiling every time. 
            Or you could write a really fancy, complicated script that checks
            what file(s) had been modified and does only the necessary compilations. 
            Do you see where I’m going with this?






            share|improve this answer
























            • For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

              – Peter Cordes
              17 hours ago






            • 2





              Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

              – Roger Lipscombe
              16 hours ago











            • @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

              – jamesqf
              13 hours ago
















            10














            As opposed to what?



            Suppose you have a program that you have split into two files,
            which you have imaginatively named file1.c and file2.c
            You can compile the program by running



            cc file1.c file2.c -o yourprogram


            But this requires recompiling both files every time,
            even if only one has changed. 
            You can decompose the compilation steps into



            cc -c file1.c
            cc -c file2.c
            cc file1.o file2.o -o yourprogram


            and then, when you edit one of the files, recompile only that file
            (and perform the linking step no matter what you changed). 
            But what if you edit one file, and then the other,
            and you forget that you edited both files,
            and accidentally recompile only one?



            Also, even for just two files,
            you’ve got about 60 characters’ worth of commands there. 
            That quickly gets tedious to type. 
            OK, sure, you could put them into a script,
            but then you’re back to recompiling every time. 
            Or you could write a really fancy, complicated script that checks
            what file(s) had been modified and does only the necessary compilations. 
            Do you see where I’m going with this?






            share|improve this answer
























            • For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

              – Peter Cordes
              17 hours ago






            • 2





              Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

              – Roger Lipscombe
              16 hours ago











            • @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

              – jamesqf
              13 hours ago














            10












            10








            10







            As opposed to what?



            Suppose you have a program that you have split into two files,
            which you have imaginatively named file1.c and file2.c
            You can compile the program by running



            cc file1.c file2.c -o yourprogram


            But this requires recompiling both files every time,
            even if only one has changed. 
            You can decompose the compilation steps into



            cc -c file1.c
            cc -c file2.c
            cc file1.o file2.o -o yourprogram


            and then, when you edit one of the files, recompile only that file
            (and perform the linking step no matter what you changed). 
            But what if you edit one file, and then the other,
            and you forget that you edited both files,
            and accidentally recompile only one?



            Also, even for just two files,
            you’ve got about 60 characters’ worth of commands there. 
            That quickly gets tedious to type. 
            OK, sure, you could put them into a script,
            but then you’re back to recompiling every time. 
            Or you could write a really fancy, complicated script that checks
            what file(s) had been modified and does only the necessary compilations. 
            Do you see where I’m going with this?






            share|improve this answer













            As opposed to what?



            Suppose you have a program that you have split into two files,
            which you have imaginatively named file1.c and file2.c
            You can compile the program by running



            cc file1.c file2.c -o yourprogram


            But this requires recompiling both files every time,
            even if only one has changed. 
            You can decompose the compilation steps into



            cc -c file1.c
            cc -c file2.c
            cc file1.o file2.o -o yourprogram


            and then, when you edit one of the files, recompile only that file
            (and perform the linking step no matter what you changed). 
            But what if you edit one file, and then the other,
            and you forget that you edited both files,
            and accidentally recompile only one?



            Also, even for just two files,
            you’ve got about 60 characters’ worth of commands there. 
            That quickly gets tedious to type. 
            OK, sure, you could put them into a script,
            but then you’re back to recompiling every time. 
            Or you could write a really fancy, complicated script that checks
            what file(s) had been modified and does only the necessary compilations. 
            Do you see where I’m going with this?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 20 hours ago









            G-ManG-Man

            13.3k93667




            13.3k93667













            • For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

              – Peter Cordes
              17 hours ago






            • 2





              Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

              – Roger Lipscombe
              16 hours ago











            • @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

              – jamesqf
              13 hours ago



















            • For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

              – Peter Cordes
              17 hours ago






            • 2





              Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

              – Roger Lipscombe
              16 hours ago











            • @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

              – jamesqf
              13 hours ago

















            For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

            – Peter Cordes
            17 hours ago





            For very small projects, gcc -O3 -march=native -fwhole-program *.c is basically fine for an edit / compile / profile cycle. But you still want a Makefile for other people to use. Being able to use -fwhole-program is a fun advantage of compiling everything together, but -flto normally gives you pretty much the same optimizations.

            – Peter Cordes
            17 hours ago




            2




            2





            Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

            – Roger Lipscombe
            16 hours ago





            Once I start adding switches to the compiler command line (even for one source file), I find it gets tricky to remember them the next time. Occasionally I'll just put a comment in the source file, but at that point I should just use a Makefile...

            – Roger Lipscombe
            16 hours ago













            @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

            – jamesqf
            13 hours ago





            @ger Lipscombe: And if you need to compile for different environments, it's as simple as defining a few macros in your makefile. And with a little creativity, you can hook the make command to an editior function key, capture the output in a file, and use another key to put you at the position of any errors...

            – jamesqf
            13 hours ago













            14














            A lot of other people are getting into the details of more complex makefiles and a lot of the complexity that comes with them. I typically use makefiles for a completely different reason:



            I don't want to remember anything.



            Even if your project is really boring and simple, and you don't use makefiles "correctly":



            all:
            gcc main.c -o project


            I don't need to think about it or treat it any differently than a project that's more complex:



            all:
            gcc libA.c libB.c main.c -o project2


            Or if I specified flags (e.g. -O2) I don't need to remember what they were.



            Also, if you start with a simple makefile, and you need to merge/refactor things later, you don't need to remember to build every project differently.






            share|improve this answer




























              14














              A lot of other people are getting into the details of more complex makefiles and a lot of the complexity that comes with them. I typically use makefiles for a completely different reason:



              I don't want to remember anything.



              Even if your project is really boring and simple, and you don't use makefiles "correctly":



              all:
              gcc main.c -o project


              I don't need to think about it or treat it any differently than a project that's more complex:



              all:
              gcc libA.c libB.c main.c -o project2


              Or if I specified flags (e.g. -O2) I don't need to remember what they were.



              Also, if you start with a simple makefile, and you need to merge/refactor things later, you don't need to remember to build every project differently.






              share|improve this answer


























                14












                14








                14







                A lot of other people are getting into the details of more complex makefiles and a lot of the complexity that comes with them. I typically use makefiles for a completely different reason:



                I don't want to remember anything.



                Even if your project is really boring and simple, and you don't use makefiles "correctly":



                all:
                gcc main.c -o project


                I don't need to think about it or treat it any differently than a project that's more complex:



                all:
                gcc libA.c libB.c main.c -o project2


                Or if I specified flags (e.g. -O2) I don't need to remember what they were.



                Also, if you start with a simple makefile, and you need to merge/refactor things later, you don't need to remember to build every project differently.






                share|improve this answer













                A lot of other people are getting into the details of more complex makefiles and a lot of the complexity that comes with them. I typically use makefiles for a completely different reason:



                I don't want to remember anything.



                Even if your project is really boring and simple, and you don't use makefiles "correctly":



                all:
                gcc main.c -o project


                I don't need to think about it or treat it any differently than a project that's more complex:



                all:
                gcc libA.c libB.c main.c -o project2


                Or if I specified flags (e.g. -O2) I don't need to remember what they were.



                Also, if you start with a simple makefile, and you need to merge/refactor things later, you don't need to remember to build every project differently.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 14 hours ago









                Stack TracerStack Tracer

                24116




                24116























                    5














                    Even with small project it can be helpful keeping the dependency logic under control and builds automated. I also used it to trigger installs and deinstallations, so it was a main switch resetting the stage.






                    share|improve this answer




























                      5














                      Even with small project it can be helpful keeping the dependency logic under control and builds automated. I also used it to trigger installs and deinstallations, so it was a main switch resetting the stage.






                      share|improve this answer


























                        5












                        5








                        5







                        Even with small project it can be helpful keeping the dependency logic under control and builds automated. I also used it to trigger installs and deinstallations, so it was a main switch resetting the stage.






                        share|improve this answer













                        Even with small project it can be helpful keeping the dependency logic under control and builds automated. I also used it to trigger installs and deinstallations, so it was a main switch resetting the stage.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 20 hours ago









                        TomaszTomasz

                        9,94952966




                        9,94952966























                            3














                            If you link your app from 2 sources (.c files) , you do not need to recompile each file, but only the changed one if you are using make.



                            Also, I will give you example from BSD world. They have framework of system-based Makefiles. They provide you paths to system directories and have targets to install your software and manual pages.



                            For example, you just wrote beer.c app and manual for it called beer.6.
                            You create Makefile:



                            PROG=   beer
                            MAN= beer.6

                            .include <bsd.prog.mk>


                            ..and call make install. It automatically compiles and installs your app to /usr/bin and compiles and installs your man page to the place where man can find it. You just installed your app with one simple command!



                            Very convenient and absolutely transparent for anyone who is familiar with BSD.
                            Much better than manual script.






                            share|improve this answer




























                              3














                              If you link your app from 2 sources (.c files) , you do not need to recompile each file, but only the changed one if you are using make.



                              Also, I will give you example from BSD world. They have framework of system-based Makefiles. They provide you paths to system directories and have targets to install your software and manual pages.



                              For example, you just wrote beer.c app and manual for it called beer.6.
                              You create Makefile:



                              PROG=   beer
                              MAN= beer.6

                              .include <bsd.prog.mk>


                              ..and call make install. It automatically compiles and installs your app to /usr/bin and compiles and installs your man page to the place where man can find it. You just installed your app with one simple command!



                              Very convenient and absolutely transparent for anyone who is familiar with BSD.
                              Much better than manual script.






                              share|improve this answer


























                                3












                                3








                                3







                                If you link your app from 2 sources (.c files) , you do not need to recompile each file, but only the changed one if you are using make.



                                Also, I will give you example from BSD world. They have framework of system-based Makefiles. They provide you paths to system directories and have targets to install your software and manual pages.



                                For example, you just wrote beer.c app and manual for it called beer.6.
                                You create Makefile:



                                PROG=   beer
                                MAN= beer.6

                                .include <bsd.prog.mk>


                                ..and call make install. It automatically compiles and installs your app to /usr/bin and compiles and installs your man page to the place where man can find it. You just installed your app with one simple command!



                                Very convenient and absolutely transparent for anyone who is familiar with BSD.
                                Much better than manual script.






                                share|improve this answer













                                If you link your app from 2 sources (.c files) , you do not need to recompile each file, but only the changed one if you are using make.



                                Also, I will give you example from BSD world. They have framework of system-based Makefiles. They provide you paths to system directories and have targets to install your software and manual pages.



                                For example, you just wrote beer.c app and manual for it called beer.6.
                                You create Makefile:



                                PROG=   beer
                                MAN= beer.6

                                .include <bsd.prog.mk>


                                ..and call make install. It automatically compiles and installs your app to /usr/bin and compiles and installs your man page to the place where man can find it. You just installed your app with one simple command!



                                Very convenient and absolutely transparent for anyone who is familiar with BSD.
                                Much better than manual script.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 15 hours ago









                                user996142user996142

                                43739




                                43739























                                    0














                                    make is pretty reliably available. If you distribute your project with a makefile, users will have a simple reference for how to achieve tasks in the same way you do. The makefile can be for more than just compilation.



                                    Take a project that doesn't require compilation, for example. I recall working on a Python project that had a make command to clear out all the .pyc files, a make command to run the tests, one to download a copy of the static data from the development server, etc.






                                    share|improve this answer








                                    New contributor




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

























                                      0














                                      make is pretty reliably available. If you distribute your project with a makefile, users will have a simple reference for how to achieve tasks in the same way you do. The makefile can be for more than just compilation.



                                      Take a project that doesn't require compilation, for example. I recall working on a Python project that had a make command to clear out all the .pyc files, a make command to run the tests, one to download a copy of the static data from the development server, etc.






                                      share|improve this answer








                                      New contributor




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























                                        0












                                        0








                                        0







                                        make is pretty reliably available. If you distribute your project with a makefile, users will have a simple reference for how to achieve tasks in the same way you do. The makefile can be for more than just compilation.



                                        Take a project that doesn't require compilation, for example. I recall working on a Python project that had a make command to clear out all the .pyc files, a make command to run the tests, one to download a copy of the static data from the development server, etc.






                                        share|improve this answer








                                        New contributor




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










                                        make is pretty reliably available. If you distribute your project with a makefile, users will have a simple reference for how to achieve tasks in the same way you do. The makefile can be for more than just compilation.



                                        Take a project that doesn't require compilation, for example. I recall working on a Python project that had a make command to clear out all the .pyc files, a make command to run the tests, one to download a copy of the static data from the development server, etc.







                                        share|improve this answer








                                        New contributor




                                        Adam Barnes 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






                                        New contributor




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









                                        answered 11 hours ago









                                        Adam BarnesAdam Barnes

                                        1011




                                        1011




                                        New contributor




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





                                        New contributor





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






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























                                            0














                                            Example Makefile for my very small project: getPixelColor



                                            It does exactly what its name says, taking two optional arguments, the coordinates.



                                            I especially like the way things get dependent there.





                                            COORDS ?= 0 0

                                            CXX := g++-8
                                            CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
                                            LDLIBS := -lX11
                                            RM := rm -f

                                            BIN := getPixelColor
                                            SRC := $(BIN).cpp

                                            $(BIN): $(SRC)
                                            $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDLIBS)

                                            .PHONY: clean
                                            clean:
                                            $(RM) $(BIN)

                                            .PHONY: run
                                            run: $(BIN)
                                            ./$(BIN) $(COORDS)


                                            As you can see, it can do all you need, without typing anything extra:





                                            Usage



                                            You can run it these ways:





                                            1. Clean-up the old binary:



                                              make clean



                                            2. Compile a new binary:



                                              make



                                            3. Run the executable in 2 ways:





                                              • the default coordinates [0,0]



                                                make run     # equals COORDS='0 0'



                                              • any given coordinates



                                                COORDS='5 6' make run







                                            Makefiles can be extremely helpful at times. The bigger the project, the bigger the benefit. But even with that my smallest C++ project, as you can see on examples saves you a lot of headaches.






                                            share|improve this answer






























                                              0














                                              Example Makefile for my very small project: getPixelColor



                                              It does exactly what its name says, taking two optional arguments, the coordinates.



                                              I especially like the way things get dependent there.





                                              COORDS ?= 0 0

                                              CXX := g++-8
                                              CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
                                              LDLIBS := -lX11
                                              RM := rm -f

                                              BIN := getPixelColor
                                              SRC := $(BIN).cpp

                                              $(BIN): $(SRC)
                                              $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDLIBS)

                                              .PHONY: clean
                                              clean:
                                              $(RM) $(BIN)

                                              .PHONY: run
                                              run: $(BIN)
                                              ./$(BIN) $(COORDS)


                                              As you can see, it can do all you need, without typing anything extra:





                                              Usage



                                              You can run it these ways:





                                              1. Clean-up the old binary:



                                                make clean



                                              2. Compile a new binary:



                                                make



                                              3. Run the executable in 2 ways:





                                                • the default coordinates [0,0]



                                                  make run     # equals COORDS='0 0'



                                                • any given coordinates



                                                  COORDS='5 6' make run







                                              Makefiles can be extremely helpful at times. The bigger the project, the bigger the benefit. But even with that my smallest C++ project, as you can see on examples saves you a lot of headaches.






                                              share|improve this answer




























                                                0












                                                0








                                                0







                                                Example Makefile for my very small project: getPixelColor



                                                It does exactly what its name says, taking two optional arguments, the coordinates.



                                                I especially like the way things get dependent there.





                                                COORDS ?= 0 0

                                                CXX := g++-8
                                                CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
                                                LDLIBS := -lX11
                                                RM := rm -f

                                                BIN := getPixelColor
                                                SRC := $(BIN).cpp

                                                $(BIN): $(SRC)
                                                $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDLIBS)

                                                .PHONY: clean
                                                clean:
                                                $(RM) $(BIN)

                                                .PHONY: run
                                                run: $(BIN)
                                                ./$(BIN) $(COORDS)


                                                As you can see, it can do all you need, without typing anything extra:





                                                Usage



                                                You can run it these ways:





                                                1. Clean-up the old binary:



                                                  make clean



                                                2. Compile a new binary:



                                                  make



                                                3. Run the executable in 2 ways:





                                                  • the default coordinates [0,0]



                                                    make run     # equals COORDS='0 0'



                                                  • any given coordinates



                                                    COORDS='5 6' make run







                                                Makefiles can be extremely helpful at times. The bigger the project, the bigger the benefit. But even with that my smallest C++ project, as you can see on examples saves you a lot of headaches.






                                                share|improve this answer















                                                Example Makefile for my very small project: getPixelColor



                                                It does exactly what its name says, taking two optional arguments, the coordinates.



                                                I especially like the way things get dependent there.





                                                COORDS ?= 0 0

                                                CXX := g++-8
                                                CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
                                                LDLIBS := -lX11
                                                RM := rm -f

                                                BIN := getPixelColor
                                                SRC := $(BIN).cpp

                                                $(BIN): $(SRC)
                                                $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDLIBS)

                                                .PHONY: clean
                                                clean:
                                                $(RM) $(BIN)

                                                .PHONY: run
                                                run: $(BIN)
                                                ./$(BIN) $(COORDS)


                                                As you can see, it can do all you need, without typing anything extra:





                                                Usage



                                                You can run it these ways:





                                                1. Clean-up the old binary:



                                                  make clean



                                                2. Compile a new binary:



                                                  make



                                                3. Run the executable in 2 ways:





                                                  • the default coordinates [0,0]



                                                    make run     # equals COORDS='0 0'



                                                  • any given coordinates



                                                    COORDS='5 6' make run







                                                Makefiles can be extremely helpful at times. The bigger the project, the bigger the benefit. But even with that my smallest C++ project, as you can see on examples saves you a lot of headaches.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 4 hours ago

























                                                answered 5 hours ago









                                                VlastimilVlastimil

                                                8,1311464139




                                                8,1311464139















                                                    Popular posts from this blog

                                                    El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

                                                    Castillo d'Acher Características Menú de navegación

                                                    Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...