Add quilt integration for packages
[openwrt/staging/yousong.git] / include / quilt.mk
1 #
2 # Copyright (C) 2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_patched && echo y))
9 ifneq ($(QUILT),)
10 STAMP_PREPARED:=$(strip $(STAMP_PREPARED))_q
11 CONFIG_AUTOREBUILD=
12 PATCHES:=$(shell cd ./patches; ls)
13 define Build/Patch/Default
14 rm -rf $(PKG_BUILD_DIR)/patches
15 mkdir -p $(PKG_BUILD_DIR)/patches
16 for patch in $(PATCHES); do ( \
17 cp "./patches/$$$$patch" $(PKG_BUILD_DIR); \
18 cd $(PKG_BUILD_DIR); \
19 quilt import -p 1 "$$$$patch"; \
20 quilt push; \
21 quilt refresh; \
22 rm -f "$$$$patch"; \
23 ); done
24 touch $(PKG_BUILD_DIR)/.quilt_patched
25 endef
26 else
27 define Build/Patch/Default
28 @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
29 $(PATCH) $(PKG_BUILD_DIR) ./patches; \
30 fi
31 endef
32 endif
33
34 refresh: $(STAMP_PREPARED)
35 @[ -f "$(PKG_BUILD_DIR)/patches/series" ] || { \
36 echo "The source directory was not unpacked using quilt. Please rebuild."; \
37 false; \
38 }
39 @[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] || { \
40 echo "The patches are not sorted in the right order. Please fix."; \
41 false; \
42 }
43 rm -f ./patches/* 2>/dev/null >/dev/null
44 @( \
45 for patch in $$(cat $(PKG_BUILD_DIR)/patches/series); do \
46 $(CP) -v "$(PKG_BUILD_DIR)/patches/$$patch" ./patches; \
47 done; \
48 )