Skip to contentSkip to conversation

Package infrastructure: make variables or make targets ?

RFC Thomas Petazzoni 4 participants 15 messages Oct 25, 2009 – Nov 3, 2009

lore
Share & tools
lore
#0 lore 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

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#1 lore raw

Hi Thomas,

Le dimanche 25 octobre 2009 ? 22:40 +0100, Thomas Petazzoni a ?crit :

Quoted 49 lines

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
Quoted 7 lines

endef

define ICU_COMPILE
make -C $(@D)/$(ICU_SUBDIR)
endef

$(eval $(call PKGTARGETS,package,icu,target))

I like this first approach.

Quoted 7 lines

======================================================================

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 :

Quoted 6 lines

======================================================================
define MYPKG_PRE_CONFIGURE_DO_THIS
foobar
endef

MYPKG_PRE_CONFIGURE_HOOKS += MYPKG_PRE_CONFIGURE_DO_THIS

I like it less.

Why not defining entry points like thoses :

$PACKAGE_PRE_CONFIGURE
$PACKAGE_POST_CONFIGURE
$PACKAGE_PRE_COMPILE
$PACKAGE_POST_COMPILE
etc...

And we just do something like this in the Makefile.in :

$(1) => package name

$(BR_OUTPUT)/build/$(1)-$($(1)_VERSION)/.stamp_configured:
ifdef $(1)_PRE_CONFIGURE

	$($(1)_PRE_CONFIGURE)
endif
ifdef $(1)_CONFIGURE
	$($(1)_CONFIGURE)

else
# Do default stuff...
endef
ifdef $(1)_POST_CONFIGURE

	$($(1)_POST_CONFIGURE)

endif

So the package doesn't have to manipulate variables like MYPKG_PRE_CONFIGURE_HOOKS, it just defines its entry points.

Quoted 13 lines

======================================================================

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 ...)).

Could we split the package's makefile in two parts ?

One defining data stuff like package version, source, site, etc... Then we call something like that :

$(eval $(call PKGDATA,package,mypkg))

That defines all paths we need etc...

And them we describe the actions we want to be triggered at each step of the build process, just like you described before.

Finally we call the rule evaluation defining actions with all the stamp files stuff.

Quoted 35 lines

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*.

Quoted 3 lines

Thanks for your input,

Thomas

Regards,

Signature · 1 line
Lionel Landwerlin <[email protected]>
#2 lore raw

Hi Lionel,

Thanks for your input!

Le Mon, 26 Oct 2009 00:51:42 +0100,
Lionel Landwerlin <[email protected]> a ?crit :

Quoted 31 lines
Quoted 6 lines

======================================================================
define MYPKG_PRE_CONFIGURE_DO_THIS
foobar
endef

MYPKG_PRE_CONFIGURE_HOOKS += MYPKG_PRE_CONFIGURE_DO_THIS

I like it less.

Why not defining entry points like thoses :

$PACKAGE_PRE_CONFIGURE
$PACKAGE_POST_CONFIGURE
$PACKAGE_PRE_COMPILE
$PACKAGE_POST_COMPILE
etc...

And we just do something like this in the Makefile.in :

$(1) => package name

$(BR_OUTPUT)/build/$(1)-$($(1)_VERSION)/.stamp_configured:
ifdef $(1)_PRE_CONFIGURE

	$($(1)_PRE_CONFIGURE)
endif
ifdef $(1)_CONFIGURE
	$($(1)_CONFIGURE)

else
# Do default stuff...
endef
ifdef $(1)_POST_CONFIGURE

Quoted 5 lines
	$($(1)_POST_CONFIGURE)

endif

So the package doesn't have to manipulate variables like MYPKG_PRE_CONFIGURE_HOOKS, it just defines its entry points.

Because this allows to have only one hook registered for each hook location. And this is not enough with the inheritance of Makefile.autotools.in from the generic package infrastructure.

The generic package infrastructure will define steps for :

* download, implemented in a generic way
* extract, implemented in a generic way
* patch, implemented in a generic way
* configure, calling a package specific definition
* build, calling a package specific definition
* install to target/staging/host, calling a package specific definition

With pre/post hooks mechanism before and after all these steps.

The Makefile.autotools.in infrastructure will plug into the generic one by at least :

* defining what configure, build, install to target/staging/host do
* defining a post-patch hook to autoreconf if necessary, patch libtool if necessary

Then, if the package specific makefile using the autotools infrastructure wants to define a post-patch hook, it cannot since, the ?slot? is already used by the generic infrastructure.

Therefore, I was thinking of a mechanism similar to OpenWRT, where the hooks variables are list of variables names that in turn contain what to do.

See for example
https://dev.openwrt.org/browser/trunk/include/autotools.mk (the end).

Quoted 7 lines

Could we split the package's makefile in two parts ?

One defining data stuff like package version, source, site, etc... Then we call something like that :

$(eval $(call PKGDATA,package,mypkg))

Quoted 7 lines

That defines all paths we need etc...

And them we describe the actions we want to be triggered at each step of the build process, just like you described before.

Finally we call the rule evaluation defining actions with all the stamp files stuff.

Yes, we could. However, for the moment, the only variable I have in mind is this package source code directory.

Would look like something like this:

=============================================================================
ICU_VERSION:=4c-3_8_1
ICU_SOURCE:=icu$(ICU_VERSION)-src.tgz ICU_SITE:=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/icu ICU_DEPENDENCIES:=host-icu
ICU_SUBDIR:=source

HOST_ICU_VERSION:=$(ICU_VERSION)
HOST_ICU_SOURCE:=$(ICU_SOURCE)
HOST_ICU_SITE:=$(ICU_SITE)
HOST_ICU_SUBDIR:=source

$(eval $(call pkgdefinitions,package,icu,target))
$(eval $(call pkgdefinitions,package,icu,host))

define HOST_ICU_CONFIGURE
$(HOST_CONFIGURE_OPTS) \
$(HOST_CONFIGURE_ARGS) \
$(HOST_CONFIGURE_ENV) \
./configure --prefix=/usr
endef

define HOST_ICU_COMPILE
make -C $(ICU_SRCDIR) # this variable was defined by pkgdefinitions above
endef

define HOST_ICU_INSTALL
make -C $(ICU_SRCDIR) DESTDIR=$(HOST_DIR) install
endef

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 $(ICU_SRCDIR)
endef

$(eval $(call pkgrules,package,icu,target))
$(eval $(call pkgrules,package,icu,host))
=============================================================================

Note 1: ICU is a fairly bad example since it should be converted to Makefile.autotools.in, but since it is not converted yet, I've used it as an example during my prototyping.

Note 2: I'd like HOST_ICU_VERSION, HOST_ICU_SOURCE, HOST_ICU_SITE and HOST_ICU_SUBDIR default to ICU_VERSION, ICU_SOURCE, ICU_SITE and ICU_SUBDIR so that they aren't duplicated, but this isn't implemented in my prototype yet.

So, in the end, I understand you prefer the "make variables" way over the "make targets" way. Am I correct ?

Thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#3 lore raw
In reply to Thomas Petazzoni

Hello,

Le Sun, 25 Oct 2009 22:40:56 +0100,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 5 lines

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.

I've pushed a set of commits to
http://git.buildroot.net/~tpetazzoni/git/buildroot/log/?h=package-infrastructure
which shows the current status of my work. Warning: it is currently in an ugly state: documentation not updated, the generic package infrastructure still contains some autotools-specific stuff, the autotools infrastructure ported over the generic infrastructure does not work yet.

But it still allows you to see how the .mk files look like for three examples : icu, zlib and olsr (randomly choosen).

Please do not pull this branch anywhere except for experimentations, as I will rebase it heavily.

Sincerly,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#4 lore raw

Hello,

Le Tue, 27 Oct 2009 09:06:28 +0100,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 14 lines
Quoted 5 lines

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.

I've pushed a set of commits to
http://git.buildroot.net/~tpetazzoni/git/buildroot/log/?h=package-infrastructure
which shows the current status of my work. Warning: it is currently in an ugly state: documentation not updated, the generic package infrastructure still contains some autotools-specific stuff, the autotools infrastructure ported over the generic infrastructure does not work yet.

Quoted 2 lines

But it still allows you to see how the .mk files look like for three examples : icu, zlib and olsr (randomly choosen).

I've pushed more changes. Since my previous e-mails, the changes are the following :

* Improved the autotools infrastructure on top of the new generic package infrastructure. It now works for at least the few packages I've tested ;

* Improved the generic infrastructure to support registration of multiple hooks. The old hook mechanism is also kept for backward compatibility, but if we agree on the new hook mechanism, I'd like to slowly get rid of the old one ;

* The pkg-config for host build has been rewritten on top of the new autotools infrastructure. Much simpler. But packages must now depend on host-pkg-config instead of host-pkgconfig (a commit in my branch updates all packages) ;

* directfb + directfb-examples build properly, which means that pkg-config for host, libpng, libts, zlib, freetype, jpeg, directfb and directfb-examples do work on top of the new infrastructure ;

* I've added a crappy package statistics script, which tries to guess which package should be converted to autotools, to the new infrastructure, both for target and host.

A lot more work remains:

* Cleanup
* Documentation
* Testing

I have one naming issue in the generic package infrastructure (package/Makefile.package.in) on which I'd like to get your input. The generic package infrastructure let the package specific .mk file specify what the configure, build and install steps should do, by defining variables :

<PKG>_CONFIGURE for configure
<PKG>_BUILD for build

for installation, I wanted to use

<PKG>_INSTALL_STAGING for staging installation
<PKG>_INSTALL_TARGET for target installation

but these variables are already existing boolean variables (YES/NO) that allows the package to specify whether it wants TARGET installation and/or STAGING installation. So we have a naming conflict, that I solved by using

<PKG>_INSTALL_STAGING_CMDS
<PKG>_INSTALL_TARGET_CMDS

for the variables that a package specific .mk must define to list the operations to be performed at staging install and target install. But I don't like this naming since it isn't coherent with <PKG>_CONFIGURE and <PKG>_BUILD.

Any suggestion ?

Sincerly,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#5 lore raw
Quoted 22 lines · Thomas Petazzoni

I have one naming issue in the generic package infrastructure (package/Makefile.package.in) on which I'd like to get your input. The generic package infrastructure let the package specific .mk file specify what the configure, build and install steps should do, by defining variables :

<PKG>_CONFIGURE for configure
<PKG>_BUILD for build

for installation, I wanted to use

<PKG>_INSTALL_STAGING for staging installation
<PKG>_INSTALL_TARGET for target installation

but these variables are already existing boolean variables (YES/NO) that allows the package to specify whether it wants TARGET installation and/or STAGING installation. So we have a naming conflict, that I solved by using

<PKG>_INSTALL_STAGING_CMDS
<PKG>_INSTALL_TARGET_CMDS

Quoted 6 lines

for the variables that a package specific .mk must define to list the operations to be performed at staging install and target install. But I don't like this naming since it isn't coherent with <PKG>_CONFIGURE and <PKG>_BUILD.

Any suggestion ?

How about changing the boolean variables to:

<PKG>_STAGING_INSTALL to indicate a STAGING installation is wanted <PKG>_TARGET_INSTALL to indicate a TARGET installation is wanted

Then you can use:

<PKG>_INSTALL_STAGING for staging installation
<PKG>_INSTALL_TARGET for target installation

Regards,
Hartley

#6 lore raw

Le jeudi 29 octobre 2009 ? 13:11 -0400, H Hartley Sweeten a ?crit :

Quoted 32 lines · Thomas Petazzoni
Quoted 22 lines

I have one naming issue in the generic package infrastructure (package/Makefile.package.in) on which I'd like to get your input. The generic package infrastructure let the package specific .mk file specify what the configure, build and install steps should do, by defining variables :

<PKG>_CONFIGURE for configure
<PKG>_BUILD for build

for installation, I wanted to use

<PKG>_INSTALL_STAGING for staging installation
<PKG>_INSTALL_TARGET for target installation

but these variables are already existing boolean variables (YES/NO) that allows the package to specify whether it wants TARGET installation and/or STAGING installation. So we have a naming conflict, that I solved by using

<PKG>_INSTALL_STAGING_CMDS
<PKG>_INSTALL_TARGET_CMDS

Quoted 6 lines

for the variables that a package specific .mk must define to list the operations to be performed at staging install and target install. But I don't like this naming since it isn't coherent with <PKG>_CONFIGURE and <PKG>_BUILD.

Any suggestion ?

How about changing the boolean variables to:

Quoted 7 lines

<PKG>_STAGING_INSTALL to indicate a STAGING installation is wanted <PKG>_TARGET_INSTALL to indicate a TARGET installation is wanted

Then you can use:

<PKG>_INSTALL_STAGING for staging installation
<PKG>_INSTALL_TARGET for target installation

Sound confusing...

I would rather prefer <PKG>_INSTALL_TARGET or <PKG>_HAS_INSTALL_TARGET.

#7 lore raw
In reply to Thomas Petazzoni
Quoted 75 lines · Thomas Petazzoni

Hello,

Le Tue, 27 Oct 2009 09:06:28 +0100,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 14 lines
Quoted 5 lines

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.

I've pushed a set of commits to
http://git.buildroot.net/~tpetazzoni/git/buildroot/log/?h=package-infrastructure
which shows the current status of my work. Warning: it is currently in an ugly state: documentation not updated, the generic package infrastructure still contains some autotools-specific stuff, the autotools infrastructure ported over the generic infrastructure does not work yet.

Quoted 2 lines

But it still allows you to see how the .mk files look like for three examples : icu, zlib and olsr (randomly choosen).

I've pushed more changes. Since my previous e-mails, the changes are the following :

?* Improved the autotools infrastructure on top of the new generic ? package infrastructure. It now works for at least the few packages ? I've tested ;

?* Improved the generic infrastructure to support registration of ? multiple hooks. The old hook mechanism is also kept for backward ? compatibility, but if we agree on the new hook mechanism, I'd like ? to slowly get rid of the old one ;

?* The pkg-config for host build has been rewritten on top of the new ? autotools infrastructure. Much simpler. But packages must now depend ? on host-pkg-config instead of host-pkgconfig (a commit in my branch ? updates all packages) ;

?* directfb + directfb-examples build properly, which means that ? pkg-config for host, libpng, libts, zlib, freetype, jpeg, directfb ? and directfb-examples do work on top of the new infrastructure ;

?* I've added a crappy package statistics script, which tries to guess ? which package should be converted to autotools, to the new ? infrastructure, both for target and host.

A lot more work remains:

?* Cleanup
?* Documentation
?* Testing

I have one naming issue in the generic package infrastructure (package/Makefile.package.in) on which I'd like to get your input. The generic package infrastructure let the package specific .mk file specify what the configure, build and install steps should do, by defining variables :

?<PKG>_CONFIGURE for configure
?<PKG>_BUILD for build

for installation, I wanted to use

?<PKG>_INSTALL_STAGING for staging installation
?<PKG>_INSTALL_TARGET for target installation

but these variables are already existing boolean variables (YES/NO) that allows the package to specify whether it wants TARGET installation and/or STAGING installation. So we have a naming conflict, that I solved by using

?<PKG>_INSTALL_STAGING_CMDS
?<PKG>_INSTALL_TARGET_CMDS

Quoted 6 lines

for the variables that a package specific .mk must define to list the operations to be performed at staging install and target install. But I don't like this naming since it isn't coherent with <PKG>_CONFIGURE and <PKG>_BUILD.

Any suggestion ?

Hi Thomas,

This stuff looks really good, it seems to reduce the lines of code in each Makefile which is definitely a good sign.

Perhaps all the targets should have a _CMDS suffix to distinguish them from other types of variables?

#8 lore raw
In reply to Thomas Petazzoni

Le Thu, 29 Oct 2009 16:39:16 +0100,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 2 lines

I've pushed more changes. Since my previous e-mails, the changes are the following :

I've pushed even more changes. Mostly conversion of packages to the new autotargets host infrastructure, which simplifies a lot of existing makefiles.

See
http://git.buildroot.net/~tpetazzoni/git/buildroot/log/?h=package-infrastructure
for details.

Sincerly,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#10 lore raw

Le Tue, 03 Nov 2009 02:14:55 +0100,
Lionel Landwerlin <[email protected]> a ?crit :

Quoted 1 line

test ?

ACK.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#11 lore raw
In reply to Thomas Petazzoni

Le mardi 27 octobre 2009 ? 09:06 +0100, Thomas Petazzoni a ?crit :

Quoted 12 lines

Hello,

Le Sun, 25 Oct 2009 22:40:56 +0100,
Thomas Petazzoni <[email protected]> a ?crit :
I've pushed a set of commits to
http://git.buildroot.net/~tpetazzoni/git/buildroot/log/?h=package-infrastructure
which shows the current status of my work. Warning: it is currently in an ugly state: documentation not updated, the generic package infrastructure still contains some autotools-specific stuff, the autotools infrastructure ported over the generic infrastructure does not work yet.

Quoted 7 lines

But it still allows you to see how the .mk files look like for three examples : icu, zlib and olsr (randomly choosen).

Please do not pull this branch anywhere except for experimentations, as I will rebase it heavily.

Sincerly,

Hi Thomas,

First thanks for your work. I like it much, it makes package's makefiles a lot more clean.

I have little question about the autotool stuff. I seen that the patching and the autoreconf steps has been merged together. Is it because you did not finish yet or do you plan keep it like that ?

I'm asking that because I'm using buildroot more as a development tool than a rootfs generation tool. I try to work upstream with packages I'm hacking on. A few days ago I sent a patch to allow to retrigger some part of the build process on a particular package
(http://lists.busybox.net/pipermail/buildroot/2009-October/030104.html).
It currently only work with "autotooled" packages, but with you ongoing work it will be easier to provide that feature on all packages.

So to me, it is important to separate the patching from the autoreconfiguring part, because when adding new source files to an autotooled package there is a need to regenerate the Makefile.in files without repatching.

Regards,

Signature · 1 line
Lionel Landwerlin <[email protected]>
#12 lore raw

Hello,

Thanks Lionel for your feedback.

Le Sun, 01 Nov 2009 22:26:58 +0100,
Lionel Landwerlin <[email protected]> a ?crit :

Quoted 2 lines

First thanks for your work. I like it much, it makes package's makefiles a lot more clean.

Thanks :)

Quoted 3 lines

I have little question about the autotool stuff. I seen that the patching and the autoreconf steps has been merged together. Is it because you did not finish yet or do you plan keep it like that ?

I was planning to keep it like that, but if it's not satisfying, we can probably find ways to improve it.

The generic package infrastructure, in package/Makefile.package.in [1] is not supposed to know anything about autotools. Therefore, it implements a set of generic steps :

* Download
* Extract
* Patch
* Configure
* Build
* Host installation
* Target installation
* Staging installation
* Clean
* Uninstall

? autoreconf ? is *not* one of these steps because it is autotools specific.

Then, the package/Makefile.autotools.in [2] ? inherits ? from this package infrastructure by :

* Providing a definition for the Configure, Build, Host installation, Target installation, Staging installation, Clean and Uninstall steps ;

* Add hooks for autoreconf and libtool patching. The autoreconf hook is attached to the $(PKG)_POST_PATCH_HOOKS hook point, and is therefore included into the generic ? Patch ? step in terms of stamp files and dependencies

Considering this more or less clean separation between generic infrastructure and autotools infrastructure, I'd like (if possible) to keep autotools-specific things outside the generic infrastructure.

Quoted 9 lines

I'm asking that because I'm using buildroot more as a development tool than a rootfs generation tool. I try to work upstream with packages I'm hacking on. A few days ago I sent a patch to allow to retrigger some part of the build process on a particular package
(http://lists.busybox.net/pipermail/buildroot/2009-October/030104.html).
It currently only work with "autotooled" packages, but with you ongoing work it will be easier to provide that feature on all packages.

Quoted 4 lines

So to me, it is important to separate the patching from the autoreconfiguring part, because when adding new source files to an autotooled package there is a need to regenerate the Makefile.in files without repatching.

Would attaching the autoreconf hook to a (not-yet-existing-but-easily-created) $(PKG)_PRE_CONFIGURE_HOOKS hook point solve the problem ?

Sincerly,

Thomas

[1]
http://git.buildroot.net/~tpetazzoni/git/buildroot/tree/package/Makefile.package.in?h=package-infrastructure

[2]
http://git.buildroot.net/~tpetazzoni/git/buildroot/tree/package/Makefile.autotools.in?h=package-infrastructure

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#13 lore raw

Woaa, this mail took more than a day to be delivered...

Le mardi 03 novembre 2009 ? 09:14 +0100, Thomas Petazzoni a ?crit :

Quoted 62 lines

Hello,

Thanks Lionel for your feedback.

Le Sun, 01 Nov 2009 22:26:58 +0100,
Lionel Landwerlin <[email protected]> a ?crit :

Quoted 2 lines

First thanks for your work. I like it much, it makes package's makefiles a lot more clean.

Thanks :)

Quoted 3 lines

I have little question about the autotool stuff. I seen that the patching and the autoreconf steps has been merged together. Is it because you did not finish yet or do you plan keep it like that ?

I was planning to keep it like that, but if it's not satisfying, we can probably find ways to improve it.

The generic package infrastructure, in package/Makefile.package.in [1] is not supposed to know anything about autotools. Therefore, it implements a set of generic steps :

* Download
* Extract
* Patch
* Configure
* Build
* Host installation
* Target installation
* Staging installation
* Clean
* Uninstall

? autoreconf ? is *not* one of these steps because it is autotools specific.

Then, the package/Makefile.autotools.in [2] ? inherits ? from this package infrastructure by :

* Providing a definition for the Configure, Build, Host installation, Target installation, Staging installation, Clean and Uninstall steps ;

* Add hooks for autoreconf and libtool patching. The autoreconf hook is attached to the $(PKG)_POST_PATCH_HOOKS hook point, and is therefore included into the generic ? Patch ? step in terms of stamp files and dependencies

Considering this more or less clean separation between generic infrastructure and autotools infrastructure, I'd like (if possible) to keep autotools-specific things outside the generic infrastructure.

Quoted 9 lines

I'm asking that because I'm using buildroot more as a development tool than a rootfs generation tool. I try to work upstream with packages I'm hacking on. A few days ago I sent a patch to allow to retrigger some part of the build process on a particular package
(http://lists.busybox.net/pipermail/buildroot/2009-October/030104.html).
It currently only work with "autotooled" packages, but with you ongoing work it will be easier to provide that feature on all packages.

Quoted 9 lines
Quoted 4 lines

So to me, it is important to separate the patching from the autoreconfiguring part, because when adding new source files to an autotooled package there is a need to regenerate the Makefile.in files without repatching.

Would attaching the autoreconf hook to a (not-yet-existing-but-easily-created) $(PKG)_PRE_CONFIGURE_HOOKS hook point solve the problem ?

The fact you had removed the stamp file for the autoreconf step annoyed me at first, but in the end I can add a rule that does not prerequise the stamp files to retrigger the autogen stuff.

Create a PRE_CONFIGURE hook could be better but that's just trolling... :)

Thanks for the explanation/rebased patches.

Signature · 1 line
Lionel Landwerlin <[email protected]>
#14 lore raw
In reply to Thomas Petazzoni

Hello,

Le Sun, 25 Oct 2009 22:40:56 +0100,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 1 line

1. Use make variables, such as :

FWIW, since only Lionel gave his opinion and because as him I was more convinced by make variables, I followed this path.

Quoted 11 lines

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 ...)).

In fact this is not true. By escaping the variable expansions, it is possible to post-pone the moment at which variables are expanded.

If you do :

======================================================================
define PKG_COMPILE
make -C $($(PKG)_SRCDIR)
endef

$(eval $(call PKGTARGETS,package,foo,target))
======================================================================

Then it doesn't work since $(PKG)_SRCDIR is defined while evaluating PKGTARGETS. But if you do:

======================================================================
define PKG_COMPILE
make -C $$($$(PKG)_SRCDIR)
endef

$(eval $(call PKGTARGETS,package,foo,target))
======================================================================

Then things work as expected. Therefore, I've solved what I thought to be the main drawback of the "make variables" solution, which is also why I've choosen to go deeper into this direction.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com