prereq-build.mk 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. $(eval $(call SetupHostCommand,gcc, \
  23. Please install the GNU C Compiler (gcc) 4.8 or later, \
  24. $(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
  25. gcc -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
  26. gcc --version | grep -E 'Apple.(LLVM|clang)' ))
  27. $(eval $(call TestHostCommand,working-gcc, \
  28. \nPlease reinstall the GNU C Compiler (4.8 or later) - \
  29. it appears to be broken, \
  30. echo 'int main(int argc, char **argv) { return 0; }' | \
  31. gcc -x c -o $(TMP_DIR)/a.out -))
  32. $(eval $(call SetupHostCommand,g++, \
  33. Please install the GNU C++ Compiler (g++) 4.8 or later, \
  34. $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
  35. g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
  36. g++ --version | grep -E 'Apple.(LLVM|clang)' ))
  37. $(eval $(call TestHostCommand,working-g++, \
  38. \nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
  39. it appears to be broken, \
  40. echo 'int main(int argc, char **argv) { return 0; }' | \
  41. g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
  42. $(TMP_DIR)/a.out))
  43. ifndef IB
  44. $(eval $(call TestHostCommand,ncurses, \
  45. Please install ncurses. (Missing libncurses.so or ncurses.h), \
  46. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  47. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
  48. endif
  49. ifeq ($(HOST_OS),Linux)
  50. zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
  51. else
  52. zlib_link_flags := -lz
  53. endif
  54. $(eval $(call TestHostCommand,perl-data-dumper, \
  55. Please install the Perl Data::Dumper module, \
  56. perl -MData::Dumper -e 1))
  57. $(eval $(call TestHostCommand,perl-thread-queue, \
  58. Please install the Perl Thread::Queue module, \
  59. perl -MThread::Queue -e 1))
  60. $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
  61. gtar --version 2>&1 | grep GNU, \
  62. gnutar --version 2>&1 | grep GNU, \
  63. tar --version 2>&1 | grep GNU))
  64. $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
  65. gfind --version 2>&1 | grep GNU, \
  66. find --version 2>&1 | grep GNU))
  67. $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
  68. bash --version 2>&1 | grep GNU))
  69. $(eval $(call SetupHostCommand,xargs, \
  70. Please install 'xargs' that supports '-r/--no-run-if-empty', \
  71. gxargs -r --version, \
  72. xargs -r --version))
  73. $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
  74. gpatch --version 2>&1 | grep 'Free Software Foundation', \
  75. patch --version 2>&1 | grep 'Free Software Foundation'))
  76. $(eval $(call SetupHostCommand,diff,Please install diffutils, \
  77. gdiff --version 2>&1 | grep diff, \
  78. diff --version 2>&1 | grep diff))
  79. $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
  80. gcp --help 2>&1 | grep 'Copy SOURCE', \
  81. cp --help 2>&1 | grep 'Copy SOURCE'))
  82. $(eval $(call SetupHostCommand,seq,Please install seq, \
  83. gseq --version, \
  84. seq --version 2>&1 | grep seq))
  85. $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
  86. gawk --version 2>&1 | grep GNU, \
  87. awk --version 2>&1 | grep GNU))
  88. $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
  89. ggrep --version 2>&1 | grep GNU, \
  90. grep --version 2>&1 | grep GNU))
  91. $(eval $(call SetupHostCommand,egrep,Please install GNU 'grep', \
  92. gegrep --version 2>&1 | grep GNU, \
  93. egrep --version 2>&1 | grep GNU))
  94. $(eval $(call SetupHostCommand,getopt, \
  95. Please install an extended getopt version that supports --long, \
  96. gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
  97. getopt -o t --long test -- --test | grep '^ *--test *--'))
  98. $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
  99. gnustat -c%s $(TOPDIR)/Makefile, \
  100. gstat -c%s $(TOPDIR)/Makefile, \
  101. stat -c%s $(TOPDIR)/Makefile))
  102. $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
  103. unzip 2>&1 | grep zipfile, \
  104. unzip))
  105. $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
  106. bzip2 --version </dev/null))
  107. $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
  108. wget --version | grep GNU))
  109. $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
  110. perl --version | grep "perl.*v5"))
  111. $(eval $(call CleanupPython2))
  112. $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
  113. python3.8 -V 2>&1 | grep 'Python 3', \
  114. python3.7 -V 2>&1 | grep 'Python 3', \
  115. python3.6 -V 2>&1 | grep 'Python 3', \
  116. python3.5 -V 2>&1 | grep 'Python 3', \
  117. python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
  118. $(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \
  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,git,Please install Git (git-core) >= 1.7.12.2, \
  125. git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
  126. $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
  127. file --version 2>&1 | grep file))
  128. $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
  129. mkdir -p $(dir $@)
  130. $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
  131. prereq: $(STAGING_DIR_HOST)/bin/mkhash
  132. # Install ldconfig stub
  133. $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
  134. touch $(STAGING_DIR_HOST)/bin/ldconfig && \
  135. chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))