prereq-build.mk 5.6 KB

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