Really add the LED driver :)
[openwrt.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 ifeq ($(KERNEL_BUILD),1)
9 PKG_BUILD_DIR:=$(LINUX_DIR)
10 endif
11 PATCH_DIR?=./patches
12
13 define Quilt/Patch
14 @for patch in $$$$( (cd $(1) && ls) 2>/dev/null ); do ( \
15 cp "$(1)/$$$$patch" $(PKG_BUILD_DIR); \
16 cd $(PKG_BUILD_DIR); \
17 quilt import -P$(2)$$$$patch -p 1 "$$$$patch"; \
18 quilt push -f >/dev/null 2>/dev/null; \
19 rm -f "$$$$patch"; \
20 ); done
21 endef
22
23 QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_used && echo y))
24 ifneq ($(QUILT),)
25 STAMP_PREPARED:=$(strip $(STAMP_PREPARED))_q
26 STAMP_PATCHED:=$(PKG_BUILD_DIR)/.quilt_patched
27 override CONFIG_AUTOREBUILD=
28 define Build/Patch/Default
29 rm -rf $(PKG_BUILD_DIR)/patches
30 mkdir -p $(PKG_BUILD_DIR)/patches
31 $(call Quilt/Patch,$(PATCH_DIR),)
32 @echo
33 touch $(PKG_BUILD_DIR)/.quilt_used
34 endef
35 $(STAMP_CONFIGURED): $(STAMP_PATCHED) FORCE
36 prepare: $(STAMP_PATCHED)
37 quilt-check: $(STAMP_PATCHED)
38 else
39 define Build/Patch/Default
40 @if [ -d $(PATCH_DIR) -a "$$$$(ls $(PATCH_DIR) | wc -l)" -gt 0 ]; then \
41 $(PATCH) $(PKG_BUILD_DIR) $(PATCH_DIR); \
42 fi
43 endef
44 endif
45
46 define Kernel/Patch/Default
47 if [ -d $(GENERIC_PLATFORM_DIR)/files ]; then $(CP) $(GENERIC_PLATFORM_DIR)/files/* $(LINUX_DIR)/; fi
48 if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
49 $(if $(strip $(QUILT)),$(call Quilt/Patch,$(GENERIC_PATCH_DIR),generic/), \
50 if [ -d $(GENERIC_PATCH_DIR) ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PATCH_DIR); fi \
51 )
52 $(if $(strip $(QUILT)),$(call Quilt/Patch,$(PATCH_DIR),platform/), \
53 if [ -d $(PATCH_DIR) ]; then $(PATCH) $(LINUX_DIR) $(PATCH_DIR); fi \
54 )
55 $(if $(strip $(QUILT)),touch $(PKG_BUILD_DIR)/.quilt_used)
56 endef
57
58 $(STAMP_PATCHED): $(STAMP_PREPARED)
59 @cd $(PKG_BUILD_DIR); quilt pop -a -f >/dev/null 2>/dev/null || true
60 (\
61 cd $(PKG_BUILD_DIR)/patches; \
62 find * -type f \! -name series | sort > series; \
63 )
64 if [ -s "$(PKG_BUILD_DIR)/patches/series" ]; then (cd $(PKG_BUILD_DIR); quilt push -a); fi
65 touch $@
66
67 define Quilt/RefreshDir
68 mkdir -p $(1)
69 -rm -f $(1)/* 2>/dev/null >/dev/null
70 @( \
71 for patch in $$($(if $(2),grep "^$(2)",cat) $(PKG_BUILD_DIR)/patches/series | awk '{print $$1}'); do \
72 $(CP) -v "$(PKG_BUILD_DIR)/patches/$$patch" $(1); \
73 done; \
74 )
75 endef
76
77 define Quilt/Refresh/Package
78 $(call Quilt/RefreshDir,$(PATCH_DIR))
79 endef
80
81 define Quilt/Refresh/Kernel
82 @[ -z "$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] || { \
83 echo "All kernel patches must start with either generic/ or platform/"; \
84 false; \
85 }
86 $(call Quilt/RefreshDir,$(GENERIC_PATCH_DIR),generic/)
87 $(call Quilt/RefreshDir,$(PATCH_DIR),platform/)
88 endef
89
90 quilt-check: $(STAMP_PREPARED) FORCE
91 @[ -f "$(PKG_BUILD_DIR)/.quilt_used" ] || { \
92 echo "The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \
93 false; \
94 }
95 @[ -f "$(PKG_BUILD_DIR)/patches/series" ] || { \
96 echo "The source directory contains no quilt patches."; \
97 false; \
98 }
99 @[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] || { \
100 echo "The patches are not sorted in the right order. Please fix."; \
101 false; \
102 }
103
104 refresh: quilt-check
105 @cd $(PKG_BUILD_DIR); quilt pop -a -f >/dev/null 2>/dev/null
106 @cd $(PKG_BUILD_DIR); while quilt next 2>/dev/null >/dev/null && quilt push; do \
107 quilt refresh; \
108 done; ! quilt next 2>/dev/null >/dev/null
109 $(if $(KERNEL_BUILD),$(Quilt/Refresh/Kernel),$(Quilt/Refresh/Package))
110
111 update: quilt-check
112 $(if $(KERNEL_BUILD),$(Quilt/Refresh/Kernel),$(Quilt/Refresh/Package))
113
This page took 0.047612 seconds and 5 git commands to generate.