prereq-build.mk 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. include $(INCLUDE_DIR)/host.mk
  10. include $(INCLUDE_DIR)/host-build.mk
  11. PKG_NAME:=Build dependency
  12. define Require/non-root
  13. [ "$$(shell whoami)" != "root" ]
  14. endef
  15. $(eval $(call Require,non-root, \
  16. Please do not compile as root. \
  17. ))
  18. # Required for the toolchain
  19. define Require/working-make
  20. $(MAKE) -v | awk '($$$$1 == "GNU") && ($$$$2 == "Make") && ($$$$3 >= "3.81") { print "ok" }' | grep ok > /dev/null
  21. endef
  22. $(eval $(call Require,working-make, \
  23. Please install GNU make v3.81 or later. (This version has bugs) \
  24. ))
  25. define Require/case-sensitive-fs
  26. rm -f $(TMP_DIR)/test.*
  27. touch $(TMP_DIR)/test.fs
  28. [ \! -f $(TMP_DIR)/test.FS ]
  29. endef
  30. $(eval $(call Require,case-sensitive-fs, \
  31. OpenWrt can only be built on a case-sensitive filesystem \
  32. ))
  33. define Require/getopt
  34. getopt --help 2>&1 | grep long >/dev/null
  35. endef
  36. $(eval $(call Require,getopt, \
  37. Please install GNU getopt \
  38. ))
  39. define Require/fileutils
  40. gcp --help || cp --help
  41. endef
  42. $(eval $(call Require,fileutils, \
  43. Please install GNU fileutils \
  44. ))
  45. define Require/working-gcc
  46. echo 'int main(int argc, char **argv) { return 0; }' | \
  47. gcc -x c -o $(TMP_DIR)/a.out -
  48. endef
  49. $(eval $(call Require,working-gcc, \
  50. Please install the GNU C Compiler (gcc). \
  51. ))
  52. define Require/working-g++
  53. echo 'int main(int argc, char **argv) { return 0; }' | \
  54. g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
  55. $(TMP_DIR)/a.out
  56. endef
  57. $(eval $(call Require,working-g++, \
  58. Please install the GNU C++ Compiler (g++). \
  59. ))
  60. ifneq ($(HOST_STATIC_LINKING),)
  61. define Require/working-gcc-static
  62. echo 'int main(int argc, char **argv) { return 0; }' | \
  63. gcc -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out -
  64. endef
  65. $(eval $(call Require,working-gcc-static, \
  66. Please install the static libc development package (glibc-static on CentOS/Fedora/RHEL). \
  67. ))
  68. define Require/working-g++-static
  69. echo 'int main(int argc, char **argv) { return 0; }' | \
  70. g++ -x c++ $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lstdc++ && \
  71. $(TMP_DIR)/a.out
  72. endef
  73. $(eval $(call Require,working-g++-static, \
  74. Please install the static libstdc++ development package (libstdc++-static on CentOS/Fedora/RHEL). \
  75. ))
  76. endif
  77. define Require/ncurses
  78. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  79. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses
  80. endef
  81. $(eval $(call Require,ncurses, \
  82. Please install ncurses. (Missing libncurses.so or ncurses.h) \
  83. ))
  84. define Require/zlib
  85. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  86. gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - -lz
  87. endef
  88. $(eval $(call Require,zlib, \
  89. Please install zlib. (Missing libz.so or zlib.h) \
  90. ))
  91. ifneq ($(HOST_STATIC_LINKING),)
  92. define Require/zlib-static
  93. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  94. gcc -include zlib.h -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lz
  95. endef
  96. $(eval $(call Require,zlib-static, \
  97. Please install a static zlib. (zlib-static on CentOS/Fedora/RHEL). \
  98. ))
  99. endif
  100. $(eval $(call RequireCommand,gawk, \
  101. Please install GNU awk. \
  102. ))
  103. $(eval $(call RequireCommand,unzip, \
  104. Please install unzip. \
  105. ))
  106. $(eval $(call RequireCommand,bzip2, \
  107. Please install bzip2. \
  108. ))
  109. $(eval $(call RequireCommand,patch, \
  110. Please install patch. \
  111. ))
  112. $(eval $(call RequireCommand,perl, \
  113. Please install perl. \
  114. ))
  115. $(eval $(call RequireCommand,python, \
  116. Please install python. \
  117. ))
  118. $(eval $(call RequireCommand,wget, \
  119. Please install wget. \
  120. ))
  121. define Require/git
  122. git --version | awk '($$$$1 == "git") && ($$$$2 == "version") && ($$$$3 >= "1.6.5") { print "ok" }' | grep ok > /dev/null
  123. endef
  124. $(eval $(call Require,git, \
  125. Please install git (git-core) v1.6.5 or later. \
  126. ))
  127. define Require/gnutar
  128. $(TAR) --version 2>&1 | grep GNU > /dev/null
  129. endef
  130. $(eval $(call Require,gnutar, \
  131. Please install GNU tar. \
  132. ))
  133. $(eval $(call RequireCommand,svn, \
  134. Please install the subversion client. \
  135. ))
  136. define Require/gnu-find
  137. $(FIND) --version 2>/dev/null
  138. endef
  139. $(eval $(call Require,gnu-find, \
  140. Please install GNU find \
  141. ))
  142. define Require/getopt-extended
  143. getopt --long - - >/dev/null
  144. endef
  145. $(eval $(call Require,getopt-extended, \
  146. Please install an extended getopt version that supports --long \
  147. ))