prereq-build.mk 7.8 KB

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