require 'mkmf'

dir_config('sary')
# sary_config = with_config('sary-config', 'sary-config')

# use_sary_config = enable_config('sary-config')
# if use_sary_config || use_sary_config == nil 
#   $CFLAGS  += ' ' + `#{sary_config} --cflags`.chomp
#   $LDFLAGS += ' ' + `#{sary_config} --libs`.chomp
# end

pkg_config = 'pkg-config'

unless system("#{pkg_config} sary --exists") then
  ENV['PKG_CONFIG_PATH'] = '/usr/local/lib/pkgconfig/'
end

$CFLAGS  += ' ' + `#{pkg_config} sary --cflags`.chomp
$LDFLAGS += ' ' + `#{pkg_config} sary --libs`.chomp

if have_header('sary.h') &&
    have_library('sary')
  create_makefile('sary')
end

# Add make targets
mfile = File.open 'Makefile', 'a'
mfile.print "\n"
mfile.print "\
deb: 
	if test -d debian ; then fakeroot $(MAKE) -f ./debian/rules clean; fi
	if test -d debian ; then fakeroot $(MAKE) -f ./debian/rules binary; fi

.PHONY: deb
"


### Local variables:
### mode: Ruby
### indent-tabs-mode: nil
### End:
