clean up and really fix bogus build_ directory
[openwrt.git] / include / prereq-build.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 include $(TOPDIR)/rules.mk
9 TMP_DIR:=$(TOPDIR)/tmp
10 include $(INCLUDE_DIR)/prereq.mk
11
12 define Require/non-root
13         [ "$$(shell whoami)" != "root" ]
14 endef
15 $(eval $(call Require,non-root, \
16         Please do not compile as root. \
17 ))
18
19 # Required for the toolchain
20 define Require/working-make
21         echo 'all: test' > $(TMP_DIR)/check.mk
22         echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
23         echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
24         echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
25         $(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
26 endef
27
28 $(eval $(call Require,working-make, \
29         Please install GNU make v3.81 or later. (This version has bugs) \
30 ))
31
32 define Require/working-gcc
33         echo 'int main(int argc, char **argv) { return 0; }' | \
34                 gcc -x c -o $(TMP_DIR)/a.out -
35 endef
36
37 $(eval $(call Require,working-gcc, \
38         Please install the GNU C Compiler (gcc). \
39 ))
40
41 define Require/working-g++
42         echo 'int main(int argc, char **argv) { return 0; }' | \
43                 g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
44 endef
45
46 $(eval $(call Require,working-g++, \
47         Please install the GNU C++ Compiler (g++). \
48 ))
49
50 define Require/ncurses
51         echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
52                 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
53 endef
54
55 $(eval $(call Require,ncurses, \
56         Please install ncurses. (Missing libncurses.so or ncurses.h) \
57 ))
58
59
60 define Require/zlib
61         echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
62                 gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
63 endef
64
65 $(eval $(call Require,zlib, \
66         Please install zlib. (Missing libz.so or zlib.h) \
67 ))
68
69
70 $(eval $(call RequireCommand,bison, \
71         Please install GNU bison. \
72 ))
73
74 $(eval $(call RequireCommand,flex, \
75         Please install flex. \
76 ))
77
78 $(eval $(call RequireCommand,python, \
79         Please install python. \
80 ))
81
82 $(eval $(call RequireCommand,unzip, \
83         Please install unzip. \
84 ))
85
86 $(eval $(call RequireCommand,bzip2, \
87         Please install bzip2. \
88 ))
89
90 $(eval $(call RequireCommand,patch, \
91         Please install patch. \
92 ))
93
94 $(eval $(call RequireCommand,perl, \
95         Please install perl. \
96 ))