Skip to content

Commit

Permalink
Configurator: try to call pkgconf before failing back to pkg-config
Browse files Browse the repository at this point in the history
Pkgconf is a modern implementation of the "pkg-config freedesktop standard". Linux distros actually use pkgconf as their
pkg-config implementation and provide a in place replacement. (Homebrew packages both and is the last place I found where you can get the historical implementation).
It is always OK to call pkgconf for pkg-config all the CLI and outputs within the standard are following the standard :-).

Cygwin pkg-config package though provides pkgconf but does not provide the alias pkg-config forcing us to uptream the switch to the tool name instead of the standard.

Signed-off-by: Pierre Boutillier <pierre.boutillier@laposte.net>
  • Loading branch information
pirbo committed Oct 15, 2024
1 parent f8208ee commit 9c5a7bf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions otherlibs/configurator/src/v1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,21 @@ module Pkg_config = struct
}

let get c =
let pkg_config_exe_name =
match Sys.getenv "PKG_CONFIG" with
| s -> s
| exception Not_found -> "pkg-config"
in
let pkg_config_args =
match Sys.getenv "PKG_CONFIG_ARGN" with
| s -> String.split ~on:' ' s
| exception Not_found -> []
in
Option.map (which c pkg_config_exe_name) ~f:(fun pkg_config ->
{ pkg_config; pkg_config_args; configurator = c })
match Sys.getenv "PKG_CONFIG" with
| s ->
Option.map (which c s) ~f:(fun pkg_config ->
{ pkg_config; pkg_config_args; configurator = c })
| exception Not_found ->
(match which c "pkgconf" with
| None ->
Option.map (which c "pkg-config") ~f:(fun pkg_config ->
{ pkg_config; pkg_config_args; configurator = c })
| Some pkg_config -> Some { pkg_config; pkg_config_args; configurator = c })
;;

type package_conf =
Expand Down

0 comments on commit 9c5a7bf

Please sign in to comment.