git: 1cc020eba69e - main - ncurses: Provide reproducible paths

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 14 Jul 2025 14:46:27 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1cc020eba69e8c3216683b41487600c6c958cbb0

commit 1cc020eba69e8c3216683b41487600c6c958cbb0
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-07-14 14:45:57 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-07-14 14:45:57 +0000

    ncurses: Provide reproducible paths
    
    Avoid hard-coding the value of SRCTOP in generated files.  Use /usr/src
    as the canonical srcdir.
    
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D50955
---
 lib/ncurses/tinfo/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/ncurses/tinfo/Makefile b/lib/ncurses/tinfo/Makefile
index 920bd6e5559c..476df54bb72a 100644
--- a/lib/ncurses/tinfo/Makefile
+++ b/lib/ncurses/tinfo/Makefile
@@ -259,10 +259,18 @@ term.h: MKterm.h.awk edit_cfg.sh Caps Caps-ncurses
 	sh ${NCURSES_DIR}/include/edit_cfg.sh ${NCURSES_CFG_H} $@.new
 	mv -f $@.new $@
 
+# Avoid hard-coding absolute source paths if requested.
+.if ${MK_REPRODUCIBLE_BUILD} != "no"
+NCURSES_SRCTOP=/usr/src
+.else
+NCURSES_SRCTOP=${SRCTOP}
+.endif
+
 curses.h: curses.head MKkey_defs.sh Caps Caps-ncurses
 	cat curses.head > $@.new
 	AWK=${AWK} _POSIX2_VERSION=199209 sh ${NCURSES_DIR}/include/MKkey_defs.sh \
 	    ${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/include/Caps-ncurses >> $@.new
+	sed -i '' 's|${SRCTOP}|${NCURSES_SRCTOP}|g' $@.new
 	cat ${NCURSES_DIR}/include/curses.wide >> $@.new
 	cat ${NCURSES_DIR}/include/curses.tail >> $@.new
 	mv -f $@.new $@
@@ -387,6 +395,7 @@ unctrl.h: unctrl.h.in
 terminfo.5: MKterminfo.sh terminfo.head Caps
 	sh ${NCURSES_DIR}/man/MKterminfo.sh ${NCURSES_DIR}/man/terminfo.head \
 	    ${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/man/terminfo.tail >$@
+	sed -i '' 's|${SRCTOP}|${NCURSES_SRCTOP}|g' $@
 
 CLEANFILES+=	terminfo.5