1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2006-2020 OpenWrt.org
5 ifneq ($(__prereq_inc
),1)
9 if
[ -f
$(TMP_DIR
)/.prereq-error
]; then \
11 cat
$(TMP_DIR
)/.prereq-error
; \
12 rm -f
$(TMP_DIR
)/.prereq-error
; \
26 ifeq ($$(CHECK_
$(1)),)
29 prereq-
$(1): $(if
$(PREREQ_PREV
),prereq-
$(PREREQ_PREV
)) FORCE
30 printf
"Checking '$(1)'... "
31 if
$(NO_TRACE_MAKE
) -f
$(firstword $(MAKEFILE_LIST
)) check-
$(1) PATH
="$(ORIG_PATH)" >/dev
/null
2>/dev
/null
; then \
33 elif
$(NO_TRACE_MAKE
) -f
$(firstword $(MAKEFILE_LIST
)) check-
$(1) PATH
="$(ORIG_PATH)" >/dev
/null
2>/dev
/null
; then \
37 echo
"$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR
)/.prereq-error
; \
44 .SILENT
: prereq-
$(1) check-
$(1)
57 $$(eval
$$(call Require
,$(1),$(2)))
65 $$(eval
$$(call Require
,$(1),$(2)))
70 # 3: optional compile time test
71 # 4: optional link library test (example -lncurses)
74 echo
'int main(int argc, char **argv) { $(3); return 0; }' | gcc
-include $(1) -x c
-o
$(TMP_DIR
)/a.out
- $(4)
77 $$(eval
$$(call Require
,$(1),$(2)))
80 define QuoteHostCommand
81 '$(subst ','"'"',$(strip $(1)))'
87 define TestHostCommand
89 ($(3)) >/dev/null 2>/dev/null
92 $$(eval $$(call Require,$(1),$(2)))
98 define SetupHostCommand
100 mkdir -p "$(STAGING_DIR_HOST
)/bin
"; \
101 for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
102 $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
103 $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
104 $(call QuoteHostCommand,$(9)) $(call QuoteHostCommand,$(10)) \
105 $(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
106 if [ -n "$$$$$$$$cmd" ]; then \
107 bin="$$$$$$$$(command
-v
"$$$$$$$${cmd%% *}")"; \
108 if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
109 case "$$$$$$$$(ls
-dl
-- $(STAGING_DIR_HOST
)/bin
/$(strip $(1)))" in \
111 *" -> $$$$$$$$bin"* | \
113 [ -x "$(STAGING_DIR_HOST
)/bin
/$(strip $(1))" ] && exit 0 \
116 ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST
)/bin
/$(strip $(1))"; \
124 $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command)))