include: prereq-build.mk: use TestHostCommand and SetupHostCommand
[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
16 # Required for the toolchain
17 $(eval $(call TestHostCommand,working-make, \
18 Please install GNU make v3.81 or later. (This version has bugs), \
19 $(MAKE) -v | grep -E 'Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)'))
20
21 $(eval $(call TestHostCommand,case-sensitive-fs, \
22 OpenWrt can only be built on a case-sensitive filesystem, \
23 rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
24 test ! -f $(TMP_DIR)/test.FS))
25
26 $(eval $(call SetupHostCommand,gcc, \
27 Please install the GNU C Compiler (gcc), \
28 $(CC) --version | grep gcc, \
29 gcc --version | grep gcc, \
30 gcc49 --version | grep gcc, \
31 gcc48 --version | grep gcc, \
32 gcc47 --version | grep gcc, \
33 gcc46 --version | grep gcc))
34
35 $(eval $(call TestHostCommand,working-gcc, \
36 Please reinstall the GNU C Compiler - it appears to be broken, \
37 echo 'int main(int argc, char **argv) { return 0; }' | \
38 gcc -x c -o $(TMP_DIR)/a.out -))
39
40 $(eval $(call SetupHostCommand,g++, \
41 Please install the GNU C++ Compiler (g++), \
42 $(CXX) --version | grep g++, \
43 g++ --version | grep g++, \
44 g++49 --version | grep g++, \
45 g++48 --version | grep g++, \
46 g++47 --version | grep g++, \
47 g++46 --version | grep g++))
48
49 $(eval $(call TestHostCommand,working-g++, \
50 Please reinstall the GNU C++ Compiler - it appears to be broken, \
51 echo 'int main(int argc, char **argv) { return 0; }' | \
52 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
53 $(TMP_DIR)/a.out))
54
55 $(eval $(call TestHostCommand,ncurses, \
56 Please install ncurses. (Missing libncurses.so or ncurses.h), \
57 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
58 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
59
60 $(eval $(call TestHostCommand,zlib, \
61 Please install zlib. (Missing libz.so or zlib.h), \
62 echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
63 gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - -lz))
64
65 $(eval $(call TestHostCommand,libssl, \
66 Please install the openssl library (with development headers), \
67 echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \
68 gcc -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl))
69
70 ifneq ($(HOST_STATIC_LINKING),)
71 $(eval $(call TestHostCommand,working-gcc-static, \
72 Please install the static libc development package (glibc-static on CentOS/Fedora/RHEL)., \
73 echo 'int main(int argc, char **argv) { return 0; }' | \
74 gcc -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out -))
75
76 $(eval $(call TestHostCommand,working-g++-static, \
77 Please install the static libstdc++ development package (libstdc++-static on CentOS/Fedora/RHEL)., \
78 echo 'int main(int argc, char **argv) { return 0; }' | \
79 g++ -x c++ $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lstdc++ && \
80 $(TMP_DIR)/a.out))
81
82 $(eval $(call TestHostCommand,zlib-static, \
83 Please install a static zlib. (zlib-static on CentOS/Fedora/RHEL)., \
84 echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
85 gcc -include zlib.h -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lz))
86 endif
87
88
89 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
90 gtar --version 2>&1 | grep GNU, \
91 gnutar --version 2>&1 | grep GNU, \
92 tar --version 2>&1 | grep GNU))
93
94 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
95 gfind --version 2>&1 | grep GNU, \
96 find --version 2>&1 | grep GNU))
97
98 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
99 bash --version 2>&1 | grep GNU))
100
101 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
102 gpatch --version 2>&1 | grep 'Free Software Foundation', \
103 patch --version 2>&1 | grep 'Free Software Foundation'))
104
105 $(eval $(call SetupHostCommand,diff,Please install diffutils, \
106 gdiff --version 2>&1 | grep diff, \
107 diff --version 2>&1 | grep diff))
108
109 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
110 gcp --help, \
111 cp --help))
112
113 $(eval $(call SetupHostCommand,seq,, \
114 gseq --version, \
115 seq --version))
116
117 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
118 gawk --version 2>&1 | grep GNU, \
119 awk --version 2>&1 | grep GNU))
120
121 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
122 ggrep --version 2>&1 | grep GNU, \
123 grep --version 2>&1 | grep GNU))
124
125 $(eval $(call SetupHostCommand,getopt, \
126 Please install an extended getopt version that supports --long, \
127 gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
128 /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
129 getopt -o t --long test -- --test | grep '^ *--test *--'))
130
131 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
132 gnustat -c%s $(TMP_DIR)/.host.mk, \
133 gstat -c%s $(TMP_DIR)/.host.mk, \
134 stat -c%s $(TMP_DIR)/.host.mk))
135
136 $(eval $(call SetupHostCommand,md5sum,, \
137 gmd5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e, \
138 md5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e, \
139 $(SCRIPT_DIR)/md5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e))
140
141 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
142 unzip 2>&1 | grep zipfile, \
143 unzip))
144
145 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
146 bzip2 --version </dev/null))
147
148 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
149 wget --version | grep GNU))
150
151 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
152 perl --version | grep "perl 5"))
153
154 $(eval $(call SetupHostCommand,python,Please install Python 2.x, \
155 python2.7 -V 2>&1 | grep Python, \
156 python2 -V 2>&1 | grep Python, \
157 python -V 2>&1 | grep Python))
158
159 $(eval $(call SetupHostCommand,svn,Please install the Subversion client, \
160 svn --version | grep Subversion))
161
162 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.6.5, \
163 git clone --help | grep -- --recursive))
164
165 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
166 file --version | grep file))
167
168 $(eval $(call SetupHostCommand,openssl,Please install the 'openssl' utility, \
169 openssl version | grep OpenSSL))
170
171
172 # Install ldconfig stub
173 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
174 touch $(STAGING_DIR_HOST)/bin/ldconfig && \
175 chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))