add prereq check to prevent people from building openwrt as root
[openwrt.git] / include / prereq.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 $(TMP_DIR):
9 mkdir -p $@
10
11 prereq:
12 if [ -f $(TMP_DIR)/.prereq-error ]; then \
13 echo; \
14 cat $(TMP_DIR)/.prereq-error; \
15 echo; \
16 rm -rf $(TMP_DIR); \
17 false; \
18 fi
19 rm -rf $(TMP_DIR)
20 mkdir -p $(TMP_DIR)
21
22 .SILENT: $(TMP_DIR) prereq
23
24 define Require
25 ifeq ($$(CHECK_$(1)),)
26 prereq: prereq-$(1)
27
28 prereq-$(1): $(TMP_DIR) FORCE
29 echo -n "Checking '$(1)'... "
30 if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
31 echo 'ok.'; \
32 else \
33 echo 'failed.'; \
34 echo -e "$(strip $(2))" >> $(TMP_DIR)/.prereq-error; \
35 fi
36
37 check-$(1): FORCE
38 $(call Require/$(1))
39 CHECK_$(1):=1
40
41 .SILENT: prereq-$(1) check-$(1)
42 endif
43 endef
44
45
46 define RequireCommand
47 define Require/$(1)
48 which $(1)
49 endef
50
51 $$(eval $$(call Require,$(1),$(2)))
52 endef
53
This page took 0.043395 seconds and 5 git commands to generate.