mediatek: fix IPv4-only corner case and commit in 99-net-ps
[oweals/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
11 SHELL:=sh
12 PKG_NAME:=Build dependency
13
14
15 # Required for the toolchain
16 $(eval $(call TestHostCommand,working-make, \
17         Please install GNU make v3.82 or later. (This version has bugs), \
18         $(MAKE) -v | grep -E 'Make (3\.8[2-9]|3\.9[0-9]|[4-9]\.)'))
19
20 $(eval $(call TestHostCommand,case-sensitive-fs, \
21         OpenWrt can only be built on a case-sensitive filesystem, \
22         rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
23                 test ! -f $(TMP_DIR)/test.FS))
24
25 $(eval $(call TestHostCommand,proper-umask, \
26         Please build with umask 022 - other values produce broken packages, \
27         umask | grep -xE 0?0[012][012]))
28
29 $(eval $(call SetupHostCommand,gcc, \
30         Please install the GNU C Compiler (gcc) 4.8 or later, \
31         $(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
32         gcc -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
33         gcc --version | grep -E 'Apple.(LLVM|clang)' ))
34
35 $(eval $(call TestHostCommand,working-gcc, \
36         \nPlease reinstall the GNU C Compiler (4.8 or later) - \
37         it appears to be broken, \
38         echo 'int main(int argc, char **argv) { return 0; }' | \
39                 gcc -x c -o $(TMP_DIR)/a.out -))
40
41 $(eval $(call SetupHostCommand,g++, \
42         Please install the GNU C++ Compiler (g++) 4.8 or later, \
43         $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
44         g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
45         g++ --version | grep -E 'Apple.(LLVM|clang)' ))
46
47 $(eval $(call TestHostCommand,working-g++, \
48         \nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
49         it appears to be broken, \
50         echo 'int main(int argc, char **argv) { return 0; }' | \
51                 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
52                 $(TMP_DIR)/a.out))
53
54 ifndef IB
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 endif
60
61 ifeq ($(HOST_OS),Linux)
62   zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
63 else
64   zlib_link_flags := -lz
65 endif
66
67 $(eval $(call TestHostCommand,perl-data-dumper, \
68         Please install the Perl Data::Dumper module, \
69         perl -MData::Dumper -e 1))
70
71 $(eval $(call TestHostCommand,perl-thread-queue, \
72         Please install the Perl Thread::Queue module, \
73         perl -MThread::Queue -e 1))
74
75
76 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
77         gtar --version 2>&1 | grep GNU, \
78         gnutar --version 2>&1 | grep GNU, \
79         tar --version 2>&1 | grep GNU))
80
81 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
82         gfind --version 2>&1 | grep GNU, \
83         find --version 2>&1 | grep GNU))
84
85 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
86         bash --version 2>&1 | grep GNU))
87
88 $(eval $(call SetupHostCommand,xargs, \
89         Please install 'xargs' that supports '-r/--no-run-if-empty', \
90         gxargs -r --version, \
91         xargs -r --version))
92
93 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
94         gpatch --version 2>&1 | grep 'Free Software Foundation', \
95         patch --version 2>&1 | grep 'Free Software Foundation'))
96
97 $(eval $(call SetupHostCommand,diff,Please install diffutils, \
98         gdiff --version 2>&1 | grep diff, \
99         diff --version 2>&1 | grep diff))
100
101 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
102         gcp --help 2>&1 | grep 'Copy SOURCE', \
103         cp --help 2>&1 | grep 'Copy SOURCE'))
104
105 $(eval $(call SetupHostCommand,seq,Please install seq, \
106         gseq --version, \
107         seq --version 2>&1 | grep seq))
108
109 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
110         gawk --version 2>&1 | grep GNU, \
111         awk --version 2>&1 | grep GNU))
112
113 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
114         ggrep --version 2>&1 | grep GNU, \
115         grep --version 2>&1 | grep GNU))
116
117 $(eval $(call SetupHostCommand,getopt, \
118         Please install an extended getopt version that supports --long, \
119         gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
120         getopt -o t --long test -- --test | grep '^ *--test *--'))
121
122 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
123         gnustat -c%s $(TOPDIR)/Makefile, \
124         gstat -c%s $(TOPDIR)/Makefile, \
125         stat -c%s $(TOPDIR)/Makefile))
126
127 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
128         unzip 2>&1 | grep zipfile, \
129         unzip))
130
131 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
132         bzip2 --version </dev/null))
133
134 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
135         wget --version | grep GNU))
136
137 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
138         perl --version | grep "perl.*v5"))
139
140 $(eval $(call CleanupPython2))
141
142 $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
143         python3.8 -V 2>&1 | grep 'Python 3', \
144         python3.7 -V 2>&1 | grep 'Python 3', \
145         python3.6 -V 2>&1 | grep 'Python 3', \
146         python3.5 -V 2>&1 | grep 'Python 3', \
147         python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
148
149 $(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \
150         python3.8 -V 2>&1 | grep 'Python 3', \
151         python3.7 -V 2>&1 | grep 'Python 3', \
152         python3.6 -V 2>&1 | grep 'Python 3', \
153         python3.5 -V 2>&1 | grep 'Python 3', \
154         python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
155
156 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
157         git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
158
159 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
160         file --version 2>&1 | grep file))
161
162 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
163         mkdir -p $(dir $@)
164         $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
165
166 prereq: $(STAGING_DIR_HOST)/bin/mkhash
167
168 # Install ldconfig stub
169 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
170         touch $(STAGING_DIR_HOST)/bin/ldconfig && \
171         chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))