prereq-build.mk 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. libreCMC 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 TestHostCommand,perl-time-piece, \
  77. Please install the Perl Time::Piece module, \
  78. perl -MTime::Piece -e 1))
  79. $(eval $(call TestHostCommand,perl-json-pp, \
  80. Please install the Perl JSON::PP module, \
  81. perl -MJSON::PP -e 1))
  82. $(eval $(call TestHostCommand,perl-ipc-cmd, \
  83. Please install the Perl IPC::Cmd module, \
  84. perl -MIPC::Cmd -e 1))
  85. $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
  86. gtar --version 2>&1 | grep GNU, \
  87. gnutar --version 2>&1 | grep GNU, \
  88. tar --version 2>&1 | grep GNU))
  89. $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
  90. gfind --version 2>&1 | grep GNU, \
  91. find --version 2>&1 | grep GNU))
  92. $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
  93. bash --version 2>&1 | grep GNU))
  94. $(eval $(call SetupHostCommand,xargs, \
  95. Please install 'xargs' that supports '-r/--no-run-if-empty', \
  96. gxargs -r --version, \
  97. xargs -r --version))
  98. $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
  99. gpatch --version 2>&1 | grep 'Free Software Foundation', \
  100. patch --version 2>&1 | grep 'Free Software Foundation'))
  101. $(eval $(call SetupHostCommand,diff,Please install GNU diffutils, \
  102. gdiff --version 2>&1 | grep GNU, \
  103. diff --version 2>&1 | grep GNU))
  104. $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
  105. gcp --help 2>&1 | grep 'Copy SOURCE', \
  106. cp --help 2>&1 | grep 'Copy SOURCE'))
  107. $(eval $(call SetupHostCommand,seq,Please install seq, \
  108. gseq --version, \
  109. seq --version 2>&1 | grep seq))
  110. $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
  111. gawk --version 2>&1 | grep GNU, \
  112. awk --version 2>&1 | grep GNU))
  113. $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
  114. ggrep --version 2>&1 | grep GNU, \
  115. grep --version 2>&1 | grep GNU))
  116. $(eval $(call SetupHostCommand,egrep,Please install GNU 'grep', \
  117. gegrep --version 2>&1 | grep GNU, \
  118. egrep --version 2>&1 | grep GNU))
  119. $(eval $(call SetupHostCommand,getopt, \
  120. Please install an extended getopt version that supports --long, \
  121. gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
  122. getopt -o t --long test -- --test | grep '^ *--test *--', \
  123. /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
  124. /opt/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
  125. $(eval $(call SetupHostCommand,realpath,Please install a 'realpath' utility, \
  126. grealpath /, \
  127. realpath /))
  128. $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
  129. gnustat -c%s $(TOPDIR)/Makefile, \
  130. gstat -c%s $(TOPDIR)/Makefile, \
  131. stat -c%s $(TOPDIR)/Makefile))
  132. $(eval $(call SetupHostCommand,gzip,Please install 'gzip', \
  133. gzip --version </dev/null))
  134. $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
  135. unzip 2>&1 | grep zipfile, \
  136. unzip))
  137. $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
  138. bzip2 --version </dev/null))
  139. $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
  140. wget --version | grep GNU))
  141. $(eval $(call SetupHostCommand,install,Please install GNU 'install', \
  142. install --version | grep GNU, \
  143. ginstall --version | grep GNU))
  144. $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
  145. perl --version | grep "perl.*v5"))
  146. $(eval $(call SetupHostCommand,python,Please install Python >= 3.6, \
  147. python3.11 -V 2>&1 | grep 'Python 3', \
  148. python3.10 -V 2>&1 | grep 'Python 3', \
  149. python3.9 -V 2>&1 | grep 'Python 3', \
  150. python3.8 -V 2>&1 | grep 'Python 3', \
  151. python3.7 -V 2>&1 | grep 'Python 3', \
  152. python3.6 -V 2>&1 | grep 'Python 3', \
  153. python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?'))
  154. $(eval $(call SetupHostCommand,python3,Please install Python >= 3.6, \
  155. python3.11 -V 2>&1 | grep 'Python 3', \
  156. python3.10 -V 2>&1 | grep 'Python 3', \
  157. python3.9 -V 2>&1 | grep 'Python 3', \
  158. python3.8 -V 2>&1 | grep 'Python 3', \
  159. python3.7 -V 2>&1 | grep 'Python 3', \
  160. python3.6 -V 2>&1 | grep 'Python 3', \
  161. python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?'))
  162. $(eval $(call TestHostCommand,python3-distutils, \
  163. Please install the Python3 distutils module, \
  164. $(STAGING_DIR_HOST)/bin/python3 -c 'from distutils import util'))
  165. $(eval $(call TestHostCommand,python3-stdlib, \
  166. Please install the Python3 stdlib module, \
  167. $(STAGING_DIR_HOST)/bin/python3 -c 'import ntpath'))
  168. $(eval $(call TestHostCommand,python3-jsmin, \
  169. Please install the jsmin Python module, \
  170. python3 -c "import jsmin" 2>&1 ))
  171. $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
  172. file --version 2>&1 | grep file))
  173. $(eval $(call SetupHostCommand,which,Please install 'which', \
  174. /usr/bin/which which, \
  175. /bin/which which, \
  176. which which))
  177. ifeq ($(HOST_OS),Linux)
  178. $(eval $(call RequireCHeader,argp.h, \
  179. Missing argp.h Please install the argp-standalone package if musl libc))
  180. $(eval $(call RequireCHeader,fts.h, \
  181. Missing fts.h Please install the musl-fts-dev package if musl libc))
  182. $(eval $(call RequireCHeader,obstack.h, \
  183. Missing obstack.h Please install the musl-obstack-dev package if musl libc))
  184. $(eval $(call RequireCHeader,libintl.h, \
  185. Missing libintl.h Please install the musl-libintl package if musl libc))
  186. endif
  187. $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
  188. mkdir -p $(dir $@)
  189. $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
  190. $(STAGING_DIR_HOST)/bin/xxd: $(SCRIPT_DIR)/xxdi.pl
  191. $(LN) $< $@
  192. prereq: $(STAGING_DIR_HOST)/bin/mkhash $(STAGING_DIR_HOST)/bin/xxd
  193. # Install ldconfig stub
  194. $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
  195. $(LN) $(firstword $(wildcard /bin/true /usr/bin/true)) $(STAGING_DIR_HOST)/bin/ldconfig))