Index: gnu/lib/libgcc/Makefile =================================================================== --- gnu/lib/libgcc/Makefile +++ gnu/lib/libgcc/Makefile @@ -15,6 +15,8 @@ # from earlier libraries. Disable stack protection for this library. # MK_SSP= no +# Cannot build anything without libgcc.a. +MK_STATIC_LIBS= yes .include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt" Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk +++ share/mk/bsd.lib.mk @@ -19,6 +19,8 @@ .if defined(NO_PIC) .undef SHLIB_NAME .undef INSTALL_PIC_ARCHIVE +# There will be no shared library so the static must be built/installed. +MK_STATIC_LIBS= yes .else .if !defined(SHLIB) && defined(LIB) SHLIB= ${LIB} @@ -31,6 +33,12 @@ .endif SONAME?= ${SHLIB_NAME} .endif +.if ${MK_STATIC_LIBS} == "no" +# Need to build static archive for internal libraries still. +.if defined(INTERNALLIB) +MK_STATIC_LIBS= yes +.endif +.endif # ${MK_STATIC_LIBS} == "no" .if defined(CRUNCH_CFLAGS) CFLAGS+= ${CRUNCH_CFLAGS} @@ -159,12 +167,13 @@ LDFLAGS+= -Wl,--version-script=${VERSION_MAP} .endif -.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) +.if (${MK_STATIC_LIBS} == "yes" && defined(LIB) && !empty(LIB)) || \ + defined(SHLIB_NAME) OBJS+= ${SRCS:N*.h:R:S/$/.o/} CLEANFILES+= ${OBJS} ${STATICOBJS} .endif -.if defined(LIB) && !empty(LIB) +.if ${MK_STATIC_LIBS} == "yes" && defined(LIB) && !empty(LIB) _LIBS= lib${LIB_PRIVATE}${LIB}.a lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS} @@ -317,7 +326,8 @@ realinstall: _libinstall .ORDER: beforeinstall _libinstall _libinstall: -.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" +.if ${MK_STATIC_LIBS} == "yes" && defined(LIB) && !empty(LIB) && \ + ${MK_INSTALLLIB} != "no" ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/ .endif Index: share/mk/bsd.opts.mk =================================================================== --- share/mk/bsd.opts.mk +++ share/mk/bsd.opts.mk @@ -62,6 +62,7 @@ OPENSSH \ PROFILE \ SSP \ + STATIC_LIBS \ SYMVER \ TOOLCHAIN \ WARNS @@ -103,6 +104,10 @@ MK_STALE_STAGED= no .endif +.if ${MK_STATIC_LIBS} == "no" +MK_PROFILE= no +.endif + .include .endif # !_WITHOUT_SRCCONF Index: share/mk/src.libnames.mk =================================================================== --- share/mk/src.libnames.mk +++ share/mk/src.libnames.mk @@ -380,7 +380,9 @@ .endif .for _l in ${LIBADD} +.if ${_INTERNALLIBS:M${_l}} || ${MK_STATIC_LIBS} == "yes" DPADD+= ${DPADD_${_l}} +.endif LDADD+= ${LDADD_${_l}} .endfor Index: tools/build/options/WITHOUT_INSTALLLIB =================================================================== --- tools/build/options/WITHOUT_INSTALLLIB +++ tools/build/options/WITHOUT_INSTALLLIB @@ -1,8 +1,13 @@ .\" $FreeBSD$ -Set this if you do not want to install optional libraries. -For example when creating a +Set this if you do not want to install any static libraries. +This will create an installation that cannot compile since +critical system libraries will be missing. +For example, this can be useful when creating a .Xr nanobsd 8 image. .Bf -symbolic The option does not work for build targets. .Ef +.Sy WITHOUT_STATIC_LIBS +can be used to avoid compiling static libraries and also still install +critical libraries. Index: tools/build/options/WITHOUT_STATIC_LIBS =================================================================== --- /dev/null +++ tools/build/options/WITHOUT_STATIC_LIBS @@ -0,0 +1,6 @@ +.\" $FreeBSD$ +Set to avoid compiling or installing optional static libraries for libraries +that build a shared library. +This will still install some critical static libraries required for compiling. +To avoid installing any static libraries see +.Sy WITHOUT_INSTALLLIB .