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
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/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
${_lib_casper} \ ${_lib_casper} \
lib/ncurses/ncurses lib/ncurses/ncursesw \ 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_libradius} lib/libsbuf lib/libtacplus \
lib/libgeom \ lib/libgeom \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
@ -1731,6 +1731,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
${_secure_lib_libcrypto} ${_lib_libldns} \ ${_secure_lib_libcrypto} ${_lib_libldns} \
${_secure_lib_libssh} ${_secure_lib_libssl} \ ${_secure_lib_libssh} ${_secure_lib_libssl} \
gnu/lib/libdialog gnu/lib/libdialog
.if ${MK_GNUCXX} != "no" .if ${MK_GNUCXX} != "no"
_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++ _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
gnu/lib/libstdc++__L: lib/msun__L gnu/lib/libstdc++__L: lib/msun__L
@ -1898,7 +1899,7 @@ ${_lib}__PL: .PHONY .MAKE
.endif .endif
.endfor .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 ${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib}) .if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
@ -1909,18 +1910,6 @@ ${_lib}__L: .PHONY .MAKE
.endif .endif
.endfor .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/} _prereq_libs: ${_prereq_libs:S/$/__PL/}
_startup_libs: ${_startup_libs:S/$/__L/} _startup_libs: ${_startup_libs:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/} _prebuild_libs: ${_prebuild_libs:S/$/__L/}

View File

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

View File

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

View File

@ -7,14 +7,7 @@ MK_PROFILE= no
CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam 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} SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
LIBADD+= pam LIBADD+= pam
.endif
.include "../Makefile.inc" .include "../Makefile.inc"

View File

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

View File

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