aboutsummaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorGravatar Thomas Petazzoni <thomas.petazzoni@free-electrons.com>2011-09-29 21:57:41 +0200
committerGravatar Peter Korsgaard <jacmet@sunsite.dk>2011-09-29 23:06:28 +0200
commite055aea216cff4d12cf55eab2e35ca1459edaa91 (patch)
tree246ff646e8835598d508dd85a89078683caf9121 /package
parent793a2ea5174e5352ec18ca32f7914c7071bf3108 (diff)
downloadbuildroot-e055aea216cff4d12cf55eab2e35ca1459edaa91.tar.gz
buildroot-e055aea216cff4d12cf55eab2e35ca1459edaa91.tar.bz2
package: add helper functions to get package name and directory magically
This commit adds the functions "pkgname" and "pkgdir", which can then be used to automatically find the name of the package and the directory of the package which does the call to GENTARGETS/AUTOTARGETS/CMAKETARGETS. These functions use the $(MAKEFILE_LIST) variable, which make automatically makes available, and which contains the list of included Makefiles, with the current Makefile being last. Thanks to this variable and a little bit of string manipulation, we can easily find out automatically the package name and the directory it is part of. These functions are used in later commits to simplify the GENTARGETS, AUTOTARGETS and CMAKETARGETS calls. [Peter: Rename to pkgmakefile->pkgdir, pkgdir->pkgparentdir as that's what it is] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'package')
-rw-r--r--package/Makefile.package.in18
1 files changed, 18 insertions, 0 deletions
diff --git a/package/Makefile.package.in b/package/Makefile.package.in
index 5987d3823b..afa8d0e9f5 100644
--- a/package/Makefile.package.in
+++ b/package/Makefile.package.in
@@ -55,6 +55,24 @@ define KCONFIG_DISABLE_OPT
echo "# $(1) is not set" >> $(2)
endef
+# Helper functions to determine the name of a package and its
+# directory from its makefile directory, using the $(MAKEFILE_LIST)
+# variable provided by make. This is used by the *TARGETS macros to
+# automagically find where the package is located. Note that the
+# pkgdir macro is carefully written to handle the case of the Linux
+# package, for which the package directory is an empty string.
+define pkgdir
+$(dir $(lastword $(MAKEFILE_LIST)))
+endef
+
+define pkgname
+$(lastword $(subst /, ,$(call pkgdir)))
+endef
+
+define pkgparentdir
+$(patsubst %$(call pkgname)/,%,$(call pkgdir))
+endef
+
# Define extractors for different archive suffixes
INFLATE.bz2 = $(BZCAT)
INFLATE.gz = $(ZCAT)