armsr: armv8: enable serial console for Renesas platforms
[openwrt/staging/stintel.git] / include / quilt.mk
index 56f674a2f39e490b4574b85266b0e6f350a0a284..a58390f6c5471d1996de4f5f1972992488040c63 100644 (file)
@@ -1,8 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
 #
-# Copyright (C) 2007-2009 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
+# Copyright (C) 2007-2020 OpenWrt.org
 
 ifeq ($(TARGET_BUILD),1)
   PKG_BUILD_DIR:=$(LINUX_DIR)
@@ -36,8 +34,8 @@ endif
 ifneq ($(if $(DUMP),1,$(__quilt_inc)),1)
 __quilt_inc:=1
 
-PATCH_DIR?=./patches
-FILES_DIR?=./files
+PATCH_DIR?=$(CURDIR)/patches
+FILES_DIR?=$(CURDIR)/files
 HOST_PATCH_DIR?=$(PATCH_DIR)
 HOST_FILES_DIR?=$(FILES_DIR)
 
@@ -108,17 +106,18 @@ define Kernel/Patch/Default
 endef
 
 define Quilt/RefreshDir
-       mkdir -p $(2)
-       -rm -f $(2)/* 2>/dev/null >/dev/null
-       @( \
+       -rm -rf $(2) 2>/dev/null >/dev/null
+       [ -f $(1)/.quilt_no_patch ] || mkdir -p $(2)
+       @[ -f $(1)/.quilt_no_patch ] || { \
                for patch in $$$$($(if $(3),grep "^$(3)",cat) $(1)/patches/series | awk '{print $$$$1}'); do \
                        $(CP) -v "$(1)/patches/$$$$patch" $(2); \
                done; \
-       )
+       }
+       @-rm -f $(1)/.quilt_no_patch 2>/dev/null >/dev/null;
 endef
 
 define Quilt/Refresh/Host
-       $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR))
+       $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR))
 endef
 
 define Quilt/Refresh/Package
@@ -158,19 +157,21 @@ define Quilt/Template
        }
        @[ -f "$(1)/patches/series" ] || { \
                echo "The source directory contains no quilt patches."; \
-               false; \
+               touch $(1)/patches/series $(1)/.quilt_no_patch; \
        }
        @[ -n "$$$$(ls $(1)/patches/series)" -o \
-          "$$$$(cat $(1)/patches/series | mkhash md5)" = "$$(sort $(1)/patches/series | mkhash md5)" ] || { \
+          "$$$$(cat $(1)/patches/series | $(MKHASH) md5)" = "$$(sort $(1)/patches/series | $(MKHASH) md5)" ] || { \
                echo "The patches are not sorted in the right order. Please fix."; \
                false; \
        }
 
   $(3)refresh: $(3)quilt-check
-       @cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null
-       @cd "$(1)"; while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
-               QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
-       done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null
+       @[ -f $(1)/.quilt_no_patch ] || { \
+               cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null; \
+               while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
+                       QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
+               done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null; \
+       }
        $(Quilt/Refresh/$(4))
        
   $(3)update: $(3)quilt-check