# -*- bazel -*-

load("@drake//tools/skylark:cc.bzl", "cc_library")
load(":path.bzl", "LIBDIR")

# libgfortran: GPL-3.0-or-later WITH GCC-exception-3.1.
# libquadmath: LGPL-2.0-or-later.
licenses(["restricted"])  # See above for details.

sh_binary(
    name = "compiler",
    srcs = ["gfortran-found"],
    visibility = ["//visibility:public"],
)

config_setting(
    name = "x86_64",
    constraint_values = [
        "@platforms//cpu:x86_64",
    ],
)

cc_library(
    name = "runtime",
    linkopts = [
        "-L{}".format(LIBDIR),
        "-ldl",
        "-lgfortran",
    ] + select({
        ":x86_64": [
            # TODO(jwnimmer-tri) Possibly this is unnecessary on Ubuntu 24.04?
            # The libgfortran5 no longer depends on libquadmath0.
            "-lquadmath",
        ],
        "//conditions:default": [],
    }),
    visibility = ["//visibility:public"],
)
