Skip to content

Commit

Permalink
Improve checks for pkg-config and fall back to gpgme-config
Browse files Browse the repository at this point in the history
#166 changed from `pkg-config`
to `gpgme-config`, but if `PKG_CONFIG_PATH` is not set properly, the C
extension library will quietly build without the right linker
dependencies.

To fix this, we now check for the existence of `gpgme.pc` in
`PKG_CONFIG_PATH` and attempt to fall back to `gpgme-config` if it
does not exist.

Closes #167
  • Loading branch information
stanhu authored and ueno committed Dec 5, 2022
1 parent b8af6be commit 644296a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ext/gpgme/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
end

if arg_config('--use-system-libraries', ENV['RUBY_GPGME_USE_SYSTEM_LIBRARIES'])
unless find_executable('pkg-config')
$stderr.puts("pkg-config not found")
if find_executable('pkg-config') && system('pkg-config gpgme --exists')
$CFLAGS += ' ' << `pkg-config --cflags gpgme`.chomp
$libs += ' ' << `pkg-config --libs gpgme`.chomp
elsif find_executable('gpgme-config')
$CFLAGS += ' ' << `gpgme-config --cflags`.chomp
$libs += ' ' << `gpgme-config --libs`.chomp
else
$stderr.puts("pkg-config with gpgme.pc and gpgme-config not found")
exit(1)
end

$CFLAGS += ' ' << `pkg-config --cflags gpgme`.chomp
$libs += ' ' << `pkg-config --libs gpgme`.chomp
else
message <<-'EOS'
************************************************************************
Expand Down

0 comments on commit 644296a

Please sign in to comment.