enable download target only if PKG_SOURCE_URL is set
[openwrt/svn-archive/archive.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 include $(INCLUDE_DIR)/host.mk
12
13 define Require/non-root
14 [ "$$(shell whoami)" != "root" ]
15 endef
16 $(eval $(call Require,non-root, \
17 Please do not compile as root. \
18 ))
19
20 # Required for the toolchain
21 define Require/working-make
22 echo 'all: test' > $(TMP_DIR)/check.mk
23 echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
24 echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
25 echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
26 $(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
27 endef
28
29 $(eval $(call Require,working-make, \
30 Please install GNU make v3.81 or later. (This version has bugs) \
31 ))
32
33 define Require/case-sensitive-fs
34 rm -f $(TMP_DIR)/test.*
35 touch $(TMP_DIR)/test.fs
36 [ \! -f $(TMP_DIR)/test.FS ]
37 endef
38
39 $(eval $(call Require,case-sensitive-fs, \
40 OpenWrt can only be built on a case-sensitive filesystem \
41 ))
42
43 define Require/working-gcc
44 echo 'int main(int argc, char **argv) { return 0; }' | \
45 gcc -x c -o $(TMP_DIR)/a.out -
46 endef
47
48 $(eval $(call Require,working-gcc, \
49 Please install the GNU C Compiler (gcc). \
50 ))
51
52 define Require/working-g++
53 echo 'int main(int argc, char **argv) { return 0; }' | \
54 g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
55 endef
56
57 $(eval $(call Require,working-g++, \
58 Please install the GNU C++ Compiler (g++). \
59 ))
60
61 define Require/ncurses
62 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
63 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
64 endef
65
66 $(eval $(call Require,ncurses, \
67 Please install ncurses. (Missing libncurses.so or ncurses.h) \
68 ))
69
70
71 define Require/zlib
72 echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
73 gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
74 endef
75
76 $(eval $(call Require,zlib, \
77 Please install zlib. (Missing libz.so or zlib.h) \
78 ))
79
80
81 $(eval $(call RequireCommand,bison, \
82 Please install GNU bison. \
83 ))
84
85 $(eval $(call RequireCommand,flex, \
86 Please install flex. \
87 ))
88
89 $(eval $(call RequireCommand,python, \
90 Please install python. \
91 ))
92
93 $(eval $(call RequireCommand,unzip, \
94 Please install unzip. \
95 ))
96
97 $(eval $(call RequireCommand,bzip2, \
98 Please install bzip2. \
99 ))
100
101 $(eval $(call RequireCommand,patch, \
102 Please install patch. \
103 ))
104
105 $(eval $(call RequireCommand,perl, \
106 Please install perl. \
107 ))
108
109 $(eval $(call RequireCommand,wget, \
110 Please install wget. \
111 ))
112
113 define Require/gnutar
114 $(TAR) --version 2>&1 | grep GNU > /dev/null
115 endef
116
117 $(eval $(call Require,gnutar, \
118 Please install GNU tar. \
119 ))