Makefile or makefile is default name for make specification
I recommend that you look at the documentation for make and gmake. Make by default looks for a file named Makefile or makefile for a specification about how to build a program from possibly several pieces using possibly several tools.
One advantage of using make for building your program is that you can put the commands and all needed parameters for the commands in the makefile so you don't need to type in the possibly fussy command line with parameters each time you want to build your project. Instead of typing in all the commands to compile and link your program myprog.c to create the executable file myprog, or even more involved projects that use higher level tools to generate some source files (for example, flex and bison), you simply type
make myprog
and make or gmake sends the commands to build myprog.
Another advantage to using make is that you don't needlessly compile parts of your project where the source files for those parts have not changed since the last time you built the project. That is not such a big deal nowadays, but not compiling some unchanged source files needlessly saved a lot of time when computers were much slower. It also can save a lot of time for large projects, such as ones which involve several tens of thousands of lines or more of source code.
Large programming efforts, for example, compiling a Linux kernel customized for your particular platform, make extensive use of makefiles. Make and gmake can include multiple "targets", or goals in a single makefile. Building a new Linux kernel (after you have installed the source code in the appropriate places on your machine is automated by the makefile or Makefile.
Configure your new kernel using
make menuconfig
and setting up the parts and pieces to match your platform.
Then type
make install
and gmake will create the thousands of command lines needed to produce a new kernel in the appropriate place for you.
Please refer to the instructions for building a custom kernel, however. There may be additional intermediate steps like
make modules
involved.
Depending on the speed of your computer and the options selected, building the kernel may take overnight or longer. But you don't have to be there typing commands to compile every little piece because gmake is doing that for you. Then, the next time you build a kernel but only change a few options, the build process can complete much faster.
|