build: prevent spurious host-build re-builds by touching .built after the install...
[openwrt/svn-archive/archive.git] / include / prereq-build.mk
1 #
2 # Copyright (C) 2006-2012 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 include $(INCLUDE_DIR)/prereq.mk
10 include $(INCLUDE_DIR)/host.mk
11 include $(INCLUDE_DIR)/host-build.mk
12
13 PKG_NAME:=Build dependency
14
15 define Require/non-root
16 [ "$$(shell whoami)" != "root" ]
17 endef
18 $(eval $(call Require,non-root, \
19 Please do not compile as root. \
20 ))
21
22 # Required for the toolchain
23 define Require/working-make
24 $(MAKE) -v | awk '($$$$1 == "GNU") && ($$$$2 == "Make") && ($$$$3 >= "3.81") { print "ok" }' | grep ok > /dev/null
25 endef
26
27 $(eval $(call Require,working-make, \
28 Please install GNU make v3.81 or later. (This version has bugs) \
29 ))
30
31 define Require/case-sensitive-fs
32 rm -f $(TMP_DIR)/test.*
33 touch $(TMP_DIR)/test.fs
34 [ \! -f $(TMP_DIR)/test.FS ]
35 endef
36
37 $(eval $(call Require,case-sensitive-fs, \
38 OpenWrt can only be built on a case-sensitive filesystem \
39 ))
40
41 define Require/getopt
42 gnugetopt --help 2>&1 | grep long >/dev/null || \
43 /usr/local/bin/getopt --help 2>&1 | grep long >/dev/null || \
44 getopt --help 2>&1 | grep long >/dev/null
45 endef
46 $(eval $(call Require,getopt, \
47 Please install GNU getopt \
48 ))
49
50 define Require/fileutils
51 gcp --help || cp --help
52 endef
53 $(eval $(call Require,fileutils, \
54 Please install GNU fileutils \
55 ))
56
57 define Require/working-gcc
58 echo 'int main(int argc, char **argv) { return 0; }' | \
59 gcc -x c -o $(TMP_DIR)/a.out -
60 endef
61
62 $(eval $(call Require,working-gcc, \
63 Please install the GNU C Compiler (gcc). \
64 ))
65
66 define Require/working-g++
67 echo 'int main(int argc, char **argv) { return 0; }' | \
68 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
69 $(TMP_DIR)/a.out
70 endef
71
72 $(eval $(call Require,working-g++, \
73 Please install the GNU C++ Compiler (g++). \
74 ))
75
76 ifneq ($(HOST_STATIC_LINKING),)
77 define Require/working-gcc-static
78 echo 'int main(int argc, char **argv) { return 0; }' | \
79 gcc -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out -
80 endef
81
82 $(eval $(call Require,working-gcc-static, \
83 Please install the static libc development package (glibc-static on CentOS/Fedora/RHEL). \
84 ))
85
86 define Require/working-g++-static
87 echo 'int main(int argc, char **argv) { return 0; }' | \
88 g++ -x c++ $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lstdc++ && \
89 $(TMP_DIR)/a.out
90 endef
91
92 $(eval $(call Require,working-g++-static, \
93 Please install the static libstdc++ development package (libstdc++-static on CentOS/Fedora/RHEL). \
94 ))
95 endif
96
97 define Require/ncurses
98 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
99 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses
100 endef
101
102 $(eval $(call Require,ncurses, \
103 Please install ncurses. (Missing libncurses.so or ncurses.h) \
104 ))
105
106
107 define Require/zlib
108 echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
109 gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - -lz
110 endef
111
112 $(eval $(call Require,zlib, \
113 Please install zlib. (Missing libz.so or zlib.h) \
114 ))
115
116 ifneq ($(HOST_STATIC_LINKING),)
117 define Require/zlib-static
118 echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
119 gcc -include zlib.h -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lz
120 endef
121
122 $(eval $(call Require,zlib-static, \
123 Please install a static zlib. (zlib-static on CentOS/Fedora/RHEL). \
124 ))
125 endif
126
127 $(eval $(call RequireCommand,gawk, \
128 Please install GNU awk. \
129 ))
130
131 $(eval $(call RequireCommand,unzip, \
132 Please install unzip. \
133 ))
134
135 $(eval $(call RequireCommand,bzip2, \
136 Please install bzip2. \
137 ))
138
139 $(eval $(call RequireCommand,perl, \
140 Please install perl. \
141 ))
142
143 $(eval $(call RequireCommand,$(PYTHON), \
144 Please install python. \
145 ))
146
147 $(eval $(call RequireCommand,wget, \
148 Please install wget. \
149 ))
150
151 define Require/git
152 git --version | awk '($$$$1 == "git") && ($$$$2 == "version") && ($$$$3 >= "1.6.5") { print "ok" }' | grep ok > /dev/null
153 endef
154
155 $(eval $(call Require,git, \
156 Please install git (git-core) v1.6.5 or later. \
157 ))
158
159 define Require/gnutar
160 $(TAR) --version 2>&1 | grep GNU > /dev/null
161 endef
162
163 $(eval $(call Require,gnutar, \
164 Please install GNU tar. \
165 ))
166
167 $(eval $(call RequireCommand,svn, \
168 Please install the subversion client. \
169 ))
170
171 define Require/libssl
172 echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \
173 gcc -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl
174 endef
175
176 $(eval $(call Require,libssl, \
177 Please install the openssl library (with development headers) \
178 ))
179
180 $(eval $(call RequireCommand,openssl, \
181 Please install openssl. \
182 ))
183
184 define Require/gnu-find
185 $(FIND) --version 2>/dev/null
186 endef
187
188 $(eval $(call Require,gnu-find, \
189 Please install GNU find \
190 ))
191
192 define Require/getopt-extended
193 getopt --long - - >/dev/null
194 endef
195
196 $(eval $(call Require,getopt-extended, \
197 Please install an extended getopt version that supports --long \
198 ))
199
200 $(eval $(call RequireCommand,file, \
201 Please install the 'file' package. \
202 ))