From c8dc48d2129cca75d1796c32f6e33c7db4f958b3 Mon Sep 17 00:00:00 2001
From: Stefan Hertrampf <stefan.hertrampf@cyberus-technology.de>
Date: Fri, 28 Jan 2022 10:33:17 +0100
Subject: [PATCH] allow specifying extra patch directory

This commit allows the user to specify an extra patch directory by
either placing EXTRA_PATCHES in the config.mak or as an environment
variable when invoking make.

The patch directory is expected to have the same structure as the
patches/ directory, thus having subdirectories with the respective
components (gcc, musl, ...) and their version.

Providing EXTRA_PATCHES is optional.

Having extra patches allows to specify custom MUSL patches without
dirtying the musl-cross-make repository directory.
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 4390e7f..fb0d43f 100644
--- a/Makefile
+++ b/Makefile
@@ -137,6 +137,7 @@ musl-git-%:
 	mkdir $@.tmp
 	( cd $@.tmp && $(COWPATCH) -I ../$< )
 	test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp && $(COWPATCH) -p1 )
+	if [ ! -z "$(EXTRA_PATCHES)" ]; then cat $(EXTRA_PATCHES)/$@/* | ( cd $@.tmp && $(COWPATCH) -p1 ); fi
 	if test -f $</configfsf.sub ; then cs=configfsf.sub ; elif test -f $</config.sub ; then cs=config.sub ; else exit 0 ; fi ; rm -f $@.tmp/$$cs && cp -f $(SOURCES)/config.sub $@.tmp/$$cs && chmod +x $@.tmp/$$cs
 	rm -rf $@
 	mv $@.tmp $@