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) >/dev
/null
2>/dev
/null
; then \
35 echo
"$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR
)/.prereq-error
; \
42 .SILENT
: prereq-
$(1) check-
$(1)
55 $$(eval
$$(call Require
,$(1),$(2)))
63 $$(eval
$$(call Require
,$(1),$(2)))
68 # 3: optional compile time test
69 # 4: optional link library test (example -lncurses)
72 echo
'int main(int argc, char **argv) { $(3); return 0; }' | gcc
-include $(1) -x c
-o
$(TMP_DIR
)/a.out
- $(4)
75 $$(eval
$$(call Require
,$(1),$(2)))
79 define Require
/python2-cleanup
80 if
[ -f
"$(STAGING_DIR_HOST)/bin/python" ] && \
81 $(STAGING_DIR_HOST
)/bin
/python
-V
2>&1 | \
82 grep
-q
'Python 2'; then \
83 rm $(STAGING_DIR_HOST
)/bin
/python
; \
87 $$(eval
$$(call Require
,python2-cleanup
))
90 define QuoteHostCommand
91 '$(subst ','"'"',$(strip $(1)))'
97 define TestHostCommand
99 ($(3)) >/dev/null 2>/dev/null
102 $$(eval $$(call Require,$(1),$(2)))
108 define SetupHostCommand
110 [ -f "$(STAGING_DIR_HOST
)/bin
/$(strip $(1))" ] && exit 0; \
111 for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
112 $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
113 $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
114 $(call QuoteHostCommand,$(9)) $(call QuoteHostCommand,$(10)) \
115 $(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
116 if [ -n "$$$$$$$$cmd" ]; then \
117 bin="$$$$$$$$(PATH
="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
118 command
-v
"$$$$$$$${cmd%% *}")"; \
119 if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
120 mkdir -p "$(STAGING_DIR_HOST
)/bin
"; \
121 ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST
)/bin
/$(strip $(1))"; \
129 $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command)))