4dce2a6d8ca2ef59312ab255d8c3100b1a2ce941
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 ifneq ($(__quilt_inc
),1)
11 ifeq ($(TARGET_BUILD
),1)
12 PKG_BUILD_DIR
:=$(LINUX_DIR
)
16 ifeq ($(MAKECMDGOALS
),refresh
)
21 @for patch in
$$$$( (cd
$(1) && if
[ -f series
]; then grep
-v
'^#' series
; else ls
; fi
; ) 2>/dev
/null
); do
( \
22 cp
"$(1)/$$$$patch" $(PKG_BUILD_DIR
); \
23 cd
$(PKG_BUILD_DIR
); \
24 quilt import
-P
$(2)$$$$patch -p
1 "$$$$patch"; \
25 quilt push
-f
>/dev
/null
2>/dev
/null
; \
30 QUILT?
=$(strip $(shell test -f
$(PKG_BUILD_DIR
)/.quilt_used
&& echo y
))
32 STAMP_PATCHED
:=$(PKG_BUILD_DIR
)/.quilt_patched
33 override CONFIG_AUTOREBUILD
=
34 define Build
/Patch
/Default
35 rm -rf
$(PKG_BUILD_DIR
)/patches
36 mkdir
-p
$(PKG_BUILD_DIR
)/patches
37 $(call Quilt
/Patch
,$(PATCH_DIR
),)
39 touch
$(PKG_BUILD_DIR
)/.quilt_used
41 $(STAMP_CONFIGURED
): $(STAMP_PATCHED
) FORCE
42 prepare
: $(STAMP_PATCHED
)
43 quilt-check
: $(STAMP_PATCHED
)
45 define Build
/Patch
/Default
46 @if
[ -d
$(PATCH_DIR
) -a
"$$$$(ls $(PATCH_DIR) | wc -l)" -gt
0 ]; then \
47 $(PATCH
) $(PKG_BUILD_DIR
) $(PATCH_DIR
); \
52 define Kernel
/Patch
/Default
53 if
[ -d
$(GENERIC_PLATFORM_DIR
)/files
]; then
$(CP
) $(GENERIC_PLATFORM_DIR
)/files
/* $(LINUX_DIR
)/; fi
54 if
[ -d .
/files
]; then
$(CP
) .
/files
/* $(LINUX_DIR
)/; fi
55 $(if
$(strip $(QUILT
)),$(call Quilt
/Patch
,$(GENERIC_PATCH_DIR
),generic
/), \
56 if
[ -d
$(GENERIC_PATCH_DIR
) ]; then
$(PATCH
) $(LINUX_DIR
) $(GENERIC_PATCH_DIR
); fi \
58 $(if
$(strip $(QUILT
)),$(call Quilt
/Patch
,$(PATCH_DIR
),platform
/), \
59 if
[ -d
$(PATCH_DIR
) ]; then
$(PATCH
) $(LINUX_DIR
) $(PATCH_DIR
); fi \
61 $(if
$(strip $(QUILT
)),touch
$(PKG_BUILD_DIR
)/.quilt_used
)
64 ifeq ($(TARGET_BUILD
),1)
65 $(STAMP_PATCHED
): $(STAMP_PREPARED
)
66 @cd
$(PKG_BUILD_DIR
); quilt pop
-a
-f
>/dev
/null
2>/dev
/null || true
68 cd
$(PKG_BUILD_DIR
)/patches
; \
71 if
[ -f
$$file/series
]; then \
72 echo
"Converting $$file/series"; \
73 awk
-v file
="$$file/" '$$0 !~ /^#/ { print file $$0 }' $$file/series
>> series
; \
75 echo
"Sorting patches in $$file"; \
76 find
$$file/* -type f \
! -name series |
sort >> series
; \
80 if
[ -s
"$(PKG_BUILD_DIR)/patches/series" ]; then
(cd
$(PKG_BUILD_DIR
); quilt push
-a
); fi
83 $(STAMP_PATCHED
): $(STAMP_PREPARED
)
84 @cd
$(PKG_BUILD_DIR
); quilt pop
-a
-f
>/dev
/null
2>/dev
/null || true
86 cd
$(PKG_BUILD_DIR
)/patches
; \
87 find
* -type f \
! -name series |
sort > series
; \
89 if
[ -s
"$(PKG_BUILD_DIR)/patches/series" ]; then
(cd
$(PKG_BUILD_DIR
); quilt push
-a
); fi
93 define Quilt
/RefreshDir
95 -rm -f
$(1)/* 2>/dev
/null
>/dev
/null
97 for patch in
$$($(if
$(2),grep
"^$(2)",cat
) $(PKG_BUILD_DIR
)/patches
/series | awk
'{print $$1}'); do \
98 $(CP
) -v
"$(PKG_BUILD_DIR)/patches/$$patch" $(1); \
103 define Quilt
/Refresh
/Package
104 $(call Quilt
/RefreshDir
,$(PATCH_DIR
))
107 define Quilt
/Refresh
/Kernel
108 @
[ -z
"$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] ||
{ \
109 echo
"All kernel patches must start with either generic/ or platform/"; \
112 $(call Quilt
/RefreshDir
,$(GENERIC_PATCH_DIR
),generic
/)
113 $(call Quilt
/RefreshDir
,$(PATCH_DIR
),platform
/)
116 quilt-check
: $(STAMP_PREPARED
) FORCE
117 @
[ -f
"$(PKG_BUILD_DIR)/.quilt_used" ] ||
{ \
118 echo
"The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \
121 @
[ -f
"$(PKG_BUILD_DIR)/patches/series" ] ||
{ \
122 echo
"The source directory contains no quilt patches."; \
125 @
[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] ||
{ \
126 echo
"The patches are not sorted in the right order. Please fix."; \
131 @cd
$(PKG_BUILD_DIR
); quilt pop
-a
-f
>/dev
/null
2>/dev
/null
132 @cd
$(PKG_BUILD_DIR
); while quilt next
2>/dev
/null
>/dev
/null
&& quilt push
; do \
134 done
; ! quilt next
2>/dev
/null
>/dev
/null
135 $(if
$(KERNEL_BUILD
),$(Quilt
/Refresh
/Kernel
),$(Quilt
/Refresh
/Package
))
138 $(if
$(KERNEL_BUILD
),$(Quilt
/Refresh
/Kernel
),$(Quilt
/Refresh
/Package
))