2 # Copyright (C) 2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_used && echo y))
10 STAMP_PREPARED:=$(strip $(STAMP_PREPARED))_q
11 STAMP_PATCHED:=$(PKG_BUILD_DIR)/.quilt_patched
13 PATCHES:=$(shell cd ./patches; ls)
14 define Build/Patch/Default
15 rm -rf $(PKG_BUILD_DIR)/patches
16 mkdir -p $(PKG_BUILD_DIR)/patches
17 @for patch in $(PATCHES); do ( \
18 cp "./patches/$$$$patch" $(PKG_BUILD_DIR); \
19 cd $(PKG_BUILD_DIR); \
20 quilt import -p 1 "$$$$patch"; \
21 quilt push -f >/dev/null 2>/dev/null; \
25 touch $(PKG_BUILD_DIR)/.quilt_used
27 $(STAMP_CONFIGURED): $(STAMP_PATCHED)
28 prepare: $(STAMP_PATCHED)
30 define Build/Patch/Default
31 @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
32 $(PATCH) $(PKG_BUILD_DIR) ./patches; \
37 $(STAMP_PATCHED): $(STAMP_PREPARED)
38 @cd $(PKG_BUILD_DIR); quilt pop -a -f >/dev/null 2>/dev/null || true
39 cd $(PKG_BUILD_DIR); quilt push -a
42 refresh: $(STAMP_PREPARED)
43 @[ -f "$(PKG_BUILD_DIR)/patches/series" ] || { \
44 echo "The source directory was not unpacked using quilt. Please rebuild."; \
47 @[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] || { \
48 echo "The patches are not sorted in the right order. Please fix."; \
51 rm -f ./patches/* 2>/dev/null >/dev/null
53 for patch in $$(cat $(PKG_BUILD_DIR)/patches/series); do \
54 $(CP) -v "$(PKG_BUILD_DIR)/patches/$$patch" ./patches; \