mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <>
To: Ahmad Fatoum <>
Cc: Barebox List <>,,,,
Subject: Re: [PATCH 4/4] scripts: allow building USB loader tools for target as well
Date: Tue, 14 Sep 2021 12:11:54 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Sep 14, 2021 at 6:21 AM Ahmad Fatoum <> wrote:
> We currently build the USB loader tools only for the host (build) system,
> but it can be useful to cross compile them as well for the target.
> We already have some target tools, but support for those is easier,
> because they don't link against libraries. We use pkg-config to get
> cc and ld flags, but we always assume that pkg-config is for the host
> system and there is no well-defined way to request pkg-config for the
> target system.
> Support this by introducing a new CROSS_PKG_CONFIG. This will be
> consulted only for target tools and default to
> $(CROSS_COMPILE)pkgconfig.
> Users can override it as necessary, for example, with Yocto, pkg-config
> will be for the cross environment, so target tools can now be built
> with:

I just added support to Buildroot for building imx-usb-loader from
Barebox, since it's nicer than the standalone version of the program.

Since pkgconfig was only used for host tools, I didn't need to make
both host and target pkgconfig work.  But of course that will no
longer be true after this patch.

There is a problem with only supplying CROSS_PKG_CONFIG.  To get both
host and target pkgconfig to work, I also need to supply the env
variables used by pkgconfig, PKG_CONFIG_SYSROOT and PKG_CONFIG_LIBDIR.

The former makes the paths returned by pkgconfig correct and the
latter controls which set, target or host, of .pc files will be used.

Maybe something like this in the Makefile:


HOST_LIBUSB_CFLAGS := $(shell $(PKG_CONFIG) --cflags)
$(CROSS_PKG_CONFIG) --cflags)

Then use those everywhere someone wants the libusb cflags.  Repeat for LDFLAGS.

You'll get fewer repeated invocations of pkg-config this way too.

barebox mailing list

  reply	other threads:[~2021-09-14 19:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 13:20 [PATCH 1/4] common: remove !SANDBOX dependency for target tools Ahmad Fatoum
2021-09-14 13:20 ` [PATCH 2/4] common: add new menu " Ahmad Fatoum
2021-09-14 16:00   ` Roland Hieber
2021-09-14 13:20 ` [PATCH 3/4] scripts: unify libusb.h inclusion Ahmad Fatoum
2021-09-14 19:22   ` Trent Piepho
2021-09-15  8:55     ` Ahmad Fatoum
2021-09-14 13:20 ` [PATCH 4/4] scripts: allow building USB loader tools for target as well Ahmad Fatoum
2021-09-14 19:11   ` Trent Piepho [this message]
2021-09-15  8:50     ` Ahmad Fatoum
2021-09-15  9:38       ` Trent Piepho
2021-09-15 10:23         ` Ahmad Fatoum
2021-09-15  8:44   ` Enrico Jörns

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox