Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/pkg.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ ifneq (,$(PKG_SOURCE_LOCAL))
include $(RIOTBASE)/pkg/local.mk
else

.PHONY: prepare git-download clean
.PHONY: prepare git-download clean git-ensure-version

prepare: git-download

ifneq (,$(wildcard $(PKG_DIR)/patches))
git-download: $(PKG_BUILDDIR)/.git-patched
else
git-download: $(PKG_BUILDDIR)/.git-downloaded
git-download: git-ensure-version
endif

GITFLAGS ?= -c user.email=buildsystem@riot -c user.name="RIOT buildsystem"
GITAMFLAGS ?= --no-gpg-sign --ignore-whitespace

ifneq (,$(wildcard $(PKG_DIR)/patches))
$(PKG_BUILDDIR)/.git-patched: $(PKG_BUILDDIR)/.git-downloaded $(PKG_DIR)/Makefile $(PKG_DIR)/patches/*.patch
$(PKG_BUILDDIR)/.git-patched: git-ensure-version $(PKG_DIR)/Makefile $(PKG_DIR)/patches/*.patch
git -C $(PKG_BUILDDIR) checkout -f $(PKG_VERSION)
git $(GITFLAGS) -C $(PKG_BUILDDIR) am $(GITAMFLAGS) "$(PKG_DIR)"/patches/*.patch
touch $@
endif

git-ensure-version: $(PKG_BUILDDIR)/.git-downloaded
if [ $(shell git -C $(PKG_BUILDDIR) rev-parse HEAD) != $(PKG_VERSION) ] ; then \
git -C $(PKG_BUILDDIR) clean -xdff ; \
git -C $(PKG_BUILDDIR) fetch "$(PKG_URL)" "$(PKG_VERSION)" ; \
git -C $(PKG_BUILDDIR) checkout -f $(PKG_VERSION) ; \
touch $(PKG_BUILDDIR)/.git-downloaded ; \
fi

$(PKG_BUILDDIR)/.git-downloaded:
rm -Rf $(PKG_BUILDDIR)
mkdir -p $(PKG_BUILDDIR)
Expand Down