pkg-infra: add host-xxx-package macro

Create host-generic-package, host-autotools-package and
host-cmake-package macros.  Such a macro is more intuitive to use than
the $(call ...,host) construct.  Also it speeds things up by having
one less $(call ...) evaluation.

Also includes documentation update, but not for buildroot.html.

This brings the time for 'make -qp' (which is used by bash-completion)
down from 1.85s to 1.35s on my laptop.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Arnout Vandecappelle (Essensium/Mind) 2012-07-03 00:05:46 +02:00 committed by Thomas Petazzoni
parent d09967e071
commit c98337911c
7 changed files with 32 additions and 53 deletions

View File

@ -23,7 +23,7 @@ package, with an example :
11: LIBFOO_CONF_OPT = --enable-shared 11: LIBFOO_CONF_OPT = --enable-shared
12: LIBFOO_DEPENDENCIES = libglib2 host-pkg-config 12: LIBFOO_DEPENDENCIES = libglib2 host-pkg-config
13: 13:
14: $(eval $(call AUTOTARGETS)) 14: $(eval $(AUTOTARGETS))
------------------------ ------------------------
On line 6, we declare the version of the package. On line 6, we declare the version of the package.
@ -67,11 +67,9 @@ package to be built.
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
The main macro of the autotools package infrastructure is The main macro of the autotools package infrastructure is
+AUTOTARGETS+. It has the same number of arguments and the +AUTOTARGETS+. It is similar to the +GENTARGETS+ macro. The ability to
same semantic as the +GENTARGETS+ macro, which is the main have target and host packages is also available, with the
macro of the generic package infrastructure. For autotools packages, the +host-autotools-package+ macro.
ability to have target and host packages is also available (and is
actually widely used).
Just like the generic infrastructure, the autotools infrastructure Just like the generic infrastructure, the autotools infrastructure
works by defining a number of variables before calling the works by defining a number of variables before calling the

View File

@ -23,7 +23,7 @@ with an example :
11: LIBFOO_CONF_OPT = -DBUILD_DEMOS=ON 11: LIBFOO_CONF_OPT = -DBUILD_DEMOS=ON
12: LIBFOO_DEPENDENCIES = libglib2 host-pkg-config 12: LIBFOO_DEPENDENCIES = libglib2 host-pkg-config
13: 13:
14: $(eval $(call CMAKETARGETS)) 14: $(eval $(CMAKETARGETS))
------------------------ ------------------------
On line 6, we declare the version of the package. On line 6, we declare the version of the package.
@ -66,10 +66,9 @@ package to be built.
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
The main macro of the CMake package infrastructure is The main macro of the CMake package infrastructure is
+CMAKETARGETS+. It has the same number of arguments and the same +CMAKETARGETS+. It is similar to the +GENTARGETS+ macro. The ability to
semantic as the +GENTARGETS+ macro, which is the main macro of the have target and host packages is also available, with the
generic package infrastructure. For CMake packages, the ability to +host-cmake-package+ macro.
have target and host packages is also available.
Just like the generic infrastructure, the CMake infrastructure works Just like the generic infrastructure, the CMake infrastructure works
by defining a number of variables before calling the +CMAKETARGETS+ by defining a number of variables before calling the +CMAKETARGETS+

View File

@ -46,7 +46,7 @@ system is based on hand-written Makefiles or shell scripts.
32: /bin/foo f 4755 0 0 - - - - - 32: /bin/foo f 4755 0 0 - - - - -
33: endef 33: endef
34: 34:
35: $(eval $(call GENTARGETS)) 35: $(eval $(GENTARGETS))
-------------------------------- --------------------------------
The Makefile begins on line 6 to 8 with metadata information: the The Makefile begins on line 6 to 8 with metadata information: the
@ -92,19 +92,16 @@ Makefile code necessary to make your package working.
+GENTARGETS+ Reference +GENTARGETS+ Reference
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
The +GENTARGETS+ macro takes one optional argument. This argument can There are two variants of the generic target. The +GENTARGETS+ macro is
be used to tell if the package is a target package (cross-compiled for used for packages to be cross-compiled for the target. The
the target) or a host package (natively compiled for the host). If +host-generic-package+ macro is used for host packages, natively compiled
unspecified, it is assumed that it is a target package. See below for for the host. It is possible to call both of them in a single +.mk+
details. file: once to create the rules to generate a target
For a given package, in a single +.mk+ file, it is possible to call
GENTARGETS twice, once to create the rules to generate a target
package and once to create the rules to generate a host package: package and once to create the rules to generate a host package:
---------------------- ----------------------
$(eval $(call GENTARGETS)) $(eval $(GENTARGETS))
$(eval $(call GENTARGETS,host)) $(eval $(host-generic-package))
---------------------- ----------------------
This might be useful if the compilation of the target package requires This might be useful if the compilation of the target package requires
@ -115,12 +112,12 @@ some tools to be installed on the host. If the package name is
variables of other packages, if they depend on +libfoo+ or variables of other packages, if they depend on +libfoo+ or
+host-libfoo+. +host-libfoo+.
The call to the +GENTARGETS+ macro *must* be at the end of the +.mk+ The call to the +GENTARGETS+ and/or +host-generic-package+ macro *must* be
file, after all variable definitions. at the end of the +.mk+ file, after all variable definitions.
For the target package, the +GENTARGETS+ uses the variables defined by For the target package, the +GENTARGETS+ uses the variables defined by
the .mk file and prefixed by the uppercased package name: the .mk file and prefixed by the uppercased package name:
+LIBFOO_*+. For the host package, it uses the +HOST_LIBFOO_*+. For +LIBFOO_*+. +host-generic-package+ uses the +HOST_LIBFOO_*+ variables. For
'some' variables, if the +HOST_LIBFOO_+ prefixed variable doesn't 'some' variables, if the +HOST_LIBFOO_+ prefixed variable doesn't
exist, the package infrastructure uses the corresponding variable exist, the package infrastructure uses the corresponding variable
prefixed by +LIBFOO_+. This is done for variables that are likely to prefixed by +LIBFOO_+. This is done for variables that are likely to

View File

@ -305,10 +305,5 @@ endef
# Argument 1 is "target" or "host" [optional, default: "target"] # Argument 1 is "target" or "host" [optional, default: "target"]
################################################################################ ################################################################################
define AUTOTARGETS AUTOTARGETS = $(call AUTOTARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
ifeq ($(1),host) host-autotools-package = $(call AUTOTARGETS_INNER,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
$(call AUTOTARGETS_INNER,$(1)-$(call pkgname),$(call UPPERCASE,$(1)-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
else
$(call AUTOTARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
endif
endef

View File

@ -190,13 +190,8 @@ endef
# Argument 1 is "target" or "host" [optional, default: "target"] # Argument 1 is "target" or "host" [optional, default: "target"]
################################################################################ ################################################################################
define CMAKETARGETS CMAKETARGETS = $(call CMAKETARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
ifeq ($(1),host) host-cmake-package = $(call CMAKETARGETS_INNER,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
$(call CMAKETARGETS_INNER,$(1)-$(call pkgname),$(call UPPERCASE,$(1)-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
else
$(call CMAKETARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
endif
endef
################################################################################ ################################################################################
# Generation of the CMake toolchain file # Generation of the CMake toolchain file

View File

@ -504,14 +504,9 @@ endef # GENTARGETS_INNER
# Argument 1 is "target" or "host" [optional, default: "target"] # Argument 1 is "target" or "host" [optional, default: "target"]
################################################################################ ################################################################################
define GENTARGETS
ifeq ($(1),host)
# In the case of host packages, turn the package name "pkg" into "host-pkg"
$(call GENTARGETS_INNER,$(1)-$(call pkgname),$(call UPPERCASE,$(1)-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
else
# In the case of target packages, keep the package name "pkg" # In the case of target packages, keep the package name "pkg"
$(call GENTARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target) GENTARGETS = $(call GENTARGETS_INNER,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
endif # In the case of host packages, turn the package name "pkg" into "host-pkg"
endef host-generic-package = $(call GENTARGETS_INNER,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
# :mode=makefile: # :mode=makefile:

View File

@ -100,27 +100,27 @@ for i in $(find package/ -name '*.mk') ; do
is_manual_target=0 is_manual_target=0
is_manual_host=0 is_manual_host=0
if grep -E "\(call AUTOTARGETS,host\)" $i > /dev/null ; then if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
is_auto_host=1 is_auto_host=1
fi fi
if grep -E "\(call AUTOTARGETS\)" $i > /dev/null ; then if grep -E "\(AUTOTARGETS\)" $i > /dev/null ; then
is_auto_target=1 is_auto_target=1
fi fi
if grep -E "\(call GENTARGETS,host\)" $i > /dev/null ; then if grep -E "\(host-generic-package\)" $i > /dev/null ; then
is_pkg_host=1 is_pkg_host=1
fi fi
if grep -E "\(call GENTARGETS\)" $i > /dev/null ; then if grep -E "\(GENTARGETS\)" $i > /dev/null ; then
is_pkg_target=1 is_pkg_target=1
fi fi
if grep -E "\(call CMAKETARGETS,host\)" $i > /dev/null ; then if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
is_cmake_host=1 is_cmake_host=1
fi fi
if grep -E "\(call CMAKETARGETS\)" $i > /dev/null ; then if grep -E "\(CMAKETARGETS\)" $i > /dev/null ; then
is_cmake_target=1 is_cmake_target=1
fi fi