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