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
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]\.)'))
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
))
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]))
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)' ))
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
-))
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)' ))
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
++ && \
52 $(eval
$(call RequireCHeader
,ncurses.h
, \
53 Please
install ncurses.
(Missing libncurses.so or ncurses.h
), \
54 initscr
(), -lncurses
))
56 $(eval
$(call SetupHostCommand
,git
,Please
install Git
(git-core
) >= 1.7.12.2, \
57 git
--exec-path | xargs
-I
% -- grep
-q
-- --recursive
%/git-submodule
, \
58 git submodule
--help | grep
-- --recursive
))
60 $(eval
$(call SetupHostCommand
,rsync
,Please
install 'rsync', \
61 rsync
--version
</dev
/null
))
64 ifeq ($(HOST_OS
),Linux
)
65 zlib_link_flags
:= -Wl
,-Bstatic
-lz
-Wl
,-Bdynamic
67 zlib_link_flags
:= -lz
70 $(eval
$(call TestHostCommand
,perl-data-dumper
, \
71 Please
install the Perl Data
::Dumper module
, \
72 perl
-MData
::Dumper
-e
1))
74 $(eval
$(call TestHostCommand
,perl-findbin
, \
75 Please
install the Perl FindBin module
, \
78 $(eval
$(call TestHostCommand
,perl-file-copy
, \
79 Please
install the Perl File
::Copy module
, \
80 perl
-MFile
::Copy
-e
1))
82 $(eval
$(call TestHostCommand
,perl-file-compare
, \
83 Please
install the Perl File
::Compare module
, \
84 perl
-MFile
::Compare
-e
1))
86 $(eval
$(call TestHostCommand
,perl-thread-queue
, \
87 Please
install the Perl Thread
::Queue module
, \
88 perl
-MThread
::Queue
-e
1))
90 $(eval
$(call SetupHostCommand
,tar,Please
install GNU
'tar', \
91 gtar
--version
2>&1 | grep GNU
, \
92 gnutar
--version
2>&1 | grep GNU
, \
93 tar --version
2>&1 | grep GNU
))
95 $(eval
$(call SetupHostCommand
,find
,Please
install GNU
'find', \
96 gfind
--version
2>&1 | grep GNU
, \
97 find
--version
2>&1 | grep GNU
))
99 $(eval
$(call SetupHostCommand
,bash
,Please
install GNU
'bash', \
100 bash
--version
2>&1 | grep GNU
))
102 $(eval
$(call SetupHostCommand
,xargs
, \
103 Please
install 'xargs' that supports
'-r/--no-run-if-empty', \
104 gxargs
-r
--version
, \
107 $(eval
$(call SetupHostCommand
,patch
,Please
install GNU
'patch', \
108 gpatch
--version
2>&1 | grep
'Free Software Foundation', \
109 patch
--version
2>&1 | grep
'Free Software Foundation'))
111 $(eval
$(call SetupHostCommand
,diff
,Please
install GNU diffutils
, \
112 gdiff
--version
2>&1 | grep GNU
, \
113 diff
--version
2>&1 | grep GNU
))
115 $(eval
$(call SetupHostCommand
,cp
,Please
install GNU fileutils
, \
116 gcp
--help
2>&1 | grep
'Copy SOURCE', \
117 cp
--help
2>&1 | grep
'Copy SOURCE'))
119 $(eval
$(call SetupHostCommand
,seq
,Please
install seq
, \
121 seq
--version
2>&1 | grep seq
))
123 $(eval
$(call SetupHostCommand
,awk
,Please
install GNU
'awk', \
124 gawk
--version
2>&1 | grep GNU
, \
125 awk
--version
2>&1 | grep GNU
))
127 $(eval
$(call SetupHostCommand
,grep
,Please
install GNU
'grep', \
128 ggrep
--version
2>&1 | grep GNU
, \
129 grep
--version
2>&1 | grep GNU
))
131 $(eval
$(call SetupHostCommand
,egrep
,Please
install GNU
'grep', \
132 gegrep
--version
2>&1 | grep GNU
, \
133 egrep
--version
2>&1 | grep GNU
))
135 $(eval
$(call SetupHostCommand
,getopt
, \
136 Please
install an extended getopt version that supports
--long
, \
137 gnugetopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
138 getopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
139 /usr
/local
/opt
/gnu-getopt
/bin
/getopt
-o t
--long
test -- --test | grep
'^ *--test *--', \
140 /opt
/local
/bin
/getopt
-o t
--long
test -- --test | grep
'^ *--test *--'))
142 $(eval
$(call SetupHostCommand
,realpath
,Please
install a
'realpath' utility
, \
146 $(eval
$(call SetupHostCommand
,stat
,Cannot find a file stat utility
, \
147 gnustat
-c
%s
$(TOPDIR
)/Makefile
, \
148 gstat
-c
%s
$(TOPDIR
)/Makefile
, \
149 stat
-c
%s
$(TOPDIR
)/Makefile
))
151 $(eval
$(call SetupHostCommand
,gzip
,Please
install 'gzip', \
152 gzip
--version
</dev
/null
))
154 $(eval
$(call SetupHostCommand
,unzip
,Please
install 'unzip', \
155 unzip
2>&1 | grep zipfile
, \
158 $(eval
$(call SetupHostCommand
,bzip2
,Please
install 'bzip2', \
159 bzip2
--version
</dev
/null
))
161 $(eval
$(call SetupHostCommand
,wget
,Please
install GNU
'wget', \
162 wget
--version | grep GNU
))
164 $(eval
$(call SetupHostCommand
,install,Please
install GNU
'install', \
165 install --version | grep GNU
, \
166 ginstall
--version | grep GNU
))
168 $(eval
$(call SetupHostCommand
,perl
,Please
install Perl
5.x
, \
169 perl
--version | grep
"perl.*v5"))
171 $(eval
$(call CleanupPython2
))
173 $(eval
$(call SetupHostCommand
,python
,Please
install Python
>= 3.6, \
174 python3.11
-V
2>&1 | grep
'Python 3', \
175 python3.10
-V
2>&1 | grep
'Python 3', \
176 python3.9
-V
2>&1 | grep
'Python 3', \
177 python3.8
-V
2>&1 | grep
'Python 3', \
178 python3.7
-V
2>&1 | grep
'Python 3', \
179 python3.6
-V
2>&1 | grep
'Python 3', \
180 python3
-V
2>&1 | grep
-E
'Python 3\.([6-9]|[0-9][0-9])\.?'))
182 $(eval
$(call SetupHostCommand
,python3
,Please
install Python
>= 3.6, \
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.6
-V
2>&1 | grep
'Python 3', \
189 python3
-V
2>&1 | grep
-E
'Python 3\.([6-9]|[0-9][0-9])\.?'))
191 $(eval
$(call TestHostCommand
,python3-distutils
, \
192 Please
install the Python3 distutils module
, \
193 $(STAGING_DIR_HOST
)/bin
/python3
-c
'from distutils import util'))
195 $(eval
$(call TestHostCommand
,python3-stdlib
, \
196 Please
install the Python3 stdlib module
, \
197 $(STAGING_DIR_HOST
)/bin
/python3
-c
'import ntpath'))
199 $(eval
$(call SetupHostCommand
,file
,Please
install the
'file' package
, \
200 file
--version
2>&1 | grep file
))
202 $(eval
$(call SetupHostCommand
,which
,Please
install 'which', \
203 /usr
/bin
/which which
, \
207 ifeq ($(HOST_OS
),Linux
)
208 $(eval
$(call RequireCHeader
,argp.h
, \
209 Missing argp.h Please
install the argp-standalone package if musl libc
))
211 $(eval
$(call RequireCHeader
,fts.h
, \
212 Missing fts.h Please
install the musl-fts-dev package if musl libc
))
214 $(eval
$(call RequireCHeader
,obstack.h
, \
215 Missing obstack.h Please
install the musl-obstack-dev package if musl libc
))
217 $(eval
$(call RequireCHeader
,libintl.h
, \
218 Missing libintl.h Please
install the musl-libintl package if musl libc
))
221 $(STAGING_DIR_HOST
)/bin
/mkhash
: $(SCRIPT_DIR
)/mkhash.c
223 $(CC
) -O2
-I
$(TOPDIR
)/tools
/include -o
$@
$<
225 $(STAGING_DIR_HOST
)/bin
/xxd
: $(SCRIPT_DIR
)/xxdi.pl
228 prereq
: $(STAGING_DIR_HOST
)/bin
/mkhash
$(STAGING_DIR_HOST
)/bin
/xxd
230 # Install ldconfig stub
231 $(eval
$(call TestHostCommand
,ldconfig-stub
,Failed to
install stub
, \
232 $(LN
) $(firstword $(wildcard /bin
/true
/usr
/bin
/true
)) $(STAGING_DIR_HOST
)/bin
/ldconfig
))