In: Computer Science
You are a renowned software developer and you have been hired by
an old British boyband that wants to make a comeback in the
industry. They ask you to make an app to showcase their new music
and events. In your implementation, you have a class for each of
the 5 group members, but you find that compiling each
band member’s class takes more time than you currently have.
Luckily, you
remember that you learned about Makefiles in your favorite online
class! You decide to create a Makefile to compile your classes to
make testing more efficient. Since Makefiles can have multiple
rules, write out the general structure of a single rule and explain
how it should be interpreted.
Ans ) make command is used when we want to build(or compile) or run multiple files or programs at a time .The make utility identifies the part of a large program that needs to be recompiled and gives the command to compile or recompile it. make command can be used for a program using the makefile. The makefile tells the compiler about what is to be compiled and the relation between the files in the program. The "make" command which is also called a make utility works by reading the makefile. The make command can be followed by many extensions when giving as a command to the terminal. We can also run "make" command by just typing "make" on the terminal and then the makefile will be looked . If makefile is found then appropriate action can be taken. If it is not found then error messages are shown .
General syntax of make :
make [-f makefile ] [options ...]
Syntax using -f :
make -f 'filename'
Syntax for specific target in the makefile out of many targets :
make target
When a make command is executed you will find that many other files like filename.o and other files are created in the same directory where you have the program on which you are using the makefile. These files are created as a part of compilation and execution of the program and makefiles associated with them. Some of these files are not recreated when it is recompiled when we use 'make' command again. And some of them are recreated when we recompile. In order to start fresh and to remove all those intermediate files created after 'make' command is executed we can make use of clean command.
Syntax of clean:
make clean
To build the programs we can just use make command and we can also use various options for different purposes. e.g. -d options builds the program in debug mode when given as "make -d " command.