From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [RFC] Package infrastructure: make variables or make targets ?
Date: Sun, 25 Oct 2009 22:40:56 +0100 [thread overview]
Message-ID: <20091025224056.59c9a6ef@surf> (raw)
Hello,
I'm currently working on improving the package infrastructure for
Buildroot. Basically, the idea is to :
1. Generalize the Makefile.autotools.in infrastructure into something
that can be used for any type of package (not limited to packages
built using autotools). The advantages over the current
situation are mainly :
* Several steps can be automated: download, extraction, patch, etc.
* The infrastructure would hide the gory details of the stamp
files, ensuring a more coherent handling of the build process
throughout our package set
* The ability to easily add pre/post operations at the various
steps (configure, compile, install, etc.)
Of course, this infrastructure would still let the package .mk file
do a lot of things : specify how the package must be configured,
built and installed.
2. Rework the Makefile.autotools.in infrastructure so that it inherits
from the generic package infrastructure.
I've already started prototyping a solution, but I'm facing a choice on
which I'd like to have the community opinion. Usually, I don't like
talking without showing patches, but as this choice is fairly intrusive
in the design of the new infrastructure, I don't want to start the
wrong way.
The choice is on how the individual packages .mk files should specify
the operations that must be performed at the configure, build and
install steps. We have two choices :
1. Use make variables, such as :
======================================================================
define ICU_CONFIGURE
$(TARGET_CONFIGURE_OPTS) \
$(TARGET_CONFIGURE_ARGS) \
$(TARGET_CONFIGURE_ENV) \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--mandir=/usr/man \
--infodir=/usr/info \
--enable-samples
endef
define ICU_COMPILE
make -C $(@D)/$(ICU_SUBDIR)
endef
$(eval $(call PKGTARGETS,package,icu,target))
======================================================================
These variables are defined *before* the call to $(eval
$(call ...)). I find this approach fairly clean. This approach
also allows to add several hooks as a Pre/Post operation by doing
something like :
======================================================================
define MYPKG_PRE_CONFIGURE_DO_THIS
foobar
endef
MYPKG_PRE_CONFIGURE_HOOKS += MYPKG_PRE_CONFIGURE_DO_THIS
======================================================================
This approach is the one used by OpenWRT. The only drawback of this
approach is that since the variables are defined *before* calling
the generating function $(eval $(call ...)), we don't have access
to any variable that could be defined by the generating function.
So, for example, the ICU_COMPILE variable must use
$(@D)/$(ICU_SUBDIR) as the directory for the sources, instead of
something like $(ICU_SRCDIR) that could be defined by the package
infrastructure. In OpenWRT, they solved this problem by having a
"include package.mk" after the package definition (name, version,
URL, etc.), but before the definition of the different steps. But
in our case, this means having two $(eval $(call ...)).
2. Use make targets, as we do today for the hooks. The make targets
must be defined *after* the call to $(eval $(call ...)). For zlib,
it would look like :
======================================================================
$(eval $(call PKGTARGETS,package,zlib,target))
$(ZLIB_TARGET_CONFIGURE):
(cd $(PKGSRCDIR); rm -rf config.cache; \
$(TARGET_CONFIGURE_ARGS) \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) $(ZLIB_PIC)" \
./configure \
$(ZLIB_SHARED) \
--prefix=/usr \
--exec-prefix=$(STAGING_DIR)/usr/bin \
--libdir=$(STAGING_DIR)/usr/lib \
--includedir=$(STAGING_DIR)/usr/include \
)
touch $@
$(ZLIB_TARGET_BUILD):
$(MAKE) -C $(PKGSRCDIR) all libz.a
touch $@
======================================================================
The advantage is that the package infrastructure can pass variables
to these make targets (here PKGSRCDIR). However, the package
infrastructure is much harder to write, we cannot have several
hooks registered for the same Pre/Post operation (which makes the
inheritance of the autotools infrastructure more difficult), and I
find it strange to have some definitions *before* the $(eval
$(call ...)) and some others *after*.
Thanks for your input,
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
next reply other threads:[~2009-10-25 21:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-25 21:40 Thomas Petazzoni [this message]
2009-10-25 23:51 ` [Buildroot] [RFC] Package infrastructure: make variables or make targets ? Lionel Landwerlin
2009-10-26 8:35 ` Thomas Petazzoni
2009-10-27 8:06 ` Thomas Petazzoni
2009-10-29 15:39 ` Thomas Petazzoni
2009-10-29 17:11 ` H Hartley Sweeten
2009-10-29 21:01 ` Lionel Landwerlin
2009-10-29 17:41 ` Will Newton
2009-11-02 23:24 ` Thomas Petazzoni
2009-11-03 1:14 ` Lionel Landwerlin
2009-11-03 8:15 ` Thomas Petazzoni
2009-11-01 21:26 ` Lionel Landwerlin
2009-11-03 8:14 ` Thomas Petazzoni
2009-11-03 14:01 ` Lionel Landwerlin
2009-10-29 15:42 ` Thomas Petazzoni
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091025224056.59c9a6ef@surf \
--to=thomas.petazzoni@free-electrons.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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