detect whether the find command supports -L or -follow
[openwrt/openwrt.git] / include / host.mk
1 #
2 # Copyright (C) 2006 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 -include $(TMP_DIR)/.host.mk
9
10 export TAR
11
12 ifneq ($(__host_inc),1)
13 __host_inc:=1
14 $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
15 @mkdir -p $(TMP_DIR)
16 @( \
17 HOST_OS=`uname`; \
18 case "$$HOST_OS" in \
19 Linux) HOST_ARCH=`uname -m`;; \
20 *) HOST_ARCH=`uname -p`;; \
21 esac; \
22 GNU_HOST_NAME=`gcc -dumpmachine`; \
23 [ -n "$$GNU_HOST_NAME" ] || \
24 GNU_HOST_NAME=`$(SCRIPT_DIR)/config.guess`; \
25 echo "HOST_OS:=$$HOST_OS" > $@; \
26 echo "HOST_ARCH:=$$HOST_ARCH" >> $@; \
27 echo "GNU_HOST_NAME:=$$GNU_HOST_NAME" >> $@; \
28 TAR=`which gtar 2>/dev/null`; \
29 [ -n "$$TAR" -a -x "$$TAR" ] || TAR=`which tar 2>/dev/null`; \
30 echo "TAR:=$$TAR" >> $@; \
31 echo "BASH:=$(shell which bash)" >> $@; \
32 if find -L /tmp -maxdepth 0 >/dev/null 2>/dev/null; then \
33 echo 'FIND_L=find -L $$(1)' >>$@; \
34 else \
35 echo 'FIND_L=find $$(1) -follow' >> $@; \
36 fi; \
37 )
38
39 endif
40
41 ifeq ($(HOST_OS),Linux)
42 XARGS:=xargs -r
43 else
44 XARGS:=xargs
45 endif