build prereq: look for tar under the name "gnutar" as well
[15.05/openwrt.git] / include / host.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 TMP_DIR ?= $(TOPDIR)/tmp
9 ifeq ($(if $(TARGET_BUILD),,$(DUMP)),)
10   -include $(TMP_DIR)/.host.mk
11 endif
12
13 export TAR FIND
14
15 ifneq ($(__host_inc),1)
16 __host_inc:=1
17 .PRECIOUS: $(TMP_DIR)/.host.mk
18 $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
19         @mkdir -p $(TMP_DIR)
20         @( \
21                 HOST_OS=`uname`; \
22                 case "$$HOST_OS" in \
23                         Linux) HOST_ARCH=`uname -m`;; \
24                         *) HOST_ARCH=`uname -p`;; \
25                 esac; \
26                 GNU_HOST_NAME=`gcc -dumpmachine`; \
27                 [ -n "$$GNU_HOST_NAME" ] || \
28                         GNU_HOST_NAME=`$(SCRIPT_DIR)/config.guess`; \
29                 echo "HOST_OS:=$$HOST_OS" > $@; \
30                 echo "HOST_ARCH:=$$HOST_ARCH" >> $@; \
31                 echo "GNU_HOST_NAME:=$$GNU_HOST_NAME" >> $@; \
32                 TAR=`which gtar 2>/dev/null`; \
33                 [ -n "$$TAR" -a -x "$$TAR" ] || TAR=`which gnutar 2>/dev/null`; \
34                 [ -n "$$TAR" -a -x "$$TAR" ] || TAR=`which tar 2>/dev/null`; \
35                 echo "TAR:=$$TAR" >> $@; \
36                 FIND=`which gfind 2>/dev/null`; \
37                 [ -n "$$FIND" -a -x "$$FIND" ] || FIND=`which find 2>/dev/null`; \
38                 echo "FIND:=$$FIND" >> $@; \
39                 echo "BASH:=$(shell which bash)" >> $@; \
40                 if $$FIND -L /tmp -maxdepth 0 >/dev/null 2>/dev/null; then \
41                         echo "FIND_L=$$FIND -L \$$(1)" >>$@; \
42                 else \
43                         echo "FIND_L=$$FIND \$$(1) -follow" >> $@; \
44                 fi; \
45                 if xargs --help 2>&1 | grep 'gnu.org' >/dev/null; then \
46                         echo 'XARGS:=xargs -r' >> $@; \
47                 else \
48                         echo 'XARGS:=xargs' >> $@; \
49                 fi; \
50         )
51
52 endif