prereq-build.mk 7.9 KB

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