build: add support for python3.11 and higher
[openwrt/staging/hauke.git] / include / prereq-build.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2006-2020 OpenWrt.org
4
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/prereq.mk
7
8 SHELL:=sh
9 PKG_NAME:=Build dependency
10
11
12 # Required for the toolchain
13 $(eval $(call TestHostCommand,working-make, \
14 Please install GNU make v4.1 or later., \
15 $(MAKE) -v | grep -E 'Make (4\.[1-9]|[5-9]\.)'))
16
17 $(eval $(call TestHostCommand,case-sensitive-fs, \
18 OpenWrt can only be built on a case-sensitive filesystem, \
19 rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
20 test ! -f $(TMP_DIR)/test.FS))
21
22 $(eval $(call TestHostCommand,proper-umask, \
23 Please build with umask 022 - other values produce broken packages, \
24 umask | grep -xE 0?0[012][012]))
25
26 ifndef IB
27 $(eval $(call SetupHostCommand,gcc, \
28 Please install the GNU C Compiler (gcc) 6 or later, \
29 $(CC) -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
30 gcc -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
31 gcc --version | grep -E 'Apple.(LLVM|clang)' ))
32
33 $(eval $(call TestHostCommand,working-gcc, \
34 Please reinstall the GNU C Compiler (6 or later) - \
35 it appears to be broken, \
36 echo 'int main(int argc, char **argv) { return 0; }' | \
37 gcc -x c -o $(TMP_DIR)/a.out -))
38
39 $(eval $(call SetupHostCommand,g++, \
40 Please install the GNU C++ Compiler (g++) 6 or later, \
41 $(CXX) -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
42 g++ -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
43 g++ --version | grep -E 'Apple.(LLVM|clang)' ))
44
45 $(eval $(call TestHostCommand,working-g++, \
46 Please reinstall the GNU C++ Compiler (6 or later) - \
47 it appears to be broken, \
48 echo 'int main(int argc, char **argv) { return 0; }' | \
49 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
50 $(TMP_DIR)/a.out))
51
52 $(eval $(call TestHostCommand,ncurses, \
53 Please install ncurses. (Missing libncurses.so or ncurses.h), \
54 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
55 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
56
57 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
58 git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule, \
59 git submodule --help | grep -- --recursive))
60
61 $(eval $(call SetupHostCommand,rsync,Please install 'rsync', \
62 rsync --version </dev/null))
63 endif # IB
64
65 ifeq ($(HOST_OS),Linux)
66 zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
67 else
68 zlib_link_flags := -lz
69 endif
70
71 $(eval $(call TestHostCommand,perl-data-dumper, \
72 Please install the Perl Data::Dumper module, \
73 perl -MData::Dumper -e 1))
74
75 $(eval $(call TestHostCommand,perl-findbin, \
76 Please install the Perl FindBin module, \
77 perl -MFindBin -e 1))
78
79 $(eval $(call TestHostCommand,perl-file-copy, \
80 Please install the Perl File::Copy module, \
81 perl -MFile::Copy -e 1))
82
83 $(eval $(call TestHostCommand,perl-file-compare, \
84 Please install the Perl File::Compare module, \
85 perl -MFile::Compare -e 1))
86
87 $(eval $(call TestHostCommand,perl-thread-queue, \
88 Please install the Perl Thread::Queue module, \
89 perl -MThread::Queue -e 1))
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,xargs, \
104 Please install 'xargs' that supports '-r/--no-run-if-empty', \
105 gxargs -r --version, \
106 xargs -r --version))
107
108 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
109 gpatch --version 2>&1 | grep 'Free Software Foundation', \
110 patch --version 2>&1 | grep 'Free Software Foundation'))
111
112 $(eval $(call SetupHostCommand,diff,Please install GNU diffutils, \
113 gdiff --version 2>&1 | grep GNU, \
114 diff --version 2>&1 | grep GNU))
115
116 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
117 gcp --help 2>&1 | grep 'Copy SOURCE', \
118 cp --help 2>&1 | grep 'Copy SOURCE'))
119
120 $(eval $(call SetupHostCommand,seq,Please install seq, \
121 gseq --version, \
122 seq --version 2>&1 | grep seq))
123
124 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
125 gawk --version 2>&1 | grep GNU, \
126 awk --version 2>&1 | grep GNU))
127
128 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
129 ggrep --version 2>&1 | grep GNU, \
130 grep --version 2>&1 | grep GNU))
131
132 $(eval $(call SetupHostCommand,egrep,Please install GNU 'grep', \
133 gegrep --version 2>&1 | grep GNU, \
134 egrep --version 2>&1 | grep GNU))
135
136 $(eval $(call SetupHostCommand,getopt, \
137 Please install an extended getopt version that supports --long, \
138 gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
139 getopt -o t --long test -- --test | grep '^ *--test *--', \
140 /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
141 /opt/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
142
143 $(eval $(call SetupHostCommand,realpath,Please install a 'realpath' utility, \
144 grealpath /, \
145 realpath /))
146
147 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
148 gnustat -c%s $(TOPDIR)/Makefile, \
149 gstat -c%s $(TOPDIR)/Makefile, \
150 stat -c%s $(TOPDIR)/Makefile))
151
152 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
153 unzip 2>&1 | grep zipfile, \
154 unzip))
155
156 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
157 bzip2 --version </dev/null))
158
159 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
160 wget --version | grep GNU))
161
162 $(eval $(call SetupHostCommand,install,Please install GNU 'install', \
163 install --version | grep GNU, \
164 ginstall --version | grep GNU))
165
166 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
167 perl --version | grep "perl.*v5"))
168
169 $(eval $(call CleanupPython2))
170
171 $(eval $(call SetupHostCommand,python,Please install Python >= 3.6, \
172 python3.11 -V 2>&1 | grep 'Python 3', \
173 python3.10 -V 2>&1 | grep 'Python 3', \
174 python3.9 -V 2>&1 | grep 'Python 3', \
175 python3.8 -V 2>&1 | grep 'Python 3', \
176 python3.7 -V 2>&1 | grep 'Python 3', \
177 python3.6 -V 2>&1 | grep 'Python 3', \
178 python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?'))
179
180 $(eval $(call SetupHostCommand,python3,Please install Python >= 3.6, \
181 python3.11 -V 2>&1 | grep 'Python 3', \
182 python3.10 -V 2>&1 | grep 'Python 3', \
183 python3.9 -V 2>&1 | grep 'Python 3', \
184 python3.8 -V 2>&1 | grep 'Python 3', \
185 python3.7 -V 2>&1 | grep 'Python 3', \
186 python3.6 -V 2>&1 | grep 'Python 3', \
187 python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?'))
188
189 $(eval $(call TestHostCommand,python3-distutils, \
190 Please install the Python3 distutils module, \
191 $(STAGING_DIR_HOST)/bin/python3 -c 'import distutils'))
192
193 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
194 file --version 2>&1 | grep file))
195
196 $(eval $(call SetupHostCommand,which,Please install 'which', \
197 /usr/bin/which which, \
198 /bin/which which, \
199 which which))
200
201 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
202 mkdir -p $(dir $@)
203 $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
204
205 prereq: $(STAGING_DIR_HOST)/bin/mkhash
206
207 # Install ldconfig stub
208 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
209 $(LN) /bin/true $(STAGING_DIR_HOST)/bin/ldconfig))