From ddc55842445a938f3271fec0ebc768a373fa071a Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Tue, 10 Oct 2006 21:06:45 +0000
Subject: [PATCH] more portability fixes and a prereq check for gnu tar

SVN-Revision: 5037
---
 openwrt/include/host.mk          | 4 ++++
 openwrt/include/prereq-build.mk  | 9 +++++++++
 openwrt/rules.mk                 | 1 +
 openwrt/scripts/make-ipkg-dir.sh | 2 +-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/openwrt/include/host.mk b/openwrt/include/host.mk
index abcf045d01..3a5fd9683e 100644
--- a/openwrt/include/host.mk
+++ b/openwrt/include/host.mk
@@ -7,6 +7,8 @@
 
 include $(TOPDIR)/.host.mk
 
+export TAR
+
 $(TOPDIR)/.host.mk: $(INCLUDE_DIR)/host.mk
 	@( \
 		HOST_OS=`uname`; \
@@ -23,5 +25,7 @@ $(TOPDIR)/.host.mk: $(INCLUDE_DIR)/host.mk
 		if tar --version 2>&1 | grep 'GNU' >/dev/null; then \
 			echo "TAR_WILDCARDS:=--wildcards" >> $@; \
 		fi; \
+		TAR=`which gtar tar | head -n 1`; \
+		echo "TAR:=$$TAR" >> $@; \
 	)
 
diff --git a/openwrt/include/prereq-build.mk b/openwrt/include/prereq-build.mk
index a2e5469fa6..d6396af8e2 100644
--- a/openwrt/include/prereq-build.mk
+++ b/openwrt/include/prereq-build.mk
@@ -8,6 +8,7 @@
 include $(TOPDIR)/rules.mk
 TMP_DIR:=$(TOPDIR)/tmp
 include $(INCLUDE_DIR)/prereq.mk
+include $(INCLUDE_DIR)/host.mk
 
 define Require/non-root
 	[ "$$(shell whoami)" != "root" ]
@@ -94,3 +95,11 @@ $(eval $(call RequireCommand,patch, \
 $(eval $(call RequireCommand,perl, \
 	Please install perl. \
 ))
+
+define Require/gnutar
+	$(TAR) --version 2>&1 | grep GNU > /dev/null
+endef
+
+$(eval $(call Require,gnutar, \
+	Please install GNU tar. \
+))
diff --git a/openwrt/rules.mk b/openwrt/rules.mk
index b9859dbd3f..73611029a3 100644
--- a/openwrt/rules.mk
+++ b/openwrt/rules.mk
@@ -6,6 +6,7 @@
 #
 
 -include $(TOPDIR)/.config
+include $(TOPDIR)/include/host.mk
 include $(TOPDIR)/include/verbose.mk
 
 export SHELL=/usr/bin/env bash -c '. $(TOPDIR)/include/shell.sh; eval "$$2"' --
diff --git a/openwrt/scripts/make-ipkg-dir.sh b/openwrt/scripts/make-ipkg-dir.sh
index 236cb6feb4..902a4b526b 100755
--- a/openwrt/scripts/make-ipkg-dir.sh
+++ b/openwrt/scripts/make-ipkg-dir.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 BASE=http://svn.openwrt.org/openwrt/trunk/openwrt
 TARGET=$1
 CONTROL=$2
-- 
GitLab