summaryrefslogtreecommitdiffstats
path: root/package/Makefile.package.in
diff options
context:
space:
mode:
Diffstat (limited to 'package/Makefile.package.in')
-rw-r--r--package/Makefile.package.in171
1 files changed, 130 insertions, 41 deletions
diff --git a/package/Makefile.package.in b/package/Makefile.package.in
index d76b7913d..377df65c0 100644
--- a/package/Makefile.package.in
+++ b/package/Makefile.package.in
@@ -68,6 +68,92 @@ MESSAGE = echo "$(TERM_BOLD)>>> $($(PKG)_NAME) $($(PKG)_VERSION) $(1)$(TERM_RESE
TERM_BOLD := $(shell tput smso)
TERM_RESET := $(shell tput rmso)
+# Download method commands
+WGET:=$(call qstrip,$(BR2_WGET)) $(QUIET)
+SVN:=$(call qstrip,$(BR2_SVN)) $(QUIET)
+BZR:=$(call qstrip,$(BR2_BZR)) $(QUIET)
+GIT:=$(call qstrip,$(BR2_GIT)) $(QUIET)
+
+# Default spider mode is 'DOWNLOAD'. Other possible values are 'SOURCE_CHECK'
+# used by the _source-check target and 'SHOW_EXTERNAL_DEPS', used by the
+# external-deps target.
+DL_MODE=DOWNLOAD
+
+DL_DIR=$(call qstrip,$(BR2_DL_DIR))
+ifeq ($(DL_DIR),)
+DL_DIR:=$(TOPDIR)/dl
+endif
+
+################################################################################
+# The DOWNLOAD_{GIT,SVN} helpers are in charge of getting a working copy of
+# the source repository for their corresponding SCM, checking out the requested
+# version / commit / tag, and create an archive out of it. DOWNLOAD_WGET is the
+# normal wget-based download mechanism.
+#
+# The SOURCE_CHECK_{GIT,SVN,WGET} helpers are in charge of simply checking that
+# the source is available for download. This can be used to make sure one will
+# be able to get all the sources needed for one's build configuration.
+#
+# The SHOW_EXTERNAL_DEPS_{GIT,SVN,WGET} helpers simply output to the console
+# the names of the files that will be downloaded, or path and revision of the
+# source repositories, producing a list of all the "external dependencies" of
+# a given build configuration.
+################################################################################
+
+define DOWNLOAD_GIT
+ test -e $(DL_DIR)/$($(PKG)_SOURCE) || \
+ (pushd $(DL_DIR) > /dev/null && \
+ $(GIT) clone $($(PKG)_SITE) $($(PKG)_BASE_NAME) && \
+ pushd $($(PKG)_BASE_NAME) > /dev/null && \
+ $(GIT) archive --format=tar --prefix=$($(PKG)_BASE_NAME)/ $($(PKG)_DL_VERSION) | \
+ gzip -c > $(DL_DIR)/$($(PKG)_SOURCE) && \
+ popd > /dev/null && \
+ rm -rf $($(PKG)_DL_DIR) && \
+ popd > /dev/null)
+endef
+
+# TODO: improve to check that the given PKG_DL_VERSION exists on the remote
+# repository
+define SOURCE_CHECK_GIT
+ $(GIT) ls-remote --heads $($(PKG)_SITE) > /dev/null
+endef
+
+define SHOW_EXTERNAL_DEPS_GIT
+ echo "$($(PKG)_SITE) [git: $($(PKG)_DL_VERSION)]"
+endef
+
+
+define DOWNLOAD_SVN
+ test -e $(DL_DIR)/$($(PKG)_SOURCE) || \
+ (pushd $(DL_DIR) > /dev/null && \
+ $(SVN) export -r $($(PKG)_DL_VERSION) $($(PKG)_SITE) $($(PKG)_DL_DIR) && \
+ $(TAR) czf $($(PKG)_SOURCE) $($(PKG)_BASE_NAME)/ && \
+ rm -rf $($(PKG)_DL_DIR) && \
+ popd > /dev/null)
+endef
+
+define SOURCE_CHECK_SVN
+ $(SVN) ls $($(PKG)_SITE) > /dev/null
+endef
+
+define SHOW_EXTERNAL_DEPS_SVN
+ echo "$($(PKG)_SITE) [svn: $($(PKG)_DL_VERSION)]"
+endef
+
+
+define DOWNLOAD_WGET
+ test -e $(DL_DIR)/$(2) || \
+ $(WGET) -P $(DL_DIR) $(call qstrip,$(1))/$(2)
+endef
+
+define SOURCE_CHECK_WGET
+ $(WGET) --spider $(call qstrip,$(1))/$(2)
+endef
+
+define SHOW_EXTERNAL_DEPS_WGET
+ echo $(2)
+endef
+
################################################################################
# DOWNLOAD -- Download helper. Will try to download source from:
# 1) BR2_PRIMARY_SITE if enabled
@@ -81,16 +167,22 @@ TERM_RESET := $(shell tput rmso)
# $(call DOWNLOAD,$(FOO_SITE),$(FOO_SOURCE))
################################################################################
-# support make source-check/external-deps
-ifneq ($(SPIDER),)
-DOWNLOAD=$(WGET) -P $(DL_DIR) $(1)/$(2)
-else
define DOWNLOAD
- $(Q)test -e $(DL_DIR)/$(2) || \
- for site in $(call qstrip,$(BR2_PRIMARY_SITE)) $(1) $(call qstrip,$(BR2_BACKUP_SITE)); \
- do $(WGET) -P $(DL_DIR) $$site/$(2) && exit; done
+ $(Q)if test -n "$(call qstrip,$(BR2_PRIMARY_SITE))" ; then \
+ $(call $(DL_MODE)_WGET,$(BR2_PRIMARY_SITE),$(2)) && exit ; \
+ fi ; \
+ if test -n "$(1)" ; then \
+ case "$($(PKG)_SITE_METHOD)" in \
+ git) $($(DL_MODE)_GIT) && exit ;; \
+ svn) $($(DL_MODE)_SVN) && exit ;; \
+ *) $(call $(DL_MODE)_WGET,$(1),$(2)) && exit ;; \
+ esac ; \
+ fi ; \
+ if test -n "$(call qstrip,$(BR2_BACKUP_SITE))" ; then \
+ $(call $(DL_MODE)_WGET,$(BR2_BACKUP_SITE),$(2)) && exit ; \
+ fi ; \
+ exit 1
endef
-endif
# Utility programs used to build packages
TAR ?= tar
@@ -117,8 +209,7 @@ endef
# Retrieve the archive
$(BUILD_DIR)/%/.stamp_downloaded:
-# support make source-check/external-deps
-ifeq ($(SPIDER),)
+ifeq ($(DL_MODE),DOWNLOAD)
# Only show the download message if it isn't already downloaded
$(Q)(test -e $(DL_DIR)/$($(PKG)_SOURCE) && \
(test -z $($(PKG)_PATCH) || test -e $(DL_DIR)$($(PKG)_PATCH))) || \
@@ -126,7 +217,7 @@ ifeq ($(SPIDER),)
endif
$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_SOURCE))
$(if $($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_PATCH)))
-ifeq ($(SPIDER),)
+ifeq ($(DL_MODE),DOWNLOAD)
$(Q)mkdir -p $(@D)
$(Q)touch $@
endif
@@ -246,21 +337,31 @@ define GENTARGETS_INNER
$(2)_TYPE = $(5)
$(2)_NAME = $(1)
+# Keep the package version that may contain forward slashes in the _DL_VERSION
+# variable, then replace all forward slashes ('/') by underscores ('_') to
+# sanitize the package version that is used in paths, directory and file names.
+# Forward slashes may appear in the package's version when pointing to a
+# version control system branch or tag, for example remotes/origin/1_10_stable.
+$(2)_DL_VERSION = $($(2)_VERSION)
ifndef $(2)_VERSION
ifdef $(3)_VERSION
$(2)_VERSION = $($(3)_VERSION)
else
$(2)_VERSION = undefined
endif
+else
+ $(2)_VERSION = $(subst /,_,$($(2)_VERSION))
endif
-$(2)_DIR = $$(BUILD_DIR)/$(1)-$$($(2)_VERSION)
+$(2)_BASE_NAME = $(1)-$$($(2)_VERSION)
+$(2)_DL_DIR = $$(DL_DIR)/$$($(2)_BASE_NAME)
+$(2)_DIR = $$(BUILD_DIR)/$$($(2)_BASE_NAME)
ifndef $(2)_SOURCE
ifdef $(3)_SOURCE
$(2)_SOURCE = $($(3)_SOURCE)
else
- $(2)_SOURCE ?= $(1)-$$($(2)_VERSION).tar.gz
+ $(2)_SOURCE ?= $$($(2)_BASE_NAME).tar.gz
endif
endif
@@ -279,6 +380,15 @@ ifndef $(2)_SITE
endif
endif
+ifndef $(2)_SITE_METHOD
+ ifdef $(3)_SITE_METHOD
+ $(2)_SITE_METHOD = $($(3)_SITE_METHOD)
+ else
+ # Try automatic detection using the scheme part of the URI
+ $(2)_SITE_METHOD = $(firstword $(subst ://, ,$(call qstrip,$($(2)_SITE))))
+ endif
+endif
+
$(2)_DEPENDENCIES ?=
$(2)_INSTALL_STAGING ?= NO
$(2)_INSTALL_TARGET ?= YES
@@ -292,12 +402,12 @@ $(2)_TARGET_BUILD = $$($(2)_DIR)/.stamp_built
$(2)_TARGET_CONFIGURE = $$($(2)_DIR)/.stamp_configured
$(2)_TARGET_PATCH = $$($(2)_DIR)/.stamp_patched
$(2)_TARGET_EXTRACT = $$($(2)_DIR)/.stamp_extracted
-$(2)_TARGET_SOURCE ?= $$($(2)_DIR)/.stamp_downloaded
+$(2)_TARGET_SOURCE = $$($(2)_DIR)/.stamp_downloaded
$(2)_TARGET_UNINSTALL = $$($(2)_DIR)/.stamp_uninstalled
$(2)_TARGET_CLEAN = $$($(2)_DIR)/.stamp_cleaned
$(2)_TARGET_DIRCLEAN = $$($(2)_DIR)/.stamp_dircleaned
-# new-style hooks
+# post-steps hooks
$(2)_POST_EXTRACT_HOOKS ?=
$(2)_POST_PATCH_HOOKS ?=
$(2)_POST_CONFIGURE_HOOKS ?=
@@ -306,20 +416,13 @@ $(2)_POST_INSTALL_HOOKS ?=
$(2)_POST_INSTALL_STAGING_HOOKS ?=
$(2)_POST_INSTALL_TARGET_HOOKS ?=
-# old-style hooks
-$(2)_HOOK_POST_EXTRACT = $$($(2)_DIR)/.stamp_hook_post_extract
-$(2)_HOOK_POST_CONFIGURE = $$($(2)_DIR)/.stamp_hook_post_configure
-$(2)_HOOK_POST_BUILD = $$($(2)_DIR)/.stamp_hook_post_build
-$(2)_HOOK_POST_INSTALL = $$($(2)_DIR)/.stamp_hook_post_install
-
# human-friendly targets and target sequencing
$(1): $(1)-install
ifeq ($$($(2)_TYPE),host)
-$(1)-install: $(1)-install-host $$($(2)_HOOK_POST_INSTALL)
+$(1)-install: $(1)-install-host
else
-$(1)-install: $(1)-install-staging $(1)-install-target \
- $$($(2)_HOOK_POST_INSTALL)
+$(1)-install: $(1)-install-staging $(1)-install-target
endif
ifeq ($$($(2)_INSTALL_TARGET),YES)
@@ -339,18 +442,15 @@ endif
$(1)-install-host: $(1)-build $$($(2)_TARGET_INSTALL_HOST)
$(1)-build: $(1)-configure \
- $$($(2)_TARGET_BUILD) \
- $$($(2)_HOOK_POST_BUILD)
+ $$($(2)_TARGET_BUILD)
$(1)-configure: $(1)-patch \
- $$($(2)_TARGET_CONFIGURE) \
- $$($(2)_HOOK_POST_CONFIGURE)
+ $$($(2)_TARGET_CONFIGURE)
$(1)-patch: $(1)-extract $$($(2)_TARGET_PATCH)
$(1)-extract: $(1)-depends \
- $$($(2)_TARGET_EXTRACT) \
- $$($(2)_HOOK_POST_EXTRACT)
+ $$($(2)_TARGET_EXTRACT)
$(1)-depends: $(1)-source $$($(2)_DEPENDENCIES)
@@ -380,17 +480,6 @@ $$($(2)_TARGET_SOURCE): PKG=$(2)
$$($(2)_TARGET_UNINSTALL): PKG=$(2)
$$($(2)_TARGET_CLEAN): PKG=$(2)
$$($(2)_TARGET_DIRCLEAN): PKG=$(2)
-$$($(2)_HOOK_POST_EXTRACT): PKG=$(2)
-$$($(2)_HOOK_POST_CONFIGURE): PKG=$(2)
-$$($(2)_HOOK_POST_BUILD): PKG=$(2)
-$$($(2)_HOOK_POST_INSTALL): PKG=$(2)
-
-# define hook targets
-# default hook behaviour: do nothing
-$$($(2)_HOOK_POST_EXTRACT):
-$$($(2)_HOOK_POST_CONFIGURE):
-$$($(2)_HOOK_POST_BUILD):
-$$($(2)_HOOK_POST_INSTALL):
# add package to the general list of targets if requested by the buildroot
# configuration