2 # Copyright (C) 2006-2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 ifneq ($(__prereq_inc),1)
12 if [ -f $(TMP_DIR)/.prereq-error ]; then \
14 cat $(TMP_DIR)/.prereq-error; \
15 rm -f $(TMP_DIR)/.prereq-error; \
29 ifeq ($$(CHECK_$(1)),)
32 prereq-$(1): $(if $(PREREQ_PREV),prereq-$(PREREQ_PREV)) FORCE
33 printf "Checking '$(1)'... "
34 if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
38 echo "$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR)/.prereq-error; \
45 .SILENT: prereq-$(1) check-$(1)
58 $$(eval $$(call Require,$(1),$(2)))
66 $$(eval $$(call Require,$(1),$(2)))
69 define QuoteHostCommand
70 '$(subst ','"'"',$(strip $(1)))'
76 define TestHostCommand
78 ($(3)) >/dev/null 2>/dev/null
81 $$(eval $$(call Require,$(1),$(2)))
87 define SetupHostCommand
89 [ -f "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0; \
90 for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
91 $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
92 $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
93 $(call QuoteHostCommand,$(9)) $(call QuoteHostCommand,$(10)) \
94 $(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
95 if [ -n "$$$$$$$$cmd" ]; then \
96 bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
97 which "$$$$$$$${cmd%% *}")"; \
98 if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
99 mkdir -p "$(STAGING_DIR_HOST)/bin"; \
100 ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
108 $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command)))