Skip to content

Makefiles: make FC default to gfortran again - #696

Merged
joellembatchou merged 1 commit into
rgcgithub:masterfrom
BenjaminDEMAILLE:makefile-fortran-compiler
Oct 2, 2026
Merged

joellembatchou merged 1 commit into
rgcgithub:masterfrom
BenjaminDEMAILLE:makefile-fortran-compiler

Conversation

@BenjaminDEMAILLE

Copy link
Copy Markdown
Contributor

Follow-up to #694, noted in #695.

Problem

external_libs/quadpack/Makefile and external_libs/mvtnorm/Makefile both do:

FC   ?= gfortran

That assignment never takes effect. GNU make already defines FC as f77 as a built-in variable, and ?= assigns only when the variable is undefined, which a built-in is not. So a build that does not set FC in the environment uses f77 and stops at:

make: f77: No such file or directory
make: *** [mvt.o] Error 1
make: *** [d1mach.o] Error 1

Machines with a f77 in PATH (often a wrapper around gfortran) do not notice; those without it cannot build regenie unless they know to pass FC=gfortran themselves. It also means the -std=legacy in FLAG is being handed to whatever f77 happens to be, rather than to gfortran as intended.

Fix

Use $(origin FC), which distinguishes make's own default from a value the user supplied:

ifeq ($(origin FC),default)
FC   := gfortran
endif

An FC passed on the command line or exported in the environment still wins, so cross-compilation and non-gfortran toolchains are unaffected.

Testing

macOS 26.6 arm64, GCC 15 gfortran:

$ env -u FC make            # before: make: f77: No such file or directory
gfortran -O2 -DNDEBUG -fPIC -std=legacy -c d1mach.f
...
$ ls libquad.a
libquad.a

$ make FC=gfortran-16       # explicit FC still honoured
gfortran-16 -O2 -DNDEBUG -fPIC -std=legacy -c d1mach.f

Same for external_libs/mvtnorm. Found while packaging regenie for Homebrew, where the build environment does not provide f77.

🤖 Generated with Claude Code

`FC ?= gfortran` never takes effect: GNU make already defines FC as `f77`
as a built-in, and `?=` only assigns when the variable is undefined. A build
that does not set FC in the environment therefore stops at:

    make: f77: No such file or directory
    make: *** [mvt.o] Error 1

Use `$(origin FC)` so gfortran is used when make supplied the default, while
an FC given on the command line or in the environment is still respected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@joellembatchou
joellembatchou merged commit 70e196b into rgcgithub:master Oct 2, 2026
1 check passed
@BenjaminDEMAILLE

Copy link
Copy Markdown
Contributor Author

Thanks for merging.
Is it possible to tag a release for homebrew ?

@joellembatchou

Copy link
Copy Markdown
Collaborator

tag added "v4.1.3.1"

@BenjaminDEMAILLE

Copy link
Copy Markdown
Contributor Author

Thanks a lot for tagging v4.1.3.1! Two small things I noticed:

  • The VERSION file in the v4.1.3.1 tag still says 4.1.3, so regenie --version reports v4.1.3.
  • The tag has no GitHub release yet, so the "Latest" release is still v4.1.3.

Would it be possible to bump VERSION and publish a release for it? That would let the Homebrew formula (Homebrew/homebrew-core#302933) point to a release that reports the right version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants