git: 3687d52b52f6 - stable/12 - ssh: move common Makefile boilerplate to a new ssh.mk

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 09 Nov 2021 00:24:52 UTC
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=3687d52b52f6a4cb739bdb0276ebe60d2b59df24

commit 3687d52b52f6a4cb739bdb0276ebe60d2b59df24
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-02 18:48:33 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-08 23:44:18 +0000

    ssh: move common Makefile boilerplate to a new ssh.mk
    
    This moves SSHDIR and ssh_namespace.h handling to a common location,
    and will simplify future work such as adding U2F support (D32509).
    
    Reviewed by:    kevans
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32808
    
    (cherry picked from commit 9d63429fa16352f58037ac2aa6ddc734b25e8331)
---
 secure/Makefile.inc                       | 6 ------
 secure/lib/libssh/Makefile                | 4 +---
 secure/libexec/sftp-server/Makefile       | 3 +--
 secure/libexec/ssh-keysign/Makefile       | 3 +--
 secure/libexec/ssh-pkcs11-helper/Makefile | 3 +--
 secure/ssh.mk                             | 6 ++++++
 secure/usr.bin/scp/Makefile               | 3 +--
 secure/usr.bin/sftp/Makefile              | 3 +--
 secure/usr.bin/ssh-add/Makefile           | 3 +--
 secure/usr.bin/ssh-agent/Makefile         | 3 +--
 secure/usr.bin/ssh-keygen/Makefile        | 3 +--
 secure/usr.bin/ssh-keyscan/Makefile       | 3 +--
 secure/usr.bin/ssh/Makefile               | 4 +---
 secure/usr.sbin/sshd/Makefile             | 3 +--
 14 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/secure/Makefile.inc b/secure/Makefile.inc
index 6c298be0223f..5de6eed37faf 100644
--- a/secure/Makefile.inc
+++ b/secure/Makefile.inc
@@ -1,15 +1,9 @@
 # $FreeBSD$
 
-.include <src.opts.mk>
-
 .if exists(${.CURDIR:H:H}/lib/libcrypt/obj)
 CRYPTOBJDIR=	${.CURDIR:H:H}/lib/libcrypt/obj
 .else
 CRYPTOBJDIR=	${.CURDIR:H:H}/lib/libcrypt
 .endif
 
-.if ${MK_OPENSSH} != "no"
-SSHDIR=		${SRCTOP}/crypto/openssh
-.endif
-
 WARNS?=		0
diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile
index b325fe9d32d4..bc4319e61746 100644
--- a/secure/lib/libssh/Makefile
+++ b/secure/lib/libssh/Makefile
@@ -1,6 +1,7 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 LIB=	ssh
 PRIVATELIB=	true
@@ -45,9 +46,6 @@ SRCS+=	getrrsetbyname-ldns.c
 LIBADD+=	ldns
 .endif
 
-CFLAGS+= -I${SSHDIR} -include ssh_namespace.h
-SRCS+=	 ssh_namespace.h
-
 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
 CFLAGS+= -include krb5_config.h
 SRCS+=	 krb5_config.h
diff --git a/secure/libexec/sftp-server/Makefile b/secure/libexec/sftp-server/Makefile
index 24d675e0cf16..97408d332d34 100644
--- a/secure/libexec/sftp-server/Makefile
+++ b/secure/libexec/sftp-server/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=   sftp-server
 SRCS=   sftp-server.c sftp-common.c sftp-server-main.c
 MAN=	sftp-server.8
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/libexec/ssh-keysign/Makefile b/secure/libexec/ssh-keysign/Makefile
index e3fc51c66432..72acf1c2d75e 100644
--- a/secure/libexec/ssh-keysign/Makefile
+++ b/secure/libexec/ssh-keysign/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-keysign
 SRCS=	ssh-keysign.c readconf.c uidswap.c
 MAN=	ssh-keysign.8
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 BINMODE=4555
 
 LIBADD=	ssh
diff --git a/secure/libexec/ssh-pkcs11-helper/Makefile b/secure/libexec/ssh-pkcs11-helper/Makefile
index 19e114be935d..c4ae4f503197 100644
--- a/secure/libexec/ssh-pkcs11-helper/Makefile
+++ b/secure/libexec/ssh-pkcs11-helper/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-pkcs11-helper
 SRCS=	ssh-pkcs11.c ssh-pkcs11-helper.c
 MAN=	ssh-pkcs11-helper.8
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/ssh.mk b/secure/ssh.mk
new file mode 100644
index 000000000000..4ab8cd399ae8
--- /dev/null
+++ b/secure/ssh.mk
@@ -0,0 +1,6 @@
+# Common Make variables for OpenSSH
+
+SSHDIR=		${SRCTOP}/crypto/openssh
+
+CFLAGS+= -I${SSHDIR} -include ssh_namespace.h
+SRCS+=	 ssh_namespace.h
diff --git a/secure/usr.bin/scp/Makefile b/secure/usr.bin/scp/Makefile
index 34469a443287..34caf79cf8bd 100644
--- a/secure/usr.bin/scp/Makefile
+++ b/secure/usr.bin/scp/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	scp
 SRCS=	scp.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/usr.bin/sftp/Makefile b/secure/usr.bin/sftp/Makefile
index 249fef233d37..868f7a23bfde 100644
--- a/secure/usr.bin/sftp/Makefile
+++ b/secure/usr.bin/sftp/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	sftp
 SRCS=   sftp.c sftp-client.c sftp-common.c sftp-glob.c progressmeter.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh edit
 
diff --git a/secure/usr.bin/ssh-add/Makefile b/secure/usr.bin/ssh-add/Makefile
index acce73d3841d..173b46c78e0d 100644
--- a/secure/usr.bin/ssh-add/Makefile
+++ b/secure/usr.bin/ssh-add/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-add
 SRCS+=	ssh-add.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/usr.bin/ssh-agent/Makefile b/secure/usr.bin/ssh-agent/Makefile
index 50eafa6ba621..d2b28d1c787b 100644
--- a/secure/usr.bin/ssh-agent/Makefile
+++ b/secure/usr.bin/ssh-agent/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-agent
 SRCS=	ssh-agent.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/usr.bin/ssh-keygen/Makefile b/secure/usr.bin/ssh-keygen/Makefile
index d6b5616dfc0a..e32a6b84302f 100644
--- a/secure/usr.bin/ssh-keygen/Makefile
+++ b/secure/usr.bin/ssh-keygen/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-keygen
 SRCS=	ssh-keygen.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/usr.bin/ssh-keyscan/Makefile b/secure/usr.bin/ssh-keyscan/Makefile
index ade1e4237ff5..130e5f61ec64 100644
--- a/secure/usr.bin/ssh-keyscan/Makefile
+++ b/secure/usr.bin/ssh-keyscan/Makefile
@@ -1,12 +1,11 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-keyscan
 SRCS=	ssh-keyscan.c
 PACKAGE=	ssh
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 LIBADD=	ssh
 
diff --git a/secure/usr.bin/ssh/Makefile b/secure/usr.bin/ssh/Makefile
index 023fa4a55be9..792360967850 100644
--- a/secure/usr.bin/ssh/Makefile
+++ b/secure/usr.bin/ssh/Makefile
@@ -1,6 +1,7 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 CONFS=	ssh_config
 CONFSDIR=	/etc/ssh
@@ -16,9 +17,6 @@ SRCS=	ssh.c readconf.c clientloop.c sshtty.c \
 # gss-genr.c really belongs in libssh; see src/secure/lib/libssh/Makefile
 SRCS+=	gss-genr.c
 
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
-
 LIBADD=	ssh
 
 .if ${MK_LDNS} != "no"
diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile
index f5a4d94a62e6..66f4fc248d15 100644
--- a/secure/usr.sbin/sshd/Makefile
+++ b/secure/usr.sbin/sshd/Makefile
@@ -1,6 +1,7 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 CONFS=	moduli sshd_config
 CONFSDIR=	/etc/ssh
@@ -25,8 +26,6 @@ PACKAGE=	ssh
 SRCS+=	gss-genr.c
 
 MAN=	sshd.8 sshd_config.5
-CFLAGS+=-I${SSHDIR} -include ssh_namespace.h
-SRCS+=	ssh_namespace.h
 
 # Don't rebuild based on moduli.c
 moduli: .MADE