1################################################################################ 2# WAF package infrastructure 3# 4# This file implements an infrastructure that eases development of package 5# .mk files for WAF packages. It should be used for all packages that use 6# WAF as their build system. 7# 8# See the Buildroot documentation for details on the usage of this 9# infrastructure 10# 11# In terms of implementation, this WAF infrastructure requires the .mk file 12# to only specify metadata information about the package: name, version, 13# download URL, etc. 14# 15# We still allow the package .mk file to override what the different steps 16# are doing, if needed. For example, if <PKG>_BUILD_CMDS is already defined, 17# it is used as the list of commands to perform to build the package, 18# instead of the default WAF behaviour. The package can also define some 19# post operation hooks. 20# 21################################################################################ 22 23################################################################################ 24# inner-waf-package -- defines how the configuration, compilation and 25# installation of a waf package should be done, implements a few hooks 26# to tune the build process for waf specifities and calls the generic 27# package infrastructure to generate the necessary make targets 28# 29# argument 1 is the lowercase package name 30# argument 2 is the uppercase package name, including a HOST_ prefix 31# for host packages 32# argument 3 is the uppercase package name, without the HOST_ prefix 33# for host packages 34# argument 4 is the type (target or host) 35################################################################################ 36 37define inner-waf-package 38 39# We need host-python3 to run waf 40$(2)_DEPENDENCIES += host-python3 41 42$(2)_NEEDS_EXTERNAL_WAF ?= NO 43 44# If the package does not have its own waf, use our own. 45ifeq ($$($(2)_NEEDS_EXTERNAL_WAF),YES) 46$(2)_DEPENDENCIES += host-waf 47$(2)_WAF = $$(HOST_DIR)/bin/waf 48else 49$(2)_WAF ?= ./waf 50endif 51 52$(2)_BUILD_OPTS ?= 53$(2)_INSTALL_STAGING_OPTS ?= 54$(2)_INSTALL_TARGET_OPTS ?= 55$(2)_WAF_OPTS ?= 56 57# 58# Configure step. Only define it if not already defined by the package 59# .mk file. 60# 61ifndef $(2)_CONFIGURE_CMDS 62define $(2)_CONFIGURE_CMDS 63 cd $$($$(PKG)_SRCDIR) && \ 64 $$(TARGET_CONFIGURE_OPTS) \ 65 $$($(2)_CONF_ENV) \ 66 $$(HOST_DIR)/bin/python3 $$($(2)_WAF) configure \ 67 --prefix=/usr \ 68 --libdir=/usr/lib \ 69 $$($(2)_CONF_OPTS) \ 70 $$($(2)_WAF_OPTS) 71endef 72endif 73 74# 75# Build step. Only define it if not already defined by the package .mk 76# file. 77# 78ifndef $(2)_BUILD_CMDS 79define $(2)_BUILD_CMDS 80 cd $$($$(PKG)_SRCDIR) && \ 81 $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \ 82 build -j $$(PARALLEL_JOBS) $$($(2)_BUILD_OPTS) \ 83 $$($(2)_WAF_OPTS) 84endef 85endif 86 87# 88# Staging installation step. Only define it if not already defined by 89# the package .mk file. 90# 91ifndef $(2)_INSTALL_STAGING_CMDS 92define $(2)_INSTALL_STAGING_CMDS 93 cd $$($$(PKG)_SRCDIR) && \ 94 $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \ 95 install --destdir=$$(STAGING_DIR) \ 96 $$($(2)_INSTALL_STAGING_OPTS) \ 97 $$($(2)_WAF_OPTS) 98endef 99endif 100 101# 102# Target installation step. Only define it if not already defined by 103# the package .mk file. 104# 105ifndef $(2)_INSTALL_TARGET_CMDS 106define $(2)_INSTALL_TARGET_CMDS 107 cd $$($$(PKG)_SRCDIR) && \ 108 $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \ 109 install --destdir=$$(TARGET_DIR) \ 110 $$($(2)_INSTALL_TARGET_OPTS) \ 111 $$($(2)_WAF_OPTS) 112endef 113endif 114 115# Call the generic package infrastructure to generate the necessary 116# make targets 117$(call inner-generic-package,$(1),$(2),$(3),$(4)) 118 119endef 120 121################################################################################ 122# waf-package -- the target generator macro for WAF packages 123################################################################################ 124 125waf-package = $(call inner-waf-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) 126