Installing fpm¶
This how-to guide covers the installation of Fortran on various platforms.
MSYS2 package manager¶
The MSYS2 project provides a package manager and makes many common Unix tools available for Windows.
Note
To install download the msys2-x86_64-YYYYMMDD.exe installer from the MSYS2 webpage and run it.
MSYS2 will create several new desktop shortcuts, like MSYS terminal, MinGW64 terminal and UCRT64 terminal (more information on MSYS2 terminals are available here).
The Fortran package manager is supported for the the UCRT64, MinGW64, or MinGW32 terminal.
Open a new terminal and update your installation with
pacman -Syu
You might have to update MSYS2 and pacman first, restart the terminal and run the above command again to update the installed packages.
If you are using the MinGW64 terminal you can install the required software with
pacman -S git mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-fpm
Tip
Both git and gfortran are not mandatory dependencies for running fpm. If you provide git and gfortran from outside they will get picked up as well.
Homebrew package manager¶
The Fortran package manager (fpm) is available for the homebrew package manager on MacOS via an additional tap. To install fpm via brew, include the new tap and install it using
brew tap awvwgk/fpm
brew install fpm
Binary distributions are available for MacOS 11 (Catalina) and 12 (Big Sur) for x86_64 architectures. For other platforms fpm will be built locally from source automatically.
Fpm should be available and functional after those steps.
Conda package manager¶
Fpm is available on conda-forge, to add conda-forge to your channels use:
conda config --add channels conda-forge
Fpm can be installed with:
conda create -n fpm fpm
conda activate fpm
Alternatively, if you want fpm to be always available directly install into your current environment with
conda install fpm
Arch Linux user repository¶
The Arch Linux user repository (AUR) contains two packages for the Fortran package manager (fpm). With the fortran-fpm-bin installs the statically linked Linux/x86_64 binary from the release page, while the fortran-fpm package will bootstrap fpm from source.
Select one of the PKGBUILDs and retrieve it with
git clone https://aur.archlinux.org/fortran-fpm.git
cd fortran-fpm
As usual, first inspect the PKGBUILD before building it. After verifying the PKGBUILD is fine, build the package with
makepkg -si
Once the build passed pacman will ask to install the fpm package.
Building from source¶
To build fpm from source get the latest fpm source, either by cloning the repository from GitHub with
git clone https://github.com/fortran-lang/fpm
cd fpm
or by downloading a source tarball from the latest source
wget https://github.com/fortran-lang/fpm/archive/refs/heads/main.zip
unzip main.zip
cd fpm-main
The available install script allows to bootstrap fpm by using just a Fortran compiler, git and network access. Invoke the script to start the bootstrap build
./install.sh
Fpm will be installed in ~/.local/bin/fpm.
Note
Building the bootstrapper binary from the single source file version might take a few seconds, which might make the install script look like it is hanging.
Tip
The installation location can be adjusted by passing the --prefix=/path/to/install option.
If you can’t run the install script, you can perform the bootstrap procedure manually, with the following three steps:
Download the single source version of fpm
wget https://github.com/fortran-lang/fpm/releases/download/current/fpm.F90
Build a bootstrap binary from the single source version
mkdir -p build/bootstrap gfortran -J build/bootstrap -o build/bootstrap/fpm fpm.F90
Use the bootstrap binary to build the feature complete fpm version
./build/bootstrap/fpm install