@@ -156,6 +156,10 @@ opts.AddVariables(
156156 "Path to Brotli's install area" ,
157157 None ,
158158 PathVariable .PathIsDir ),
159+ PathVariable ('UNBOUND' ,
160+ "Path to libunbound's install area" ,
161+ None ,
162+ PathVariable .PathIsDir ),
159163 BoolVariable ('DEBUG' ,
160164 "Enable debugging info and strict compile warnings" ,
161165 False ),
@@ -290,6 +294,7 @@ zlib = str(env['ZLIB'])
290294expat = env .get ('EXPAT' , None )
291295gssapi = env .get ('GSSAPI' , None )
292296brotli = env .get ('BROTLI' , None )
297+ unbound = env .get ('UNBOUND' , None )
293298
294299if gssapi and os .path .isdir (gssapi ):
295300 krb5_config = os .path .join (gssapi , 'bin' , 'krb5-config' )
@@ -386,6 +391,9 @@ if sys.platform != 'win32':
386391 if brotli :
387392 env .Append (LIBS = ['brotlicommon' , 'brotlidec' ])
388393
394+ if unbound :
395+ env .Append (LIBS = ['unbound' ])
396+
389397else :
390398 # Warning level 4, no unused argument warnings
391399 env .Append (CCFLAGS = ['/W4' ,
@@ -551,6 +559,13 @@ if sys.platform == 'win32':
551559 pc_private_libs .append ('$BROTLI/Release/brotlicommon.lib' )
552560 pc_private_libs .append ('$BROTLI/Release/brotlidec.lib' )
553561
562+ # unbound
563+ if unbound :
564+ env .Append (CPPPATH = ['$UNBOUND/include' ],
565+ LIBPATH = ['$UNBOUND/lib' ],
566+ LIBS = ['unbound.lib' ])
567+ pc_private_libs .append ('$UNBOUND/lib/unbound.lib' )
568+
554569 env .Append (LIBS = win_std_libs )
555570
556571else :
@@ -616,6 +631,13 @@ else:
616631 pc_private_libs .append ('-L$BROTLI/lib' )
617632 pc_private_libs .append ('-lbrotlicommon -lbrotlidec' )
618633
634+ if unbound :
635+ env .Append (CPPPATH = ['$UNBOUND/include' ],
636+ LIBPATH = ['$UNBOUND/lib' ])
637+ if env .subst ('$UNBOUND' ) not in ('' , '/usr' ):
638+ pc_private_libs .append ('-L$UNBOUND/lib' )
639+ pc_private_libs .append ('-lunbound' )
640+
619641# Check for OpenSSL functions which are only available in some of
620642# the versions we support. Also handles forks like LibreSSL.
621643ssl_include_rx = re .compile (r'^\s*#\s*include\s+<openssl/[^>]+>' )
@@ -627,7 +649,6 @@ for line in stream.readlines():
627649 ssl_include_list .append (line .rstrip ())
628650ssl_includes = '\n ' .join (ssl_include_list )
629651
630-
631652conf = Configure (env , custom_tests = custom_tests )
632653if not conf .CheckFunc ('BIO_set_init' , ssl_includes , 'C' , 'NULL, 0' ):
633654 env .Append (CPPDEFINES = ['SERF_NO_SSL_BIO_WRAPPERS' ])
@@ -672,16 +693,34 @@ if sys.platform == 'win32':
672693
673694if brotli and CALLOUT_OKAY :
674695 conf = Configure (env , custom_tests = custom_tests )
675- if conf .CheckCHeader ('brotli/decode.h' ) and \
676- conf .CheckFunc ('BrotliDecoderTakeOutput' ,
677- '#include <brotli/decode.h>' ,
678- 'C' , 'NULL, NULL' ):
696+ if ( conf .CheckCHeader ('brotli/decode.h' )
697+ and conf .CheckFunc ('BrotliDecoderTakeOutput' ,
698+ '#include <brotli/decode.h>' ,
699+ 'C' , 'NULL, NULL' ) ):
679700 env .Append (CPPDEFINES = ['SERF_HAVE_BROTLI' ])
680701 else :
681702 print ("Cannot find Brotli library >= 1.0.0 in '%s'." % env .get ('BROTLI' ))
682703 Exit (1 )
683704 env = conf .Finish ()
684705
706+ if unbound and CALLOUT_OKAY :
707+ print (custom_tests )
708+ conf = Configure (env , custom_tests = custom_tests )
709+ if (conf .CheckCHeader ('unbound.h' )
710+ and conf .CheckFunc ('ub_ctx_create' ,
711+ '#include <unbound.h>' ,
712+ 'C' , '' )
713+ and conf .CheckFunc ('ub_resolve_async' ,
714+ '#include <stddef.h>\n '
715+ '#include <unbound.h>' ,
716+ 'C' , 'NULL, NULL, 0, 0, NULL, NULL, NULL' )):
717+ env .Append (CPPDEFINES = ['SERF_HAVE_ASYNC_RESOLVER=1' ,
718+ 'SERF_HAVE_UNBOUND=1' ])
719+ else :
720+ print ("Cannot find Unbound library in '%s'." % env .get ('UNBOUND' ))
721+ Exit (1 )
722+ env = conf .Finish ()
723+
685724if CALLOUT_OKAY :
686725 conf = Configure (env , custom_tests = custom_tests )
687726
0 commit comments