diff mbox

host-pkgconf: use --static option for static builds

Message ID 1394021977-60055-1-git-send-email-Vincent.Riera@imgtec.com
State Accepted
Commit 958c9438ccb5e8c8864edf242b6b4ce3b1f058a4
Headers show

Commit Message

Vicente Olivert Riera March 5, 2014, 12:19 p.m. UTC
Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
pkg-config wrapper to append the --static option in that case.

Fixes:
   http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
---
 package/pkgconf/pkg-config.in |    2 +-
 package/pkgconf/pkgconf.mk    |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

Comments

Baruch Siach April 8, 2014, 3:58 a.m. UTC | #1
Hi Vicente,

On Wed, Mar 05, 2014 at 12:19:37PM +0000, Vicente Olivert Riera wrote:
> Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
> pkg-config wrapper to append the --static option in that case.
> 
> Fixes:
>    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
> 
> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

Also fixes 
http://autobuild.buildroot.net/results/e62/e62d35bcf7d6c98d0a0348532c2b159affb20e83/.

Tested-by: Baruch Siach <baruch@tkos.co.il>

Thanks,
baruch

> ---
> package/pkgconf/pkg-config.in |    2 +-
>  package/pkgconf/pkgconf.mk    |   14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in
> index 25a536b..4dec487 100644
> --- a/package/pkgconf/pkg-config.in
> +++ b/package/pkgconf/pkg-config.in
> @@ -1,2 +1,2 @@
>  #!/bin/sh
> -PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf $@
> +PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf @STATIC@ $@
> diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
> index f3f6526..9641371 100644
> --- a/package/pkgconf/pkgconf.mk
> +++ b/package/pkgconf/pkgconf.mk
> @@ -24,8 +24,22 @@ define HOST_PKGCONF_INSTALL_WRAPPER
>  		$(HOST_DIR)/usr/bin/pkg-config
>  endef
>  
> +define HOST_PKGCONF_STATIC
> +	$(SED) 's,@STATIC@,--static,' $(HOST_DIR)/usr/bin/pkg-config
> +endef
> +
> +define HOST_PKGCONF_SHARED
> +	$(SED) 's,@STATIC@,,' $(HOST_DIR)/usr/bin/pkg-config
> +endef
> +
>  PKGCONF_POST_INSTALL_TARGET_HOOKS += PKGCONF_LINK_PKGCONFIG
>  HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_INSTALL_WRAPPER
>  
> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
> +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_STATIC
> +else
> +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_SHARED
> +endif
> +
>  $(eval $(autotools-package))
>  $(eval $(host-autotools-package))
Baruch Siach May 1, 2014, 12:49 p.m. UTC | #2
Hi Vicente, Buildroot list,

On Tue, Apr 08, 2014 at 06:58:51AM +0300, Baruch Siach wrote:
> On Wed, Mar 05, 2014 at 12:19:37PM +0000, Vicente Olivert Riera wrote:
> > Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
> > pkg-config wrapper to append the --static option in that case.
> > 
> > Fixes:
> >    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
> > 
> > Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
> 
> Also fixes 
> http://autobuild.buildroot.net/results/e62/e62d35bcf7d6c98d0a0348532c2b159affb20e83/.
> 
> Tested-by: Baruch Siach <baruch@tkos.co.il>

Fixes also 
http://autobuild.buildroot.net/results/7e7/7e7b33266317ead92ef275fe10111e8e90bebc5a/.

Is there a reason not to apply this one? It should not break shared linking 
even for packages that are not static linking aware. Maybe only add some 
redundant NEEDED entries in the ELF dynamic section.

baruch

> > ---
> > package/pkgconf/pkg-config.in |    2 +-
> >  package/pkgconf/pkgconf.mk    |   14 ++++++++++++++
> >  2 files changed, 15 insertions(+), 1 deletions(-)
> > 
> > diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in
> > index 25a536b..4dec487 100644
> > --- a/package/pkgconf/pkg-config.in
> > +++ b/package/pkgconf/pkg-config.in
> > @@ -1,2 +1,2 @@
> >  #!/bin/sh
> > -PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf $@
> > +PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf @STATIC@ $@
> > diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
> > index f3f6526..9641371 100644
> > --- a/package/pkgconf/pkgconf.mk
> > +++ b/package/pkgconf/pkgconf.mk
> > @@ -24,8 +24,22 @@ define HOST_PKGCONF_INSTALL_WRAPPER
> >  		$(HOST_DIR)/usr/bin/pkg-config
> >  endef
> >  
> > +define HOST_PKGCONF_STATIC
> > +	$(SED) 's,@STATIC@,--static,' $(HOST_DIR)/usr/bin/pkg-config
> > +endef
> > +
> > +define HOST_PKGCONF_SHARED
> > +	$(SED) 's,@STATIC@,,' $(HOST_DIR)/usr/bin/pkg-config
> > +endef
> > +
> >  PKGCONF_POST_INSTALL_TARGET_HOOKS += PKGCONF_LINK_PKGCONFIG
> >  HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_INSTALL_WRAPPER
> >  
> > +ifeq ($(BR2_PREFER_STATIC_LIB),y)
> > +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_STATIC
> > +else
> > +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_SHARED
> > +endif
> > +
> >  $(eval $(autotools-package))
> >  $(eval $(host-autotools-package))
Vicente Olivert Riera May 1, 2014, 1:51 p.m. UTC | #3
Hello Baruch,

I was talking with ThomasP about the same thing. He told me that it has 
huge consequences and can't be committed easily, because it affects how 
almost all packages are built in a BR2_PREFER_STATIC_LIB=y build.
Arnout Vandecappelle May 2, 2014, 10 p.m. UTC | #4
On 01/05/14 15:51, Vicente Olivert Riera wrote:
> I was talking with ThomasP about the same thing. He told me that it has huge
> consequences and can't be committed easily, because it affects how almost all
> packages are built in a BR2_PREFER_STATIC_LIB=y build.

 That's a bit a strange argument... If it doesn't get committed, it will never
be tested. We have a month to fix autobuilder failures, that should be enough, no?

 Regards,
 Arnout
Thomas Petazzoni May 5, 2014, 8:10 a.m. UTC | #5
Dear Arnout Vandecappelle,

On Sat, 03 May 2014 00:00:03 +0200, Arnout Vandecappelle wrote:
> On 01/05/14 15:51, Vicente Olivert Riera wrote:
> > I was talking with ThomasP about the same thing. He told me that it has huge
> > consequences and can't be committed easily, because it affects how almost all
> > packages are built in a BR2_PREFER_STATIC_LIB=y build.
> 
>  That's a bit a strange argument... If it doesn't get committed, it will never
> be tested. We have a month to fix autobuilder failures, that should be enough, no?

Well, it would at least be good to have a preliminary testing with a
fairly large set of packages enabled, in a BR2_PREFER_STATIC_LIB=y
configuration, to check that things are still working OK after applying
this patch. Not a 100% coverage, but at least testing a few dozens of
packages.

Thomas
Arnout Vandecappelle May 7, 2014, 2:43 p.m. UTC | #6
On 05/03/14 13:19, Vicente Olivert Riera wrote:
> Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
> pkg-config wrapper to append the --static option in that case.
> 
> Fixes:
>    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
> 
> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 Tested with an allpackageyesconfig with 
http://autobuild.buildroot.org/toolchains/configs/free-electrons/br-x86-64-core2-full.config
as the toolchain (and PREFER_STATIC added to the config, of course).

 I ran this config with and without this patch applied, by running make -k
and then make -k again to collect the failures. 

 The following packages are fixed by this patch:
at
gdk-pixbuf
xerces
xfsprogs


 The following packages fail in both cases. I did a very basic
analysis for about half of them, but then I gave up :-)

python (duplicate symbols in -lpthread and -lc)
armadillo (builds a shared library and tries to link it with a static library)
audiofile (tries to link against libstdc++.so)
bash (multiple definition of function getenv)
util-linux (libpam needs -ldl)
directfb (tries to link against libstdc++.so)
mesa3d (tries to hardlink libGLESv1_CM.so instead of .a)
cdrkit (duplicate symbols in -lpthread and -lc)
libnspr (tries to link with gcc -shared ... --static ...)
rtmpdump (tries to link shared library against non-PIC .a libraries)
libssh2 (fails to link against -lgpg-error, dependency of gcrypt, which doesn't use pkg-config)
mysql (tries to link against libstdc++.so)
lm-sensors (tries to link with gcc -shared ... --static ...)
neard (duplicate symbols in -lpthread and -lc)
ofono (duplicate symbols in -lpthread and -lc)
coreutils (tries to link with gcc -shared ... --static ...)
crda (fails to link against -lgpg-error, dependency of gcrypt, which doesn't use pkg-config)
dhcpdump (fails to link agains -lusb, dependency of pcap, which doesn't use pkg-config)
dnsmasq (undefined references, but it does link against those libraries... weird)
keyutils (tries to link with gcc -shared ... --static ...)
elfutils (tries to link with gcc -shared ... --static ...)
exim (missing -pthread)
tcl (tries to link with gcc -shared ... --static ...)
fbgrab (missing -lm, dependency of libpng; fbgrab doesn't use pkg-config)
fbterm (missing -pthread)
fbv (missing -lz -lm, dependencies of libpng; fbv doesn't use pkg-config)
fetchmail (configure fails to link -lssl because of missing -lz; fetchmail doesn't use pkg-config)
flashrom (missing -lz, dependency of libpci)
openssh (configure fails to link -lssl because of missing -lz)
perl (but it succeeds the second build!)
libsigc (tries to link against libstdc++.so)
gnuplot (missing -pthread from libgd)
portaudio (tries to link against libstdc++.so)
libv4l (missing -pthread and -ljpeg)
taglib (tries to link with gcc -shared ... --static ...)
libvpx (failed sstrip; probably not related to static build)
heirloom-mailx (multiple definition of getopt)
polarssl (missing -lz, dependency of -lcrypto)
httping (missing -lm, dependency of -lfftw3)
iftop (configure fails on -lpcap, which doesn't use pkg-config)
inotify-tools (multiple definitions of internal symbols, weird)
iproute2 (tries to link with gcc -shared ... --static ...)
iprutils (undefined references to wattr from -lmenu (ncurses))
kismet (configure fails on -lpcap, which doesn't use pkg-config)
knock (configure fails on -lpcap, which doesn't use pkg-config)
lcdapi (tries to link with gcc -shared ... --static ...)
lcdproc (tries to link with gcc -shared ... --static ...)
lftp (tries to link against libstdc++.so)
libeXosip2 (missing -lssl + dependencies)
libfcgi (tries to link against libstdc++.so)
libgeotiff (configures fails to link with -ltiff)
libiqrf (tries to link with gcc -shared ... --static ...)
libiscsi (tries to link with gcc -shared ... --static ...)
libmicrohttpd (configure fails to link with -lgnutls)
libplist (tries to link with gcc -shared ... --static ...)
libqrencode (missing -pthread)
libroxml (missing -pthread)
libseccomp (tries to link with gcc -shared ... --static ...)
libserial (tries to link against libstdc++.so)
libwebsockets (tries to link with gcc -shared ... --static ...)
lighttpd (but succeeds the second time)
log4cplus
logrotate
ltp-testsuite (probably not related to static)
lxc
mtdev2tuio
mutt
ndisc6
slang
nfs-utils
nftables
ngrep
numactl
protobuf
olsr
openntpd
openpowerlink
oprofile
poppler
procps
proftpd
ptpd2
quagga
quota
rpm
rsh-redone
ruby
smstools3
snappy
squid
sudo
sysstat
tar
tcpreplay
ti-utils
tinyxml
tn5250
uemacs
urg
ushare
valgrind
vpnc
vsftpd
wget
wireshark
xinetd
xl2tp
xmlstarlet
znc


 For the interested, the log of these failures is available at
http://code.bulix.org/bezsjm-86178


 Regards,
 Arnout

> ---
>  package/pkgconf/pkg-config.in |    2 +-
>  package/pkgconf/pkgconf.mk    |   14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in
> index 25a536b..4dec487 100644
> --- a/package/pkgconf/pkg-config.in
> +++ b/package/pkgconf/pkg-config.in
> @@ -1,2 +1,2 @@
>  #!/bin/sh
> -PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf $@
> +PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf @STATIC@ $@
> diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
> index f3f6526..9641371 100644
> --- a/package/pkgconf/pkgconf.mk
> +++ b/package/pkgconf/pkgconf.mk
> @@ -24,8 +24,22 @@ define HOST_PKGCONF_INSTALL_WRAPPER
>  		$(HOST_DIR)/usr/bin/pkg-config
>  endef
>  
> +define HOST_PKGCONF_STATIC
> +	$(SED) 's,@STATIC@,--static,' $(HOST_DIR)/usr/bin/pkg-config
> +endef
> +
> +define HOST_PKGCONF_SHARED
> +	$(SED) 's,@STATIC@,,' $(HOST_DIR)/usr/bin/pkg-config
> +endef
> +
>  PKGCONF_POST_INSTALL_TARGET_HOOKS += PKGCONF_LINK_PKGCONFIG
>  HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_INSTALL_WRAPPER
>  
> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
> +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_STATIC
> +else
> +	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_SHARED
> +endif
> +
>  $(eval $(autotools-package))
>  $(eval $(host-autotools-package))
>
Baruch Siach May 7, 2014, 4:47 p.m. UTC | #7
Hi Arnout,

On Wed, May 07, 2014 at 04:43:46PM +0200, Arnout Vandecappelle wrote:
> On 05/03/14 13:19, Vicente Olivert Riera wrote:
> > Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
> > pkg-config wrapper to append the --static option in that case.
> > 
> > Fixes:
> >    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
> > 
> > Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
> 
> Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> 
>  Tested with an allpackageyesconfig with 
> http://autobuild.buildroot.org/toolchains/configs/free-electrons/br-x86-64-core2-full.config
> as the toolchain (and PREFER_STATIC added to the config, of course).
> 
>  I ran this config with and without this patch applied, by running make -k
> and then make -k again to collect the failures. 
> 
>  The following packages are fixed by this patch:
> at
> gdk-pixbuf
> xerces
> xfsprogs
> 
>  The following packages fail in both cases. I did a very basic
> analysis for about half of them, but then I gave up :-)

Thanks for testing.

[...]

> dhcpdump (fails to link agains -lusb, dependency of pcap, which doesn't use 
> pkg-config)

Fixed by http://patchwork.ozlabs.org/patch/341970/.

Haven't you encountered the flite failure 
http://autobuild.buildroot.net/results/3ff/3ff2217a4fccbddbdb2bc8ade68c88fc52848d36/? 
This one is fixed by http://patchwork.ozlabs.org/patch/344396/.

baruch
Arnout Vandecappelle May 7, 2014, 5:05 p.m. UTC | #8
On 07/05/14 18:47, Baruch Siach wrote:
> Hi Arnout,
> 
> On Wed, May 07, 2014 at 04:43:46PM +0200, Arnout Vandecappelle wrote:
>> On 05/03/14 13:19, Vicente Olivert Riera wrote:
>>> Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
>>> pkg-config wrapper to append the --static option in that case.
>>>
>>> Fixes:
>>>    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
>>>
>>> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
>>
>> Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
>> Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
>>
>>  Tested with an allpackageyesconfig with 
>> http://autobuild.buildroot.org/toolchains/configs/free-electrons/br-x86-64-core2-full.config
>> as the toolchain (and PREFER_STATIC added to the config, of course).
>>
>>  I ran this config with and without this patch applied, by running make -k
>> and then make -k again to collect the failures. 
>>
>>  The following packages are fixed by this patch:
>> at
>> gdk-pixbuf
>> xerces
>> xfsprogs
>>
>>  The following packages fail in both cases. I did a very basic
>> analysis for about half of them, but then I gave up :-)
> 
> Thanks for testing.
> 
> [...]
> 
>> dhcpdump (fails to link agains -lusb, dependency of pcap, which doesn't use 
>> pkg-config)
> 
> Fixed by http://patchwork.ozlabs.org/patch/341970/.
> 
> Haven't you encountered the flite failure 
> http://autobuild.buildroot.net/results/3ff/3ff2217a4fccbddbdb2bc8ade68c88fc52848d36/? 
> This one is fixed by http://patchwork.ozlabs.org/patch/344396/.

 Since python and alsa-lib are enabled, flite depends on python so it doesn't
get built. That's the problem with allpackageyes: one build failure can block a
lot of other packages.

 Regards,
 Arnout
Peter Korsgaard May 7, 2014, 8:40 p.m. UTC | #9
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

 > On 05/03/14 13:19, Vicente Olivert Riera wrote:
 >> Detect when BR2_PREFER_STATIC_LIBS is selected and modify the host
 >> pkg-config wrapper to append the --static option in that case.
 >> 
 >> Fixes:
 >> http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
 >> 
 >> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

 > Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
 > Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 >  Tested with an allpackageyesconfig with 
 > http://autobuild.buildroot.org/toolchains/configs/free-electrons/br-x86-64-core2-full.config
 > as the toolchain (and PREFER_STATIC added to the config, of course).

 >  I ran this config with and without this patch applied, by running make -k
 > and then make -k again to collect the failures. 

 >  The following packages are fixed by this patch:
 > at
 > gdk-pixbuf
 > xerces
 > xfsprogs

Thanks for the work both - Committed, thanks.
diff mbox

Patch

diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in
index 25a536b..4dec487 100644
--- a/package/pkgconf/pkg-config.in
+++ b/package/pkgconf/pkg-config.in
@@ -1,2 +1,2 @@ 
 #!/bin/sh
-PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf $@
+PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-@PKG_CONFIG_LIBDIR@} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-@STAGING_DIR@} $(dirname $0)/pkgconf @STATIC@ $@
diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
index f3f6526..9641371 100644
--- a/package/pkgconf/pkgconf.mk
+++ b/package/pkgconf/pkgconf.mk
@@ -24,8 +24,22 @@  define HOST_PKGCONF_INSTALL_WRAPPER
 		$(HOST_DIR)/usr/bin/pkg-config
 endef
 
+define HOST_PKGCONF_STATIC
+	$(SED) 's,@STATIC@,--static,' $(HOST_DIR)/usr/bin/pkg-config
+endef
+
+define HOST_PKGCONF_SHARED
+	$(SED) 's,@STATIC@,,' $(HOST_DIR)/usr/bin/pkg-config
+endef
+
 PKGCONF_POST_INSTALL_TARGET_HOOKS += PKGCONF_LINK_PKGCONFIG
 HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_INSTALL_WRAPPER
 
+ifeq ($(BR2_PREFER_STATIC_LIB),y)
+	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_STATIC
+else
+	HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_SHARED
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))