| 1 |
# vim: ft=make ts=4 sw=4 noet |
| 2 |
.DEFAULT_GOAL := all |
| 3 |
|
| 4 |
NAME = bind |
| 5 |
VERSION = 9.20.24 |
| 6 |
GARTYPE = v2 |
| 7 |
|
| 8 |
DESCRIPTION = ISC BIND 9 DNS server |
| 9 |
define BLURB |
| 10 |
BIND 9.20 authoritative and recursive DNS server suite. |
| 11 |
Includes named, rndc, dig, nslookup, host, nsupdate, delv. |
| 12 |
endef |
| 13 |
|
| 14 |
MASTER_SITES = https://ftp.isc.org/isc/bind9/$(VERSION)/ |
| 15 |
DISTFILES += $(NAME)-$(VERSION).tar.xz |
| 16 |
|
| 17 |
LICENSE = LICENSE |
| 18 |
|
| 19 |
# BIND 9.16+ requires libuv >= 1.40; 9.18+ requires liburcu >= 0.10 |
| 20 |
BUILD_DEP_PKGS += OZSWopenssl OZSWzlib OZSWreadline OZSWlibuv OZSWliburcu |
| 21 |
|
| 22 |
# ----------------------------------------------------------------------- |
| 23 |
# OZSWbind9rt — runtime libraries (libdns, libisc, libns, etc.) |
| 24 |
# ----------------------------------------------------------------------- |
| 25 |
PACKAGES += OZSWbind9rt |
| 26 |
SPKG_DESC_OZSWbind9rt = ISC BIND 9.20 runtime libraries |
| 27 |
CATALOGNAME_OZSWbind9rt = bind9rt |
| 28 |
RUNTIME_DEP_PKGS_OZSWbind9rt += OZSWopenssl OZSWzlib OZSWlibuv OZSWliburcu |
| 29 |
PKGFILES_OZSWbind9rt = .*/lib/libdns\.so.* |
| 30 |
PKGFILES_OZSWbind9rt += .*/lib/libbind9\.so.* |
| 31 |
PKGFILES_OZSWbind9rt += .*/lib/libirs\.so.* |
| 32 |
PKGFILES_OZSWbind9rt += .*/lib/libisc\.so.* |
| 33 |
PKGFILES_OZSWbind9rt += .*/lib/libisccc\.so.* |
| 34 |
PKGFILES_OZSWbind9rt += .*/lib/libisccfg\.so.* |
| 35 |
PKGFILES_OZSWbind9rt += .*/lib/libns\.so.* |
| 36 |
|
| 37 |
# ----------------------------------------------------------------------- |
| 38 |
# OZSWbind9 — server, tools, headers (catch-all) |
| 39 |
# ----------------------------------------------------------------------- |
| 40 |
PACKAGES += OZSWbind9 |
| 41 |
SPKG_DESC_OZSWbind9 = ISC BIND 9.20 DNS server and utilities |
| 42 |
CATALOGNAME_OZSWbind9 = bind9 |
| 43 |
RUNTIME_DEP_PKGS_OZSWbind9 += OZSWbind9rt OZSWopenssl OZSWzlib OZSWreadline OZSWlibuv OZSWliburcu |
| 44 |
|
| 45 |
# ----------------------------------------------------------------------- |
| 46 |
# Build configuration |
| 47 |
# ----------------------------------------------------------------------- |
| 48 |
|
| 49 |
EXTENSIONS = 1 |
| 50 |
|
| 51 |
CONFIGURE_ARGS = --prefix=$(prefix) |
| 52 |
CONFIGURE_ARGS += --sysconfdir=/etc/named |
| 53 |
CONFIGURE_ARGS += --localstatedir=/var |
| 54 |
# OpenSSL via BUILD_PREFIX; libuv and liburcu via pkg-config |
| 55 |
CONFIGURE_ARGS += --with-openssl=$(BUILD_PREFIX) |
| 56 |
# Disable optional features we don't have |
| 57 |
CONFIGURE_ARGS += --without-libxml2 |
| 58 |
CONFIGURE_ARGS += --without-gssapi |
| 59 |
CONFIGURE_ARGS += --without-lmdb |
| 60 |
CONFIGURE_ARGS += --without-json-c |
| 61 |
CONFIGURE_ARGS += --without-libnghttp2 |
| 62 |
CONFIGURE_ARGS += --disable-dnstap |
| 63 |
CONFIGURE_ARGS += --disable-doh |
| 64 |
CONFIGURE_ARGS += --disable-dependency-tracking |
| 65 |
CONFIGURE_ARGS += DTRACE= |
| 66 |
# Solaris: socket/nsl/rt/pthread needed explicitly |
| 67 |
CONFIGURE_ARGS += CFLAGS="-D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -include /usr/include/sys/types.h" |
| 68 |
CONFIGURE_ARGS += CXXFLAGS="-D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -include /usr/include/sys/types.h" |
| 69 |
CONFIGURE_ARGS += LDFLAGS="-L$(BUILD_PREFIX)/lib -Wl,-R,$(BUILD_PREFIX)/lib -lsocket -lnsl -lrt -lpthread" |
| 70 |
|
| 71 |
post-extract: |
| 72 |
@echo "==> Creating lib/isc/ifaddrs.h shim (getifaddrs via SIOCGIFCONF for Solaris)" |
| 73 |
@# Only interfaceiter.c includes <ifaddrs.h>; placing it in lib/isc/ makes it |
| 74 |
@# findable via -I$(srcdir) without any Makefile.in changes. |
| 75 |
@# getifaddrs/freeifaddrs are static so they only exist in interfaceiter.c's TU. |
| 76 |
@/opt/ozsw/bin/python3 -c "\ |
| 77 |
import textwrap; \ |
| 78 |
h = textwrap.dedent('''\ |
| 79 |
/* ifaddrs.h -- getifaddrs/freeifaddrs shim for OpenSolaris snv_111b via SIOCGIFCONF.\n\ |
| 80 |
* Only used by BIND'\''s interfaceiter.c; functions are static to avoid ODR issues.\n\ |
| 81 |
*/\n\ |
| 82 |
#ifndef _IFADDRS_H\n\ |
| 83 |
#define _IFADDRS_H\n\ |
| 84 |
\n\ |
| 85 |
#include <sys/types.h>\n\ |
| 86 |
#include <sys/socket.h>\n\ |
| 87 |
#include <sys/ioctl.h>\n\ |
| 88 |
#include <net/if.h>\n\ |
| 89 |
#include <netinet/in.h>\n\ |
| 90 |
#include <stdlib.h>\n\ |
| 91 |
#include <string.h>\n\ |
| 92 |
#include <unistd.h>\n\ |
| 93 |
\n\ |
| 94 |
struct ifaddrs {\n\ |
| 95 |
struct ifaddrs *ifa_next;\n\ |
| 96 |
char *ifa_name;\n\ |
| 97 |
unsigned int ifa_flags;\n\ |
| 98 |
struct sockaddr *ifa_addr;\n\ |
| 99 |
struct sockaddr *ifa_netmask;\n\ |
| 100 |
union {\n\ |
| 101 |
struct sockaddr *ifu_broadaddr;\n\ |
| 102 |
struct sockaddr *ifu_dstaddr;\n\ |
| 103 |
} ifa_ifu;\n\ |
| 104 |
void *ifa_data;\n\ |
| 105 |
};\n\ |
| 106 |
#define ifa_broadaddr ifa_ifu.ifu_broadaddr\n\ |
| 107 |
#define ifa_dstaddr ifa_ifu.ifu_dstaddr\n\ |
| 108 |
\n\ |
| 109 |
static void\n\ |
| 110 |
freeifaddrs(struct ifaddrs *ifa)\n\ |
| 111 |
{\n\ |
| 112 |
while (ifa) {\n\ |
| 113 |
struct ifaddrs *next = ifa->ifa_next;\n\ |
| 114 |
free(ifa->ifa_name);\n\ |
| 115 |
free(ifa->ifa_addr);\n\ |
| 116 |
free(ifa->ifa_netmask);\n\ |
| 117 |
free(ifa);\n\ |
| 118 |
ifa = next;\n\ |
| 119 |
}\n\ |
| 120 |
}\n\ |
| 121 |
\n\ |
| 122 |
static int\n\ |
| 123 |
getifaddrs(struct ifaddrs **ifap)\n\ |
| 124 |
{\n\ |
| 125 |
struct ifconf ifc;\n\ |
| 126 |
struct ifreq buf[64];\n\ |
| 127 |
struct ifaddrs *head = NULL, **tail = &head;\n\ |
| 128 |
int fd, n, i;\n\ |
| 129 |
\n\ |
| 130 |
fd = socket(AF_INET, SOCK_DGRAM, 0);\n\ |
| 131 |
if (fd < 0) return -1;\n\ |
| 132 |
ifc.ifc_len = sizeof(buf);\n\ |
| 133 |
ifc.ifc_req = buf;\n\ |
| 134 |
if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) { close(fd); return -1; }\n\ |
| 135 |
close(fd);\n\ |
| 136 |
\n\ |
| 137 |
n = ifc.ifc_len / (int)sizeof(struct ifreq);\n\ |
| 138 |
for (i = 0; i < n; i++) {\n\ |
| 139 |
struct ifreq req;\n\ |
| 140 |
struct ifaddrs *ifa;\n\ |
| 141 |
int sfd;\n\ |
| 142 |
\n\ |
| 143 |
if (buf[i].ifr_addr.sa_family != AF_INET)\n\ |
| 144 |
continue;\n\ |
| 145 |
\n\ |
| 146 |
ifa = calloc(1, sizeof(*ifa));\n\ |
| 147 |
if (!ifa) goto fail;\n\ |
| 148 |
\n\ |
| 149 |
ifa->ifa_name = strdup(buf[i].ifr_name);\n\ |
| 150 |
if (!ifa->ifa_name) { free(ifa); goto fail; }\n\ |
| 151 |
\n\ |
| 152 |
ifa->ifa_addr = malloc(sizeof(struct sockaddr_in));\n\ |
| 153 |
if (ifa->ifa_addr)\n\ |
| 154 |
memcpy(ifa->ifa_addr, &buf[i].ifr_addr, sizeof(struct sockaddr_in));\n\ |
| 155 |
\n\ |
| 156 |
sfd = socket(AF_INET, SOCK_DGRAM, 0);\n\ |
| 157 |
if (sfd >= 0) {\n\ |
| 158 |
memset(&req, 0, sizeof(req));\n\ |
| 159 |
strncpy(req.ifr_name, buf[i].ifr_name, IFNAMSIZ - 1);\n\ |
| 160 |
if (ioctl(sfd, SIOCGIFFLAGS, &req) == 0)\n\ |
| 161 |
ifa->ifa_flags = (unsigned int)req.ifr_flags;\n\ |
| 162 |
memset(&req, 0, sizeof(req));\n\ |
| 163 |
strncpy(req.ifr_name, buf[i].ifr_name, IFNAMSIZ - 1);\n\ |
| 164 |
if (ioctl(sfd, SIOCGIFNETMASK, &req) == 0) {\n\ |
| 165 |
ifa->ifa_netmask = malloc(sizeof(struct sockaddr_in));\n\ |
| 166 |
if (ifa->ifa_netmask)\n\ |
| 167 |
memcpy(ifa->ifa_netmask, &req.ifr_addr, sizeof(struct sockaddr_in));\n\ |
| 168 |
}\n\ |
| 169 |
close(sfd);\n\ |
| 170 |
}\n\ |
| 171 |
\n\ |
| 172 |
*tail = ifa;\n\ |
| 173 |
tail = &ifa->ifa_next;\n\ |
| 174 |
}\n\ |
| 175 |
*ifap = head;\n\ |
| 176 |
return 0;\n\ |
| 177 |
fail:\n\ |
| 178 |
freeifaddrs(head);\n\ |
| 179 |
return -1;\n\ |
| 180 |
}\n\ |
| 181 |
\n\ |
| 182 |
#endif /* _IFADDRS_H */\n\ |
| 183 |
'''); \ |
| 184 |
open('$(WORKSRC)/lib/isc/ifaddrs.h','w').write(h)" |
| 185 |
@echo "==> Patching util/dtrace.sh: Solaris tr treats a-z as literal, use [:lower:]/[:upper:]" |
| 186 |
@gsed -i 's/| tr "a-z" "A-Z"/| tr '\''[:lower:]'\'' '\''[:upper:]'\''/g' $(WORKSRC)/util/dtrace.sh |
| 187 |
@echo "==> Generating probes.h files with correct uppercase macros (Solaris sed/dtrace.sh produces wrong case)" |
| 188 |
@/opt/ozsw/bin/python3 -c "import re, os; w='$(WORKSRC)'; dirs=['lib/isc','lib/dns','lib/ns']; [(open(os.path.join(w,d,'probes.h'),'w').write(''.join(['#define {p}_{probe}_ENABLED() 0\n#define {p}_{probe}(...)\n'.format(p=re.search(r\"provider (\\S+)\", open(os.path.join(w,d,'probes.d')).read()).group(1).upper(), probe=m.group(1).upper()) for m in re.finditer(r\"probe ([a-z_]+)\\(\", open(os.path.join(w,d,'probes.d')).read())]))) for d in dirs if os.path.exists(os.path.join(w,d,'probes.d'))]" |
| 189 |
@$(MAKECOOKIE) |
| 190 |
|
| 191 |
# Fix libtool ECHO="print -r --" (ksh93 builtin, fails under bash) |
| 192 |
# Regenerate probes.h using dtrace.sh shim so macro names are correct (uppercase). |
| 193 |
# The native Solaris dtrace binary generates mixed-case names that don't match job.c. |
| 194 |
post-configure: |
| 195 |
@find $(WORKSRC) -name "libtool" -type f -exec gsed -i 's/ECHO="print -r --"/ECHO="printf %s\\n"/g' {} \; |
| 196 |
@$(MAKECOOKIE) |
| 197 |
|
| 198 |
include gar/category.mk |