prereq-build.mk 8.1 KB

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