Basics on GNU autotools developing environment

Source: Internet
Author: User
Tags mathematical functions automake

GNU autotools will be considered as the ideal tool to manage Fortran project after creating a basic program structure by using Eclipse IDE. eclipse IDE is quite convenient for developing a simple project, however, only one target binary can be generated, I. e. A single binary executable or library. therefore, it is still not good enough to manage a large or a collaborated project in which a couple of binaries shoshould be generated with varous types, such as executable binaries, static or shared libraries and test programs. one more comment shoshould be added here: for a collaborated project, each team member has his own scope of module to be implemented and modules contributed from different members shocould cooperate seamlessly. this usually requires each Member write his own test code to ensure quality and validity of the program. therefore, there must be at least a couple of executable binaries in a collaborated project, which can't be directly handled by Eclipse IDE. this is what GNU autotools aim.

GNU autotools comprise two parts: Autoconf and automake. autoconf is used to create automation scripts for creating system tests (such as dependencies on some header files, libraries, etc .) and tolerations which are adapted to different system ubuntures. hence, the source code can be made cross-platform. automake is useful for transforming a user maintained FileMakefile. AMIntoMakefile. InBy conforming to GNU make standard. makefile plays the core role to record source code file dependencies and to determine the execution process of compiler and linker. in the following, only the concept of dependency tree is described, which provides you with most of the underlying ideas about what GNU make is.

If we want to compile a program executing some mathematical calculations, we create a file named main. f90, which contains the source code of main program. let's assume that main. f90 depends on two modules: mathfunc and defs. mathfunc is defined and implemented in mathfunc. f90 and it contains user defined mathematical functions and constants. defs is defined and implemented in defs. f90 and it contains some special ID numbers for the standard I/O and other files. furthermore, module mathfunc depends on defs because some constants defined in defs may be used. with these relations, a dependency tree can be generated as in Figure 1. we can see that a FORTRAN source file is compiled into an object file (*. o) and object files are linked into a binary file main.exe. if a module is defined in a source file, *. MOD file will also be generated. this *. MOD file contains information about function, subroutine and variable declarations, which is equivalent to header file in C or C ++ with the difference that it is automatically generated by Fortran compiler.

After the dependency relation is clear, GNU make takes over the responsibility to ensure that if any node in the dependency tree has some changes, then this node and all of its parent nodes will be recompiled and the generated object files will be relinked into the final binary target. during this procedure, file timestamp is used to determine if there is any file changes and it is obvious to see that only requisite Compiling is already med by GNU make, which will greatly reduce the compiling time when the project gradually becomes larger.

With the above short introductions, we 've got a basic concept of program development by using GNU tool chains. And this lays out a foundation for possible detailed learning of Autoconf and automake in the future.

Figure 1 dependency tree

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.