git: 9d63429fa163 - main - ssh: move common Makefile boilerplate to a new ssh.mk

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 03 Nov 2021 23:38:33 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d63429fa16352f58037ac2aa6ddc734b25e8331

commit 9d63429fa16352f58037ac2aa6ddc734b25e8331
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-02 18:48:33 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-03 23:38:05 +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
---
 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 49b5319d2b54..f6ea5c211a03 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
@@ -50,9 +51,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 a4e55c1bf86b..c071f5198902 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 sftp-common.c sftp-client.c sftp-glob.c progressmeter.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 c76e50a4a91a..162ea60a29d0 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 ssh-sk-client.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 95ccd05811fe..c8139ec376c3 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 eec0b23e1b3f..b53b645e8576 100644
--- a/secure/usr.bin/ssh-keygen/Makefile
+++ b/secure/usr.bin/ssh-keygen/Makefile
@@ -1,13 +1,12 @@
 # $FreeBSD$
 
 .include <src.opts.mk>
+.include "${SRCTOP}/secure/ssh.mk"
 
 PROG=	ssh-keygen
 # XXX ssh-sk-client.c in libssh maybe?
 SRCS=	ssh-keygen.c sshsig.c ssh-sk-client.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 614cc7627fc5..5528aceed5ee 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 b374e737a139..a34732f868c7 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