2
0

prereq-build.mk 3.3 KB

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