Skip to content

Commit 2ee32e5

Browse files
committed
pkgconf: use pkg.m4 from pkg-config via split formula
1 parent 4d2f32b commit 2ee32e5

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

Diff for: Formula/p/pkgconf.rb

+34-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Pkgconf < Formula
44
url "https://distfiles.ariadne.space/pkgconf/pkgconf-2.3.0.tar.xz"
55
sha256 "3a9080ac51d03615e7c1910a0a2a8df08424892b5f13b0628a204d3fcce0ea8b"
66
license "ISC"
7+
revision 1
78

89
livecheck do
910
url "https://distfiles.ariadne.space/pkgconf/"
@@ -28,35 +29,61 @@ class Pkgconf < Formula
2829
depends_on "libtool" => :build
2930
end
3031

31-
conflicts_with "pkg-config", because: "both install `pkg.m4` file"
32+
depends_on "pkg.m4"
3233

3334
def install
3435
if build.head?
3536
ENV["LIBTOOLIZE"] = "glibtoolize"
3637
system "./autogen.sh"
3738
end
3839

40+
system_prefix = "/usr"
3941
pc_path = %W[
4042
#{HOMEBREW_PREFIX}/lib/pkgconfig
4143
#{HOMEBREW_PREFIX}/share/pkgconfig
4244
]
4345
pc_path << if OS.mac?
44-
pc_path << "/usr/local/lib/pkgconfig"
46+
system_prefix = "#{MacOS.sdk_path_if_needed}/usr"
47+
48+
pc_path << "/usr/local/lib/pkgconfig" if HOMEBREW_PREFIX.to_s != "/usr/local"
4549
pc_path << "/usr/lib/pkgconfig"
4650
"#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"
4751
else
4852
"#{HOMEBREW_LIBRARY}/Homebrew/os/linux/pkgconfig"
4953
end
5054

51-
pc_path = pc_path.uniq.join(File::PATH_SEPARATOR)
52-
53-
configure_args = std_configure_args + %W[
54-
--with-pkg-config-dir=#{pc_path}
55+
args = %W[
56+
--with-pkg-config-dir=#{pc_path.uniq.join(File::PATH_SEPARATOR)}
57+
--with-personality-dir=#{HOMEBREW_PREFIX}/share/pkgconfig/personality.d:#{etc}/pkgconfig/personality.d
58+
--with-system-includedir=#{HOMEBREW_PREFIX}/include:#{system_prefix}/include
59+
--with-system-libdir=#{HOMEBREW_PREFIX}/lib:#{system_prefix}/lib
60+
--disable-silent-rules
5561
]
5662

57-
system "./configure", *configure_args
63+
system "./configure", *args, *std_configure_args
5864
system "make"
5965
system "make", "install"
66+
67+
# Move `pkg.m4` into libexec to make it easier for migration to `pkgconf`
68+
libexec.install share/"aclocal/pkg.m4"
69+
70+
# TODO: Consider making `pkgconf` a drop-in replacement to `pkg-config` by adding
71+
# symlink and restoring conflicts. Similar to Debian, Fedora, ArchLinux and MacPorts.
72+
# Alternatively can keep separate non-conflicting commands and update `pkg.m4` to use
73+
# `pkgconf` copy after sufficiently migrated.
74+
# Ref: https://github.com/pkgconf/pkgconf/#pkg-config-symlink
75+
# Ref: https://salsa.debian.org/debian/pkgconf/-/blob/debian/unstable/debian/pkgconf.links?ref_type=heads
76+
#
77+
# bin.install_symlink "pkgconf" => "pkg-config"
78+
# man1.install_symlink "pkgconf.1" => "pkg-config.1"
79+
end
80+
81+
def caveats
82+
<<~EOS
83+
To allow easier migration from `pkg-config` to `pkgconf`, the `pkgconf` formula
84+
uses `pkg-config`'s pkg.m4 to avoid conflict. If you need the copy from `pkgconf`,
85+
then it is available at #{libexec}/pkg.m4
86+
EOS
6087
end
6188

6289
test do

0 commit comments

Comments
 (0)