9c54517
From 040227009453b3f0aa7914c7a6a94dc57ad5269b Mon Sep 17 00:00:00 2001
f3d54bb
From: Petr Mensik <pemensik@redhat.com>
f3d54bb
Date: Thu, 21 Jan 2021 10:46:20 +0100
f3d54bb
Subject: [PATCH] Enable custom pkcs11 native build
f3d54bb
f3d54bb
Share common parts like libisc, libcc and others. But provide native
f3d54bb
pkcs11 libraries as a new copy of libdns and libns.
f3d54bb
---
f3d54bb
 bin/Makefile.in                  |  2 +-
f3d54bb
 bin/confgen/Makefile.in          |  2 +-
f3d54bb
 bin/dnssec-pkcs11/Makefile.in    | 39 +++++++++++++++++---------------
f3d54bb
 bin/named-pkcs11/Makefile.in     | 33 ++++++++++++++-------------
f3d54bb
 configure.ac                     | 19 ++++++++++++++++
f3d54bb
 lib/Makefile.in                  |  2 +-
f3d54bb
 lib/dns-pkcs11/Makefile.in       | 22 +++++++++---------
f3d54bb
 lib/dns-pkcs11/tests/Makefile.in |  8 +++----
f3d54bb
 lib/ns-pkcs11/Makefile.in        | 26 ++++++++++-----------
f3d54bb
 lib/ns-pkcs11/tests/Makefile.in  | 12 +++++-----
f3d54bb
 make/includes.in                 |  7 ++++++
f3d54bb
 11 files changed, 101 insertions(+), 71 deletions(-)
f3d54bb
dce2d1b
diff --git a/bin/Makefile.in b/bin/Makefile.in
df81e82
index 9ad7f62..094775a 100644
dce2d1b
--- a/bin/Makefile.in
dce2d1b
+++ b/bin/Makefile.in
df81e82
@@ -11,7 +11,7 @@ srcdir =	@srcdir@
dce2d1b
 VPATH =		@srcdir@
dce2d1b
 top_srcdir =	@top_srcdir@
dce2d1b
 
a38c250
-SUBDIRS =	named rndc dig delv dnssec tools nsupdate check confgen \
df81e82
+SUBDIRS =	named named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate check confgen \
df81e82
 		@NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ plugins tests
dce2d1b
 TARGETS =
dce2d1b
 
05dbc88
diff --git a/bin/confgen/Makefile.in b/bin/confgen/Makefile.in
b8ccda0
index c126bf3..1b7512d 100644
05dbc88
--- a/bin/confgen/Makefile.in
05dbc88
+++ b/bin/confgen/Makefile.in
05dbc88
@@ -22,7 +22,7 @@ VERSION=@BIND9_VERSION@
05dbc88
 CINCLUDES = -I${srcdir}/include ${ISC_INCLUDES} ${ISCCC_INCLUDES} \
05dbc88
 	${ISCCFG_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES}
05dbc88
 
05dbc88
-CDEFINES = @USE_PKCS11@
05dbc88
+CDEFINES =
05dbc88
 CWARNINGS =
05dbc88
 
05dbc88
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
dce2d1b
diff --git a/bin/dnssec-pkcs11/Makefile.in b/bin/dnssec-pkcs11/Makefile.in
b8ccda0
index ace0e5a..e0f6a00 100644
dce2d1b
--- a/bin/dnssec-pkcs11/Makefile.in
dce2d1b
+++ b/bin/dnssec-pkcs11/Makefile.in
afbbd0b
@@ -15,18 +15,18 @@ VERSION=@BIND9_VERSION@
dce2d1b
 
dce2d1b
 @BIND9_MAKE_INCLUDES@
dce2d1b
 
afbbd0b
-CINCLUDES =	${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \
afbbd0b
+CINCLUDES =	${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \
afbbd0b
 		${OPENSSL_CFLAGS}
dce2d1b
 
afbbd0b
-CDEFINES =	-DVERSION=\"${VERSION}\" -DNAMED_CONFFILE=\"${sysconfdir}/named.conf\"
afbbd0b
+CDEFINES =	-DVERSION=\"${VERSION}\" -DNAMED_CONFFILE=\"${sysconfdir}/named.conf\" -DUSE_PKCS11=1
dce2d1b
 CWARNINGS =
dce2d1b
 
b8ccda0
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda0
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
afbbd0b
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
b8ccda0
 ISCLIBS =	../../lib/isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
b8ccda0
 ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @NO_LIBTOOL_ISCLIBS@
dce2d1b
 
dce2d1b
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
dce2d1b
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
05dbc88
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
afbbd0b
 ISCCFGDEPLIBS =	../../lib/isccfg/libisccfg.@A@
dce2d1b
 
afbbd0b
@@ -36,12 +36,15 @@ LIBS =		${DNSLIBS} ${ISCCFGLIBS} ${ISCLIBS} @LIBS@
dce2d1b
 
afbbd0b
 NOSYMLIBS =	${DNSLIBS} ${ISCCFGLIBS} ${ISCNOSYMLIBS} @LIBS@
afbbd0b
 
afbbd0b
+# Add suffix to all targets
afbbd0b
+EXEEXT =	-pkcs11@EXEEXT@
afbbd0b
+
dce2d1b
 # Alphabetically
df81e82
-TARGETS =	dnssec-cds@EXEEXT@ dnssec-dsfromkey@EXEEXT@ \
df81e82
-		dnssec-importkey@EXEEXT@ dnssec-keyfromlabel@EXEEXT@ \
df81e82
-		dnssec-keygen@EXEEXT@ dnssec-revoke@EXEEXT@ \
df81e82
-		dnssec-settime@EXEEXT@ dnssec-signzone@EXEEXT@ \
df81e82
-		dnssec-verify@EXEEXT@
afbbd0b
+TARGETS =	dnssec-cds${EXEEXT} dnssec-dsfromkey${EXEEXT} \
afbbd0b
+		dnssec-importkey${EXEEXT} dnssec-keyfromlabel${EXEEXT} \
afbbd0b
+		dnssec-keygen${EXEEXT} dnssec-revoke${EXEEXT} \
afbbd0b
+		dnssec-settime${EXEEXT} dnssec-signzone${EXEEXT} \
afbbd0b
+		dnssec-verify${EXEEXT}
dce2d1b
 
dce2d1b
 OBJS =		dnssectool.@O@
dce2d1b
 
b8ccda0
@@ -52,19 +55,19 @@ SRCS =		dnssec-cds.c dnssec-dsfromkey.c dnssec-importkey.c \
dce2d1b
 
dce2d1b
 @BIND9_MAKE_RULES@
dce2d1b
 
df81e82
-dnssec-cds@EXEEXT@: dnssec-cds.@O@ ${OBJS} ${DEPLIBS}
df81e82
+dnssec-cds-pkcs11@EXEEXT@: dnssec-cds.@O@ ${OBJS} ${DEPLIBS}
df81e82
 	export BASEOBJS="dnssec-cds.@O@ ${OBJS}"; \
df81e82
 	${FINALBUILDCMD}
df81e82
 
dce2d1b
-dnssec-dsfromkey@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-dsfromkey-pkcs11@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	export BASEOBJS="dnssec-dsfromkey.@O@ ${OBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
dce2d1b
 
dce2d1b
-dnssec-keyfromlabel@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-keyfromlabel-pkcs11@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	export BASEOBJS="dnssec-keyfromlabel.@O@ ${OBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
dce2d1b
 
dce2d1b
-dnssec-keygen@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-keygen-pkcs11@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	export BASEOBJS="dnssec-keygen.@O@ ${OBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
dce2d1b
 
b8ccda0
@@ -72,7 +75,7 @@ dnssec-signzone.@O@: dnssec-signzone.c
dce2d1b
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
dce2d1b
 		-c ${srcdir}/dnssec-signzone.c
dce2d1b
 
dce2d1b
-dnssec-signzone@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-signzone-pkcs11@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	export BASEOBJS="dnssec-signzone.@O@ ${OBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
dce2d1b
 
b8ccda0
@@ -80,19 +83,19 @@ dnssec-verify.@O@: dnssec-verify.c
dce2d1b
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
dce2d1b
 		-c ${srcdir}/dnssec-verify.c
dce2d1b
 
dce2d1b
-dnssec-verify@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-verify-pkcs11@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	export BASEOBJS="dnssec-verify.@O@ ${OBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
dce2d1b
 
dce2d1b
-dnssec-revoke@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-revoke-pkcs11@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
dce2d1b
 	dnssec-revoke.@O@ ${OBJS} ${LIBS}
dce2d1b
 
dce2d1b
-dnssec-settime@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-settime-pkcs11@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
dce2d1b
 	dnssec-settime.@O@ ${OBJS} ${LIBS}
dce2d1b
 
dce2d1b
-dnssec-importkey@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
+dnssec-importkey-pkcs11@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
dce2d1b
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
dce2d1b
 	dnssec-importkey.@O@ ${OBJS} ${LIBS}
dce2d1b
 
dce2d1b
diff --git a/bin/named-pkcs11/Makefile.in b/bin/named-pkcs11/Makefile.in
76074cd
index 98125dd..518a75f 100644
dce2d1b
--- a/bin/named-pkcs11/Makefile.in
dce2d1b
+++ b/bin/named-pkcs11/Makefile.in
afbbd0b
@@ -37,13 +37,14 @@ DBDRIVER_LIBS =
afbbd0b
 
afbbd0b
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
afbbd0b
 
afbbd0b
-DLZDRIVER_OBJS =	@DLZ_DRIVER_OBJS@
afbbd0b
-DLZDRIVER_SRCS =	@DLZ_DRIVER_SRCS@
afbbd0b
-DLZDRIVER_INCLUDES =	@DLZ_DRIVER_INCLUDES@
afbbd0b
-DLZDRIVER_LIBS =	@DLZ_DRIVER_LIBS@
afbbd0b
+# Skip building on PKCS11 variant
afbbd0b
+DLZDRIVER_OBJS =
afbbd0b
+DLZDRIVER_SRCS =
afbbd0b
+DLZDRIVER_INCLUDES =
afbbd0b
+DLZDRIVER_LIBS =
dce2d1b
 
dce2d1b
 CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
df81e82
-		${NS_INCLUDES} ${DNS_INCLUDES} \
05dbc88
+		${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} \
df81e82
 		${BIND9_INCLUDES} ${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} \
05dbc88
 		${ISC_INCLUDES} ${DLZDRIVER_INCLUDES} \
afbbd0b
 		${DBDRIVER_INCLUDES} \
76074cd
@@ -56,24 +57,24 @@ CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
b8ccda0
 		${LIBXML2_CFLAGS} \
b8ccda0
 		${MAXMINDDB_CFLAGS}
afbbd0b
 
afbbd0b
-CDEFINES =      @CONTRIB_DLZ@
afbbd0b
+CDEFINES =
dce2d1b
 
dce2d1b
 CWARNINGS =
dce2d1b
 
b8ccda0
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda0
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
dce2d1b
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
dce2d1b
 ISCCCLIBS =	../../lib/isccc/libisccc.@A@
b8ccda0
 ISCLIBS =	../../lib/isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
b8ccda0
 ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @NO_LIBTOOL_ISCLIBS@
dce2d1b
 BIND9LIBS =	../../lib/bind9/libbind9.@A@
05dbc88
-NSLIBS =	../../lib/ns/libns.@A@
05dbc88
+NSLIBS =	../../lib/ns-pkcs11/libns-pkcs11.@A@
dce2d1b
 
dce2d1b
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
371a1e3
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
dce2d1b
 ISCCFGDEPLIBS =	../../lib/isccfg/libisccfg.@A@
dce2d1b
 ISCCCDEPLIBS =	../../lib/isccc/libisccc.@A@
05dbc88
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
dce2d1b
 BIND9DEPLIBS =	../../lib/bind9/libbind9.@A@
05dbc88
-NSDEPLIBS =	../../lib/ns/libns.@A@
05dbc88
+NSDEPLIBS =	../../lib/ns-pkcs11/libns-pkcs11.@A@
dce2d1b
 
05dbc88
 DEPLIBS =	${NSDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
05dbc88
 		${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
76074cd
@@ -93,7 +94,7 @@ NOSYMLIBS =	${NSLIBS} ${DNSLIBS} ${BIND9LIBS} \
dce2d1b
 
dce2d1b
 SUBDIRS =	unix
dce2d1b
 
df81e82
-TARGETS =	named@EXEEXT@ feature-test@EXEEXT@
d0d7288
+TARGETS =	named-pkcs11@EXEEXT@ feature-test-pkcs11@EXEEXT@
dce2d1b
 
2dbb099
 GEOIP2LINKOBJS = geoip.@O@
afbbd0b
 
76074cd
@@ -151,7 +152,7 @@ server.@O@: server.c
Michal Ruprich d886cd0
 		-DPRODUCT=\"${PRODUCT}\" \
Michal Ruprich d886cd0
 		-DVERSION=\"${VERSION}\" -c ${srcdir}/server.c
dce2d1b
 
cb21723
-named@EXEEXT@: ${OBJS} ${DEPLIBS}
cb21723
+named-pkcs11@EXEEXT@: ${OBJS} ${DEPLIBS}
dce2d1b
 	export MAKE_SYMTABLE="yes"; \
dce2d1b
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
dce2d1b
 	${FINALBUILDCMD}
76074cd
@@ -161,7 +162,7 @@ feature-test.@O@: ${top_srcdir}/bin/tests/system/feature-test.c
d0d7288
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
d0d7288
 		-c ${top_srcdir}/bin/tests/system/feature-test.c
d0d7288
 
d0d7288
-feature-test@EXEEXT@: feature-test.@O@
d0d7288
+feature-test-pkcs11@EXEEXT@: feature-test.@O@
d0d7288
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \
d0d7288
 		-o $@ feature-test.@O@ ${ISCLIBS} ${LIBS}
cb21723
 
76074cd
@@ -180,11 +181,11 @@ statschannel.@O@: bind9.xsl.h
b8ccda0
 installdirs:
b8ccda0
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
Michal Ruprich d886cd0
 
b8ccda0
-install:: named@EXEEXT@ installdirs
dce2d1b
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
b8ccda0
+install:: named-pkcs11@EXEEXT@ installdirs
dce2d1b
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-pkcs11@EXEEXT@ ${DESTDIR}${sbindir}
dce2d1b
 
102df25
 uninstall::
102df25
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
102df25
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named-pkcs11@EXEEXT@
102df25
 
dce2d1b
 @DLZ_DRIVER_RULES@
dce2d1b
 
1e41691
diff --git a/configure.ac b/configure.ac
9c54517
index 032228b..64e3da0 100644
1e41691
--- a/configure.ac
1e41691
+++ b/configure.ac
76074cd
@@ -1251,12 +1251,14 @@ AC_SUBST(USE_GSSAPI)
4fa9972
 AC_SUBST(DST_GSSAPI_INC)
4fa9972
 AC_SUBST(DNS_GSSAPI_LIBS)
df81e82
 DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS"
4fa9972
+DNS_CRYPTO_PK11_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_PK11_LIBS"
4fa9972
 
4fa9972
 #
4fa9972
 # Applications linking with libdns also need to link with these libraries.
4fa9972
 #
4fa9972
 
4fa9972
 AC_SUBST(DNS_CRYPTO_LIBS)
4fa9972
+AC_SUBST(DNS_CRYPTO_PK11_LIBS)
4fa9972
 
4fa9972
 #
df81e82
 # was --with-lmdb specified?
f8cb93d
@@ -2327,6 +2329,8 @@ AC_SUBST(BIND9_DNS_BUILDINCLUDE)
df81e82
 AC_SUBST(BIND9_NS_BUILDINCLUDE)
df81e82
 AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
df81e82
 AC_SUBST(BIND9_IRS_BUILDINCLUDE)
df81e82
+AC_SUBST(BIND9_DNS_PKCS11_BUILDINCLUDE)
df81e82
+AC_SUBST(BIND9_NS_PKCS11_BUILDINCLUDE)
df81e82
 if test "X$srcdir" != "X"; then
df81e82
 	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
df81e82
 	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
f8cb93d
@@ -2335,6 +2339,8 @@ if test "X$srcdir" != "X"; then
df81e82
 	BIND9_NS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/ns/include"
df81e82
 	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
df81e82
 	BIND9_IRS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/irs/include"
df81e82
+	BIND9_DNS_PKCS11_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns-pkcs11/include"
df81e82
+	BIND9_NS_PKCS11_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/ns-pkcs11/include"
df81e82
 else
df81e82
 	BIND9_ISC_BUILDINCLUDE=""
df81e82
 	BIND9_ISCCC_BUILDINCLUDE=""
f8cb93d
@@ -2343,6 +2349,8 @@ else
df81e82
 	BIND9_NS_BUILDINCLUDE=""
df81e82
 	BIND9_BIND9_BUILDINCLUDE=""
df81e82
 	BIND9_IRS_BUILDINCLUDE=""
df81e82
+	BIND9_DNS_PKCS11_BUILDINCLUDE=""
df81e82
+	BIND9_NS_PKCS11_BUILDINCLUDE=""
dce2d1b
 fi
df81e82
 
df81e82
 AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
f8cb93d
@@ -2798,8 +2806,11 @@ AC_CONFIG_FILES([
4fa9972
 	bin/delv/Makefile
dce2d1b
 	bin/dig/Makefile
dce2d1b
 	bin/dnssec/Makefile
df81e82
+	bin/dnssec-pkcs11/Makefile
dce2d1b
 	bin/named/Makefile
4fa9972
 	bin/named/unix/Makefile
dce2d1b
+	bin/named-pkcs11/Makefile
dce2d1b
+	bin/named-pkcs11/unix/Makefile
dce2d1b
 	bin/nsupdate/Makefile
dce2d1b
 	bin/pkcs11/Makefile
df81e82
 	bin/plugins/Makefile
f8cb93d
@@ -2861,6 +2872,10 @@ AC_CONFIG_FILES([
dce2d1b
 	lib/dns/include/dns/Makefile
dce2d1b
 	lib/dns/include/dst/Makefile
dce2d1b
 	lib/dns/tests/Makefile
dce2d1b
+	lib/dns-pkcs11/Makefile
dce2d1b
+	lib/dns-pkcs11/include/Makefile
dce2d1b
+	lib/dns-pkcs11/include/dns/Makefile
dce2d1b
+	lib/dns-pkcs11/include/dst/Makefile
4fa9972
 	lib/irs/Makefile
4fa9972
 	lib/irs/include/Makefile
4fa9972
 	lib/irs/include/irs/Makefile
f8cb93d
@@ -2893,6 +2908,10 @@ AC_CONFIG_FILES([
05dbc88
 	lib/ns/include/Makefile
05dbc88
 	lib/ns/include/ns/Makefile
05dbc88
 	lib/ns/tests/Makefile
05dbc88
+	lib/ns-pkcs11/Makefile
05dbc88
+	lib/ns-pkcs11/include/Makefile
05dbc88
+	lib/ns-pkcs11/include/ns/Makefile
05dbc88
+	lib/ns-pkcs11/tests/Makefile
afbbd0b
 	make/Makefile
9c54517
 	make/mkdep
9c54517
 	unit/unittest.sh
dce2d1b
diff --git a/lib/Makefile.in b/lib/Makefile.in
9c54517
index 833964e..058ba2f 100644
dce2d1b
--- a/lib/Makefile.in
dce2d1b
+++ b/lib/Makefile.in
a38c250
@@ -15,7 +15,7 @@ top_srcdir =	@top_srcdir@
dce2d1b
 # Attempt to disable parallel processing.
dce2d1b
 .NOTPARALLEL:
dce2d1b
 .NO_PARALLEL:
9c54517
-SUBDIRS =	isc isccc dns ns isccfg bind9 irs
9c54517
+SUBDIRS =	isc isccc dns dns-pkcs11 ns ns-pkcs11 isccfg bind9 irs
dce2d1b
 TARGETS =
dce2d1b
 
dce2d1b
 @BIND9_MAKE_RULES@
dce2d1b
diff --git a/lib/dns-pkcs11/Makefile.in b/lib/dns-pkcs11/Makefile.in
f8cb93d
index 58bda3c..d6a45df 100644
dce2d1b
--- a/lib/dns-pkcs11/Makefile.in
dce2d1b
+++ b/lib/dns-pkcs11/Makefile.in
f8cb93d
@@ -22,7 +22,7 @@ VERSION=@BIND9_VERSION@
dce2d1b
 
f8cb93d
 @BIND9_MAKE_INCLUDES@
dce2d1b
 
4fa9972
-CINCLUDES =	-I. -I${top_srcdir}/lib/dns -Iinclude ${DNS_INCLUDES} \
4fa9972
+CINCLUDES =	-I. -I${top_srcdir}/lib/dns-pkcs11 -Iinclude ${DNS_PKCS11_INCLUDES} \
afbbd0b
 		${ISC_INCLUDES} \
b8ccda0
 		${FSTRM_CFLAGS} \
afbbd0b
 		${OPENSSL_CFLAGS} @DST_GSSAPI_INC@ \
f8cb93d
@@ -32,7 +32,7 @@ CINCLUDES =	-I. -I${top_srcdir}/lib/dns -Iinclude ${DNS_INCLUDES} \
b8ccda0
 		${LMDB_CFLAGS} \
afbbd0b
 		${MAXMINDDB_CFLAGS}
dce2d1b
 
f8cb93d
-CDEFINES =	@USE_GSSAPI@
f8cb93d
+CDEFINES =	@USE_GSSAPI@ @USE_PKCS11@
dce2d1b
 
dce2d1b
 CWARNINGS =
dce2d1b
 
f8cb93d
@@ -135,15 +135,15 @@ version.@O@: version.c
76074cd
 		-DMAPAPI=\"${MAPAPI}\" \
4fa9972
 		-c ${srcdir}/version.c
dce2d1b
 
dce2d1b
-libdns.@SA@: ${OBJS}
dce2d1b
+libdns-pkcs11.@SA@: ${OBJS}
dce2d1b
 	${AR} ${ARFLAGS} $@ ${OBJS}
dce2d1b
 	${RANLIB} $@
dce2d1b
 
dce2d1b
-libdns.la: ${OBJS}
dce2d1b
+libdns-pkcs11.la: ${OBJS}
dce2d1b
 	${LIBTOOL_MODE_LINK} \
dce2d1b
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la -rpath ${libdir} \
dce2d1b
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns-pkcs11.la -rpath ${libdir} \
76074cd
 		-release "${VERSION}" \
dce2d1b
-		${OBJS} ${ISCLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}
dce2d1b
+		${OBJS} ${ISCLIBS} @DNS_CRYPTO_PK11_LIBS@ ${LIBS}
102df25
 
79d28ed
 include: gen
79d28ed
 	${MAKE} include/dns/enumtype.h
f8cb93d
@@ -174,22 +174,22 @@ gen: gen.c
2dbb099
 	${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c \
2dbb099
 	${BUILD_LIBS} ${LFS_LIBS}
79d28ed
 
79d28ed
-timestamp: include libdns.@A@
79d28ed
+timestamp: include libdns-pkcs11.@A@
dce2d1b
 	touch timestamp
102df25
 
79d28ed
-testdirs: libdns.@A@
79d28ed
+testdirs: libdns-pkcs11.@A@
79d28ed
 
dce2d1b
 installdirs:
dce2d1b
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
102df25
 
dce2d1b
 install:: timestamp installdirs
dce2d1b
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns.@A@ ${DESTDIR}${libdir}
dce2d1b
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns-pkcs11.@A@ ${DESTDIR}${libdir}
102df25
 
102df25
 uninstall::
102df25
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns.@A@
102df25
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns-pkcs11.@A@
102df25
 
dce2d1b
 clean distclean::
dce2d1b
-	rm -f libdns.@A@ timestamp
dce2d1b
+	rm -f libdns-pkcs11.@A@ timestamp
dce2d1b
 	rm -f gen code.h include/dns/enumtype.h include/dns/enumclass.h
dce2d1b
 	rm -f include/dns/rdatastruct.h
2dbb099
 	rm -f dnstap.pb-c.c dnstap.pb-c.h
05dbc88
diff --git a/lib/dns-pkcs11/tests/Makefile.in b/lib/dns-pkcs11/tests/Makefile.in
76074cd
index 3bb5e01..c96fe7d 100644
05dbc88
--- a/lib/dns-pkcs11/tests/Makefile.in
05dbc88
+++ b/lib/dns-pkcs11/tests/Makefile.in
76074cd
@@ -15,15 +15,15 @@ VERSION=@BIND9_VERSION@
05dbc88
 
05dbc88
 @BIND9_MAKE_INCLUDES@
05dbc88
 
05dbc88
-CINCLUDES =	-I. -Iinclude ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc88
+CINCLUDES =	-I. -Iinclude ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
76074cd
 		${FSTRM_CFLAGS} ${OPENSSL_CFLAGS} \
76074cd
 		${PROTOBUF_C_CFLAGS} ${MAXMINDDB_CFLAGS} @CMOCKA_CFLAGS@
05dbc88
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/dns/tests/\""
05dbc88
+CDEFINES =	@USE_PKCS11@ -DTESTS="\"${top_builddir}/lib/dns-pkcs11/tests/\""
05dbc88
 
b8ccda0
 ISCLIBS =	../../isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
05dbc88
 ISCDEPLIBS =	../../isc/libisc.@A@
b8ccda0
-DNSLIBS =	../libdns.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc88
-DNSDEPLIBS =	../libdns.@A@
b8ccda0
+DNSLIBS =	../libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc88
+DNSDEPLIBS =	../libdns-pkcs11.@A@
05dbc88
 
05dbc88
 LIBS =		@LIBS@ @CMOCKA_LIBS@
05dbc88
 
05dbc88
diff --git a/lib/ns-pkcs11/Makefile.in b/lib/ns-pkcs11/Makefile.in
f8cb93d
index bc683ce..7a9d2f2 100644
05dbc88
--- a/lib/ns-pkcs11/Makefile.in
05dbc88
+++ b/lib/ns-pkcs11/Makefile.in
f8cb93d
@@ -16,12 +16,12 @@ VERSION=@BIND9_VERSION@
05dbc88
 
f8cb93d
 @BIND9_MAKE_INCLUDES@
05dbc88
 
05dbc88
-CINCLUDES =	-I. -I${top_srcdir}/lib/ns -Iinclude \
05dbc88
-		${NS_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc88
+CINCLUDES =	-I. -I${top_srcdir}/lib/ns-pkcs11 -Iinclude \
05dbc88
+		${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
b8ccda0
 		${OPENSSL_CFLAGS} @DST_GSSAPI_INC@ \
b8ccda0
 		${FSTRM_CFLAGS}
05dbc88
 
afbbd0b
-CDEFINES =	-DNAMED_PLUGINDIR=\"${plugindir}\"
afbbd0b
+CDEFINES =	@USE_PKCS11@ -DNAMED_PLUGINDIR=\"${plugindir}\"
afbbd0b
 
afbbd0b
 CWARNINGS =
afbbd0b
 
f8cb93d
@@ -29,9 +29,9 @@ ISCLIBS =	../../lib/isc/libisc.@A@
05dbc88
 
05dbc88
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
05dbc88
 
b8ccda0
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda0
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc88
 
05dbc88
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
05dbc88
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
05dbc88
 
05dbc88
 LIBS =		@LIBS@
05dbc88
 
f8cb93d
@@ -60,28 +60,28 @@ version.@O@: version.c
76074cd
 		-DMAJOR=\"${MAJOR}\" \
dce2d1b
 		-c ${srcdir}/version.c
dce2d1b
 
05dbc88
-libns.@SA@: ${OBJS}
05dbc88
+libns-pkcs11.@SA@: ${OBJS}
dce2d1b
 	${AR} ${ARFLAGS} $@ ${OBJS}
dce2d1b
 	${RANLIB} $@
dce2d1b
 
05dbc88
-libns.la: ${OBJS}
05dbc88
+libns-pkcs11.la: ${OBJS}
dce2d1b
 	${LIBTOOL_MODE_LINK} \
05dbc88
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libns.la -rpath ${libdir} \
05dbc88
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libns-pkcs11.la -rpath ${libdir} \
76074cd
 		-release "${VERSION}" \
b8ccda0
-		${OBJS} ${ISCLIBS} ${DNSLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}
b8ccda0
+		${OBJS} ${ISCLIBS} ${DNSLIBS} @DNS_CRYPTO_PK11_LIBS@ ${LIBS}
dce2d1b
 
05dbc88
-timestamp: libns.@A@
05dbc88
+timestamp: libns-pkcs11.@A@
dce2d1b
 	touch timestamp
dce2d1b
 
dce2d1b
 installdirs:
dce2d1b
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
dce2d1b
 
dce2d1b
 install:: timestamp installdirs
05dbc88
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libns.@A@ \
05dbc88
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libns-pkcs11.@A@ \
05dbc88
 		${DESTDIR}${libdir}
dce2d1b
 
102df25
 uninstall::
05dbc88
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libns.@A@
05dbc88
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libns-pkcs11.@A@
102df25
 
dce2d1b
 clean distclean::
05dbc88
-	rm -f libns.@A@ timestamp
05dbc88
+	rm -f libns-pkcs11.@A@ timestamp
05dbc88
diff --git a/lib/ns-pkcs11/tests/Makefile.in b/lib/ns-pkcs11/tests/Makefile.in
f3d54bb
index 4c3e694..c1b6d99 100644
05dbc88
--- a/lib/ns-pkcs11/tests/Makefile.in
05dbc88
+++ b/lib/ns-pkcs11/tests/Makefile.in
b471154
@@ -17,17 +17,17 @@ VERSION=@BIND9_VERSION@
b471154
 
f3d54bb
 WRAP_OPTIONS =	-Wl,--wrap=isc__nmhandle_detach -Wl,--wrap=isc__nmhandle_attach
05dbc88
 
05dbc88
-CINCLUDES =	-I. -Iinclude ${NS_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc88
+CINCLUDES =	-I. -Iinclude ${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
afbbd0b
 		${OPENSSL_CFLAGS} \
afbbd0b
 		@CMOCKA_CFLAGS@
05dbc88
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/ns/tests/\"" -DNAMED_PLUGINDIR=\"${plugindir}\"
b471154
+CDEFINES =	-DTESTS="\"${top_builddir}/lib/ns-pkcs11/tests/\"" -DNAMED_PLUGINDIR=\"${plugindir}\" @USE_PKCS11@
05dbc88
 
b8ccda0
 ISCLIBS =	../../isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
05dbc88
 ISCDEPLIBS =	../../isc/libisc.@A@
b8ccda0
-DNSLIBS =	../../dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc88
-DNSDEPLIBS =	../../dns/libdns.@A@
05dbc88
-NSLIBS =	../libns.@A@
05dbc88
-NSDEPLIBS =	../libns.@A@
b8ccda0
+DNSLIBS =	../../dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc88
+DNSDEPLIBS =	../../dns-pkcs11/libdns-pkcs11.@A@
05dbc88
+NSLIBS =	../libns-pkcs11.@A@
05dbc88
+NSDEPLIBS =	../libns-pkcs11.@A@
df81e82
 
df81e82
 LIBS =		@LIBS@ @CMOCKA_LIBS@
05dbc88
 
dce2d1b
diff --git a/make/includes.in b/make/includes.in
76074cd
index b8317d3..b73b0c4 100644
dce2d1b
--- a/make/includes.in
dce2d1b
+++ b/make/includes.in
76074cd
@@ -39,3 +39,10 @@ BIND9_INCLUDES = @BIND9_BIND9_BUILDINCLUDE@ \
dce2d1b
 
dce2d1b
 TEST_INCLUDES = \
dce2d1b
 	-I${top_srcdir}/lib/tests/include
dce2d1b
+
df81e82
+DNS_PKCS11_INCLUDES = @BIND9_DNS_PKCS11_BUILDINCLUDE@ \
dce2d1b
+	-I${top_srcdir}/lib/dns-pkcs11/include
df81e82
+
df81e82
+NS_PKCS11_INCLUDES = @BIND9_NS_PKCS11_BUILDINCLUDE@ \
df81e82
+	-I${top_srcdir}/lib/ns-pkcs11/include
df81e82
+
f3d54bb
-- 
f8cb93d
2.26.3
f3d54bb