From: John Ericson Subject: [PATCH v2] makefiles: Introduce `NOLIBSHARED` To: tech@openbsd.org Date: Sat, 29 Jun 2024 17:54:33 -0400 This forces the build system to only produce static archives. This is intended to be the counterpart of the (already existing) `NOLIBSTATIC`, which does the opposite. N.B. There is already a `NOPIC` which also disables shared objects, but in addition furthermore turns of position-independent-code. Now, `NOPIC` implies `NOLIBSHARED` instead, and only directly concerns itself with disabling position-independent-code. --- gnu/usr.bin/cc/libgcov/Makefile | 2 +- libexec/ld.so/Makefile | 2 +- regress/libexec/Makefile | 2 +- share/mk/bsd.README | 6 +++++- share/mk/bsd.lib.mk | 6 +++--- share/mk/bsd.own.mk | 4 ++++ 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gnu/usr.bin/cc/libgcov/Makefile b/gnu/usr.bin/cc/libgcov/Makefile index b1d4f7e8d53..e1f0db10312 100644 --- a/gnu/usr.bin/cc/libgcov/Makefile +++ b/gnu/usr.bin/cc/libgcov/Makefile @@ -76,7 +76,7 @@ BUILDAFTER += ${OBJS_T} ${OBJS_P} ${OBJS_S} ${OBJS_T}: libgcov.c ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} -.if !defined(NOPIC) +.if !defined(NOLIBSHARED) ${OBJS_S}: libgcov.c ${CC_S} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} .endif diff --git a/libexec/ld.so/Makefile b/libexec/ld.so/Makefile index 7f8f6ef2961..e9d101546bc 100644 --- a/libexec/ld.so/Makefile +++ b/libexec/ld.so/Makefile @@ -5,7 +5,7 @@ MAN= ld.so.1 .include -.if defined(NOPIC) +.if defined(NOLIBSHARED) NOPROG= .else PROG= ld.so diff --git a/regress/libexec/Makefile b/regress/libexec/Makefile index a1cd2b3d02e..e0c824dbe78 100644 --- a/regress/libexec/Makefile +++ b/regress/libexec/Makefile @@ -3,7 +3,7 @@ .include SUBDIR+= ftpd -.if !defined(NOPIC) +.if !defined(NOLIBSHARED) SUBDIR+= ld.so .endif diff --git a/share/mk/bsd.README b/share/mk/bsd.README index ce23a826a8d..27e447e1bd9 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -227,8 +227,12 @@ SYS_INCLUDE Copy or symlink kernel include files into /usr/include. NOPROFILE Do not build profiled versions of system libraries. +NOLIBSTATIC Do not build static libraries. + +NOLIBSHARED Do not build shared libraries. + NOPIC Do not build PIC versions of system libraries, and - do not build shared libraries. + do not build shared libraries. (Implies NOLIBSHARED.) NOPIE Do not build PIE objects or executables. diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 9cf9ffdf8e6..cef4acb2cc9 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -2,7 +2,7 @@ # $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $ # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 -.include # for 'NOPIC' definition +.include # for 'NOLIBSHARED' definition .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" @@ -154,7 +154,7 @@ _LIBS=lib${LIB}.a _LIBS+=lib${LIB}_p.a .endif -.if !defined(NOPIC) +.if !defined(NOLIBSHARED) .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) FULLSHLIBNAME=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} _LIBS+=${FULLSHLIBNAME} @@ -283,7 +283,7 @@ realinstall: lib${LIB}_p.a ${DESTDIR}${LIBDIR} chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a .endif -.if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) +.if !defined(NOLIBSHARED) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${FULLSHLIBNAME} ${DESTDIR}${LIBDIR} .if defined(LIBREBUILD) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index acde59a95c1..3e7d150a002 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -68,6 +68,10 @@ BUILD_LLDB?=no STATICPIE?=-pie .endif +.ifdef NOPIC +NOLIBSHARED=yes +.endif + # Executables are always PIC on mips64. # Do not pass -fno-pie to the compiler because clang does not accept it. .if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" -- 2.42.0