From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 14 23:54:24 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F26AAA66 for ; Fri, 14 Dec 2012 23:54:23 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-ea0-f182.google.com (mail-ea0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 759028FC14 for ; Fri, 14 Dec 2012 23:54:22 +0000 (UTC) Received: by mail-ea0-f182.google.com with SMTP id a14so1537930eaa.13 for ; Fri, 14 Dec 2012 15:54:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=mpx8txW9OpN2NKNwn6PM4uvI6/HHuafQDIBjBfEV6wo=; b=FQxpl3A/knzzhaQAd7hO4sOQZYqFMjLVE3u9QJUeL7doZ9DynMTPsXRLfZRs2LGbkn nVrwqf+KPwUeHReqt0O6YUM/5+UsvNwTOfee4C4GrLQTxJWmh1FLsl+7eECjRSvQ9pQ+ 2EwYDuHHK1e4sp1HzVMPVhKHzhCw9M25bWyWu6n5BbjqqC8IxUuG5oXCcPL4/qlVV9h6 stFnYIwu+6naiUJ9BKJwxe8TZmJ8Ln7yDHyIaOT40n4BBvGpqSjF90XmACIkQJcUMOsH FuG3QsKBKOoLNshzSJdIapSfU+gZPUjRTfgBl9CDS1yauX0M4K9n2i7KDJY+Vxu0Ct0/ olAQ== Received: by 10.14.223.200 with SMTP id v48mr18968525eep.24.1355529262020; Fri, 14 Dec 2012 15:54:22 -0800 (PST) Received: from ithaqua.etoilebsd.net (ithaqua.etoilebsd.net. [37.59.37.188]) by mx.google.com with ESMTPS id f49sm12275548eep.12.2012.12.14.15.54.20 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 15:54:21 -0800 (PST) Sender: Baptiste Daroussin Date: Sat, 15 Dec 2012 00:54:19 +0100 From: Baptiste Daroussin To: hackers@FreeBSD.org Subject: Fix overlinking in base aka import pkgconf Message-ID: <20121214235418.GF18884@ithaqua.etoilebsd.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ni93GHxFvA+th69W" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 23:54:24 -0000 --ni93GHxFvA+th69W Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, Some of our binary are overlinked, the way we handle the linking doesn't he= lp for that. On proposition could be to use pkgconf https://github.com/pkgconf/pkgconf w= hich is BSD license pkg-config implementation 100% compatible with pkg-config. What I propose is to create a new PCADD variable for the Makefiles. PCADD will invoke pkgconf to gather the libraries and the cflags for a given project. The second thing would be to create .pc files for all of our libraries. for example: usr.bin/fstat dynamic build is overlinked With the following simple patch we can solve the problem: Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- Makefile (revision 243899) +++ Makefile (working copy) @@ -5,7 +5,7 @@ SRCS=3D fstat.c fuser.c main.c LINKS=3D ${BINDIR}/fstat ${BINDIR}/fuser DPADD=3D ${LIBKVM} ${LIBUTIL} ${LIBPROCSTAT} -LDADD=3D -lkvm -lutil -lprocstat +PCADD=3D procstat =20 MAN1=3D fuser.1 fstat.1 =20 This requires the following .pc files quick and dirty ones: - util.pc: prefix=3D/usr libdir=3D${prefix}/lib includedir=3D${prefix}/include Name: util Libs: -L${libdir} -lutil Cflags: -I${includedir} - kvm.pc: prefix=3D/usr libdir=3D${prefix}/lib includedir=3D${prefix}/include Name: kvm Libs: -L${libdir} -lkvm Cflags: -I${includedir} - procstat.pc: prefix=3D/usr libdir=3D${prefix}/lib includedir=3D${prefix}/include Name: procstat Requires.private: kvm util Libs: -L${libdir} -lprocstat Cflags: -I${includedir} The quick and dirty patch for our framework is: Index: bsd.prog.mk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- bsd.prog.mk (revision 243899) +++ bsd.prog.mk (working copy) @@ -36,6 +36,18 @@ LDFLAGS+=3D -static .endif =20 +.if defined(PCADD) +PCFLAGS!=3D ${PKGCONF} --cflags ${PCADD} +.if defined(NO_SHARED) && (${NO_SHARED} !=3D "no" && ${NO_SHARED} !=3D "NO= ") +PCLIBS!=3D ${PKGCONF} --libs --static ${PCADD} +.else +PCLIBS!=3D ${PKGCONF} --libs ${PCADD} +.endif +CFLAGS+=3D ${PCFLAGS} +CXXFLAGS+=3D ${PCFLAGS} +LDADD+=3D ${PCLIBS} +.endif + .if defined(PROG_CXX) PROG=3D ${PROG_CXX} .endif Index: sys.mk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys.mk (revision 243899) +++ sys.mk (working copy) @@ -137,6 +137,8 @@ PC ?=3D pc PFLAGS ?=3D =20 +PKGCONF ?=3D pkgconf + RC ?=3D f77 RFLAGS ?=3D =20 Of course a lot of work is needed to get something really well integrated b= ut I wanted feedback first before working on anything like this :) regards, Bapt --ni93GHxFvA+th69W Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlDLvCoACgkQ8kTtMUmk6EzbPACbB6cR+36w0Gv8sFW93J7EJTbi k5QAnRpPMLDTjadalIT32dhOTjvjl7PX =nloN -----END PGP SIGNATURE----- --ni93GHxFvA+th69W--