git: c0cf36bc0210 - main - ncurses: rework static linker script generation

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Tue, 26 Oct 2021 13:57:33 UTC
The branch main has been updated by bapt:

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

commit c0cf36bc0210c4d74f626b944b4c7036cb01df5d
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-10-26 10:02:00 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-10-26 13:57:29 +0000

    ncurses: rework static linker script generation
    
    Rework the generation of the linker script to make it in par with
    ldscript, this also forces the regeneration of the .aldscript in the obj
    dir which might in the past have ended up empty.
    
    Tested by:      manu
---
 lib/ncurses/ncurses/Makefile              | 19 +++++++++----------
 lib/ncurses/ncurses/libncursesw.aldscript |  1 +
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index 951e8a4ea63f..af733d3ac613 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -170,13 +170,12 @@ SYMLINKS+=	libncursesw_p.a ${LIBDIR}/libcurses_p.a
 LIBADD+=	tinfow
 SHLIB_LDSCRIPT=	libncursesw.ldscript
 STATIC_LDSCRIPT= libncursesw.aldscript
-CLEANFILES+=	${STATIC_LDSCRIPT}
+CLEANFILES+= libncursesw.a
 
-libncursesw.aldscript:
-	@${ECHO} "INPUT(-lncursesw_real -ltinfow)" >$@
-
-libncurses.ldscript:
-	@${ECHO} "INPUT(${SHLIB_NAME} AS NEEDED(-ltinfow))" >$@
+libncursesw.a: ${.CURDIR}/${STATIC_LDSCRIPT}
+	sed -e 's,@@LIB@@,${LIB},g' \
+	    -e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \
+	    ${.ALLSRC} > ${.TARGET}
 
 lib_gen.c: MKlib_gen.sh ${.OBJDIR:H}/tinfo/curses.h ncurses_dll.h
 	LC_ALL=C sh ${NCURSES_DIR}/ncurses/base/MKlib_gen.sh "${CPP:N${CCACHE_BIN}} ${CFLAGS}" \
@@ -185,13 +184,13 @@ lib_gen.c: MKlib_gen.sh ${.OBJDIR:H}/tinfo/curses.h ncurses_dll.h
 expanded.c: MKexpanded.sh
 	sh ${NCURSES_DIR}/ncurses/tty/MKexpanded.sh "${CC:N${CCACHE_BIN}} -E" ${CFLAGS} >expanded.c
 
-all: ${STATIC_LDSCRIPT}
+all: ${STATIC_LDSCRIPT} libncursesw.a
 
-install-aldscript: ${STATIC_LDSCRIPT}
+install-libncursesw.a: libncursesw.a
 	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
-	    ${_INSTALLFLAGS} ${STATIC_LDSCRIPT} ${DESTDIR}${_LIBDIR}/lib${LIB}.a
+	    ${_INSTALLFLAGS} libncursesw.a ${DESTDIR}${_LIBDIR}/lib${LIB}.a
 
-realinstall: install-aldscript
+realinstall: install-libncursesw.a
 
 
 .include <bsd.lib.mk>
diff --git a/lib/ncurses/ncurses/libncursesw.aldscript b/lib/ncurses/ncurses/libncursesw.aldscript
new file mode 100644
index 000000000000..337995f095c8
--- /dev/null
+++ b/lib/ncurses/ncurses/libncursesw.aldscript
@@ -0,0 +1 @@
+INPUT(-l@@LIB@@@@STATICLIB_SUFFIX@@ -ltinfow)