prereq-build.mk 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. endif # IB
  46. ifeq ($(HOST_OS),Linux)
  47. zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
  48. else
  49. zlib_link_flags := -lz
  50. endif
  51. $(eval $(call TestHostCommand,perl-data-dumper, \
  52. Please install the Perl Data::Dumper module, \
  53. perl -MData::Dumper -e 1))
  54. $(eval $(call TestHostCommand,perl-findbin, \
  55. Please install the Perl FindBin module, \
  56. perl -MFindBin -e 1))
  57. $(eval $(call TestHostCommand,perl-file-copy, \
  58. Please install the Perl File::Copy module, \
  59. perl -MFile::Copy -e 1))
  60. $(eval $(call TestHostCommand,perl-file-compare, \
  61. Please install the Perl File::Compare module, \
  62. perl -MFile::Compare -e 1))
  63. $(eval $(call TestHostCommand,perl-thread-queue, \
  64. Please install the Perl Thread::Queue module, \
  65. perl -MThread::Queue -e 1))
  66. $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
  67. gtar --version 2>&1 | grep GNU, \
  68. gnutar --version 2>&1 | grep GNU, \
  69. tar --version 2>&1 | grep GNU))
  70. $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
  71. gfind --version 2>&1 | grep GNU, \
  72. find --version 2>&1 | grep GNU))
  73. $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
  74. bash --version 2>&1 | grep GNU))
  75. $(eval $(call SetupHostCommand,xargs, \
  76. Please install 'xargs' that supports '-r/--no-run-if-empty', \
  77. gxargs -r --version, \
  78. xargs -r --version))
  79. $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
  80. gpatch --version 2>&1 | grep 'Free Software Foundation', \
  81. patch --version 2>&1 | grep 'Free Software Foundation'))
  82. $(eval $(call SetupHostCommand,diff,Please install GNU diffutils, \
  83. gdiff --version 2>&1 | grep GNU, \
  84. diff --version 2>&1 | grep GNU))
  85. $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
  86. gcp --help 2>&1 | grep 'Copy SOURCE', \
  87. cp --help 2>&1 | grep 'Copy SOURCE'))
  88. $(eval $(call SetupHostCommand,seq,Please install seq, \
  89. gseq --version, \
  90. seq --version 2>&1 | grep seq))
  91. $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
  92. gawk --version 2>&1 | grep GNU, \
  93. awk --version 2>&1 | grep GNU))
  94. $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
  95. ggrep --version 2>&1 | grep GNU, \
  96. grep --version 2>&1 | grep GNU))
  97. $(eval $(call SetupHostCommand,egrep,Please install GNU 'grep', \
  98. gegrep --version 2>&1 | grep GNU, \
  99. egrep --version 2>&1 | grep GNU))
  100. $(eval $(call SetupHostCommand,getopt, \
  101. Please install an extended getopt version that supports --long, \
  102. gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
  103. getopt -o t --long test -- --test | grep '^ *--test *--', \
  104. /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
  105. $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
  106. gnustat -c%s $(TOPDIR)/Makefile, \
  107. gstat -c%s $(TOPDIR)/Makefile, \
  108. stat -c%s $(TOPDIR)/Makefile))
  109. $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
  110. unzip 2>&1 | grep zipfile, \
  111. unzip))
  112. $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
  113. bzip2 --version </dev/null))
  114. $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
  115. wget --version | grep GNU))
  116. $(eval $(call SetupHostCommand,install,Please install GNU 'install', \
  117. install --version | grep GNU, \
  118. ginstall --version | grep GNU))
  119. $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
  120. perl --version | grep "perl.*v5"))
  121. $(eval $(call CleanupPython2))
  122. $(eval $(call SetupHostCommand,python,Please install Python >= 3.6, \
  123. python3.10 -V 2>&1 | grep 'Python 3', \
  124. python3.9 -V 2>&1 | grep 'Python 3', \
  125. python3.8 -V 2>&1 | grep 'Python 3', \
  126. python3.7 -V 2>&1 | grep 'Python 3', \
  127. python3.6 -V 2>&1 | grep 'Python 3', \
  128. python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|10)\.?'))
  129. $(eval $(call SetupHostCommand,python3,Please install Python >= 3.6, \
  130. python3.10 -V 2>&1 | grep 'Python 3', \
  131. python3.9 -V 2>&1 | grep 'Python 3', \
  132. python3.8 -V 2>&1 | grep 'Python 3', \
  133. python3.7 -V 2>&1 | grep 'Python 3', \
  134. python3.6 -V 2>&1 | grep 'Python 3', \
  135. python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|10)\.?'))
  136. $(eval $(call TestHostCommand,python3-distutils, \
  137. Please install the Python3 distutils module, \
  138. $(STAGING_DIR_HOST)/bin/python3 -c 'import distutils'))
  139. $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
  140. git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
  141. $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
  142. file --version 2>&1 | grep file))
  143. $(eval $(call SetupHostCommand,rsync,Please install 'rsync', \
  144. rsync --version </dev/null))
  145. $(eval $(call SetupHostCommand,which,Please install 'which', \
  146. /usr/bin/which which, \
  147. /bin/which which, \
  148. which which))
  149. $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
  150. mkdir -p $(dir $@)
  151. $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
  152. prereq: $(STAGING_DIR_HOST)/bin/mkhash
  153. # Install ldconfig stub
  154. $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
  155. touch $(STAGING_DIR_HOST)/bin/ldconfig && \
  156. chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))