prereq-build.mk 6.2 KB

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