diff --git a/share/man/man5/mk.conf.5 b/share/man/man5/mk.conf.5 index 98d3395e49a2..4406063ee1ca 100644 --- a/share/man/man5/mk.conf.5 +++ b/share/man/man5/mk.conf.5 @@ -1,4 +1,4 @@ -.\" $NetBSD: mk.conf.5,v 1.108 2023/07/23 16:52:37 lukem Exp $ +.\" $NetBSD: mk.conf.5,v 1.109 2024/05/29 02:06:45 riastradh Exp $ .\" .\" Copyright (c) 1999-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -1859,6 +1859,16 @@ builds from real releases. .DFLTu .Pq I.e., Dq no . . +.It Sy NETBSD_REVISIONID +Tree-wide revision identifier, such as a Mercurial or Git commit hash +or similar. +If set, will be included in program notes where +.Xr __RCSID 3 +and +.Xr __KERNEL_RCSID 3 +are used, and will be reported by +.Xr ident 1 . +.DFLTu .It Sy NOCLEANDIR If set, avoids the .Dq make cleandir diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 8e6404ee10c3..83c151265ec9 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.1373 2024/04/28 08:01:04 nia Exp $ +# $NetBSD: bsd.own.mk,v 1.1374 2024/05/29 02:06:45 riastradh Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -235,6 +235,14 @@ PRINTOBJDIR= ${MAKE} -V .OBJDIR PRINTOBJDIR= echo /error/bsd.own.mk/PRINTOBJDIR # avoid infinite recursion .endif +# +# Make sure we set _NETBSD_REVISIONID in CPPFLAGS if requested. +# +.ifdef NETBSD_REVISIONID +_NETBSD_REVISIONID_STR= "${NETBSD_REVISIONID}" +CPPFLAGS+= -D_NETBSD_REVISIONID=${_NETBSD_REVISIONID_STR:Q} +.endif + # # Determine if running in the NetBSD source tree by checking for the # existence of build.sh and tools/ in the current or a parent directory, diff --git a/sys/sys/cdefs_aout.h b/sys/sys/cdefs_aout.h index b58e72f6d7ec..f62546d8cf48 100644 --- a/sys/sys/cdefs_aout.h +++ b/sys/sys/cdefs_aout.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs_aout.h,v 1.20 2006/05/18 17:55:38 christos Exp $ */ +/* $NetBSD: cdefs_aout.h,v 1.21 2024/05/29 02:06:46 riastradh Exp $ */ /* * Written by J.T. Conklin 01/17/95. @@ -77,7 +77,14 @@ #undef __KERNEL_RCSID +#ifdef _NETBSD_REVISIONID +#define __RCSID(_s) \ + __IDSTRING(rcsid,_s); \ + __IDSTRING(revisionid, \ + "$" "NetBSD: " __FILE__ " " _NETBSD_REVISIONID " $") +#else #define __RCSID(_s) __IDSTRING(rcsid,_s) +#endif #define __SCCSID(_s) #define __SCCSID2(_s) #if 0 /* XXX userland __COPYRIGHTs have \ns in them */ diff --git a/sys/sys/cdefs_elf.h b/sys/sys/cdefs_elf.h index bf997c84b378..bea672a3523f 100644 --- a/sys/sys/cdefs_elf.h +++ b/sys/sys/cdefs_elf.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs_elf.h,v 1.58 2021/06/04 01:58:02 thorpej Exp $ */ +/* $NetBSD: cdefs_elf.h,v 1.59 2024/05/29 02:06:46 riastradh Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -162,7 +162,14 @@ #define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s) -#define __RCSID(_s) __IDSTRING(rcsid,_s) +#ifdef _NETBSD_REVISIONID +#define __RCSID(_s) \ + __IDSTRING(rcsid,_s); \ + __IDSTRING(revisionid, \ + "$" "NetBSD: " __FILE__ " " _NETBSD_REVISIONID " $") +#else +#define __RCSID(_s) __IDSTRING(rcsid,_s) +#endif #define __SCCSID(_s) #define __SCCSID2(_s) #define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s)