/ext/dnssd/extconf.rb

http://github.com/tenderlove/dnssd · Ruby · 74 lines · 47 code · 15 blank · 12 comment · 3 complexity · 63ede825c3b549d176feb40a817af836 MD5 · raw file

  1. require 'mkmf'
  2. $CFLAGS << ' -Wall' if with_config 'warnings'
  3. dir_config 'dnssd'
  4. abort 'unable to find dnssd header' unless have_header 'dns_sd.h'
  5. have_library('dnssd') ||
  6. have_library('dns_sd') ||
  7. have_library('mdns') ||
  8. have_library('System') ||
  9. abort('unable to find dnssd library')
  10. have_macro('htons', 'arpa/inet.h') ||
  11. have_func('htons', 'arpa/inet.h') ||
  12. abort("couldn't find htons")
  13. have_macro('ntohs', 'arpa/inet.h') ||
  14. have_func('ntohs', 'arpa/inet.h') ||
  15. abort("couldn't find ntohs")
  16. # These functions live in netioapi.h on Windows, not net/if.h. The MSDN
  17. # documentation says to include iphlpapi.h, not netioapi.h directly.
  18. #
  19. # Note, however, that these functions only exist on Vista/Server 2008 or later.
  20. # On Windows XP and earlier you will have to define a custom version of each
  21. # function using native functions, such as ConvertInterfaceIndexToLuid() and
  22. # ConvertInterfaceLuidToNameA().
  23. #
  24. if have_header 'iphlpapi.h' then
  25. have_func('if_indextoname', %w[iphlpapi.h netioapi.h]) &&
  26. have_func('if_nametoindex', %w[iphlpapi.h netioapi.h]) ||
  27. abort('unable to find if_indextoname or if_nametoindex')
  28. else
  29. if RUBY_PLATFORM =~ /solaris/ then
  30. have_library('xnet') ||
  31. abort('unable to find xnet library for if_indextoname/if_nametoindex')
  32. $CFLAGS << ' -lxnet'
  33. end
  34. have_func('if_indextoname', %w[sys/types.h sys/socket.h net/if.h]) &&
  35. have_func('if_nametoindex', %w[sys/types.h sys/socket.h net/if.h]) ||
  36. abort('unable to find if_indextoname or if_nametoindex')
  37. end
  38. have_type('struct sockaddr_in', 'netinet/in.h') ||
  39. abort('unable to find struct sockaddr_in')
  40. have_struct_member 'struct sockaddr_in', 'sin_len', 'netinet/in.h'
  41. # otherwise, use sizeof()
  42. puts
  43. puts 'checking for missing avahi features'
  44. # avahi 0.6.25 is missing these functions
  45. have_func 'DNSServiceGetProperty', 'dns_sd.h'
  46. have_func 'DNSServiceGetAddrInfo', 'dns_sd.h'
  47. # avahi 0.6.25 is missing these flags
  48. have_func 'kDNSServiceFlagsForce', 'dns_sd.h'
  49. have_func 'kDNSServiceFlagsNonBrowsable', 'dns_sd.h'
  50. have_func 'kDNSServiceFlagsReturnIntermediates', 'dns_sd.h'
  51. have_func 'kDNSServiceFlagsShareConnection', 'dns_sd.h'
  52. # avahi 0.6.25 is missing errors after BadTime
  53. have_func 'kDNSServiceErr_BadSig', 'dns_sd.h'
  54. puts
  55. puts 'checking for ruby features'
  56. have_header 'ruby/encoding.h'
  57. puts
  58. create_makefile 'dnssd/dnssd'