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