Copyright © tutorialspoint.com
The make program is an intelligent utility and works based on the changes you do in your source files. If you have four files main.cpp, hello.cpp, factorial.cpp and functions.h. Here all the reamining files are dependent on functions.h and main.cpp is dependent on hello.cpp and factorical.cpp. So if you make any change in functions.h then make will recompile all the source files to generate new object files. But if you make any change main.cpp, as this is not dependent of any other fil, then in this case only main.cpp file will be recompiled and hellp.cpp and factorial.cpp will not be recompiled. While compiling a file, make checks its object file and comprare the time staps, if source file has newer time stamp than object file then it will generate new object file assuimg that source file has been changed. Avoiding RecompilationThere may be a project consisted of thausands of files. Sometimes you may have changed a source file but you do not want to recompile all the files that depend on it. For example, suppose you add a macro or a declaration to a header file that many other files depend on. Being conservative, make assumes that any change in the header file requires recompilation of all dependent files, but you know that they do not need to be recompiled and you would rather not waste the time waiting for them to compile. If you anticipate the problem before changing the header file, you can use the `-t' flag. This flag tells make not to run the commands in the rules, but rather to mark the target up to date by changing its last-modification date. You would follow this procedure:
If you have already changed the header file at a time when some files do need recompilation, it is too late to do this. Instead, you can use the `-o file' flag, which marks a specified file as "old". This means that the file itself will not be remade, and nothing else will be remade on its account. Follow this procedure:
|
Copyright © tutorialspoint.com