prereq-build.mk 7.4 KB

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