1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2006-2020 OpenWrt.org
5 include $(TOPDIR
)/rules.mk
6 include $(INCLUDE_DIR
)/prereq.mk
9 PKG_NAME
:=Build dependency
11 $(eval
$(call TestHostCommand
,true
, \
12 Please
install GNU
'coreutils', \
15 $(eval
$(call TestHostCommand
,false
, \
16 Please
install GNU
'coreutils', \
17 $(FALSE
); [ $$$$$$$$?
= 1 ] && $(TRUE
)))
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]\.)'))
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
))
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]))
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)' ))
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
-))
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)' ))
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
++ && \
59 $(eval
$(call RequireCHeader
,ncurses.h
, \
60 Please
install ncurses.
(Missing libncurses.so or ncurses.h
), \
61 initscr
(), -lncurses
))
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
))
67 $(eval
$(call SetupHostCommand
,rsync
,Please
install 'rsync', \
68 rsync
--version
</dev
/null
))
71 ifeq ($(HOST_OS
),Linux
)
72 zlib_link_flags
:= -Wl
,-Bstatic
-lz
-Wl
,-Bdynamic
74 zlib_link_flags
:= -lz
77 $(eval
$(call TestHostCommand
,perl-data-dumper
, \
78 Please
install the Perl Data
::Dumper module
, \
79 perl
-MData
::Dumper
-e
1))
81 $(eval
$(call TestHostCommand
,perl-findbin
, \
82 Please
install the Perl FindBin module
, \
85 $(eval
$(call TestHostCommand
,perl-file-copy
, \
86 Please
install the Perl File
::Copy module
, \
87 perl
-MFile
::Copy
-e
1))
89 $(eval
$(call TestHostCommand
,perl-file-compare
, \
90 Please
install the Perl File
::Compare module
, \
91 perl
-MFile
::Compare
-e
1))
93 $(eval
$(call TestHostCommand
,perl-thread-queue
, \
94 Please
install the Perl Thread
::Queue module
, \
95 perl
-MThread
::Queue
-e
1))
97 $(eval
$(call SetupHostCommand
,tar,Please
install GNU
'tar', \
98 gtar
--version
2>&1 | grep GNU
, \
99 gnutar
--version
2>&1 | grep GNU
, \
100 tar --version
2>&1 | grep GNU
))
102 $(eval
$(call SetupHostCommand
,find
,Please
install GNU
'find', \
103 gfind
--version
2>&1 | grep GNU
, \
104 find
--version
2>&1 | grep GNU
))
106 $(eval
$(call SetupHostCommand
,bash
,Please
install GNU
'bash', \
107 bash
--version
2>&1 | grep GNU
))
109 $(eval
$(call SetupHostCommand
,xargs
, \
110 Please
install 'xargs' that supports
'-r/--no-run-if-empty', \
111 gxargs
-r
--version
, \
114 $(eval
$(call SetupHostCommand
,patch
,Please
install GNU
'patch', \
115 gpatch
--version
2>&1 | grep
'Free Software Foundation', \
116 patch
--version
2>&1 | grep
'Free Software Foundation'))
118 $(eval
$(call SetupHostCommand
,diff
,Please
install GNU diffutils
, \
119 gdiff
--version
2>&1 | grep GNU
, \
120 diff
--version
2>&1 | grep GNU
))
122 $(eval
$(call SetupHostCommand
,cp
,Please
install GNU fileutils
, \
123 gcp
--help
2>&1 | grep
'Copy SOURCE', \
124 cp
--help
2>&1 | grep
'Copy SOURCE'))
126 $(eval
$(call SetupHostCommand
,seq
,Please
install seq
, \
128 seq
--version
2>&1 | grep seq
))
130 $(eval
$(call SetupHostCommand
,awk
,Please
install GNU
'awk', \
131 gawk
--version
2>&1 | grep GNU
, \
132 awk
--version
2>&1 | grep GNU
))
134 $(eval
$(call SetupHostCommand
,grep
,Please
install GNU
'grep', \
135 ggrep
--version
2>&1 | grep GNU
, \
136 grep
--version
2>&1 | grep GNU
))
138 $(eval
$(call SetupHostCommand
,egrep
,Please
install GNU
'grep', \
139 gegrep
--version
2>&1 | grep GNU
, \
140 egrep
--version
2>&1 | grep GNU
))
142 $(eval
$(call SetupHostCommand
,getopt
, \
143 Please
install an extended getopt version that supports
--long
, \
144 gnugetopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
145 getopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
146 /usr
/local
/opt
/gnu-getopt
/bin
/getopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
147 /opt
/local
/bin
/getopt
-o t
--long
test -- --test | grep
'^ *--test *--'))
149 $(eval
$(call SetupHostCommand
,realpath
,Please
install a
'realpath' utility
, \
153 $(eval
$(call SetupHostCommand
,stat
,Cannot find a file stat utility
, \
154 gnustat
-c
%s
$(TOPDIR
)/Makefile
, \
155 gstat
-c
%s
$(TOPDIR
)/Makefile
, \
156 stat
-c
%s
$(TOPDIR
)/Makefile
))
158 $(eval
$(call SetupHostCommand
,gzip
,Please
install 'gzip', \
159 gzip
--version
</dev
/null
))
161 $(eval
$(call SetupHostCommand
,unzip
,Please
install 'unzip', \
162 unzip
2>&1 | grep zipfile
, \
165 $(eval
$(call SetupHostCommand
,bzip2
,Please
install 'bzip2', \
166 bzip2
--version
</dev
/null
))
168 $(eval
$(call SetupHostCommand
,wget
,Please
install GNU
'wget', \
169 wget
--version | grep GNU
))
171 $(eval
$(call SetupHostCommand
,install,Please
install GNU
'install', \
172 install --version | grep GNU
, \
173 ginstall
--version | grep GNU
))
175 $(eval
$(call SetupHostCommand
,perl
,Please
install Perl
5.x
, \
176 perl
--version | grep
"perl.*v5"))
178 $(eval
$(call SetupHostCommand
,python
,Please
install Python
>= 3.7, \
179 python3.11
-V
2>&1 | grep
'Python 3', \
180 python3.10
-V
2>&1 | grep
'Python 3', \
181 python3.9
-V
2>&1 | grep
'Python 3', \
182 python3.8
-V
2>&1 | grep
'Python 3', \
183 python3.7
-V
2>&1 | grep
'Python 3', \
184 python3
-V
2>&1 | grep
-E
'Python 3\.([7-9]|[0-9][0-9])\.?'))
186 $(eval
$(call SetupHostCommand
,python3
,Please
install Python
>= 3.7, \
187 python3.11
-V
2>&1 | grep
'Python 3', \
188 python3.10
-V
2>&1 | grep
'Python 3', \
189 python3.9
-V
2>&1 | grep
'Python 3', \
190 python3.8
-V
2>&1 | grep
'Python 3', \
191 python3.7
-V
2>&1 | grep
'Python 3', \
192 python3
-V
2>&1 | grep
-E
'Python 3\.([7-9]|[0-9][0-9])\.?'))
194 $(eval
$(call TestHostCommand
,python3-distutils
, \
195 Please
install the Python3 distutils module
, \
196 $(STAGING_DIR_HOST
)/bin
/python3
-c
'from distutils import util'))
198 $(eval
$(call TestHostCommand
,python3-stdlib
, \
199 Please
install the Python3 stdlib module
, \
200 $(STAGING_DIR_HOST
)/bin
/python3
-c
'import ntpath'))
202 $(eval
$(call SetupHostCommand
,file
,Please
install the
'file' package
, \
203 file
--version
2>&1 | grep file
))
205 $(eval
$(call SetupHostCommand
,which
,Please
install 'which', \
206 /usr
/bin
/which which
, \
210 ifeq ($(HOST_OS
),Linux
)
211 $(eval
$(call RequireCHeader
,argp.h
, \
212 Missing argp.h Please
install the argp-standalone package if musl libc
))
214 $(eval
$(call RequireCHeader
,fts.h
, \
215 Missing fts.h Please
install the musl-fts-dev package if musl libc
))
217 $(eval
$(call RequireCHeader
,obstack.h
, \
218 Missing obstack.h Please
install the musl-obstack-dev package if musl libc
))
220 $(eval
$(call RequireCHeader
,libintl.h
, \
221 Missing libintl.h Please
install the musl-libintl package if musl libc
))
224 $(STAGING_DIR_HOST
)/bin
/mkhash
: $(SCRIPT_DIR
)/mkhash.c
226 $(CC
) -O2
-I
$(TOPDIR
)/tools
/include -o
$@
$<
228 $(STAGING_DIR_HOST
)/bin
/xxd
: $(SCRIPT_DIR
)/xxdi.pl
231 prereq
: $(STAGING_DIR_HOST
)/bin
/mkhash
$(STAGING_DIR_HOST
)/bin
/xxd
233 # Install ldconfig stub
234 $(eval
$(call TestHostCommand
,ldconfig-stub
,Failed to
install stub
, \
235 $(LN
) $(firstword $(wildcard /bin
/true
/usr
/bin
/true
)) $(STAGING_DIR_HOST
)/bin
/ldconfig
))