Simplify building libpam and fix libpam.a not containing the modules since r284345.

The change in r284345 moved the creation of openpam_static_modules.o to
lib/libpam/static_modules but never managed to get them into libpam.a.

Move this logic to lib/libpam/static_libpam and have it create a static
library for libpam.a  The main lib/libpam/libpam will only create a
shared library.  No redundancy in compilation or installation exists
in this solution.

This avoids requiring a pass with -D_NO_LIBPAM_SO_YET.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Bryan Drewery 2016-04-14 01:17:03 +00:00
parent 2d57dc7e6e
commit 7cbd0a2953
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=297946
7 changed files with 28 additions and 40 deletions

View File

@ -1719,7 +1719,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
${_lib_casper} \
lib/ncurses/ncurses lib/ncurses/ncursesw \
lib/libopie lib/libpam ${_lib_libthr} \
lib/libopie lib/libpam/libpam ${_lib_libthr} \
${_lib_libradius} lib/libsbuf lib/libtacplus \
lib/libgeom \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
@ -1731,6 +1731,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
${_secure_lib_libcrypto} ${_lib_libldns} \
${_secure_lib_libssh} ${_secure_lib_libssl} \
gnu/lib/libdialog
.if ${MK_GNUCXX} != "no"
_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
gnu/lib/libstdc++__L: lib/msun__L
@ -1898,7 +1899,7 @@ ${_lib}__PL: .PHONY .MAKE
.endif
.endfor
.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
@ -1909,18 +1910,6 @@ ${_lib}__L: .PHONY .MAKE
.endif
.endfor
# libpam is special: we need to build static PAM modules before
# static PAM library, and dynamic PAM library before dynamic PAM
# modules.
lib/libpam__L: .PHONY .MAKE
${_+_}@${ECHODIR} "===> lib/libpam (obj,all,install)"; \
cd ${.CURDIR}/lib/libpam; \
${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
-D_NO_LIBPAM_SO_YET all; \
${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
-D_NO_LIBPAM_SO_YET install
_prereq_libs: ${_prereq_libs:S/$/__PL/}
_startup_libs: ${_startup_libs:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/}

View File

@ -24,8 +24,11 @@
#
# $FreeBSD$
# The modules must be built first, because they are built into the
# static version of libpam.
SUBDIR+= modules libpam static_modules
# The modules link in libpam. They build the static modules as well.
SUBDIR+= libpam modules
SUBDIR_DEPEND_modules= libpam
SUBDIR+= static_libpam
SUBDIR_DEPEND_static_libpam= modules
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>

View File

@ -38,7 +38,11 @@
OPENPAM= ${.CURDIR}/../../../contrib/openpam
.PATH: ${OPENPAM}/include ${OPENPAM}/lib/libpam ${OPENPAM}/doc/man
LIB= pam
# static_libpam will build libpam.a
.if !defined(LIB)
SHLIB= pam
.endif
MK_PROFILE=no
SRCS= openpam_asprintf.c \
@ -98,7 +102,7 @@ SRCS= openpam_asprintf.c \
# Local additions
SRCS+= pam_debug_log.c
MAN= openpam.3 \
MAN?= openpam.3 \
openpam_borrow_cred.3 \
openpam_free_data.3 \
openpam_free_envlist.3 \
@ -150,10 +154,10 @@ MAN= openpam.3 \
pam_vprompt.3 \
pam.conf.5
MLINKS= pam.conf.5 pam.d.5
MLINKS?= pam.conf.5 pam.d.5
CSTD?= c99
CFLAGS+= -I${.CURDIR} -I${OPENPAM}/include
CFLAGS+= -I${OPENPAM}/include
CFLAGS+= -DLIB_MAJ=${SHLIB_MAJOR}
CFLAGS+= -DHAVE_DLFUNC=1
CFLAGS+= -DHAVE_FDLOPEN=1
@ -172,7 +176,7 @@ HEADERS= security/openpam.h \
ADD_HEADERS= security/pam_mod_misc.h
# Headers
INCS= ${HEADERS} ${ADD_HEADERS}
INCS?= ${HEADERS} ${ADD_HEADERS}
INCSDIR= ${INCLUDEDIR}/security
.include <src.opts.mk>

View File

@ -7,14 +7,7 @@ MK_PROFILE= no
CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
# This is nasty.
# For the static case, libpam.a depends on the modules.
# For the dynamic case, the modules depend on libpam.so.N
.if defined(_NO_LIBPAM_SO_YET)
NO_PIC=
.else
SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
LIBADD+= pam
.endif
.include "../Makefile.inc"

View File

@ -35,15 +35,17 @@
#
# $FreeBSD$
OPENPAM= ${.CURDIR:H:H:H}/contrib/openpam
.PATH: ${OPENPAM}/lib
.PATH: ${OPENPAM}/lib/libpam
.PATH: ${.CURDIR}/../libpam
all:
SRCS = openpam_static.c
# Only build the static library.
LIB= pam
NO_PIC=
# Avoid redundancy with the master Makefile.
MAN=
INCS=
MLINKS=
MK_TESTS= no
#
# Static modules
@ -61,11 +63,7 @@ STATICOBJS+= openpam_static_modules.o
CLEANFILES+= openpam_static.o \
openpam_static_modules.o
.include <bsd.prog.mk>
.if empty(_SKIP_BUILD)
openpam_static_modules.o: openpam_static.o ${STATIC_MODULES}
${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
all: ${STATICOBJS}
.endif
.include "${.CURDIR}/../libpam/Makefile"

View File

@ -117,6 +117,7 @@ DIRDEPS = \
lib/libpam/modules/pam_ssh \
lib/libpam/modules/pam_tacplus \
lib/libpam/modules/pam_unix \
lib/libpam/static_libpam \
lib/libpcap \
lib/libpe \
lib/libpjdlog \