Makefiles: make FC default to gfortran again - #696
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
`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>
7 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #694, noted in #695.
Problem
external_libs/quadpack/Makefileandexternal_libs/mvtnorm/Makefileboth do:FC ?= gfortranThat assignment never takes effect. GNU make already defines
FCasf77as a built-in variable, and?=assigns only when the variable is undefined, which a built-in is not. So a build that does not setFCin the environment usesf77and stops at:Machines with a
f77inPATH(often a wrapper around gfortran) do not notice; those without it cannot build regenie unless they know to passFC=gfortranthemselves. It also means the-std=legacyinFLAGis being handed to whateverf77happens to be, rather than to gfortran as intended.Fix
Use
$(origin FC), which distinguishes make's own default from a value the user supplied:An
FCpassed 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:
Same for
external_libs/mvtnorm. Found while packaging regenie for Homebrew, where the build environment does not providef77.🤖 Generated with Claude Code