A C library for asynchronous DNS requests (grpc依赖)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.8 KiB

#
# Watcom / OpenWatcom / Win32 makefile for cares.
# Quick hack by Guenter; comments to: /dev/nul
#
!ifndef %watcom
!error WATCOM environment variable not set!
!else
SYS_INCL = -I$(%watcom)\h\nt -I$(%watcom)\h
SYS_LIBS = $(%watcom)\lib386\nt;$(%watcom)\lib386
!endif
!ifdef %libname
LIBNAME = $(%libname)
!else
LIBNAME = cares
!endif
TARGETS = $(LIBNAME).dll $(LIBNAME)_imp.lib $(LIBNAME).lib
DEMOS = adig.exe ahost.exe acountry.exe
CC = wcc386
LD = wlink
AR = wlib
RC = wrc
!ifdef __LOADDLL__
! loaddll wcc386 wccd386
! loaddll wpp386 wppd386
! loaddll wlib wlibd
!endif
!if $(__VERSION__) < 1250
RM = del /q /f 2>NUL
!else
RM = rm -f
!endif
MD = mkdir
RD = rmdir /q /s 2>NUL
CP = copy
CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm &
-wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY &
-dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL)
LFLAGS = option quiet, map, caseexact, eliminate
!ifdef %debug
DEBUG = -dDEBUG=1 -dDEBUGBUILD
CFLAGS += -d3 $(DEBUG)
LFLAGS += debug all
!else
CFLAGS += -d0
!endif
Windows DNS server sorting (#81) Original Patch From Brad Spencer: https://c-ares.haxx.se/mail/c-ares-archive-2016-04/0000.shtml My modifications include: * Dynamically find GetBestRoute2 since it is a Windows Vista+ symbol, and will fall back to prior behavior when not available. * Prefer get_DNS_AdaptersAddresses as the modifications should alleviate the concerns which caused us to prefer get_DNS_NetworkParams * Update AppVeyor to use MinGW-w64 instead of the legacy MinGW * Fix compile error in test suite for Windows. Original message from patch below: From: Brad Spencer <bspencer@blackberry.com> Date: Fri, 29 Apr 2016 14:26:23 -0300 On Windows, the c-ares DNS resolver tries first to get a full list of DNS server addresses by enumerating the system's IPv4/v6 interfaces and then getting the per-interface DNS server lists from those interfaces and joining them together. The OS, at least in the way the c-ares prefers to query them (which also may be the only or best way in some environments), does not provide a unified list of DNS servers ordered according to "current network conditions". Currently, c-ares will then try to use them in whatever order the nested enumeration produces, which may result in DNS requests being sent to servers on one interface (hosting the current default route, for example) that are only intended to be used via another interface (intended to be used when the first interface is not available, for example). This, in turn, can lead to spurious failures and timeouts simply because of the server address order that resulted because of the enumeration process. This patch makes the (safe?) assumption that there is no other better rule to chose which interface's DNS server list should be prioritized. After all, a DNS lookup isn't something "per network"; applications don't look up "these DNS names on this interface and those DNS names on that interface". There is a single resource pool of DNS servers and the application should presume that any server will give it the "right" answer. However, even if all DNS servers are assumed to give equally useful responses, it is reasonable to expect that some DNS servers will not accept requests on all interfaces. This patch avoids the problem by sorting the DNS server addresses using the Windows IPv4/v6 routing tables. For example, a request to DNS server C on interface 2 that is actually sent over interface 1 (which may happen to have the default route) may be rejected by or not delivered to DNS server C. So, better to use DNS servers A and B associated with interface 1, at least as a first try. By using the metric of the route to the DNS server itself as a proxy for priority of the DNS server in the list, this patch is able to adapt dynamically to changes in the interface list, the DNS server lists per interface, which interfaces are active, the routing table, and so on, while always picking a good "best" DNS server first. In cases where any DNS server on any interface will do, this patch still seems useful because it will prioritize a lower-metric route's (and thus interface's) servers.
8 years ago
CFLAGS += -d_WIN32_WINNT=0x0600
#
# Change to suite.
#
!ifdef %use_watt32
CFLAGS += -dWATT32 -I$(%watt_root)\inc
!endif
OBJ_BASE = WC_Win32.obj
LINK_ARG = $(OBJ_BASE)\dyn\wlink.arg
LIB_ARG = $(OBJ_BASE)\stat\wlib.arg
# In order to process Makefile.inc wmake must be called with -u switch!
!ifneq __MAKEOPTS__ -u
!error You MUST call wmake with the -u switch!
!else
!include Makefile.inc
!endif
OBJS = $(CSOURCES:.c=.obj)
OBJS = $OBJ_DIR\$(OBJS: = $OBJ_DIR\)
#
# Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN).
#
OBJ_DIR = $(OBJ_BASE)\stat
OBJS_STAT = $+ $(OBJS) $-
OBJ_DIR = $(OBJ_BASE)\dyn
OBJS_DYN = $+ $(OBJS) $-
ARESBUILDH = ares_build.h
RESOURCE = $(OBJ_BASE)\dyn\cares.res
all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC
@echo Welcome to cares
$(OBJ_BASE):
-$(MD) $^@
-$(MD) $^@\stat
-$(MD) $^@\dyn
-$(MD) $^@\demos
$(ARESBUILDH): .EXISTSONLY
$(CP) $^@.dist $^@
$(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG)
$(LD) name $^@ @$]@
$(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG)
$(AR) -q -b -c $^@ @$]@
adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
clean: .SYMBOLIC
-$(RM) $(OBJS_STAT)
-$(RM) $(OBJS_DYN)
-$(RM) $(RESOURCE) $(LINK_ARG) $(LIB_ARG)
vclean realclean: clean .SYMBOLIC
-$(RM) $(TARGETS) $(LIBNAME).map
-$(RM) $(DEMOS) $(DEMOS:.exe=.map)
-$(RD) $(OBJ_BASE)\stat
-$(RD) $(OBJ_BASE)\dyn
-$(RD) $(OBJ_BASE)\demos
-$(RD) $(OBJ_BASE)
.ERASE
$(RESOURCE): cares.rc .AUTODEPEND
$(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\dyn}.obj:
$(CC) $(CFLAGS) -bd $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\stat}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\demos}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
$(LINK_ARG): $(__MAKEFILES__)
%create $^@
@%append $^@ system nt dll
@%append $^@ file { $(OBJS_DYN) }
@%append $^@ option res=$(RESOURCE), implib=$(LIBNAME)_imp.lib
@%append $^@ $(LFLAGS)
@%append $^@ libpath $(SYS_LIBS)
# @%append $^@ library clib3r.lib
!ifdef %use_watt32
@%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib
!else
@%append $^@ library ws2_32.lib
!endif
$(LIB_ARG): $(__MAKEFILES__)
%create $^@
@for %f in ($(OBJS_STAT)) do @%append $^@ +- %f