Creating a simple fortran Autotools based project

My objective is to include my modules in a big library written in Fortran. To compile and install this library, the autotools suits are used. I can see that including my modules into the source codes of this library (by writing: use myModule) leads to errors indicating that myModule cannot be read. So, this means that I have probably to change other files (such as Makefile.am, Makefile.in, Makefile.mk, Makefile, etc.). So in order to understand the steps and not changing blindly the contents of these files by trial and error, I would like to ask you if you could possibly provide me with some tutorials/videos/PDFs on how to create a simple fortran autotools based project.

P.S.: I posted a question yesterday about “How to make a Fortran Makefiles with object files (.o) and a shared library (.so)?”. This is now clear to me. I don’t know if the next step is reading about Autotools or before that I should learn and read about other tools. But please do not hesitate to provide me with what you think to be useful to achieve my goal which is changing a big library by including my own modules.

1 Like

Welcome to the Forum!

I have a small demo project that might be of some use. It does not cover all the features you mention, nor is there much in the way of explanatory text. I know of no specific tutorials or the like. Unfortunately, uploading a zip file is not allowed, so I attach a shell archive instead.
autofort.sh.txt (52.3 KB)

2 Likes

Hi Mary, welcome to Discourse!

The book 21st Century C by Ben Klemens has a section titled “Packaging Your Code with Autotools” (pg. 79) which offers a short introduction. The Autotools workflow is summarized by the following chart:

Another source of information could be looking at existing Fortran projects using Autotools. One I’m aware of is PSBLAS. A Google search has also led me to AstroBEAR, which offers some materials on the Use [of] GNU Autotools (PDF, 305 kB).

Generally speaking, the issue you encounter with GNU Autotools and Fortran is how to capture the module dependencies. We’ve had a few discussions on that topic already including

Several tools exist to automate generation of these dependencies in the makefile rule format, including compiler built-in ones, makedepf90 or fdep (Autotools specific), however YMMV. Since you say your are contributing to an (existing) big library, it is likely your project already has some mechanisms/conventions for capturing module dependencies (either automated or manually/explicitly).

3 Likes

Thank you so much Arjen

Thank you Ivan for taking the time to answer me. In meantime, I found AstroBEAR and PSBLAS and did some tests. The book that you mentioned is what I was really looking for; lots of explanation and very intuitive. Thank you.