A "prerequisite" is a file that is used as input to create the target. A target can also be the name of an action to carry out, such as `clean'. Finally, if any source file has been recompiled, all the object files, whether newly made or obtained from previous compilations, must be linked together to produce the new executable file.Ī simple makefile consists of "rules" with the following shape:Ī "target" is usually the name of a file that is generated by a program examples of targets are executable or object files. Each compilation produces an object file corresponding to the source file (with extension. If a module file has changed (which holds global parameters accesed by other files), each F90 source file that includes this module file must be recompiled as well. When `make' recompiles the program, each changed F90 source file must be recompiled as well. All F90 source files need to be compiled and linked together in order to produce the executable file which runs the program. ![]() Let's say (for the sake of complexity) that one of these F90 source files is a module which holds global varibles, functions and subroutines that are seen from other subroutines (or functions) contained in other F90 source files. The makefile can also tell `make' how to run miscellaneous commands when explicitly asked (for example, to remove certain files as a clean-up operation). We will discuss only a simple makefiles that describe how to compile and link a fortran program which consists of several Fortran 90/95 source files. Most often, the makefile tells `make' how to compile and link a program. You need a file called a "makefile" to tell `make' what to do. For each of those files, it issues the commands recorded in the data base. The `make' program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated. Each of these makefiles can be completely different from each other. Where 'name' stands for the name of the makefile file that you want to use. If you have several makefile files in the same project workspace / directory (default makefile file will be named: makefile), and some of these makefile files have different names, then you can execute them (specify which makefile you want to use) with the following command: Suffices to perform all necessary recompilations. Once a suitable makefile exists, each time you change some source files, this simple shell command: In a program, typically, the executable file is updated from object files, which are in turn made by compiling source files. To prepare to use `make', you must write a file called the "makefile" that describes the relationships among files in your program and provides commands for updating each file. ![]() ![]() Here is a basic description of the GNU make utility. You can use it to describe any task where some files must be updated automatically from others whenever the others change. Indeed, 'make' is not limited to programs. Our examples show Fortran (F90/95) programs, but you can use `make' with any programming language (for example: C or C++) whose compiler can be run with a shell command. The GNU `make' utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program. Make gets its knowledge of how to build your program from a file Gearscalled the makefile, which lists each of the non-source files and how to compute it from other files. Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. It could be adapted, with some modifications, to other programming languages as well. This tutorial is about creating makefiles for the Fortran 90/95 projects on Linux OS.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |