| 1 |
# Copyright (C) 1994-2026 Free Software Foundation, Inc. |
| 2 |
# This file is part of the GNU C Library. |
| 3 |
|
| 4 |
# The GNU C Library is free software; you can redistribute it and/or |
| 5 |
# modify it under the terms of the GNU Lesser General Public |
| 6 |
# License as published by the Free Software Foundation; either |
| 7 |
# version 2.1 of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
# The GNU C Library is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
# Lesser General Public License for more details. |
| 13 |
|
| 14 |
# You should have received a copy of the GNU Lesser General Public |
| 15 |
# License along with the GNU C Library; if not, see |
| 16 |
# <https://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
# |
| 19 |
# Sub-makefile for resolv portion of the library. |
| 20 |
# |
| 21 |
subdir := resolv |
| 22 |
|
| 23 |
include ../Makeconfig |
| 24 |
|
| 25 |
headers := resolv.h bits/types/res_state.h \ |
| 26 |
netdb.h bits/netdb.h \ |
| 27 |
arpa/nameser.h arpa/nameser_compat.h \ |
| 28 |
sys/bitypes.h |
| 29 |
|
| 30 |
routines := \ |
| 31 |
dn_comp \ |
| 32 |
dn_expand \ |
| 33 |
dn_skipname \ |
| 34 |
dns-canon \ |
| 35 |
dns-host \ |
| 36 |
dns-network \ |
| 37 |
herror \ |
| 38 |
inet_addr \ |
| 39 |
inet_ntop \ |
| 40 |
inet_pton \ |
| 41 |
inet_pton_length \ |
| 42 |
ns_makecanon \ |
| 43 |
ns_name_compress \ |
| 44 |
ns_name_length_uncompressed \ |
| 45 |
ns_name_ntop \ |
| 46 |
ns_name_pack \ |
| 47 |
ns_name_pton \ |
| 48 |
ns_name_skip \ |
| 49 |
ns_name_uncompress \ |
| 50 |
ns_name_unpack \ |
| 51 |
ns_rr_cursor_init \ |
| 52 |
ns_rr_cursor_next \ |
| 53 |
ns_samebinaryname \ |
| 54 |
ns_samename \ |
| 55 |
nsap_addr \ |
| 56 |
nss_dns_functions \ |
| 57 |
res-close \ |
| 58 |
res-name-checking \ |
| 59 |
res-noaaaa \ |
| 60 |
res-state \ |
| 61 |
res_context_hostalias \ |
| 62 |
res_enable_icmp \ |
| 63 |
res_get_nsaddr \ |
| 64 |
res_hconf \ |
| 65 |
res_init \ |
| 66 |
res_libc \ |
| 67 |
res_mkquery \ |
| 68 |
res_nameinquery \ |
| 69 |
res_queriesmatch \ |
| 70 |
res_query \ |
| 71 |
res_randomid \ |
| 72 |
res_send \ |
| 73 |
resolv_conf \ |
| 74 |
resolv_context \ |
| 75 |
# routines |
| 76 |
|
| 77 |
# Exclude fortified routines from being built with _FORTIFY_SOURCE |
| 78 |
routines_no_fortify += \ |
| 79 |
inet_pton \ |
| 80 |
# routines_no_fortify |
| 81 |
|
| 82 |
tests = tst-aton tst-leaks tst-inet_ntop |
| 83 |
tests-container += \ |
| 84 |
tst-getaddrinfo-eai-again \ |
| 85 |
tst-leaks2 \ |
| 86 |
# tests-container |
| 87 |
|
| 88 |
tests-internal += tst-inet_aton_exact |
| 89 |
|
| 90 |
|
| 91 |
generate := mtrace-tst-leaks.out tst-leaks.mtrace tst-leaks2.mtrace |
| 92 |
|
| 93 |
extra-libs := libresolv libnss_dns |
| 94 |
ifeq ($(have-thread-library),yes) |
| 95 |
routines += gai_sigqueue |
| 96 |
|
| 97 |
tests += \ |
| 98 |
tst-bug18665 \ |
| 99 |
tst-bug18665-tcp \ |
| 100 |
tst-inet_addr-binary \ |
| 101 |
tst-ns_name \ |
| 102 |
tst-ns_name_compress \ |
| 103 |
tst-ns_name_pton \ |
| 104 |
tst-res_hconf_reorder \ |
| 105 |
tst-res_hnok \ |
| 106 |
tst-resolv-aliases \ |
| 107 |
tst-resolv-basic \ |
| 108 |
tst-resolv-binary \ |
| 109 |
tst-resolv-byaddr \ |
| 110 |
tst-resolv-edns \ |
| 111 |
tst-resolv-invalid-cname \ |
| 112 |
tst-resolv-network \ |
| 113 |
tst-resolv-noaaaa \ |
| 114 |
tst-resolv-noaaaa-vc \ |
| 115 |
tst-resolv-nondecimal \ |
| 116 |
tst-resolv-res_init-multi \ |
| 117 |
tst-resolv-search \ |
| 118 |
tst-resolv-semi-failure \ |
| 119 |
tst-resolv-short-response \ |
| 120 |
tst-resolv-trailing \ |
| 121 |
|
| 122 |
# This test calls __res_context_send directly, which is not exported |
| 123 |
# from libresolv. |
| 124 |
tests-internal += tst-resolv-txnid-collision |
| 125 |
tests-static += tst-resolv-txnid-collision |
| 126 |
|
| 127 |
# Likewise for __ns_samebinaryname. |
| 128 |
tests-internal += tst-ns_samebinaryname |
| 129 |
tests-static += tst-ns_samebinaryname |
| 130 |
|
| 131 |
# Likewise for __ns_name_length_uncompressed. |
| 132 |
tests-internal += tst-ns_name_length_uncompressed |
| 133 |
tests-static += tst-ns_name_length_uncompressed |
| 134 |
|
| 135 |
# Likewise for struct ns_rr_cursor and its functions. |
| 136 |
tests-internal += tst-ns_rr_cursor |
| 137 |
tests-static += tst-ns_rr_cursor |
| 138 |
|
| 139 |
# These tests need libdl. |
| 140 |
ifeq (yes,$(build-shared)) |
| 141 |
tests += \ |
| 142 |
tst-getaddrinfo-eai-again-timeout \ |
| 143 |
tst-resolv-af-unspec-noerror-nodata \ |
| 144 |
tst-resolv-ai_idn \ |
| 145 |
tst-resolv-ai_idn-latin1 \ |
| 146 |
tst-resolv-ai_idn-nolibidn2 \ |
| 147 |
tst-resolv-canonname \ |
| 148 |
tst-resolv-getaddrinfo-fqdn \ |
| 149 |
tst-resolv-trustad \ |
| 150 |
|
| 151 |
# Needs resolv_context. |
| 152 |
tests-internal += \ |
| 153 |
tst-resolv-res_init \ |
| 154 |
tst-resolv-res_init-thread \ |
| 155 |
tst-resolv-res_ninit \ |
| 156 |
tst-resolv-threads \ |
| 157 |
|
| 158 |
# Used by tst-resolv-ai_idn-nolibidn2 to disable libidn2 (by not |
| 159 |
# providing any functions in libidn2.so.0). |
| 160 |
modules-names += tst-no-libidn2 |
| 161 |
extra-test-objs += tst-no-libidn2.os |
| 162 |
LDFLAGS-tst-no-libidn2.so = -Wl,-soname,libidn2.so.0 |
| 163 |
|
| 164 |
endif # $(build-shared) |
| 165 |
|
| 166 |
# This test accesses __inet_ntop_length, an internal libc function. |
| 167 |
tests-internal += tst-inet_pton |
| 168 |
|
| 169 |
# This test accesses the __p_secstodate compat symbol. |
| 170 |
ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes) |
| 171 |
tests += tst-p_secstodate |
| 172 |
endif |
| 173 |
|
| 174 |
# This test sends millions of packets and is rather slow. |
| 175 |
xtests += tst-resolv-qtypes |
| 176 |
|
| 177 |
# This test has dropped packet tests and runs for a long time. |
| 178 |
xtests += tst-resolv-rotate |
| 179 |
endif # $(have-thread-library) |
| 180 |
|
| 181 |
extra-libs-others = $(extra-libs) |
| 182 |
libresolv-routines := \ |
| 183 |
base64 \ |
| 184 |
compat-gethnamaddr \ |
| 185 |
compat-hooks \ |
| 186 |
inet_net_ntop \ |
| 187 |
inet_net_pton \ |
| 188 |
inet_neta \ |
| 189 |
ns_date \ |
| 190 |
ns_name \ |
| 191 |
ns_netint \ |
| 192 |
ns_parse \ |
| 193 |
ns_print \ |
| 194 |
ns_samedomain \ |
| 195 |
ns_ttl \ |
| 196 |
res-putget \ |
| 197 |
res_data \ |
| 198 |
res_debug \ |
| 199 |
res_hostalias \ |
| 200 |
res_isourserver \ |
| 201 |
resolv-deprecated \ |
| 202 |
# libresolv-routines |
| 203 |
|
| 204 |
ifeq ($(have-anl-library),yes) |
| 205 |
# Empty compatibility library for old binaries. |
| 206 |
extra-libs += libanl |
| 207 |
libanl-routines += libanl-compat |
| 208 |
libanl-shared-only-routines += libanl-compat |
| 209 |
endif |
| 210 |
|
| 211 |
$(libanl-routines-var) += \ |
| 212 |
gai_cancel \ |
| 213 |
gai_error \ |
| 214 |
gai_misc \ |
| 215 |
gai_notify \ |
| 216 |
gai_suspend \ |
| 217 |
getaddrinfo_a \ |
| 218 |
# $(libanl-routines-var) |
| 219 |
|
| 220 |
# Pretend that libanl.so is a linker script, so that the symbolic link |
| 221 |
# is not installed. |
| 222 |
install-lib-ldscripts = libanl.so |
| 223 |
$(inst_libdir)/libanl.so: |
| 224 |
|
| 225 |
subdir-dirs = nss_dns |
| 226 |
vpath %.c nss_dns |
| 227 |
|
| 228 |
# Build only an empty shared libnss_dns. |
| 229 |
libnss_dns-inhibit-o = $(filter-out .os,$(object-suffixes)) |
| 230 |
|
| 231 |
# Pretend that libnss_dns.so is a linker script, so that the symbolic link |
| 232 |
# is not installed. |
| 233 |
install-lib-ldscripts = libnss_dns.so |
| 234 |
$(inst_libdir)/libnss_dns.so: |
| 235 |
|
| 236 |
ifeq ($(run-built-tests),yes) |
| 237 |
ifneq (no,$(PERL)) |
| 238 |
tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \ |
| 239 |
$(objpfx)mtrace-tst-resolv-res_ninit.out |
| 240 |
endif |
| 241 |
endif |
| 242 |
|
| 243 |
generated += mtrace-tst-leaks.out tst-leaks.mtrace \ |
| 244 |
mtrace-tst-leaks2.out tst-leaks2.mtrace \ |
| 245 |
mtrace-tst-resolv-res_ninit.out tst-resolv-res_ninit.mtrace \ |
| 246 |
|
| 247 |
include ../Rules |
| 248 |
|
| 249 |
LOCALES := en_US.UTF-8 en_US.ISO-8859-1 |
| 250 |
include ../gen-locales.mk |
| 251 |
|
| 252 |
CFLAGS-res_hconf.c += -fexceptions |
| 253 |
|
| 254 |
# The DNS NSS modules needs the resolver. |
| 255 |
$(objpfx)libnss_dns.so: $(objpfx)libresolv.so |
| 256 |
|
| 257 |
# The asynchronous name lookup code needs the thread library. |
| 258 |
$(objpfx)libanl.so: $(shared-thread-library) |
| 259 |
|
| 260 |
$(objpfx)tst-res_hconf_reorder: $(shared-thread-library) |
| 261 |
tst-res_hconf_reorder-ENV = RESOLV_REORDER=on |
| 262 |
|
| 263 |
$(objpfx)tst-leaks: $(objpfx)libresolv.so |
| 264 |
tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace \ |
| 265 |
LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so |
| 266 |
$(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out |
| 267 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@; \ |
| 268 |
$(evaluate-test) |
| 269 |
|
| 270 |
tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace \ |
| 271 |
LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so |
| 272 |
$(objpfx)mtrace-tst-leaks2.out: $(objpfx)tst-leaks2.out |
| 273 |
{ test -r $(objpfx)tst-leaks2.mtrace \ |
| 274 |
|| ( echo "tst-leaks2.mtrace does not exist"; exit 77; ) \ |
| 275 |
&& $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace; } > $@; \ |
| 276 |
$(evaluate-test) |
| 277 |
|
| 278 |
tst-resolv-res_ninit-ENV = MALLOC_TRACE=$(objpfx)tst-resolv-res_ninit.mtrace \ |
| 279 |
LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so |
| 280 |
$(objpfx)mtrace-tst-resolv-res_ninit.out: $(objpfx)tst-resolv-res_ninit.out |
| 281 |
$(common-objpfx)malloc/mtrace \ |
| 282 |
$(objpfx)tst-resolv-res_ninit.mtrace > $@; \ |
| 283 |
$(evaluate-test) |
| 284 |
|
| 285 |
$(objpfx)tst-bug18665-tcp: $(objpfx)libresolv.so $(shared-thread-library) |
| 286 |
$(objpfx)tst-bug18665: $(objpfx)libresolv.so $(shared-thread-library) |
| 287 |
$(objpfx)tst-resolv-af-unspec-noerror-nodata: \ |
| 288 |
$(objpfx)libresolv.so $(shared-thread-library) |
| 289 |
$(objpfx)tst-getaddrinfo-eai-again-timeout: \ |
| 290 |
$(objpfx)libresolv.so $(shared-thread-library) |
| 291 |
$(objpfx)tst-resolv-ai_idn: $(objpfx)libresolv.so $(shared-thread-library) |
| 292 |
$(objpfx)tst-resolv-ai_idn-latin1: \ |
| 293 |
$(objpfx)libresolv.so $(shared-thread-library) |
| 294 |
$(objpfx)tst-resolv-ai_idn-nolibidn2: \ |
| 295 |
$(objpfx)libresolv.so $(shared-thread-library) |
| 296 |
$(objpfx)tst-resolv-ai_idn.out: $(gen-locales) |
| 297 |
$(objpfx)tst-resolv-ai_idn-latin1.out: $(gen-locales) |
| 298 |
$(objpfx)tst-resolv-ai_idn-nolibidn2.out: \ |
| 299 |
$(gen-locales) $(objpfx)tst-no-libidn2.so |
| 300 |
$(objpfx)tst-resolv-aliases: $(objpfx)libresolv.so $(shared-thread-library) |
| 301 |
$(objpfx)tst-resolv-basic: $(objpfx)libresolv.so $(shared-thread-library) |
| 302 |
$(objpfx)tst-resolv-binary: $(objpfx)libresolv.so $(shared-thread-library) |
| 303 |
$(objpfx)tst-resolv-byaddr: $(objpfx)libresolv.so $(shared-thread-library) |
| 304 |
$(objpfx)tst-resolv-edns: $(objpfx)libresolv.so $(shared-thread-library) |
| 305 |
$(objpfx)tst-resolv-network: $(objpfx)libresolv.so $(shared-thread-library) |
| 306 |
$(objpfx)tst-resolv-res_init: $(objpfx)libresolv.so |
| 307 |
$(objpfx)tst-resolv-res_init-multi: $(objpfx)libresolv.so \ |
| 308 |
$(shared-thread-library) |
| 309 |
$(objpfx)tst-resolv-res_init-thread: $(objpfx)libresolv.so \ |
| 310 |
$(shared-thread-library) |
| 311 |
$(objpfx)tst-resolv-invalid-cname: $(objpfx)libresolv.so \ |
| 312 |
$(shared-thread-library) |
| 313 |
$(objpfx)tst-resolv-noaaaa: $(objpfx)libresolv.so $(shared-thread-library) |
| 314 |
$(objpfx)tst-resolv-noaaaa-vc: $(objpfx)libresolv.so $(shared-thread-library) |
| 315 |
$(objpfx)tst-resolv-nondecimal: $(objpfx)libresolv.so $(shared-thread-library) |
| 316 |
$(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library) |
| 317 |
$(objpfx)tst-resolv-rotate: $(objpfx)libresolv.so $(shared-thread-library) |
| 318 |
$(objpfx)tst-resolv-search: $(objpfx)libresolv.so $(shared-thread-library) |
| 319 |
$(objpfx)tst-resolv-semi-failure: $(objpfx)libresolv.so \ |
| 320 |
$(shared-thread-library) |
| 321 |
$(objpfx)tst-resolv-short-response: $(objpfx)libresolv.so \ |
| 322 |
$(shared-thread-library) |
| 323 |
$(objpfx)tst-resolv-trailing: $(objpfx)libresolv.so $(shared-thread-library) |
| 324 |
$(objpfx)tst-resolv-threads: $(objpfx)libresolv.so $(shared-thread-library) |
| 325 |
$(objpfx)tst-resolv-txnid-collision: $(objpfx)libresolv.a \ |
| 326 |
$(static-thread-library) |
| 327 |
$(objpfx)tst-resolv-canonname: $(objpfx)libresolv.so $(shared-thread-library) |
| 328 |
$(objpfx)tst-resolv-getaddrinfo-fqdn: $(objpfx)libresolv.so $(shared-thread-library) |
| 329 |
$(objpfx)tst-resolv-trustad: $(objpfx)libresolv.so $(shared-thread-library) |
| 330 |
|
| 331 |
$(objpfx)tst-ns_name: $(objpfx)libresolv.so |
| 332 |
$(objpfx)tst-ns_name.out: tst-ns_name.data |
| 333 |
$(objpfx)tst-ns_name_compress: $(objpfx)libresolv.so |
| 334 |
$(objpfx)tst-ns_name_pton: $(objpfx)libresolv.so |
| 335 |
$(objpfx)tst-res_hnok: $(objpfx)libresolv.so |
| 336 |
$(objpfx)tst-p_secstodate: $(objpfx)libresolv.so |