uclient: update to Git HEAD (2024-04-19)
[openwrt/openwrt.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 $(eval $(call TestHostCommand,true, \
12 Please install GNU 'coreutils', \
13 $(TRUE)))
14
15 $(eval $(call TestHostCommand,false, \
16 Please install GNU 'coreutils', \
17 $(FALSE); [ $$$$$$$$? = 1 ] && $(TRUE)))
18
19 # Required for the toolchain
20 $(eval $(call TestHostCommand,working-make, \
21 Please install GNU make v4.1 or later., \
22 $(MAKE) -v | grep -E 'Make (4\.[1-9]|[5-9]\.)'))
23
24 $(eval $(call TestHostCommand,case-sensitive-fs, \
25 OpenWrt can only be built on a case-sensitive filesystem, \
26 rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
27 test ! -f $(TMP_DIR)/test.FS))
28
29 $(eval $(call TestHostCommand,proper-umask, \
30 Please build with umask 022 - other values produce broken packages, \
31 umask | grep -xE 0?0[012][012]))
32
33 ifndef IB
34 $(eval $(call SetupHostCommand,gcc, \
35 Please install the GNU C Compiler (gcc) 6 or later, \
36 $(CC) -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
37 gcc -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
38 gcc --version | grep -E 'Apple.(LLVM|clang)' ))
39
40 $(eval $(call TestHostCommand,working-gcc, \
41 Please reinstall the GNU C Compiler (6 or later) - \
42 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++) 6 or later, \
48 $(CXX) -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
49 g++ -dumpversion | grep -E '^([6-9]\.?|1[0-9]\.?)', \
50 g++ --version | grep -E 'Apple.(LLVM|clang)' ))
51
52 $(eval $(call TestHostCommand,working-g++, \
53 Please reinstall the GNU C++ Compiler (6 or later) - \
54 it appears to be broken, \
55 echo 'int main(int argc, char **argv) { return 0; }' | \
56 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
57 $(TMP_DIR)/a.out))
58
59 $(eval $(call RequireCHeader,ncurses.h, \
60 Please install ncurses. (Missing libncurses.so or ncurses.h), \
61 initscr(), -lncurses))
62
63 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
64 git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule, \
65 git submodule --help | grep -- --recursive))
66
67 $(eval $(call SetupHostCommand,rsync,Please install 'rsync', \
68 rsync --version </dev/null))
69 endif # IB
70
71 ifeq ($(HOST_OS),Linux)
72 zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
73 else
74 zlib_link_flags := -lz
75 endif
76
77 $(eval $(call TestHostCommand,perl-data-dumper, \
78 Please install the Perl Data::Dumper module, \
79 perl -MData::Dumper -e 1))
80
81 $(eval $(call TestHostCommand,perl-findbin, \
82 Please install the Perl FindBin module, \
83 perl -MFindBin -e 1))
84
85 $(eval $(call TestHostCommand,perl-file-copy, \
86 Please install the Perl File::Copy module, \
87 perl -MFile::Copy -e 1))
88
89 $(eval $(call TestHostCommand,perl-file-compare, \
90 Please install the Perl File::Compare module, \
91 perl -MFile::Compare -e 1))
92
93 $(eval $(call TestHostCommand,perl-thread-queue, \
94 Please install the Perl Thread::Queue module, \
95 perl -MThread::Queue -e 1))
96
97 $(eval $(call TestHostCommand,perl-ipc-cmd, \
98 Please install the Perl IPC:Cmd module, \
99 perl -MIPC::Cmd -e 1))
100
101 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
102 gtar --version 2>&1 | grep GNU, \
103 gnutar --version 2>&1 | grep GNU, \
104 tar --version 2>&1 | grep GNU))
105
106 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
107 gfind --version 2>&1 | grep GNU, \
108 find --version 2>&1 | grep GNU))
109
110 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
111 bash --version 2>&1 | grep GNU))
112
113 $(eval $(call SetupHostCommand,xargs, \
114 Please install 'xargs' that supports '-r/--no-run-if-empty', \
115 gxargs -r --version, \
116 xargs -r --version))
117
118 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
119 gpatch --version 2>&1 | grep 'Free Software Foundation', \
120 patch --version 2>&1 | grep 'Free Software Foundation'))
121
122 $(eval $(call SetupHostCommand,diff,Please install GNU diffutils, \
123 gdiff --version 2>&1 | grep GNU, \
124 diff --version 2>&1 | grep GNU))
125
126 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
127 gcp --help 2>&1 | grep 'Copy SOURCE', \
128 cp --help 2>&1 | grep 'Copy SOURCE'))
129
130 $(eval $(call SetupHostCommand,seq,Please install seq, \
131 gseq --version, \
132 seq --version 2>&1 | grep seq))
133
134 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
135 gawk --version 2>&1 | grep GNU, \
136 awk --version 2>&1 | grep GNU))
137
138 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
139 ggrep --version 2>&1 | grep GNU, \
140 grep --version 2>&1 | grep GNU))
141
142 $(eval $(call SetupHostCommand,egrep,Please install GNU 'grep', \
143 gegrep --version 2>&1 | grep GNU, \
144 egrep --version 2>&1 | grep GNU))
145
146 $(eval $(call SetupHostCommand,getopt, \
147 Please install an extended getopt version that supports --long, \
148 gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
149 getopt -o t --long test -- --test | grep '^ *--test *--', \
150 /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
151 /opt/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
152
153 $(eval $(call SetupHostCommand,realpath,Please install a 'realpath' utility, \
154 grealpath /, \
155 realpath /))
156
157 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
158 gnustat -c%s $(TOPDIR)/Makefile, \
159 gstat -c%s $(TOPDIR)/Makefile, \
160 stat -c%s $(TOPDIR)/Makefile))
161
162 $(eval $(call SetupHostCommand,gzip,Please install 'gzip', \
163 gzip --version </dev/null))
164
165 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
166 unzip 2>&1 | grep zipfile, \
167 unzip))
168
169 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
170 bzip2 --version </dev/null))
171
172 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
173 wget --version | grep GNU))
174
175 $(eval $(call SetupHostCommand,install,Please install GNU 'install', \
176 install --version | grep GNU, \
177 ginstall --version | grep GNU))
178
179 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
180 perl --version | grep "perl.*v5"))
181
182 $(eval $(call SetupHostCommand,python,Please install Python >= 3.7, \
183 python3.11 -V 2>&1 | grep 'Python 3', \
184 python3.10 -V 2>&1 | grep 'Python 3', \
185 python3.9 -V 2>&1 | grep 'Python 3', \
186 python3.8 -V 2>&1 | grep 'Python 3', \
187 python3.7 -V 2>&1 | grep 'Python 3', \
188 python3 -V 2>&1 | grep -E 'Python 3\.([7-9]|[0-9][0-9])\.?'))
189
190 $(eval $(call SetupHostCommand,python3,Please install Python >= 3.7, \
191 python3.11 -V 2>&1 | grep 'Python 3', \
192 python3.10 -V 2>&1 | grep 'Python 3', \
193 python3.9 -V 2>&1 | grep 'Python 3', \
194 python3.8 -V 2>&1 | grep 'Python 3', \
195 python3.7 -V 2>&1 | grep 'Python 3', \
196 python3 -V 2>&1 | grep -E 'Python 3\.([7-9]|[0-9][0-9])\.?'))
197
198 $(eval $(call TestHostCommand,python3-distutils, \
199 Please install the Python3 distutils module, \
200 $(STAGING_DIR_HOST)/bin/python3 -c 'from distutils import util'))
201
202 $(eval $(call TestHostCommand,python3-stdlib, \
203 Please install the Python3 stdlib module, \
204 $(STAGING_DIR_HOST)/bin/python3 -c 'import ntpath'))
205
206 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
207 file --version 2>&1 | grep file))
208
209 $(eval $(call SetupHostCommand,which,Please install 'which', \
210 /usr/bin/which which, \
211 /bin/which which, \
212 which which))
213
214 ifeq ($(HOST_OS),Linux)
215 $(eval $(call RequireCHeader,argp.h, \
216 Missing argp.h Please install the argp-standalone package if musl libc))
217
218 $(eval $(call RequireCHeader,fts.h, \
219 Missing fts.h Please install the musl-fts-dev package if musl libc))
220
221 $(eval $(call RequireCHeader,obstack.h, \
222 Missing obstack.h Please install the musl-obstack-dev package if musl libc))
223
224 $(eval $(call RequireCHeader,libintl.h, \
225 Missing libintl.h Please install the musl-libintl package if musl libc))
226 endif
227
228 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
229 mkdir -p $(dir $@)
230 $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
231
232 $(STAGING_DIR_HOST)/bin/xxd: $(SCRIPT_DIR)/xxdi.pl
233 $(LN) $< $@
234
235 prereq: $(STAGING_DIR_HOST)/bin/mkhash $(STAGING_DIR_HOST)/bin/xxd
236
237 # Install ldconfig stub
238 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
239 $(LN) $(firstword $(wildcard /bin/true /usr/bin/true)) $(STAGING_DIR_HOST)/bin/ldconfig))