Mohid Makefile
From MohidWiki
Following the makefile cross-platform, cross-compiler project methodology, we finally developped a sound makefile project for MOHID.
Contents
Features
Global environment variables
There is one thing that allow this project to be easily cross-platformed:
- The use of global environment variables. They are all defined in the respective platform makefile: Win.mk, Nix.mk, etc... Every new addition of a module, of a fortran file, or of an action must be followed by an update of all the respective platform makefiles (Win.mk, Nix.mk, etc...)
Platform/Compiler expandible
The project makefile's DAG meta-tree shows currently 4 platforms/compilers available: windows Win.mk, linux Nix.mk, linux with Portland Group Fortran Nix_pgf.mk and macintosh Mac.mk.
- To add a new compiler and/or a new architecture, one needs to change the main Makefile and create a new Arch_Fcomp.mk file.
Action extensible
An action is one given process to apply to the whole project: it could be to build the project, to clean the project, to install the binaries of the project to a safe place, to Get the files of the project from SourceOffSite etc ... The makefile code for the actions of the MOHID project is located in the files contained by the makefiles folder (at the bottom of the image).
- To add an action, one needs to edit the actions.mk file and create in the makefiles folder a new myaction.mk file.
Module extensible
The MOHID project has a modular nature. In this makefile project, each module is subject to the same overall actions and each module is contained in a light-blue folder in the image (MohidWater, Mohid_Base_1, Mohid_Base_2 and ...).
- To add a new file to an existing module: one must edit the Files.mk and the Dependencies.mk within the module's folder.
- To add a new module: one must create a new folder, name it after the module, copy the module's files, create the corresponding Files.mk and Dependencies.mk files. Finally, one must edit the Modules.mk and Dependencies.mk from the root folder.
Makefile project tree
mohid/Solutions/Linux> tree . |-- Actions.mk |-- Dependencies.mk |-- Editme.mk |-- Files.mk |-- Makefile |-- Makefiles | |-- All.mk | |-- Alllib.mk | |-- Clean.mk | |-- Files.mk | |-- Install.mk | `-- Makefile |-- MohidWater | |-- Dependencies.mk | |-- Files.mk | `-- Makefile |-- Mohid_Base_1 | |-- Dependencies.mk | |-- Files.mk | `-- Makefile |-- Mohid_Base_2 | |-- Dependencies.mk | |-- Files.mk | `-- Makefile `-- Nix.mk
User's guide
Get the latest version of the code at http://mohid.codeplex.com.
Linux
- Build
>make Nix
Please edit the nix_template.mk first and save it as nix.mk
- Clean
>make Nix.clean
Please edit the ../makefiles/Sos_template.mk file first and save it as ../makefiles/Sos.mk.
- Install
>make Nix.install
This will copy the binaries to a specific location on the harddisk. You can change the location by editing the Nix.mk file.
Windows
Use GNUmake! Attention: Rename gmake.exe to make.exe.
- Build
>make win
- Clean
>make win.clean
Administrator's guide
How do I add a new module file in MohidWater?
Suppose your new module filename is MohidWater/ModuleNew.F90
> vim Solutions/Linux/MohidWater/Files.mk FILES = \ ModuleNew.$(S) \ ModuleAssimilation.$(S) \ ModuleConsolidation.$(S) \ ModuleFreeVerticalMovement.$(S) \ ModuleJet.$(S) \ ...
References
- The makefile methodology.
- The GNU make manual.
- The graph editor yED.