require 'mkmf'

dir_config('rkerberos', '/usr/local')

have_header('krb5.h')
have_library('krb5')

unless pkg_config('com_err')
  puts 'warning: com_err not found, usually a dependency for kadm5clnt'
end

if have_header('kadm5/admin.h')
  have_library('kadm5clnt')
else
  raise "kadm5clnt library not found"
end

if have_header('kdb.h')
  have_library('libkdb5')
else
  raise 'kdb5 library not found'
end

$CFLAGS << '-std=c99 -Wall -pedantic'
create_makefile('rkerberos')

require 'mkmf'

dir_config('rkerberos', '/usr/local')

have_header('krb5.h')
have_library('krb5')

unless pkg_config('com_err')
  puts 'warning: com_err not found, usually a dependency for kadm5clnt'
end

if have_header('kadm5/admin.h')
  have_library('kadm5clnt')
else
  raise "kadm5clnt library not found"
end

if have_header('kdb.h')
  have_library('libkdb5')
else
  raise 'kdb5 library not found'
end

$CFLAGS << ' -std=c99 -Wall -pedantic'
create_makefile('rkerberos')

Prepend space to additional CLFAGS
Prepend space to additional CLFAGS

On Ruby 2.0.0 and 2.1, `pkg_config('com_err')` may not leave an blank
space at the end of CFLAGS, causing the `-std=c99` concatentation to
generate an incorrect command, e.g.

    CFLAGS   = $(CCDLFLAGS) $(cflags)  -fPIC -I/usr/include/et-std=c99 -Wall -pedantic $(ARCH_FLAG)

The behaviour changes a little between Ruby versions.
