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 echo -n "Checking '$(1)'... "
34 if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
38 echo -e "$(PKG_NAME): $(strip $(2))" | perl -ne 's/\\\s*/\n/g,print' >> $(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 for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
90 $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
91 $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)); do \
92 if [ -n "$$$$$$$$cmd" ]; then \
93 bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
94 which "$$$$$$$${cmd%% *}")"; \
95 if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
96 mkdir -p "$(STAGING_DIR_HOST)/bin"; \
97 ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
105 $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command)))