From owner-svn-src-stable@freebsd.org Mon Dec 4 09:53:04 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FE46DF64A2; Mon, 4 Dec 2017 09:53:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5F171809E3; Mon, 4 Dec 2017 09:53:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB49r3vt094574; Mon, 4 Dec 2017 09:53:03 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB49r3jY094573; Mon, 4 Dec 2017 09:53:03 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201712040953.vB49r3jY094573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 4 Dec 2017 09:53:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r326520 - stable/11/tools X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/tools X-SVN-Commit-Revision: 326520 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 09:53:04 -0000 Author: hselasky Date: Mon Dec 4 09:53:03 2017 New Revision: 326520 URL: https://svnweb.freebsd.org/changeset/base/326520 Log: MFC r325897: Improve the library dependencies helper script in src/tools. Implement double pass of the relevant Makefiles. First make a list of library names and directories and then scan for all the dependencies. Spaces in directories in the source tree are not supported. This avoids using hardcoded mappings between the library name and the directory containing the library Makefile. Add support for scanning contrib/ofed . Bail out on any errors. Sponsored by: Mellanox Technologies Modified: stable/11/tools/make_libdeps.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tools/make_libdeps.sh ============================================================================== --- stable/11/tools/make_libdeps.sh Mon Dec 4 09:51:08 2017 (r326519) +++ stable/11/tools/make_libdeps.sh Mon Dec 4 09:53:03 2017 (r326520) @@ -28,9 +28,12 @@ export PATH=/bin:/usr/bin +set -e + LC_ALL=C # make sort deterministic FS=': ' # internal field separator LIBDEPENDS=./_libdeps # intermediate output file +LIBDIRS=./_libdirs # intermediate output file USRSRC=${1:-/usr/src} # source root LIBS=" lib @@ -39,44 +42,74 @@ LIBS=" secure/lib usr.bin/lex/lib cddl/lib + contrib/ofed " # where to scan for libraries -# This sed(1) filter is used to convert -lfoo to path/to/libfoo. -# -SED_FILTER=" -sed -E - -e's; ;! ;g' - -e's;$;!;' - -e's;-lbsdxml!;lib/libexpat;g' - -e's;-lpthread!;lib/libthr;g' - -e's;-lm!;lib/msun;g' - -e's;-l(ncurses|termcap)!;lib/ncurses/ncurses;g' - -e's;-l(gcc)!;gnu/lib/lib\1;g' - -e's;-lssp_nonshared!;gnu/lib/libssp/libssp_nonshared;g' - -e's;-l(asn1|hdb|kdc|heimbase|heimntlm|heimsqlite|hx509|krb5|roken|wind)!;kerberos5/lib/lib\1;g' - -e's;-l(crypto|ssh|ssl)!;secure/lib/lib\1;g' - -e's;-l([^!]+)!;lib/lib\1;g' -" +# convert -lfoo to foo +convert() +{ + sed -e "s/\-l//g" -e "s/pthread/thr/g" -e "s/ncurses.*/ncurses/g" +} + +# find library build directory given library name +findlibdir() +{ + while read NAME && read DIR + do + if [ "$NAME" = "$1" ]; then + echo "$DIR" + exit + fi + done + + # Should not happen + echo lib_not_found/lib$1 +} + +# find library build directories given one or more library names +resolvelibdirs() +{ + while read LIBNAME + do + cat $LIBDIRS | tr ' ' '\n' | findlibdir "$LIBNAME" + done +} + # Generate interdependencies between libraries. # genlibdepends() { ( + # Reset file + echo -n > $LIBDIRS + + # First pass - generate list of directories cd ${USRSRC} - find -s ${LIBS} -mindepth 1 -name Makefile | + find -s ${LIBS} -name Makefile | xargs grep -l 'bsd\.lib\.mk' | while read makefile; do libdir=$(dirname ${makefile}) + libname=$( + cd ${libdir} + make -m ${USRSRC}/share/mk WITH_OFED=YES -V LIB + ) + if [ "${libname}" ]; then + echo "${libname} ${libdir}" >> $LIBDIRS + fi + done + + # Second pass - generate dependencies + find -s ${LIBS} -name Makefile | + xargs grep -l 'bsd\.lib\.mk' | + while read makefile; do + libdir=$(dirname ${makefile}) deps=$( cd ${libdir} - make -m ${USRSRC}/share/mk -V LDADD + make -m ${USRSRC}/share/mk WITH_OFED=YES -V LDADD ) if [ "${deps}" ]; then - echo ${libdir}"${FS}"$( - echo ${deps} | - eval ${SED_FILTER} - ) + echo ${libdir}"${FS}"$(echo ${deps} | tr ' ' '\n' | convert | resolvelibdirs) fi done )