What is the use of make program in UNIX?

The make program plays a very important role in a multiprogramming operating system namely UNIX. When there is more than one file and when changes are made to the files make program keeps track automatically of the changes made to these files and recompile them as and when needed automatically. The make program takes as its input any file name or in general a file named as makefile which has in it descriptions of the name of the files that is sued in the program, their relationships with each other and the way f regeneration if any changes made to the files. Once these are described in the file just when the user gives the make command the makefile is examined and whenever regenerations are needed it is done as per the said explanations in the makefile. Thus make program saves the users from thinking about recompilation when file changes are made as this is taken care automatically by make program as described above.

Let us see this by a small example:

Suppose we have a program named as exforsys which has three 3 files namely e1.c, e2.c and e3.c. Making changes to any the three files would necessarily need the recompilation of the program and there by relinking to the main program exforsys.

Let us see how to handle this situation using make program.

As described above we have a make a makefile as

cat makefile

Inside the makefile one ahs to describe all the program names, their link to each other as namely

exforsys: e1.o e2.o e3.o

cc –o exforsys e1.o e2.o e3.o

e1.o : e1.c

e2.o : e2.c

e3.o : e3.c

Thus in the above if any changes are made to e1.o e2.o e3.o and the method of making these and relinking is given in next tab line. The next line depicts that when changes are made to e1.c then e1.o needs to be made again and so on for e2.o and e3.o.

After all this simply when make command is executed the makefile which must be present in current directory gets executed and handles recompilation and relinking of files as and when needed automatically.

Questions by GeekAdmin   answers by GeekAdmin


This Question is not yet answered!


Related Answered Questions


Related Open Questions